Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2012-06-21 19:36:38 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2012-06-21 19:36:38 +0400
commit994f6a67917b778b2bfdc9cf3eb9ced087143315 (patch)
tree05bfa2963b85174a5085937a80e093f8f1718fb2
parent55652eda9684b582ea489f8369721186b3125ea0 (diff)
add MediaInfoLib and ZenLib to the repo
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@5220 10f7b99b-c216-0410-bff0-8a66a9350fd8
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_7z.cpp85
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_7z.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Ace.cpp86
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Ace.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Bzip2.cpp90
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Bzip2.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Elf.cpp244
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Elf.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Gzip.cpp96
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Gzip.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Iso9660.cpp122
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Iso9660.h55
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Mz.cpp177
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Mz.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Rar.cpp329
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Rar.h78
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Tar.cpp109
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Tar.h49
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Zip.cpp483
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Archive/File_Zip.h70
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac.cpp682
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac.h378
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio.cpp1439
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio.h2848
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.cpp752
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.h728
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr_Ps.cpp110
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr_Ps.h150
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_Main.cpp1124
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_Others.cpp472
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ac3.cpp2090
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ac3.h175
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Adpcm.cpp89
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Adpcm.h53
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aes3.cpp1880
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aes3.h114
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Als.cpp151
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Als.h63
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amr.cpp275
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amr.h75
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amv.cpp59
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amv.h49
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ape.cpp221
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ape.h67
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Au.cpp187
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Au.h50
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Celt.cpp161
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Celt.h65
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_ChannelGrouping.cpp333
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_ChannelGrouping.h147
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_DolbyE.cpp126
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_DolbyE.h64
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Dts.cpp1333
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Dts.h118
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_ExtendedModule.cpp120
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_ExtendedModule.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Flac.cpp267
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Flac.h95
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_ImpulseTracker.cpp140
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_ImpulseTracker.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_La.cpp158
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_La.h63
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Midi.cpp59
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Midi.h49
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Module.cpp116
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Module.h53
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpc.cpp224
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpc.h62
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_MpcSv8.cpp257
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_MpcSv8.h77
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpega.cpp1591
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpega.h118
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Pcm.cpp488
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Pcm.h70
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ps2Audio.cpp135
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ps2Audio.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Rkau.cpp155
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Rkau.h66
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_ScreamTracker3.cpp138
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_ScreamTracker3.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Speex.cpp165
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Speex.h64
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tak.cpp311
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tak.h77
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tta.cpp145
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tta.h65
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_TwinVQ.cpp214
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_TwinVQ.h70
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Vorbis.cpp261
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Vorbis.h58
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Wvpk.cpp734
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Audio/File_Wvpk.h97
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate_MpegTs.cpp492
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate_MpegTs.h158
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Base.cpp51
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Base.h51
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Writer.cpp167
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Writer.h81
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Export/Export_Mpeg7.cpp1563
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Export/Export_Mpeg7.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Export/Export_PBCore.cpp404
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Export/Export_PBCore.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Export/Export_reVTMD.cpp9
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Export/Export_reVTMD.h1
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File_Dummy.cpp326
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File_Dummy.h60
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File_Other.cpp190
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File_Other.h51
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File_Unknown.cpp67
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File_Unknown.h53
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Analyse_Automatic.h1324
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Analyze.cpp3085
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Analyze.h1484
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Buffer.cpp2464
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Buffer_MinimizeSize.cpp1655
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Analyze_MinimizeSize.h1339
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Streams.cpp2533
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Streams_Finish.cpp631
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Base.cpp229
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Base.h128
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Duplicate.cpp100
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__Duplicate.h65
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__MultipleParsing.cpp710
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/File__MultipleParsing.h66
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Bmp.cpp223
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Bmp.h57
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Dpx.cpp848
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Dpx.h94
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Exr.cpp350
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Exr.h89
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Gif.cpp114
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Gif.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Ico.cpp162
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Ico.h76
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Jpeg.cpp885
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Jpeg.h176
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Png.cpp322
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Png.h81
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Rle.cpp88
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Rle.h55
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Tga.cpp312
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Tga.h80
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Tiff.cpp558
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Image/File_Tiff.h81
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo.cpp247
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo.h257
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfoList.cpp260
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfoList.h225
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfoList_Internal.cpp454
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfoList_Internal.h97
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config.cpp2075
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config.h317
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_Automatic.cpp5611
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_MediaInfo.cpp1674
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_MediaInfo.h340
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Const.h143
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Events.h673
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Events_Internal.h74
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_File.cpp972
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Inform.cpp623
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal.cpp1122
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal.h189
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal_Const.h151
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ancillary.cpp469
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ancillary.h107
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Bdmv.cpp1624
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Bdmv.h93
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Cdxa.cpp321
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Cdxa.h73
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dcp.cpp182
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dcp.h69
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dpg.cpp191
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dpg.h71
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif.cpp1842
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif.h361
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif_Analysis.cpp1629
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dvdv.cpp1586
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dvdv.h129
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dxw.cpp211
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dxw.h69
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Flv.cpp1519
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Flv.h124
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf.cpp1469
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf.h168
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf_TimeCode.cpp207
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf_TimeCode.h70
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Hls.cpp198
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Hls.h69
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi.cpp765
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi.h95
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi_Creation.cpp445
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi_Creation.h129
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ism.cpp202
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ism.h68
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ivf.cpp134
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ivf.h55
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Lxf.cpp1312
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Lxf.h155
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mk.cpp3432
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mk.h354
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4.cpp1596
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4.h483
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Descriptors.cpp1008
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Descriptors.h144
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Elements.cpp6050
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_TimeCode.cpp99
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_TimeCode.h59
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegPs.cpp4506
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegPs.h305
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs.cpp2499
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs.h171
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs_Duplicate.cpp359
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Descriptors.cpp3125
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Descriptors.h666
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Psi.cpp2608
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Psi.h183
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mxf.cpp9156
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mxf.h800
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Nut.cpp300
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Nut.h59
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg.cpp406
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg.h110
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg_SubElement.cpp881
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg_SubElement.h102
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_P2_Clip.cpp405
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_P2_Clip.h69
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff.cpp911
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff.h328
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff_Elements.cpp3538
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Rm.cpp794
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Rm.h76
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_SequenceInfo.cpp258
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_SequenceInfo.h69
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Skm.cpp201
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Skm.h83
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Swf.cpp706
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Swf.h130
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Umf.cpp253
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Umf.h63
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm.cpp257
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm.h190
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm_Elements.cpp1730
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Xdcam_Clip.cpp160
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Xdcam_Clip.h50
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File__ReferenceFilesHelper.cpp888
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Multiple/File__ReferenceFilesHelper.h128
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/PreComp.cpp27
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/PreComp.h39
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_Directory.cpp244
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_Directory.h68
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_File.cpp419
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_File.h62
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Reader/Reader__Base.h56
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl.cpp814
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl.h63
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl_Include.h984
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libmms.cpp175
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libmms.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Setup.h675
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_ApeTag.cpp214
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_ApeTag.h60
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3.cpp140
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3.h49
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3v2.cpp1350
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3v2.h248
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3.cpp99
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3.h56
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3v2.cpp237
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3v2.h73
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_VorbisCom.cpp356
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File_VorbisCom.h75
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File__Tags.cpp604
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Tag/File__Tags.h105
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Cdp.cpp502
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Cdp.h98
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Cmml.cpp122
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Cmml.h58
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_DtvccTransport.cpp336
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_DtvccTransport.h91
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_DvbSubtitle.cpp421
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_DvbSubtitle.h110
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia608.cpp969
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia608.h151
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia708.cpp1367
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia708.h187
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Kate.cpp158
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Kate.h56
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_N19.cpp383
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_N19.h59
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_OtherText.cpp219
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_OtherText.h48
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Pgs.cpp77
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Pgs.h52
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Scc.cpp217
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Scc.h65
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Scte20.cpp282
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Scte20.h93
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Teletext.cpp101
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Text/File_Teletext.h58
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/TimeCode.cpp152
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/TimeCode.h109
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_AfdBarData.cpp368
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_AfdBarData.h102
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc.cpp3504
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc.h394
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc_Duplicate.cpp274
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_AvsV.cpp834
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_AvsV.h122
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Dirac.cpp902
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Dirac.h114
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Flic.cpp148
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Flic.h49
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Fraps.cpp151
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Fraps.h61
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_H263.cpp433
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_H263.h83
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Lagarith.cpp106
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Lagarith.h56
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpeg4v.cpp1857
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpeg4v.h201
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpegv.cpp3775
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpegv.h341
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Theora.cpp145
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Theora.h58
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc1.cpp1143
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc1.h165
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc3.cpp383
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc3.h91
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Vp8.cpp126
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Vp8.h64
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Y4m.cpp242
-rw-r--r--src/thirdparty/MediaInfo/MediaInfo/Video/File_Y4m.h62
-rw-r--r--src/thirdparty/MediaInfo/ThirdParty/base64/base64.h158
-rw-r--r--src/thirdparty/MediaInfo/ThirdParty/tinyxml2/tinyxml2.cpp1824
-rw-r--r--src/thirdparty/MediaInfo/ThirdParty/tinyxml2/tinyxml2.h1407
-rw-r--r--src/thirdparty/ZenLib/ZenLib/BitStream.h366
-rw-r--r--src/thirdparty/ZenLib/ZenLib/BitStream_Fast.h434
-rw-r--r--src/thirdparty/ZenLib/ZenLib/BitStream_LE.h147
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Conf.cpp59
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Conf.h372
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Conf_Internal.h41
-rw-r--r--src/thirdparty/ZenLib/ZenLib/CriticalSection.cpp204
-rw-r--r--src/thirdparty/ZenLib/ZenLib/CriticalSection.h84
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Dir.cpp335
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Dir.h70
-rw-r--r--src/thirdparty/ZenLib/ZenLib/File.cpp954
-rw-r--r--src/thirdparty/ZenLib/ZenLib/File.h113
-rw-r--r--src/thirdparty/ZenLib/ZenLib/FileName.cpp239
-rw-r--r--src/thirdparty/ZenLib/ZenLib/FileName.h81
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Handler.cpp71
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Handler.h91
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Request.cpp79
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Request.h77
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Cookies.cpp118
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Cookies.h91
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Handler.cpp70
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Handler.h87
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Request.cpp255
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Request.h81
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Utils.cpp251
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Utils.h80
-rw-r--r--src/thirdparty/ZenLib/ZenLib/HTTP_Client.cpp140
-rw-r--r--src/thirdparty/ZenLib/ZenLib/HTTP_Client.h64
-rw-r--r--src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClient.c3646
-rw-r--r--src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClient.h306
-rw-r--r--src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientAuth.c665
-rw-r--r--src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientAuth.h90
-rw-r--r--src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientCommon.h120
-rw-r--r--src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientString.c424
-rw-r--r--src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientString.h23
-rw-r--r--src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientWrapper.c348
-rw-r--r--src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientWrapper.h111
-rw-r--r--src/thirdparty/ZenLib/ZenLib/InfoMap.cpp182
-rw-r--r--src/thirdparty/ZenLib/ZenLib/InfoMap.h77
-rw-r--r--src/thirdparty/ZenLib/ZenLib/MemoryDebug.cpp201
-rw-r--r--src/thirdparty/ZenLib/ZenLib/MemoryDebug.h130
-rw-r--r--src/thirdparty/ZenLib/ZenLib/OS_Utils.cpp233
-rw-r--r--src/thirdparty/ZenLib/ZenLib/OS_Utils.h64
-rw-r--r--src/thirdparty/ZenLib/ZenLib/PreComp.cpp25
-rw-r--r--src/thirdparty/ZenLib/ZenLib/PreComp.h44
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Thread.cpp654
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Thread.h105
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Trace.h77
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Translation.cpp174
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Translation.h79
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Utils.cpp1042
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Utils.h320
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Ztring.cpp2420
-rw-r--r--src/thirdparty/ZenLib/ZenLib/Ztring.h372
-rw-r--r--src/thirdparty/ZenLib/ZenLib/ZtringList.cpp379
-rw-r--r--src/thirdparty/ZenLib/ZenLib/ZtringList.h103
-rw-r--r--src/thirdparty/ZenLib/ZenLib/ZtringListList.cpp605
-rw-r--r--src/thirdparty/ZenLib/ZenLib/ZtringListList.h146
-rw-r--r--src/thirdparty/ZenLib/ZenLib/ZtringListListF.cpp384
-rw-r--r--src/thirdparty/ZenLib/ZenLib/ZtringListListF.h91
-rw-r--r--src/thirdparty/ZenLib/ZenLib/int128s.cpp421
-rw-r--r--src/thirdparty/ZenLib/ZenLib/int128s.h205
-rw-r--r--src/thirdparty/ZenLib/ZenLib/int128u.cpp403
-rw-r--r--src/thirdparty/ZenLib/ZenLib/int128u.h201
399 files changed, 186342 insertions, 0 deletions
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_7z.cpp b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_7z.cpp
new file mode 100644
index 000000000..17e1e679e
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_7z.cpp
@@ -0,0 +1,85 @@
+// File_7z - Info for 7z files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_7Z_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Archive/File_7z.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_7z::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<6)
+ return false; //Must wait for more data
+
+ if (CC6(Buffer)!=0x377ABCAF271CLL) //"7z...."
+ {
+ Reject("7-Zip");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_7z::Read_Buffer_Continue()
+{
+ Skip_B6( "Magic");
+ Skip_XX(File_Size-6, "Data");
+
+ FILLING_BEGIN();
+ Accept("7-Zip");
+
+ Fill(Stream_General, 0, General_Format, "7-Zip");
+
+ Finish("7-Zip");
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_7Z_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_7z.h b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_7z.h
new file mode 100644
index 000000000..c160989b9
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_7z.h
@@ -0,0 +1,52 @@
+// File_7z - Info for 7z files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about 7z files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_7zH
+#define MediaInfo_File_7zH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_7z
+//***************************************************************************
+
+class File_7z : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Ace.cpp b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Ace.cpp
new file mode 100644
index 000000000..75994e14f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Ace.cpp
@@ -0,0 +1,86 @@
+// File_Ace - Info for ACE files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_ACE_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Archive/File_Ace.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Ace::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<7)
+ return false; //Must wait for more data
+
+ if (CC7(Buffer)!=0x2A2A4143452A2ALL) //"**ACE**"
+ {
+ Reject("Ace");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ace::Read_Buffer_Continue()
+{
+ //Parsing
+ Skip_B7( "Magic");
+ Skip_XX(File_Size-7, "Data");
+
+ FILLING_BEGIN();
+ Accept("Ace");
+
+ Fill(Stream_General, 0, General_Format, "ACE");
+
+ Finish("Ace");
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_ACE_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Ace.h b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Ace.h
new file mode 100644
index 000000000..3ea4a0f10
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Ace.h
@@ -0,0 +1,52 @@
+// File_Ace - Info for ACE files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about ACE files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_AceH
+#define MediaInfo_File_AceH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Ace
+//***************************************************************************
+
+class File_Ace : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Bzip2.cpp b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Bzip2.cpp
new file mode 100644
index 000000000..9fed97f0f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Bzip2.cpp
@@ -0,0 +1,90 @@
+// File_Bzip2 - Info for BZIP2 files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_BZIP2_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Archive/File_Bzip2.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Bzip2::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<2)
+ return false; //Must wait for more data
+
+ if (CC2(Buffer)!=0x425A) //"BZ"
+ {
+ Reject("Bzip2");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Bzip2::Read_Buffer_Continue()
+{
+ //Parsing
+ Skip_B7( "Magic");
+ Skip_XX(File_Size-2, "Data");
+
+ FILLING_BEGIN();
+ Accept("Bzip2");
+
+ Fill(Stream_General, 0, General_Format, "BZip2");
+
+ Finish("Bzip2");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_BZIP2_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Bzip2.h b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Bzip2.h
new file mode 100644
index 000000000..4351029dd
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Bzip2.h
@@ -0,0 +1,52 @@
+// File_Bzip2 - Info for PCM files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Bzip2 files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Bzip2H
+#define MediaInfo_File_Bzip2H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Bzip2
+//***************************************************************************
+
+class File_Bzip2 : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Elf.cpp b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Elf.cpp
new file mode 100644
index 000000000..8aeff8ac7
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Elf.cpp
@@ -0,0 +1,244 @@
+// File_Elf - Info for ELF files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_ELF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Archive/File_Elf.h"
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Elf_osabi(int8u osabi)
+{
+ switch (osabi)
+ {
+ case 0 : return "UNIX System V ABI";
+ case 1 : return "HP-UX";
+ case 2 : return "NetBSD";
+ case 3 : return "Linux";
+ case 6 : return "Sun Solaris";
+ case 7 : return "IBM AIX";
+ case 8 : return "SGI Irix";
+ case 9 : return "FreeBSD";
+ case 10 : return "Compaq TRU64 UNIX";
+ case 11 : return "Novell Modesto";
+ case 12 : return "OpenBSD";
+ case 97 : return "ARM";
+ case 255 : return "Standalone";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Elf_type(int16u type)
+{
+ switch (type)
+ {
+ case 1 : return "Relocatable";
+ case 2 : return "Executable";
+ case 3 : return "Shared object";
+ case 4 : return "Core";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Elf_machine(int16u machine)
+{
+ switch (machine)
+ {
+ case 1 : return "AT&T WE 32100";
+ case 2 : return "SUN SPARC";
+ case 3 : return "Intel i386";
+ case 4 : return "Motorola m68k";
+ case 5 : return "Motorola m88k";
+ case 7 : return "Intel i860";
+ case 8 : return "MIPS R3000";
+ case 9 : return "IBM System/370";
+ case 10 : return "MIPS R3000";
+
+ case 15 : return "HPPA";
+ case 17 : return "Fujitsu VPP500";
+ case 18 : return "Sun v8plus";
+ case 19 : return "Intel i960";
+ case 20 : return "PowerPC";
+ case 21 : return "PowerPC 64-bit";
+ case 22 : return "IBM S390";
+
+ case 36 : return "NEC V800";
+ case 37 : return "Fujitsu FR20";
+ case 38 : return "TRW RH-32";
+ case 39 : return "Motorola RCE";
+ case 40 : return "ARM";
+ case 41 : return "DEC Alpha";
+ case 42 : return "Hitachi SH";
+ case 43 : return "SPARC v9 64-bit";
+ case 44 : return "Siemens Tricore";
+ case 45 : return "Argonaut RISC Core";
+ case 46 : return "Hitachi H8/300";
+ case 47 : return "Hitachi H8/300H";
+ case 48 : return "Hitachi H8S";
+ case 49 : return "Hitachi H8/500";
+ case 50 : return "Intel IA64";
+ case 51 : return "Stanford MIPS-X";
+ case 52 : return "Motorola Coldfire";
+ case 53 : return "Motorola M68HC12";
+ case 54 : return "Fujitsu MMA";
+ case 55 : return "Siemens PCP";
+ case 56 : return "Sony nCPU";
+ case 57 : return "Denso NDR1";
+ case 58 : return "Motorola Start*Core";
+ case 59 : return "Toyota ME16";
+ case 60 : return "STMicroelectronic ST100";
+ case 61 : return "Advanced Logic Corp. Tinyj";
+ case 62 : return "AMD x86-64";
+ case 63 : return "Sony DSP";
+
+ case 66 : return "Siemens FX66";
+ case 67 : return "STMicroelectronics ST9+";
+ case 68 : return "STmicroelectronics ST7";
+ case 69 : return "Motorola MC68HC16";
+ case 70 : return "Motorola MC68HC11";
+ case 71 : return "Motorola MC68HC08";
+ case 72 : return "Motorola MC68HC05";
+ case 73 : return "Silicon Graphics SVx";
+ case 74 : return "STMicroelectronics ST19";
+ case 75 : return "DEC VAX";
+ case 76 : return "Axis Communications 32-bit";
+ case 77 : return "Infineon Technologies 32-bit";
+ case 78 : return "Element 14 64-bit";
+ case 79 : return "LSI Logic 16-bit";
+ case 80 : return "Donald Knuth's educational 64-bit";
+ case 81 : return "Harvard University machine-independent";
+ case 82 : return "SiTera Prism";
+ case 83 : return "Atmel AVR 8-bit";
+ case 84 : return "Fujitsu FR30";
+ case 85 : return "Mitsubishi D10V";
+ case 86 : return "Mitsubishi D30V";
+ case 87 : return "NEC v850";
+ case 88 : return "Mitsubishi M32R";
+ case 89 : return "Matsushita MN10300";
+ case 90 : return "Matsushita MN10200";
+ case 91 : return "picoJava";
+ case 92 : return "OpenRISC 32-bit";
+ case 93 : return "ARC Cores Tangent-A5";
+ case 94 : return "Tensilica Xtensa";
+ default : return "";
+ }
+}
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Elf::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ if (CC4(Buffer)!=0x7F454C46) //".ELF"
+ {
+ Reject("ELF");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Elf::Read_Buffer_Continue()
+{
+ //Parsing
+ int32u version4=(int32u)-1;
+ int16u type=(int16u)-1, machine=(int16u)-1;
+ int8u classs, data, version1, osabi, abiversion;
+ Skip_C4( "magic");
+ Get_L1 (classs, "class");
+ Get_L1 (data, "data");
+ Get_L1 (version1, "version");
+ Get_L1 (osabi, "osabi"); Param_Info1(Elf_osabi(osabi));
+ Get_L1 (abiversion, "abiversion");
+ Skip_XX(7, "reserved");
+ if (data==1) //LE
+ {
+ Get_L2 (type, "type"); Param_Info1(Elf_type(type));
+ Get_L2 (machine, "machine"); Param_Info1(Elf_machine(machine));
+ Get_L4 (version4, "version");
+ }
+ if (data==2) //BE
+ {
+ Get_B2 (type, "type"); Param_Info1(Elf_type(type));
+ Get_B2 (machine, "machine"); Param_Info1(Elf_machine(machine));
+ Get_B4 (version4, "version");
+ }
+ Skip_XX(Element_Size-Element_Offset, "Data");
+
+ FILLING_BEGIN();
+ if (version4!=(int32u)-1 && version1!=version4)
+ {
+ Reject("ELF");
+ return;
+ }
+
+ Accept("ELF");
+
+ Fill(Stream_General, 0, General_Format, "ELF");
+ if (type!=(int16u)-1)
+ Fill(Stream_General, 0, General_Format_Profile, Elf_type(type));
+ if (machine!=(int16u)-1)
+ Fill(Stream_General, 0, General_Format_Profile, Elf_machine(machine));
+
+ //No need of more
+ Finish("ELF");
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_ELF_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Elf.h b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Elf.h
new file mode 100644
index 000000000..3cd3cc72d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Elf.h
@@ -0,0 +1,52 @@
+// File_Elf - Info for ELF files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about ELF files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_ElfH
+#define MediaInfo_File_ElfH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Elf
+//***************************************************************************
+
+class File_Elf : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Gzip.cpp b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Gzip.cpp
new file mode 100644
index 000000000..4c78a7746
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Gzip.cpp
@@ -0,0 +1,96 @@
+// File_Gzip - Info for Gzip files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_GZIP_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Archive/File_Gzip.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Gzip::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<2)
+ return false; //Must wait for more data
+
+ if (CC2(Buffer)!=0x1F8B)
+ {
+ Reject("Gzip");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Gzip::Read_Buffer_Continue()
+{
+ //Parsing
+ int8u CM;
+ Skip_B2( "IDentification");
+ Get_B1 (CM, "Compression Method");
+ Skip_B1( "FLaGs");
+ Skip_B4( "Modified TIME");
+ Skip_XX(File_Size-10, "Data");
+
+ FILLING_BEGIN();
+ //Filling
+ Accept("Gzip");
+
+ Fill(Stream_General, 0, General_Format, "GZip");
+ Fill(Stream_General, 0, General_Format_Profile, "deflate");
+
+ Finish("Gzip");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_GZIP_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Gzip.h b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Gzip.h
new file mode 100644
index 000000000..8c7d1e7a1
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Gzip.h
@@ -0,0 +1,52 @@
+// File_Gzip - Info for Gzip files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Gzip files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_GzipH
+#define MediaInfo_File_GzipH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Gzip
+//***************************************************************************
+
+class File_Gzip : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Iso9660.cpp b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Iso9660.cpp
new file mode 100644
index 000000000..1da64b20f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Iso9660.cpp
@@ -0,0 +1,122 @@
+// File_Iso9660 - Info for Iso9660 files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_7Z_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Archive/File_Iso9660.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Iso9660::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<65536)
+ return false; //Must wait for more data
+
+ if (CC6(Buffer+32768)!=0x014344303031LL) //"Iso9660...."
+ {
+ Reject("ISO 9660");
+ return false;
+ }
+
+ //All should be OK...
+ Accept("ISO 9660");
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Iso9660::Read_Buffer_Continue()
+{
+ Skip_XX(32768, "System Area");
+ Primary_Volume_Descriptor();
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_Format, "ISO 9660");
+
+ Finish("ISO 9660");
+ FILLING_END();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Iso9660::Primary_Volume_Descriptor()
+{
+ int32u Volume_Space_Size;
+ Element_Begin1("Volume_Descriptor");
+ Skip_B1("Volume Descriptor Type");
+ Skip_Local(5,"Standard Identifier");
+ Skip_B1("Volume Descriptor Version");
+ Skip_B1("Unused field");
+ Skip_Local(32,"System Identifier");
+ Skip_Local(32,"Volume Identifier");
+ Skip_XX(8,"Unused field");
+ Get_D4(Volume_Space_Size, "Volume Space Size"); Param_Info2(Volume_Space_Size*(int64u)2048, " bytes");
+ Skip_XX(32,"Unused field");
+ Skip_B4("Volume Set Size");
+ Skip_B4("Volume Sequence Number");
+ Skip_B4("Logical Block Size");
+ Skip_B8("Path Table Size");
+ Skip_B4("Location of Occurrence of Type L Path Table");
+ Skip_B4("Location of Optional Occurrence of Type L Path Table");
+ Skip_B4("Location of Occurrence of Type M Path Table");
+ Skip_B4("Location of Optional Occurrence of Type M Path Table");
+ Skip_Local(34,"Directory Record for Root Directory");
+ Skip_Local(128,"Volume Set Identifier");
+ Skip_Local(128,"Publisher Identifier");
+ Skip_Local(128,"Data Preparer Identifier");
+ Skip_Local(128,"Application Identifier");
+ Skip_Local(37,"Copyright File Identifier");
+ Skip_Local(37,"Abstract File Identifier");
+ Skip_Local(37,"Bibliographic File Identifier");
+ Skip_XX(17,"Volume Creation Date and Time");
+ Element_End0();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_7Z_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Iso9660.h b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Iso9660.h
new file mode 100644
index 000000000..ac841977d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Iso9660.h
@@ -0,0 +1,55 @@
+// File_Iso9660 - Info for Iso9660 files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Iso9660 files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Iso9660H
+#define MediaInfo_File_Iso9660H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Iso9660
+//***************************************************************************
+
+class File_Iso9660 : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+
+ //Elements
+ void Primary_Volume_Descriptor();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Mz.cpp b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Mz.cpp
new file mode 100644
index 000000000..2b9353ed2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Mz.cpp
@@ -0,0 +1,177 @@
+// File_Mz - Info for MZ files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MZ_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Archive/File_Mz.h"
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Mz_Machine(int16u Machine)
+{
+ switch (Machine)
+ {
+ case 0x014D : return "Intel i860";
+ case 0x014C : return "Intel i386";
+ case 0x0162 : return "MIPS R3000";
+ case 0x0166 : return "MIPS R4000";
+ case 0x0183 : return "DEC Alpha";
+ case 0x0200 : return "Intel IA64";
+ case 0x8664 : return "AMD x86-64";
+ default : return "";
+ }
+}
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Mz::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<2)
+ return false; //Must wait for more data
+
+ if (CC2(Buffer)!=0x4D5A) //"MZ"
+ {
+ Reject("MZ");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mz::Read_Buffer_Continue()
+{
+ //Parsing
+ int32u lfanew;
+ Element_Begin1("MZ");
+ Skip_C2( "magic");
+ Skip_L2( "cblp");
+ Skip_L2( "cp");
+ Skip_L2( "crlc");
+ Skip_L2( "cparhdr");
+ Skip_L2( "minalloc");
+ Skip_L2( "maxalloc");
+ Skip_L2( "ss");
+ Skip_L2( "sp");
+ Skip_L2( "csum");
+ Skip_L2( "ip");
+ Skip_L2( "cs");
+ Skip_L2( "lsarlc");
+ Skip_L2( "ovno");
+ Skip_L2( "res");
+ Skip_L2( "res");
+ Skip_L2( "res");
+ Skip_L2( "res");
+ Skip_L2( "oemid");
+ Skip_L2( "oeminfo");
+ Skip_L2( "res2");
+ Skip_L2( "res2");
+ Skip_L2( "res2");
+ Skip_L2( "res2");
+ Skip_L2( "res2");
+ Skip_L2( "res2");
+ Skip_L2( "res2");
+ Skip_L2( "res2");
+ Skip_L2( "res2");
+ Skip_L2( "res2");
+ Get_L4 (lfanew, "lfanew");
+
+ //Computing
+ if (lfanew>Element_Offset)
+ {
+ Skip_XX(lfanew-Element_Offset, "MZ data");
+ Element_End0();
+ }
+ if (Element_Offset>lfanew)
+ {
+ Element_End0();
+ Element_Offset=lfanew; //Multi usage off the first bytes
+ }
+
+ //Parsing
+ int32u Signature, TimeDateStamp=0;
+ int16u Machine=0, Characteristics=0;
+ Peek_B4(Signature);
+ if (Signature==0x50450000) //"PE"
+ {
+ Element_Begin1("PE");
+ Skip_C4( "Header");
+ Get_L2 (Machine, "Machine"); Param_Info1(Mz_Machine(Machine));
+ Skip_L2( "NumberOfSections");
+ Get_L4 (TimeDateStamp, "TimeDateStamp"); Param_Info1(Ztring().Date_From_Seconds_1970(TimeDateStamp));
+ Skip_L4( "PointerToSymbolTable");
+ Skip_L4( "NumberOfSymbols");
+ Skip_L2( "SizeOfOptionalHeader");
+ Get_L2 (Characteristics, "Characteristics");
+ Element_End0();
+ }
+
+ FILLING_BEGIN();
+ Accept("MZ");
+
+ Fill(Stream_General, 0, General_Format, "MZ");
+ if (Characteristics&0x2000)
+ Fill(Stream_General, 0, General_Format_Profile, "DLL");
+ else if (Characteristics&0x0002)
+ Fill(Stream_General, 0, General_Format_Profile, "Executable");
+ Fill(Stream_General, 0, General_Format_Profile, Mz_Machine(Machine));
+ if (TimeDateStamp)
+ Fill(Stream_General, 0, General_Encoded_Date, Ztring().Date_From_Seconds_1970(TimeDateStamp));
+
+ //No more need data
+ Finish("MZ");
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_MZ_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Mz.h b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Mz.h
new file mode 100644
index 000000000..6bec4fcf4
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Mz.h
@@ -0,0 +1,52 @@
+// File_Mz - Info for MZ files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MZ files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_MzH
+#define MediaInfo_File_MzH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Mz
+//***************************************************************************
+
+class File_Mz : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Rar.cpp b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Rar.cpp
new file mode 100644
index 000000000..5a6713f6d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Rar.cpp
@@ -0,0 +1,329 @@
+// File_Rar - Info for RAR files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_RAR_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Archive/File_Rar.h"
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+
+//---------------------------------------------------------------------------
+const char* Rar_host_os[6]=
+{
+ "MS DOS",
+ "OS/2",
+ "Win32",
+ "Unix",
+ "Mac OS",
+ "BeOS"
+};
+
+//---------------------------------------------------------------------------
+const char* Rar_packing_method[6]=
+{
+ "storing",
+ "fastest compression",
+ "fast compression",
+ "normal compression",
+ "good compression",
+ "best compression"
+};
+
+//---------------------------------------------------------------------------
+const char* Rar_HEADER_TYPE(int8u HEADER_TYPE)
+{
+ switch(HEADER_TYPE)
+ {
+ case 0x72 : return "marker block";
+ case 0x73 : return "archive header";
+ case 0x74 : return "file header";
+ case 0x75 : return "old style comment header";
+ case 0x76 : return "old style authenticity information";
+ case 0x77 : return "old style subblock";
+ case 0x78 : return "old style recovery record";
+ case 0x79 : return "old style authenticity informatio";
+ case 0x7A : return "subblock";
+ case 0x7B : return "end of file";
+ default : return "";
+ }
+};
+
+//---------------------------------------------------------------------------
+Ztring Rar_version_number(int8u byte)
+{
+ //Version number is encoded as 10 * Major version + minor version.
+ return Ztring::ToZtring(byte/10)+Ztring(".")+Ztring::ToZtring(byte%10);
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Rar::File_Rar()
+:File__Analyze()
+{
+ //Configuration
+ DataMustAlwaysBeComplete=false;
+}
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Rar::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<7)
+ return false; //Must wait for more data
+
+ state=0;
+
+ if (CC7(Buffer)!=0x526172211A0700LL) //"Rar!"
+ {
+ Reject("RAR");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Rar::Header_Begin()
+{
+ if (Element_Offset+7>Element_Size)
+ return false; //Not enough data for header size
+ int16u HEAD_SIZE=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset+5);
+
+ if (Element_Offset+HEAD_SIZE>Element_Size)
+ return false; //Not enough data for header
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Rar::Header_Parse()
+{
+ //Config
+ HIGH_PACK_SIZE=0;
+ PACK_SIZE=0;
+
+ //Parsing
+ int16u HEAD_SIZE;
+ Skip_L2( "HEAD_CRC"); //CRC of total block or block part
+ Get_L1 (HEAD_TYPE, "HEAD_TYPE"); //Block type
+ Get_L2 (HEAD_FLAGS, "HEAD_FLAGS");
+ Header_Parse_Flags();
+ Get_L2 (HEAD_SIZE, "HEAD_SIZE");
+ Header_Parse_Content();
+ Skip_XX(HEAD_SIZE-(size_t)Element_Offset, "REST OF HEADER");
+
+ //Filling
+ Header_Fill_Size(HEAD_SIZE+HIGH_PACK_SIZE*0x100000000LL+PACK_SIZE);
+ Header_Fill_Code(HEAD_TYPE, Rar_HEADER_TYPE(HEAD_TYPE));
+}
+
+//---------------------------------------------------------------------------
+void File_Rar::Header_Parse_Flags()
+{
+ switch (HEAD_TYPE)
+ {
+ case 0x73 : Header_Parse_Flags_73(); break;
+ case 0x74 : Header_Parse_Flags_74(); break;
+ default : Header_Parse_Flags_XX();
+ }
+}
+
+//---------------------------------------------------------------------------
+// archive header
+void File_Rar::Header_Parse_Flags_73()
+{
+ Skip_Flags(HEAD_FLAGS, 1, "Volume attribute (archive volume)");
+ Skip_Flags(HEAD_FLAGS, 2, "Archive comment present");
+ Skip_Flags(HEAD_FLAGS, 3, "Archive lock attribute");
+ Skip_Flags(HEAD_FLAGS, 4, "Solid attribute (solid archive)");
+ Skip_Flags(HEAD_FLAGS, 5, "New volume naming scheme"); // (\'volname.partN.rar\')
+ Skip_Flags(HEAD_FLAGS, 6, "Authenticity information present");
+ Skip_Flags(HEAD_FLAGS, 7, "Recovery record present");
+ Skip_Flags(HEAD_FLAGS, 8, "Block headers are encrypted");
+ Skip_Flags(HEAD_FLAGS, 9, "First volume (set only by RAR 3.0 and later)");
+ Get_Flags (HEAD_FLAGS, 15, add_size, "ADD_SIZE present");
+}
+
+//---------------------------------------------------------------------------
+// file header
+void File_Rar::Header_Parse_Flags_74()
+{
+ Skip_Flags(HEAD_FLAGS,0, "file continued from previous volume");
+ Skip_Flags(HEAD_FLAGS,1, "file continued in next volume");
+ Skip_Flags(HEAD_FLAGS,2, "file encrypted with password");
+ Skip_Flags(HEAD_FLAGS,3, "file comment present");
+ Skip_Flags(HEAD_FLAGS,4, "information from previous files is used"); // (solid flag)
+ // bits 7 6 5 (for RAR 2.0 and later)
+ // 0 0 0 - dictionary size 64 KB
+ // 0 0 1 - dictionary size 128 KB
+ // 0 1 0 - dictionary size 256 KB
+ // 0 1 1 - dictionary size 512 KB
+ // 1 0 0 - dictionary size 1024 KB
+ // 1 0 1 - dictionary size 2048 KB
+ // 1 1 0 - dictionary size 4096 KB
+ // 1 1 1 - file is directory
+ Get_Flags (HEAD_FLAGS, 8, high_fields, "HIGH_PACK_SIZE and HIGH_UNP_SIZE fields");
+ Get_Flags (HEAD_FLAGS, 9, usual_or_utf8, "FILE_NAME contains usual and encoded unicode");
+ Get_Flags (HEAD_FLAGS, 10, salt, "SALT present");
+ Skip_Flags(HEAD_FLAGS, 11, "Version flag.");
+ Get_Flags (HEAD_FLAGS, 12, exttime, "Extended time field present");
+ Get_Flags (HEAD_FLAGS, 15, add_size, "ADD_SIZE present");
+}
+
+//---------------------------------------------------------------------------
+// Generic
+void File_Rar::Header_Parse_Flags_XX()
+{
+ Get_Flags (HEAD_FLAGS, 15, add_size, "ADD_SIZE present");
+}
+
+//---------------------------------------------------------------------------
+void File_Rar::Header_Parse_Content()
+{
+ switch (HEAD_TYPE)
+ {
+ case 0x73 : Header_Parse_Content_73(); break;
+ case 0x74 : Header_Parse_Content_74(); break;
+ default : Header_Parse_Content_XX(); break;
+ }
+}
+
+//---------------------------------------------------------------------------
+// archive header
+void File_Rar::Header_Parse_Content_73()
+{
+ Skip_L2( "RESERVED_1");
+ Skip_L4( "RESERVED_2");
+}
+
+//---------------------------------------------------------------------------
+// file header
+void File_Rar::Header_Parse_Content_74()
+{
+ int16u name_size;
+ int8u HOST_OS, METHOD, UNP_VER;
+ Get_L4 (PACK_SIZE, "PACK_SIZE"); //Compressed file size
+ Skip_L4( "UNP_SIZE"); //Uncompressed file size
+ Get_L1 (HOST_OS, "HOST_OS"); Param_Info1((HOST_OS<6?Rar_host_os[HOST_OS]:"Unknown"));
+ Skip_L4( "FILE_CRC");
+ Skip_L4( "FTIME"); //Date and time in standard MS DOS format
+ Get_L1 (UNP_VER, "UNP_VER"); Param_Info1(Rar_version_number(UNP_VER)); //RAR version needed to extract file
+ Get_L1 (METHOD, "METHOD"); Param_Info1(((METHOD>=0x30)&&(METHOD<0x36)?Rar_packing_method[METHOD-0x30]:"Unknown"));
+ Get_L2 (name_size, "NAME_SIZE"); //File name size
+ Skip_L4( "ATTR"); //File attributes
+ if(high_fields)
+ {
+ Get_L4 (HIGH_PACK_SIZE, "HIGH_PACK_SIZE"); //High 4 bytes of 64 bit value of compressed file size.
+ Skip_L4( "HIGH_UNP_SIZE"); //High 4 bytes of 64 bit value of uncompressed file size.
+ }
+ else
+ HIGH_PACK_SIZE=0;
+ if (usual_or_utf8)
+ {
+ //Must test the content before reading, looking fore zero byte
+ if (Element_Offset+name_size>Element_Size)
+ {
+ Skip_XX(Element_Size-Element_Offset, "Error");
+ return;
+ }
+ int64u ZeroPos=0;
+ while (ZeroPos<name_size)
+ {
+ if (Buffer[Buffer_Offset+(size_t)(Element_Offset+ZeroPos)]==0)
+ break; //Found
+ ZeroPos++;
+ }
+
+ if (ZeroPos==name_size)
+ Skip_UTF8(name_size, "FILE_NAME");
+ else
+ {
+ Skip_Local(ZeroPos, "FILE_NAME"); //Up to ZeroPos
+ Skip_L1( "Zero");
+ Skip_UTF16L(name_size-(ZeroPos+1), "FILE_NAME"); //Spec is not precise, "Unicode" without encoding format (character size, endianess), because RAR is from Windows, we hope this is the format from Windows (UTF-16 Little Endian)
+ }
+ }
+ else
+ Skip_Local(name_size, "FILE_NAME");
+
+ if (salt)
+ Skip_L8( "SALT");
+ //if(exttime)
+ //Skip_XX("EXT_TIME"); //Which size?
+}
+
+//---------------------------------------------------------------------------
+// Generic
+void File_Rar::Header_Parse_Content_XX()
+{
+ if (add_size)
+ Get_L4 (PACK_SIZE, "ADD_SIZE"); //Additional data size
+}
+
+//---------------------------------------------------------------------------
+void File_Rar::Data_Parse()
+{
+ switch (Element_Code)
+ {
+ case 0x72 : Accept("RAR"); Fill(Stream_General, 0, General_Format, "RAR"); break;
+ default : ;
+ }
+
+ Skip_XX(Element_Size, "Data");
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_RAR_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Rar.h b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Rar.h
new file mode 100644
index 000000000..4c87eecc3
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Rar.h
@@ -0,0 +1,78 @@
+// File_Rar - Info for RAR files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about RAR files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_RarH
+#define MediaInfo_File_RarH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Rar
+//***************************************************************************
+
+class File_Rar : public File__Analyze
+{
+public :
+ File_Rar();
+
+protected :
+ int state;
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Per element
+ bool Header_Begin();
+ void Header_Parse();
+ void Header_Parse_Flags();
+ void Header_Parse_Flags_73();
+ void Header_Parse_Flags_74();
+ void Header_Parse_Flags_XX();
+ void Header_Parse_Content();
+ void Header_Parse_Content_73();
+ void Header_Parse_Content_74();
+ void Header_Parse_Content_XX();
+ void Data_Parse();
+
+ //Temp
+ int8u HEAD_TYPE;
+ int32u PACK_SIZE;
+ int32u HIGH_PACK_SIZE;
+ int16u HEAD_FLAGS;
+ bool high_fields;
+ bool usual_or_utf8;
+ bool salt;
+ bool exttime;
+ bool add_size;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Tar.cpp b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Tar.cpp
new file mode 100644
index 000000000..972071bac
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Tar.cpp
@@ -0,0 +1,109 @@
+// File_Tar - Info for Tar files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_TAR_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Archive/File_Tar.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Tar::Read_Buffer_Continue()
+{
+ if (File_Size<257)
+ {
+ Reject();
+ return;
+ }
+ if (Buffer_Size<257)
+ return; //Wait for more data
+
+ //Parsing
+ Ztring ChecksumO;
+ Skip_Local(100, "File name");
+ Skip_Local( 8, "File mode");
+ Skip_Local( 8, "Owner's numeric user ID");
+ Skip_Local( 12, "Group's numeric user ID");
+ Skip_Local( 12, "File size in bytes");
+ Skip_Local( 8, "Last modification time in numeric Unix time format");
+ Get_Local ( 8, ChecksumO, "Checksum for header block");
+ Skip_B1( "Link indicator (file type)");
+ Skip_Local(100, "Name of linked file");
+ Skip_XX(File_Size-257, "Data");
+
+ FILLING_BEGIN();
+ //Handling Checksum
+ int32u Checksum=ChecksumO.To_int32u(8);
+ int32u ChecksumU=0;
+ int32u ChecksumS=0;
+ for (size_t Pos=0; Pos<257; Pos++)
+ {
+ if (Pos==148)
+ {
+ ChecksumU+=32*8; //8 spaces
+ ChecksumS+=32*8; //8 spaces
+ Pos+=7; //Skiping Checksum
+ }
+ ChecksumU+=(int8u)Buffer[Pos];
+ ChecksumS+=(int8s)Buffer[Pos];
+ }
+
+ if (ChecksumU!=Checksum && ChecksumS!=Checksum)
+ {
+ Reject("Tar");
+ return;
+ }
+
+ //Filling
+ Accept("Tar");
+
+ Fill(Stream_General, 0, General_Format, "Tar");
+
+ Reject("Tar");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_TAR_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Tar.h b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Tar.h
new file mode 100644
index 000000000..9de66979f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Tar.h
@@ -0,0 +1,49 @@
+// File_Tar - Info for Tar files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Tar files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_TarH
+#define MediaInfo_File_TarH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Tar
+//***************************************************************************
+
+class File_Tar : public File__Analyze
+{
+protected :
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Zip.cpp b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Zip.cpp
new file mode 100644
index 000000000..5852569c3
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Zip.cpp
@@ -0,0 +1,483 @@
+// File_Zip - Info for NewFormat files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_ZIP_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Archive/File_Zip.h"
+#include "ZenLib/Utils.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+
+//---------------------------------------------------------------------------
+const char* Zip_made_by[20]=
+{
+ "MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)",
+ "Amiga",
+ "OpenVMS",
+ "UNIX",
+ "VM/CMS",
+ "Atari ST",
+ "OS/2 H.P.F.S.",
+ "Macintosh",
+ "Z-System",
+ "CP/M",
+ "Windows NTFS",
+ "MVS (OS/390 - Z/OS)",
+ "VSE",
+ "Acorn Risc",
+ "VFAT",
+ "alternate MVS",
+ "BeOS",
+ "Tandem",
+ "OS/400",
+ "OS/X (Darwin)"
+};
+
+//---------------------------------------------------------------------------
+const char* Zip_compression_method[22]=
+{
+ "stored (no compression)",
+ "Shrunk",
+ "Reduced with compression factor 1",
+ "Reduced with compression factor 2",
+ "Reduced with compression factor 3",
+ "Reduced with compression factor 4",
+ "Imploded",
+ "Tokenizing compression algorithm",
+ "Deflated",
+ "Enhanced Deflating using Deflate64(tm)",
+ "PKWARE Data Compression Library Imploding (old IBM TERSE)",
+ "Reserved by PKWARE",
+ "compressed using BZIP2 algorithm",
+ "Reserved by PKWARE",
+ "LZMA (EFS)",
+ "Reserved by PKWARE",
+ "Reserved by PKWARE",
+ "Reserved by PKWARE",
+ "File is compressed using IBM TERSE (new)",
+ "IBM LZ77 z Architecture (PFS)",
+ "WavPack compressed data", // 97
+ "PPMd version I, Rev 1" // 98
+};
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Zip::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ if (CC4(Buffer)!=0x504B0304) //"PK.."
+ {
+ Reject("ZIP");
+ return false;
+ }
+
+ //This is OK, ZIP detected
+ Accept();
+
+ //Init
+ signature=0x00000000;
+ local_file_Step=0;
+ end_of_central_directory_IsParsed=false;
+
+ //Jumping to the end of the file minus end_of_central_directory size (we hope there is no comment)
+ GoTo(File_Size-22);
+
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Zip::Read_Buffer_Continue()
+{
+ for (;;)
+ {
+ //Probing
+ if (signature==0x00000000) //If not already tested (else an element is being parsed)
+ {
+ if (Element_Offset+4>Element_Size) //signature size
+ return; //Not enough data
+ signature=LittleEndian2int32u(Buffer+(size_t)Element_Offset);
+ }
+
+ //Parsing
+ switch (signature)
+ {
+ case 0x04034b50 : if (!local_file())
+ return; //Not enough data
+ break;
+ case 0x02014b50 : if (!central_directory())
+ return; //Not enough data
+ break;
+ case 0x05054b50 : if (!digital_signature())
+ return; //Not enough data
+ break;
+ case 0x06054b50 : if (!end_of_central_directory())
+ return; //Not enough data
+ break;
+ case 0x08064b50 : if(!archive_extra_data_record())
+ return;
+ break;
+ case 0x06064b50 : if(!Zip64_end_of_central_directory_record())
+ return;
+ break;
+ case 0x07064b50 : if(!Zip64_end_of_central_directory_locator())
+ return;
+ break;
+ default: Finish(); return; //Reject(); return; //Unknown value //Décommenter quand toutes les signatures sont implémentées
+ }
+
+ //Cleanup
+ signature=0x00000000; //Reset, must probe again the signature (next element)
+ }
+}
+
+//***************************************************************************
+// Files
+//***************************************************************************
+
+bool File_Zip::local_file()
+{
+ switch(local_file_Step)
+ {
+ case 0 :
+ if (!local_file_header())
+ return false;
+ local_file_Step=1; //local_file_header parsed
+ case 1 :
+ local_file_Step=2; //file_data is always parsed
+ if (!file_data())
+ return false;
+ case 2 :
+ if (!data_descriptor())
+ return false;
+ local_file_Step=0; //data_descriptor is parsed, back to begin
+ default : ; //Should never happen
+ }
+
+ return true;
+}
+
+bool File_Zip::archive_extra_data_record()
+{
+ if (Element_Offset+8>Element_Size) //archive_extra_data_record
+ return false; //Not enough data
+
+ //Retrieving complete archive_extra_data_record size
+ int32u extra_field_length=LittleEndian2int32u(Buffer+(size_t)Element_Offset+4);
+
+ //Parsing
+ Element_Begin1("archive_extra_data_record");
+ Skip_C4("Archive extra data signature");
+ Skip_L4("extra field length");
+ Skip_XX(extra_field_length,"extra_field_data");
+ Element_End0();
+
+ return true;
+}
+
+bool File_Zip::digital_signature()
+{
+ if (Element_Offset+6>Element_Size) //digital_signature
+ return false; //Not enough data
+
+ //Retrieving complete archive_extra_data_record size
+ int16u size_of_data=LittleEndian2int16u(Buffer+(size_t)Element_Offset+4);
+
+ //Parsing
+ Element_Begin1("digital_signature");
+ Skip_C4("Header signature");
+ Skip_L2("size of data");
+ Skip_XX(size_of_data,"signature data");
+ Element_End0();
+
+ return true;
+}
+
+bool File_Zip::local_file_header()
+{
+ if (Element_Offset+30>Element_Size) //local_file_header up to extra_field_length included
+ return false; //Not enough data
+
+ //Retrieving complete local_file_header size
+ int16u file_name_length=LittleEndian2int16u(Buffer+(size_t)Element_Offset+26);
+ int16u extra_field_length=LittleEndian2int16u(Buffer+(size_t)Element_Offset+28);
+ if (Element_Offset+30+file_name_length+extra_field_length>Element_Size) //local_file_header all included
+ return false; //Not enough data
+
+ //Parsing
+ Element_Begin1("local_file_header");
+ int16u general_purpose_bit_flag,compression_method;
+ bool efs;
+ Skip_C4("Local file header signature");
+ Skip_L2("Version needed to extract");
+ Get_L2 (general_purpose_bit_flag,"general purpose bit flag");
+ Skip_Flags(general_purpose_bit_flag, 0, "encrypted file");
+ Skip_Flags(general_purpose_bit_flag, 1, "8K sliding dictionary");
+ Skip_Flags(general_purpose_bit_flag, 2, "3 Shannon-Fano trees");
+ Get_Flags (general_purpose_bit_flag, 3, data_descriptor_set, "data descriptor");
+ Skip_Flags(general_purpose_bit_flag, 4, "Reserved for use with method 8");
+ Skip_Flags(general_purpose_bit_flag, 4, "file is compressed patched data");
+ Skip_Flags(general_purpose_bit_flag, 4, "Strong encryption");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused");
+ Get_Flags (general_purpose_bit_flag, 11, efs, "Language encoding flag (EFS)");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Reserved by PKWARE for enhanced compression");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Reserved by PKWARE");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Reserved by PKWARE");
+ Get_L2 (compression_method,"compression method");
+ Param_Info1C((compression_method<20), Zip_compression_method[compression_method]);
+ Param_Info1C((compression_method==97||compression_method==98), Zip_compression_method[compression_method-97+20]);
+ Skip_L2("last mod file time");
+ Skip_L2("last mod file date");
+ Skip_L4("crc-32");
+ Get_L4(compressed_size,"compressed size");
+ Skip_L4("uncompressed size");
+ Get_L2(file_name_length,"file name lenth");
+ Get_L2(extra_field_length,"extra field length");
+ if(efs) {
+ Skip_UTF8(file_name_length,"file name");
+ Skip_UTF8(extra_field_length,"extra field");
+ } else {
+ Skip_Local(file_name_length,"file name");
+ Skip_Local(extra_field_length,"extra field");
+ }
+ Element_End0();
+
+ FILLING_BEGIN();
+ Accept("Zip");
+ Fill(Stream_General, 0, General_Format, "ZIP");
+ FILLING_END();
+ return true;
+}
+
+bool File_Zip::file_data()
+{
+ Element_Begin1("file_data");
+ Skip_XX(compressed_size,"File_data");
+ Element_End0();
+
+ if (Element_Offset>Element_Size)
+ {
+ GoTo(File_Offset+Element_Offset);
+ return false;
+ }
+ return true;
+
+}
+
+bool File_Zip::data_descriptor()
+{
+ if(data_descriptor_set)
+ {
+ if (Element_Offset+12>Element_Size)
+ return false; //Not enough data
+
+ Element_Begin1("data_descriptor");
+ Skip_L4("crc-32");
+ Skip_L4("compressed size");
+ Skip_L4("uncompressed size");
+ Element_End0();
+ }
+ return true;
+}
+
+bool File_Zip::central_directory()
+{
+ if (Element_Offset+46>Element_Size) //central_directory up to relative offset of local header included
+ return false; //Not enough data
+
+ //Retrieving complete local_file_header size
+ int16u file_name_length=LittleEndian2int16u(Buffer+(size_t)Element_Offset+28);
+ int16u extra_field_length=LittleEndian2int16u(Buffer+(size_t)Element_Offset+30);
+ int16u file_comment_length=LittleEndian2int16u(Buffer+(size_t)Element_Offset+32);
+ if (Element_Offset+46+file_name_length+extra_field_length+file_comment_length>Element_Size) //central_directory_structure all included
+ return false; //Not enough data
+
+ int16u general_purpose_bit_flag;
+ bool efs;
+ int16u version_made_by,compression_method;
+
+ //Parsing
+ Element_Begin1("Central directory");
+ Skip_C4("central file header signature");
+ Get_L2 (version_made_by,"version made by");Param_Info1((version_made_by>>8)>20?"unused":Zip_made_by[version_made_by>>8]);
+ Skip_L2("version needed to extract");
+ Get_L2 (general_purpose_bit_flag,"general purpose bit flag");
+ Skip_Flags(general_purpose_bit_flag, 0, "encrypted file");
+ Skip_Flags(general_purpose_bit_flag, 1, "8K sliding dictionary");
+ Skip_Flags(general_purpose_bit_flag, 2, "3 Shannon-Fano trees");
+ Skip_Flags(general_purpose_bit_flag, 3, "data descriptor");
+ Skip_Flags(general_purpose_bit_flag, 4, "Reserved for use with method 8");
+ Skip_Flags(general_purpose_bit_flag, 4, "file is compressed patched data");
+ Skip_Flags(general_purpose_bit_flag, 4, "Strong encryption");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Currently unused");
+ Get_Flags (general_purpose_bit_flag, 11, efs, "Language encoding flag (EFS)");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Reserved by PKWARE for enhanced compression");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Reserved by PKWARE");
+ //~ Skip_Flags(general_purpose_bit_flag, 4, "Reserved by PKWARE");
+ Get_L2 (compression_method,"compression method");
+ Param_Info1C((compression_method<20), Zip_compression_method[compression_method]);
+ Param_Info1C((compression_method==97||compression_method==98), Zip_compression_method[compression_method-97+20]);
+ Skip_L2("last mod file time");
+ Skip_L2("last mod file date");
+ Skip_L4("crc-32");
+ Skip_L4("compressed size");
+ Skip_L4("uncompressed size");
+ Skip_L2("file name length");
+ Skip_L2("extra field length");
+ Skip_L2("file comment length");
+ Skip_L2("disk number start");
+ Skip_L2("internal file attributes");
+ Skip_L4("external file attributes");
+ Skip_L4("relative offset of local header");
+ if(efs) {
+ Skip_UTF8(file_name_length,"file name");
+ Skip_UTF8(extra_field_length,"extra field");
+ Skip_UTF8(file_comment_length,"file comment");
+ } else {
+ Skip_Local(file_name_length,"file name");
+ Skip_Local(extra_field_length,"extra field");
+ Skip_Local(file_comment_length,"file comment");
+ }
+ Element_End0();
+
+ return true;
+}
+
+bool File_Zip::end_of_central_directory()
+{
+ if (Element_Offset+22>Element_Size) //end_of_central_directory up to relative offset of .ZIP file comment length included
+ return false; //Not enough data
+
+ //Retrieving complete local_file_header size
+ int16u zip_comment_length=LittleEndian2int16u(Buffer+(size_t)Element_Offset+20);
+ if (Element_Offset+22+zip_comment_length>Element_Size) //end_of_central_directory all included
+ return false; //Not enough data
+
+ //Parsing
+ int32u offset;
+ Element_Begin1("End of central directory");
+ Skip_C4( "end of central dir signature");
+ Skip_L2( "number of this disk");
+ Skip_L2( "number of the disk");// with the start of the central directory
+ Skip_L2( "total number of entries on this disk");// in the central directory
+ Skip_L2( "total number of entries");// in the central directory
+ Skip_L4( "size of the central directory");
+ Get_L4 (offset, "offset of start of central directory");// with respect to the starting disk number
+ Skip_L2( "zip file comment length");
+ Skip_XX(zip_comment_length, "zip file comment");
+ Element_End0();
+
+ //Going to first central directory (once)
+ if (!end_of_central_directory_IsParsed)
+ {
+ end_of_central_directory_IsParsed=true;
+ GoTo(offset);
+ }
+ return true;
+}
+
+bool File_Zip::Zip64_end_of_central_directory_record()
+{
+ if (Element_Offset+12>Element_Size) //Zip64_end_of_central_directory_record
+ return false; //Not enough data
+
+ //Retrieving complete Zip64_end_of_central_directory_record size
+ int64u size_of_Zip64_end_of_central_directory_record=LittleEndian2int64u(Buffer+(size_t)Element_Offset+4);
+ if (Element_Offset+12+size_of_Zip64_end_of_central_directory_record>Element_Size) //end_of_central_directory all included
+ return false; //Not enough data
+
+ //Parsing
+ //~ int32u offset;
+ int16u version_made_by;
+ Element_Begin1("Zip64 End of central directory record");
+ Skip_C4( "Zip64 end of central dir signature");
+ Skip_L8( "size of zip64 end of central directory record");
+ Get_L2 (version_made_by, "version made by");
+ Param_Info1((version_made_by>>8)>20?"unused":Zip_made_by[version_made_by>>8]);
+ Skip_L2( "version needed to extract");
+ Skip_L4( "number of this disk");
+ Skip_L4( "number of the disk");// with the start of the central directory
+ Skip_L8( "total number of entries on this disk");// in the central directory
+ Skip_L8( "total number of entries");// in the central directory
+ Skip_L8( "size of the central directory");
+ Skip_L8( "offset of start of central directory"); // with respect to the starting disk number
+ Skip_XX(size_of_Zip64_end_of_central_directory_record-44, "zip64 extensible data sector");
+ Element_End0();
+
+ return true;
+}
+
+bool File_Zip::Zip64_end_of_central_directory_locator()
+{
+ if (Element_Offset+20>Element_Size) //Zip64_end_of_central_directory_locator
+ return false; //Not enough data
+
+ //Parsing
+ Element_Begin1("Zip64 end of central directory locator");
+ Skip_C4("zip64 end of central dir locator signature");
+ Skip_L4("number of the disk");// with the start of the zip64 end of central directory
+ Skip_L8("relative offset of the zip64 end of central directory record");
+ Skip_L4("total number of disks");
+ Element_End0();
+
+ return true;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_ZIP_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Zip.h b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Zip.h
new file mode 100644
index 000000000..bdc08aae8
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Archive/File_Zip.h
@@ -0,0 +1,70 @@
+// File_Zip - Info for NewFormat files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about ZIP files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_ZipH
+#define MediaInfo_File_ZipH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Zip
+//***************************************************************************
+
+class File_Zip : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+
+ int32u compressed_size;
+ bool data_descriptor_set;
+ int32u signature;
+ int8u local_file_Step;
+ bool end_of_central_directory_IsParsed;
+
+ bool local_file();
+ bool local_file_header();
+ bool file_data();
+ bool data_descriptor();
+ bool archive_extra_data_record();
+ bool central_directory();
+ bool digital_signature();
+ bool end_of_central_directory();
+ bool Zip64_end_of_central_directory_record();
+ bool Zip64_end_of_central_directory_locator();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac.cpp
new file mode 100644
index 000000000..be5096f01
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac.cpp
@@ -0,0 +1,682 @@
+// File_Aac - Info for AAC (Raw) files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AAC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Aac.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Aac::File_Aac()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+
+ //Configuration
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+ PTS_DTS_Needed=true;
+ IsRawStream=true;
+
+ //In
+ Frame_Count_Valid=MediaInfoLib::Config.ParseSpeed_Get()>=0.5?128:(MediaInfoLib::Config.ParseSpeed_Get()>=0.3?32:2);
+ FrameIsAlwaysComplete=false;
+ Mode=Mode_Unknown;
+
+ audioObjectType=(int8u)-1;
+ extensionAudioObjectType=(int8u)-1;
+ channelConfiguration=(int8u)-1;
+ frame_length=1024;
+ sampling_frequency_index=(int8u)-1;
+ sampling_frequency=(int32u)-1;
+ extension_sampling_frequency_index=(int8u)-1;
+ extension_sampling_frequency=(int32u)-1;
+ aacSpectralDataResilienceFlag=false;
+ aacSectionDataResilienceFlag=false;
+ aacScalefactorDataResilienceFlag=false;
+ FrameSize_Min=(int64u)-1;
+ FrameSize_Max=0;
+
+ //Temp - Main
+ muxConfigPresent=true;
+ audioMuxVersionA=false;
+
+ //Temp - General Audio
+ sbr=NULL;
+ ps=NULL;
+
+ //Temp
+ CanFill=false;
+}
+
+//---------------------------------------------------------------------------
+File_Aac::~File_Aac()
+{
+ delete sbr;
+ delete ps;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::Streams_Fill()
+{
+ switch(Mode)
+ {
+ case Mode_LATM : Fill(Stream_General, 0, General_Format, "LATM"); if (IsSub) Fill(Stream_Audio, 0, Audio_MuxingMode, "LATM"); break;
+ default : ;
+ }
+
+ for (std::map<std::string, Ztring>::iterator Info=Infos_General.begin(); Info!=Infos_General.end(); Info++)
+ Fill(Stream_General, 0, Info->first.c_str(), Info->second);
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ for (std::map<std::string, Ztring>::iterator Info=Infos.begin(); Info!=Infos.end(); Info++)
+ Fill(Stream_Audio, StreamPos_Last, Info->first.c_str(), Info->second);
+
+ switch(Mode)
+ {
+ case Mode_ADTS : File__Tags_Helper::Streams_Fill(); break;
+ default : ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::Streams_Finish()
+{
+ switch(Mode)
+ {
+ case Mode_ADIF :
+ case Mode_ADTS : File__Tags_Helper::Streams_Finish(); break;
+ default : ;
+ }
+
+ if (FrameSize_Min!=(int32u)-1 && FrameSize_Max)
+ {
+ if (FrameSize_Max>FrameSize_Min*1.02)
+ {
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "VBR", Unlimited, true, true);
+ Fill(Stream_Audio, 0, Audio_BitRate_Minimum, ((float64)FrameSize_Min)/1024*48000*8, 0);
+ Fill(Stream_Audio, 0, Audio_BitRate_Maximum, ((float64)FrameSize_Max)/1024*48000*8, 0);
+ }
+ else if (Config_ParseSpeed>=1.0)
+ {
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR");
+ }
+ }
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Aac::FileHeader_Begin()
+{
+ switch(Mode)
+ {
+ case Mode_AudioSpecificConfig :
+ case Mode_ADIF :
+ MustSynchronize=false; break;
+ default : ; //Synchronization is requested, and this is the default
+ }
+
+ switch(Mode)
+ {
+ case Mode_Unknown :
+ case Mode_ADIF :
+ case Mode_ADTS :
+ break;
+ default : return true; //no file header test with other modes
+ }
+
+ //Tags
+ if (!File__Tags_Helper::FileHeader_Begin())
+ return false;
+
+ //Testing
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ if (CC4(Buffer+Buffer_Offset)==0x41444946) //"ADIF"
+ {
+ Mode=Mode_ADIF;
+ File__Tags_Helper::Accept("ADIF");
+ MustSynchronize=false;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::FileHeader_Parse()
+{
+ switch (Mode)
+ {
+ case Mode_ADIF : FileHeader_Parse_ADIF(); break;
+ default : ; //no file header test with other modes
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::FileHeader_Parse_ADIF()
+{
+ adif_header();
+ BS_Begin();
+ raw_data_block();
+ BS_End();
+
+ FILLING_BEGIN();
+ File__Tags_Helper::Finish();
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::Read_Buffer_Continue()
+{
+ if (Element_Size==0)
+ return;
+
+ switch(Mode)
+ {
+ case Mode_AudioSpecificConfig : Read_Buffer_Continue_AudioSpecificConfig(); break;
+ case Mode_raw_data_block : Read_Buffer_Continue_raw_data_block(); break;
+ case Mode_ADIF :
+ case Mode_ADTS : File__Tags_Helper::Read_Buffer_Continue(); break;
+ default : ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::Read_Buffer_Continue_AudioSpecificConfig()
+{
+ File__Analyze::Accept(); //We automaticly trust it
+
+ BS_Begin();
+ AudioSpecificConfig(0); //Up to the end of the block
+ BS_End();
+
+ Mode=Mode_raw_data_block; //Mode_AudioSpecificConfig only once
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::Read_Buffer_Continue_raw_data_block()
+{
+ if (Frame_Count>Frame_Count_Valid)
+ {
+ Skip_XX(Element_Size, "Data");
+ return; //Parsing completely only the 1st frame
+ }
+
+ BS_Begin();
+ raw_data_block();
+ BS_End();
+ if (FrameIsAlwaysComplete && Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+
+ FILLING_BEGIN();
+ //Counting
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ Element_Info1(Ztring::ToZtring(Frame_Count));
+
+ //Filling
+ if (!Status[IsAccepted])
+ File__Analyze::Accept();
+ if (Frame_Count>=Frame_Count_Valid)
+ {
+ //No more need data
+ File__Analyze::Finish();
+ }
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Aac::Synchronize()
+{
+ switch (Mode)
+ {
+ case Mode_Unknown : if (Synchronize_LATM()) return true; Buffer_Offset=0; return Synchronize_ADTS();
+ case Mode_ADTS : return Synchronize_ADTS();
+ case Mode_LATM : return Synchronize_LATM();
+ default : return true; //No synchro
+ }
+}
+
+//---------------------------------------------------------------------------
+bool File_Aac::Synchronize_ADTS()
+{
+ //Tags
+ bool Tag_Found;
+ if (!File__Tags_Helper::Synchronize(Tag_Found))
+ return false;
+ if (Tag_Found)
+ return true;
+
+ //Synchronizing
+ while (Buffer_Offset+6<=Buffer_Size)
+ {
+ while (Buffer_Offset+6<=Buffer_Size && (Buffer[Buffer_Offset ]!=0xFF
+ || (Buffer[Buffer_Offset+1]&0xF6)!=0xF0))
+ Buffer_Offset++;
+
+ if (Buffer_Offset+6<=Buffer_Size)//Testing if size is coherant
+ {
+ //Testing next start, to be sure
+ int16u aac_frame_length=(CC3(Buffer+Buffer_Offset+3)>>5)&0x1FFF;
+ if (IsSub && Buffer_Offset+aac_frame_length==Buffer_Size)
+ break;
+ if (File_Offset+Buffer_Offset+aac_frame_length!=File_Size-File_EndTagSize)
+ {
+ if (Buffer_Offset+aac_frame_length+2>Buffer_Size)
+ return false; //Need more data
+
+ //Testing
+ if (aac_frame_length<=7 || (CC2(Buffer+Buffer_Offset+aac_frame_length)&0xFFF6)!=0xFFF0)
+ Buffer_Offset++;
+ else
+ {
+ //Testing next start, to be sure
+ int16u aac_frame_length2=(CC3(Buffer+Buffer_Offset+aac_frame_length+3)>>5)&0x1FFF;
+ if (File_Offset+Buffer_Offset+aac_frame_length+aac_frame_length2!=File_Size-File_EndTagSize)
+ {
+ if (Buffer_Offset+aac_frame_length+aac_frame_length2+2>Buffer_Size)
+ return false; //Need more data
+
+ //Testing
+ if (aac_frame_length2<=7 || (CC2(Buffer+Buffer_Offset+aac_frame_length+aac_frame_length2)&0xFFF6)!=0xFFF0)
+ Buffer_Offset++;
+ else
+ {
+ //Testing next start, to be sure
+ int16u aac_frame_length3=(CC3(Buffer+Buffer_Offset+aac_frame_length+aac_frame_length2+3)>>5)&0x1FFF;
+ if (File_Offset+Buffer_Offset+aac_frame_length+aac_frame_length2+aac_frame_length3!=File_Size-File_EndTagSize)
+ {
+ if (Buffer_Offset+aac_frame_length+aac_frame_length2+aac_frame_length3+2>Buffer_Size)
+ return false; //Need more data
+
+ //Testing
+ if (aac_frame_length3<=7 || (CC2(Buffer+Buffer_Offset+aac_frame_length+aac_frame_length2+aac_frame_length3)&0xFFF6)!=0xFFF0)
+ Buffer_Offset++;
+ else
+ break; //while()
+ }
+ else
+ break; //while()
+ }
+ }
+ else
+ break; //while()
+ }
+ }
+ else
+ break; //while()
+ }
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+6>Buffer_Size)
+ {
+ if (Buffer_Offset+5==Buffer_Size && (CC2(Buffer+Buffer_Offset)&0xFFF6)!=0xFFF0)
+ Buffer_Offset++;
+ if (Buffer_Offset+4==Buffer_Size && (CC2(Buffer+Buffer_Offset)&0xFFF6)!=0xFFF0)
+ Buffer_Offset++;
+ if (Buffer_Offset+3==Buffer_Size && (CC2(Buffer+Buffer_Offset)&0xFFF6)!=0xFFF0)
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && (CC2(Buffer+Buffer_Offset)&0xFFF6)!=0xFFF0)
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0xFF)
+ Buffer_Offset++;
+ return false;
+ }
+
+ //Synched is OK
+ Mode=Mode_ADTS;
+ File__Tags_Helper::Accept("ADTS");
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Aac::Synchronize_LATM()
+{
+ //Synchronizing
+ while (Buffer_Offset+3<=Buffer_Size)
+ {
+ while (Buffer_Offset+3<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x56
+ || (Buffer[Buffer_Offset+1]&0xE0)!=0xE0))
+ Buffer_Offset++;
+
+ if (Buffer_Offset+3<=Buffer_Size)//Testing if size is coherant
+ {
+ //Testing next start, to be sure
+ int16u audioMuxLengthBytes=CC2(Buffer+Buffer_Offset+1)&0x1FFF;
+ if (IsSub && Buffer_Offset+3+audioMuxLengthBytes==Buffer_Size)
+ break;
+ if (File_Offset+Buffer_Offset+3+audioMuxLengthBytes!=File_Size)
+ {
+ if (Buffer_Offset+3+audioMuxLengthBytes+3>Buffer_Size)
+ return false; //Need more data
+
+ //Testing
+ if ((CC2(Buffer+Buffer_Offset+3+audioMuxLengthBytes)&0xFFE0)!=0x56E0)
+ Buffer_Offset++;
+ else
+ {
+ //Testing next start, to be sure
+ int16u audioMuxLengthBytes2=CC2(Buffer+Buffer_Offset+3+audioMuxLengthBytes+1)&0x1FFF;
+ if (File_Offset+Buffer_Offset+3+audioMuxLengthBytes+3+audioMuxLengthBytes2!=File_Size)
+ {
+ if (Buffer_Offset+3+audioMuxLengthBytes+3+audioMuxLengthBytes2+3>Buffer_Size)
+ return false; //Need more data
+
+ //Testing
+ if ((CC2(Buffer+Buffer_Offset+3+audioMuxLengthBytes+3+audioMuxLengthBytes2)&0xFFE0)!=0x56E0)
+ Buffer_Offset++;
+ else
+ break; //while()
+ }
+ else
+ break; //while()
+ }
+ }
+ else
+ break; //while()
+ }
+ }
+
+
+ //Synchronizing
+ while (Buffer_Offset+2<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x56
+ || (Buffer[Buffer_Offset+1]&0xE0)!=0xE0))
+ Buffer_Offset++;
+ if (Buffer_Offset+2>=Buffer_Size)
+ return false;
+
+ //Synched is OK
+ Mode=Mode_LATM;
+ File__Analyze::Accept("LATM");
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Aac::Synched_Test()
+{
+ switch (Mode)
+ {
+ case Mode_ADTS : return Synched_Test_ADTS();
+ case Mode_LATM : return Synched_Test_LATM();
+ default : return true; //No synchro
+ }
+}
+
+//---------------------------------------------------------------------------
+bool File_Aac::Synched_Test_ADTS()
+{
+ //Tags
+ if (!File__Tags_Helper::Synched_Test())
+ return false;
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+2>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if ((CC2(Buffer+Buffer_Offset)&0xFFF6)!=0xFFF0)
+ Synched=false;
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Aac::Synched_Test_LATM()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+2>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if ((CC2(Buffer+Buffer_Offset)&0xFFE0)!=0x56E0)
+ Synched=false;
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Demux
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+bool File_Aac::Demux_UnpacketizeContainer_Test()
+{
+ switch (Mode)
+ {
+ case Mode_ADTS : return Demux_UnpacketizeContainer_Test_ADTS();
+ case Mode_LATM : return Demux_UnpacketizeContainer_Test_LATM();
+ default : return true; //No header
+ }
+}
+bool File_Aac::Demux_UnpacketizeContainer_Test_ADTS()
+{
+ int16u aac_frame_length=(BigEndian2int24u(Buffer+Buffer_Offset+3)>>5)&0x1FFF; //13 bits
+ Demux_Offset=Buffer_Offset+aac_frame_length;
+
+ if (Demux_Offset>Buffer_Size && File_Offset+Buffer_Size!=File_Size)
+ return false; //No complete frame
+
+ Demux_UnpacketizeContainer_Demux();
+
+ return true;
+}
+bool File_Aac::Demux_UnpacketizeContainer_Test_LATM()
+{
+ int16u audioMuxLengthBytes=BigEndian2int16u(Buffer+Buffer_Offset+1)&0x1FFF; //13 bits
+ Demux_Offset=Buffer_Offset+3+audioMuxLengthBytes;
+
+ if (Demux_Offset>Buffer_Size && File_Offset+Buffer_Size!=File_Size)
+ return false; //No complete frame
+
+ Demux_UnpacketizeContainer_Demux();
+
+ return true;
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Aac::Header_Begin()
+{
+ switch (Mode)
+ {
+ case Mode_ADTS : return Header_Begin_ADTS();
+ case Mode_LATM : return Header_Begin_LATM();
+ default : return true; //No header
+ }
+}
+
+//---------------------------------------------------------------------------
+bool File_Aac::Header_Begin_ADTS()
+{
+ //There is no real header in ADTS, retrieving only the frame length
+ if (Buffer_Offset+8>Buffer_Size) //size of adts_fixed_header + adts_variable_header
+ return false;
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Aac::Header_Begin_LATM()
+{
+ if (Buffer_Offset+3>Buffer_Size) //fixed 24-bit header
+ return false;
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::Header_Parse()
+{
+ switch (Mode)
+ {
+ case Mode_ADTS : Header_Parse_ADTS(); break;
+ case Mode_LATM : Header_Parse_LATM(); break;
+ default : ; //No header
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::Header_Parse_ADTS()
+{
+ //There is no "header" in ADTS, retrieving only the frame length
+ int16u aac_frame_length=(BigEndian2int24u(Buffer+Buffer_Offset+3)>>5)&0x1FFF; //13 bits
+
+ //Filling
+ Header_Fill_Size(aac_frame_length);
+ Header_Fill_Code(0, "adts_frame");
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::Header_Parse_LATM()
+{
+ int16u audioMuxLengthBytes;
+ BS_Begin();
+ Skip_S2(11, "syncword");
+ Get_S2 (13, audioMuxLengthBytes, "audioMuxLengthBytes");
+ BS_End();
+
+ //Filling
+ Header_Fill_Size(3+audioMuxLengthBytes);
+ Header_Fill_Code(0, "LATM");
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::Data_Parse()
+{
+ if (FrameSize_Min>Header_Size+Element_Size)
+ FrameSize_Min=Header_Size+Element_Size;
+ if (FrameSize_Max<Header_Size+Element_Size)
+ FrameSize_Max=Header_Size+Element_Size;
+
+ if (Frame_Count>Frame_Count_Valid || CanFill)
+ {
+ Skip_XX(Element_Size, "Data");
+ FrameInfo.DTS+=float64_int64s(((float64)frame_length)*1000000000/sampling_frequency);
+ FrameInfo.PTS=FrameInfo.DTS;
+ return; //Parsing completely only the 1st frame
+ }
+
+ switch (Mode)
+ {
+ case Mode_ADTS : Data_Parse_ADTS(); break;
+ case Mode_LATM : Data_Parse_LATM(); break;
+ default : ; //No header
+ }
+
+ FILLING_BEGIN();
+ //Counting
+ if (File_Offset+Buffer_Offset+Element_Size==File_Size)
+ Frame_Count_Valid=Frame_Count; //Finish frames in case of there are less than Frame_Count_Valid frames
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ Element_Info1(Ztring::ToZtring(Frame_Count));
+
+ //Filling
+ if ((Frame_Count>=Frame_Count_Valid || CanFill) && Config_ParseSpeed<1.0)
+ {
+ //No more need data
+ switch (Mode)
+ {
+ case Mode_ADTS :
+ case Mode_LATM :
+ Fill();
+ if (!IsSub)
+ File__Tags_Helper::Finish(); break;
+ default : ; //No header
+ }
+
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::Data_Parse_ADTS()
+{
+ //Parsing
+ BS_Begin();
+ adts_frame();
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::Data_Parse_LATM()
+{
+ BS_Begin();
+ AudioMuxElement();
+ BS_End();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_AAC_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac.h
new file mode 100644
index 000000000..a741c3bbb
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac.h
@@ -0,0 +1,378 @@
+// File_Aac - Info for AAC (Raw) files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about AAC files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_AacH
+#define MediaInfo_File_AacH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#ifdef MEDIAINFO_MPEG4_YES
+ #include "MediaInfo/Multiple/File_Mpeg4_Descriptors.h"
+#endif
+#include "MediaInfo/Tag/File__Tags.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Aac
+//***************************************************************************
+
+struct sbr_handler
+{
+ //sbr_header
+ int8u bs_amp_res[2];
+ int8u bs_amp_res_FromHeader;
+ int8u bs_start_freq;
+ int8u bs_stop_freq;
+ int8u bs_xover_band;
+ int8u bs_freq_scale;
+ int8u bs_alter_scale;
+ int8u bs_noise_bands;
+
+ //sbr_grid
+ int8u bs_num_env[2];
+ bool bs_freq_res[2][8];
+ int8u bs_num_noise[2];
+
+ //sbr_dtdf
+ int8u bs_df_env[2][4];
+ int8u bs_df_noise[2][2];
+
+ //Computed values
+ int8u num_noise_bands;
+ int8u num_env_bands[2];
+};
+
+struct ps_handler
+{
+ bool enable_iid;
+ bool enable_icc;
+ bool enable_ext;
+ int8u iid_mode;
+ int8u icc_mode;
+};
+
+typedef const int8s (*sbr_huffman)[2];
+
+class File_Aac : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ bool FrameIsAlwaysComplete;
+ enum mode
+ {
+ Mode_Unknown,
+ Mode_AudioSpecificConfig,
+ Mode_raw_data_block,
+ Mode_ADIF,
+ Mode_ADTS,
+ Mode_LATM,
+ };
+ mode Mode;
+ void AudioSpecificConfig_OutOfBand(int32u sampling_frequency, int8u audioObjectType=(int8u)-1, bool sbrData=false, bool psData=false, bool sbrPresentFlag=false, bool psPresentFlag=false);
+
+ //Constructor/Destructor
+ File_Aac();
+ ~File_Aac();
+
+protected :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+ void FileHeader_Parse_ADIF();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+ void Read_Buffer_Continue_AudioSpecificConfig();
+ void Read_Buffer_Continue_raw_data_block();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synchronize_ADTS();
+ bool Synchronize_LATM();
+ bool Synched_Test();
+ bool Synched_Test_ADTS();
+ bool Synched_Test_LATM();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test();
+ bool Demux_UnpacketizeContainer_Test_ADTS();
+ bool Demux_UnpacketizeContainer_Test_LATM();
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Per element
+ bool Header_Begin();
+ bool Header_Begin_ADTS();
+ bool Header_Begin_LATM();
+ void Header_Parse();
+ void Header_Parse_ADTS();
+ void Header_Parse_LATM();
+ void Data_Parse();
+ void Data_Parse_ADTS();
+ void Data_Parse_LATM();
+
+ //***********************************************************************
+ // Elements - Main
+ //***********************************************************************
+
+ //Elements - Interface to MPEG-4 container
+ void AudioSpecificConfig (size_t End=(size_t)-1);
+ void GetAudioObjectType (int8u &ObjectType, const char* Name);
+
+ //Elements - Multiplex layer
+ void EPMuxElement ();
+ void AudioMuxElement ();
+ void StreamMuxConfig ();
+ int32u LatmGetValue ();
+ void PayloadLengthInfo ();
+ void PayloadMux ();
+ bool muxConfigPresent;
+
+ //Elements - Error protection
+ void ErrorProtectionSpecificConfig ();
+
+ //Elements - MPEG-2 AAC Audio_Data_Interchange_Format, ADIF
+ void adif_header ();
+
+ //Elements - Audio_Data_Transport_Stream frame, ADTS
+ void adts_frame ();
+ void adts_fixed_header ();
+ void adts_variable_header ();
+
+ //Temp
+ int8u numSubFrames;
+ int8u numProgram;
+ int8u numLayer;
+ int8u numChunk;
+ bool audioMuxVersionA;
+ int8u streamID[16][8];
+ int8u progSIndx[128];
+ int8u laySIndx[128];
+ int8u progCIndx[128];
+ int8u layCIndx[128];
+ int8u frameLengthType[128];
+ int16u frameLength[128];
+ int32u MuxSlotLengthBytes[128];
+ int32u otherDataLenBits;
+ bool otherDataPresent;
+ bool allStreamsSameTimeFraming;
+ int8u audioObjectType;
+ int8u extensionAudioObjectType;
+ int8u channelConfiguration;
+ int16u frame_length;
+ int8u sampling_frequency_index;
+ int32u sampling_frequency;
+ int8u extension_sampling_frequency_index;
+ int32u extension_sampling_frequency;
+ bool aacScalefactorDataResilienceFlag;
+ bool aacSectionDataResilienceFlag;
+ bool aacSpectralDataResilienceFlag;
+ std::vector<int16u> aac_frame_lengths;
+ int8u num_raw_data_blocks;
+ bool protection_absent;
+ int64u FrameSize_Min;
+ int64u FrameSize_Max;
+
+ //***********************************************************************
+ // Elements - Speech coding (HVXC)
+ //***********************************************************************
+
+ void HvxcSpecificConfig ();
+ void HVXCconfig ();
+ void ErrorResilientHvxcSpecificConfig ();
+ void ErHVXCconfig ();
+
+ //***********************************************************************
+ // Elements - Speech Coding (CELP)
+ //***********************************************************************
+
+ void CelpSpecificConfig ();
+ void CelpHeader ();
+ void ErrorResilientCelpSpecificConfig ();
+ void ER_SC_CelpHeader ();
+
+ //***********************************************************************
+ // Elements - General Audio (GA)
+ //***********************************************************************
+
+ //Elements - Decoder configuration
+ void GASpecificConfig ();
+ void program_config_element ();
+
+ //Elements - GA bitstream
+ void raw_data_block ();
+ void single_channel_element ();
+ void channel_pair_element ();
+ void ics_info ();
+ void pulse_data ();
+ void coupling_channel_element ();
+ void lfe_channel_element ();
+ void data_stream_element ();
+ void fill_element (int8u old_id);
+ void gain_control_data ();
+
+ //Elements - Subsidiary
+ void individual_channel_stream (bool common_window, bool scale_flag);
+ void section_data ();
+ void scale_factor_data ();
+ void tns_data ();
+ void ltp_data ();
+ void spectral_data ();
+ void extension_payload (size_t End, int8u id_aac);
+ void dynamic_range_info ();
+ void sac_extension_data (size_t End);
+
+ //Elements - SBR
+ void sbr_extension_data (size_t End, int8u id_aac, bool crc_flag);
+ void sbr_header ();
+ void sbr_data (int8u id_aac);
+ void sbr_single_channel_element ();
+ void sbr_channel_pair_element ();
+ void sbr_grid (bool ch);
+ void sbr_dtdf (bool ch);
+ void sbr_invf (bool ch);
+ void sbr_envelope (bool ch, bool bs_coupling);
+ void sbr_noise (bool ch, bool bs_coupling);
+ void sbr_sinusoidal_coding (bool ch);
+ int16u sbr_huff_dec (sbr_huffman Table, const char* Name);
+
+ //Elements - SBR - PS
+ void ps_data (size_t End);
+
+ //Elements - Perceptual noise substitution (PNS)
+ bool is_noise (size_t group, size_t sfb);
+ int is_intensity (size_t group, size_t sfb);
+
+ //Elements - Enhanced Low Delay Codec
+ void ELDSpecificConfig ();
+ void ld_sbr_header ();
+
+ //Helpers
+ void hcod (int8u sect_cb, const char* Name);
+ void hcod_sf (const char* Name);
+ void hcod_binary (int8u CodeBook, int8s* Values, int8u Values_Count);
+ void hcod_2step (int8u CodeBook, int8s* Values, int8u Values_Count);
+
+ //Temp - channel_pair_element
+ bool common_window;
+
+ //Temp - ics_info
+ int8u window_sequence;
+ int8u max_sfb;
+ int8u scale_factor_grouping;
+ int8u num_windows;
+ int8u num_window_groups;
+ int8u window_group_length [8];
+ int16u sect_sfb_offset [8][1024];
+ int16u swb_offset [64];
+ int8u sfb_cb [8][64];
+ int8u num_swb;
+
+ //Temp - section_data
+ int8u num_sec [8];
+ int8u sect_cb [8][64];
+ int16u sect_start [8][64];
+ int16u sect_end [8][64];
+
+ //Temp - ltp_data
+ int16u ltp_lag;
+
+ //Temp - SBR
+ sbr_handler* sbr;
+
+ //Temp - PS
+ ps_handler* ps;
+
+ //***********************************************************************
+ // Elements - Structured Audio (SA)
+ //***********************************************************************
+
+ void StructuredAudioSpecificConfig ();
+
+ //***********************************************************************
+ // Elements - Text to Speech Interface (TTSI)
+ //***********************************************************************
+
+ void TTSSpecificConfig ();
+
+ //***********************************************************************
+ // Elements - Parametric Audio (HILN)
+ //***********************************************************************
+
+ void HILNconfig ();
+ void HILNenexConfig ();
+ void ParametricSpecificConfig ();
+ void PARAconfig ();
+
+ //***********************************************************************
+ // Elements - Technical description of parametric coding for high quality audio
+ //***********************************************************************
+
+ void SSCSpecificConfig ();
+
+ //***********************************************************************
+ // Elements - MPEG-1/2 Audio
+ //***********************************************************************
+
+ void MPEG_1_2_SpecificConfig ();
+
+ //***********************************************************************
+ // Elements - Technical description of lossless coding of oversampled audio
+ //***********************************************************************
+
+ void DSTSpecificConfig ();
+ //***********************************************************************
+ // Elements - Audio Lossless
+ //***********************************************************************
+
+ void ALSSpecificConfig ();
+
+ //***********************************************************************
+ // Elements - Scalable lossless
+ //***********************************************************************
+
+ void SLSSpecificConfig ();
+
+ //***********************************************************************
+ // Temp
+ //***********************************************************************
+
+ std::map<std::string, Ztring> Infos_General;
+ std::map<std::string, Ztring> Infos;
+ bool CanFill;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio.cpp
new file mode 100644
index 000000000..57704fb54
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio.cpp
@@ -0,0 +1,1439 @@
+// File_Aac - Info for AAC (Raw) files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AAC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Aac.h"
+#include "MediaInfo/Audio/File_Aac_GeneralAudio.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+extern const int32u Aac_sampling_frequency[];
+extern const char* Aac_audioObjectType(int8u audioObjectType);
+extern const char* Aac_Format_Profile(int8u ID);
+
+//---------------------------------------------------------------------------
+const char* Aac_id_syn_ele[8]=
+{
+ "SCE - single_channel_element",
+ "CPE - channel_pair_element",
+ "CCE - coupling_channel_element",
+ "LFE - lfe_channel_element",
+ "DSE - data_stream_element",
+ "PCE - program_config_element",
+ "FIL - fill_element",
+ "END - End"
+};
+
+//---------------------------------------------------------------------------
+const char* Aac_window_sequence[4]=
+{
+ "ONLY_LONG_SEQUENCE",
+ "LONG_START_SEQUENCE",
+ "EIGHT_SHORT_SEQUENCE",
+ "LONG_STOP_SEQUENCE"
+};
+
+//***************************************************************************
+// Elements - Decoder configuration
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::GASpecificConfig ()
+{
+ //Parsing
+ Element_Begin1("GASpecificConfig");
+ bool frameLengthFlag, dependsOnCoreCoder, extensionFlag;
+ Get_SB ( frameLengthFlag, "frameLengthFlag");
+ frame_length=frameLengthFlag==0?1024:960; Param_Info2(frame_length, " bytes");
+ Get_SB ( dependsOnCoreCoder, "dependsOnCoreCoder");
+ if (dependsOnCoreCoder)
+ Skip_S2(14, "coreCoderDelay");
+ Get_SB ( extensionFlag, "extensionFlag");
+ if (channelConfiguration==0)
+ program_config_element();
+ if (audioObjectType==06 || audioObjectType==20)
+ Skip_S1(3, "layerNr");
+ if (extensionFlag)
+ {
+ bool extensionFlag3;
+ if (audioObjectType==22)
+ {
+ Skip_S1( 5, "numOfSubFrame");
+ Skip_S2(11, "layer_length");
+ }
+ if (audioObjectType==17
+ || audioObjectType==19
+ || audioObjectType==20
+ || audioObjectType==23)
+ {
+ Skip_SB( "aacSectionDataResilienceFlag");
+ Skip_SB( "aacScalefactorDataResilienceFlag");
+ Skip_SB( "aacSpectralDataResilienceFlag");
+ }
+ Get_SB ( extensionFlag3, "extensionFlag3");
+ if (extensionFlag3)
+ {
+ Skip_BS(Data_BS_Remain(), "Not implemented");
+ }
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::program_config_element()
+{
+ Element_Begin1("program_config_element");
+ Ztring comment_field_data;
+ int8u Channels=0, Channels_Front=0, Channels_Side=0, Channels_Back=0, Channels_LFE=0;
+ int8u num_front_channel_elements, num_side_channel_elements, num_back_channel_elements, num_lfe_channel_elements, num_assoc_data_elements, num_valid_cc_elements, comment_field_bytes;
+ int8u audioObjectType_Temp, sampling_frequency_index_Temp;
+ Skip_S1(4, "element_instance_tag");
+ Get_S1 (2, audioObjectType_Temp, "object_type"); audioObjectType_Temp++; Param_Info1(Aac_audioObjectType(audioObjectType_Temp));
+ Get_S1 (4, sampling_frequency_index_Temp, "sampling_frequency_index"); Param_Info1(Aac_sampling_frequency[sampling_frequency_index_Temp]);
+ Get_S1 (4, num_front_channel_elements, "num_front_channel_elements");
+ Get_S1 (4, num_side_channel_elements, "num_side_channel_elements");
+ Get_S1 (4, num_back_channel_elements, "num_back_channel_elements");
+ Get_S1 (2, num_lfe_channel_elements, "num_lfe_channel_elements");
+ Get_S1 (3, num_assoc_data_elements, "num_assoc_data_elements");
+ Get_S1 (4, num_valid_cc_elements, "num_valid_cc_elements");
+ TEST_SB_SKIP( "mono_mixdown_present");
+ Skip_S1(4, "mono_mixdown_element_number");
+ TEST_SB_END();
+ TEST_SB_SKIP( "stereo_mixdown_present");
+ Skip_S1(4, "stereo_mixdown_element_number");
+ TEST_SB_END();
+ TEST_SB_SKIP( "matrix_mixdown_idx_present");
+ Skip_S1(2, "matrix_mixdown_idx");
+ Skip_SB( "pseudo_surround_enable");
+ TEST_SB_END();
+ for (int8u Pos=0; Pos<num_front_channel_elements; Pos++)
+ {
+ Element_Begin1("front_element");
+ bool front_element_is_cpe;
+ Get_SB ( front_element_is_cpe, "front_element_is_cpe");
+ Skip_S1(4, "front_element_tag_select");
+ if (front_element_is_cpe)
+ {
+ Channels_Front+=2;
+ Channels+=2;
+ }
+ else
+ {
+ Channels_Front++;
+ Channels++;
+ }
+ Element_End0();
+ }
+ for (int8u Pos=0; Pos<num_side_channel_elements; Pos++)
+ {
+ Element_Begin1("side_element");
+ bool side_element_is_cpe;
+ Get_SB ( side_element_is_cpe, "side_element_is_cpe");
+ Skip_S1(4, "side_element_tag_select");
+ if (side_element_is_cpe)
+ {
+ Channels_Side+=2;
+ Channels+=2;
+ }
+ else
+ {
+ Channels_Side++;
+ Channels++;
+ }
+ Element_End0();
+ }
+ for (int8u Pos=0; Pos<num_back_channel_elements; Pos++)
+ {
+ Element_Begin1("back_element");
+ bool back_element_is_cpe;
+ Get_SB ( back_element_is_cpe, "back_element_is_cpe");
+ Skip_S1(4, "back_element_tag_select");
+ if (back_element_is_cpe)
+ {
+ Channels_Back+=2;
+ Channels+=2;
+ }
+ else
+ {
+ Channels_Back++;
+ Channels++;
+ }
+ Element_End0();
+ }
+ for (int8u Pos=0; Pos<num_lfe_channel_elements; Pos++)
+ {
+ Element_Begin1("lfe_element");
+ Skip_S1(4, "lfe_element_tag_select");
+ Channels_LFE++;
+ Channels++;
+ Element_End0();
+ }
+ for (int8u Pos=0; Pos<num_assoc_data_elements; Pos++)
+ {
+ Element_Begin1("assoc_data_element");
+ Skip_S1(4, "assoc_data_element_tag_select");
+ Element_End0();
+ }
+ for (int8u Pos=0; Pos<num_valid_cc_elements; Pos++)
+ {
+ Element_Begin1("valid_cc_element");
+ Skip_SB( "cc_element_is_ind_sw");
+ Skip_S1(4, "valid_cc_element_tag_select");
+ Element_End0();
+ }
+ BS_End(); //Byte align
+ Get_B1 (comment_field_bytes, "comment_field_bytes");
+ if (comment_field_bytes)
+ Get_Local(comment_field_bytes, comment_field_data, "comment_field_data");
+ BS_Begin(); //The stream needs continuity in the bitstream
+ Element_End0();
+
+ //Filling
+ Ztring Channels_Positions, Channels_Positions2;
+ switch (Channels_Front)
+ {
+ case 0 : break;
+ case 1 : Channels_Positions+=_T("Front: C"); break;
+ case 2 : Channels_Positions+=_T("Front: L R"); break;
+ case 3 : Channels_Positions+=_T("Front: L C R"); break;
+ default : Channels_Positions+=_T("Front: "); Channels_Positions+=Ztring::ToZtring(Channels_Front); //Which config?
+ }
+ switch (Channels_Side)
+ {
+ case 0 : break;
+ case 1 : Channels_Positions+=_T(", Side: C"); break;
+ case 2 : Channels_Positions+=_T(", Side: L R"); break;
+ case 3 : Channels_Positions+=_T(", Side: L C R"); break;
+ default : Channels_Positions+=_T(", Side: "); Channels_Positions+=Ztring::ToZtring(Channels_Side); //Which config?
+ }
+ switch (Channels_Back)
+ {
+ case 0 : break;
+ case 1 : Channels_Positions+=_T(", Back: C"); break;
+ case 2 : Channels_Positions+=_T(", Back: L R"); break;
+ case 3 : Channels_Positions+=_T(", Back: L C R"); break;
+ default : Channels_Positions+=_T(", Back: "); Channels_Positions+=Ztring::ToZtring(Channels_Back); //Which config?
+ }
+ switch (Channels_LFE)
+ {
+ case 0 : break;
+ case 1 : Channels_Positions+=_T(", LFE"); break;
+ default : Channels_Positions+=_T(", LFE= "); Channels_Positions+=Ztring::ToZtring(Channels_LFE); //Which config?
+ }
+ Channels_Positions2=Ztring::ToZtring(Channels_Front)+_T('/')
+ +Ztring::ToZtring(Channels_Side)+_T('/')
+ +Ztring::ToZtring(Channels_Back)
+ +(Channels_LFE?_T(".1"):_T(""));
+
+ FILLING_BEGIN();
+ //Integrity test
+ if (Aac_sampling_frequency[sampling_frequency_index_Temp]==0 || Channels_Front<Channels_Side || Channels_Side<Channels_Back)
+ {
+ Skip_BS(Data_BS_Remain(), "(Unknown frequency)");
+ return;
+ }
+
+ if (audioObjectType==(int8u)-1)
+ audioObjectType=audioObjectType_Temp;
+ if (sampling_frequency_index==(int8u)-1)
+ sampling_frequency_index=sampling_frequency_index_Temp;
+
+ Infos_General["Comment"]=comment_field_data;
+
+ Infos["Format"].From_Local("AAC");
+ Infos["Format_Profile"].From_Local(Aac_Format_Profile(audioObjectType));
+ Infos["Codec"].From_Local(Aac_audioObjectType(audioObjectType));
+ Infos["SamplingRate"].From_Number(Aac_sampling_frequency[sampling_frequency_index]);
+ Infos["Channel(s)"].From_Number(Channels);
+ Infos["ChannelPositions"]=Channels_Positions;
+ Infos["ChannelPositions/String2"]=Channels_Positions2;
+
+ if (!Infos["Format_Settings_SBR"].empty())
+ {
+ Infos["Format_Profile"]=_T("HE-AAC");
+ Ztring SamplingRate=Infos["SamplingRate"];
+ Infos["SamplingRate"].From_Number((extension_sampling_frequency_index==(int8u)-1)?(sampling_frequency*2):extension_sampling_frequency, 10);
+ if (MediaInfoLib::Config.LegacyStreamDisplay_Get())
+ {
+ Infos["Format_Profile"]+=_T(" / LC");
+ Infos["SamplingRate"]+=_T(" / ")+SamplingRate;
+ }
+ Infos["Format_Settings_SBR"]=_T("Yes (Implicit)");
+ Infos["Codec"]=Ztring().From_Local(Aac_audioObjectType(audioObjectType))+_T("-SBR");
+ }
+
+ if (!Infos["Format_Settings_PS"].empty())
+ {
+ Infos["Format_Profile"]=_T("HE-AACv2");
+ Ztring Channels=Infos["Channel(s)"];
+ Ztring ChannelPositions=Infos["ChannelPositions"];
+ Ztring SamplingRate=Infos["SamplingRate"];
+ Infos["Channel(s)"]=_T("2");
+ Infos["ChannelPositions"]=_T("Front: L R");
+ if (MediaInfoLib::Config.LegacyStreamDisplay_Get())
+ {
+ Infos["Format_Profile"]+=_T(" / HE-AAC / LC");
+ Infos["Channel(s)"]+=_T(" / ")+Channels+_T(" / ")+Channels;
+ Infos["ChannelPositions"]+=_T(" / ")+ChannelPositions+_T(" / ")+ChannelPositions;
+ Infos["SamplingRate"]=Ztring().From_Number((extension_sampling_frequency_index==(int8u)-1)?(sampling_frequency*2):extension_sampling_frequency, 10)+_T(" / ")+SamplingRate;
+ }
+ Infos["Format_Settings_PS"]=_T("Yes (Implicit)");
+ Ztring Codec=Retrieve(Stream_Audio, StreamPos_Last, Audio_Codec);
+ Infos["Codec"]=Ztring().From_Local(Aac_audioObjectType(audioObjectType))+_T("-SBR-PS");
+ }
+ FILLING_END();
+}
+
+//***************************************************************************
+// Elements - GA bitstream
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::raw_data_block()
+{
+ if (audioObjectType!=2)
+ {
+ Skip_BS(Data_BS_Remain(), "Data");
+ return; //We test only AAC LC
+ }
+
+ if (sampling_frequency_index>=16 || Aac_sampling_frequency[sampling_frequency_index]==0)
+ {
+ Trusted_IsNot("(Problem)");
+ Skip_BS(Data_BS_Remain(), "(Problem)");
+ return;
+ }
+
+ //Parsing
+ Element_Begin1("raw_data_block");
+ int8u id_syn_ele=0, id_syn_ele_Previous;
+ do
+ {
+ Element_Begin0();
+ id_syn_ele_Previous=id_syn_ele;
+ Get_S1 (3, id_syn_ele, "id_syn_ele"); Param_Info1(Aac_id_syn_ele[id_syn_ele]); Element_Name(Aac_id_syn_ele[id_syn_ele]);
+ switch (id_syn_ele)
+ {
+ case 0x00 : single_channel_element(); break; //ID_SCE
+ case 0x01 : channel_pair_element(); break; //ID_CPE
+ case 0x02 : coupling_channel_element(); break; //ID_CCE
+ case 0x03 : lfe_channel_element(); break; //ID_LFE
+ case 0x04 : data_stream_element(); break; //ID_DSE
+ case 0x05 : program_config_element(); break; //ID_PCE
+ case 0x06 : fill_element(id_syn_ele_Previous); break; //ID_FIL
+ case 0x07 : break; //ID_END
+ default : ; //Can not happen
+ }
+ Element_End0();
+ }
+ while(Element_IsOK() && Data_BS_Remain() && id_syn_ele!=0x07); //ID_END
+ if (Element_IsOK() && Data_BS_Remain()%8)
+ Skip_S1(Data_BS_Remain()%8, "byte_alignment");
+ Element_End0();
+
+ if (sampling_frequency)
+ {
+ FrameInfo.DTS+=float64_int64s(((float64)frame_length)*1000000000/sampling_frequency);
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::single_channel_element()
+{
+ //Parsing
+ Skip_S1 (4, "element_instance_tag");
+ individual_channel_stream(false, false);
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::channel_pair_element()
+{
+ //Parsing
+ Skip_S1(4, "element_instance_tag");
+ Get_SB (common_window, "common_window");
+ if (common_window)
+ {
+ int8u ms_mask_present;
+ ics_info();
+ Get_S1(2, ms_mask_present, "ms_mask_present");
+ if (ms_mask_present==1)
+ {
+ Element_Begin1("ms_mask");
+ for (int8u g=0; g<num_window_groups; g++)
+ {
+ Element_Begin1("window");
+ for (int8u sfb=0; sfb<max_sfb; sfb++)
+ Skip_SB( "ms_used[g][sfb]");
+ Element_End0();
+ }
+ Element_End0();
+ }
+ }
+ individual_channel_stream(common_window, false);
+ if (!Element_IsOK())
+ return;
+ individual_channel_stream(common_window, false);
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::ics_info()
+{
+ //Parsing
+ Element_Begin1("ics_info");
+ Skip_SB( "ics_reserved_bit");
+ Get_S1 (2, window_sequence, "window_sequence"); Param_Info1(Aac_window_sequence[window_sequence]);
+ Skip_SB( "window_shape");
+ if (window_sequence==2) //EIGHT_SHORT_SEQUENCE
+ {
+ Get_S1 (4, max_sfb, "max_sfb");
+ Get_S1 (7, scale_factor_grouping, "scale_factor_grouping");
+ }
+ else
+ {
+ bool predictor_data_present;
+ Get_S1 (6, max_sfb, "max_sfb");
+ Get_SB ( predictor_data_present, "predictor_data_present");
+ if (predictor_data_present)
+ {
+ if (audioObjectType==1) //AAC Main
+ {
+ bool predictor_reset;
+ Get_SB (predictor_reset, "predictor_reset");
+ if (predictor_reset)
+ Skip_S1(5, "predictor_reset_group_number");
+ int8u PRED_SFB_MAX=max_sfb;
+ if (PRED_SFB_MAX>Aac_PRED_SFB_MAX[sampling_frequency_index])
+ PRED_SFB_MAX=Aac_PRED_SFB_MAX[sampling_frequency_index];
+ for (int8u sfb=0; sfb<PRED_SFB_MAX; sfb++)
+ Skip_SB( "prediction_used[sfb]");
+ }
+ else
+ {
+ bool ltp_data_present;
+ Get_SB (ltp_data_present, "ltp_data_present");
+ if (ltp_data_present)
+ ltp_data();
+ if (common_window)
+ {
+ Get_SB (ltp_data_present, "ltp_data_present");
+ if (ltp_data_present)
+ ltp_data();
+ }
+ }
+ }
+ }
+ Element_End0();
+
+ //Calculation of windows
+ switch (window_sequence)
+ {
+ case 0 : //ONLY_LONG_SEQUENCE
+ case 1 : //LONG_START_SEQUENCE
+ case 3 : //LONG_STOP_SEQUENCE
+ num_windows=1;
+ num_window_groups=1;
+ window_group_length[0]=1;
+ num_swb=Aac_swb_offset_long_window[sampling_frequency_index]->num_swb;
+ for (int8u i=0; i<num_swb+1; i++)
+ {
+ if (Aac_swb_offset_long_window[sampling_frequency_index]->swb_offset[i]<frame_length)
+ swb_offset[i]=Aac_swb_offset_long_window[sampling_frequency_index]->swb_offset[i];
+ else
+ swb_offset[i]=frame_length;
+ sect_sfb_offset[0][i]=swb_offset[i];
+ }
+ break;
+ case 2 : //EIGHT_SHORT_SEQUENCE
+ num_windows=8;
+ num_window_groups=1;
+ window_group_length[0]=1;
+ num_swb=Aac_swb_offset_short_window[sampling_frequency_index]->num_swb;
+ for (int8u i=0; i<num_swb + 1; i++)
+ swb_offset[i] = Aac_swb_offset_short_window[sampling_frequency_index]->swb_offset[i];
+ swb_offset[num_swb] = frame_length/8;
+ for (int8u i=0; i<num_windows-1; i++)
+ {
+ if (!(scale_factor_grouping&(1<<(6-i))))
+ {
+ num_window_groups++;
+ window_group_length[num_window_groups-1]=1;
+ }
+ else
+ window_group_length[num_window_groups-1]++;
+ }
+ for (int g = 0; g < num_window_groups; g++)
+ {
+ int8u sect_sfb = 0;
+ int16u offset = 0;
+ for (int8u i=0; i<num_swb; i++)
+ {
+ int16u width = Aac_swb_offset_short_window[sampling_frequency_index]->swb_offset[i+1] - Aac_swb_offset_short_window[sampling_frequency_index]->swb_offset[i];
+ width *= window_group_length[g];
+ sect_sfb_offset[g][sect_sfb++] = offset;
+ offset += width;
+ }
+ sect_sfb_offset[g][sect_sfb] = offset;
+ }
+ break;
+ default: ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::pulse_data()
+{
+ //Parsing
+ int8u number_pulse;
+ Get_S1(2,number_pulse, "number_pulse");
+ Skip_S1(6, "pulse_start_sfb");
+ for (int i = 0; i < number_pulse+1; i++)
+ {
+ Skip_S1(5, "pulse_offset[i]");
+ Skip_S1(4, "pulse_amp[i]");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::coupling_channel_element()
+{
+ //Parsing
+ int8u num_coupled_elements;
+ bool ind_sw_cce_flag;
+ Skip_S1(4, "element_instance_tag");
+ Get_SB ( ind_sw_cce_flag, "ind_sw_cce_flag");
+ Get_S1 (3, num_coupled_elements, "num_coupled_elements");
+ size_t num_gain_element_lists=0;
+ for (int8u c=0; c<num_coupled_elements+1; c++)
+ {
+ num_gain_element_lists++;
+ bool cc_target_is_cpe;
+ Get_SB ( cc_target_is_cpe, "cc_target_is_cpe[c]");
+ Skip_S1(4, "cc_target_tag_select[c]");
+ if (cc_target_is_cpe)
+ {
+ bool cc_l, cc_r;
+ Get_SB (cc_l, "cc_l[c]");
+ Get_SB (cc_r, "cc_r[c]");
+ if (cc_l && cc_r)
+ num_gain_element_lists++;
+ }
+ }
+ Skip_SB( "cc_domain");
+ Skip_SB( "gain_element_sign");
+ Skip_S1(2, "gain_element_scale");
+ individual_channel_stream(false, false);
+ if (!Element_IsOK())
+ return;
+ bool cge;
+ for (size_t c=1; c<num_gain_element_lists; c++)
+ {
+ if (ind_sw_cce_flag)
+ cge = true;
+ else
+ Get_SB (cge, "common_gain_element_present[c]");
+ if (cge)
+ hcod_sf( "hcod_sf[common_gain_element[c]]");
+ else
+ {
+ for (int g = 0; g < num_window_groups; g++)
+ {
+ for (int sfb=0; sfb<max_sfb; sfb++)
+ {
+ if (sfb_cb[g][sfb]) //Not ZERO_HCB
+ hcod_sf( "hcod_sf[dpcm_gain_element[c][g][sfb]]");
+ }
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::lfe_channel_element()
+{
+ Skip_S1(4, "element_instance_tag");
+ individual_channel_stream(false, false);
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::data_stream_element()
+{
+ bool data_byte_align_flag;
+ int16u cnt;
+ int8u count;
+ Skip_S1(4, "element_instance_tag");
+ Get_SB ( data_byte_align_flag, "data_byte_align_flag");
+ Get_S1 (8, count, "count");
+ cnt=count;
+ if (cnt==255)
+ {
+ Get_S1(8, count, "esc_count");
+ cnt+=count;
+ }
+ if (data_byte_align_flag)
+ {
+ if (Data_BS_Remain()%8)
+ Skip_S1(Data_BS_Remain()%8, "byte_alignment");
+ }
+ Element_Begin1("data_stream_byte[element_instance_tag]");
+ for (int16u i=0; i<cnt; i++)
+ Skip_S1(8, "[i]");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::fill_element(int8u id_syn_ele)
+{
+ //Parsing
+ int8u count;
+ Get_S1 (4, count, "count");
+ size_t cnt=count;
+ if (count==15)
+ {
+ int8u esc_count;
+ Get_S1 (8, esc_count, "esc_count");
+ cnt+=esc_count-1;
+ }
+ if (cnt)
+ {
+ if (Data_BS_Remain()>=8*cnt)
+ {
+ size_t End=Data_BS_Remain()-8*cnt;
+ extension_payload(End, id_syn_ele);
+ }
+ else
+ Skip_BS(Data_BS_Remain(), "(Error)");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::gain_control_data()
+{
+ int8u max_band, adjust_num, aloc_bits, aloc_bits0;
+ int8u wd_max=0;
+ switch(window_sequence)
+ {
+ case 0 : //ONLY_LONG_SEQUENCE
+ wd_max = 1;
+ aloc_bits0 = 5;
+ aloc_bits = 5;
+ break;
+ case 1 : //LONG_START_SEQUENCE
+ wd_max = 2;
+ aloc_bits0 = 4;
+ aloc_bits = 2;
+ break;
+ case 2 : //EIGHT_SHORT_SEQUENCE
+ wd_max = 8;
+ aloc_bits0 = 2;
+ aloc_bits = 2;
+ break;
+ case 3 : //LONG_STOP_SEQUENCE
+ wd_max = 2;
+ aloc_bits0 = 4;
+ aloc_bits = 5;
+ break;
+ default: return; //Never happens but makes compiler happy
+ }
+ Get_S1 (2, max_band, "max_band");
+ for (int8u bd=1; bd<=max_band; bd++)
+ {
+ for (int8u wd=0; wd<wd_max; wd++)
+ {
+ Get_S1(3, adjust_num, "adjust_num[bd][wd]");
+ for (int8u ad=0; ad<adjust_num; ad++)
+ {
+ Skip_S1(4, "alevcode[bd][wd][ad]");
+ Skip_S1(wd==0?aloc_bits0:aloc_bits, "aloccode[bd][wd][ad]");
+ }
+ }
+ }
+}
+
+//***************************************************************************
+// Elements - Subsidiary
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::individual_channel_stream (bool common_window, bool scale_flag)
+{
+ Element_Begin1("individual_channel_stream");
+ Skip_S1(8, "global_gain");
+ if (!common_window && !scale_flag)
+ ics_info();
+ if (!Element_IsOK())
+ {
+ Element_End0();
+ return;
+ }
+ section_data();
+ if (!Element_IsOK())
+ {
+ Element_End0();
+ return;
+ }
+ scale_factor_data();
+ if (!Element_IsOK())
+ {
+ Element_End0();
+ return;
+ }
+ if (!scale_flag)
+ {
+ bool pulse_data_present;
+ Get_SB (pulse_data_present, "pulse_data_present");
+ if (pulse_data_present)
+ pulse_data ();
+ bool tns_data_present;
+ Get_SB(tns_data_present, "tns_data_present");
+ if (tns_data_present)
+ tns_data ();
+ bool gain_control_data_present;
+ Get_SB(gain_control_data_present, "gain_control_data_present");
+ if (gain_control_data_present)
+ gain_control_data ();
+ }
+ if (!aacSpectralDataResilienceFlag)
+ spectral_data ();
+ else
+ {
+ Skip_BS(Data_BS_Remain(), "Not implemented");
+ //~ length_of_reordered_spectral_data;
+ //~ length_of_longest_codeword;
+ //~ reordered_spectral_data ();
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::section_data()
+{
+ Element_Begin1("section_data");
+ int8u sect_esc_val;
+ if (window_sequence==2) //EIGHT_SHORT_SEQUENCE
+ sect_esc_val=(1<<3)-1;
+ else
+ sect_esc_val=(1<<5)-1;
+ for (int8u g=0; g<num_window_groups; g++)
+ {
+ if (num_window_groups>1)
+ Element_Begin1("windows");
+ int8u k=0;
+ int8u i=0;
+ while (k<max_sfb)
+ {
+ if (aacSectionDataResilienceFlag)
+ Get_S1(5, sect_cb[g][i], "sect_cb[g][i]");
+ else
+ Get_S1(4, sect_cb[g][i], "sect_cb[g][i]");
+ int8u sect_len=0;
+ int8u sect_len_incr;
+ if (!aacSectionDataResilienceFlag || sect_cb[g][i]<11 || (sect_cb[g][i]>11 && sect_cb[g][i]<16))
+ {
+ for (;;)
+ {
+ if (Data_BS_Remain()==0)
+ {
+ Trusted_IsNot("Size is wrong");
+ if (num_window_groups>1)
+ Element_End0();
+ Element_End0();
+ return; //Error
+ }
+ Get_S1 ((window_sequence==2?3:5), sect_len_incr, "sect_len_incr"); // (window_sequence == EIGHT_SHORT_SEQUENCE) => 3
+ if (sect_len_incr!=sect_esc_val)
+ break;
+ sect_len+=sect_esc_val;
+ }
+ }
+ else
+ sect_len_incr=1;
+ sect_len+=sect_len_incr;
+ sect_start[g][i]=k;
+ sect_end[g][i]=k+sect_len;
+ for (int8u sfb=k; sfb<k+sect_len; sfb++)
+ sfb_cb[g][sfb]=sect_cb[g][i];
+ k+= sect_len;
+ i++;
+ }
+ num_sec[g]=i;
+ if (num_window_groups>1)
+ Element_End0();
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::scale_factor_data()
+{
+ Element_Begin1("scale_factor_data");
+ if (!aacScalefactorDataResilienceFlag)
+ {
+ bool noise_pcm_flag=true;
+ for (int g=0; g<num_window_groups; g++)
+ {
+ for (int8u sfb=0; sfb<max_sfb; sfb++)
+ {
+ if (sfb_cb[g][sfb]) //Not ZERO_HCB
+ {
+ if (is_intensity( g, sfb))
+ hcod_sf( "hcod_sf[dpcm_is_position[g][sfb]]");
+ else
+ {
+ if (is_noise(g, sfb))
+ {
+ if (noise_pcm_flag)
+ {
+ noise_pcm_flag = 0;
+ Skip_S2(9, "dpcm_noise_nrg[g][sfb]");
+ }
+ else
+ hcod_sf( "hcod_sf[dpcm_noise_nrg[g][sfb]]");
+ }
+ else
+ hcod_sf( "hcod_sf[dpcm_sf[g][sfb]]");
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ //scale_factor_data - part not implemented
+ Skip_BS(Data_BS_Remain(), "Not implemented");
+ //~ intensity_used = 0;
+ //~ noise_used = 0;
+ //~ sf_concealment;
+ //~ rev_global_gain;
+ //~ length_of_rvlc_sf;
+ //~ for ( g = 0; g < num_window_groups; g++ ) {
+ //~ for ( sfb=0; sfb < max_sfb; sfb++ ) {
+ //~ if ( sfb_cb[g][sfb] ) { //Not ZERO_HCB
+ //~ if ( is_intensity ( g, sfb) ) {
+ //~ intensity_used = 1;
+ //~ rvlc_cod_sf[dpcm_is_position[g][sfb]];
+ //~ } else {
+ //~ if ( is_noise(g,sfb) ) {
+ //~ if ( ! noise_used ) {
+ //~ noise_used = 1;
+ //~ dpcm_noise_nrg[g][sfb];
+ //~ } else {
+ //~ rvlc_cod_sf[dpcm_noise_nrg[g][sfb]];
+ //~ }
+ //~ } else {
+ //~ rvlc_cod_sf[dpcm_sf[g][sfb]];
+ //~ }
+ //~ }
+ //~ }
+ //~ }
+ //~ }
+ //~ if ( intensity_used ) {
+ //~ rvlc_cod_sf[dpcm_is_last_position];
+ //~ }
+ //~ noise_used = 0;
+ //~ sf_escapes_present;
+ //~ if ( sf_escapes_present ) {
+ //~ length_of_rvlc_escapes;
+ //~ for ( g = 0; g < num_window_groups; g++ ) {
+ //~ for ( sfb = 0; sfb < max_sfb; sfb++ ) {
+ //~ if ( sfb_cb[g][sfb]) { //Not ZERO_HCB
+ //~ if ( is_intensity ( g, sfb ) && dpcm_is_position[g][sfb] == ESC_FLAG ) {
+ //~ rvlc_esc_sf[dpcm_is_position[g][sfb]];
+ //~ } else {
+ //~ if ( is_noise ( g, sfb ) {
+ //~ if ( ! noise_used ) {
+ //~ noise_used = 1;
+ //~ } else {
+ //~ if (dpcm_noise_nrg[g][sfb] == ESC_FLAG ) {
+ //~ rvlc_esc_sf[dpcm_noise_nrg[g][sfb]];
+ //~ }
+ //~ }
+ //~ } else {
+ //~ if (dpcm_sf[g][sfb] == ESC_FLAG ) {
+ //~ rvlc_esc_sf[dpcm_sf[g][sfb]];
+ //~ }
+ //~ }
+ //~ }
+ //~ }
+ //~ }
+ //~ }
+ //~ if ( intensity_used && dpcm_is_last_position == ESC_FLAG ) {
+ //~ rvlc_esc_sf[dpcm_is_last_position];
+ //~ }
+ //~ }
+ //~ if ( noise_used ) {
+ //~ dpcm_noise_last_position;
+ //~ }
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::tns_data()
+{
+ int8u n_filt_bits=2;
+ int8u length_bits=6;
+ int8u order_bits=5;
+
+ if (window_sequence==2) //EIGHT_SHORT_SEQUENCE
+ {
+ n_filt_bits=1;
+ length_bits=4;
+ order_bits=3;
+ }
+
+ for (int8u w=0; w<num_windows; w++)
+ {
+ int8u start_coef_bits, n_filt;
+ Get_S1(n_filt_bits, n_filt, "n_filt[w]");
+ if (n_filt)
+ {
+ bool coef_res;
+ Get_SB (coef_res, "coef_res[w]");
+ start_coef_bits=coef_res?4:3;
+
+ for (int8u filt=0; filt<n_filt; filt++)
+ {
+ int8u order;
+ Skip_S1(length_bits, "length[w][filt]");
+ Get_S1 (order_bits, order, "order[w][filt]");
+ if (order)
+ {
+ bool coef_compress;
+ Skip_SB( "direction[w][filt]");
+ Get_SB (coef_compress, "coef_compress[w][filt]");
+ int8u coef_bits=start_coef_bits-(coef_compress?1:0);
+ for (int8u i=0; i<order; i++)
+ Skip_S1(coef_bits, "coef[w][filt][i]");
+ }
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::ltp_data()
+{
+ Element_Begin1("ltp_data");
+ //int sfb;
+ //bool ltp_lag_update;
+ //if (AudioObjectType == ER_AAC_LD ) {
+ //~ Get_SB(ltp_lag_update,"ltp_lag_update");
+ //~ if ( ltp_lag_update ) {
+ //~ Get_S2(10,ltp_lag,"ltp_lag");
+ //~ } else {
+ //~ //ltp_lag = ltp_prev_lag;
+ //~ }
+ //~ Skip_S1(3,"ltp_coef");
+ //~ for (sfb = 0; sfb <(max_sfb<MAX_LTP_LONG_SFB?max_sfb:MAX_LTP_LONG_SFB);& sfb++ ) {
+ //~ Skip_SB("ltp_long_used[sfb]");
+ //~ }
+ //} else {
+ Get_S2(11,ltp_lag, "ltp_lag");
+ Skip_S1(3, "ltp_coef");
+ if(window_sequence!=2) //EIGHT_SHORT_SEQUENCE
+ {
+ for (int8u sfb=0; sfb<(max_sfb<40?max_sfb:40); sfb++ ) //MAX_LTP_LONG_SFB=40
+ Skip_SB("ltp_long_used[sfb]");
+ }
+ //}
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::spectral_data()
+{
+ Element_Begin1("spectral_data");
+ for (int g = 0; g < num_window_groups; g++)
+ {
+ if (num_window_groups>1)
+ Element_Begin1("windows");
+ for (int8u i=0; i<num_sec[g]; i++)
+ {
+ switch (sect_cb[g][i])
+ {
+ case 0 : //ZERO_HCB
+ case 13 : //NOISE_HCB
+ case 14 : //INTENSITY_HCB2
+ case 15 : //INTENSITY_HCB
+ break;
+ default :
+ if (sect_end[g][i]>=num_swb+1)
+ {
+ Trusted_IsNot("(Problem)");
+ Skip_BS(Data_BS_Remain(), "(Problem)");
+ if (num_window_groups>1)
+ Element_End0();
+ Element_End0();
+ return;
+ }
+ for (int16u k=sect_sfb_offset[g][sect_start[g][i]]; k<sect_sfb_offset[g][sect_end[g][i]]; k+=(sect_cb[g][i]<5?4:2))
+ {
+ hcod(sect_cb[g][i], "sect_cb");
+ if (!Element_IsOK())
+ {
+ Skip_BS(Data_BS_Remain(), "(Problem)");
+ if (num_window_groups>1)
+ Element_End0();
+ Element_End0();
+ return;
+ }
+ }
+ }
+ }
+ if (num_window_groups>1)
+ Element_End0();
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::extension_payload(size_t End, int8u id_aac)
+{
+ Element_Begin1("extension_payload");
+ int8u extension_type;
+ Get_S1 (4, extension_type, "extension_type");
+ switch(extension_type)
+ {
+ case 11 : dynamic_range_info(); break; //EXT_DYNAMIC_RANGE
+ case 12 : sac_extension_data(End); break; //EXT_SAC_DATA
+ case 13 : sbr_extension_data(End, id_aac, 0); break; //EXT_SBR_DATA
+ case 14 : sbr_extension_data(End, id_aac, 1); break; //EXT_SBR_DATA_CRC
+ case 1 : //EXT_FILL_DATA
+ Skip_S1(4, "fill_nibble"); Param_Info1("must be 0000");
+ if (Data_BS_Remain()>End)
+ {
+ Element_Begin1("fill_byte");
+ while (Data_BS_Remain()>End)
+ Skip_S1(8, "fill_byte[i]"); Param_Info1("must be 10100101");
+ Element_End0();
+ }
+ break;
+ case 2 : //EXT_DATA_ELEMENT
+ int8u data_element_version;
+ Get_S1 (4,data_element_version, "data_element_version");
+ switch(data_element_version)
+ {
+ case 0 : //ANC_DATA
+ {
+ int16u dataElementLength=0;
+ int8u dataElementLengthPart;
+ do
+ {
+ Get_S1 (8, dataElementLengthPart, "dataElementLengthPart");
+ dataElementLength+=dataElementLengthPart;
+ }
+ while (dataElementLengthPart==255);
+ Skip_BS(8*dataElementLength, "data_element_byte[i]");
+ }
+ break;
+ default: ;
+ }
+ case 0 : //EXT_FILL
+ default:
+ Skip_BS(Data_BS_Remain()-End, "other_bits");
+ }
+
+ Element_End0();
+ if (End<Data_BS_Remain())
+ Skip_BS(Data_BS_Remain()-End, "padding");
+ if (Data_BS_Remain()!=End)
+ {
+ Skip_BS(Data_BS_Remain(), "Wrong size");
+ Trusted_IsNot("Wrong size");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::dynamic_range_info()
+{
+ Element_Begin1("dynamic_range_info");
+ int8u drc_num_bands=1;
+ bool present;
+ Get_SB (present, "pce_tag_present");
+ if (present)
+ {
+ Skip_S1(4, "pce_ instance_tag");
+ Skip_S1(4, "drc_tag_reserved_bits");
+ }
+ Skip_SB( "excluded_chns_present");
+ Get_SB (present, "drc_bands_present");
+ if (present)
+ {
+ int8u drc_band_incr;
+ Get_S1 (4, drc_band_incr, "drc_band_incr");
+ Skip_S1(4, "drc_interpolation_scheme");
+ drc_num_bands+=drc_band_incr;
+ for (int8u i=0; i<drc_num_bands; i++)
+ {
+ Skip_S1(8, "drc_band_top[i]");
+ }
+ }
+ Get_SB (present, "prog_ref_level_present");
+ if (present)
+ {
+ Skip_S1(7, "prog_ref_level");
+ Skip_S1(1, "prog_ref_level_reserved_bits");
+ }
+ for (int8u i=0; i<drc_num_bands; i++)
+ {
+ Skip_S1(1, "dyn_rng_sgn[i]");
+ Skip_S1(7, "dyn_rng_ctl[i]");
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sac_extension_data(size_t End)
+{
+ Element_Begin1("sac_extension_data");
+ Skip_S1(2, "ancType");
+ Skip_SB( "ancStart");
+ Skip_SB( "ancStop");
+ Element_Begin1("ancDataSegmentByte");
+ while (Data_BS_Remain()>End)
+ Skip_S1(8, "ancDataSegmentByte[i]");
+ Element_End0();
+ Element_End0();
+}
+
+//***************************************************************************
+// Elements - Perceptual noise substitution (PNS)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+int File_Aac::is_intensity(size_t group, size_t sfb)
+{
+ switch (sfb_cb[group][sfb])
+ {
+ case 14 : return 1;
+ case 15 : return -1;
+ default : return 0;
+ }
+}
+
+//---------------------------------------------------------------------------
+bool File_Aac::is_noise(size_t group, size_t sfb)
+{
+ return (sfb_cb[group][sfb]==13);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//---------------------------------------------------------------------------
+void File_Aac::hcod_sf(const char* Name)
+{
+ Element_Begin1(Name);
+ int16u Pos=0;
+
+ while (huffman_sf[Pos][1])
+ {
+ bool h;
+ Get_SB (h, "huffman");
+ Pos+=huffman_sf[Pos][h];
+
+ if (Pos>240)
+ {
+ Skip_BS(Data_BS_Remain(), "Error");
+ Element_End0();
+ return;
+ }
+ }
+ Element_Info1(huffman_sf[Pos][0]-60);
+ Element_End0();
+
+ return;
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::hcod_2step(int8u CodeBook, int8s* Values, int8u Values_Count)
+{
+ int8u CodeWord;
+ int8u ToRead=hcb_2step_Bytes[CodeBook];
+ if ((size_t)ToRead>Data_BS_Remain())
+ ToRead=(int8u)Data_BS_Remain(); //Read a maximum of remaining bytes
+ Peek_S1(ToRead, CodeWord);
+ int16u Offset=hcb_2step[CodeBook][CodeWord].Offset;
+ int8u Extra=hcb_2step[CodeBook][CodeWord].Extra;
+
+ if (Extra)
+ {
+ Skip_BS(hcb_2step_Bytes[CodeBook], "extra");
+ int8u Offset_inc;
+ Peek_S1(Extra, Offset_inc);
+ Offset+=Offset_inc;
+ if(hcb_table[CodeBook][Offset][0]-hcb_2step_Bytes[CodeBook])
+ Skip_BS(hcb_table[CodeBook][Offset][0]-hcb_2step_Bytes[CodeBook],"extra");
+ }
+ else
+ {
+ Skip_BS(hcb_table[CodeBook][Offset][0], "bits");
+ }
+
+ if (Offset>=hcb_table_size[CodeBook])
+ {
+ Skip_BS(Data_BS_Remain(), "Error");
+ return;
+ }
+
+ for (int8u Pos=0; Pos<Values_Count; Pos++)
+ Values[Pos]=hcb_table[CodeBook][Offset][Pos+1];
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::hcod_binary(int8u CodeBook, int8s* Values, int8u Values_Count)
+{
+ int16u Offset=0;
+ while (!hcb_table[CodeBook][Offset][0])
+ {
+ bool b;
+ Get_SB(b, "huffman binary");
+ Offset+=hcb_table[CodeBook][Offset][1+(b?1:0)];
+ }
+
+ if (Offset>=hcb_table_size[CodeBook])
+ {
+ Skip_BS(Data_BS_Remain(), "Error");
+ return;
+ }
+
+ for (int8u Pos=0; Pos<Values_Count; Pos++)
+ Values[Pos]=hcb_table[CodeBook][Offset][Pos+1];
+}
+
+
+
+//***************************************************************************
+// Elements - Enhanced Low Delay Codec
+//***************************************************************************
+
+
+//---------------------------------------------------------------------------
+void File_Aac::ELDSpecificConfig ()
+{
+ Element_Begin1("ELDSpecificConfig");
+ Skip_SB("frameLengthFlag");
+ Skip_SB("aacSectionDataResilienceFlag");
+ Skip_SB("aacScalefactorDataResilienceFlag");
+ Skip_SB("aacSpectralDataResilienceFlag");
+
+ bool ldSbrPresentFlag;
+ Get_SB(ldSbrPresentFlag,"ldSbrPresentFlag");
+ if (ldSbrPresentFlag)
+ {
+ Skip_SB("ldSbrSamplingRate");
+ Skip_SB("ldSbrCrcFlag");
+ ld_sbr_header();
+ }
+
+ int8u eldExtType;
+ Get_S1(4,eldExtType,"eldExtType");
+ while (eldExtType != 0/*ELDEXT_TERM*/)
+ {
+ int8u eldExtLen,eldExtLenAdd=0;
+ int16u eldExtLenAddAdd;
+ Get_S1(4,eldExtLen,"eldExtLen");
+ int32u len = eldExtLen;
+ if (eldExtLen == 15)
+ {
+ Get_S1(8,eldExtLenAdd,"eldExtLenAdd");
+ len += eldExtLenAdd;
+ }
+ if (eldExtLenAdd==255)
+ {
+ Get_S2(16,eldExtLenAddAdd,"eldExtLenAddAdd");
+ len += eldExtLenAdd;
+ }
+ //~ switch (eldExtType) {
+ /* add future eld extension configs here */
+ //~ default:
+ for(int32u cnt=0; cnt<len; cnt++)
+ Skip_S1(8,"other_byte");
+ //~ break;
+ //~ }
+
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::ld_sbr_header()
+{
+ int8u numSbrHeader;
+ switch (channelConfiguration)
+ {
+ case 1:
+ case 2:
+ numSbrHeader = 1;
+ break;
+ case 3:
+ numSbrHeader = 2;
+ break;
+ case 4:
+ case 5:
+ case 6:
+ numSbrHeader = 3;
+ break;
+ case 7:
+ numSbrHeader = 4;
+ break;
+ default:
+ numSbrHeader = 0;
+ break;
+ }
+
+ for (int el=0; el<numSbrHeader; el++) {
+ //~ sbr_header();
+ Element_Begin1("not implemented");
+ Element_End0();
+ }
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::hcod(int8u sect_cb, const char* Name)
+{
+ int8s Values[4];
+
+ Element_Begin1(Name);
+ switch (sect_cb)
+ {
+ case 1 :
+ case 2 :
+ case 4 : //4-values, 2-step method
+ hcod_2step(sect_cb, Values, 4);
+ break;
+ case 3 : //4-values, binary search method
+ hcod_binary(sect_cb, Values, 4);
+ break;
+ case 5 :
+ case 7 :
+ case 9 : //2-values, binary search method
+ hcod_binary(sect_cb, Values, 2);
+ break;
+ case 6 :
+ case 8 :
+ case 10 :
+ case 11 : //2-values, 2-step method
+ hcod_2step(sect_cb, Values, 2);
+ break;
+ default: Trusted_IsNot("(Problem)");
+ Element_End0();
+ return;
+ }
+
+ switch (sect_cb)
+ {
+ case 1 :
+ case 2 :
+ case 5 :
+ case 6 :
+ break;
+ default : //With sign
+ for(int i=0; i<((sect_cb<5)?4:2); i++)
+ if(Values[i])
+ Skip_SB( "sign");
+ }
+
+ switch (sect_cb)
+ {
+ case 11 : //With hcod_esc
+ for (int i=0; i<2; i++)
+ if (Values[i]==16 || Values[i] == -16)
+ {
+ Element_Begin1("hcod_esc");
+ bool Escape;
+ int BitCount=3;
+ do
+ {
+ BitCount++;
+ Get_SB(Escape, "bit count");
+ }
+ while (Escape);
+
+
+ Skip_BS(BitCount, "value");
+ Element_End0();
+
+ }
+ break;
+ default: ;
+ }
+
+ Element_End0();
+}
+
+
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_AAC_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio.h
new file mode 100644
index 000000000..4c24892c7
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio.h
@@ -0,0 +1,2848 @@
+// File_Aac - Info for AAC files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Aac_GeneralAudioH
+#define MediaInfo_File_Aac_GeneralAudioH
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Huffman tables
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Optimal huffman from:
+// "SELECTING AN OPTIMAL HUFFMAN DECODER FOR AAC"
+// VLADIMIR Z. MESAROVIC , RAGHUNATH RAO, MIROSLAV V. DOKIC, and SACHIN DEO
+// AES Convention Paper 5436
+
+//---------------------------------------------------------------------------
+//2-step 1st pass
+struct hcb_struct_1
+{
+ int8u Offset;
+ int8u Extra;
+};
+
+//2-step 2nd pass or binary
+typedef int8s hcb_struct[5]; //0=bits to read (2step) or more to read (binary), 1-4: data (1-2 in case of pairs)
+
+//---------------------------------------------------------------------------
+// Scalefactor Huffman Codebook
+static int8u huffman_sf[241][2]=
+{
+ { 1, 2 },
+ { 60, 0 },
+ { 1, 2 },
+ { 2, 3 },
+ { 3, 4 },
+ { 59, 0 },
+ { 3, 4 },
+ { 4, 5 },
+ { 5, 6 },
+ { 61, 0 },
+ { 58, 0 },
+ { 62, 0 },
+ { 3, 4 },
+ { 4, 5 },
+ { 5, 6 },
+ { 57, 0 },
+ { 63, 0 },
+ { 4, 5 },
+ { 5, 6 },
+ { 6, 7 },
+ { 7, 8 },
+ { 56, 0 },
+ { 64, 0 },
+ { 55, 0 },
+ { 65, 0 },
+ { 4, 5 },
+ { 5, 6 },
+ { 6, 7 },
+ { 7, 8 },
+ { 66, 0 },
+ { 54, 0 },
+ { 67, 0 },
+ { 5, 6 },
+ { 6, 7 },
+ { 7, 8 },
+ { 8, 9 },
+ { 9, 10 },
+ { 53, 0 },
+ { 68, 0 },
+ { 52, 0 },
+ { 69, 0 },
+ { 51, 0 },
+ { 5, 6 },
+ { 6, 7 },
+ { 7, 8 },
+ { 8, 9 },
+ { 9, 10 },
+ { 70, 0 },
+ { 50, 0 },
+ { 49, 0 },
+ { 71, 0 },
+ { 6, 7 },
+ { 7, 8 },
+ { 8, 9 },
+ { 9, 10 },
+ { 10, 11 },
+ { 11, 12 },
+ { 72, 0 },
+ { 48, 0 },
+ { 73, 0 },
+ { 47, 0 },
+ { 74, 0 },
+ { 46, 0 },
+ { 6, 7 },
+ { 7, 8 },
+ { 8, 9 },
+ { 9, 10 },
+ { 10, 11 },
+ { 11, 12 },
+ { 76, 0 },
+ { 75, 0 },
+ { 77, 0 },
+ { 78, 0 },
+ { 45, 0 },
+ { 43, 0 },
+ { 6, 7 },
+ { 7, 8 },
+ { 8, 9 },
+ { 9, 10 },
+ { 10, 11 },
+ { 11, 12 },
+ { 44, 0 },
+ { 79, 0 },
+ { 42, 0 },
+ { 41, 0 },
+ { 80, 0 },
+ { 40, 0 },
+ { 6, 7 },
+ { 7, 8 },
+ { 8, 9 },
+ { 9, 10 },
+ { 10, 11 },
+ { 11, 12 },
+ { 81, 0 },
+ { 39, 0 },
+ { 82, 0 },
+ { 38, 0 },
+ { 83, 0 },
+ { 7, 8 },
+ { 8, 9 },
+ { 9, 10 },
+ { 10, 11 },
+ { 11, 12 },
+ { 12, 13 },
+ { 13, 14 },
+ { 37, 0 },
+ { 35, 0 },
+ { 85, 0 },
+ { 33, 0 },
+ { 36, 0 },
+ { 34, 0 },
+ { 84, 0 },
+ { 32, 0 },
+ { 6, 7 },
+ { 7, 8 },
+ { 8, 9 },
+ { 9, 10 },
+ { 10, 11 },
+ { 11, 12 },
+ { 87, 0 },
+ { 89, 0 },
+ { 30, 0 },
+ { 31, 0 },
+ { 8, 9 },
+ { 9, 10 },
+ { 10, 11 },
+ { 11, 12 },
+ { 12, 13 },
+ { 13, 14 },
+ { 14, 15 },
+ { 15, 16 },
+ { 86, 0 },
+ { 29, 0 },
+ { 26, 0 },
+ { 27, 0 },
+ { 28, 0 },
+ { 24, 0 },
+ { 88, 0 },
+ { 9, 10 },
+ { 10, 11 },
+ { 11, 12 },
+ { 12, 13 },
+ { 13, 14 },
+ { 14, 15 },
+ { 15, 16 },
+ { 16, 17 },
+ { 17, 18 },
+ { 25, 0 },
+ { 22, 0 },
+ { 23, 0 },
+ { 15, 16 },
+ { 16, 17 },
+ { 17, 18 },
+ { 18, 19 },
+ { 19, 20 },
+ { 20, 21 },
+ { 21, 22 },
+ { 22, 23 },
+ { 23, 24 },
+ { 24, 25 },
+ { 25, 26 },
+ { 26, 27 },
+ { 27, 28 },
+ { 28, 29 },
+ { 29, 30 },
+ { 90, 0 },
+ { 21, 0 },
+ { 19, 0 },
+ { 3, 0 },
+ { 1, 0 },
+ { 2, 0 },
+ { 0, 0 },
+ { 23, 24 },
+ { 24, 25 },
+ { 25, 26 },
+ { 26, 27 },
+ { 27, 28 },
+ { 28, 29 },
+ { 29, 30 },
+ { 30, 31 },
+ { 31, 32 },
+ { 32, 33 },
+ { 33, 34 },
+ { 34, 35 },
+ { 35, 36 },
+ { 36, 37 },
+ { 37, 38 },
+ { 38, 39 },
+ { 39, 40 },
+ { 40, 41 },
+ { 41, 42 },
+ { 42, 43 },
+ { 43, 44 },
+ { 44, 45 },
+ { 45, 46 },
+ { 98, 0 },
+ { 99, 0 },
+ { 100, 0 },
+ { 101, 0 },
+ { 102, 0 },
+ { 117, 0 },
+ { 97, 0 },
+ { 91, 0 },
+ { 92, 0 },
+ { 93, 0 },
+ { 94, 0 },
+ { 95, 0 },
+ { 96, 0 },
+ { 104, 0 },
+ { 111, 0 },
+ { 112, 0 },
+ { 113, 0 },
+ { 114, 0 },
+ { 115, 0 },
+ { 116, 0 },
+ { 110, 0 },
+ { 105, 0 },
+ { 106, 0 },
+ { 107, 0 },
+ { 108, 0 },
+ { 109, 0 },
+ { 118, 0 },
+ { 6, 0 },
+ { 8, 0 },
+ { 9, 0 },
+ { 10, 0 },
+ { 5, 0 },
+ { 103, 0 },
+ { 120, 0 },
+ { 119, 0 },
+ { 4, 0 },
+ { 7, 0 },
+ { 15, 0 },
+ { 16, 0 },
+ { 18, 0 },
+ { 20, 0 },
+ { 17, 0 },
+ { 11, 0 },
+ { 12, 0 },
+ { 14, 0 },
+ { 13, 0 }
+};
+
+//---------------------------------------------------------------------------
+// Spectrum Huffman Codebook 1
+static hcb_struct_1 huffman_01_1[32]=
+{
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 1, 0 },
+ { 2, 0 },
+ { 3, 0 },
+ { 4, 0 },
+ { 5, 0 },
+ { 6, 0 },
+ { 7, 0 },
+ { 8, 0 },
+ { 9, 2 },
+ { 13, 2 },
+ { 17, 2 },
+ { 21, 2 },
+ { 25, 2 },
+ { 29, 2 },
+ { 33, 4 },
+ { 49, 6 }
+};
+
+static hcb_struct huffman_01[114]=
+{
+ { 1, 0, 0, 0, 0 },
+ { 5, 1, 0, 0, 0 },
+ { 5, -1, 0, 0, 0 },
+ { 5, 0, 0, 0, -1 },
+ { 5, 0, 1, 0, 0 },
+ { 5, 0, 0, 0, 1 },
+ { 5, 0, 0, -1, 0 },
+ { 5, 0, 0, 1, 0 },
+ { 5, 0, -1, 0, 0 },
+ { 7, 1, -1, 0, 0 },
+ { 7, -1, 1, 0, 0 },
+ { 7, 0, 0, -1, 1 },
+ { 7, 0, 1, -1, 0 },
+ { 7, 0, -1, 1, 0 },
+ { 7, 0, 0, 1, -1 },
+ { 7, 1, 1, 0, 0 },
+ { 7, 0, 0, -1, -1 },
+ { 7, -1, -1, 0, 0 },
+ { 7, 0, -1, -1, 0 },
+ { 7, 1, 0, -1, 0 },
+ { 7, 0, 1, 0, -1 },
+ { 7, -1, 0, 1, 0 },
+ { 7, 0, 0, 1, 1 },
+ { 7, 1, 0, 1, 0 },
+ { 7, 0, -1, 0, 1 },
+ { 7, 0, 1, 1, 0 },
+ { 7, 0, 1, 0, 1 },
+ { 7, -1, 0, -1, 0 },
+ { 7, 1, 0, 0, 1 },
+ { 7, -1, 0, 0, -1 },
+ { 7, 1, 0, 0, -1 },
+ { 7, -1, 0, 0, 1 },
+ { 7, 0, -1, 0, -1 },
+ { 9, 1, 1, -1, 0 },
+ { 9, -1, 1, -1, 0 },
+ { 9, 1, -1, 1, 0 },
+ { 9, 0, 1, 1, -1 },
+ { 9, 0, 1, -1, 1 },
+ { 9, 0, -1, 1, 1 },
+ { 9, 0, -1, 1, -1 },
+ { 9, 1, -1, -1, 0 },
+ { 9, 1, 0, -1, 1 },
+ { 9, 0, 1, -1, -1 },
+ { 9, -1, 1, 1, 0 },
+ { 9, -1, 0, 1, -1 },
+ { 9, -1, -1, 1, 0 },
+ { 9, 0, -1, -1, 1 },
+ { 9, 1, -1, 0, 1 },
+ { 9, 1, -1, 0, -1 },
+ { 9, -1, 1, 0, -1 },
+ { 9, -1, 1, 0, -1 },
+ { 9, -1, 1, 0, -1 },
+ { 9, -1, 1, 0, -1 },
+ { 9, -1, -1, -1, 0 },
+ { 9, -1, -1, -1, 0 },
+ { 9, -1, -1, -1, 0 },
+ { 9, -1, -1, -1, 0 },
+ { 9, 0, -1, -1, -1 },
+ { 9, 0, -1, -1, -1 },
+ { 9, 0, -1, -1, -1 },
+ { 9, 0, -1, -1, -1 },
+ { 9, 0, 1, 1, 1 },
+ { 9, 0, 1, 1, 1 },
+ { 9, 0, 1, 1, 1 },
+ { 9, 0, 1, 1, 1 },
+ { 9, 1, 0, 1, -1 },
+ { 9, 1, 0, 1, -1 },
+ { 9, 1, 0, 1, -1 },
+ { 9, 1, 0, 1, -1 },
+ { 9, 1, 1, 0, 1 },
+ { 9, 1, 1, 0, 1 },
+ { 9, 1, 1, 0, 1 },
+ { 9, 1, 1, 0, 1 },
+ { 9, -1, 1, 0, 1 },
+ { 9, -1, 1, 0, 1 },
+ { 9, -1, 1, 0, 1 },
+ { 9, -1, 1, 0, 1 },
+ { 9, 1, 1, 1, 0 },
+ { 9, 1, 1, 1, 0 },
+ { 9, 1, 1, 1, 0 },
+ { 9, 1, 1, 1, 0 },
+ { 10, -1, -1, 0, 1 },
+ { 10, -1, -1, 0, 1 },
+ { 10, -1, 0, -1, -1 },
+ { 10, -1, 0, -1, -1 },
+ { 10, 1, 1, 0, -1 },
+ { 10, 1, 1, 0, -1 },
+ { 10, 1, 0, -1, -1 },
+ { 10, 1, 0, -1, -1 },
+ { 10, -1, 0, -1, 1 },
+ { 10, -1, 0, -1, 1 },
+ { 10, -1, -1, 0, -1 },
+ { 10, -1, -1, 0, -1 },
+ { 10, -1, 0, 1, 1 },
+ { 10, -1, 0, 1, 1 },
+ { 10, 1, 0, 1, 1 },
+ { 10, 1, 0, 1, 1 },
+ { 11, 1, -1, 1, -1 },
+ { 11, -1, 1, -1, 1 },
+ { 11, -1, 1, 1, -1 },
+ { 11, 1, -1, -1, 1 },
+ { 11, 1, 1, 1, 1 },
+ { 11, -1, -1, 1, 1 },
+ { 11, 1, 1, -1, -1 },
+ { 11, -1, -1, 1, -1 },
+ { 11, -1, -1, -1, -1 },
+ { 11, 1, 1, -1, 1 },
+ { 11, 1, -1, 1, 1 },
+ { 11, -1, 1, 1, 1 },
+ { 11, -1, 1, -1, -1 },
+ { 11, -1, -1, -1, 1 },
+ { 11, 1, -1, -1, -1 },
+ { 11, 1, 1, 1, -1 }
+};
+
+//---------------------------------------------------------------------------
+// Spectrum Huffman Codebook 2
+static hcb_struct_1 huffman_02_1[] =
+{
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 1, 0 },
+ { 1, 0 },
+ { 2, 0 },
+ { 3, 0 },
+ { 4, 0 },
+ { 5, 0 },
+ { 6, 0 },
+ { 7, 0 },
+ { 8, 0 },
+ { 9, 1 },
+ { 11, 1 },
+ { 13, 1 },
+ { 15, 1 },
+ { 17, 1 },
+ { 19, 1 },
+ { 21, 1 },
+ { 23, 1 },
+ { 25, 1 },
+ { 27, 1 },
+ { 29, 1 },
+ { 31, 1 },
+ { 33, 2 },
+ { 37, 2 },
+ { 41, 2 },
+ { 45, 3 },
+ { 53, 3 },
+ { 61, 3 },
+ { 69, 4 }
+};
+
+static hcb_struct huffman_02[86]=
+{
+ { 3, 0, 0, 0, 0 },
+ { 4, 1, 0, 0, 0 },
+ { 5, -1, 0, 0, 0 },
+ { 5, 0, 0, 0, 1 },
+ { 5, 0, 0, -1, 0 },
+ { 5, 0, 0, 0, -1 },
+ { 5, 0, -1, 0, 0 },
+ { 5, 0, 0, 1, 0 },
+ { 5, 0, 1, 0, 0 },
+ { 6, 0, -1, 1, 0 },
+ { 6, -1, 1, 0, 0 },
+ { 6, 0, 1, -1, 0 },
+ { 6, 0, 0, 1, -1 },
+ { 6, 0, 1, 0, -1 },
+ { 6, 0, 0, -1, 1 },
+ { 6, -1, 0, 0, -1 },
+ { 6, 1, -1, 0, 0 },
+ { 6, 1, 0, -1, 0 },
+ { 6, -1, -1, 0, 0 },
+ { 6, 0, 0, -1, -1 },
+ { 6, 1, 0, 1, 0 },
+ { 6, 1, 0, 0, 1 },
+ { 6, 0, -1, 0, 1 },
+ { 6, -1, 0, 1, 0 },
+ { 6, 0, 1, 0, 1 },
+ { 6, 0, -1, -1, 0 },
+ { 6, -1, 0, 0, 1 },
+ { 6, 0, -1, 0, -1 },
+ { 6, -1, 0, -1, 0 },
+ { 6, 1, 1, 0, 0 },
+ { 6, 0, 1, 1, 0 },
+ { 6, 0, 0, 1, 1 },
+ { 6, 1, 0, 0, -1 },
+ { 7, 0, 1, -1, 1 },
+ { 7, 1, 0, -1, 1 },
+ { 7, -1, 1, -1, 0 },
+ { 7, 0, -1, 1, -1 },
+ { 7, 1, -1, 1, 0 },
+ { 7, 1, 1, 0, -1 },
+ { 7, 1, 0, 1, 1 },
+ { 7, -1, 1, 1, 0 },
+ { 7, 0, -1, -1, 1 },
+ { 7, 1, 1, 1, 0 },
+ { 7, -1, 0, 1, -1 },
+ { 7, -1, -1, -1, 0 },
+ { 7, -1, 0, -1, 1 },
+ { 7, -1, 0, -1, 1 },
+ { 7, 1, -1, -1, 0 },
+ { 7, 1, -1, -1, 0 },
+ { 7, 1, 1, -1, 0 },
+ { 7, 1, 1, -1, 0 },
+ { 8, 1, -1, 0, 1 },
+ { 8, -1, 1, 0, -1 },
+ { 8, -1, -1, 1, 0 },
+ { 8, -1, 0, 1, 1 },
+ { 8, -1, -1, 0, 1 },
+ { 8, -1, -1, 0, -1 },
+ { 8, 0, -1, -1, -1 },
+ { 8, 1, 0, 1, -1 },
+ { 8, 1, 0, -1, -1 },
+ { 8, 0, 1, -1, -1 },
+ { 8, 0, 1, 1, 1 },
+ { 8, -1, 1, 0, 1 },
+ { 8, -1, 0, -1, -1 },
+ { 8, 0, 1, 1, -1 },
+ { 8, 1, -1, 0, -1 },
+ { 8, 0, -1, 1, 1 },
+ { 8, 1, 1, 0, 1 },
+ { 8, 1, -1, 1, -1 },
+ { 8, -1, 1, -1, 1 },
+ { 8, -1, 1, -1, 1 },
+ { 9, 1, -1, -1, 1 },
+ { 9, -1, -1, -1, -1 },
+ { 9, -1, 1, 1, -1 },
+ { 9, -1, 1, 1, 1 },
+ { 9, 1, 1, 1, 1 },
+ { 9, -1, -1, 1, -1 },
+ { 9, 1, -1, 1, 1 },
+ { 9, -1, 1, -1, -1 },
+ { 9, -1, -1, 1, 1 },
+ { 9, 1, 1, -1, -1 },
+ { 9, 1, -1, -1, -1 },
+ { 9, -1, -1, -1, 1 },
+ { 9, 1, 1, -1, 1 },
+ { 9, 1, 1, 1, -1 }
+};
+
+//---------------------------------------------------------------------------
+// Spectrum Huffman Codebook 2
+static hcb_struct huffman_03[161] =
+{
+ { 0, 1, 2 },
+ { 1, 0, 0 },
+ { 0, 1, 2 },
+ { 0, 2, 3 },
+ { 0, 3, 4 },
+ { 0, 4, 5 },
+ { 0, 5, 6 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 1, 1, 0 },
+ { 1, 0, 0, 0, 1 },
+ { 1, 0, 1, 0, 0 },
+ { 1, 0, 0, 1, 0 },
+ { 0, 4, 5 },
+ { 0, 5, 6 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 1, 1, 1 },
+ { 1, 0, 0, 1, 1 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 1, 0, 1, 1, 0 },
+ { 1, 0, 1, 0, 1 },
+ { 1, 1, 0, 1, 0 },
+ { 1, 0, 1, 1, 1 },
+ { 1, 1, 0, 0, 1 },
+ { 1, 1, 1, 1, 0 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 1, 1, 1, 1, 1 },
+ { 1, 1, 0, 1, 1 },
+ { 1, 1, 1, 0, 1 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 0, 16, 17 },
+ { 0, 17, 18 },
+ { 1, 2, 0, 0, 0 },
+ { 1, 0, 0, 0, 2 },
+ { 1, 0, 0, 1, 2 },
+ { 1, 2, 1, 0, 0 },
+ { 1, 1, 2, 1, 0 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 0, 16, 17 },
+ { 0, 17, 18 },
+ { 0, 18, 19 },
+ { 0, 19, 20 },
+ { 0, 20, 21 },
+ { 0, 21, 22 },
+ { 0, 22, 23 },
+ { 0, 23, 24 },
+ { 0, 24, 25 },
+ { 0, 25, 26 },
+ { 1, 0, 0, 2, 1 },
+ { 1, 0, 1, 2, 1 },
+ { 1, 1, 2, 0, 0 },
+ { 1, 0, 1, 1, 2 },
+ { 1, 2, 1, 1, 0 },
+ { 1, 0, 0, 2, 0 },
+ { 1, 0, 2, 1, 0 },
+ { 1, 0, 1, 2, 0 },
+ { 1, 0, 2, 0, 0 },
+ { 1, 0, 1, 0, 2 },
+ { 1, 2, 0, 1, 0 },
+ { 1, 1, 2, 1, 1 },
+ { 1, 0, 2, 1, 1 },
+ { 1, 1, 1, 2, 0 },
+ { 1, 1, 1, 2, 1 },
+ { 0, 11, 12 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 0, 16, 17 },
+ { 0, 17, 18 },
+ { 0, 18, 19 },
+ { 0, 19, 20 },
+ { 0, 20, 21 },
+ { 0, 21, 22 },
+ { 1, 1, 2, 0, 1 },
+ { 1, 1, 0, 2, 0 },
+ { 1, 1, 0, 2, 1 },
+ { 1, 0, 2, 0, 1 },
+ { 1, 2, 1, 1, 1 },
+ { 1, 1, 1, 1, 2 },
+ { 1, 2, 1, 0, 1 },
+ { 1, 1, 0, 1, 2 },
+ { 1, 0, 0, 2, 2 },
+ { 1, 0, 1, 2, 2 },
+ { 1, 2, 2, 1, 0 },
+ { 1, 1, 2, 2, 0 },
+ { 1, 1, 0, 0, 2 },
+ { 1, 2, 0, 0, 1 },
+ { 1, 0, 2, 2, 1 },
+ { 0, 7, 8 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 1, 2, 2, 0, 0 },
+ { 1, 1, 2, 2, 1 },
+ { 1, 1, 1, 0, 2 },
+ { 1, 2, 0, 1, 1 },
+ { 1, 1, 1, 2, 2 },
+ { 1, 2, 2, 1, 1 },
+ { 1, 0, 2, 2, 0 },
+ { 1, 0, 2, 1, 2 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 1, 1, 0, 2, 2 },
+ { 1, 2, 2, 0, 1 },
+ { 1, 2, 1, 2, 0 },
+ { 1, 2, 2, 2, 0 },
+ { 1, 0, 2, 2, 2 },
+ { 1, 2, 2, 2, 1 },
+ { 1, 2, 1, 2, 1 },
+ { 1, 1, 2, 1, 2 },
+ { 1, 1, 2, 2, 2 },
+ { 0, 3, 4 },
+ { 0, 4, 5 },
+ { 0, 5, 6 },
+ { 1, 0, 2, 0, 2 },
+ { 1, 2, 0, 2, 0 },
+ { 1, 1, 2, 0, 2 },
+ { 0, 3, 4 },
+ { 0, 4, 5 },
+ { 0, 5, 6 },
+ { 1, 2, 0, 2, 1 },
+ { 1, 2, 1, 1, 2 },
+ { 1, 2, 1, 0, 2 },
+ { 0, 3, 4 },
+ { 0, 4, 5 },
+ { 0, 5, 6 },
+ { 1, 2, 2, 2, 2 },
+ { 1, 2, 2, 1, 2 },
+ { 1, 2, 1, 2, 2 },
+ { 1, 2, 0, 1, 2 },
+ { 1, 2, 0, 0, 2 },
+ { 0, 1, 2 },
+ { 1, 2, 2, 0, 2 },
+ { 1, 2, 0, 2, 2 },
+};
+
+//---------------------------------------------------------------------------
+// Spectrum Huffman Codebook 4
+static hcb_struct_1 huffman_04_1[32]=
+{
+ { 0, 0 },
+ { 0, 0 },
+ { 1, 0 },
+ { 1, 0 },
+ { 2, 0 },
+ { 2, 0 },
+ { 3, 0 },
+ { 3, 0 },
+ { 4, 0 },
+ { 4, 0 },
+ { 5, 0 },
+ { 5, 0 },
+ { 6, 0 },
+ { 6, 0 },
+ { 7, 0 },
+ { 7, 0 },
+ { 8, 0 },
+ { 8, 0 },
+ { 9, 0 },
+ { 9, 0 },
+ { 10, 0 },
+ { 11, 0 },
+ { 12, 0 },
+ { 13, 0 },
+ { 14, 0 },
+ { 15, 0 },
+ { 16, 2 },
+ { 20, 2 },
+ { 24, 3 },
+ { 32, 3 },
+ { 40, 4 },
+ { 56, 7 }
+};
+
+static hcb_struct huffman_04[185]=
+{
+ { 4, 1, 1, 1, 1 },
+ { 4, 0, 1, 1, 1 },
+ { 4, 1, 1, 0, 1 },
+ { 4, 1, 1, 1, 0 },
+ { 4, 1, 0, 1, 1 },
+ { 4, 1, 0, 0, 0 },
+ { 4, 1, 1, 0, 0 },
+ { 4, 0, 0, 0, 0 },
+ { 4, 0, 0, 1, 1 },
+ { 4, 1, 0, 1, 0 },
+ { 5, 1, 0, 0, 1 },
+ { 5, 0, 1, 1, 0 },
+ { 5, 0, 0, 0, 1 },
+ { 5, 0, 1, 0, 1 },
+ { 5, 0, 0, 1, 0 },
+ { 5, 0, 1, 0, 0 },
+ { 7, 2, 1, 1, 1 },
+ { 7, 1, 1, 2, 1 },
+ { 7, 1, 2, 1, 1 },
+ { 7, 1, 1, 1, 2 },
+ { 7, 2, 1, 1, 0 },
+ { 7, 2, 1, 0, 1 },
+ { 7, 1, 2, 1, 0 },
+ { 7, 2, 0, 1, 1 },
+ { 7, 0, 1, 2, 1 },
+ { 7, 0, 1, 2, 1 },
+ { 8, 0, 1, 1, 2 },
+ { 8, 1, 1, 2, 0 },
+ { 8, 0, 2, 1, 1 },
+ { 8, 1, 0, 1, 2 },
+ { 8, 1, 2, 0, 1 },
+ { 8, 1, 1, 0, 2 },
+ { 8, 1, 0, 2, 1 },
+ { 8, 2, 1, 0, 0 },
+ { 8, 2, 0, 1, 0 },
+ { 8, 1, 2, 0, 0 },
+ { 8, 2, 0, 0, 1 },
+ { 8, 0, 1, 0, 2 },
+ { 8, 0, 2, 1, 0 },
+ { 8, 0, 0, 1, 2 },
+ { 8, 0, 1, 2, 0 },
+ { 8, 0, 1, 2, 0 },
+ { 8, 0, 2, 0, 1 },
+ { 8, 0, 2, 0, 1 },
+ { 8, 1, 0, 0, 2 },
+ { 8, 1, 0, 0, 2 },
+ { 8, 0, 0, 2, 1 },
+ { 8, 0, 0, 2, 1 },
+ { 8, 1, 0, 2, 0 },
+ { 8, 1, 0, 2, 0 },
+ { 8, 2, 0, 0, 0 },
+ { 8, 2, 0, 0, 0 },
+ { 8, 0, 0, 0, 2 },
+ { 8, 0, 0, 0, 2 },
+ { 9, 0, 2, 0, 0 },
+ { 9, 0, 0, 2, 0 },
+ { 9, 1, 2, 2, 1 },
+ { 9, 1, 2, 2, 1 },
+ { 9, 1, 2, 2, 1 },
+ { 9, 1, 2, 2, 1 },
+ { 9, 1, 2, 2, 1 },
+ { 9, 1, 2, 2, 1 },
+ { 9, 1, 2, 2, 1 },
+ { 9, 1, 2, 2, 1 },
+ { 9, 2, 2, 1, 1 },
+ { 9, 2, 2, 1, 1 },
+ { 9, 2, 2, 1, 1 },
+ { 9, 2, 2, 1, 1 },
+ { 9, 2, 2, 1, 1 },
+ { 9, 2, 2, 1, 1 },
+ { 9, 2, 2, 1, 1 },
+ { 9, 2, 2, 1, 1 },
+ { 9, 2, 1, 2, 1 },
+ { 9, 2, 1, 2, 1 },
+ { 9, 2, 1, 2, 1 },
+ { 9, 2, 1, 2, 1 },
+ { 9, 2, 1, 2, 1 },
+ { 9, 2, 1, 2, 1 },
+ { 9, 2, 1, 2, 1 },
+ { 9, 2, 1, 2, 1 },
+ { 9, 1, 1, 2, 2 },
+ { 9, 1, 1, 2, 2 },
+ { 9, 1, 1, 2, 2 },
+ { 9, 1, 1, 2, 2 },
+ { 9, 1, 1, 2, 2 },
+ { 9, 1, 1, 2, 2 },
+ { 9, 1, 1, 2, 2 },
+ { 9, 1, 1, 2, 2 },
+ { 9, 1, 2, 1, 2 },
+ { 9, 1, 2, 1, 2 },
+ { 9, 1, 2, 1, 2 },
+ { 9, 1, 2, 1, 2 },
+ { 9, 1, 2, 1, 2 },
+ { 9, 1, 2, 1, 2 },
+ { 9, 1, 2, 1, 2 },
+ { 9, 1, 2, 1, 2 },
+ { 9, 2, 1, 1, 2 },
+ { 9, 2, 1, 1, 2 },
+ { 9, 2, 1, 1, 2 },
+ { 9, 2, 1, 1, 2 },
+ { 9, 2, 1, 1, 2 },
+ { 9, 2, 1, 1, 2 },
+ { 9, 2, 1, 1, 2 },
+ { 9, 2, 1, 1, 2 },
+ { 10, 1, 2, 2, 0 },
+ { 10, 1, 2, 2, 0 },
+ { 10, 1, 2, 2, 0 },
+ { 10, 1, 2, 2, 0 },
+ { 10, 2, 2, 1, 0 },
+ { 10, 2, 2, 1, 0 },
+ { 10, 2, 2, 1, 0 },
+ { 10, 2, 2, 1, 0 },
+ { 10, 2, 1, 2, 0 },
+ { 10, 2, 1, 2, 0 },
+ { 10, 2, 1, 2, 0 },
+ { 10, 2, 1, 2, 0 },
+ { 10, 0, 2, 2, 1 },
+ { 10, 0, 2, 2, 1 },
+ { 10, 0, 2, 2, 1 },
+ { 10, 0, 2, 2, 1 },
+ { 10, 0, 1, 2, 2 },
+ { 10, 0, 1, 2, 2 },
+ { 10, 0, 1, 2, 2 },
+ { 10, 0, 1, 2, 2 },
+ { 10, 2, 2, 0, 1 },
+ { 10, 2, 2, 0, 1 },
+ { 10, 2, 2, 0, 1 },
+ { 10, 2, 2, 0, 1 },
+ { 10, 0, 2, 1, 2 },
+ { 10, 0, 2, 1, 2 },
+ { 10, 0, 2, 1, 2 },
+ { 10, 0, 2, 1, 2 },
+ { 10, 2, 0, 2, 1 },
+ { 10, 2, 0, 2, 1 },
+ { 10, 2, 0, 2, 1 },
+ { 10, 2, 0, 2, 1 },
+ { 10, 1, 0, 2, 2 },
+ { 10, 1, 0, 2, 2 },
+ { 10, 1, 0, 2, 2 },
+ { 10, 1, 0, 2, 2 },
+ { 10, 2, 2, 2, 1 },
+ { 10, 2, 2, 2, 1 },
+ { 10, 2, 2, 2, 1 },
+ { 10, 2, 2, 2, 1 },
+ { 10, 1, 2, 0, 2 },
+ { 10, 1, 2, 0, 2 },
+ { 10, 1, 2, 0, 2 },
+ { 10, 1, 2, 0, 2 },
+ { 10, 2, 0, 1, 2 },
+ { 10, 2, 0, 1, 2 },
+ { 10, 2, 0, 1, 2 },
+ { 10, 2, 0, 1, 2 },
+ { 10, 2, 1, 0, 2 },
+ { 10, 2, 1, 0, 2 },
+ { 10, 2, 1, 0, 2 },
+ { 10, 2, 1, 0, 2 },
+ { 10, 1, 2, 2, 2 },
+ { 10, 1, 2, 2, 2 },
+ { 10, 1, 2, 2, 2 },
+ { 10, 1, 2, 2, 2 },
+ { 11, 2, 1, 2, 2 },
+ { 11, 2, 1, 2, 2 },
+ { 11, 2, 2, 1, 2 },
+ { 11, 2, 2, 1, 2 },
+ { 11, 0, 2, 2, 0 },
+ { 11, 0, 2, 2, 0 },
+ { 11, 2, 2, 0, 0 },
+ { 11, 2, 2, 0, 0 },
+ { 11, 0, 0, 2, 2 },
+ { 11, 0, 0, 2, 2 },
+ { 11, 2, 0, 2, 0 },
+ { 11, 2, 0, 2, 0 },
+ { 11, 0, 2, 0, 2 },
+ { 11, 0, 2, 0, 2 },
+ { 11, 2, 0, 0, 2 },
+ { 11, 2, 0, 0, 2 },
+ { 11, 2, 2, 2, 2 },
+ { 11, 2, 2, 2, 2 },
+ { 11, 0, 2, 2, 2 },
+ { 11, 0, 2, 2, 2 },
+ { 11, 2, 2, 2, 0 },
+ { 11, 2, 2, 2, 0 },
+ { 12, 2, 2, 0, 2 },
+ { 12, 2, 0, 2, 2 },
+};
+
+//---------------------------------------------------------------------------
+// Spectrum Huffman Codebook 5
+static hcb_struct huffman_05[161]=
+{
+ { 0, 1, 2 },
+ { 1, 0, 0 },
+ { 0, 1, 2 },
+ { 0, 2, 3 },
+ { 0, 3, 4 },
+ { 0, 4, 5 },
+ { 0, 5, 6 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 1, -1, 0 },
+ { 1, 1, 0 },
+ { 1, 0, 1 },
+ { 1, 0, -1 },
+ { 0, 4, 5 },
+ { 0, 5, 6 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 1, 1, -1 },
+ { 1, -1, 1 },
+ { 1, -1, -1 },
+ { 1, 1, 1 },
+ { 0, 4, 5 },
+ { 0, 5, 6 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 1, -2, 0 },
+ { 1, 0, 2 },
+ { 1, 2, 0 },
+ { 1, 0, -2 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 0, 16, 17 },
+ { 0, 17, 18 },
+ { 0, 18, 19 },
+ { 0, 19, 20 },
+ { 0, 20, 21 },
+ { 0, 21, 22 },
+ { 0, 22, 23 },
+ { 0, 23, 24 },
+ { 1, -2, -1 },
+ { 1, 2, 1 },
+ { 1, -1, -2 },
+ { 1, 1, 2 },
+ { 1, -2, 1 },
+ { 1, 2, -1 },
+ { 1, -1, 2 },
+ { 1, 1, -2 },
+ { 1, -3, 0 },
+ { 1, 3, 0 },
+ { 1, 0, -3 },
+ { 1, 0, 3 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 0, 16, 17 },
+ { 0, 17, 18 },
+ { 0, 18, 19 },
+ { 0, 19, 20 },
+ { 0, 20, 21 },
+ { 0, 21, 22 },
+ { 0, 22, 23 },
+ { 0, 23, 24 },
+ { 1, -3, -1 },
+ { 1, 1, 3 },
+ { 1, 3, 1 },
+ { 1, -1, -3 },
+ { 1, -3, 1 },
+ { 1, 3, -1 },
+ { 1, 1, -3 },
+ { 1, -1, 3 },
+ { 1, -2, 2 },
+ { 1, 2, 2 },
+ { 1, -2, -2 },
+ { 1, 2, -2 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 0, 16, 17 },
+ { 0, 17, 18 },
+ { 0, 18, 19 },
+ { 0, 19, 20 },
+ { 0, 20, 21 },
+ { 0, 21, 22 },
+ { 0, 22, 23 },
+ { 0, 23, 24 },
+ { 1, -3, -2 },
+ { 1, 3, -2 },
+ { 1, -2, 3 },
+ { 1, 2, -3 },
+ { 1, 3, 2 },
+ { 1, 2, 3 },
+ { 1, -3, 2 },
+ { 1, -2, -3 },
+ { 1, 0, -4 },
+ { 1, -4, 0 },
+ { 1, 4, 1 },
+ { 1, 4, 0 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 0, 16, 17 },
+ { 0, 17, 18 },
+ { 0, 18, 19 },
+ { 0, 19, 20 },
+ { 0, 20, 21 },
+ { 0, 21, 22 },
+ { 0, 22, 23 },
+ { 0, 23, 24 },
+ { 1, -4, -1 },
+ { 1, 0, 4 },
+ { 1, 4, -1 },
+ { 1, -1, -4 },
+ { 1, 1, 4 },
+ { 1, -1, 4 },
+ { 1, -4, 1 },
+ { 1, 1, -4 },
+ { 1, 3, -3 },
+ { 1, -3, -3 },
+ { 1, -3, 3 },
+ { 1, -2, 4 },
+ { 1, -4, -2 },
+ { 1, 4, 2 },
+ { 1, 2, -4 },
+ { 1, 2, 4 },
+ { 1, 3, 3 },
+ { 1, -4, 2 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 1, -2, -4 },
+ { 1, 4, -2 },
+ { 1, 3, -4 },
+ { 1, -4, -3 },
+ { 1, -4, 3 },
+ { 1, 3, 4 },
+ { 1, -3, 4 },
+ { 1, 4, 3 },
+ { 1, 4, -3 },
+ { 1, -3, -4 },
+ { 0, 2, 3 },
+ { 0, 3, 4 },
+ { 1, 4, -4 },
+ { 1, -4, 4 },
+ { 1, 4, 4 },
+ { 1, -4, -4 }
+};
+
+//---------------------------------------------------------------------------
+// Spectrum Huffman Codebook 6
+static hcb_struct_1 huffman_06_1[32] = {
+ { 0, 0 },
+ { 0, 0 },
+ { 1, 0 },
+ { 1, 0 },
+ { 2, 0 },
+ { 2, 0 },
+ { 3, 0 },
+ { 3, 0 },
+ { 4, 0 },
+ { 4, 0 },
+ { 5, 0 },
+ { 5, 0 },
+ { 6, 0 },
+ { 6, 0 },
+ { 7, 0 },
+ { 7, 0 },
+ { 8, 0 },
+ { 8, 0 },
+ { 9, 1 },
+ { 11, 1 },
+ { 13, 1 },
+ { 15, 1 },
+ { 17, 1 },
+ { 19, 1 },
+ { 21, 1 },
+ { 23, 1 },
+ { 25, 2 },
+ { 29, 2 },
+ { 33, 2 },
+ { 37, 3 },
+ { 45, 4 },
+ { 61, 6 }
+};
+
+static hcb_struct huffman_06[126]=
+{
+ { 4, 0, 0 },
+ { 4, 1, 0 },
+ { 4, 0, -1 },
+ { 4, 0, 1 },
+ { 4, -1, 0 },
+ { 4, 1, 1 },
+ { 4, -1, 1 },
+ { 4, 1, -1 },
+ { 4, -1, -1 },
+ { 6, 2, -1 },
+ { 6, 2, 1 },
+ { 6, -2, 1 },
+ { 6, -2, -1 },
+ { 6, -2, 0 },
+ { 6, -1, 2 },
+ { 6, 2, 0 },
+ { 6, 1, -2 },
+ { 6, 1, 2 },
+ { 6, 0, -2 },
+ { 6, -1, -2 },
+ { 6, 0, 2 },
+ { 6, 2, -2 },
+ { 6, -2, 2 },
+ { 6, -2, -2 },
+ { 6, 2, 2 },
+ { 7, -3, 1 },
+ { 7, 3, 1 },
+ { 7, 3, -1 },
+ { 7, -1, 3 },
+ { 7, -3, -1 },
+ { 7, 1, 3 },
+ { 7, 1, -3 },
+ { 7, -1, -3 },
+ { 7, 3, 0 },
+ { 7, -3, 0 },
+ { 7, 0, -3 },
+ { 7, 0, 3 },
+ { 7, 3, 2 },
+ { 7, 3, 2 },
+ { 8, -3, -2 },
+ { 8, -2, 3 },
+ { 8, 2, 3 },
+ { 8, 3, -2 },
+ { 8, 2, -3 },
+ { 8, -2, -3 },
+ { 8, -3, 2 },
+ { 8, -3, 2 },
+ { 8, 3, 3 },
+ { 8, 3, 3 },
+ { 9, 3, -3 },
+ { 9, -3, -3 },
+ { 9, -3, 3 },
+ { 9, 1, -4 },
+ { 9, -1, -4 },
+ { 9, 4, 1 },
+ { 9, -4, 1 },
+ { 9, -4, -1 },
+ { 9, 1, 4 },
+ { 9, 4, -1 },
+ { 9, -1, 4 },
+ { 9, 0, -4 },
+ { 9, -4, 2 },
+ { 9, -4, 2 },
+ { 9, -4, 2 },
+ { 9, -4, 2 },
+ { 9, -4, -2 },
+ { 9, -4, -2 },
+ { 9, -4, -2 },
+ { 9, -4, -2 },
+ { 9, 2, 4 },
+ { 9, 2, 4 },
+ { 9, 2, 4 },
+ { 9, 2, 4 },
+ { 9, -2, -4 },
+ { 9, -2, -4 },
+ { 9, -2, -4 },
+ { 9, -2, -4 },
+ { 9, -4, 0 },
+ { 9, -4, 0 },
+ { 9, -4, 0 },
+ { 9, -4, 0 },
+ { 9, 4, 2 },
+ { 9, 4, 2 },
+ { 9, 4, 2 },
+ { 9, 4, 2 },
+ { 9, 4, -2 },
+ { 9, 4, -2 },
+ { 9, 4, -2 },
+ { 9, 4, -2 },
+ { 9, -2, 4 },
+ { 9, -2, 4 },
+ { 9, -2, 4 },
+ { 9, -2, 4 },
+ { 9, 4, 0 },
+ { 9, 4, 0 },
+ { 9, 4, 0 },
+ { 9, 4, 0 },
+ { 9, 2, -4 },
+ { 9, 2, -4 },
+ { 9, 2, -4 },
+ { 9, 2, -4 },
+ { 9, 0, 4 },
+ { 9, 0, 4 },
+ { 9, 0, 4 },
+ { 9, 0, 4 },
+ { 10, -3, -4 },
+ { 10, -3, -4 },
+ { 10, -3, 4 },
+ { 10, -3, 4 },
+ { 10, 3, -4 },
+ { 10, 3, -4 },
+ { 10, 4, -3 },
+ { 10, 4, -3 },
+ { 10, 3, 4 },
+ { 10, 3, 4 },
+ { 10, 4, 3 },
+ { 10, 4, 3 },
+ { 10, -4, 3 },
+ { 10, -4, 3 },
+ { 10, -4, -3 },
+ { 10, -4, -3 },
+ { 11, 4, 4 },
+ { 11, -4, 4 },
+ { 11, -4, -4 },
+ { 11, 4, -4 }
+};
+
+//---------------------------------------------------------------------------
+// Spectrum Huffman Codebook 7
+static hcb_struct huffman_07[127] =
+{
+ { 0, 1, 2 },
+ { 1, 0, 0 },
+ { 0, 1, 2 },
+ { 0, 2, 3 },
+ { 0, 3, 4 },
+ { 1, 1, 0 },
+ { 1, 0, 1 },
+ { 0, 2, 3 },
+ { 0, 3, 4 },
+ { 1, 1, 1 },
+ { 0, 3, 4 },
+ { 0, 4, 5 },
+ { 0, 5, 6 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 1, 2, 1 },
+ { 1, 1, 2 },
+ { 1, 2, 0 },
+ { 1, 0, 2 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 1, 3, 1 },
+ { 1, 1, 3 },
+ { 1, 2, 2 },
+ { 1, 3, 0 },
+ { 1, 0, 3 },
+ { 0, 11, 12 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 0, 16, 17 },
+ { 0, 17, 18 },
+ { 0, 18, 19 },
+ { 0, 19, 20 },
+ { 0, 20, 21 },
+ { 0, 21, 22 },
+ { 1, 2, 3 },
+ { 1, 3, 2 },
+ { 1, 1, 4 },
+ { 1, 4, 1 },
+ { 1, 1, 5 },
+ { 1, 5, 1 },
+ { 1, 3, 3 },
+ { 1, 2, 4 },
+ { 1, 0, 4 },
+ { 1, 4, 0 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 0, 16, 17 },
+ { 0, 17, 18 },
+ { 0, 18, 19 },
+ { 0, 19, 20 },
+ { 0, 20, 21 },
+ { 0, 21, 22 },
+ { 0, 22, 23 },
+ { 0, 23, 24 },
+ { 1, 4, 2 },
+ { 1, 2, 5 },
+ { 1, 5, 2 },
+ { 1, 0, 5 },
+ { 1, 6, 1 },
+ { 1, 5, 0 },
+ { 1, 1, 6 },
+ { 1, 4, 3 },
+ { 1, 3, 5 },
+ { 1, 3, 4 },
+ { 1, 5, 3 },
+ { 1, 2, 6 },
+ { 1, 6, 2 },
+ { 1, 1, 7 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 0, 16, 17 },
+ { 0, 17, 18 },
+ { 0, 18, 19 },
+ { 0, 19, 20 },
+ { 1, 3, 6 },
+ { 1, 0, 6 },
+ { 1, 6, 0 },
+ { 1, 4, 4 },
+ { 1, 7, 1 },
+ { 1, 4, 5 },
+ { 1, 7, 2 },
+ { 1, 5, 4 },
+ { 1, 6, 3 },
+ { 1, 2, 7 },
+ { 1, 7, 3 },
+ { 1, 6, 4 },
+ { 1, 5, 5 },
+ { 1, 4, 6 },
+ { 1, 3, 7 },
+ { 0, 5, 6 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 1, 7, 0 },
+ { 1, 0, 7 },
+ { 1, 6, 5 },
+ { 1, 5, 6 },
+ { 1, 7, 4 },
+ { 1, 4, 7 },
+ { 1, 5, 7 },
+ { 1, 7, 5 },
+ { 0, 2, 3 },
+ { 0, 3, 4 },
+ { 1, 7, 6 },
+ { 1, 6, 6 },
+ { 1, 6, 7 },
+ { 1, 7, 7 }
+};
+
+//---------------------------------------------------------------------------
+// Spectrum Huffman Codebook 8
+static hcb_struct_1 huffman_08_1[32]=
+{
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 1, 0 },
+ { 1, 0 },
+ { 2, 0 },
+ { 2, 0 },
+ { 3, 0 },
+ { 3, 0 },
+ { 4, 0 },
+ { 4, 0 },
+ { 5, 0 },
+ { 5, 0 },
+ { 6, 0 },
+ { 7, 0 },
+ { 8, 0 },
+ { 9, 0 },
+ { 10, 0 },
+ { 11, 0 },
+ { 12, 0 },
+ { 13, 1 },
+ { 15, 1 },
+ { 17, 1 },
+ { 19, 1 },
+ { 21, 1 },
+ { 23, 2 },
+ { 27, 2 },
+ { 31, 2 },
+ { 35, 3 },
+ { 43, 3 },
+ { 51, 5 }
+};
+
+static hcb_struct huffman_08[83]=
+{
+ { 3, 1, 1 },
+ { 4, 2, 1 },
+ { 4, 1, 0 },
+ { 4, 1, 2 },
+ { 4, 0, 1 },
+ { 4, 2, 2 },
+ { 5, 0, 0 },
+ { 5, 2, 0 },
+ { 5, 0, 2 },
+ { 5, 3, 1 },
+ { 5, 1, 3 },
+ { 5, 3, 2 },
+ { 5, 2, 3 },
+ { 6, 3, 3 },
+ { 6, 4, 1 },
+ { 6, 1, 4 },
+ { 6, 4, 2 },
+ { 6, 2, 4 },
+ { 6, 3, 0 },
+ { 6, 0, 3 },
+ { 6, 4, 3 },
+ { 6, 3, 4 },
+ { 6, 5, 2 },
+ { 7, 5, 1 },
+ { 7, 2, 5 },
+ { 7, 1, 5 },
+ { 7, 5, 3 },
+ { 7, 3, 5 },
+ { 7, 4, 4 },
+ { 7, 5, 4 },
+ { 7, 0, 4 },
+ { 7, 4, 5 },
+ { 7, 4, 0 },
+ { 7, 2, 6 },
+ { 7, 6, 2 },
+ { 7, 6, 1 },
+ { 7, 6, 1 },
+ { 7, 1, 6 },
+ { 7, 1, 6 },
+ { 8, 3, 6 },
+ { 8, 6, 3 },
+ { 8, 5, 5 },
+ { 8, 5, 0 },
+ { 8, 6, 4 },
+ { 8, 0, 5 },
+ { 8, 4, 6 },
+ { 8, 7, 1 },
+ { 8, 7, 2 },
+ { 8, 2, 7 },
+ { 8, 6, 5 },
+ { 8, 7, 3 },
+ { 8, 1, 7 },
+ { 8, 1, 7 },
+ { 8, 1, 7 },
+ { 8, 1, 7 },
+ { 8, 5, 6 },
+ { 8, 5, 6 },
+ { 8, 5, 6 },
+ { 8, 5, 6 },
+ { 8, 3, 7 },
+ { 8, 3, 7 },
+ { 8, 3, 7 },
+ { 8, 3, 7 },
+ { 9, 6, 6 },
+ { 9, 6, 6 },
+ { 9, 7, 4 },
+ { 9, 7, 4 },
+ { 9, 6, 0 },
+ { 9, 6, 0 },
+ { 9, 4, 7 },
+ { 9, 4, 7 },
+ { 9, 0, 6 },
+ { 9, 0, 6 },
+ { 9, 7, 5 },
+ { 9, 7, 5 },
+ { 9, 7, 6 },
+ { 9, 7, 6 },
+ { 9, 6, 7 },
+ { 9, 6, 7 },
+ { 10, 5, 7 },
+ { 10, 7, 0 },
+ { 10, 0, 7 },
+ { 10, 7, 7 }
+};
+
+//---------------------------------------------------------------------------
+// Spectrum Huffman Codebook 9
+static hcb_struct huffman_09[337]=
+{
+ { 0, 1, 2 },
+ { 1, 0, 0 },
+ { 0, 1, 2 },
+ { 0, 2, 3 },
+ { 0, 3, 4 },
+ { 1, 1, 0 },
+ { 1, 0, 1 },
+ { 0, 2, 3 },
+ { 0, 3, 4 },
+ { 1, 1, 1 },
+ { 0, 3, 4 },
+ { 0, 4, 5 },
+ { 0, 5, 6 },
+ { 0, 6, 7 },
+ { 0, 7, 8 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 1, 2, 1 },
+ { 1, 1, 2 },
+ { 1, 2, 0 },
+ { 1, 0, 2 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 1, 3, 1 },
+ { 1, 2, 2 },
+ { 1, 1, 3 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 0, 16, 17 },
+ { 0, 17, 18 },
+ { 0, 18, 19 },
+ { 0, 19, 20 },
+ { 0, 20, 21 },
+ { 0, 21, 22 },
+ { 0, 22, 23 },
+ { 0, 23, 24 },
+ { 0, 24, 25 },
+ { 0, 25, 26 },
+ { 1, 3, 0 },
+ { 1, 0, 3 },
+ { 1, 2, 3 },
+ { 1, 3, 2 },
+ { 1, 1, 4 },
+ { 1, 4, 1 },
+ { 1, 2, 4 },
+ { 1, 1, 5 },
+ { 0, 18, 19 },
+ { 0, 19, 20 },
+ { 0, 20, 21 },
+ { 0, 21, 22 },
+ { 0, 22, 23 },
+ { 0, 23, 24 },
+ { 0, 24, 25 },
+ { 0, 25, 26 },
+ { 0, 26, 27 },
+ { 0, 27, 28 },
+ { 0, 28, 29 },
+ { 0, 29, 30 },
+ { 0, 30, 31 },
+ { 0, 31, 32 },
+ { 0, 32, 33 },
+ { 0, 33, 34 },
+ { 0, 34, 35 },
+ { 0, 35, 36 },
+ { 1, 4, 2 },
+ { 1, 3, 3 },
+ { 1, 0, 4 },
+ { 1, 4, 0 },
+ { 1, 5, 1 },
+ { 1, 2, 5 },
+ { 1, 1, 6 },
+ { 1, 3, 4 },
+ { 1, 5, 2 },
+ { 1, 6, 1 },
+ { 1, 4, 3 },
+ { 0, 25, 26 },
+ { 0, 26, 27 },
+ { 0, 27, 28 },
+ { 0, 28, 29 },
+ { 0, 29, 30 },
+ { 0, 30, 31 },
+ { 0, 31, 32 },
+ { 0, 32, 33 },
+ { 0, 33, 34 },
+ { 0, 34, 35 },
+ { 0, 35, 36 },
+ { 0, 36, 37 },
+ { 0, 37, 38 },
+ { 0, 38, 39 },
+ { 0, 39, 40 },
+ { 0, 40, 41 },
+ { 0, 41, 42 },
+ { 0, 42, 43 },
+ { 0, 43, 44 },
+ { 0, 44, 45 },
+ { 0, 45, 46 },
+ { 0, 46, 47 },
+ { 0, 47, 48 },
+ { 0, 48, 49 },
+ { 0, 49, 50 },
+ { 1, 0, 5 },
+ { 1, 2, 6 },
+ { 1, 5, 0 },
+ { 1, 1, 7 },
+ { 1, 3, 5 },
+ { 1, 1, 8 },
+ { 1, 8, 1 },
+ { 1, 4, 4 },
+ { 1, 5, 3 },
+ { 1, 6, 2 },
+ { 1, 7, 1 },
+ { 1, 0, 6 },
+ { 1, 8, 2 },
+ { 1, 2, 8 },
+ { 1, 3, 6 },
+ { 1, 2, 7 },
+ { 1, 4, 5 },
+ { 1, 9, 1 },
+ { 1, 1, 9 },
+ { 1, 7, 2 },
+ { 0, 30, 31 },
+ { 0, 31, 32 },
+ { 0, 32, 33 },
+ { 0, 33, 34 },
+ { 0, 34, 35 },
+ { 0, 35, 36 },
+ { 0, 36, 37 },
+ { 0, 37, 38 },
+ { 0, 38, 39 },
+ { 0, 39, 40 },
+ { 0, 40, 41 },
+ { 0, 41, 42 },
+ { 0, 42, 43 },
+ { 0, 43, 44 },
+ { 0, 44, 45 },
+ { 0, 45, 46 },
+ { 0, 46, 47 },
+ { 0, 47, 48 },
+ { 0, 48, 49 },
+ { 0, 49, 50 },
+ { 0, 50, 51 },
+ { 0, 51, 52 },
+ { 0, 52, 53 },
+ { 0, 53, 54 },
+ { 0, 54, 55 },
+ { 0, 55, 56 },
+ { 0, 56, 57 },
+ { 0, 57, 58 },
+ { 0, 58, 59 },
+ { 0, 59, 60 },
+ { 1, 6, 0 },
+ { 1, 5, 4 },
+ { 1, 6, 3 },
+ { 1, 8, 3 },
+ { 1, 0, 7 },
+ { 1, 9, 2 },
+ { 1, 3, 8 },
+ { 1, 4, 6 },
+ { 1, 3, 7 },
+ { 1, 0, 8 },
+ { 1, 10, 1 },
+ { 1, 6, 4 },
+ { 1, 2, 9 },
+ { 1, 5, 5 },
+ { 1, 8, 0 },
+ { 1, 7, 0 },
+ { 1, 7, 3 },
+ { 1, 10, 2 },
+ { 1, 9, 3 },
+ { 1, 8, 4 },
+ { 1, 1, 10 },
+ { 1, 7, 4 },
+ { 1, 6, 5 },
+ { 1, 5, 6 },
+ { 1, 4, 8 },
+ { 1, 4, 7 },
+ { 1, 3, 9 },
+ { 1, 11, 1 },
+ { 1, 5, 8 },
+ { 1, 9, 0 },
+ { 1, 8, 5 },
+ { 0, 29, 30 },
+ { 0, 30, 31 },
+ { 0, 31, 32 },
+ { 0, 32, 33 },
+ { 0, 33, 34 },
+ { 0, 34, 35 },
+ { 0, 35, 36 },
+ { 0, 36, 37 },
+ { 0, 37, 38 },
+ { 0, 38, 39 },
+ { 0, 39, 40 },
+ { 0, 40, 41 },
+ { 0, 41, 42 },
+ { 0, 42, 43 },
+ { 0, 43, 44 },
+ { 0, 44, 45 },
+ { 0, 45, 46 },
+ { 0, 46, 47 },
+ { 0, 47, 48 },
+ { 0, 48, 49 },
+ { 0, 49, 50 },
+ { 0, 50, 51 },
+ { 0, 51, 52 },
+ { 0, 52, 53 },
+ { 0, 53, 54 },
+ { 0, 54, 55 },
+ { 0, 55, 56 },
+ { 0, 56, 57 },
+ { 0, 57, 58 },
+ { 1, 10, 3 },
+ { 1, 2, 10 },
+ { 1, 0, 9 },
+ { 1, 11, 2 },
+ { 1, 9, 4 },
+ { 1, 6, 6 },
+ { 1, 12, 1 },
+ { 1, 4, 9 },
+ { 1, 8, 6 },
+ { 1, 1, 11 },
+ { 1, 9, 5 },
+ { 1, 10, 4 },
+ { 1, 5, 7 },
+ { 1, 7, 5 },
+ { 1, 2, 11 },
+ { 1, 1, 12 },
+ { 1, 12, 2 },
+ { 1, 11, 3 },
+ { 1, 3, 10 },
+ { 1, 5, 9 },
+ { 1, 6, 7 },
+ { 1, 8, 7 },
+ { 1, 11, 4 },
+ { 1, 0, 10 },
+ { 1, 7, 6 },
+ { 1, 12, 3 },
+ { 1, 10, 0 },
+ { 1, 10, 5 },
+ { 1, 4, 10 },
+ { 1, 6, 8 },
+ { 1, 2, 12 },
+ { 1, 9, 6 },
+ { 1, 9, 7 },
+ { 1, 4, 11 },
+ { 1, 11, 0 },
+ { 1, 6, 9 },
+ { 1, 3, 11 },
+ { 1, 5, 10 },
+ { 0, 20, 21 },
+ { 0, 21, 22 },
+ { 0, 22, 23 },
+ { 0, 23, 24 },
+ { 0, 24, 25 },
+ { 0, 25, 26 },
+ { 0, 26, 27 },
+ { 0, 27, 28 },
+ { 0, 28, 29 },
+ { 0, 29, 30 },
+ { 0, 30, 31 },
+ { 0, 31, 32 },
+ { 0, 32, 33 },
+ { 0, 33, 34 },
+ { 0, 34, 35 },
+ { 0, 35, 36 },
+ { 0, 36, 37 },
+ { 0, 37, 38 },
+ { 0, 38, 39 },
+ { 0, 39, 40 },
+ { 1, 8, 8 },
+ { 1, 7, 8 },
+ { 1, 12, 5 },
+ { 1, 3, 12 },
+ { 1, 11, 5 },
+ { 1, 7, 7 },
+ { 1, 12, 4 },
+ { 1, 11, 6 },
+ { 1, 10, 6 },
+ { 1, 4, 12 },
+ { 1, 7, 9 },
+ { 1, 5, 11 },
+ { 1, 0, 11 },
+ { 1, 12, 6 },
+ { 1, 6, 10 },
+ { 1, 12, 0 },
+ { 1, 10, 7 },
+ { 1, 5, 12 },
+ { 1, 7, 10 },
+ { 1, 9, 8 },
+ { 1, 0, 12 },
+ { 1, 11, 7 },
+ { 1, 8, 9 },
+ { 1, 9, 9 },
+ { 1, 10, 8 },
+ { 1, 7, 11 },
+ { 1, 12, 7 },
+ { 1, 6, 11 },
+ { 1, 8, 11 },
+ { 1, 11, 8 },
+ { 1, 7, 12 },
+ { 1, 6, 12 },
+ { 0, 8, 9 },
+ { 0, 9, 10 },
+ { 0, 10, 11 },
+ { 0, 11, 12 },
+ { 0, 12, 13 },
+ { 0, 13, 14 },
+ { 0, 14, 15 },
+ { 0, 15, 16 },
+ { 1, 8, 10 },
+ { 1, 10, 9 },
+ { 1, 8, 12 },
+ { 1, 9, 10 },
+ { 1, 9, 11 },
+ { 1, 9, 12 },
+ { 1, 10, 11 },
+ { 1, 12, 9 },
+ { 1, 10, 10 },
+ { 1, 11, 9 },
+ { 1, 12, 8 },
+ { 1, 11, 10 },
+ { 1, 12, 10 },
+ { 1, 12, 11 },
+ { 0, 2, 3 },
+ { 0, 3, 4 },
+ { 1, 10, 12 },
+ { 1, 11, 11 },
+ { 1, 11, 12 },
+ { 1, 12, 12 }
+};
+
+//---------------------------------------------------------------------------
+// Spectrum Huffman Codebook 10
+static hcb_struct_1 huffman_10_1[64]=
+{
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 1, 0 },
+ { 1, 0 },
+ { 1, 0 },
+ { 1, 0 },
+ { 2, 0 },
+ { 2, 0 },
+ { 2, 0 },
+ { 2, 0 },
+ { 3, 0 },
+ { 3, 0 },
+ { 4, 0 },
+ { 4, 0 },
+ { 5, 0 },
+ { 5, 0 },
+ { 6, 0 },
+ { 6, 0 },
+ { 7, 0 },
+ { 7, 0 },
+ { 8, 0 },
+ { 8, 0 },
+ { 9, 0 },
+ { 9, 0 },
+ { 10, 0 },
+ { 10, 0 },
+ { 11, 0 },
+ { 12, 0 },
+ { 13, 0 },
+ { 14, 0 },
+ { 15, 0 },
+ { 16, 0 },
+ { 17, 0 },
+ { 18, 0 },
+ { 19, 0 },
+ { 20, 0 },
+ { 21, 0 },
+ { 22, 0 },
+ { 23, 0 },
+ { 24, 0 },
+ { 25, 1 },
+ { 27, 1 },
+ { 29, 1 },
+ { 31, 1 },
+ { 33, 1 },
+ { 35, 1 },
+ { 37, 1 },
+ { 39, 1 },
+ { 41, 2 },
+ { 45, 2 },
+ { 49, 2 },
+ { 53, 2 },
+ { 57, 2 },
+ { 61, 2 },
+ { 65, 3 },
+ { 73, 3 },
+ { 81, 3 },
+ { 89, 3 },
+ { 97, 4 },
+ { 113, 4 },
+ { 129, 4 },
+ { 145, 6 }
+};
+
+static hcb_struct huffman_10[210]=
+{
+ { 4, 1, 1 },
+ { 4, 1, 2 },
+ { 4, 2, 1 },
+ { 5, 2, 2 },
+ { 5, 1, 0 },
+ { 5, 0, 1 },
+ { 5, 1, 3 },
+ { 5, 3, 2 },
+ { 5, 3, 1 },
+ { 5, 2, 3 },
+ { 5, 3, 3 },
+ { 6, 2, 0 },
+ { 6, 0, 2 },
+ { 6, 2, 4 },
+ { 6, 4, 2 },
+ { 6, 1, 4 },
+ { 6, 4, 1 },
+ { 6, 0, 0 },
+ { 6, 4, 3 },
+ { 6, 3, 4 },
+ { 6, 3, 0 },
+ { 6, 0, 3 },
+ { 6, 4, 4 },
+ { 6, 2, 5 },
+ { 6, 5, 2 },
+ { 7, 1, 5 },
+ { 7, 5, 1 },
+ { 7, 5, 3 },
+ { 7, 3, 5 },
+ { 7, 5, 4 },
+ { 7, 4, 5 },
+ { 7, 6, 2 },
+ { 7, 2, 6 },
+ { 7, 6, 3 },
+ { 7, 4, 0 },
+ { 7, 6, 1 },
+ { 7, 0, 4 },
+ { 7, 1, 6 },
+ { 7, 3, 6 },
+ { 7, 5, 5 },
+ { 7, 6, 4 },
+ { 7, 4, 6 },
+ { 7, 4, 6 },
+ { 8, 6, 5 },
+ { 8, 7, 2 },
+ { 8, 3, 7 },
+ { 8, 2, 7 },
+ { 8, 5, 6 },
+ { 8, 8, 2 },
+ { 8, 7, 3 },
+ { 8, 5, 0 },
+ { 8, 7, 1 },
+ { 8, 0, 5 },
+ { 8, 8, 1 },
+ { 8, 1, 7 },
+ { 8, 8, 3 },
+ { 8, 7, 4 },
+ { 8, 4, 7 },
+ { 8, 2, 8 },
+ { 8, 6, 6 },
+ { 8, 7, 5 },
+ { 8, 1, 8 },
+ { 8, 3, 8 },
+ { 8, 8, 4 },
+ { 8, 4, 8 },
+ { 8, 5, 7 },
+ { 8, 5, 7 },
+ { 8, 8, 5 },
+ { 8, 8, 5 },
+ { 8, 5, 8 },
+ { 8, 5, 8 },
+ { 9, 7, 6 },
+ { 9, 6, 7 },
+ { 9, 9, 2 },
+ { 9, 6, 0 },
+ { 9, 6, 8 },
+ { 9, 9, 3 },
+ { 9, 3, 9 },
+ { 9, 9, 1 },
+ { 9, 2, 9 },
+ { 9, 0, 6 },
+ { 9, 8, 6 },
+ { 9, 9, 4 },
+ { 9, 4, 9 },
+ { 9, 10, 2 },
+ { 9, 1, 9 },
+ { 9, 7, 7 },
+ { 9, 8, 7 },
+ { 9, 9, 5 },
+ { 9, 7, 8 },
+ { 9, 10, 3 },
+ { 9, 5, 9 },
+ { 9, 10, 4 },
+ { 9, 2, 10 },
+ { 9, 10, 1 },
+ { 9, 3, 10 },
+ { 9, 9, 6 },
+ { 9, 6, 9 },
+ { 9, 6, 9 },
+ { 9, 8, 0 },
+ { 9, 8, 0 },
+ { 9, 4, 10 },
+ { 9, 4, 10 },
+ { 9, 7, 0 },
+ { 9, 7, 0 },
+ { 9, 11, 2 },
+ { 9, 11, 2 },
+ { 10, 7, 9 },
+ { 10, 11, 3 },
+ { 10, 10, 6 },
+ { 10, 1, 10 },
+ { 10, 11, 1 },
+ { 10, 9, 7 },
+ { 10, 0, 7 },
+ { 10, 8, 8 },
+ { 10, 10, 5 },
+ { 10, 3, 11 },
+ { 10, 5, 10 },
+ { 10, 8, 9 },
+ { 10, 11, 5 },
+ { 10, 0, 8 },
+ { 10, 11, 4 },
+ { 10, 2, 11 },
+ { 10, 7, 10 },
+ { 10, 6, 10 },
+ { 10, 10, 7 },
+ { 10, 4, 11 },
+ { 10, 1, 11 },
+ { 10, 12, 2 },
+ { 10, 9, 8 },
+ { 10, 12, 3 },
+ { 10, 11, 6 },
+ { 10, 5, 11 },
+ { 10, 12, 4 },
+ { 10, 11, 7 },
+ { 10, 12, 5 },
+ { 10, 3, 12 },
+ { 10, 6, 11 },
+ { 10, 9, 0 },
+ { 10, 10, 8 },
+ { 10, 10, 0 },
+ { 10, 12, 1 },
+ { 10, 0, 9 },
+ { 10, 4, 12 },
+ { 10, 9, 9 },
+ { 10, 12, 6 },
+ { 10, 12, 6 },
+ { 10, 12, 6 },
+ { 10, 12, 6 },
+ { 10, 2, 12 },
+ { 10, 2, 12 },
+ { 10, 2, 12 },
+ { 10, 2, 12 },
+ { 10, 8, 10 },
+ { 10, 8, 10 },
+ { 10, 8, 10 },
+ { 10, 8, 10 },
+ { 11, 9, 10 },
+ { 11, 9, 10 },
+ { 11, 1, 12 },
+ { 11, 1, 12 },
+ { 11, 11, 8 },
+ { 11, 11, 8 },
+ { 11, 12, 7 },
+ { 11, 12, 7 },
+ { 11, 7, 11 },
+ { 11, 7, 11 },
+ { 11, 5, 12 },
+ { 11, 5, 12 },
+ { 11, 6, 12 },
+ { 11, 6, 12 },
+ { 11, 10, 9 },
+ { 11, 10, 9 },
+ { 11, 8, 11 },
+ { 11, 8, 11 },
+ { 11, 12, 8 },
+ { 11, 12, 8 },
+ { 11, 0, 10 },
+ { 11, 0, 10 },
+ { 11, 7, 12 },
+ { 11, 7, 12 },
+ { 11, 11, 0 },
+ { 11, 11, 0 },
+ { 11, 10, 10 },
+ { 11, 10, 10 },
+ { 11, 11, 9 },
+ { 11, 11, 9 },
+ { 11, 11, 10 },
+ { 11, 11, 10 },
+ { 11, 0, 11 },
+ { 11, 0, 11 },
+ { 11, 11, 11 },
+ { 11, 11, 11 },
+ { 11, 9, 11 },
+ { 11, 9, 11 },
+ { 11, 10, 11 },
+ { 11, 10, 11 },
+ { 11, 12, 0 },
+ { 11, 12, 0 },
+ { 11, 8, 12 },
+ { 11, 8, 12 },
+ { 12, 12, 9 },
+ { 12, 10, 12 },
+ { 12, 9, 12 },
+ { 12, 11, 12 },
+ { 12, 12, 11 },
+ { 12, 0, 12 },
+ { 12, 12, 10 },
+ { 12, 12, 12 }
+};
+
+//---------------------------------------------------------------------------
+// Spectrum Huffman Codebook 11
+static hcb_struct_1 huffman_11_1[32]=
+{
+ { 0, 0 },
+ { 0, 0 },
+ { 1, 0 },
+ { 1, 0 },
+ { 2, 0 },
+ { 3, 0 },
+ { 4, 0 },
+ { 5, 0 },
+ { 6, 0 },
+ { 7, 0 },
+ { 8, 1 },
+ { 10, 1 },
+ { 12, 1 },
+ { 14, 2 },
+ { 18, 2 },
+ { 22, 2 },
+ { 26, 2 },
+ { 30, 3 },
+ { 38, 3 },
+ { 46, 3 },
+ { 54, 3 },
+ { 62, 3 },
+ { 70, 3 },
+ { 78, 3 },
+ { 86, 4 },
+ { 102, 4 },
+ { 118, 4 },
+ { 134, 4 },
+ { 150, 5 },
+ { 182, 5 },
+ { 214, 5 },
+ { 246, 7 }
+};
+
+static hcb_struct huffman_11[374]=
+{
+ { 4, 0, 0 },
+ { 4, 1, 1 },
+ { 5, 16, 16 },
+ { 5, 1, 0 },
+ { 5, 0, 1 },
+ { 5, 2, 1 },
+ { 5, 1, 2 },
+ { 5, 2, 2 },
+ { 6, 1, 3 },
+ { 6, 3, 1 },
+ { 6, 3, 2 },
+ { 6, 2, 0 },
+ { 6, 2, 3 },
+ { 6, 0, 2 },
+ { 6, 3, 3 },
+ { 6, 3, 3 },
+ { 7, 4, 1 },
+ { 7, 1, 4 },
+ { 7, 4, 2 },
+ { 7, 2, 4 },
+ { 7, 4, 3 },
+ { 7, 3, 4 },
+ { 7, 3, 0 },
+ { 7, 0, 3 },
+ { 7, 5, 1 },
+ { 7, 5, 2 },
+ { 7, 2, 5 },
+ { 7, 4, 4 },
+ { 7, 1, 5 },
+ { 7, 5, 3 },
+ { 7, 3, 5 },
+ { 7, 3, 5 },
+ { 7, 5, 4 },
+ { 7, 5, 4 },
+ { 8, 4, 5 },
+ { 8, 6, 2 },
+ { 8, 2, 6 },
+ { 8, 6, 1 },
+ { 8, 6, 3 },
+ { 8, 3, 6 },
+ { 8, 1, 6 },
+ { 8, 4, 16 },
+ { 8, 3, 16 },
+ { 8, 16, 5 },
+ { 8, 16, 3 },
+ { 8, 16, 4 },
+ { 8, 6, 4 },
+ { 8, 16, 6 },
+ { 8, 4, 0 },
+ { 8, 4, 6 },
+ { 8, 0, 4 },
+ { 8, 2, 16 },
+ { 8, 5, 5 },
+ { 8, 5, 16 },
+ { 8, 16, 7 },
+ { 8, 16, 2 },
+ { 8, 16, 8 },
+ { 8, 2, 7 },
+ { 8, 7, 2 },
+ { 8, 3, 7 },
+ { 8, 6, 5 },
+ { 8, 5, 6 },
+ { 8, 6, 16 },
+ { 8, 16, 10 },
+ { 8, 7, 3 },
+ { 8, 7, 1 },
+ { 8, 16, 9 },
+ { 8, 7, 16 },
+ { 8, 1, 16 },
+ { 8, 1, 7 },
+ { 8, 4, 7 },
+ { 8, 16, 11 },
+ { 8, 7, 4 },
+ { 8, 16, 12 },
+ { 8, 8, 16 },
+ { 8, 16, 1 },
+ { 8, 6, 6 },
+ { 8, 9, 16 },
+ { 8, 2, 8 },
+ { 8, 5, 7 },
+ { 8, 10, 16 },
+ { 8, 16, 13 },
+ { 8, 8, 3 },
+ { 8, 8, 2 },
+ { 8, 3, 8 },
+ { 8, 5, 0 },
+ { 8, 16, 14 },
+ { 8, 16, 14 },
+ { 8, 11, 16 },
+ { 8, 11, 16 },
+ { 8, 7, 5 },
+ { 8, 7, 5 },
+ { 8, 4, 8 },
+ { 8, 4, 8 },
+ { 8, 6, 7 },
+ { 8, 6, 7 },
+ { 8, 7, 6 },
+ { 8, 7, 6 },
+ { 8, 0, 5 },
+ { 8, 0, 5 },
+ { 9, 8, 4 },
+ { 9, 16, 15 },
+ { 9, 12, 16 },
+ { 9, 1, 8 },
+ { 9, 8, 1 },
+ { 9, 14, 16 },
+ { 9, 5, 8 },
+ { 9, 13, 16 },
+ { 9, 3, 9 },
+ { 9, 8, 5 },
+ { 9, 7, 7 },
+ { 9, 2, 9 },
+ { 9, 8, 6 },
+ { 9, 9, 2 },
+ { 9, 9, 3 },
+ { 9, 15, 16 },
+ { 9, 4, 9 },
+ { 9, 6, 8 },
+ { 9, 6, 0 },
+ { 9, 9, 4 },
+ { 9, 5, 9 },
+ { 9, 8, 7 },
+ { 9, 7, 8 },
+ { 9, 1, 9 },
+ { 9, 10, 3 },
+ { 9, 0, 6 },
+ { 9, 10, 2 },
+ { 9, 9, 1 },
+ { 9, 9, 5 },
+ { 9, 4, 10 },
+ { 9, 2, 10 },
+ { 9, 9, 6 },
+ { 9, 3, 10 },
+ { 9, 6, 9 },
+ { 9, 10, 4 },
+ { 9, 8, 8 },
+ { 9, 10, 5 },
+ { 9, 9, 7 },
+ { 9, 11, 3 },
+ { 9, 1, 10 },
+ { 9, 7, 0 },
+ { 9, 10, 6 },
+ { 9, 7, 9 },
+ { 9, 3, 11 },
+ { 9, 5, 10 },
+ { 9, 10, 1 },
+ { 9, 4, 11 },
+ { 9, 11, 2 },
+ { 9, 13, 2 },
+ { 9, 6, 10 },
+ { 9, 13, 3 },
+ { 9, 13, 3 },
+ { 9, 2, 11 },
+ { 9, 2, 11 },
+ { 9, 16, 0 },
+ { 9, 16, 0 },
+ { 9, 5, 11 },
+ { 9, 5, 11 },
+ { 9, 11, 5 },
+ { 9, 11, 5 },
+ { 10, 11, 4 },
+ { 10, 9, 8 },
+ { 10, 7, 10 },
+ { 10, 8, 9 },
+ { 10, 0, 16 },
+ { 10, 4, 13 },
+ { 10, 0, 7 },
+ { 10, 3, 13 },
+ { 10, 11, 6 },
+ { 10, 13, 1 },
+ { 10, 13, 4 },
+ { 10, 12, 3 },
+ { 10, 2, 13 },
+ { 10, 13, 5 },
+ { 10, 8, 10 },
+ { 10, 6, 11 },
+ { 10, 10, 8 },
+ { 10, 10, 7 },
+ { 10, 14, 2 },
+ { 10, 12, 4 },
+ { 10, 1, 11 },
+ { 10, 4, 12 },
+ { 10, 11, 1 },
+ { 10, 3, 12 },
+ { 10, 1, 13 },
+ { 10, 12, 2 },
+ { 10, 7, 11 },
+ { 10, 3, 14 },
+ { 10, 5, 12 },
+ { 10, 5, 13 },
+ { 10, 14, 4 },
+ { 10, 4, 14 },
+ { 10, 11, 7 },
+ { 10, 14, 3 },
+ { 10, 12, 5 },
+ { 10, 13, 6 },
+ { 10, 12, 6 },
+ { 10, 8, 0 },
+ { 10, 11, 8 },
+ { 10, 2, 12 },
+ { 10, 9, 9 },
+ { 10, 14, 5 },
+ { 10, 6, 13 },
+ { 10, 10, 10 },
+ { 10, 15, 2 },
+ { 10, 8, 11 },
+ { 10, 9, 10 },
+ { 10, 14, 6 },
+ { 10, 10, 9 },
+ { 10, 5, 14 },
+ { 10, 11, 9 },
+ { 10, 14, 1 },
+ { 10, 2, 14 },
+ { 10, 6, 12 },
+ { 10, 1, 12 },
+ { 10, 13, 8 },
+ { 10, 0, 8 },
+ { 10, 13, 7 },
+ { 10, 7, 12 },
+ { 10, 12, 7 },
+ { 10, 7, 13 },
+ { 10, 15, 3 },
+ { 10, 12, 1 },
+ { 10, 6, 14 },
+ { 10, 2, 15 },
+ { 10, 15, 5 },
+ { 10, 15, 4 },
+ { 10, 1, 14 },
+ { 10, 9, 11 },
+ { 10, 4, 15 },
+ { 10, 14, 7 },
+ { 10, 8, 13 },
+ { 10, 13, 9 },
+ { 10, 8, 12 },
+ { 10, 5, 15 },
+ { 10, 3, 15 },
+ { 10, 10, 11 },
+ { 10, 11, 10 },
+ { 10, 12, 8 },
+ { 10, 15, 6 },
+ { 10, 15, 7 },
+ { 10, 8, 14 },
+ { 10, 15, 1 },
+ { 10, 7, 14 },
+ { 10, 9, 0 },
+ { 10, 0, 9 },
+ { 10, 9, 13 },
+ { 10, 9, 13 },
+ { 10, 9, 13 },
+ { 10, 9, 13 },
+ { 10, 9, 12 },
+ { 10, 9, 12 },
+ { 10, 9, 12 },
+ { 10, 9, 12 },
+ { 10, 12, 9 },
+ { 10, 12, 9 },
+ { 10, 12, 9 },
+ { 10, 12, 9 },
+ { 10, 14, 8 },
+ { 10, 14, 8 },
+ { 10, 14, 8 },
+ { 10, 14, 8 },
+ { 10, 10, 13 },
+ { 10, 10, 13 },
+ { 10, 10, 13 },
+ { 10, 10, 13 },
+ { 10, 14, 9 },
+ { 10, 14, 9 },
+ { 10, 14, 9 },
+ { 10, 14, 9 },
+ { 10, 12, 10 },
+ { 10, 12, 10 },
+ { 10, 12, 10 },
+ { 10, 12, 10 },
+ { 10, 6, 15 },
+ { 10, 6, 15 },
+ { 10, 6, 15 },
+ { 10, 6, 15 },
+ { 10, 7, 15 },
+ { 10, 7, 15 },
+ { 10, 7, 15 },
+ { 10, 7, 15 },
+ { 11, 9, 14 },
+ { 11, 9, 14 },
+ { 11, 15, 8 },
+ { 11, 15, 8 },
+ { 11, 11, 11 },
+ { 11, 11, 11 },
+ { 11, 11, 14 },
+ { 11, 11, 14 },
+ { 11, 1, 15 },
+ { 11, 1, 15 },
+ { 11, 10, 12 },
+ { 11, 10, 12 },
+ { 11, 10, 14 },
+ { 11, 10, 14 },
+ { 11, 13, 11 },
+ { 11, 13, 11 },
+ { 11, 13, 10 },
+ { 11, 13, 10 },
+ { 11, 11, 13 },
+ { 11, 11, 13 },
+ { 11, 11, 12 },
+ { 11, 11, 12 },
+ { 11, 8, 15 },
+ { 11, 8, 15 },
+ { 11, 14, 11 },
+ { 11, 14, 11 },
+ { 11, 13, 12 },
+ { 11, 13, 12 },
+ { 11, 12, 13 },
+ { 11, 12, 13 },
+ { 11, 15, 9 },
+ { 11, 15, 9 },
+ { 11, 14, 10 },
+ { 11, 14, 10 },
+ { 11, 10, 0 },
+ { 11, 10, 0 },
+ { 11, 12, 11 },
+ { 11, 12, 11 },
+ { 11, 9, 15 },
+ { 11, 9, 15 },
+ { 11, 0, 10 },
+ { 11, 0, 10 },
+ { 11, 12, 12 },
+ { 11, 12, 12 },
+ { 11, 11, 0 },
+ { 11, 11, 0 },
+ { 11, 12, 14 },
+ { 11, 12, 14 },
+ { 11, 10, 15 },
+ { 11, 10, 15 },
+ { 11, 13, 13 },
+ { 11, 13, 13 },
+ { 11, 0, 13 },
+ { 11, 0, 13 },
+ { 11, 14, 12 },
+ { 11, 14, 12 },
+ { 11, 15, 10 },
+ { 11, 15, 10 },
+ { 11, 15, 11 },
+ { 11, 15, 11 },
+ { 11, 11, 15 },
+ { 11, 11, 15 },
+ { 11, 14, 13 },
+ { 11, 14, 13 },
+ { 11, 13, 0 },
+ { 11, 13, 0 },
+ { 11, 0, 11 },
+ { 11, 0, 11 },
+ { 11, 13, 14 },
+ { 11, 13, 14 },
+ { 11, 15, 12 },
+ { 11, 15, 12 },
+ { 11, 15, 13 },
+ { 11, 15, 13 },
+ { 11, 12, 15 },
+ { 11, 12, 15 },
+ { 11, 14, 0 },
+ { 11, 14, 0 },
+ { 11, 14, 14 },
+ { 11, 14, 14 },
+ { 11, 13, 15 },
+ { 11, 13, 15 },
+ { 11, 12, 0 },
+ { 11, 12, 0 },
+ { 11, 14, 15 },
+ { 11, 14, 15 },
+ { 12, 0, 14 },
+ { 12, 0, 12 },
+ { 12, 15, 14 },
+ { 12, 15, 0 },
+ { 12, 0, 15 },
+ { 12, 15, 15 },
+};
+
+//---------------------------------------------------------------------------
+const int8u hcb_2step_Bytes[]=
+{
+ 0, 5, 5, 0, 5, 0, 5, 0, 5, 0, 6, 5
+};
+
+const hcb_struct_1* hcb_2step[]=
+{
+ 0, huffman_01_1, huffman_02_1, 0, huffman_04_1, 0, huffman_06_1, 0, huffman_08_1, 0, huffman_10_1, huffman_11_1
+};
+
+//---------------------------------------------------------------------------
+const int16u hcb_table_size[]=
+{
+ 0, 114, 86, 161, 185, 161, 126, 127, 83, 337, 210, 374
+};
+const hcb_struct* hcb_table[]=
+{
+ 0, huffman_01, huffman_02, huffman_03, huffman_04, huffman_05, huffman_06, huffman_07, huffman_08, huffman_09, huffman_10, huffman_11
+};
+
+//***************************************************************************
+// PRED_SFB_MAX
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const int8u Aac_PRED_SFB_MAX[16]=
+{
+ 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34, 64, 64, 64, 64
+};
+
+//***************************************************************************
+// swb offsets
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+struct Aac_swb_offset
+{
+ int8u num_swb;
+ int16u swb_offset[64];
+};
+
+//---------------------------------------------------------------------------
+const Aac_swb_offset Aac_swb_short_window_96[] =
+{
+ {
+ 12,
+ {
+ 0, 4, 8, 12, 16, 20, 24, 32, 40, 48,
+ 64, 92, 128
+ }
+ }
+};
+
+const Aac_swb_offset Aac_swb_short_window_64[] =
+{
+ {
+ 12,
+ {
+ 0, 4, 8, 12, 16, 20, 24, 32, 40, 48,
+ 64, 92, 128
+ }
+ }
+};
+
+const Aac_swb_offset Aac_swb_short_window_48[] =
+{
+ {
+ 14,
+ {
+ 0, 4, 8, 12, 16, 20, 28, 36, 44, 56,
+ 68, 80, 96, 112, 128
+ }
+ }
+};
+
+const Aac_swb_offset Aac_swb_short_window_24[] =
+{
+ {
+ 15,
+ {
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44,
+ 52, 64, 76, 92, 108, 128
+ }
+ }
+};
+
+const Aac_swb_offset Aac_swb_short_window_16[] =
+{
+ {
+ 15,
+ {
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 40,
+ 48, 60, 72, 88, 108, 128
+ }
+ }
+};
+
+const Aac_swb_offset Aac_swb_short_window_8[] =
+{
+ {
+ 15,
+ {
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44,
+ 52, 60, 72, 88, 108, 128
+ }
+ }
+};
+
+const Aac_swb_offset* Aac_swb_offset_short_window[] =
+{
+ Aac_swb_short_window_96, //96000
+ Aac_swb_short_window_96, //88200
+ Aac_swb_short_window_64, //64000
+ Aac_swb_short_window_48, //48000
+ Aac_swb_short_window_48, //44100
+ Aac_swb_short_window_48, //32000
+ Aac_swb_short_window_24, //24000
+ Aac_swb_short_window_24, //22050
+ Aac_swb_short_window_16, //16000
+ Aac_swb_short_window_16, //12000
+ Aac_swb_short_window_16, //11025
+ Aac_swb_short_window_8 //8000
+};
+
+//---------------------------------------------------------------------------
+const Aac_swb_offset Aac_swb_long_window_96[]=
+{
+ {
+ 41,
+ {
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 36,
+ 40, 44, 48, 52, 56, 64, 72, 80, 88, 96,
+ 108, 120, 132, 144, 156, 172, 188, 212, 240, 276,
+ 320, 384, 448, 512, 576, 640, 704, 768, 832, 896,
+ 960, 1024
+ }
+ }
+};
+
+const Aac_swb_offset Aac_swb_long_window_64[]=
+{
+ {
+ 47,
+ {
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 36,
+ 40, 44, 48, 52, 56, 64, 72, 80, 88, 100,
+ 112, 124, 140, 156, 172, 192, 216, 240, 268, 304,
+ 344, 384, 424, 464, 504, 544, 584, 624, 664, 704,
+ 744, 784, 824, 864, 904, 944, 984, 1024
+ }
+ }
+};
+//---------------------------------------------------------------------------
+const Aac_swb_offset Aac_swb_long_window_48[]=
+{
+ {
+ 49,
+ {
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 36,
+ 40, 48, 56, 64, 72, 80, 88, 96, 108, 120,
+ 132, 144, 160, 176, 196, 216, 240, 264, 292, 320,
+ 352, 384, 416, 448, 480, 512, 544, 576, 608, 640,
+ 672, 704, 736, 768, 800, 832, 864, 896, 928, 1024
+ }
+ }
+};
+//---------------------------------------------------------------------------
+const Aac_swb_offset Aac_swb_long_window_32[]=
+{
+ {
+ 51,
+ {
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 36,
+ 40, 48, 56, 64, 72, 80, 88, 96, 108, 120,
+ 132, 144, 160, 176, 196, 216, 240, 264, 292, 320,
+ 352, 384, 416, 448, 480, 512, 544, 576, 608, 640,
+ 672, 704, 736, 768, 800, 832, 864, 896, 928, 960,
+ 992, 1024
+ }
+ }
+};
+//---------------------------------------------------------------------------
+const Aac_swb_offset Aac_swb_long_window_24[]=
+{
+ {
+ 47,
+ {
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 36,
+ 40, 44, 52, 60, 68, 76, 84, 92, 100, 108,
+ 116, 124, 136, 148, 160, 172, 188, 204, 220, 240,
+ 260, 284, 308, 336, 364, 396, 432, 468, 508, 552,
+ 600, 652, 704, 768, 832, 896, 960, 1024
+ }
+ }
+};
+//---------------------------------------------------------------------------
+const Aac_swb_offset Aac_swb_long_window_16[]=
+{
+ {
+ 43,
+ {
+ 0, 8, 16, 24, 32, 40, 48, 56, 64, 72,
+ 80, 88, 100, 112, 124, 136, 148, 160, 172, 184,
+ 196, 212, 228, 244, 260, 280, 300, 320, 344, 368,
+ 396, 424, 456, 492, 532, 572, 616, 664, 716, 772,
+ 832, 896, 960, 1024
+ }
+ }
+};
+//---------------------------------------------------------------------------
+const Aac_swb_offset Aac_swb_long_window_8[]=
+{
+ {
+ 40,
+ {
+ 0, 12, 24, 36, 48, 60, 72, 84, 96, 108,
+ 120, 132, 144, 156, 172, 188, 204, 220, 236, 252,
+ 268, 288, 308, 328, 348, 372, 396, 420, 448, 476,
+ 508, 544, 580, 620, 664, 712, 764, 820, 880, 944,
+ 1024
+ }
+ }
+};
+
+//---------------------------------------------------------------------------
+const Aac_swb_offset* Aac_swb_offset_long_window[]=
+{
+ Aac_swb_long_window_96, //96000
+ Aac_swb_long_window_96, //88200
+ Aac_swb_long_window_64, //64000
+ Aac_swb_long_window_48, //48000
+ Aac_swb_long_window_48, //44100
+ Aac_swb_long_window_32, //32000
+ Aac_swb_long_window_24, //24000
+ Aac_swb_long_window_24, //22050
+ Aac_swb_long_window_16, //16000
+ Aac_swb_long_window_16, //12000
+ Aac_swb_long_window_16, //11025
+ Aac_swb_long_window_8 //8000
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.cpp
new file mode 100644
index 000000000..84ec7dcd0
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.cpp
@@ -0,0 +1,752 @@
+// File_Aac - Info for AAC files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AAC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Aac.h"
+#include "MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.h"
+#include <cmath>
+#include <algorithm>
+#include <cstring>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern const char* Aac_audioObjectType(int8u audioObjectType);
+
+//---------------------------------------------------------------------------
+int8u Aac_AudioSpecificConfig_sampling_frequency_index(const int32u sampling_frequency);
+
+//---------------------------------------------------------------------------
+// Master frequency band table
+// k0 = lower frequency boundary
+int8u Aac_k0_Compute(int8u bs_start_freq, int8u extension_sampling_frequency_index)
+{
+ return Aac_k0_startMin[extension_sampling_frequency_index]+Aac_k0_offset[extension_sampling_frequency_index][bs_start_freq];
+}
+
+//---------------------------------------------------------------------------
+// Master frequency band table
+// k2 = upper frequency boundary
+int8u Aac_k2_Compute(int8u bs_stop_freq, int8u extension_sampling_frequency_index, int8u k0)
+{
+ switch (bs_stop_freq)
+ {
+ case 14 : return (int8u)min(64, 2*k0);
+ case 15 : return (int8u)min(64, 3*k0);
+ default : ;
+ }
+
+ return (int8u)min(64, Aac_k2_stopMin[extension_sampling_frequency_index]+Aac_k2_offset[extension_sampling_frequency_index][bs_stop_freq]);
+}
+
+//---------------------------------------------------------------------------
+//Helper
+int8u Aac_bands_Compute(bool warp, int8u bands, int8u a0, int8u a1)
+{
+ float div=(float)log(2.0);
+ if (warp)
+ div*=(float)1.3;
+
+ return (int8u)(bands*log((float)a1/(float)a0)/div+0.5);
+}
+
+//---------------------------------------------------------------------------
+// Master frequency band table
+// Computing for bs_freq_scale = 0
+bool Aac_f_master_Compute_0(int8u &num_env_bands_Master, int8u* f_Master, sbr_handler *sbr, int8u k0, int8u k2)
+{
+ int8u dk, numBands;
+ if (sbr->bs_alter_scale)
+ {
+ dk=1;
+ numBands=(((k2-k0+2)>>2)<<1);
+ }
+ else
+ {
+ dk=2;
+ numBands=(((k2-k0)>>1)<<1);
+ }
+
+ int8u k2Achieved=k0+numBands*dk;
+ int8s k2Diff=k2-k2Achieved;
+ int8s vDk[64];
+ for (int8u k=0; k<numBands; k++)
+ vDk[k]=dk;
+
+ if (k2Diff)
+ {
+ int8s incr;
+ int8u k;
+ if (k2Diff>0)
+ {
+ incr=-1;
+ k=numBands-1;
+ }
+ else
+ {
+ incr=1;
+ k=0;
+ }
+
+ while (k2Diff)
+ {
+ vDk[k]-=incr;
+ k+=incr;
+ k2Diff+=incr;
+ }
+ }
+
+ f_Master[0]=k0;
+ for (int8u k=1; k<=numBands; k++)
+ f_Master[k]=f_Master[k-1]+vDk[k-1];
+
+ num_env_bands_Master=numBands;
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+// Master frequency band table
+// Computing for bs_freq_scale != 0
+int int8u_cmp(const void *a, const void *b)
+{
+ return ((int8u)(*(int8u*)a - *(int8u*)b));
+}
+bool Aac_f_master_Compute(int8u &num_env_bands_Master, int8u* f_Master, sbr_handler *sbr, int8u k0, int8u k2)
+{
+ int8u temp1[]={6, 5, 4 };
+ int8u bands=temp1[sbr->bs_freq_scale-1];
+
+ int8u twoRegions, k1;
+ if ((float)k2/(float)k0>2.2449)
+ {
+ twoRegions=1;
+ k1=2*k0;
+ }
+ else
+ {
+ twoRegions=0;
+ k1=k2;
+ }
+
+ int8u numBands0=2*Aac_bands_Compute(false, bands, k0, k1);
+ if (numBands0>=64)
+ return false;
+
+ int8u vDk0[64];
+ int8u vk0[64];
+ float Power=pow((float)k1/(float)k0, (float)1/(float)numBands0);
+ float Power2=(float)k0;
+ int8s Temp1=(int8s)(Power2+0.5);
+ for (int8u k=0; k<=numBands0-1; k++)
+ {
+ int8s Temp0=Temp1;
+ Power2*=Power;
+ Temp1=(int8s)(Power2+0.5);
+ vDk0[k]=Temp1-Temp0;
+ }
+ qsort(vDk0, numBands0, sizeof(int8u), int8u_cmp);
+ vk0[0]=k0;
+ for (int8u k=1; k<=numBands0; k++)
+ {
+ if (vDk0[k-1]==0)
+ return false;
+ vk0[k]=vk0[k-1]+vDk0[k-1];
+ }
+
+ if (!twoRegions)
+ {
+ for (int8u k=0; k<=numBands0; k++)
+ f_Master[k]=vk0[k];
+ num_env_bands_Master=numBands0;
+ return true;
+ }
+
+ //With twoRegions
+ int8u numBands1;
+ int8u vDk1[64];
+ int8u vk1[64];
+ numBands1=2*Aac_bands_Compute(true, bands, k1, k2);
+ if (numBands0+numBands1>=64)
+ return false;
+
+ Power=(float)pow((float)k2/(float)k1, (float)1/(float)numBands1);
+ Power2=(float)k1;
+ Temp1=(int8s)(Power2+0.5);
+ for (int8u k=0; k<=numBands1-1; k++)
+ {
+ int8s Temp0=Temp1;
+ Power2*=Power;
+ Temp1=(int8s)(Power2+0.5);
+ vDk1[k]=Temp1-Temp0;
+ }
+
+ if (vDk1[0]<vDk0[numBands0-1])
+ {
+ qsort(vDk1, numBands1+1, sizeof(int8u), int8u_cmp);
+ int8u change=vDk0[numBands0-1]-vDk1[0];
+ vDk1[0]=vDk0[numBands0-1];
+ vDk1[numBands1-1]=vDk1[numBands1-1]-change;
+ }
+
+ qsort(vDk1, numBands1, sizeof(int8u), int8u_cmp);
+ vk1[0]=k1;
+ for (int8u k=1; k<=numBands1; k++)
+ {
+ if (vDk1[k-1]==0)
+ return false;
+ vk1[k]=vk1[k-1]+vDk1[k-1];
+ }
+
+ num_env_bands_Master=numBands0+numBands1;
+ for (int8u k=0; k<=numBands0; k++)
+ f_Master[k]=vk0[k];
+ for (int8u k=numBands0+1; k <=num_env_bands_Master; k++)
+ f_Master[k]=vk1[k-numBands0];
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+// Derived frequency border tables
+bool Aac_bands_Compute(int8u &num_env_bands_Master, int8u* f_Master, sbr_handler *sbr, int8u k2)
+{
+ sbr->num_env_bands[1]=num_env_bands_Master-sbr->bs_xover_band;
+ sbr->num_env_bands[0]=(sbr->num_env_bands[1]>>1)+(sbr->num_env_bands[1]-((sbr->num_env_bands[1]>>1)<<1));
+
+ if (f_Master[sbr->bs_xover_band]>32)
+ return false;
+
+ if (sbr->bs_noise_bands==0)
+ sbr->num_noise_bands=1;
+ else
+ {
+ sbr->num_noise_bands=Aac_bands_Compute(false, sbr->bs_noise_bands, f_Master[sbr->bs_xover_band], k2);
+ if (sbr->num_noise_bands<1 || sbr->num_noise_bands>5)
+ return false;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool Aac_Sbr_Compute(sbr_handler *sbr, int8u extension_sampling_frequency_index)
+{
+ if (extension_sampling_frequency_index>=9)
+ return 0; //Not supported
+ int8u k0=Aac_k0_Compute(sbr->bs_start_freq, extension_sampling_frequency_index);
+ int8u k2=Aac_k2_Compute(sbr->bs_stop_freq, extension_sampling_frequency_index, k0);
+ if (k2<=k0) return false;
+ switch (extension_sampling_frequency_index)
+ {
+ case 0 :
+ case 1 :
+ case 2 :
+ case 3 : if ((k2-k0)>32) return false; break;
+ case 4 : if ((k2-k0)>35) return false; break;
+ case 5 :
+ case 6 :
+ case 7 :
+ case 8 : if ((k2-k0)>48) return false; break;
+ default : ;
+ }
+
+ int8u num_env_bands_Master;
+ int8u f_Master[64];
+ if (sbr->bs_freq_scale==0)
+ {
+ if (!Aac_f_master_Compute_0(num_env_bands_Master, f_Master, sbr, k0, k2))
+ return false;
+ }
+ else
+ {
+ if (!Aac_f_master_Compute(num_env_bands_Master, f_Master, sbr, k0, k2))
+ return false;
+ }
+ if (num_env_bands_Master<=sbr->bs_xover_band)
+ return false;
+ if (!Aac_bands_Compute(num_env_bands_Master, f_Master, sbr, k2))
+ return false;
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+int16u File_Aac::sbr_huff_dec(sbr_huffman Table, const char* Name)
+{
+ int8u bit;
+ int16s index = 0;
+
+ Element_Begin1(Name);
+ while (index>=0)
+ {
+ Get_S1(1, bit, "bit");
+ index=Table[index][bit];
+ }
+ Element_End0();
+
+ return index+64;
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sbr_extension_data(size_t End, int8u id_aac, bool crc_flag)
+{
+ FILLING_BEGIN();
+ if (Infos["Format_Settings_SBR"].empty())
+ {
+ Infos["Format_Profile"]=_T("HE-AAC");
+ Ztring SamplingRate=Infos["SamplingRate"];
+ if (SamplingRate.empty())
+ SamplingRate.From_Number(sampling_frequency);
+ Infos["SamplingRate"].From_Number((extension_sampling_frequency_index==(int8u)-1)?(sampling_frequency*2):extension_sampling_frequency, 10);
+ if (MediaInfoLib::Config.LegacyStreamDisplay_Get())
+ {
+ Infos["Format_Profile"]+=_T(" / LC");
+ Infos["SamplingRate"]+=_T(" / ")+SamplingRate;
+ }
+ Infos["Format_Settings_SBR"]=_T("Yes (Implicit)");
+ Infos["Codec"]=Ztring().From_Local(Aac_audioObjectType(audioObjectType))+_T("-SBR");
+ }
+ FILLING_END();
+
+ Element_Begin1("sbr_extension_data");
+ bool bs_header_flag;
+ if (crc_flag)
+ Skip_S2(10, "bs_sbr_crc_bits");
+ //~ if (sbr_layer != SBR_STEREO_ENHANCE)
+ //~ {
+ Get_SB(bs_header_flag, "bs_header_flag");
+ if (bs_header_flag)
+ {
+ if (extension_sampling_frequency_index==(int8u)-1)
+ {
+ extension_sampling_frequency=sampling_frequency*2;
+ extension_sampling_frequency_index=Aac_AudioSpecificConfig_sampling_frequency_index(extension_sampling_frequency);
+ }
+
+ delete sbr;
+ sbr=new sbr_handler;
+
+ sbr_header();
+
+ if (!Aac_Sbr_Compute(sbr, extension_sampling_frequency_index))
+ {
+ delete sbr; sbr=NULL;
+ }
+ }
+ //~ }
+
+ //Parsing
+ if (sbr) //only if a header is found
+ {
+ sbr->bs_amp_res[0]=sbr->bs_amp_res_FromHeader; //Set up with header data
+ sbr->bs_amp_res[1]=sbr->bs_amp_res_FromHeader; //Set up with header data
+ sbr_data(id_aac);
+ }
+ if (Data_BS_Remain()>End)
+ Skip_BS(Data_BS_Remain()-End, "bs_fill_bits");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sbr_header()
+{
+ Element_Begin1("sbr_header");
+ Get_S1 (1, sbr->bs_amp_res_FromHeader, "bs_amp_res");
+ Get_S1 (4, sbr->bs_start_freq, "bs_start_freq");
+ Get_S1 (4, sbr->bs_stop_freq, "bs_stop_freq");
+ Get_S1 (3, sbr->bs_xover_band, "bs_xover_band");
+ Skip_S1(2, "bs_reserved");
+ bool bs_header_extra_1, bs_header_extra_2;
+ Get_SB (bs_header_extra_1, "bs_header_extra_1");
+ Get_SB (bs_header_extra_2, "bs_header_extra_2");
+ if(bs_header_extra_1)
+ {
+ Get_S1 (2, sbr->bs_freq_scale, "bs_freq_scale");
+ Get_S1 (1, sbr->bs_alter_scale, "bs_alter_scale");
+ Get_S1 (2, sbr->bs_noise_bands, "bs_noise_bands");
+ }
+ else
+ {
+ sbr->bs_freq_scale=2;
+ sbr->bs_alter_scale=1;
+ sbr->bs_noise_bands=2;
+ }
+ if(bs_header_extra_2)
+ {
+ Skip_S1(2, "bs_limiter_bands");
+ Skip_S1(2, "bs_limiter_gains");
+ Skip_SB( "bs_interpol_freq");
+ Skip_SB( "bs_smoothing_mode");
+ }
+
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sbr_data(int8u id_aac)
+{
+ Element_Begin1("sbr_data");
+ switch (id_aac)
+ {
+ case 0 : sbr_single_channel_element(); break; //ID_SCE
+ case 1 : sbr_channel_pair_element(); break; //ID_CPE
+ default : ;
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sbr_single_channel_element()
+{
+ Element_Begin1("sbr_single_channel_element");
+ bool bs_data_extra, bs_add_harmonic_flag, bs_extended_data;
+ int8u bs_extension_size, bs_esc_count, bs_extension_id;
+ Get_SB (bs_data_extra, "bs_data_extra");
+ if (bs_data_extra)
+ {
+ Skip_S1(4, "bs_reserved");
+ }
+ sbr_grid(0);
+ sbr_dtdf(0);
+ sbr_invf(0);
+ sbr_envelope(0, 0);
+ sbr_noise(0, 0);
+ Get_SB (bs_add_harmonic_flag, "bs_add_harmonic_flag[0]");
+ if (bs_add_harmonic_flag)
+ sbr_sinusoidal_coding(0);
+
+ Get_SB (bs_extended_data, "bs_extended_data[0]");
+ if (bs_extended_data) {
+ Get_S1 (4,bs_extension_size, "bs_extension_size");
+ size_t cnt=bs_extension_size;
+ if (cnt==15)
+ {
+ Get_S1 (8, bs_esc_count, "bs_esc_count");
+ cnt+=bs_esc_count;
+ }
+
+ if (Data_BS_Remain()>=8*cnt)
+ {
+ size_t End=Data_BS_Remain()-8*cnt;
+ while (Data_BS_Remain()>End+7)
+ {
+ Get_S1 (2,bs_extension_id, "bs_extension_id");
+ switch (bs_extension_id)
+ {
+ case 2 : ps_data(End); break; //EXTENSION_ID_PS
+ default: ;
+ }
+ }
+ if (End<Data_BS_Remain())
+ Skip_BS(Data_BS_Remain()-End, "bs_fill_bits");
+ }
+ else
+ Skip_BS(Data_BS_Remain(), "(Error)");
+
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sbr_grid(bool ch)
+{
+ Element_Begin1("sbr_grid");
+ int8u bs_frame_class, bs_num_rel_0, bs_num_rel_1, tmp;
+ int ptr_bits;
+ Get_S1(2, bs_frame_class, "bs_frame_class");
+ switch (bs_frame_class)
+ {
+ case 0 : //FIXFIX
+ Get_S1 (2, tmp, "tmp");
+ sbr->bs_num_env[ch]=(int8u)pow(2.0, tmp);
+ if (sbr->bs_num_env[ch]==1)
+ sbr->bs_amp_res[ch]=0;
+ Get_SB ( sbr->bs_freq_res[ch][0], "bs_freq_res[ch][0]");
+ for (int8u env=1; env<sbr->bs_num_env[ch]; env++)
+ sbr->bs_freq_res[ch][env]=sbr->bs_freq_res[ch][0];
+ break;
+ case 1 : //FIXVAR
+ Skip_S1(2, "bs_var_bord_1[ch]");
+ Get_S1 (2, bs_num_rel_1, "bs_num_rel_1[ch]");
+ sbr->bs_num_env[ch]=bs_num_rel_1+1;
+ for (int8u rel=0; rel<sbr->bs_num_env[ch]-1; rel++) {
+ Skip_S1(2, "tmp");
+ }
+ ptr_bits=(int8u)ceil(log((double)sbr->bs_num_env[ch]+1)/log((double)2));
+ Skip_BS(ptr_bits, "bs_pointer[ch]");
+ Element_Begin1("bs_freq_res[ch]");
+ for (int8u env=0; env<sbr->bs_num_env[ch]; env++)
+ Get_SB (sbr->bs_freq_res[ch][sbr->bs_num_env[ch]-1-env], "bs_freq_res[ch][bs_num_env[ch]-1-env]");
+ Element_End0();
+ break;
+ case 2 : //VARFIX
+ Skip_S1(2, "bs_var_bord_0[ch]");
+ Get_S1 (2,bs_num_rel_0, "bs_num_rel_0[ch]");
+ sbr->bs_num_env[ch] = bs_num_rel_0 + 1;
+ for (int8u rel=0; rel<sbr->bs_num_env[ch]-1; rel++)
+ Skip_S1(2, "tmp");
+ ptr_bits=(int8u)ceil(log((double)sbr->bs_num_env[ch]+1)/log((double)2));
+ Skip_BS(ptr_bits, "bs_pointer[ch]");
+ Element_Begin1("bs_freq_res[ch]");
+ for (int8u env = 0; env < sbr->bs_num_env[ch]; env++)
+ Get_SB (sbr->bs_freq_res[ch][env], "bs_freq_res[ch][env]");
+ Element_End0();
+ break;
+ case 3 : //VARVAR
+ Skip_S1(2, "bs_var_bord_0[ch]");
+ Skip_S1(2, "bs_var_bord_1[ch]");
+ Get_S1 (2,bs_num_rel_0, "bs_num_rel_0[ch]");
+ Get_S1 (2,bs_num_rel_1, "bs_num_rel_1[ch]");
+ sbr->bs_num_env[ch] = bs_num_rel_0 + bs_num_rel_1 + 1;
+ for (int8u rel=0; rel<bs_num_rel_0; rel++)
+ Skip_S1(2, "tmp");
+ for (int8u rel=0; rel<bs_num_rel_1; rel++)
+ Skip_S1(2, "tmp");
+ ptr_bits=(int8u)ceil(log((double)(sbr->bs_num_env[ch]+1))/log((double)2));
+ Skip_BS(ptr_bits, "bs_pointer[ch]");
+ Element_Begin1("bs_freq_res[ch]");
+ for (int8u env=0; env<sbr->bs_num_env[ch]; env++)
+ Get_SB (sbr->bs_freq_res[ch][env], "bs_freq_res[ch][env]");
+ Element_End0();
+ break;
+ }
+ if (sbr->bs_num_env[ch]>1)
+ sbr->bs_num_noise[ch]=2;
+ else
+ sbr->bs_num_noise[ch]=1;
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sbr_channel_pair_element()
+{
+ Element_Begin1("sbr_channel_pair_element");
+ bool bs_data_extra,bs_coupling,bs_add_harmonic_flag,bs_extended_data;
+ int8u bs_extension_size,bs_esc_count,bs_extension_id;
+ Get_SB (bs_data_extra, "bs_data_extra");
+ if (bs_data_extra) {
+ Skip_S1(4, "bs_reserved");
+ Skip_S1(4, "bs_reserved");
+ }
+
+ Get_SB (bs_coupling, "bs_coupling");
+ sbr_grid(0);
+ if (bs_coupling)
+ {
+ //Coupling
+ sbr->bs_num_env [1]=sbr->bs_num_env [0];
+ sbr->bs_num_noise [1]=sbr->bs_num_noise [0];
+ for (int8u env=0; env<sbr->bs_num_env[0]; env++)
+ sbr->bs_freq_res[1][env]=sbr->bs_freq_res[0][env];
+ }
+ else
+ sbr_grid(1);
+ sbr_dtdf(0);
+ sbr_dtdf(1);
+ sbr_invf(0);
+ if (!bs_coupling)
+ sbr_invf(1);
+ sbr_envelope(0, bs_coupling);
+ if (bs_coupling)
+ {
+ sbr_noise(0, bs_coupling);
+ sbr_envelope(1, bs_coupling);
+ }
+ else
+ {
+ sbr_envelope(1, bs_coupling);
+ sbr_noise(0, bs_coupling);
+ }
+ sbr_noise(1, bs_coupling);
+ Get_SB (bs_add_harmonic_flag, "bs_add_harmonic_flag[0]");
+ if (bs_add_harmonic_flag)
+ sbr_sinusoidal_coding(0);
+ Get_SB (bs_add_harmonic_flag, "bs_add_harmonic_flag[1]");
+ if (bs_add_harmonic_flag)
+ sbr_sinusoidal_coding(1);
+
+ Get_SB (bs_extended_data, "bs_extended_data");
+ if (bs_extended_data) {
+ Get_S1(4,bs_extension_size, "bs_extension_size");
+ size_t cnt = bs_extension_size;
+ if (cnt == 15)
+ {
+ Get_S1(8,bs_esc_count, "bs_esc_count");
+ cnt += bs_esc_count;
+ }
+ if (Data_BS_Remain()>=8*cnt)
+ {
+ size_t End=Data_BS_Remain()-8*cnt;
+ while (Data_BS_Remain()>End+7)
+ {
+ Get_S1 (2,bs_extension_id, "bs_extension_id");
+ switch (bs_extension_id)
+ {
+ case 2 : ps_data(End); break; //EXTENSION_ID_PS
+ default: ;
+ }
+ }
+ if (End<Data_BS_Remain())
+ Skip_BS(Data_BS_Remain()-End, "bs_fill_bits");
+ }
+ else
+ Skip_BS(Data_BS_Remain(), "(Error)");
+
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sbr_dtdf(bool ch)
+{
+ Element_Begin1("sbr_dtdf");
+ for (int env=0; env<sbr->bs_num_env[ch]; env++)
+ Get_S1 (1, sbr->bs_df_env[ch][env], "bs_df_env[ch][env]");
+ for (int noise=0; noise<sbr->bs_num_noise[ch]; noise++)
+ Get_S1 (1, sbr->bs_df_noise[ch][noise], "bs_df_noise[ch][noise]");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sbr_invf(bool)
+{
+ Element_Begin1("sbr_invf");
+ for (int n = 0; n<sbr->num_noise_bands; n++ )
+ Skip_S1(2, "bs_invf_mode[ch][n]");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sbr_envelope(bool ch, bool bs_coupling)
+{
+ sbr_huffman t_huff, f_huff;
+ Element_Begin1("sbr_envelope");
+ if (bs_coupling && ch)
+ {
+ if (sbr->bs_amp_res[ch])
+ {
+ t_huff = t_huffman_env_bal_3_0dB;
+ f_huff = f_huffman_env_bal_3_0dB;
+ }
+ else
+ {
+ t_huff = t_huffman_env_bal_1_5dB;
+ f_huff = f_huffman_env_bal_1_5dB;
+ }
+ }
+ else
+ {
+ if (sbr->bs_amp_res[ch])
+ {
+ t_huff = t_huffman_env_3_0dB;
+ f_huff = f_huffman_env_3_0dB;
+ }
+ else
+ {
+ t_huff = t_huffman_env_1_5dB;
+ f_huff = f_huffman_env_1_5dB;
+ }
+ }
+
+ for (int8u env=0; env<sbr->bs_num_env[ch]; env++)
+ {
+ if (sbr->bs_df_env[ch][env] == 0)
+ {
+ if (bs_coupling && ch)
+ Skip_S1(sbr->bs_amp_res[ch]?5:6, "bs_env_start_value_balance");
+ else
+ Skip_S1(sbr->bs_amp_res[ch]?6:7, "bs_env_start_value_level");
+ for (int8u band = 1; band < sbr->num_env_bands[sbr->bs_freq_res[ch][env]]; band++)
+ sbr_huff_dec(f_huff, "bs_data_env[ch][env][band]");
+ }
+ else
+ {
+ for (int8u band = 0; band < sbr->num_env_bands[sbr->bs_freq_res[ch][env]]; band++)
+ sbr_huff_dec(t_huff, "bs_data_env[ch][env][band]");
+ }
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sbr_noise(bool ch, bool bs_coupling)
+{
+ sbr_huffman t_huff, f_huff;
+ Element_Begin1("sbr_noise");
+ if (bs_coupling && ch)
+ {
+ t_huff = t_huffman_noise_bal_3_0dB;
+ f_huff = f_huffman_env_bal_3_0dB;
+ }
+ else
+ {
+ t_huff = t_huffman_noise_3_0dB;
+ f_huff = f_huffman_env_3_0dB;
+ }
+
+ for (int noise=0; noise<sbr->bs_num_noise[ch]; noise++)
+ {
+ if (sbr->bs_df_noise[ch][noise] == 0)
+ {
+ Skip_S1(5, (bs_coupling && ch)?"bs_noise_start_value_balance":"bs_noise_start_value_level");
+ for (int8u band=1; band<sbr->num_noise_bands; band++)
+ sbr_huff_dec(f_huff, "bs_data_noise[ch][noise][band]");
+ }
+ else
+ {
+ for (int8u band = 0; band < sbr->num_noise_bands; band++)
+ sbr_huff_dec(t_huff, "bs_data_noise[ch][noise][band]");
+ }
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::sbr_sinusoidal_coding(bool)
+{
+ Element_Begin1("sbr_sinusoidal_coding");
+ for (int8u n=0; n<sbr->num_env_bands[1]; n++)
+ Skip_SB( "bs_add_harmonic[ch][n]");
+ Element_End0();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_AAC_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.h
new file mode 100644
index 000000000..42fc29689
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.h
@@ -0,0 +1,728 @@
+// File_Aac - Info for AAC files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Aac_GeneralAudio_SbrH
+#define MediaInfo_File_Aac_GeneralAudio_SbrH
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+const int8s t_huffman_env_1_5dB[120][2]=
+{
+ { 1, 2 },
+ { -64, -65 },
+ { 3, 4 },
+ { -63, -66 },
+ { 5, 6 },
+ { -62, -67 },
+ { 7, 8 },
+ { -61, -68 },
+ { 9, 10 },
+ { -60, -69 },
+ { 11, 12 },
+ { -59, -70 },
+ { 13, 14 },
+ { -58, -71 },
+ { 15, 16 },
+ { -57, -72 },
+ { 17, 18 },
+ { -73, -56 },
+ { 19, 21 },
+ { -74, 20 },
+ { -55, -75 },
+ { 22, 26 },
+ { 23, 24 },
+ { -54, -76 },
+ { -77, 25 },
+ { -53, -78 },
+ { 27, 34 },
+ { 28, 29 },
+ { -52, -79 },
+ { 30, 31 },
+ { -80, -51 },
+ { 32, 33 },
+ { -83, -82 },
+ { -81, -50 },
+ { 35, 57 },
+ { 36, 40 },
+ { 37, 38 },
+ { -88, -84 },
+ { -48, 39 },
+ { -90, -85 },
+ { 41, 46 },
+ { 42, 43 },
+ { -49, -87 },
+ { 44, 45 },
+ { -89, -86 },
+ {-124, -123 },
+ { 47, 50 },
+ { 48, 49 },
+ {-122, -121 },
+ {-120, -119 },
+ { 51, 54 },
+ { 52, 53 },
+ {-118, -117 },
+ {-116, -115 },
+ { 55, 56 },
+ {-114, -113 },
+ {-112, -111 },
+ { 58, 89 },
+ { 59, 74 },
+ { 60, 67 },
+ { 61, 64 },
+ { 62, 63 },
+ {-110, -109 },
+ {-108, -107 },
+ { 65, 66 },
+ {-106, -105 },
+ {-104, -103 },
+ { 68, 71 },
+ { 69, 70 },
+ {-102, -101 },
+ {-100, -99 },
+ { 72, 73 },
+ { -98, -97 },
+ { -96, -95 },
+ { 75, 82 },
+ { 76, 79 },
+ { 77, 78 },
+ { -94, -93 },
+ { -92, -91 },
+ { 80, 81 },
+ { -47, -46 },
+ { -45, -44 },
+ { 83, 86 },
+ { 84, 85 },
+ { -43, -42 },
+ { -41, -40 },
+ { 87, 88 },
+ { -39, -38 },
+ { -37, -36 },
+ { 90, 105 },
+ { 91, 98 },
+ { 92, 95 },
+ { 93, 94 },
+ { -35, -34 },
+ { -33, -32 },
+ { 96, 97 },
+ { -31, -30 },
+ { -29, -28 },
+ { 99, 102 },
+ { 100, 101 },
+ { -27, -26 },
+ { -25, -24 },
+ { 103, 104 },
+ { -23, -22 },
+ { -21, -20 },
+ { 106, 113 },
+ { 107, 110 },
+ { 108, 109 },
+ { -19, -18 },
+ { -17, -16 },
+ { 111, 112 },
+ { -15, -14 },
+ { -13, -12 },
+ { 114, 117 },
+ { 115, 116 },
+ { -11, -10 },
+ { -9, -8 },
+ { 118, 119 },
+ { -7, -6 },
+ { -5, -4 }
+};
+
+const int8s f_huffman_env_1_5dB[120][2]=
+{
+ { 1, 2 },
+ { -64, -65 },
+ { 3, 4 },
+ { -63, -66 },
+ { 5, 6 },
+ { -67, -62 },
+ { 7, 8 },
+ { -68, -61 },
+ { 9, 10 },
+ { -69, -60 },
+ { 11, 13 },
+ { -70, 12 },
+ { -59, -71 },
+ { 14, 16 },
+ { -58, 15 },
+ { -72, -57 },
+ { 17, 19 },
+ { -73, 18 },
+ { -56, -74 },
+ { 20, 23 },
+ { 21, 22 },
+ { -55, -75 },
+ { -54, -53 },
+ { 24, 27 },
+ { 25, 26 },
+ { -76, -52 },
+ { -77, -51 },
+ { 28, 31 },
+ { 29, 30 },
+ { -50, -78 },
+ { -79, -49 },
+ { 32, 36 },
+ { 33, 34 },
+ { -48, -47 },
+ { -80, 35 },
+ { -81, -82 },
+ { 37, 47 },
+ { 38, 41 },
+ { 39, 40 },
+ { -83, -46 },
+ { -45, -84 },
+ { 42, 44 },
+ { -85, 43 },
+ { -44, -43 },
+ { 45, 46 },
+ { -88, -87 },
+ { -86, -90 },
+ { 48, 66 },
+ { 49, 56 },
+ { 50, 53 },
+ { 51, 52 },
+ { -92, -42 },
+ { -41, -39 },
+ { 54, 55 },
+ {-105, -89 },
+ { -38, -37 },
+ { 57, 60 },
+ { 58, 59 },
+ { -94, -91 },
+ { -40, -36 },
+ { 61, 63 },
+ { -20, 62 },
+ {-115, -110 },
+ { 64, 65 },
+ {-108, -107 },
+ {-101, -97 },
+ { 67, 89 },
+ { 68, 75 },
+ { 69, 72 },
+ { 70, 71 },
+ { -95, -93 },
+ { -34, -27 },
+ { 73, 74 },
+ { -22, -17 },
+ { -16, -124 },
+ { 76, 82 },
+ { 77, 79 },
+ {-123, 78 },
+ {-122, -121 },
+ { 80, 81 },
+ {-120, -119 },
+ {-118, -117 },
+ { 83, 86 },
+ { 84, 85 },
+ {-116, -114 },
+ {-113, -112 },
+ { 87, 88 },
+ {-111, -109 },
+ {-106, -104 },
+ { 90, 105 },
+ { 91, 98 },
+ { 92, 95 },
+ { 93, 94 },
+ {-103, -102 },
+ {-100, -99 },
+ { 96, 97 },
+ { -98, -96 },
+ { -35, -33 },
+ { 99, 102 },
+ { 100, 101 },
+ { -32, -31 },
+ { -30, -29 },
+ { 103, 104 },
+ { -28, -26 },
+ { -25, -24 },
+ { 106, 113 },
+ { 107, 110 },
+ { 108, 109 },
+ { -23, -21 },
+ { -19, -18 },
+ { 111, 112 },
+ { -15, -14 },
+ { -13, -12 },
+ { 114, 117 },
+ { 115, 116 },
+ { -11, -10 },
+ { -9, -8 },
+ { 118, 119 },
+ { -7, -6 },
+ { -5, -4 }
+};
+
+const int8s t_huffman_env_bal_1_5dB[48][2]=
+{
+ { -64, 1 },
+ { -63, 2 },
+ { -65, 3 },
+ { -62, 4 },
+ { -66, 5 },
+ { -61, 6 },
+ { -67, 7 },
+ { -60, 8 },
+ { -68, 9 },
+ { 10, 11 },
+ { -69, -59 },
+ { 12, 13 },
+ { -70, -58 },
+ { 14, 28 },
+ { 15, 21 },
+ { 16, 18 },
+ { -57, 17 },
+ { -71, -56 },
+ { 19, 20 },
+ { -88, -87 },
+ { -86, -85 },
+ { 22, 25 },
+ { 23, 24 },
+ { -84, -83 },
+ { -82, -81 },
+ { 26, 27 },
+ { -80, -79 },
+ { -78, -77 },
+ { 29, 36 },
+ { 30, 33 },
+ { 31, 32 },
+ { -76, -75 },
+ { -74, -73 },
+ { 34, 35 },
+ { -72, -55 },
+ { -54, -53 },
+ { 37, 41 },
+ { 38, 39 },
+ { -52, -51 },
+ { -50, 40 },
+ { -49, -48 },
+ { 42, 45 },
+ { 43, 44 },
+ { -47, -46 },
+ { -45, -44 },
+ { 46, 47 },
+ { -43, -42 },
+ { -41, -40 }
+};
+
+const int8s f_huffman_env_bal_1_5dB[48][2]=
+{
+ { -64, 1 },
+ { -65, 2 },
+ { -63, 3 },
+ { -66, 4 },
+ { -62, 5 },
+ { -61, 6 },
+ { -67, 7 },
+ { -68, 8 },
+ { -60, 9 },
+ { 10, 11 },
+ { -69, -59 },
+ { -70, 12 },
+ { -58, 13 },
+ { 14, 17 },
+ { -71, 15 },
+ { -57, 16 },
+ { -56, -73 },
+ { 18, 32 },
+ { 19, 25 },
+ { 20, 22 },
+ { -72, 21 },
+ { -88, -87 },
+ { 23, 24 },
+ { -86, -85 },
+ { -84, -83 },
+ { 26, 29 },
+ { 27, 28 },
+ { -82, -81 },
+ { -80, -79 },
+ { 30, 31 },
+ { -78, -77 },
+ { -76, -75 },
+ { 33, 40 },
+ { 34, 37 },
+ { 35, 36 },
+ { -74, -55 },
+ { -54, -53 },
+ { 38, 39 },
+ { -52, -51 },
+ { -50, -49 },
+ { 41, 44 },
+ { 42, 43 },
+ { -48, -47 },
+ { -46, -45 },
+ { 45, 46 },
+ { -44, -43 },
+ { -42, 47 },
+ { -41, -40 }
+};
+
+const int8s t_huffman_env_3_0dB[62][2]=
+{
+ { -64, 1 },
+ { -65, 2 },
+ { -63, 3 },
+ { -66, 4 },
+ { -62, 5 },
+ { -67, 6 },
+ { -61, 7 },
+ { -68, 8 },
+ { -60, 9 },
+ { 10, 11 },
+ { -69, -59 },
+ { 12, 14 },
+ { -70, 13 },
+ { -71, -58 },
+ { 15, 18 },
+ { 16, 17 },
+ { -72, -57 },
+ { -73, -74 },
+ { 19, 22 },
+ { -56, 20 },
+ { -55, 21 },
+ { -54, -77 },
+ { 23, 31 },
+ { 24, 25 },
+ { -75, -76 },
+ { 26, 27 },
+ { -78, -53 },
+ { 28, 29 },
+ { -52, -95 },
+ { -94, 30 },
+ { -93, -92 },
+ { 32, 47 },
+ { 33, 40 },
+ { 34, 37 },
+ { 35, 36 },
+ { -91, -90 },
+ { -89, -88 },
+ { 38, 39 },
+ { -87, -86 },
+ { -85, -84 },
+ { 41, 44 },
+ { 42, 43 },
+ { -83, -82 },
+ { -81, -80 },
+ { 45, 46 },
+ { -79, -51 },
+ { -50, -49 },
+ { 48, 55 },
+ { 49, 52 },
+ { 50, 51 },
+ { -48, -47 },
+ { -46, -45 },
+ { 53, 54 },
+ { -44, -43 },
+ { -42, -41 },
+ { 56, 59 },
+ { 57, 58 },
+ { -40, -39 },
+ { -38, -37 },
+ { 60, 61 },
+ { -36, -35 },
+ { -34, -33 }
+};
+
+const int8s f_huffman_env_3_0dB[62][2]=
+{
+ { -64, 1 },
+ { -65, 2 },
+ { -63, 3 },
+ { -66, 4 },
+ { -62, 5 },
+ { -67, 6 },
+ { 7, 8 },
+ { -61, -68 },
+ { 9, 10 },
+ { -60, -69 },
+ { 11, 12 },
+ { -59, -70 },
+ { 13, 14 },
+ { -58, -71 },
+ { 15, 16 },
+ { -57, -72 },
+ { 17, 19 },
+ { -56, 18 },
+ { -55, -73 },
+ { 20, 24 },
+ { 21, 22 },
+ { -74, -54 },
+ { -53, 23 },
+ { -75, -76 },
+ { 25, 30 },
+ { 26, 27 },
+ { -52, -51 },
+ { 28, 29 },
+ { -77, -79 },
+ { -50, -49 },
+ { 31, 39 },
+ { 32, 35 },
+ { 33, 34 },
+ { -78, -46 },
+ { -82, -88 },
+ { 36, 37 },
+ { -83, -48 },
+ { -47, 38 },
+ { -86, -85 },
+ { 40, 47 },
+ { 41, 44 },
+ { 42, 43 },
+ { -80, -44 },
+ { -43, -42 },
+ { 45, 46 },
+ { -39, -87 },
+ { -84, -40 },
+ { 48, 55 },
+ { 49, 52 },
+ { 50, 51 },
+ { -95, -94 },
+ { -93, -92 },
+ { 53, 54 },
+ { -91, -90 },
+ { -89, -81 },
+ { 56, 59 },
+ { 57, 58 },
+ { -45, -41 },
+ { -38, -37 },
+ { 60, 61 },
+ { -36, -35 },
+ { -34, -33 }
+};
+
+const int8s t_huffman_env_bal_3_0dB[24][2]=
+{
+ { -64, 1 },
+ { -63, 2 },
+ { -65, 3 },
+ { -66, 4 },
+ { -62, 5 },
+ { -61, 6 },
+ { -67, 7 },
+ { -68, 8 },
+ { -60, 9 },
+ { 10, 16 },
+ { 11, 13 },
+ { -69, 12 },
+ { -76, -75 },
+ { 14, 15 },
+ { -74, -73 },
+ { -72, -71 },
+ { 17, 20 },
+ { 18, 19 },
+ { -70, -59 },
+ { -58, -57 },
+ { 21, 22 },
+ { -56, -55 },
+ { -54, 23 },
+ { -53, -52 }
+};
+
+const int8s f_huffman_env_bal_3_0dB[24][2]=
+{
+ { -64, 1 },
+ { -65, 2 },
+ { -63, 3 },
+ { -66, 4 },
+ { -62, 5 },
+ { -61, 6 },
+ { -67, 7 },
+ { -68, 8 },
+ { -60, 9 },
+ { 10, 13 },
+ { -69, 11 },
+ { -59, 12 },
+ { -58, -76 },
+ { 14, 17 },
+ { 15, 16 },
+ { -75, -74 },
+ { -73, -72 },
+ { 18, 21 },
+ { 19, 20 },
+ { -71, -70 },
+ { -57, -56 },
+ { 22, 23 },
+ { -55, -54 },
+ { -53, -52 }
+};
+
+const int8s t_huffman_noise_3_0dB[62][2]=
+{
+ { -64, 1 },
+ { -63, 2 },
+ { -65, 3 },
+ { -66, 4 },
+ { -62, 5 },
+ { -67, 6 },
+ { 7, 8 },
+ { -61, -68 },
+ { 9, 30 },
+ { 10, 15 },
+ { -60, 11 },
+ { -69, 12 },
+ { 13, 14 },
+ { -59, -53 },
+ { -95, -94 },
+ { 16, 23 },
+ { 17, 20 },
+ { 18, 19 },
+ { -93, -92 },
+ { -91, -90 },
+ { 21, 22 },
+ { -89, -88 },
+ { -87, -86 },
+ { 24, 27 },
+ { 25, 26 },
+ { -85, -84 },
+ { -83, -82 },
+ { 28, 29 },
+ { -81, -80 },
+ { -79, -78 },
+ { 31, 46 },
+ { 32, 39 },
+ { 33, 36 },
+ { 34, 35 },
+ { -77, -76 },
+ { -75, -74 },
+ { 37, 38 },
+ { -73, -72 },
+ { -71, -70 },
+ { 40, 43 },
+ { 41, 42 },
+ { -58, -57 },
+ { -56, -55 },
+ { 44, 45 },
+ { -54, -52 },
+ { -51, -50 },
+ { 47, 54 },
+ { 48, 51 },
+ { 49, 50 },
+ { -49, -48 },
+ { -47, -46 },
+ { 52, 53 },
+ { -45, -44 },
+ { -43, -42 },
+ { 55, 58 },
+ { 56, 57 },
+ { -41, -40 },
+ { -39, -38 },
+ { 59, 60 },
+ { -37, -36 },
+ { -35, 61 },
+ { -34, -33 }
+};
+
+const int8s t_huffman_noise_bal_3_0dB[24][2]=
+{
+ { -64, 1 },
+ { -65, 2 },
+ { -63, 3 },
+ { 4, 9 },
+ { -66, 5 },
+ { -62, 6 },
+ { 7, 8 },
+ { -76, -75 },
+ { -74, -73 },
+ { 10, 17 },
+ { 11, 14 },
+ { 12, 13 },
+ { -72, -71 },
+ { -70, -69 },
+ { 15, 16 },
+ { -68, -67 },
+ { -61, -60 },
+ { 18, 21 },
+ { 19, 20 },
+ { -59, -58 },
+ { -57, -56 },
+ { 22, 23 },
+ { -55, -54 },
+ { -53, -52 }
+};
+
+//---------------------------------------------------------------------------
+// Master frequency band table
+// k0 = lower frequency boundary
+const int8s Aac_k0_offset_16[16]=
+{
+ -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7,
+};
+const int8s Aac_k0_offset_22[16]=
+{
+ -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13,
+};
+const int8s Aac_k0_offset_24[16]=
+{
+ -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16,
+};
+const int8s Aac_k0_offset_32[16]=
+{
+ -6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16,
+};
+const int8s Aac_k0_offset_64[16]=
+{
+ -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20,
+};
+const int8s Aac_k0_offset_96[16]=
+{
+ -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24,
+};
+const int8s* Aac_k0_offset[9]=
+{
+ Aac_k0_offset_96, //96000
+ Aac_k0_offset_96, //88200
+ Aac_k0_offset_64, //64000
+ Aac_k0_offset_64, //48000
+ Aac_k0_offset_64, //44100
+ Aac_k0_offset_32, //32000
+ Aac_k0_offset_24, //24000
+ Aac_k0_offset_22, //22050
+ Aac_k0_offset_16, //16000
+};
+const int8u Aac_k0_startMin[9]=
+{
+ 7, 7, 10, 11, 12, 16, 16, 17, 24, //32, 35, 48, 0, 0, 0, 0,
+};
+
+//---------------------------------------------------------------------------
+// Master frequency band table
+// k2 = upper frequency boundary
+const int8u Aac_k2_stopMin[9]=
+{
+ 13, 15, 20, 21, 23, 32, 32, 35, 48, //64, 70, 96, 0, 0, 0, 0,
+};
+const int8s Aac_k2_offset[9][14]=
+{
+ { 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 37, 44, 51 },
+ { 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 36, 42, 49 },
+ { 0, 2, 4, 6, 8, 11, 14, 17, 21, 25, 29, 34, 39, 44 },
+ { 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 33, 38, 43 },
+ { 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 32, 36, 41 },
+ { 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 },
+ { 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 },
+ { 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 20, 23, 26, 29 },
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16 },
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr_Ps.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr_Ps.cpp
new file mode 100644
index 000000000..9fec49d92
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr_Ps.cpp
@@ -0,0 +1,110 @@
+// File_Aac - Info for AAC (Raw) files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AAC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Aac.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern const char* Aac_audioObjectType(int8u audioObjectType);
+
+//---------------------------------------------------------------------------
+void File_Aac::ps_data(size_t End)
+{
+ FILLING_BEGIN();
+ if (Infos["Format_Settings_PS"].empty())
+ {
+ Infos["Format_Profile"]=_T("HE-AACv2");
+ Ztring Channels=Infos["Channel(s)"];
+ Ztring ChannelPositions=Infos["ChannelPositions"];
+ Ztring SamplingRate=Infos["SamplingRate"];
+ Infos["Channel(s)"]=_T("2");
+ Infos["ChannelPositions"]=_T("Front: L R");
+ if (MediaInfoLib::Config.LegacyStreamDisplay_Get())
+ {
+ Infos["Format_Profile"]+=_T(" / HE-AAC / LC");
+ Infos["Channel(s)"]+=_T(" / ")+Channels+_T(" / ")+Channels;
+ Infos["ChannelPositions"]+=_T(" / ")+ChannelPositions+_T(" / ")+ChannelPositions;
+ Infos["SamplingRate"]=Ztring().From_Number((extension_sampling_frequency_index==(int8u)-1)?(sampling_frequency*2):extension_sampling_frequency, 10)+_T(" / ")+SamplingRate;
+ }
+ Infos["Format_Settings_PS"]=_T("Yes (Implicit)");
+ Ztring Codec=Retrieve(Stream_Audio, StreamPos_Last, Audio_Codec);
+ Infos["Codec"]=Ztring().From_Local(Aac_audioObjectType(audioObjectType))+_T("-SBR-PS");
+ }
+ FILLING_END();
+
+ //Parsing
+ Element_Begin1("ps_data");
+ bool enable_ps_header;
+ Get_SB(enable_ps_header, "enable_ps_header");
+ if (enable_ps_header)
+ {
+ //Init
+ delete ps; ps=new ps_handler();
+
+ Get_SB(ps->enable_iid, "enable_iid");
+ if (ps->enable_iid)
+ {
+ Get_S1 (3, ps->iid_mode, "iid_mode");
+ }
+ Get_SB(ps->enable_icc, "enable_icc");
+ if (ps->enable_icc)
+ {
+ Get_S1 (3, ps->icc_mode, "icc_mode");
+ }
+ Get_SB(ps->enable_ext, "enable_ext");
+ }
+
+ if (ps==NULL)
+ {
+ if (Data_BS_Remain()>End)
+ Skip_BS(Data_BS_Remain()-End, "(Waiting for header)");
+ Element_End0();
+ return;
+ }
+
+ //PS not yet parsed
+ if (Data_BS_Remain()>End)
+ Skip_BS(Data_BS_Remain()-End, "Data");
+ Element_End0();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_AAC_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr_Ps.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr_Ps.h
new file mode 100644
index 000000000..43f43ba3c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr_Ps.h
@@ -0,0 +1,150 @@
+// File_Aac - Info for AAC (Raw) files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Aac_GeneralAudio_Sbr_PsH
+#define MediaInfo_File_Aac_GeneralAudio_Sbr_PsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Aac.h"
+
+
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+typedef float complex_t[2];
+typedef complex_t qmf_t;
+#define MAX_PS_ENVELOPES 5
+#define NO_ALLPASS_LINKS 3
+
+struct hyb_info
+{
+ int8u frame_len;
+ int8u resolution20[3];
+ int8u resolution34[5];
+
+ qmf_t *work;
+ qmf_t **buffer;
+ qmf_t **temp;
+
+ hyb_info(int8u numTimeSlotsRate);
+ ~hyb_info();
+};
+
+struct ps_info
+{
+ //ps_data
+ bool enable_ps_header;
+ bool enable_iid;
+ bool enable_icc;
+ bool enable_ext;
+ int8u iid_mode;
+ int8u nr_iid_par;
+ int8u nr_ipdopd_par;
+ int8u icc_mode;
+ int8u nr_icc_par;
+ bool frame_class;
+ int8u num_env;
+
+ int8u border_position[MAX_PS_ENVELOPES+1];
+
+ int8u iid_dt[MAX_PS_ENVELOPES];
+ int8u icc_dt[MAX_PS_ENVELOPES];
+
+ int8u enable_ipdopd;
+ int8u ipd_mode;
+ int8u ipd_dt[MAX_PS_ENVELOPES];
+ int8u opd_dt[MAX_PS_ENVELOPES];
+
+ /* indices */
+ int8s iid_index_prev[34];
+ int8s icc_index_prev[34];
+ int8s ipd_index_prev[17];
+ int8s opd_index_prev[17];
+ int8s iid_index[MAX_PS_ENVELOPES][34];
+ int8s icc_index[MAX_PS_ENVELOPES][34];
+ int8s ipd_index[MAX_PS_ENVELOPES][17];
+ int8s opd_index[MAX_PS_ENVELOPES][17];
+
+ int8s ipd_index_1[17];
+ int8s opd_index_1[17];
+ int8s ipd_index_2[17];
+ int8s opd_index_2[17];
+
+ /* ps data was correctly read */
+ int8u ps_data_available;
+
+ /* a header has been read */
+ int8u header_read;
+
+ /* hybrid filterbank parameters */
+ hyb_info *hyb;
+ int8u use34hybrid_bands;
+ int8u numTimeSlotsRate;
+
+ /**/
+ int8u num_groups;
+ int8u num_hybrid_groups;
+ int8u nr_par_bands;
+ int8u nr_allpass_bands;
+ int8u decay_cutoff;
+
+ int8u *group_border;
+ int16u *map_group2bk;
+
+ /* filter delay handling */
+ int8u saved_delay;
+ int8u delay_buf_index_ser[NO_ALLPASS_LINKS];
+ int8u num_sample_delay_ser[NO_ALLPASS_LINKS];
+ int8u delay_D[64];
+ int8u delay_buf_index_delay[64];
+
+ complex_t delay_Qmf[14][64]; /* 14 samples delay max, 64 QMF channels */
+ complex_t delay_SubQmf[2][32]; /* 2 samples delay max (SubQmf is always allpass filtered) */
+ complex_t delay_Qmf_ser[NO_ALLPASS_LINKS][5][64]; /* 5 samples delay max (table 8.34), 64 QMF channels */
+ complex_t delay_SubQmf_ser[NO_ALLPASS_LINKS][5][32]; /* 5 samples delay max (table 8.34) */
+
+ /* transients */
+ float alpha_decay;
+ float alpha_smooth;
+
+ float P_PeakDecayNrg[34];
+ float P_prev[34];
+ float P_SmoothPeakDecayDiffNrg_prev[34];
+
+ /* mixing and phase */
+ complex_t h11_prev[50];
+ complex_t h12_prev[50];
+ complex_t h21_prev[50];
+ complex_t h22_prev[50];
+ int8u phase_hist;
+ complex_t ipd_prev[20][2];
+ complex_t opd_prev[20][2];
+
+ ps_info(int8u sr_index, int8u numTimeSlotsRate);
+ ~ps_info();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_Main.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_Main.cpp
new file mode 100644
index 000000000..3dbb5ad6a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_Main.cpp
@@ -0,0 +1,1124 @@
+// File_Aac - Info for AAC files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AAC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Aac.h"
+#include <cmath>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+extern const int32u Aac_sampling_frequency[]=
+{96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
+ 16000, 12000, 11025, 8000, 7350, 0, 0, 0,};
+
+//---------------------------------------------------------------------------
+const char* Aac_Adts_ID[]=
+{
+ "MPEG-4",
+ "MPEG-2",
+};
+
+//---------------------------------------------------------------------------
+const char* Aac_Format(int8u ID)
+{
+ switch (ID)
+ {
+ case 1 :
+ case 2 :
+ case 3 :
+ case 4 : return "AAC";
+ case 5 : return "SBR";
+ case 6 : return "AAC Scalable";
+ case 7 : return "TwinVQ";
+ case 8 : return "CELP";
+ case 9 : return "HVXC";
+ case 12 : return "TTSI";
+ case 13 : return "Main synthetic";
+ case 14 : return "Wavetable synthesis";
+ case 15 : return "General MIDI";
+ case 16 : return "Algorithmic Synthesis and Audio FX";
+ case 17 :
+ case 19 :
+ case 20 : return "ER AAC";
+ case 21 : return "ER TwinVQ";
+ case 22 : return "ER BSAC";
+ case 23 : return "ER AAC LD";
+ case 24 : return "ER CELP";
+ case 25 : return "ER HVXC";
+ case 26 : return "ER HILN";
+ case 27 : return "ER Parametric";
+ case 28 : return "SSC";
+ case 29 : return "ParametricStereo";
+ case 32 : return "Layer-1";
+ case 33 : return "Layer-2";
+ case 34 : return "Layer-3";
+ case 35 : return "DST";
+ case 36 : return "ALS";
+ case 37 :
+ case 38 : return "SLS";
+ case 39 : return "ER AAC ELD";
+ case 40 : return "SMR Simple";
+ case 41 : return "SMR Main";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Aac_Format_Profile(int8u ID)
+{
+ switch (ID)
+ {
+ case 1 : return "Main";
+ case 2 : return "LC";
+ case 3 : return "SSR";
+ case 4 : return "LTP";
+ case 17 : return "LC";
+ case 19 : return "LTP";
+ case 37 : return "non-core";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Aac_audioObjectType(int8u audioObjectType)
+{
+ switch (audioObjectType)
+ {
+ case 1 : return "AAC Main";
+ case 2 : return "AAC LC";
+ case 3 : return "AAC SSR";
+ case 4 : return "AAC LTP";
+ case 5 : return "SBR";
+ case 6 : return "AAC Scalable";
+ case 7 : return "TwinVQ";
+ case 8 : return "CELP";
+ case 9 : return "HVXC";
+ case 12 : return "TTSI";
+ case 13 : return "Main synthetic";
+ case 14 : return "Wavetable synthesis";
+ case 15 : return "General MIDI";
+ case 16 : return "Algorithmic Synthesis and Audio FX";
+ case 17 : return "ER AAC LC";
+ case 19 : return "ER AAC LTP";
+ case 20 : return "ER AAC Scalable";
+ case 21 : return "ER TwinVQ";
+ case 22 : return "ER BSAC";
+ case 23 : return "ER AAC LD";
+ case 24 : return "ER CELP";
+ case 25 : return "ER HVXC";
+ case 26 : return "ER HILN";
+ case 27 : return "ER Parametric";
+ case 28 : return "SSC";
+ case 29 : return "PS";
+ case 31 : return "(escape)";
+ case 32 : return "Layer-1";
+ case 33 : return "Layer-2";
+ case 34 : return "Layer-3";
+ case 35 : return "DST";
+ case 36 : return "ALS";
+ case 37 : return "SLS";
+ case 38 : return "SLS non-core";
+ case 39 : return "ER AAC ELD";
+ case 40 : return "SMR Simple";
+ case 41 : return "SMR Main";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const int8u Aac_Channels[]=
+{
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 8,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+const char* Aac_ChannelConfiguration[]=
+{
+ "",
+ "Front: C",
+ "Front: L R",
+ "Front: L C R",
+ "Front: L C R, Side: C",
+ "Front: L C R, Side: L R",
+ "Front: L C R, Side: L R, LFE",
+ "Front: L C R, Side: L R, Back: L R, LFE",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Aac_ChannelConfiguration2[]=
+{
+ "",
+ "1/0/0",
+ "2/0/0",
+ "3/0/0",
+ "3/1/0",
+ "3/2/0",
+ "3/2/0.1",
+ "3/2/2.1",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+int8u Aac_AudioSpecificConfig_sampling_frequency_index(const int32u sampling_frequency)
+{
+ if (sampling_frequency>=92017) return 0;
+ if (sampling_frequency>=75132) return 1;
+ if (sampling_frequency>=55426) return 2;
+ if (sampling_frequency>=46009) return 3;
+ if (sampling_frequency>=37566) return 4;
+ if (sampling_frequency>=27713) return 5;
+ if (sampling_frequency>=23004) return 6;
+ if (sampling_frequency>=18783) return 7;
+ if (sampling_frequency>=13856) return 8;
+ if (sampling_frequency>=11502) return 9;
+ if (sampling_frequency>=9391) return 10;
+ return 11;
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::AudioSpecificConfig (size_t End)
+{
+ //Parsing
+ bool sbrData=false, sbrPresentFlag=false, psData=false, psPresentFlag=false;
+ Element_Begin1("AudioSpecificConfig");
+ GetAudioObjectType(audioObjectType, "audioObjectType");
+ Get_S1 (4, sampling_frequency_index, "samplingFrequencyIndex"); Param_Info1(Aac_sampling_frequency[sampling_frequency_index]);
+ if (sampling_frequency_index==0xF)
+ {
+ Get_S3 (24, sampling_frequency, "samplingFrequency");
+ sampling_frequency_index=Aac_AudioSpecificConfig_sampling_frequency_index(sampling_frequency);
+ }
+ else
+ sampling_frequency=Aac_sampling_frequency[sampling_frequency_index];
+ Get_S1 (4, channelConfiguration, "channelConfiguration"); Param_Info1(Aac_ChannelConfiguration[channelConfiguration]);
+ if (audioObjectType==0x05 || audioObjectType==0x29)
+ {
+ extensionAudioObjectType=5;
+ sbrPresentFlag=true;
+ if (audioObjectType==29)
+ psPresentFlag=true;
+ Get_S1 (4, extension_sampling_frequency_index, "extensionSamplingFrequencyIndex"); Param_Info1(Aac_sampling_frequency[extension_sampling_frequency_index]);
+ if (extension_sampling_frequency_index==0xF)
+ {
+ Get_S3 (24, extension_sampling_frequency, "extensionSamplingFrequency");
+ sampling_frequency_index=Aac_AudioSpecificConfig_sampling_frequency_index(extension_sampling_frequency);
+ }
+ else
+ extension_sampling_frequency=Aac_sampling_frequency[extension_sampling_frequency_index];
+ GetAudioObjectType(audioObjectType, "audioObjectType");
+ if (audioObjectType==22) //BSAC
+ Skip_S1(4, "extensionChannelConfiguration");
+ }
+ else
+ extensionAudioObjectType=0x00;
+
+ switch (audioObjectType)
+ {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 6:
+ case 7:
+ case 17:
+ case 19:
+ case 20:
+ case 21:
+ case 22:
+ case 23:
+ GASpecificConfig();
+ break;
+ case 8:
+ CelpSpecificConfig();
+ break;
+ case 9:
+ HvxcSpecificConfig();
+ break;
+ case 12:
+ TTSSpecificConfig();
+ break;
+ //~ case 13:
+ //~ case 14:
+ //~ case 15:
+ //~ case 16:
+ //~ StructuredAudioSpecificConfig();
+ //~ break;
+ case 24:
+ ErrorResilientCelpSpecificConfig();
+ break;
+ case 25:
+ ErrorResilientHvxcSpecificConfig();
+ break;
+ case 26:
+ case 27:
+ ParametricSpecificConfig();
+ break;
+ case 28:
+ SSCSpecificConfig();
+ break;
+ //~ case 30:
+ //~ Skip_S1(1, "sacPayloadEmbedding");
+ //~ SpatialSpecificConfig(); //ISO/IEC 23003-1
+ //~ break;
+ case 32:
+ case 33:
+ case 34:
+ MPEG_1_2_SpecificConfig();
+ break;
+ case 35:
+ DSTSpecificConfig();
+ break;
+ case 36:
+ Skip_S1(5, "fillBits");
+ ALSSpecificConfig();
+ break;
+ case 37:
+ case 38:
+ SLSSpecificConfig();
+ break;
+ case 39:
+ ELDSpecificConfig();
+ break;
+ //~ case 40:
+ //~ case 41:
+ //~ SymbolicMusicSpecificConfig(); //ISO/IEC 14496-23
+ //~ break;
+ default:
+ Element_Begin1("not implemented part");
+ Skip_BS(Data_BS_Remain()-End, "(Not implemented)");
+ Element_End0();
+ if (Mode==File_Aac::Mode_ADIF || Mode==File_Aac::Mode_ADTS)
+ File__Tags_Helper::Finish();
+ else
+ File__Analyze::Finish();
+ Frame_Count=(size_t)-1; //Forcing not to parse following data anymore (if ParseSpeed==1)
+ return;
+ }
+
+ switch (audioObjectType)
+ {
+ case 17:
+ case 19:
+ case 20:
+ case 21:
+ case 22:
+ case 23:
+ case 24:
+ case 25:
+ case 26:
+ case 27:
+ case 39:
+ int8u epConfig;
+ Get_S1(2,epConfig, "epConfig");
+ if ( epConfig == 2 || epConfig == 3 )
+ ErrorProtectionSpecificConfig();
+ if ( epConfig == 3 )
+ {
+ bool directMapping;
+ Get_SB(directMapping, "directMapping");
+ if ( ! directMapping )
+ {
+ Element_Begin1("not implemented part");
+ Skip_BS(Data_BS_Remain()-End, "(Not implemented)");
+ Element_End0();
+ if (Mode==File_Aac::Mode_ADIF || Mode==File_Aac::Mode_ADTS)
+ File__Tags_Helper::Finish();
+ else
+ File__Analyze::Finish();
+ Frame_Count=(size_t)-1; //Forcing not to parse following data anymore (if ParseSpeed==1)
+ return;
+ }
+ }
+ default : ;
+ }
+
+ if (extensionAudioObjectType!=5 && End!=(size_t)-1 && Data_BS_Remain()>=End+16)
+ {
+ int16u syncExtensionType;
+ Get_S2(11,syncExtensionType, "syncExtensionType");
+ if (syncExtensionType == 0x2b7)
+ {
+ sbrData=true;
+ GetAudioObjectType(extensionAudioObjectType, "extensionAudioObjectType");
+ if (extensionAudioObjectType==5 )
+ {
+ Get_SB(sbrPresentFlag, "sbrPresentFlag");
+ if (sbrPresentFlag)
+ {
+ Get_S1 (4, extension_sampling_frequency_index, "extensionSamplingFrequencyIndex"); Param_Info1(Aac_sampling_frequency[extension_sampling_frequency_index]);
+ if (extension_sampling_frequency_index==0xF)
+ {
+ Get_S3 (24, extension_sampling_frequency, "extensionSamplingFrequency");
+ extension_sampling_frequency_index=Aac_AudioSpecificConfig_sampling_frequency_index(extension_sampling_frequency);
+ }
+ else
+ extension_sampling_frequency=Aac_sampling_frequency[extension_sampling_frequency_index];
+ if (End!=(size_t)-1 && Data_BS_Remain()>=End+12)
+ {
+ int16u syncExtensionType;
+ Get_S2(11,syncExtensionType, "syncExtensionType");
+ if (syncExtensionType == 0x548)
+ {
+ psData=true;
+ Get_SB (psPresentFlag, "psPresentFlag");
+ }
+ }
+ }
+ }
+ if ( extensionAudioObjectType == 22 )
+ {
+ Get_SB(sbrPresentFlag, "sbrPresentFlag");
+ if (sbrPresentFlag)
+ {
+ Get_S1 (4, extension_sampling_frequency_index, "extensionSamplingFrequencyIndex"); Param_Info1(Aac_sampling_frequency[extension_sampling_frequency_index]);
+ if (extension_sampling_frequency_index==0xF)
+ {
+ Get_S3 (24, extension_sampling_frequency, "extensionSamplingFrequency");
+ extension_sampling_frequency_index=Aac_AudioSpecificConfig_sampling_frequency_index(extension_sampling_frequency);
+ }
+ else
+ extension_sampling_frequency=Aac_sampling_frequency[extension_sampling_frequency_index];
+ }
+ Skip_S1(4, "extensionChannelConfiguration");
+ }
+ }
+ }
+ Element_End0();
+ if (Data_BS_Remain()>End)
+ {
+ int8u LastByte=0xFF;
+ if (Data_BS_Remain()-End<8)
+ Peek_S1((int8u)(Data_BS_Remain()-End), LastByte);
+ Skip_BS(Data_BS_Remain()-End, LastByte?"Unknown":"Padding");
+ }
+
+ FILLING_BEGIN()
+ AudioSpecificConfig_OutOfBand (sampling_frequency, audioObjectType, sbrData, psData, sbrPresentFlag, psPresentFlag);
+
+ //Parsing the rest
+ if (audioObjectType!=2) //We continue only if AAC LC (in order to detect SBR and PS)
+ {
+ File__Analyze::Finish();
+ Frame_Count=(size_t)-1; //Forcing not to parse following data anymore (if ParseSpeed==1)
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::AudioSpecificConfig_OutOfBand (int32u sampling_frequency_, int8u audioObjectType_, bool sbrData, bool psData, bool sbrPresentFlag, bool psPresentFlag)
+{
+ if (sampling_frequency==(int32u)-1 && sampling_frequency_) //Only if not yet set
+ {
+ sampling_frequency=sampling_frequency_;
+ sampling_frequency_index=Aac_AudioSpecificConfig_sampling_frequency_index(sampling_frequency);
+ }
+
+ if (audioObjectType_==(int8u)-1)
+ {
+ if (audioObjectType==(int8u)-1)
+ return; //All data is not yet available
+ if (Infos.find("Format_Settings_SBR")!=Infos.end())
+ {
+ sbrData=true;
+ sbrPresentFlag=Infos["Format_Settings_SBR"].find(_T("Yes"))!=string::npos;
+ }
+ else
+ {
+ sbrData=false;
+ sbrPresentFlag=false;
+ }
+ if (Infos.find("Format_Settings_PS")!=Infos.end())
+ {
+ psData=true;
+ psPresentFlag=Infos["Format_Settings_PS"].find(_T("Yes"))!=string::npos;
+ }
+ else
+ {
+ psData=false;
+ psPresentFlag=false;
+ }
+ }
+ else
+ audioObjectType=audioObjectType_;
+
+ Infos["SamplingRate"].From_Number(sampling_frequency);
+ Infos["Format"].From_Local(Aac_Format(audioObjectType));
+ Infos["Format_Profile"].From_Local(Aac_Format_Profile(audioObjectType));
+ Infos["Codec"].From_Local(Aac_audioObjectType(audioObjectType));
+ if (channelConfiguration && channelConfiguration<8)
+ {
+ Infos["Channel(s)"].From_Number(Aac_Channels[channelConfiguration]);
+ Infos["ChannelPositions"].From_Local(Aac_ChannelConfiguration[channelConfiguration]);
+ Infos["ChannelPositions/String2"].From_Local(Aac_ChannelConfiguration2[channelConfiguration]);
+ }
+
+ if (sbrPresentFlag)
+ {
+ Infos["Format_Profile"]=_T("HE-AAC");
+ Ztring SamplingRate=Infos["SamplingRate"];
+ Infos["SamplingRate"].From_Number((extension_sampling_frequency_index==(int8u)-1)?(sampling_frequency*2):extension_sampling_frequency, 10);
+ if (MediaInfoLib::Config.LegacyStreamDisplay_Get())
+ {
+ Infos["Format_Profile"]+=_T(" / LC");
+ Infos["SamplingRate"]+=_T(" / ")+SamplingRate;
+ }
+ Infos["Format_Settings_SBR"]=_T("Yes (Implicit)");
+ Infos["Codec"]=Ztring().From_Local(Aac_audioObjectType(audioObjectType))+_T("-SBR");
+ }
+ else if (sbrData)
+ Infos["Format_Settings_SBR"]=_T("No (Explicit)");
+
+ if (psPresentFlag)
+ {
+ Infos["Format_Profile"]=_T("HE-AACv2");
+ Ztring Channels=Infos["Channel(s)"];
+ Ztring ChannelPositions=Infos["ChannelPositions"];
+ Ztring SamplingRate=Infos["SamplingRate"];
+ Infos["Channel(s)"]=_T("2");
+ Infos["ChannelPositions"]=_T("Front: L R");
+ if (MediaInfoLib::Config.LegacyStreamDisplay_Get())
+ {
+ Infos["Format_Profile"]+=_T(" / HE-AAC / LC");
+ Infos["Channel(s)"]+=_T(" / ")+Channels+_T(" / ")+Channels;
+ Infos["ChannelPositions"]+=_T(" / ")+ChannelPositions+_T(" / ")+ChannelPositions;
+ Infos["SamplingRate"]=Ztring().From_Number((extension_sampling_frequency_index==(int8u)-1)?(sampling_frequency*2):extension_sampling_frequency, 10)+_T(" / ")+SamplingRate;
+ }
+ Infos["Format_Settings_PS"]=_T("Yes (Implicit)");
+ if (StreamPos_Last!=(size_t)-1)
+ {
+ Ztring Codec=Retrieve(Stream_Audio, StreamPos_Last, Audio_Codec);
+ Infos["Codec"]=Ztring().From_Local(Aac_audioObjectType(audioObjectType))+_T("-SBR-PS");
+ }
+ }
+ else if (psData)
+ Infos["Format_Settings_PS"]=_T("No (Explicit)");
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::GetAudioObjectType(int8u &ObjectType, const char* Name)
+{
+ Element_Begin1(Name);
+ Get_S1(5, ObjectType, "audioObjectType");
+ if (ObjectType==31)
+ {
+ Get_S1(6, ObjectType, "audioObjectTypeExt");
+ ObjectType+=32;
+ }
+ Element_Info1(ObjectType); Element_Info1(Aac_Format_Profile(ObjectType));
+ Element_End0();
+}
+
+//***************************************************************************
+// Elements - Multiplex layer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::AudioMuxElement()
+{
+ Element_Begin1("AudioMuxElement");
+ if (muxConfigPresent)
+ {
+ bool useSameStreamMux;
+ Get_SB (useSameStreamMux, "useSameStreamMux");
+ if (!useSameStreamMux)
+ StreamMuxConfig();
+ }
+ if (sampling_frequency_index==(int8u)-1) //No previous config
+ {
+ Skip_BS(Data_BS_Remain(), "(Waiting for configuration)");
+ return;
+ }
+ if (audioMuxVersionA==0)
+ {
+ for (int8u i=0; i<=numSubFrames; i++)
+ {
+ PayloadLengthInfo();
+ PayloadMux();
+ }
+ if (otherDataPresent)
+ {
+ for(int32u i=0; i<otherDataLenBits; i++)
+ Skip_SB( "otherDataBit");
+ }
+ }
+ else
+ {
+ Element_Begin1("(not implemented)");
+ Skip_BS(Data_BS_Remain(), "(not implemented)");
+ Element_End0();
+ }
+ if (Data_BS_Remain()%8)
+ Skip_S1(Data_BS_Remain()%8, "byte_alignment");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::StreamMuxConfig()
+{
+ Element_Begin1("StreamMuxConfig");
+
+ bool useSameConfig,audioMuxVersion;
+ Get_SB (audioMuxVersion, "audioMuxVersion");
+ if (audioMuxVersion)
+ Get_SB (audioMuxVersionA, "audioMuxVersionA");
+ else
+ audioMuxVersionA=false;
+
+ if (!audioMuxVersionA)
+ {
+ if (audioMuxVersion==1)
+ {
+ Element_Begin1("(not implemented)");
+ Skip_BS(Data_BS_Remain(), "(not implemented)");
+ Element_End0();
+ //taraBufferFullness=LatmGetValue();
+ }
+
+ int8u streamCnt = 0;
+
+ Get_SB (allStreamsSameTimeFraming, "allStreamsSameTimeFraming");
+ Get_S1 (6, numSubFrames, "numSubFrames");
+ Get_S1 (4, numProgram, "numProgram");
+
+ for (int8u prog=0; prog<=numProgram; prog++)
+ {
+ Get_S1(3,numLayer, "numLayer");
+ for (int8u lay=0; lay<=numLayer; lay++)
+ {
+ progSIndx[streamCnt]=prog;
+ laySIndx[streamCnt]=lay;
+ streamID[prog][lay]=streamCnt++;
+ if (prog==0 && lay==0)
+ useSameConfig=0;
+ else
+ Get_SB(useSameConfig, "useSameConfig");
+
+ if (!useSameConfig)
+ {
+ if (audioMuxVersion==0)
+ AudioSpecificConfig();
+ else
+ {
+ int ascLen=LatmGetValue();
+ AudioSpecificConfig(Data_BS_Remain()-ascLen);
+ }
+ }
+
+ Get_S1(3,frameLengthType[streamID[prog][lay]], "frameLengthType[streamID[prog][lay]]");
+ switch(frameLengthType[streamID[prog][lay]])
+ {
+ case 0 :
+ Skip_S1(8, "latmBufferFullness[streamID[prog][lay]]");
+ if(!allStreamsSameTimeFraming)
+ {
+ Element_Begin1("(not implemented)");
+ Skip_BS(Data_BS_Remain(), "(not implemented)");
+ Element_End0();
+ }
+ //~ if ((!allStreamsSameTimeFraming) &&
+ //~ (AudioObjectType[lay] == 6 || AudioObjectType[lay] == 20) &&
+ //~ (AudioObjectType[lay-1] == 8 || AudioObjectType[lay-1] == 24))
+ //~ {
+ //~ Skip_S1(6, "coreFrameOffset");
+ //~ }
+ break;
+ case 1 :
+ Get_S2(9,frameLength[streamID[prog][lay]],"frameLength[streamID[prog][lay]]");
+ break;
+ case 3 :
+ case 4 :
+ case 5 :
+ Skip_S1(6, "CELPframeLengthTableIndex[streamID[prog][lay]]");
+ break;
+ case 6 :
+ case 7 :
+ Skip_S1(1, "HVXCframeLengthTableIndex[streamID[prog][lay]]");
+ break;
+ default :
+ Element_Begin1("(not implemented)");
+ Skip_BS(Data_BS_Remain(), "(not implemented)");
+ Element_End0();
+ }
+ }
+ }
+ bool otherDataLenEsc, crcCheckPresent;
+ Get_SB (otherDataPresent, "otherDataPresent");
+ if (otherDataPresent)
+ {
+ if (audioMuxVersion==1)
+ otherDataLenBits=LatmGetValue();
+ else
+ {
+ otherDataLenBits=0;
+ do
+ {
+ int8u otherDataLenTmp;
+ otherDataLenBits<<=8;
+ Get_SB( otherDataLenEsc, "otherDataLenEsc");
+ Get_S1(8, otherDataLenTmp, "otherDataLenTmp");
+ otherDataLenBits+=otherDataLenTmp;
+ }
+ while (otherDataLenEsc);
+ }
+ }
+ Get_SB(crcCheckPresent, "crcCheckPresent");
+ if(crcCheckPresent)
+ Skip_S1(8, "crcCheckSum");
+ }
+ else
+ {
+ Element_Begin1("(not implemented)");
+ Skip_BS(Data_BS_Remain(), "(not implemented)");
+ Element_End0();
+ }
+ Element_End0();
+
+ FILLING_BEGIN();
+ CanFill=true;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+int32u File_Aac::LatmGetValue()
+{
+ Element_Begin1("LatmGetValue");
+ int8u valueTmp, bytesForValue;
+ Get_S1(2, bytesForValue, "bytesForValue");
+ int32u value=0;
+ for (int8u i=0; i<=bytesForValue; i++)
+ {
+ value<<=8;
+ Get_S1(8, valueTmp, "valueTmp");
+ value+=valueTmp;
+ }
+ Element_End0();
+ return value;
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::PayloadLengthInfo()
+{
+ Element_Begin1("PayloadLengthInfo");
+ int8u tmp;
+ if (allStreamsSameTimeFraming)
+ {
+ for (int8u prog=0; prog<=numProgram; prog++)
+ {
+ for (int8u lay=0; lay<=numLayer; lay++)
+ {
+ if (frameLengthType[streamID[prog][lay]]==0)
+ {
+ MuxSlotLengthBytes[streamID[prog][lay]]=0;
+ do
+ {
+ Get_S1(8, tmp, "tmp");
+ MuxSlotLengthBytes[streamID[prog][lay]]+=tmp;
+ }
+ while(tmp==255);
+ }
+ else if (frameLengthType[streamID[prog][lay]]==3
+ || frameLengthType[streamID[prog][lay]]==5
+ || frameLengthType[streamID[prog][lay]]==7)
+ {
+ Skip_S1(2, "MuxSlotLengthCoded[streamID[prog][lay]]");
+ }
+ }
+ }
+ }
+ else
+ {
+ int8u streamIndx;
+ int8u prog, lay;
+ Get_S1(4, numChunk, "numChunk");
+ for (int chunkCnt=0; chunkCnt<=numChunk; chunkCnt++)
+ {
+ Get_S1(4,streamIndx, "streamIndx");
+ prog=progCIndx[chunkCnt]=progSIndx[streamIndx];
+ lay=layCIndx[chunkCnt]=laySIndx[streamIndx];
+ if (frameLengthType[streamID[prog][lay]]==0)
+ {
+ MuxSlotLengthBytes[streamID[prog][lay]]=0;
+ do
+ {
+ Get_S1(8, tmp, "tmp");
+ MuxSlotLengthBytes[streamID[prog][lay]]+=tmp;
+ }
+ while(tmp==255);
+ Skip_SB( "AuEndFlag[streamID[prog][lay]]");
+ }
+ else if (frameLengthType[streamID[prog][lay]]==3
+ || frameLengthType[streamID[prog][lay]]==5
+ || frameLengthType[streamID[prog][lay]]==7)
+ {
+ Skip_S1(2, "MuxSlotLengthCoded[streamID[prog][lay]]");
+ }
+ }
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::PayloadMux()
+{
+ Element_Begin1("PayloadMux");
+ if (allStreamsSameTimeFraming)
+ {
+ for (int8u prog=0; prog<=numProgram; prog++)
+ for (int8u lay=0; lay<=numLayer; lay++)
+ {
+ switch(frameLengthType[streamID[prog][lay]])
+ {
+ case 0 :
+ raw_data_block(); //Skip_BS(8*MuxSlotLengthBytes[streamID[prog][lay]],"payload[streamID[prog][lay]]");
+ break;
+ case 1 :
+ Skip_BS(8 * (frameLength[streamID[prog][lay]] + 20),"payload[streamID[prog][lay]]");
+ break;
+ default:
+ Element_Begin1("(not implemented)");
+ Skip_BS(Data_BS_Remain(), "(not implemented)");
+ Element_End0();
+ }
+ }
+ }
+ else
+ {
+ for (int8u chunkCnt=0; chunkCnt<=numChunk; chunkCnt++)
+ {
+ int8u prog=progCIndx[chunkCnt];
+ int8u lay=layCIndx[chunkCnt];
+ switch(frameLengthType[streamID[prog][lay]])
+ {
+ case 0 :
+ raw_data_block(); //Skip_BS(MuxSlotLengthBytes[streamID[prog][lay]], "payload[streamID[prog][lay]]");
+ break;
+ case 1 :
+ Skip_BS(8*(frameLength[streamID[prog][lay]]+20), "payload[streamID[prog][lay]]");
+ break;
+ default:
+ Element_Begin1("not implemented");
+ Element_End0();
+ }
+ }
+ }
+ Element_End0();
+}
+
+//***************************************************************************
+// Elements - Error protection
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::ErrorProtectionSpecificConfig()
+{
+ Element_Begin1("ErrorProtectionSpecificConfig");
+ int8u number_of_predefined_set,number_of_concatenated_frame,interleave_type;
+ Get_S1(8,number_of_predefined_set, "number_of_predefined_set");
+ Get_S1(2,interleave_type, "interleave_type");
+ Skip_S1(3, "bit_stuffing");
+ Get_S1(3,number_of_concatenated_frame, "number_of_concatenated_frame");
+ for (int8u i = 0; i < number_of_predefined_set; i++ )
+ {
+ int8u number_of_class;
+ Get_S1(6,number_of_class, "number_of_class[i]");
+ for (int8u j = 0; j < number_of_class; j++)
+ {
+ bool length_escape,fec_type,rate_escape,crclen_escape;
+ Get_SB(length_escape, "length_escape[i][j]");
+ Get_SB(rate_escape, "rate_escape[i][j]");
+ Get_SB(crclen_escape, "crclen_escape[i][j]");
+ if (number_of_concatenated_frame != 1)
+ Skip_SB( "concatenate_flag[i][j]");
+ Get_SB(fec_type, "fec_type[i][j]");
+ if(!fec_type)
+ Skip_SB( "termination_switch[i][j]");
+ if (interleave_type == 2)
+ Skip_S1(2, "interleave_switch[i][j]");
+ Skip_SB( "class_optional");
+ if (length_escape)
+ {
+ /* ESC */
+ Skip_S1(4, "number_of_bits_for_length[i][j]");
+ }
+ else
+ {
+ Skip_S2(16, "class_length[i][j]");
+ }
+ if (!rate_escape)
+ { /* not ESC */
+ if(fec_type)
+ {
+ Skip_S1(7, "class_rate[i][j]");
+ }
+ else
+ {
+ Skip_S1(5, "class_rate[i][j]");
+ }
+ }
+ if (!crclen_escape)
+ {
+ /* not ESC */
+ Skip_S1(5, "class_crclen[i][j]");
+ }
+ }
+ bool class_reordered_output;
+ Get_SB(class_reordered_output, "class_reordered_output");
+ if ( class_reordered_output )
+ {
+ for (int j = 0; j < number_of_class; j++ )
+ {
+ Skip_S1(6, "class_output_order[i][j]");
+ }
+ }
+ }
+ bool header_protection;
+ Get_SB(header_protection, "header_protection");
+ if (header_protection)
+ {
+ Skip_S1(5, "header_rate");
+ Skip_S1(5, "header_crclen");
+ }
+ Element_End0();
+}
+
+//***************************************************************************
+// Elements - MPEG-2 AAC Audio_Data_Interchange_Format, ADIF
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::adif_header()
+{
+ //Parsing
+ int32u bitrate;
+ int8u num_program_config_elements;
+ bool bitstream_type;
+ Skip_C4( "adif_id");
+ BS_Begin();
+ TEST_SB_SKIP( "copyright_id_present");
+ Skip_S4(32, "copyright_id");
+ Skip_S4(32, "copyright_id");
+ Skip_S4( 8, "copyright_id");
+ TEST_SB_END();
+ Skip_SB( "original_copy");
+ Skip_SB( "home");
+ Get_SB ( bitstream_type, "bitstream_type"); Param_Info1(bitstream_type?"VBR":"CBR");
+ Get_S3 (23, bitrate, "bitrate");
+ Get_S1 ( 4, num_program_config_elements, "num_program_config_elements");
+ if (!bitstream_type)
+ Skip_S3(20, "adif_buffer_fullness");
+ for (int8u Pos=0; Pos<num_program_config_elements+1; Pos++)
+ program_config_element();
+ BS_End();
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_Format, "ADIF", Unlimited, true, true);
+ Fill(Stream_General, 0, General_HeaderSize, Element_Size);
+ Fill(Stream_General, 0, General_OverallBitRate_Mode, bitstream_type?"VBR":"CBR");
+
+ for (size_t StreamPos=0; StreamPos<Count_Get(Stream_Audio); StreamPos++)
+ Fill(Stream_Audio, StreamPos, Audio_MuxingMode, "ADIF");
+ if (num_program_config_elements==0) //Easy to fill only if 1 audio stream
+ {
+ Infos["BitRate_Mode"].From_Local(bitstream_type?"VBR":"CBR");
+ if (bitrate>0)
+ Infos[bitstream_type?"BitRate_Maximum":"BitRate"].From_Number(bitrate);
+ }
+
+ //No more need data
+ File__Tags_Helper::Finish("ADIF");
+ FILLING_END();
+}
+
+//***************************************************************************
+// Elements - Audio_Data_Transport_Stream frame, ADTS
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::adts_frame()
+{
+ //Parsing
+ adts_fixed_header();
+ adts_variable_header();
+ if (num_raw_data_blocks==0)
+ {
+ if (!protection_absent)
+ {
+ Element_Begin1("adts_error_check");
+ Skip_S2(16, "crc_check");
+ Element_End0();
+ }
+ raw_data_block();
+ }
+ else
+ {
+ Element_Begin1("adts_header_error_check");
+ if (!protection_absent)
+ for (int i=1; i<=num_raw_data_blocks; i++)
+ Skip_S2(16, "raw_data_block_position(i)");
+ Skip_S2(16, "crc_check");
+ Element_End0();
+
+ for(int i=0; i<=num_raw_data_blocks; i++)
+ {
+ raw_data_block();
+ if (!protection_absent)
+ {
+ Element_Begin1("adts_raw_data_block_error_check");
+ Skip_BS(16, "crc_check");
+ Element_End0();
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::adts_fixed_header()
+{
+ //Parsing
+ bool id;
+ Element_Begin1("adts_fixed_header");
+ Skip_BS(12, "syncword");
+ Get_SB ( id, "id"); Param_Info1(Aac_Adts_ID[id]);
+ Skip_BS( 2, "layer");
+ Get_SB ( protection_absent, "protection_absent");
+ Get_S1 ( 2, audioObjectType, "profile_ObjectType"); audioObjectType++; Param_Info1(Aac_audioObjectType(audioObjectType));
+ Get_S1 ( 4, sampling_frequency_index, "sampling_frequency_index"); Param_Info2(Aac_sampling_frequency[sampling_frequency_index], " Hz");
+ sampling_frequency=Aac_sampling_frequency[sampling_frequency_index];
+ Skip_SB( "private");
+ Get_S1 ( 3, channelConfiguration, "channel_configuration");
+ Skip_SB( "original");
+ Skip_SB( "home");
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (Infos["Format"].empty())
+ {
+ Infos_General["Format"].From_Local("ADTS");
+
+ Infos["Format"].From_Local("AAC");
+ Infos["Format_Version"].From_Local(id?"Version 2":"Version 4");
+ Infos["Format_Profile"].From_Local(Aac_Format_Profile(audioObjectType));
+ Infos["Codec"].From_Local(Aac_audioObjectType(audioObjectType));
+ Infos["SamplingRate"].From_Number(Aac_sampling_frequency[sampling_frequency_index]);
+ Infos["Channel(s)"].From_Number(channelConfiguration);
+ Infos["ChannelPositions"].From_Local(Aac_ChannelConfiguration[channelConfiguration]);
+ Infos["ChannelPositions/String2"].From_Local(Aac_ChannelConfiguration2[channelConfiguration]);
+ if (IsSub)
+ Infos["MuxingMode"].From_Local("ADTS");
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::adts_variable_header()
+{
+ //Parsing
+ int16u aac_frame_length, adts_buffer_fullness;
+ Element_Begin1("adts_variable_header");
+ Skip_SB( "copyright_id");
+ Skip_SB( "copyright_id_start");
+ Get_S2 (13, aac_frame_length, "aac_frame_length");
+ Get_S2 (11, adts_buffer_fullness, "adts_buffer_fullness"); Param_Info1(adts_buffer_fullness==0x7FF?"VBR":"CBR");
+ Get_S1 ( 2, num_raw_data_blocks, "num_raw_data_blocks");
+ Element_End0();
+
+ FILLING_BEGIN();
+ aac_frame_lengths.push_back(aac_frame_length);
+
+ if (adts_buffer_fullness==0x7FF)
+ Infos["BitRate_Mode"].From_Local("VBR");
+ else
+ {
+ //Calculating
+ int64u aac_frame_length_Total=0;
+ for (size_t Pos=0; Pos<aac_frame_lengths.size(); Pos++)
+ aac_frame_length_Total+=aac_frame_lengths[Pos];
+
+ int64u BitRate=(Aac_sampling_frequency[sampling_frequency_index]/1024);
+ BitRate*=aac_frame_length_Total*8;
+ BitRate/=aac_frame_lengths.size();
+
+ //Filling
+ Infos["BitRate_Mode"].From_Local("CBR");
+ Infos["BitRate"].From_Number(BitRate);
+ }
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_AAC_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_Others.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_Others.cpp
new file mode 100644
index 000000000..da3100df4
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aac_Others.cpp
@@ -0,0 +1,472 @@
+// File_aac - Info for AAC files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AAC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Aac.h"
+#if defined(MEDIAINFO_RIFF_YES)
+ #include "MediaInfo/Multiple/File_Riff.h"
+#endif
+#include <cmath>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Speech coding (HVXC)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::HvxcSpecificConfig()
+{
+ Element_Begin1("HvxcSpecificConfig");
+ bool isBaseLayer;
+ Get_SB(isBaseLayer, "isBaseLayer");
+ if (isBaseLayer)
+ HVXCconfig();
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::HVXCconfig()
+{
+ Element_Begin1("HVXCconfig");
+ Skip_SB( "HVXCvarMode");
+ Skip_S1(2, "HVXCrateMode");
+ Skip_SB( "extensionFlag");
+ //~ if (extensionFlag) {
+ /*< to be defined in MPEG-4 Version 2 >*/
+ //~ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::ErrorResilientHvxcSpecificConfig() {
+ Element_Begin1("ErrorResilientHvxcSpecificConfig");
+ bool isBaseLayer;
+ Get_SB(isBaseLayer,"isBaseLayer");
+ if (isBaseLayer) {
+ ErHVXCconfig();
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::ErHVXCconfig()
+{
+ Element_Begin1("ErHVXCconfig");
+ bool extensionFlag;
+ Skip_SB( "HVXCvarMode");
+ Skip_S1(2, "HVXCrateMode");
+ Get_SB (extensionFlag, "extensionFlag");
+
+ if (extensionFlag) {
+ Skip_SB( "var_ScalableFlag");
+ }
+ Element_End0();
+}
+
+//***************************************************************************
+// Speech Coding (CELP)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::CelpSpecificConfig ()
+{
+ Element_Begin1("CelpSpecificConfig");
+ bool isBaseLayer;
+ Get_SB(isBaseLayer, "isBaseLayer");
+ if (isBaseLayer)
+ {
+ CelpHeader ();
+ }
+ else
+ {
+ bool isBWSLayer;
+ Get_SB(isBWSLayer, "isBWSLayer");
+ if (isBWSLayer)
+ {
+ //~ CelpBWSenhHeader ()
+ //~ {
+ Skip_S1(2, "BWS_configuration");
+ //~ }
+
+ }
+ else
+ {
+ Skip_S1(2, "CELP-BRS-id");
+ }
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::CelpHeader ()
+{
+ Element_Begin1("CelpHeader");
+ bool ExcitationMode;
+ Get_SB(ExcitationMode, "ExcitationMode");
+ Skip_SB( "SampleRateMode");
+ Skip_SB( "FineRateControl");
+ if (ExcitationMode == 1/*RPE*/)
+ {
+ Skip_S1(3, "RPE_Configuration");
+ }
+ if (ExcitationMode == 0/*MPE*/)
+ {
+ Skip_S1(5, "MPE_Configuration");
+ Skip_S1(2, "NumEnhLayers");
+ Skip_SB( "BandwidthScalabilityMode");
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::ErrorResilientCelpSpecificConfig ()
+{
+ Element_Begin1("ErrorResilientCelpSpecificConfig");
+ bool isBaseLayer;
+ Get_SB(isBaseLayer, "isBaseLayer");
+ if (isBaseLayer)
+ {
+ ER_SC_CelpHeader ();
+ }
+ else
+ {
+ bool isBWSLayer;
+ Get_SB(isBWSLayer, "isBWSLayer");
+ if (isBWSLayer)
+ {
+ //~ CelpBWSenhHeader ()
+ //~ {
+ Skip_S1(2, "BWS_configuration");
+ //~ }
+
+ }
+ else
+ {
+ Skip_S1(2, "CELP-BRS-id");
+ }
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::ER_SC_CelpHeader ()
+{
+ Element_Begin1("ER_SC_CelpHeader");
+ bool ExcitationMode;
+ Get_SB(ExcitationMode, "ExcitationMode");
+ Skip_SB( "SampleRateMode");
+ Skip_SB( "FineRateControl");
+ Skip_SB( "SilenceCompression");
+
+ if (ExcitationMode == 1/*RPE*/) {
+ Skip_S1(3, "RPE_Configuration");
+ }
+ if (ExcitationMode == 0/*MPE*/) {
+ Skip_S1(5, "MPE_Configuration");
+ Skip_S1(2, "NumEnhLayers");
+ Skip_SB( "BandwidthScalabilityMode");
+ }
+ Element_End0();
+}
+
+//***************************************************************************
+// Structured Audio (SA)
+//***************************************************************************
+
+//***************************************************************************
+// Text to Speech Interface (TTSI)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::TTSSpecificConfig()
+{
+ Element_Begin1("TTSSpecificConfig");
+ //~ TTS_Sequence()
+ //~ {
+ Skip_S1(5, "TTS_Sequence_ID");
+ Skip_BS(18, "Language_Code");
+ Skip_SB( "Gender_Enable");
+ Skip_SB( "Age_Enable");
+ Skip_SB( "Speech_Rate_Enable");
+ Skip_SB( "Prosody_Enable");
+ Skip_SB( "Video_Enable");
+ Skip_SB( "Lip_Shape_Enable");
+ Skip_SB( "Trick_Mode_Enable");
+ //~ }
+ Element_End0();
+}
+
+//***************************************************************************
+// Parametric Audio (HILN)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::HILNconfig()
+{
+ Element_Begin1("HILNconfig");
+ Skip_SB( "HILNquantMode");
+ Skip_S1(8, "HILNmaxNumLine");
+ Skip_S1(4, "HILNsampleRateCode");
+ Skip_S2(12, "HILNframeLength");
+ Skip_S1(2, "HILNcontMode");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::HILNenexConfig()
+{
+ Element_Begin1("HILNenexConfig");
+ bool HILNenhaLayer;
+ Get_SB(HILNenhaLayer, "HILNenhaLayer");
+ if (HILNenhaLayer)
+ Skip_S1(2, "HILNenhaQuantMode");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::ParametricSpecificConfig()
+{
+ Element_Begin1("ParametricSpecificConfig");
+ bool isBaseLayer;
+ Get_SB(isBaseLayer, "isBaseLayer");
+ if (isBaseLayer)
+ PARAconfig();
+ else
+ HILNenexConfig();
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Aac::PARAconfig()
+{
+ Element_Begin1("PARAconfig");
+ int8u PARAmode;
+ Get_S1(2,PARAmode, "PARAmode");
+ if (PARAmode != 1)
+ ErHVXCconfig();
+ if (PARAmode != 0)
+ HILNconfig();
+ bool PARAextensionFlag;
+ Get_SB(PARAextensionFlag, "PARAextensionFlag");
+ if (PARAextensionFlag) {
+ /* to be defined in MPEG-4 Phase 3 */
+ }
+ Element_End0();
+}
+
+//***************************************************************************
+// Technical description of parametric coding for high quality audio
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::SSCSpecificConfig ()
+{
+ Element_Begin1("SSCSpecificConfig");
+ Skip_S1(2,"decoder_level");
+ Skip_S1(4,"update_rate");
+ Skip_S1(2,"synthesis_method");
+ if (channelConfiguration != 1)
+ {
+ int8u mode_ext;
+ Get_S1(2,mode_ext,"mode_ext");
+ if ((channelConfiguration == 2) && (mode_ext == 1))
+ {
+ /*reserved*/
+ }
+ }
+ Element_End0();
+}
+
+//***************************************************************************
+// MPEG-1/2 Audio
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::MPEG_1_2_SpecificConfig()
+{
+ Element_Begin1("MPEG_1_2_SpecificConfig");
+ Skip_SB( "extension");
+ Element_End0();
+}
+
+//***************************************************************************
+// Technical description of lossless coding of oversampled audio
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::DSTSpecificConfig()
+{
+ Element_Begin1("DSTSpecificConfig");
+ Skip_SB("DSDDST_Coded");
+ Skip_S2(14,"N_Channels");
+ Skip_SB("reserved");
+ Element_End0();
+}
+
+//***************************************************************************
+// Audio Lossless
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::ALSSpecificConfig()
+{
+ //Not in spec, but something weird in the example I have
+ int32u Junk;
+ while (Data_BS_Remain())
+ {
+ Peek_S4(32, Junk);
+ if (Junk!=0x414C5300)
+ {
+ Skip_SB( "Unknown");
+ }
+ else
+ break;
+ }
+ if (Data_BS_Remain()==0)
+ return; //There is a problem
+
+ Element_Begin1("ALSSpecificConfig");
+ bool chan_config,chan_sort,crc_enabled,aux_data_enabled;
+ int32u samp_freq, samples;
+ int16u channels,frame_length;
+ int8u ra_flag,random_access, file_type;
+ Skip_BS(32,"als_id");
+ Get_BS (32, samp_freq, "samp_freq");
+ Get_BS (32, samples, "samples");
+ Get_S2 (16, channels, "channels"); Param_Info2(channels+1, " channel(s)");
+ Get_S1 (3, file_type, "file_type");
+ Skip_S1(3,"resolution");
+ Skip_SB("floating");
+ Skip_SB("msb_first");
+ Get_S2 (16,frame_length,"frame_length");
+ Get_S1 (8,random_access,"random_access");
+ Get_S1 (2,ra_flag,"ra_flag");
+ Skip_SB("adapt_order");
+ Skip_S1(2,"coef_table");
+ Skip_SB("long_term_prediction");
+ Skip_S2(10,"max_order");
+ Skip_S1(2,"block_switching");
+ Skip_SB("bgmc_mode");
+ Skip_SB("sb_part");
+ Skip_SB("joint_stereo");
+ Skip_SB("mc_coding");
+ Get_SB (chan_config,"chan_config");
+ Get_SB (chan_sort,"chan_sort");
+ Get_SB (crc_enabled,"crc_enabled");
+ Skip_SB("RLSLMS");
+ Skip_BS(5,"(reserved)");
+ Get_SB (aux_data_enabled,"aux_data_enabled");
+ if (chan_config)
+ Skip_S2(16,"chan_config_info");
+ if (chan_sort)
+ {
+ int16u ChBits=(int16u)ceil(log((double)(channels+1))/log((double)2));
+ for (int8u c=0; c<=channels; c++)
+ Skip_BS(ChBits, "chan_pos[c]");
+ }
+ if(Data_BS_Remain()%8)
+ Skip_S1(Data_BS_Remain()%8, "byte_align");
+ BS_End();
+ int32u header_size,trailer_size;
+ Get_B4(header_size, "header_size");
+ Get_B4(trailer_size, "trailer_size");
+ #ifdef MEDIAINFO_RIFF_YES
+ if (file_type==1) //WAVE file
+ {
+ Element_Begin1("orig_header");
+ File_Riff MI;
+ Open_Buffer_Init(&MI);
+ Open_Buffer_Continue(&MI, Buffer+Buffer_Offset+(size_t)Element_Offset, header_size);
+ Element_Offset+=header_size;
+ File__Analyze::Finish(&MI); //No merge of data, only for trace information, because this is the data about the decoded stream, not the encoded stream
+ Element_End0();
+ }
+ else
+ #endif //MEDIAINFO_RIFF_YES
+ Skip_XX(header_size, "orig_header[]");
+
+ Skip_XX(trailer_size, "orig_trailer[]");
+ if (crc_enabled)
+ Skip_B4( "crc");
+ if ((ra_flag == 2) && (random_access > 0))
+ for (int32u f=0; f<((samples-1)/(frame_length+1))+1; f++)
+ Skip_B4( "ra_unit_size[f]");
+ if (aux_data_enabled)
+ {
+ int32u aux_size;
+ Get_B4(aux_size, "aux_size");
+ Skip_XX(aux_size, "aux_data[]");
+ }
+ Element_End0();
+ BS_Begin(); //To be in sync with other objectTypes
+
+ FILLING_BEGIN();
+ //Filling
+ File__Analyze::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, channels+1);
+
+ //Forcing default confignuration (something weird in the example I have)
+ channelConfiguration=0;
+ sampling_frequency_index=(int8u)-1;
+ sampling_frequency=samp_freq;
+ FILLING_END();
+}
+
+//***************************************************************************
+// Scalable lossless
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aac::SLSSpecificConfig()
+{
+ Element_Begin1("SLSSpecificConfig");
+ Skip_S1(3,"pcmWordLength");
+ Skip_SB("aac_core_present");
+ Skip_SB("lle_main_stream");
+ Skip_SB("reserved_bit");
+ Skip_S1(3,"frameLength");
+ if (!channelConfiguration)
+ program_config_element();
+ Element_End0();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_AAC_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ac3.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ac3.cpp
new file mode 100644
index 000000000..ec61d8698
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ac3.cpp
@@ -0,0 +1,2090 @@
+// File_Ac3 - Info for AC3 files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos (Common)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AC3_YES) || defined(MEDIAINFO_DVDV_YES) || defined(MEDIAINFO_MPEGPS_YES) || defined(MEDIAINFO_MPEGTS_YES)
+//---------------------------------------------------------------------------
+
+#include "ZenLib/Conf.h"
+using namespace ZenLib;
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern const int32u AC3_SamplingRate[]=
+{ 48000, 44100, 32000, 0,};
+
+//---------------------------------------------------------------------------
+const char* AC3_Mode[]=
+{
+ "CM (complete main)",
+ "ME (music and effects)",
+ "VI (visually impaired)",
+ "HI (hearing impaired)",
+ "D (dialogue)",
+ "C (commentary)",
+ "E (emergency)",
+ "VO (voice over)",
+};
+
+//---------------------------------------------------------------------------
+const char* AC3_Surround[]=
+{
+ "",
+ "Not Dolby Surround encoded",
+ "Dolby Surround encoded",
+ "",
+};
+
+//---------------------------------------------------------------------------
+extern const int16u AC3_BitRate[]=
+{
+
+ 32,
+ 40,
+ 48,
+ 56,
+ 64,
+ 80,
+ 96,
+ 112,
+ 128,
+ 160,
+ 192,
+ 224,
+ 256,
+ 320,
+ 384,
+ 448,
+ 512,
+ 576,
+ 640,
+};
+
+//---------------------------------------------------------------------------
+extern const int8u AC3_Channels[]=
+{2, 1, 2, 3, 3, 4, 4, 5};
+
+//---------------------------------------------------------------------------
+} //NameSpace
+
+//---------------------------------------------------------------------------
+#endif //...
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+//
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AC3_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Ac3.h"
+#include <vector>
+#include <cmath>
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const int32u AC3_SamplingRate2[]=
+{ 24000, 22050, 16000, 0,};
+
+//---------------------------------------------------------------------------
+const char* AC3_ChannelPositions[]=
+{
+ "Front: L R",
+ "Front: C",
+ "Front: L R",
+ "Front: L C R",
+ "Front: L R, Side: C",
+ "Front: L C R, Side: C",
+ "Front: L R, Side: L R",
+ "Front: L C R, Side: L R",
+};
+
+//---------------------------------------------------------------------------
+const char* AC3_ChannelPositions2[]=
+{
+ "2/0/0",
+ "1/0/0",
+ "2/0/0",
+ "3/0/0",
+ "2/1/0",
+ "3/1/0",
+ "2/2/0",
+ "3/2/0",
+};
+
+//---------------------------------------------------------------------------
+const int16u AC3_FrameSize[27][4]=
+{
+ { 128, 138, 192, 0},
+ { 160, 174, 240, 0},
+ { 192, 208, 288, 0},
+ { 224, 242, 336, 0},
+ { 256, 278, 384, 0},
+ { 320, 348, 480, 0},
+ { 384, 416, 576, 0},
+ { 448, 486, 672, 0},
+ { 512, 556, 768, 0},
+ { 640, 696, 960, 0},
+ { 768, 834, 1152, 0},
+ { 896, 974, 1344, 0},
+ {1024, 1114, 1536, 0},
+ {1280, 1392, 1920, 0},
+ {1536, 1670, 2304, 0},
+ {1792, 1950, 2688, 0},
+ {2048, 2228, 3072, 0},
+ {2304, 2506, 3456, 0},
+ {2560, 2786, 3840, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 768, 0, 0, 0},
+};
+
+//---------------------------------------------------------------------------
+int16u AC3_FrameSize_Get(int8u frmsizecod, int8u fscod)
+{
+ bool Padding=(frmsizecod%2)?true:false;
+ int16u frame_size_id=frmsizecod/2;
+
+ if (frame_size_id>26 || fscod>3)
+ return 0;
+
+ int16u FrameSize=AC3_FrameSize[frame_size_id][fscod];
+ if (fscod==1 && Padding)
+ FrameSize+=2; // frame lengths are padded by 1 word (16 bits) at 44100 Hz
+ return FrameSize;
+}
+
+//---------------------------------------------------------------------------
+// CRC_16_Table
+// A CRC is computed like this:
+// Init: int32u CRC_16 = 0x0000;
+// for each data byte do
+// CRC_16=(CRC_16<<8) ^ CRC_16_Table[(CRC_16>>8)^(data_byte)];
+int16u CRC_16_Table[256] =
+{
+ 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
+ 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
+ 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
+ 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
+ 0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2,
+ 0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1,
+ 0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1,
+ 0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082,
+ 0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192,
+ 0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1,
+ 0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1,
+ 0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2,
+ 0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151,
+ 0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162,
+ 0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132,
+ 0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101,
+ 0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312,
+ 0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321,
+ 0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371,
+ 0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342,
+ 0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1,
+ 0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2,
+ 0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2,
+ 0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381,
+ 0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291,
+ 0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2,
+ 0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2,
+ 0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1,
+ 0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252,
+ 0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261,
+ 0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
+ 0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202
+};
+
+int CRC16_Init(int16u *Table, int16u Polynomial)
+{
+ for (size_t Pos=0; Pos<256; Pos++)
+ {
+ Table[Pos]=(int16u)Pos<<8;
+
+ for(int8u bit=0; bit<8; bit++)
+ {
+ if (Table[Pos]&0x8000)
+ Table[Pos]=(Table[Pos]<<1)^Polynomial;
+ else
+ Table[Pos]=Table[Pos]<<1;
+ }
+ }
+ return 0;
+}
+
+//---------------------------------------------------------------------------
+const float64 AC3_dynrng[]=
+{
+ 6.02,
+ 12.04,
+ 18.06,
+ 24.08,
+ -18.06,
+ -12.04,
+ - 6.02,
+ 0.00,
+};
+
+//---------------------------------------------------------------------------
+const float64 AC3_compr[]=
+{
+ 6.02,
+ 12.04,
+ 18.06,
+ 24.08,
+ 30.10,
+ 36.12,
+ 42.14,
+ 48.16,
+ -42.14,
+ -36.12,
+ -30.10,
+ -24.08,
+ -18.06,
+ -12.04,
+ - 6.02,
+ 0.00,
+};
+
+//---------------------------------------------------------------------------
+const char* AC3_HD_StreamType(int8u StreamType)
+{
+ switch (StreamType)
+ {
+ case 0xBA : return "TrueHD";
+ case 0xBB : return "MLP";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+int32u AC3_HD_SamplingRate(int8u SamplingRate)
+{
+ if (SamplingRate==0xF)
+ return 0;
+
+ return ((SamplingRate&8)?44100:48000)<<(SamplingRate&7) ;
+}
+
+//---------------------------------------------------------------------------
+static const int8u AC3_TrueHD_ChannelCountPerBit[13]=
+{
+ 2, //LR
+ 1, //C
+ 1, //LFE
+ 2, //LRs
+ 2, //LRvh
+ 2, //LRc
+ 2, //LRrs
+ 1, //Cs
+ 1, //Ts
+ 2, //LRsd
+ 2, //LRw
+ 1, //Cvh
+ 1, //LFE2
+};
+
+//---------------------------------------------------------------------------
+int8u AC3_TrueHD_Channels(int16u ChannelsMap)
+{
+ int8u Channels=0;
+
+ for (int8u Pos=0; Pos<13; Pos++)
+ Channels+=AC3_TrueHD_ChannelCountPerBit[Pos]*((ChannelsMap>>Pos)&0x1);
+
+ return Channels;
+}
+
+//---------------------------------------------------------------------------
+std::string AC3_TrueHD_Channels_Positions(int16u ChannelsMap)
+{
+ std::string Text;
+ if ((ChannelsMap&0x0003)==0x0003)
+ Text+="Front: L C R";
+ else
+ {
+ if (ChannelsMap&0x0001)
+ Text+="Front: C";
+ if (ChannelsMap&0x0002)
+ Text+="Front: L, R";
+ }
+
+ if (ChannelsMap&0x08)
+ Text+=", Side: L R";
+
+ if (ChannelsMap&0x80)
+ Text+=", Back: C";
+
+ if ((ChannelsMap&0x0810)==0x0810)
+ Text+=", vh: L C R";
+ else
+ {
+ if (ChannelsMap&0x0010)
+ Text+=", vh: L R";
+ if (ChannelsMap&0x0800)
+ Text+=", vh: C";
+ }
+
+ if (ChannelsMap&0x0020)
+ Text+=", c: L R";
+ if (ChannelsMap&0x0040)
+ Text+=", Back: L R";
+ if (ChannelsMap&0x0100)
+ Text+=", s: T";
+ if (ChannelsMap&0x0200)
+ Text+=", sd: L R";
+ if (ChannelsMap&0x0400)
+ Text+=", w: L R";
+
+ if (ChannelsMap&0x0004)
+ Text+=", LFE";
+ if (ChannelsMap&0x1000)
+ Text+=", LFE2";
+
+ return Text;
+}
+
+//---------------------------------------------------------------------------
+Ztring AC3_TrueHD_Channels_Positions2(int16u ChannelsMap)
+{
+ int8u Front=0, Surround=0, Rear=0, LFE=0;
+
+ if (ChannelsMap&0x0001)
+ Front++;
+ if (ChannelsMap&0x0002)
+ Front+=2;
+
+ if (ChannelsMap&0x08)
+ Surround+=2;
+ if (ChannelsMap&0x80)
+ Surround++;
+
+ if (ChannelsMap&0x0010)
+ Rear+=2; //vh
+ if (ChannelsMap&0x0800)
+ Rear++; //vh
+
+
+ if (ChannelsMap&0x0020)
+ Rear+=2; //c
+ if (ChannelsMap&0x0040)
+ Rear+=2; //rs
+ if (ChannelsMap&0x0100)
+ Rear+=2; //s
+ if (ChannelsMap&0x0200)
+ Rear+=2; //sd
+ if (ChannelsMap&0x0400)
+ Rear+=2; //w
+
+ if (ChannelsMap&0x0004)
+ LFE++;
+ if (ChannelsMap&0x1000)
+ LFE++;
+
+ Ztring Text;
+ Text+=Ztring::ToZtring(Front);
+ Text+=_T('/')+Ztring::ToZtring(Surround);
+ Text+=_T('/')+Ztring::ToZtring(Rear);
+ Text+=_T('.')+Ztring::ToZtring(LFE);
+ return Text;
+}
+
+//---------------------------------------------------------------------------
+static const int32u AC3_MLP_Channels[32]=
+{
+ 1,
+ 2,
+ 3,
+ 4,
+ 3,
+ 4,
+ 5,
+ 3,
+ 4,
+ 5,
+ 4,
+ 5,
+ 6,
+ 4,
+ 5,
+ 4,
+ 5,
+ 6,
+ 5,
+ 5,
+ 6,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+static const int32u AC3_MLP_Resolution[16]=
+{
+ 16,
+ 20,
+ 24,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Ac3::File_Ac3()
+:File__Analyze()
+{
+ //Configuration
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Ac3;
+ StreamIDs_Width[0]=0;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(8); //Stream
+ #endif //MEDIAINFO_TRACE
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=32*1024;
+ Buffer_TotalBytes_Fill_Max=1024*1024;
+ PTS_DTS_Needed=true;
+ IsRawStream=true;
+ Frame_Count_NotParsedIncluded=0;
+
+ //In
+ Frame_Count_Valid=MediaInfoLib::Config.ParseSpeed_Get()>=0.3?32:2;
+ MustParse_dac3=false;
+ MustParse_dec3=false;
+ CalculateDelay=false;
+
+ //Buffer
+ Save_Buffer=NULL;
+
+ //Temp
+ chanmap=0;
+ frmsiz=0;
+ fscod=0;
+ fscod2=0;
+ frmsizecod=0;
+ bsid=(int8u)-1;
+ bsmod=0;
+ acmod=0;
+ dsurmod=0;
+ numblkscod=0;
+ lfeon=false;
+ dxc3_Parsed=false;
+ HD_MajorSync_Parsed=false;
+ Core_IsPresent=false;
+ HD_IsPresent=false;
+ dynrnge_Exists=false;
+ TimeStamp_IsPresent=false;
+ TimeStamp_IsParsing=false;
+ TimeStamp_Parsed=false;
+ TimeStamp_DropFrame_IsValid=false;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ac3::Streams_Fill()
+{
+ if (HD_MajorSync_Parsed)
+ {
+ Stream_Prepare(Stream_Audio);
+ if (HD_BitRate_Max)
+ Fill(Stream_Audio, 0, Audio_BitRate_Maximum, (HD_BitRate_Max*AC3_HD_SamplingRate(HD_SamplingRate2)+8)>>4);
+
+ if (HD_StreamType==0xBA) //TrueHD
+ {
+ Fill(Stream_General, 0, General_Format, "TrueHD");
+ Fill(Stream_Audio, 0, Audio_Format, "TrueHD");
+
+ Fill(Stream_Audio, 0, Audio_Codec, "TrueHD");
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "VBR");
+ Fill(Stream_Audio, 0, Audio_SamplingRate, AC3_HD_SamplingRate(HD_SamplingRate1));
+ Fill(Stream_Audio, 0, Audio_Channel_s_, AC3_TrueHD_Channels(HD_Channels2));
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, AC3_TrueHD_Channels_Positions(HD_Channels2));
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, AC3_TrueHD_Channels_Positions2(HD_Channels2));
+ if (Core_IsPresent && !IsSub)
+ Fill(Stream_Audio, 0, Audio_MuxingMode, "After core data");
+ }
+
+ if (HD_StreamType==0xBB) //TrueHD
+ {
+ Fill(Stream_General, 0, General_Format, "MLP");
+ if (!Core_IsPresent)
+ {
+ Fill(Stream_Audio, 0, Audio_Format, "MLP");
+ Fill(Stream_Audio, 0, Audio_Codec, "MLP");
+ }
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "VBR");
+ Fill(Stream_Audio, 0, Audio_SamplingRate, AC3_HD_SamplingRate(HD_SamplingRate2));
+ if (HD_SamplingRate1!=HD_SamplingRate2)
+ Fill(Stream_Audio, 0, Audio_SamplingRate, AC3_HD_SamplingRate(HD_SamplingRate2));
+ Fill(Stream_Audio, 0, Audio_Channel_s_, AC3_MLP_Channels[HD_Channels1]);
+ if (HD_Channels1!=HD_Channels2)
+ Fill(Stream_Audio, 0, Audio_Channel_s_, AC3_MLP_Channels[HD_Channels1]);
+ Fill(Stream_Audio, 0, Audio_BitDepth, AC3_MLP_Resolution[HD_Resolution2]);
+ if (HD_Resolution1!=HD_Resolution2)
+ Fill(Stream_Audio, 0, Audio_BitDepth, AC3_MLP_Resolution[HD_Resolution1]);
+ }
+ }
+
+ //AC-3
+ if (bsid<=0x08)
+ {
+ if (Count_Get(Stream_Audio)==0)
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_General, 0, General_Format, "AC-3");
+ Fill(Stream_Audio, 0, Audio_Format, "AC-3");
+ Fill(Stream_Audio, 0, Audio_Codec, "AC3");
+ Fill(Stream_Audio, 0, Audio_BitDepth, 16);
+
+ if (Ztring::ToZtring(AC3_SamplingRate[fscod])!=Retrieve(Stream_Audio, 0, Audio_SamplingRate))
+ Fill(Stream_Audio, 0, Audio_SamplingRate, AC3_SamplingRate[fscod]);
+ if (frmsizecod/2<19)
+ {
+ if (Info_HD.Frame_Count)
+ Fill(Stream_Audio, 0, Audio_BitRate, "Unknown");
+ int32u BitRate=AC3_BitRate[frmsizecod/2]*1000;
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate);
+ if (CalculateDelay && Buffer_TotalBytes_FirstSynched>100 && BitRate>0)
+ {
+ Fill(Stream_Audio, 0, Audio_Delay, (float)Buffer_TotalBytes_FirstSynched*8*1000/BitRate, 0);
+ Fill(Stream_Audio, 0, Audio_Delay_Source, "Stream");
+ }
+ }
+
+ if (acmod==0)
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Mode, "Dual Mono");
+ Fill(Stream_Audio, 0, Audio_Format_Settings_ModeExtension, AC3_Mode[bsmod]);
+ int8u Channels=AC3_Channels[acmod];
+ Ztring ChannelPositions; ChannelPositions.From_Local(AC3_ChannelPositions[acmod]);
+ Ztring ChannelPositions2; ChannelPositions2.From_Local(AC3_ChannelPositions2[acmod]);
+ if (lfeon)
+ {
+ Channels+=1;
+ ChannelPositions+=_T(", LFE");
+ ChannelPositions2+=_T(".1");
+ }
+ if (Ztring::ToZtring(Channels)!=Retrieve(Stream_Audio, 0, Audio_Channel_s_))
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Channels);
+ if (ChannelPositions!=Retrieve(Stream_Audio, 0, Audio_ChannelPositions))
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, ChannelPositions);
+ if (ChannelPositions2!=Retrieve(Stream_Audio, 0, Audio_ChannelPositions_String2))
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, ChannelPositions2);
+ if (dsurmod==2)
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Profile, "Dolby Digital");
+ Fill(Stream_Audio, 0, Audio_Codec_Profile, "Dolby Digital");
+ }
+ if (_T("CBR")!=Retrieve(Stream_Audio, 0, Audio_BitRate_Mode))
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR");
+ }
+
+ //E-AC-3
+ else if (bsid<=0x10)
+ {
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "E-AC-3");
+ Fill(Stream_Audio, 0, Audio_Codec, "AC3+");
+
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR");
+ int8u numblks=numblkscod==3?6:numblkscod+1;
+ if (numblks>0)
+ Fill(Stream_Audio, 0, Audio_BitRate, ((frmsiz*2+2)*8*(750/numblks))/4);
+
+ if (fscod!=2)
+ Fill(Stream_Audio, 0, Audio_SamplingRate, AC3_SamplingRate[fscod]);
+ else
+ Fill(Stream_Audio, 0, Audio_SamplingRate, AC3_SamplingRate2[fscod2]);
+
+ if (chanmap==0)
+ {
+ if (acmod==0)
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Profile, "Dual Mono");
+ Fill(Stream_Audio, 0, Audio_Codec_Profile, "Dual Mono");
+ }
+ int8u Channels=AC3_Channels[acmod];
+ Ztring ChannelPositions; ChannelPositions.From_Local(AC3_ChannelPositions[acmod]);
+ if (lfeon)
+ {
+ Channels+=1;
+ ChannelPositions+=_T(", LFE");
+ }
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Channels);
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, ChannelPositions);
+ }
+ }
+
+ if (HD_MajorSync_Parsed)
+ {
+ //Filling Maximum bitrate with the constant core bitrate for better coherancy
+ ZtringList List;
+ List.Separator_Set(0, _T(" / "));
+ List.Write(Retrieve(Stream_Audio, 0, Audio_BitRate));
+ if (List.size()>=2)
+ Fill(Stream_Audio, 0, Audio_BitRate_Maximum, List[1]);
+ }
+
+ //Dolby Metadata
+ if (Core_IsPresent)
+ {
+ //Endianess
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, BigEndian?"Big":"Little");
+
+ if (acmod==2)
+ {
+ Fill(Stream_Audio, 0, "dsurmod", dsurmod);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dsurmod"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dsurmod/String", AC3_Surround[dsurmod]);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dsurmod/String"), Info_Options)=_T("N NT");
+ }
+ Fill(Stream_Audio, 0, "dialnorm", FirstFrame_Dolby.dialnorm==0?-31:-FirstFrame_Dolby.dialnorm);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dialnorm"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dialnorm/String", Ztring::ToZtring(FirstFrame_Dolby.dialnorm==0?-31:-FirstFrame_Dolby.dialnorm)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dialnorm/String"), Info_Options)=_T("N NT");
+ if (FirstFrame_Dolby.compre)
+ {
+ float64 Value=AC3_compr[FirstFrame_Dolby.compr>>4]+20*std::log10(((float)(0x10+(FirstFrame_Dolby.compr&0x0F)))/32);
+ Fill(Stream_Audio, 0, "compr", Value, 2);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("compr"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "compr/String", Ztring::ToZtring(Value, 2)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("compr/String"), Info_Options)=_T("N NT");
+ }
+ if (FirstFrame_Dolby.dynrnge)
+ {
+ float64 Value;
+ if (FirstFrame_Dolby.dynrng==0)
+ Value=0; //Special case in the formula
+ else
+ Value=AC3_dynrng[FirstFrame_Dolby.dynrng>>5]+20*std::log10(((float)(0x20+(FirstFrame_Dolby.dynrng&0x1F)))/64);
+ Fill(Stream_Audio, 0, "dynrng", Value, 2);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dynrng"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dynrng/String", Ztring::ToZtring(Value, 2)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dynrng/String"), Info_Options)=_T("N NT");
+ }
+ Fill(Stream_Audio, 0, "bsid", bsid);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("bsid"), Info_Options)=_T("N NT");
+ }
+
+ //TimeStamp
+ if (TimeStamp_IsPresent)
+ {
+ Fill(Stream_Audio, 0, Audio_Delay, TimeStamp_Content*1000, 0);
+ Fill(Stream_Audio, 0, Audio_Delay_Source, "Stream");
+ if (TimeStamp_DropFrame_IsValid)
+ Fill(Stream_Audio, 0, Audio_Delay_Settings, TimeStamp_DropFrame_Content?"drop_frame_flag=1":"drop_frame_flag=0");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Ac3::Streams_Finish()
+{
+ //Stats
+ if (!dialnorms.empty())
+ {
+ int8u Minimum_Raw=1;
+ int8u Maximum_Raw=31;
+ float64 Sum_Intensity=0;
+ int64u Count=0;
+ for (int8u Pos=0; (size_t)Pos<dialnorms.size(); Pos++)
+ if (dialnorms[Pos])
+ {
+ if (Minimum_Raw<(Pos==0?31:Pos))
+ Minimum_Raw=(Pos==0?31:Pos);
+ if (Maximum_Raw>(Pos==0?31:Pos))
+ Maximum_Raw=(Pos==0?31:Pos);
+ Sum_Intensity+=dialnorms[Pos]*pow(10, -((float64)Pos)/10);
+ Count+=dialnorms[Pos];
+ }
+ float64 Average_dB=log10(Sum_Intensity/Count)*10;
+ Fill(Stream_Audio, 0, "dialnorm_Average", Average_dB, 0);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dialnorm_Average"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dialnorm_Average/String", Ztring::ToZtring(Average_dB, 0)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dialnorm_Average/String"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dialnorm_Minimum", -Minimum_Raw);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dialnorm_Minimum"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dialnorm_Minimum/String", Ztring::ToZtring(-Minimum_Raw)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dialnorm_Minimum/String"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dialnorm_Maximum", -Maximum_Raw);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dialnorm_Maximum"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dialnorm_Maximum/String", Ztring::ToZtring(-Maximum_Raw)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dialnorm_Maximum/String"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dialnorm_Count", Count);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dialnorm_Count"), Info_Options)=_T("N NT");
+ }
+ if (!comprs.empty())
+ {
+ float64 Minimum_dB=47.89;
+ float64 Maximum_dB=-48.16;
+ float64 Sum_Intensity=0;
+ int64u Count=0;
+ for (size_t Pos=0; Pos<comprs.size(); Pos++)
+ if (comprs[Pos])
+ {
+ float64 Value=AC3_compr[Pos>>4]+20*std::log10(((float)(0x10+(Pos&0x0F)))/32);
+ if (Minimum_dB>Value)
+ Minimum_dB=Value;
+ if (Maximum_dB<Value)
+ Maximum_dB=Value;
+ Sum_Intensity+=comprs[Pos]*pow(10, Value/10);
+ Count+=comprs[Pos];
+ }
+ float64 Average_dB=log10(Sum_Intensity/Count)*10;
+ Fill(Stream_Audio, 0, "compr_Average", Average_dB, 2);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("compr_Average"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "compr_Average/String", Ztring::ToZtring(Average_dB, 2)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("compr_Average/String"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "compr_Minimum", Minimum_dB, 2);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("compr_Minimum"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "compr_Minimum/String", Ztring::ToZtring(Minimum_dB, 2)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("compr_Minimum/String"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "compr_Maximum", Maximum_dB, 2);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("compr_Maximum"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "compr_Maximum/String", Ztring::ToZtring(Maximum_dB, 2)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("compr_Maximum/String"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "compr_Count", Count);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("compr_Count"), Info_Options)=_T("N NT");
+ }
+ if (dynrnge_Exists && !dynrngs.empty())
+ {
+ float64 Minimum_dB=23.95;
+ float64 Maximum_dB=-24.08;
+ float64 Sum_Intensity=0;
+ int64u Count=0;
+ for (size_t Pos=0; Pos<dynrngs.size(); Pos++)
+ if (dynrngs[Pos])
+ {
+ float64 Value;
+ if (Pos==0)
+ Value=0; //Special case in the formula
+ else
+ Value=AC3_dynrng[Pos>>5]+20*std::log10(((float)(0x20+(Pos&0x1F)))/64);
+ if (Minimum_dB>Value)
+ Minimum_dB=Value;
+ if (Maximum_dB<Value)
+ Maximum_dB=Value;
+ Sum_Intensity+=dynrngs[Pos]*pow(10, Value/10);
+ Count+=dynrngs[Pos];
+ }
+ float64 Average_dB=log10(Sum_Intensity/Count)*10;
+ Fill(Stream_Audio, 0, "dynrng_Average", Average_dB, 2);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dynrng_Average"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dynrng_Average/String", Ztring::ToZtring(Average_dB, 2)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dynrng_Average/String"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dynrng_Minimum", Minimum_dB, 2);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dynrng_Minimum"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dynrng_Minimum/String", Ztring::ToZtring(Minimum_dB, 2)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dynrng_Minimum/String"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dynrng_Maximum", Maximum_dB, 2);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dynrng_Maximum"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dynrng_Maximum/String", Ztring::ToZtring(Maximum_dB, 2)+_T(" dB"));
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dynrng_Maximum/String"), Info_Options)=_T("N NT");
+ Fill(Stream_Audio, 0, "dynrng_Count", Count);
+ (*Stream_More)[Stream_Audio][0](Ztring().From_Local("dynrng_Count"), Info_Options)=_T("N NT");
+ }
+
+ //Duration
+ if (!IsSub)
+ {
+ int64u Frame_Count_ForDuration=0;
+ if (MediaInfoLib::Config.ParseSpeed_Get()==1)
+ {
+ Frame_Count_ForDuration=Frame_Count; //We have the exact count of frames
+ Fill(Stream_Audio, 0, Audio_StreamSize, File_Offset+Buffer_Offset+Element_Size-File_Offset_FirstSynched);
+ }
+ else if (bsid<=8 && frmsizecods.size()==1 && fscods.size()==1 && Info_HD.Frame_Count==0)
+ {
+ int16u Size=AC3_FrameSize_Get(frmsizecods.begin()->first, fscods.begin()->first);
+ if (TimeStamp_IsPresent)
+ Size+=16;
+ Frame_Count_ForDuration=(File_Size-File_Offset_FirstSynched)/Size; //Only complete frames
+ Fill(Stream_Audio, 0, Audio_StreamSize, Frame_Count_ForDuration*Size);
+ }
+ if (Frame_Count_ForDuration)
+ {
+ Clear(Stream_Audio, 0, Audio_BitRate);
+
+ //HD part
+ if (Info_HD.Frame_Count)
+ {
+ int32u HD_SamplingRate=AC3_HD_SamplingRate(HD_SamplingRate1);
+ if (HD_SamplingRate)
+ {
+ int8u FrameDuration; //In samples
+ if (HD_SamplingRate<44100)
+ FrameDuration=0; //Unknown
+ else if (HD_SamplingRate<=48000)
+ FrameDuration=40;
+ else if (HD_SamplingRate<=96000)
+ FrameDuration=80;
+ else if (HD_SamplingRate<=192000)
+ FrameDuration=160;
+ else
+ FrameDuration=0; //Unknown
+ if (FrameDuration)
+ {
+ int64u SamplingCount=Info_HD.Frame_Count*FrameDuration;
+ Fill(Stream_Audio, 0, Audio_Duration, SamplingCount/(((float64)HD_SamplingRate)/1000), 0);
+ Fill(Stream_Audio, 0, Audio_SamplingCount, SamplingCount);
+ Fill(Stream_Audio, 0, Audio_BitRate, (File_Size-File_Offset_FirstSynched)/(SamplingCount/(((float64)HD_SamplingRate)/1000))*8, 0);
+ }
+ Fill(Stream_Audio, 0, Audio_FrameCount, Info_HD.Frame_Count);
+ }
+ }
+ if (Core_IsPresent)
+ {
+ Fill(Stream_Audio, 0, Audio_FrameCount, Frame_Count_ForDuration);
+ if (AC3_SamplingRate[fscod])
+ {
+ float64 FrameDuration=((float64)(32*48000))/AC3_SamplingRate[fscod]; //32 ms for 48 KHz, else proportional (34.83 for 44.1 KHz, 48 ms for 32 KHz)
+ Fill(Stream_Audio, 0, Audio_SamplingCount, Frame_Count_ForDuration*1536);
+ Fill(Stream_Audio, 0, Audio_Duration, Frame_Count_ForDuration*FrameDuration, 0);
+ int32u BitRate=AC3_BitRate[frmsizecod/2]*1000;
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate);
+ }
+ }
+ }
+ }
+ else if (FrameInfo.PTS!=(int64u)-1 && FrameInfo.PTS>PTS_Begin)
+ {
+ Fill(Stream_Audio, 0, Audio_Duration, float64_int64s(((float64)(FrameInfo.PTS-PTS_Begin))/1000000));
+ Fill(Stream_Audio, 0, Audio_FrameCount, float64_int64s(((float64)(FrameInfo.PTS-PTS_Begin))/1000000/32));
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Ac3::Read_Buffer_Unsynched()
+{
+ Info_Core.FrameInfo=FrameInfo;
+ Info_Core.Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded;
+ Info_HD.FrameInfo=FrameInfo;
+ Info_HD.Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded;
+
+ delete[] Save_Buffer; Save_Buffer=NULL;
+
+ if (File_GoTo==0)
+ Synched_Init();
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_Ac3::Read_Buffer_Seek (size_t Method, int64u Value, int64u /*ID*/)
+{
+ GoTo(0);
+ Open_Buffer_Unsynch();
+ return 1;
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Ac3::FileHeader_Begin()
+{
+ //Specific cases
+ if (MustParse_dac3 || MustParse_dec3)
+ return true;
+
+ //Must have enough buffer for having header
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ //False positives detection: detect Matroska files, AC-3 parser is not smart enough
+ if (CC4(Buffer)==0x1A45DFA3) //EBML
+ {
+ Finish("AC-3");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Ac3::Synchronize()
+{
+ //Specific cases
+ if (MustParse_dac3 || MustParse_dec3)
+ return true;
+
+ //Synchronizing
+ while (Buffer_Offset+8<=Buffer_Size)
+ {
+ if (!FrameSynchPoint_Test())
+ return false; //Need more data
+ if (Synched)
+ break;
+ Buffer_Offset++;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+8>Buffer_Size)
+ {
+ //We must keep more bytes in order to detect TimeStamp
+ if (Frame_Count==0)
+ {
+ if (Buffer_Offset>=16)
+ Buffer_Offset-=16;
+ else
+ Buffer_Offset=0;
+ return false;
+ }
+
+ if (Buffer_Offset+7==Buffer_Size && CC3(Buffer+Buffer_Offset+4)!=0xF8726F && CC2(Buffer+Buffer_Offset)!=0x0B77 && CC2(Buffer+Buffer_Offset)!=0x770B)
+ Buffer_Offset++;
+ if (Buffer_Offset+6==Buffer_Size && CC2(Buffer+Buffer_Offset+4)!=0xF872 && CC2(Buffer+Buffer_Offset)!=0x0B77 && CC2(Buffer+Buffer_Offset)!=0x770B)
+ Buffer_Offset++;
+ if (Buffer_Offset+5==Buffer_Size && CC1(Buffer+Buffer_Offset+4)!=0xF8 && CC2(Buffer+Buffer_Offset)!=0x0B77 && CC2(Buffer+Buffer_Offset)!=0x770B)
+ Buffer_Offset++;
+ if (Buffer_Offset+4==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x0B77 && CC2(Buffer+Buffer_Offset)!=0x770B)
+ Buffer_Offset++;
+ if (Buffer_Offset+3==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x0B77 && CC2(Buffer+Buffer_Offset)!=0x770B)
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x0B77 && CC2(Buffer+Buffer_Offset)!=0x770B)
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x0B && CC1(Buffer+Buffer_Offset)!=0x77)
+ Buffer_Offset++;
+ return false;
+ }
+
+ //Testing if we have TimeStamp
+ if (Buffer_Offset>=16)
+ {
+ if ( Buffer[Buffer_Offset-0x10+0x02]==0x00 //First byte of HH? Always 0x00
+ && (Buffer[Buffer_Offset-0x10+0x03]>>4 )<0x6 //Second byte of HH? First 4 bits must be <0x6
+ && (Buffer[Buffer_Offset-0x10+0x03]&0xF)<0xA //Second byte of HH? Second 4 bits must be <0xA
+ && Buffer[Buffer_Offset-0x10+0x04]==0x00 //First byte of MM? Always 0x00
+ && (Buffer[Buffer_Offset-0x10+0x05]>>4 )<0x6 //Second byte of MM? First 4 bits must be <0x6
+ && (Buffer[Buffer_Offset-0x10+0x05]&0xF)<0xA //Second byte of MM? Second 4 bits must be <0xA
+ && Buffer[Buffer_Offset-0x10+0x06]==0x00 //First byte of SS? Always 0x00
+ && (Buffer[Buffer_Offset-0x10+0x07]>>4 )<0x6 //Second byte of SS? First 4 bits must be <0x6
+ && (Buffer[Buffer_Offset-0x10+0x07]&0xF)<0xA //Second byte of SS? Second 4 bits must be <0xA
+ && Buffer[Buffer_Offset-0x10+0x08]==0x00 //First byte of FF? Always 0x00
+ && (Buffer[Buffer_Offset-0x10+0x09]>>4 )<0x4 //Second byte of FF? First 4 bits must be <0x4
+ && (Buffer[Buffer_Offset-0x10+0x09]&0xF)<0xA //Second byte of FF? Second 4 bits must be <0xA
+ && !(Buffer[Buffer_Offset-0x10+0x00]==0x00 //We want at least a byte not zero, in order to differentiate TimeStamp from padding
+ && Buffer[Buffer_Offset-0x10+0x01]==0x00
+ && Buffer[Buffer_Offset-0x10+0x0C]==0x00
+ && Buffer[Buffer_Offset-0x10+0x0D]==0x00
+ && Buffer[Buffer_Offset-0x10+0x0E]==0x00
+ && Buffer[Buffer_Offset-0x10+0x0F]==0x00))
+ {
+ TimeStamp_IsPresent=true;
+ Buffer_Offset-=16;
+
+ if (Frame_Count_Valid<10000)
+ Frame_Count_Valid=10000; //Setting it to 10000 in order to be able to have the drop frame for extreme stream (60 fps...)
+ }
+ }
+
+ //Synched
+ Data_Accept("AC-3");
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Ac3::Synched_Init()
+{
+ //FrameInfo
+ PTS_End=0;
+ if (FrameInfo.DTS==(int64u)-1)
+ FrameInfo.DTS=0; //No DTS in container
+ if (FrameInfo.PTS==(int64u)-1)
+ FrameInfo.PTS=0; //No PTS in container
+ DTS_Begin=FrameInfo.DTS;
+ DTS_End=FrameInfo.DTS;
+ if (Frame_Count_NotParsedIncluded==(int64u)-1)
+ Frame_Count_NotParsedIncluded=0; //No Frame_Count_NotParsedIncluded in the container
+
+ Info_Core.FrameInfo=FrameInfo;
+ Info_Core.Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded;
+ Info_HD.FrameInfo=FrameInfo;
+ Info_HD.Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded;
+}
+
+//---------------------------------------------------------------------------
+bool File_Ac3::Synched_Test()
+{
+ //Specific cases
+ if (MustParse_dac3 || MustParse_dec3)
+ return true;
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+(TimeStamp_IsPresent?16:0)+6>Buffer_Size)
+ return false;
+
+ //TimeStamp
+ if (TimeStamp_IsPresent && !TimeStamp_Parsed)
+ {
+ if (!( Buffer[Buffer_Offset+0x02]==0x00 //First byte of HH? Always 0x00
+ && (Buffer[Buffer_Offset+0x03]>>4 )<0x6 //Second byte of HH? First 4 bits must be <0x6
+ && (Buffer[Buffer_Offset+0x03]&0xF)<0xA //Second byte of HH? Second 4 bits must be <0xA
+ && Buffer[Buffer_Offset+0x04]==0x00 //First byte of MM? Always 0x00
+ && (Buffer[Buffer_Offset+0x05]>>4 )<0x6 //Second byte of MM? First 4 bits must be <0x6
+ && (Buffer[Buffer_Offset+0x05]&0xF)<0xA //Second byte of MM? Second 4 bits must be <0xA
+ && Buffer[Buffer_Offset+0x06]==0x00 //First byte of SS? Always 0x00
+ && (Buffer[Buffer_Offset+0x07]>>4 )<0x6 //Second byte of SS? First 4 bits must be <0x6
+ && (Buffer[Buffer_Offset+0x07]&0xF)<0xA //Second byte of SS? Second 4 bits must be <0xA
+ && Buffer[Buffer_Offset+0x08]==0x00 //First byte of FF? Always 0x00
+ && (Buffer[Buffer_Offset+0x09]>>4 )<0x4 //Second byte of FF? First 4 bits must be <0x4
+ && (Buffer[Buffer_Offset+0x09]&0xF)<0xA //Second byte of FF? Second 4 bits must be <0xA
+ && Buffer[Buffer_Offset+0x10]==0x0B //TimeStamp is followed by AC-3
+ && Buffer[Buffer_Offset+0x11]==0x77))
+ TimeStamp_IsPresent=false;
+ }
+ if (TimeStamp_IsPresent && !TimeStamp_Parsed)
+ Buffer_Offset+=16;
+
+ //Quick test of synchro
+ if (!FrameSynchPoint_Test())
+ return false; //Need more data
+ if (!Synched)
+ return true;
+
+ //TimeStamp
+ if (TimeStamp_IsPresent && !TimeStamp_Parsed)
+ {
+ Buffer_Offset-=16;
+ if (Synched)
+ {
+ TimeStamp_IsParsing=true;
+ TimeStamp_Parsed=false;
+ }
+ else
+ {
+ TimeStamp_IsParsing=false;
+ TimeStamp_Parsed=false;
+ }
+ }
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Demux
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+bool File_Ac3::Demux_UnpacketizeContainer_Test()
+{
+ if (TimeStamp_IsPresent)
+ Buffer_Offset+=16;
+
+ if (!HD_IsPresent && Info_Core.Frame_Count==0 && Save_Buffer==NULL)
+ {
+ //Searching HD part
+ size_t Buffer_Offset_Save=Buffer_Offset;
+ Buffer_Offset++;
+ Synched=false;
+ while (Buffer_Offset+8<=Buffer_Size)
+ {
+ if (!FrameSynchPoint_Test())
+ {
+ Buffer_Offset=Buffer_Offset_Save;
+ return false; //Need more data
+ }
+ if (Synched)
+ break;
+ Buffer_Offset++;
+ }
+ Buffer_Offset=Buffer_Offset_Save;
+ if (!Synched)
+ {
+ Synched=true;
+ if (TimeStamp_IsPresent)
+ Buffer_Offset-=16;
+ return false; //Need more data
+ }
+ }
+
+
+ if ((Buffer[Buffer_Offset]==0x0B && Buffer[Buffer_Offset+1]==0x77)
+ || (Buffer[Buffer_Offset]==0x77 && Buffer[Buffer_Offset+1]==0x0B))
+ {
+ FrameInfo=Info_Core.FrameInfo;
+ Frame_Count=Info_Core.Frame_Count;
+ Frame_Count_InThisBlock=Info_Core.Frame_Count_InThisBlock;
+ Frame_Count_NotParsedIncluded=Info_Core.Frame_Count_NotParsedIncluded;
+
+ Demux_Offset=Buffer_Offset+Core_Size_Get();
+
+ //Core part
+ if (HD_IsPresent)
+ {
+ if (TimeStamp_IsPresent)
+ Buffer_Offset-=16;
+ return true; //No AC-3 demux
+ }
+ }
+ else
+ {
+ FrameInfo=Info_HD.FrameInfo;
+ Frame_Count=Info_HD.Frame_Count;
+ Frame_Count_InThisBlock=Info_HD.Frame_Count_InThisBlock;
+ Frame_Count_NotParsedIncluded=Info_HD.Frame_Count_NotParsedIncluded;
+
+ Demux_Offset=Buffer_Offset+HD_Size_Get();
+ }
+
+
+ if (Demux_Offset>Buffer_Size && File_Offset+Buffer_Size!=File_Size)
+ {
+ if (TimeStamp_IsPresent)
+ Buffer_Offset-=16;
+ return false; //No complete frame
+ }
+
+ if (Save_Buffer)
+ {
+ Demux_TotalBytes-=Buffer_Offset;
+ Demux_Offset-=Buffer_Offset;
+ File_Offset+=Buffer_Offset;
+ swap(Buffer, Save_Buffer);
+ swap(Buffer_Offset, Save_Buffer_Offset);
+ swap(Buffer_Size, Save_Buffer_Size);
+ }
+
+ Demux_UnpacketizeContainer_Demux();
+
+ if (Save_Buffer)
+ {
+ swap(Buffer, Save_Buffer);
+ swap(Buffer_Offset, Save_Buffer_Offset);
+ swap(Buffer_Size, Save_Buffer_Size);
+ Demux_TotalBytes+=Buffer_Offset;
+ Demux_Offset+=Buffer_Offset;
+ File_Offset-=Buffer_Offset;
+ }
+
+ if (TimeStamp_IsPresent)
+ Buffer_Offset-=16;
+
+ return true;
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ac3::Read_Buffer_Continue()
+{
+ if (MustParse_dac3)
+ {
+ dac3();
+ return;
+ }
+ if (MustParse_dec3)
+ {
+ dec3();
+ return;
+ }
+
+ if (IsSub)
+ {
+ Info_Core.FrameInfo=FrameInfo;
+ Info_Core.Frame_Count_InThisBlock=0;
+ Info_HD.FrameInfo=FrameInfo;
+ Info_HD.Frame_Count_InThisBlock=0;
+ }
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ac3::Header_Parse()
+{
+ //TimeStamp
+ if (TimeStamp_IsParsing)
+ {
+ Header_Fill_Size(16);
+ Header_Fill_Code(2, "TimeStamp");
+ return;
+ }
+ else
+ TimeStamp_Parsed=false; //Currently, only one kind of intermediate element is detected (no TimeStamp and HD part together), and we don't know the precise specification of MLP nor TimeStamp, so we consider next eleemnt is TimeStamp
+
+ //Filling
+ if ((Buffer[Buffer_Offset]==0x0B && Buffer[Buffer_Offset+1]==0x77)
+ || (Buffer[Buffer_Offset]==0x77 && Buffer[Buffer_Offset+1]==0x0B))
+ {
+ Header_Fill_Size(Core_Size_Get());
+ Header_Fill_Code(0, "syncframe");
+ return;
+ }
+
+ //MLP or TrueHD specific
+ int16u Size;
+ BS_Begin();
+ Skip_S1( 4, "CRC?");
+ Get_S2 (12, Size, "Size");
+ BS_End();
+ Skip_B2( "Timestamp?");
+
+ //Filling
+ if (Size<2)
+ {
+ Synched=false;
+ Size=2;
+ }
+
+ Size*=2;
+ Header_Fill_Size(Size);
+ Header_Fill_Code(1, "HD");
+}
+
+//---------------------------------------------------------------------------
+void File_Ac3::Data_Parse()
+{
+ if (Save_Buffer)
+ {
+ swap(Buffer, Save_Buffer);
+ swap(Buffer_Offset, Save_Buffer_Offset);
+ swap(Buffer_Size, Save_Buffer_Size);
+ }
+
+ //Parsing
+ switch (Element_Code)
+ {
+ case 0 :
+ FrameInfo=Info_Core.FrameInfo;
+ Frame_Count=Info_Core.Frame_Count;
+ Frame_Count_InThisBlock=Info_Core.Frame_Count_InThisBlock;
+ Frame_Count_NotParsedIncluded=Info_Core.Frame_Count_NotParsedIncluded;
+ Element_Info1C((FrameInfo.PTS!=(int64u)-1), _T("PTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/1000000)));
+ Element_Info1(Frame_Count);
+ Core();
+ Info_Core.FrameInfo=FrameInfo;
+ Info_Core.Frame_Count=Frame_Count;
+ Info_Core.Frame_Count_InThisBlock=Frame_Count_InThisBlock;
+ Info_Core.Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded;
+ break;
+ case 1 :
+ FrameInfo=Info_HD.FrameInfo;
+ Frame_Count=Info_HD.Frame_Count;
+ Frame_Count_InThisBlock=Info_HD.Frame_Count_InThisBlock;
+ Frame_Count_NotParsedIncluded=Info_HD.Frame_Count_NotParsedIncluded;
+ Element_Info1C((FrameInfo.PTS!=(int64u)-1), _T("PTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/1000000)));
+ Element_Info1(Frame_Count);
+ HD();
+ Info_HD.FrameInfo=FrameInfo;
+ Info_HD.Frame_Count=Frame_Count;
+ Info_HD.Frame_Count_InThisBlock=Frame_Count_InThisBlock;
+ Info_HD.Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded;
+ break;
+ case 2 : TimeStamp(); break;
+ default: ;
+ }
+
+ //Little Endian management
+ if (Save_Buffer)
+ {
+ delete[] Buffer;
+ Buffer=Save_Buffer; Save_Buffer=NULL;
+ Buffer_Offset=Save_Buffer_Offset;
+ Buffer_Size=Save_Buffer_Size;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Ac3::Core()
+{
+ //Parsing
+ int8u dialnorm=(int8u)-1, dialnorm2=(int8u)-1, compr=(int8u)-1, compr2=(int8u)-1, dynrng=(int8u)-1, dynrng2=(int8u)-1;
+ bool compre=false, compr2e=false, dynrnge=false, dynrng2e=false;
+ if (bsid<=0x08)
+ {
+ Element_Begin1("synchinfo");
+ Skip_B2( "syncword");
+ Skip_B2( "crc1");
+ BS_Begin();
+ Get_S1 (2, fscod, "fscod - Sample Rate Code"); Param_Info2(AC3_SamplingRate[fscod], " Hz");
+ Get_S1 (6, frmsizecod, "frmsizecod - Frame Size Code"); if (frmsizecod/2<19) {Param_Info2(AC3_BitRate[frmsizecod/2]*1000, " bps");}
+ Element_End0();
+ Element_Begin1("bsi");
+ Get_S1 (5, bsid, "bsid - Bit Stream Identification");
+ Get_S1 (3, bsmod, "bsmod - Bit Stream Mode"); Param_Info1(AC3_Mode[bsmod]);
+ Get_S1 (3, acmod, "acmod - Audio Coding Mode"); Param_Info1(AC3_ChannelPositions[acmod]);
+ if ((acmod&1) && acmod!=1) //central present
+ Skip_S1(2, "cmixlev - Center Mix Level");
+ if (acmod&4) //back present
+ Skip_S1(2, "surmixlev - Surround Mix Level");
+ if (acmod==2)
+ Get_S1 (2, dsurmod, "dsurmod - Dolby Surround Mode"); Param_Info1(AC3_Surround[dsurmod]);
+ Get_SB ( lfeon, "lfeon - Low Frequency Effects");
+ Get_S1 (5, dialnorm, "dialnorm - Dialogue Normalization");
+ Get_SB ( compre, "compre - Compression Gain Word Exists");
+ if (compre)
+ Get_S1 (8, compr, "compr - Compression Gain Word");
+ TEST_SB_SKIP( "langcode - Language Code Exists");
+ Skip_S1(8, "langcod - Language Code");
+ TEST_SB_END();
+ TEST_SB_SKIP( "audprodie - Audio Production Information Exists");
+ Skip_S1(8, "mixlevel - Mixing Level");
+ Skip_S1(2, "roomtyp - Room Type");
+ TEST_SB_END();
+ if (acmod==0) //1+1 mode
+ {
+ Get_S1 (5, dialnorm2, "dialnorm2 - Dialogue Normalization");
+ Get_SB ( compr2e, "compr2e - Compression Gain Word Exists");
+ if (compr2e)
+ Get_S1 (8, compr2, "compr2 - Compression Gain Word");
+ TEST_SB_SKIP( "langcod2e - Language Code Exists");
+ Skip_S1(8, "langcod2 - Language Code");
+ TEST_SB_END();
+ TEST_SB_SKIP( "audprodi2e - Audio Production Information Exists");
+ Skip_S1(8, "mixlevel2 - Mixing Level");
+ Skip_S1(2, "roomtyp2 - Room Type");
+ TEST_SB_END();
+ }
+ Skip_SB( "copyrightb - Copyright Bit");
+ Skip_SB( "origbs - Original Bit Stream");
+ TEST_SB_SKIP( "timecod1e");
+ Skip_S1(14, "timecod1");
+ TEST_SB_END();
+ TEST_SB_SKIP( "timecod2e");
+ Skip_S1(14, "timecod2");
+ TEST_SB_END();
+ TEST_SB_SKIP( "addbsie");
+ int8u addbsil;
+ Get_S1 (6, addbsil, "addbsil");
+ for (int8u Pos=0; Pos<=addbsil; Pos++) //addbsil+1 bytes
+ Skip_S1(8, "addbsi");
+ TEST_SB_END();
+ Element_End0();
+ Element_Begin1("audblk");
+ for (int8u Pos=0; Pos<AC3_Channels[acmod]; Pos++)
+ Skip_SB( "blksw - Block Switch Flag");
+ for (int8u Pos=0; Pos<AC3_Channels[acmod]; Pos++)
+ Skip_SB( "dithflag - Dither Flag");
+ Get_SB ( dynrnge, "dynrnge - Dynamic Range Gain Word Exists");
+ if (dynrnge)
+ Get_S1 (8, dynrng, "dynrng - Dynamic Range Gain Word");
+ if (acmod==0) //1+1 mode
+ {
+ Get_SB ( dynrng2e, "dynrng2e - Dynamic Range Gain Word Exists");
+ if (dynrng2e)
+ Get_S1 (8, dynrng2, "dynrng2 - Dynamic Range Gain Word");
+ }
+ BS_End();
+ Element_End0();
+ Skip_XX(Element_Size-Element_Offset, "audblk(continue)+5*audblk+auxdata+errorcheck");
+ }
+ else if (bsid>0x0A && bsid<=0x10)
+ {
+ Element_Begin1("synchinfo");
+ Skip_B2( "syncword");
+ Element_End0();
+ Element_Begin1("bsi");
+ int8u strmtyp;
+ BS_Begin();
+ Get_S1 ( 2, strmtyp, "strmtyp");
+ Skip_S1( 3, "substreamid");
+ Get_S2 (11, frmsiz, "frmsiz");
+ Get_S1 ( 2, fscod, "fscod");
+ if (fscod==3)
+ {
+ Get_S1 ( 2, fscod2, "fscod2");
+ numblkscod=3;
+ }
+ else
+ Get_S1 ( 2, numblkscod, "numblkscod");
+ Get_S1 (3, acmod, "acmod - Audio Coding Mode"); Param_Info1(AC3_ChannelPositions[acmod]);
+ Get_SB ( lfeon, "lfeon - Low Frequency Effects");
+ Get_S1 ( 5, bsid, "bsid - Bit Stream Identification");
+ Get_S1 ( 5, dialnorm, "dialnorm");
+ TEST_SB_GET(compre, "compre");
+ Get_S1 (8, compr, "compr");
+ TEST_SB_END();
+ if (acmod==0) //1+1 mode
+ {
+ Get_S1 (5, dialnorm2, "dialnorm2");
+ TEST_SB_GET(compr2e, "compr2e");
+ Get_S1 (8, compr2, "compr2");
+ TEST_SB_END();
+ }
+ if (strmtyp==1) //dependent stream
+ {
+ TEST_SB_SKIP( "chanmape");
+ Get_S2(16, chanmap, "chanmap");
+ TEST_SB_END();
+ }
+ Element_End0();
+ if (Data_BS_Remain()<17)
+ {
+ BS_End();
+ Trusted_IsNot("Not enough data");
+ }
+ else
+ {
+ Element_Begin1("errorcheck");
+ Skip_BS(Data_BS_Remain()-17, "bsi(continue)+audfrm+x*audblk+auxdata+errorcheck");
+ Skip_SB( "encinfo");
+ BS_End();
+ Skip_B2( "crc2");
+ Element_End0();
+ }
+ }
+
+ FILLING_BEGIN();
+ //Specific to first frame
+ if (Frame_Count==0)
+ {
+ FirstFrame_Dolby.dialnorm=dialnorm;
+ if (compre)
+ FirstFrame_Dolby.compr=compr;
+ if (dynrnge)
+ FirstFrame_Dolby.dynrng=dynrng;
+ FirstFrame_Dolby.compre=compre;
+ FirstFrame_Dolby.dynrnge=dynrnge;
+ if (acmod==0) //1+1 mode
+ {
+ FirstFrame_Dolby2.dialnorm=dialnorm2;
+ if (compr2e)
+ FirstFrame_Dolby2.compr=compr2;
+ if (dynrng2e)
+ FirstFrame_Dolby2.dynrng=dynrng2;
+ FirstFrame_Dolby2.compre=compr2e;
+ FirstFrame_Dolby2.dynrnge=dynrng2e;
+ }
+ }
+
+ //Stats
+ if (dialnorms.empty())
+ dialnorms.resize(32);
+ dialnorms[dialnorm]++;
+ if (compre)
+ {
+ if (comprs.empty())
+ comprs.resize(256);
+ comprs[compr]++;
+ }
+ if (dynrnge)
+ {
+ //Saving new value
+ dynrnge_Exists=true;
+ dynrng_Old=dynrng;
+ }
+ if (!dynrnge)
+ dynrng=0;
+ if (dynrngs.empty())
+ dynrngs.resize(256);
+ dynrngs[dynrng]++;
+ if (acmod==0) //1+1 mode
+ {
+ if (dialnorm2s.empty())
+ dialnorm2s.resize(32);
+ dialnorm2s[dialnorm2]++;
+ }
+
+ //Counting
+ if (Frame_Count==0)
+ {
+ Core_IsPresent=true;
+ PTS_Begin=FrameInfo.PTS;
+ }
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ FrameInfo.DUR=32000000;
+ if (fscod && AC3_SamplingRate[fscod])
+ {
+ FrameInfo.DUR*=48000;
+ FrameInfo.DUR/=AC3_SamplingRate[fscod];
+ }
+ if (FrameInfo.DTS!=(int64u)-1)
+ FrameInfo.DTS+=FrameInfo.DUR;
+ if (FrameInfo.PTS!=(int64u)-1)
+ FrameInfo.PTS=FrameInfo.DTS;
+
+ if (File_Offset+Buffer_Offset+Element_Size==File_Size)
+ Frame_Count_Valid=Frame_Count; //Finish frames in case of there are less than Frame_Count_Valid frames
+
+ //Filling
+ if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid)
+ {
+ Fill("AC-3");
+
+ //No more need data
+ if (!IsSub && MediaInfoLib::Config.ParseSpeed_Get()<1)
+ Finish("AC-3");
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Ac3::HD()
+{
+ Trusted=1000;
+
+ //Parsing
+ int32u Synch;
+ Peek_B3(Synch);
+ if (Synch==0xF8726F)
+ {
+ if (Buffer_Offset+28>Buffer_Size)
+ {
+ Trusted_IsNot("Not enough data");
+ return; //Need more data
+ }
+
+ //Testing
+ /* Not working
+ int16u CRC_16_Table_HD[256];
+ CRC16_Init(CRC_16_Table_HD, 0x002D);
+
+ int16u CRC_16=0x0000;
+ const int8u* CRC_16_Buffer=Buffer+Buffer_Offset;
+ while(CRC_16_Buffer<Buffer+Buffer_Offset+24)
+ {
+ CRC_16=(CRC_16<<8) ^ CRC_16_Table_HD[(CRC_16>>8)^(*CRC_16_Buffer)];
+ CRC_16_Buffer++;
+ }
+ CRC_16^=LittleEndian2int16u(Buffer+Buffer_Offset+24);
+ */
+
+ Element_Begin1("MajorSync");
+ Skip_B3( "Synch");
+ Get_B1 (HD_StreamType, "Stream type"); Param_Info1(AC3_HD_StreamType(HD_StreamType));
+
+ if (HD_StreamType==0xBA)
+ {
+ BS_Begin();
+ Get_S1 ( 4, HD_SamplingRate1, "Sampling rate"); Param_Info2(AC3_HD_SamplingRate(HD_SamplingRate1), " Hz");
+ Skip_S1( 8, "Unknown");
+ Get_S1 ( 5, HD_Channels1, "Channels (1st substream)"); Param_Info1(AC3_TrueHD_Channels(HD_Channels1)); Param_Info1(Ztring().From_Local(AC3_TrueHD_Channels_Positions(HD_Channels1)));
+ Skip_S1( 2, "Unknown");
+ Get_S2 (13, HD_Channels2, "Channels (2nd substream)"); Param_Info1(AC3_TrueHD_Channels(HD_Channels2)); Param_Info1(Ztring().From_Local(AC3_TrueHD_Channels_Positions(HD_Channels2)));
+ BS_End();
+ HD_Resolution2=HD_Resolution1=24; //Not sure
+ HD_SamplingRate2=HD_SamplingRate1;
+ }
+ else if (HD_StreamType==0xBB)
+ {
+ BS_Begin();
+ Get_S1 ( 4, HD_Resolution1, "Resolution1"); Param_Info2(AC3_MLP_Resolution[HD_Resolution1], " bits");
+ Get_S1 ( 4, HD_Resolution2, "Resolution2"); Param_Info2(AC3_MLP_Resolution[HD_Resolution2], " bits");
+ Get_S1 ( 4, HD_SamplingRate1, "Sampling rate"); Param_Info2(AC3_HD_SamplingRate(HD_SamplingRate1), " Hz");
+ Get_S1 ( 4, HD_SamplingRate2, "Sampling rate"); Param_Info2(AC3_HD_SamplingRate(HD_SamplingRate2), " Hz");
+ Skip_S1(11, "Unknown");
+ Get_S1 ( 5, HD_Channels1, "Channels"); Param_Info1(AC3_MLP_Channels[HD_Channels1]);
+ BS_End();
+ HD_Channels2=HD_Channels1;
+ }
+ else
+ {
+ Skip_XX(Element_Size-Element_Offset, "Data");
+ return;
+ }
+
+ Skip_B6( "Unknown");
+ BS_Begin();
+ Get_SB ( HD_IsVBR, "Is VBR");
+ Get_S2 (15, HD_BitRate_Max, "Maximum bitrate"); Param_Info2((HD_BitRate_Max*(AC3_HD_SamplingRate(HD_SamplingRate2)?AC3_HD_SamplingRate(HD_SamplingRate2):AC3_HD_SamplingRate(HD_SamplingRate1))+8)>>4, " bps");
+ Get_S1 ( 4, HD_SubStreams_Count, "SubStreams_Count");
+ Skip_S1( 4, "Unknown");
+ BS_End();
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ Element_End0();
+
+ FILLING_BEGIN();
+ HD_MajorSync_Parsed=true;
+
+ if (HD_SubStreams_Count==1 && HD_StreamType==0xBB) //MLP with only 1 stream
+ {
+ HD_Resolution2=HD_Resolution1;
+ HD_SamplingRate2=HD_SamplingRate1;
+ }
+ FILLING_END();
+ }
+
+ /*
+ if (HD_MajorSync_Parsed)
+ {
+ Element_Begin1("Sizes");
+ std::vector<int16u> Sizes;
+ for (int8u Pos=0; Pos<HD_SubStreams_Count; Pos++)
+ {
+ Element_Begin1("Size");
+ int16u Size;
+ bool HD_Unknown1_Present, HD_NoRestart, HD_ExtraParity;
+ BS_Begin();
+ Get_SB ( HD_Unknown1_Present, "Unknown present"); //Only TrueHD
+ Get_SB ( HD_NoRestart, "No restart"); //Not present if MajorSync, present if no MajorSync
+ Get_SB ( HD_ExtraParity, "Extra parity information");
+ Skip_SB( "Unknown");
+ Get_S2 (12, Size, "Size");
+ BS_End();
+ if (HD_Unknown1_Present)
+ Skip_B2( "Unknown");
+ Sizes.push_back(Size);
+ Element_End0();
+ }
+ Element_End0();
+
+ int64u Element_Offset_Begin=Element_Offset;
+ for (int8u Pos=0; Pos<HD_SubStreams_Count; Pos++)
+ {
+ Element_Begin1("Block");
+ bool DecodingParameterBlockPresent;
+ BS_Begin();
+ Get_SB (DecodingParameterBlockPresent, "Decoding parameter block is present");
+ if (DecodingParameterBlockPresent)
+ {
+ TEST_SB_SKIP( "Restart header");
+ int16u SyncWord;
+ int8u max_matrix_channel;
+ Get_S2(13, SyncWord, "SyncWord");
+ if (SyncWord==0x18F5)
+ {
+ Skip_SB( "noise_type"); //Only for TrueHD
+ Skip_S2(16, "Output timestamp");
+ Skip_S1( 4, "min_channel");
+ Skip_S1( 4, "max_channel");
+ Get_S1 ( 4, max_matrix_channel, "max_matrix_channel");
+ Skip_S1( 4, "noise_shift");
+ Skip_S3(23, "noisegen_seed");
+ Skip_S3(19, "unknown");
+ Skip_SB( "data_check_present");
+ Skip_S1( 8, "lossless_check");
+ Skip_S2(16, "unknown");
+ for (int8u matrix_channel=0; matrix_channel<max_matrix_channel; matrix_channel++)
+ Skip_S1(6, "ch_assign");
+ Skip_S1( 8, "checksum");
+ }
+ TEST_SB_END();
+ }
+ BS_End();
+ Skip_XX(Element_Offset_Begin+Sizes[Pos]*2-Element_Offset, "Data");
+ Element_End0();
+ }
+ }
+ else
+ Skip_XX(Element_Size-Element_Offset, "Waiting for MajorSync...");
+ */
+ Skip_XX(Element_Size-Element_Offset, "(Data)");
+
+ FILLING_BEGIN_PRECISE();
+ if (Frame_Count==0)
+ PTS_Begin=FrameInfo.PTS;
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ FrameInfo.DUR=833333;
+ int64u HD_SamplingRate=AC3_HD_SamplingRate(HD_SamplingRate1);
+ if (HD_SamplingRate && HD_SamplingRate!=48000)
+ {
+ FrameInfo.DUR*=48000;
+ FrameInfo.DUR/=HD_SamplingRate;
+ }
+ if (FrameInfo.DTS!=(int64u)-1)
+ FrameInfo.DTS+=FrameInfo.DUR;
+ if (FrameInfo.PTS!=(int64u)-1)
+ FrameInfo.PTS=FrameInfo.DTS;
+
+ //Filling
+ if (!Status[IsFilled] && !Core_IsPresent && Frame_Count>=Frame_Count_Valid*32)
+ {
+ Fill("AC-3");
+
+ //No more need data
+ if (!IsSub && MediaInfoLib::Config.ParseSpeed_Get()<1)
+ Finish("AC-3");
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Ac3::TimeStamp()
+{
+ //Parsing
+ int8u H1, H2, M1, M2, S1, S2, F1, F2;
+ Skip_B2( "Unknown");
+ BS_Begin();
+ Skip_S1(8, "H");
+ Get_S1 (4, H1, "H");
+ Get_S1( 4, H2, "H");
+ Skip_S1(8, "M");
+ Get_S1 (4, M1, "M");
+ Get_S1( 4, M2, "M");
+ Skip_S1(8, "S");
+ Get_S1 (4, S1, "S");
+ Get_S1( 4, S2, "S");
+ Skip_S1(8, "F");
+ Get_S1 (4, F1, "F");
+ Get_S1( 4, F2, "F");
+ BS_End();
+ Skip_B2( "Byte offset related to frame");
+ Skip_B4( "Unknown");
+
+ FILLING_BEGIN();
+ float64 Temp=H1*10*60*60
+ + H2 *60*60
+ + M1 *10*60
+ + M2 *60
+ + S1 *10
+ + S2
+ + (F1*10+F2)/29.97; //No idea about where is the frame rate
+ #ifdef MEDIAINFO_TRACE
+ Element_Info1(Ztring::ToZtring(H1)+Ztring::ToZtring(H2)+_T(':')
+ + Ztring::ToZtring(M1)+Ztring::ToZtring(M2)+_T(':')
+ + Ztring::ToZtring(S1)+Ztring::ToZtring(S2)+_T(':')
+ + Ztring::ToZtring(F1)+Ztring::ToZtring(F2));
+ #endif //MEDIAINFO_TRACE
+ if (Frame_Count==0)
+ TimeStamp_Content=Temp;
+ TimeStamp_IsParsing=false;
+ TimeStamp_Parsed=true;
+
+ if (!TimeStamp_DropFrame_IsValid && M2 && !S2 && !S1 && !F1)
+ {
+ //If drop frame configuration, frames 0 and 1 are dropped for every minutes except 00 10 20 30 40 50
+ switch (F2)
+ {
+ case 0 :
+ case 1 :
+ TimeStamp_DropFrame_IsValid=true;
+ TimeStamp_DropFrame_Content=false;
+ break;
+ case 2 :
+ if (Frame_Count>=2)
+ {
+ TimeStamp_DropFrame_IsValid=true;
+ TimeStamp_DropFrame_Content=true;
+ }
+ default: ;
+ }
+
+ if (TimeStamp_DropFrame_IsValid)
+ Frame_Count_Valid=32; //Reset
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Ac3::dac3()
+{
+ BS_Begin();
+ Get_S1 (2, fscod, "fscod");
+ Get_S1 (5, bsid, "bsid");
+ Get_S1 (3, bsmod, "bsmod");
+ Get_S1 (3, acmod, "acmod");
+ Get_SB ( lfeon, "lfeon");
+ Get_S1 (5, frmsizecod, "bit_rate_code"); frmsizecod*=2;
+ Skip_S1(5, "reserved");
+ BS_End();
+
+ MustParse_dac3=false;
+ dxc3_Parsed=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Ac3::dec3()
+{
+ //Parsing
+ BS_Begin();
+ int8u num_ind_sub;
+ Skip_S2(13, "data_rate");
+ Get_S1 ( 3, num_ind_sub, "num_ind_sub");
+ for (int8u Pos=0; Pos<num_ind_sub; Pos++)
+ {
+ Element_Begin1("independent substream");
+ int8u num_dep_sub;
+ Get_S1 (2, fscod, "fscod");
+ Get_S1 (5, bsid, "bsid");
+ Get_S1 (3, bsmod, "bsmod");
+ Get_S1 (3, acmod, "acmod");
+ Get_SB ( lfeon, "lfeon");
+ Skip_S1(3, "reserved");
+ Get_S1 (4, num_dep_sub, "num_dep_sub");
+ if (num_dep_sub>0)
+ Skip_S2(9, "chan_loc");
+ else
+ Skip_SB( "reserved");
+ Element_End0();
+ }
+ BS_End();
+
+ MustParse_dec3=false;
+ dxc3_Parsed=true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Ac3::FrameSynchPoint_Test()
+{
+ if (Save_Buffer)
+ return true; //Test already made by Synchronize()
+
+ if (Buffer[Buffer_Offset ]==0x0B
+ && Buffer[Buffer_Offset+1]==0x77) //AC-3
+ {
+ int8u bsid=CC1(Buffer+Buffer_Offset+5)>>3;
+ int16u Size=0;
+ if (bsid<=0x08)
+ {
+ int8u fscod =(CC1(Buffer+Buffer_Offset+4)>>6)&0x03;
+ int8u frmsizecod=(CC1(Buffer+Buffer_Offset+4) )&0x3F;
+ Size=AC3_FrameSize_Get(frmsizecod, fscod);
+ }
+ else if (bsid>0x0A && bsid<=0x10)
+ {
+ int16u frmsiz=CC2(Buffer+Buffer_Offset+2)&0x07FF;
+ Size=2+frmsiz*2;
+ }
+ if (Size>=6)
+ {
+ if (Buffer_Offset+Size>Buffer_Size)
+ return false; //Need more data
+ if (CRC_Compute(Size))
+ {
+ Synched=true;
+ return true;
+ }
+ }
+ }
+
+ if (Buffer[Buffer_Offset+0]==0x77
+ && Buffer[Buffer_Offset+1]==0x0B) //AC-3 LE
+ {
+ int8u bsid=CC1(Buffer+Buffer_Offset+4)>>3;
+ int16u Size=0;
+ if (bsid<=0x08)
+ {
+ int8u fscod =(CC1(Buffer+Buffer_Offset+5)>>6)&0x03;
+ int8u frmsizecod=(CC1(Buffer+Buffer_Offset+5) )&0x3F;
+ Size=AC3_FrameSize_Get(frmsizecod, fscod);
+ }
+ else if (bsid>0x0A && bsid<=0x10)
+ {
+ int16u frmsiz=LittleEndian2int16u(Buffer+Buffer_Offset+2)&0x07FF;
+ Size=2+frmsiz*2;
+ }
+ if (Size>=6)
+ {
+ if (Buffer_Offset+Size>Buffer_Size)
+ return false; //Need more data
+
+ Save_Buffer=Buffer;
+ Save_Buffer_Offset=Buffer_Offset;
+ Save_Buffer_Size=Buffer_Size;
+
+ //Exception handling
+ try
+ {
+ int8u* Buffer_Little=new int8u[Size];
+ for (size_t Pos=0; Pos+1<Size; Pos+=2)
+ {
+ Buffer_Little[Pos+1]=Save_Buffer[Buffer_Offset+Pos ];
+ Buffer_Little[Pos ]=Save_Buffer[Buffer_Offset+Pos+1];
+ }
+ Buffer=Buffer_Little;
+ Buffer_Offset=0;
+ Buffer_Size=Size;
+
+ Synched=CRC_Compute(Size);
+
+ if (Synched)
+ {
+ swap(Buffer, Save_Buffer);
+ swap(Buffer_Offset, Save_Buffer_Offset);
+ swap(Buffer_Size, Save_Buffer_Size);
+
+ return true;
+ }
+
+ delete[] Buffer_Little;
+ }
+ catch(...)
+ {
+ }
+ Buffer=Save_Buffer; Save_Buffer=NULL;
+ Buffer_Offset=Save_Buffer_Offset;
+ Buffer_Size=Save_Buffer_Size;
+ }
+ }
+
+ if (HD_MajorSync_Parsed
+ || (Buffer[Buffer_Offset+4]==0xF8
+ && Buffer[Buffer_Offset+5]==0x72
+ && Buffer[Buffer_Offset+6]==0x6F
+ && (Buffer[Buffer_Offset+7]&0xFE)==0xBA)) //TrueHD or MLP
+ {
+ HD_IsPresent=true;
+ Synched=true;
+ return true;
+ }
+
+ Synched=false;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Ac3::CRC_Compute(size_t Size)
+{
+ int16u CRC_16=0x0000;
+ const int8u* CRC_16_Buffer=Buffer+Buffer_Offset+2; //After syncword
+ const int8u* CRC_16_Buffer_5_8=Buffer+Buffer_Offset+(((Size>>2)+(Size>>4))<<1); //Magic formula to meet 5/8 frame size from Dolby
+ const int8u* CRC_16_Buffer_EndMinus3=Buffer+Buffer_Offset+Size-3; //End of frame minus 3
+ const int8u* CRC_16_Buffer_End=Buffer+Buffer_Offset+Size; //End of frame
+ while(CRC_16_Buffer<CRC_16_Buffer_End)
+ {
+ CRC_16=(CRC_16<<8) ^ CRC_16_Table[(CRC_16>>8)^(*CRC_16_Buffer)];
+ CRC_16_Buffer++;
+
+ //CRC bytes inversion
+ if (CRC_16_Buffer==CRC_16_Buffer_EndMinus3 && ((*CRC_16_Buffer)&0x01)) //CRC inversion bit
+ {
+ CRC_16=(CRC_16<<8) ^ CRC_16_Table[(CRC_16>>8)^(~(*CRC_16_Buffer))];
+ CRC_16_Buffer++;
+ CRC_16=(CRC_16<<8) ^ CRC_16_Table[(CRC_16>>8)^(~(*CRC_16_Buffer))];
+ CRC_16_Buffer++;
+ }
+
+ //5/8 intermediate test
+ if (CRC_16_Buffer==CRC_16_Buffer_5_8 && bsid<=0x08 && CRC_16!=0x0000)
+ break;
+ }
+
+ return (CRC_16==0x0000);
+}
+
+//---------------------------------------------------------------------------
+size_t File_Ac3::Core_Size_Get()
+{
+ BigEndian=Buffer[Buffer_Offset]==0x0B;
+
+ int16u Size=(int16u)-1;
+ bsid=(Buffer[(size_t)(Buffer_Offset+(BigEndian?5:4))]&0xF8)>>3;
+ if (bsid<=0x08)
+ {
+ fscod =(Buffer[(size_t)(Buffer_Offset+(BigEndian?4:5))]&0xC0)>>6;
+ frmsizecod= Buffer[(size_t)(Buffer_Offset+(BigEndian?4:5))]&0x3F;
+
+ //Filling
+ fscods[fscod]++;
+ frmsizecods[frmsizecod]++;
+ Size=AC3_FrameSize_Get(frmsizecod, fscod);
+ }
+ else if (bsid>0x0A && bsid<=0x10)
+ {
+ frmsiz =((int16u)(Buffer[(size_t)(Buffer_Offset+2)]&0x07)<<8)
+ | ( Buffer[(size_t)(Buffer_Offset+3)] );
+
+ //Filling
+ Size=2+frmsiz*2;
+ }
+
+ return Size;
+}
+
+//---------------------------------------------------------------------------
+size_t File_Ac3::HD_Size_Get()
+{
+ size_t Size=BigEndian2int16u(Buffer+Buffer_Offset)&0x0FFF;
+ Size*=2;
+
+ return Size;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_AC3_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ac3.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ac3.h
new file mode 100644
index 000000000..596a8e51b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ac3.h
@@ -0,0 +1,175 @@
+// File_Ac3 - Info for AC3 files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Ac3H
+#define MediaInfo_Ac3H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Ac3
+//***************************************************************************
+
+class File_Ac3 : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ bool MustParse_dac3;
+ bool MustParse_dec3;
+ bool CalculateDelay;
+
+ //Constructor/Destructor
+ File_Ac3();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ void Synched_Init();
+ bool Synched_Test();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test();
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+ void Read_Buffer_Unsynched();
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Core();
+ void HD();
+ void TimeStamp();
+ void dac3();
+ void dec3();
+ bool FrameSynchPoint_Test();
+ bool CRC_Compute(size_t Size);
+ size_t Core_Size_Get();
+ size_t HD_Size_Get();
+
+ //Buffer
+ const int8u* Save_Buffer;
+ size_t Save_Buffer_Offset;
+ size_t Save_Buffer_Size;
+
+ //Temp
+ struct dolby
+ {
+ int8u dialnorm;
+ int8u compr;
+ int8u dynrng; //This is only the first occurence of aufblk
+ bool compre;
+ bool dynrnge; //This is only the first occurence of aufblk
+
+ dolby()
+ {
+ dialnorm=0;
+ compre=false;
+ dynrnge=false;
+ }
+ };
+ dolby FirstFrame_Dolby;
+ dolby FirstFrame_Dolby2;
+ std::vector<int64u> dialnorms;
+ std::vector<int64u> dialnorm2s;
+ std::vector<int64u> comprs;
+ std::vector<int64u> compr2s;
+ std::vector<int64u> dynrngs;
+ std::vector<int64u> dynrng2s;
+ std::map<int8u, int64u> fscods;
+ std::map<int8u, int64u> frmsizecods;
+ struct frame_info2
+ {
+ frame_info FrameInfo;
+ int64u Frame_Count;
+ int64u Frame_Count_InThisBlock;
+ int64u Frame_Count_NotParsedIncluded;
+
+ frame_info2()
+ {
+ Frame_Count=0;
+ Frame_Count_InThisBlock=0;
+ Frame_Count_NotParsedIncluded=(int64u)-1;
+ }
+ };
+ frame_info2 Info_Core;
+ frame_info2 Info_HD;
+ int16u chanmap;
+ int16u frmsiz;
+ int16u HD_BitRate_Max;
+ int16u HD_Channels2;
+ int8u fscod;
+ int8u fscod2;
+ int8u frmsizecod;
+ int8u bsid;
+ int8u bsmod;
+ int8u acmod;
+ int8u dsurmod;
+ int8u numblkscod;
+ int8u HD_StreamType;
+ int8u HD_SubStreams_Count;
+ int8u HD_SamplingRate1;
+ int8u HD_SamplingRate2;
+ int8u HD_Channels1;
+ int8u HD_Resolution1;
+ int8u HD_Resolution2;
+ int8u dynrng_Old;
+ bool lfeon;
+ bool dxc3_Parsed;
+ bool HD_MajorSync_Parsed;
+ bool HD_NoRestart;
+ bool HD_ExtraParity;
+ bool HD_IsVBR;
+ bool Core_IsPresent;
+ bool HD_IsPresent;
+ bool dynrnge_Exists;
+ bool TimeStamp_IsPresent;
+ bool TimeStamp_IsParsing;
+ bool TimeStamp_Parsed;
+ bool TimeStamp_DropFrame_IsValid;
+ bool TimeStamp_DropFrame_Content;
+ bool BigEndian;
+ float64 TimeStamp_Content;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Adpcm.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Adpcm.cpp
new file mode 100644
index 000000000..70f38a29c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Adpcm.cpp
@@ -0,0 +1,89 @@
+// File_Adpcm - Info for ADPCM files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_ADPCM_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Adpcm.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Adpcm::Read_Buffer_Continue()
+{
+ //It is impossible to detect... Default is no detection, only filling
+
+ //Filling
+ Accept("ADPCM");
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_General, 0, Audio_Format, "ADPCM");
+ Fill(Stream_General, 0, Audio_Codec, "ADPCM");
+ Ztring Profile, Firm;
+ if (Codec==_T("alaw")) {Profile=_T("A-Law");}
+ else if (Codec==_T("ulaw")) {Profile=_T("U-Law");}
+ else if (Codec==_T("ima4")) { Firm=_T("IMA");}
+ else if (Codec==_T("6")) {Profile=_T("A-Law");}
+ else if (Codec==_T("7")) {Profile=_T("U-Law");}
+ else if (Codec==_T("102")) {Profile=_T("A-Law");}
+ else if (Codec==_T("171")) {Profile=_T("U-Law"); Firm=_T("Unisys");}
+ else if (Codec==_T("172")) {Profile=_T("A-Law"); Firm=_T("Unisys");}
+
+ if (!Profile.empty())
+ Fill(Stream_Audio, 0, Audio_Format_Profile, Profile);
+ if (!Firm.empty())
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Settings, Firm);
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Firm, Firm);
+ Fill(Stream_Audio, 0, Audio_Codec_Settings, Firm);
+ Fill(Stream_Audio, 0, Audio_Codec_Settings_Firm, Firm);
+ }
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR");
+
+ //No more need data
+ Finish("ADPCM");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_ADPCM_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Adpcm.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Adpcm.h
new file mode 100644
index 000000000..c14bdd971
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Adpcm.h
@@ -0,0 +1,53 @@
+// File_Adpcm - Info for ADPCM files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about ADPCM files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_AdpcmH
+#define MediaInfo_File_AdpcmH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Adpcm
+//***************************************************************************
+
+class File_Adpcm : public File__Analyze
+{
+public :
+ //In
+ ZenLib::Ztring Codec;
+
+protected :
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aes3.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aes3.cpp
new file mode 100644
index 000000000..134594468
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aes3.cpp
@@ -0,0 +1,1880 @@
+// File_Aes3 - Info for AES3 packetized streams
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// AES3 PCM and non-PCM (SMPTE 337M)
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AES3_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Aes3.h"
+#if defined(MEDIAINFO_AAC_YES)
+ #include "MediaInfo/Audio/File_Aac.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_DOLBYE_YES)
+ #include "MediaInfo/Audio/File_DolbyE.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#if MEDIAINFO_SEEK
+ #include "MediaInfo/MediaInfo_Internal.h"
+#endif //MEDIAINFO_SEEK
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Aes3_ChannelsPositions(int8u number_channels)
+{
+ switch (number_channels)
+ {
+ case 0 : return "Front: L R"; //2 channels
+ case 1 : return "Front: L C R, LFE"; //4 channels
+ case 2 : return "Front: L C R, Side: L R, LFE"; //6 channels
+ case 3 : return "Front: L C R, Side: L R, Back: L R, LFE"; //8 channels
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Aes3_ChannelsPositions2(int8u number_channels)
+{
+ switch (number_channels)
+ {
+ case 0 : return "2/0/0.0"; //2 channels
+ case 1 : return "3/0/0.1"; //4 channels
+ case 2 : return "3/2/0.1"; //6 channels
+ case 3 : return "3/2/2.1"; //8 channels
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Aes3_NonPCM_data_type[32]= //SMPTE 338M
+{
+ "",
+ "AC-3",
+ "Time stamp",
+ "Pause",
+ "MPEG Audio",
+ "MPEG Audio",
+ "MPEG Audio",
+ "AAC",
+ "MPEG Audio",
+ "MPEG Audio",
+ "AAC",
+ "AAC",
+ "",
+ "",
+ "",
+ "",
+ "E-AC-3",
+ "",
+ "",
+ "AAC",
+ "",
+ "E-AC-3",
+ "",
+ "",
+ "",
+ "",
+ "Utility",
+ "KLV",
+ "Dolby E",
+ "Captioning",
+ "User defined",
+ "",
+};
+
+//---------------------------------------------------------------------------
+stream_t Aes3_NonPCM_data_type_StreamKind[32]= //SMPTE 338M
+{
+ Stream_Max,
+ Stream_Audio,
+ Stream_Max,
+ Stream_Max,
+ Stream_Audio,
+ Stream_Audio,
+ Stream_Audio,
+ Stream_Max,
+ Stream_Audio,
+ Stream_Audio,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Max,
+ Stream_Menu,
+ Stream_Audio,
+ Stream_Text,
+ Stream_Max,
+ Stream_Max,
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Aes3::File_Aes3()
+:File__Analyze()
+{
+ //Configuration
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Aes3;
+ #endif //MEDIAINFO_EVENTS
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=32*1024;
+ PTS_DTS_Needed=true;
+ FrameInfo.DTS=0;
+ IsRawStream=true;
+
+ //In
+ SampleRate=0;
+ ByteSize=0;
+ QuantizationBits=0;
+ ChannelCount=0;
+ From_Raw=false;
+ From_MpegPs=false;
+ From_Aes3=false;
+ IsAes3=false;
+ Endianness=0x00;
+
+ //Out
+ FrameRate=0;
+
+ //Temp
+ Frame_Count=0;
+ Frame_Size=(int64u)-1;
+ Frame_Duration=(int64u)-1;
+ IsPcm_Frame_Count=0;
+ NotPCM_SizePerFrame=(int64u)-1;
+ data_type=(int8u)-1;
+ IsParsingNonPcm=false;
+ IsPcm=false;
+
+ //Parser
+ Parser=NULL;
+
+ #if MEDIAINFO_SEEK
+ Duration_Detected=false;
+ #endif //MEDIAINFO_SEEK
+}
+
+//---------------------------------------------------------------------------
+File_Aes3::~File_Aes3()
+{
+ delete Parser; //Parser=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aes3::Streams_Accept()
+{
+ Fill(Stream_General, 0, General_Format, "AES3");
+}
+
+//---------------------------------------------------------------------------
+void File_Aes3::Streams_Fill()
+{
+ int64u BitRate=(int64u)-1;
+ int64u SamplingRate=(int64u)-1;
+ if (Frame_Count && FrameInfo.PTS!=(int32u)-1 && PTS_Begin!=(int64u)-1 && FrameInfo.PTS!=PTS_Begin)
+ {
+ //Rounding
+ BitRate=Frame_Size*8*1000*1000000*(Frame_Count-1)/(FrameInfo.PTS-PTS_Begin);
+ SamplingRate=BitRate*(4+bits_per_sample)/(5+bits_per_sample)/(2+2*number_channels)/(16+4*bits_per_sample);
+ if (SamplingRate> 7840 && SamplingRate< 8160) SamplingRate= 8000;
+ if (SamplingRate> 15680 && SamplingRate< 16320) SamplingRate= 16000;
+ if (SamplingRate> 31360 && SamplingRate< 32640) SamplingRate= 32000;
+ if (SamplingRate> 62720 && SamplingRate< 65280) SamplingRate= 64000;
+ if (SamplingRate> 10804 && SamplingRate< 11246) SamplingRate= 11025;
+ if (SamplingRate> 21609 && SamplingRate< 22491) SamplingRate= 22050;
+ if (SamplingRate> 43218 && SamplingRate< 44982) SamplingRate= 44100;
+ if (SamplingRate> 86436 && SamplingRate< 89964) SamplingRate= 88200;
+ if (SamplingRate> 11760 && SamplingRate< 12240) SamplingRate= 12000;
+ if (SamplingRate> 23520 && SamplingRate< 24480) SamplingRate= 24000;
+ if (SamplingRate> 47040 && SamplingRate< 48960) SamplingRate= 48000;
+ if (SamplingRate> 94080 && SamplingRate< 97920) SamplingRate= 96000;
+ if (SamplingRate>188160 && SamplingRate<195840) SamplingRate=192000;
+ BitRate=SamplingRate/(4+bits_per_sample)*(5+bits_per_sample)*(2+2*number_channels)*(16+4*bits_per_sample);
+ }
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR", Unlimited, true, true);
+
+ if (Parser && Parser->Status[IsAccepted] && !Parser->Status[IsFilled])
+ {
+ Fill(Parser);
+ Merge(*Parser);
+ }
+ else if (data_type!=(int8u)-1)
+ {
+ if (Retrieve(Stream_Audio, 0, Audio_Format).empty() && Aes3_NonPCM_data_type_StreamKind[data_type]!=Stream_Max)
+ {
+ Stream_Prepare(Aes3_NonPCM_data_type_StreamKind[data_type]);
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Format), Aes3_NonPCM_data_type[data_type]);
+ }
+
+ if (IsSub)
+ Fill(Stream_Audio, 0, Audio_MuxingMode, "AES3", Unlimited, true, true);
+ }
+ else if (IsPcm)
+ {
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ Fill(Stream_Audio, 0, Audio_Codec, "PCM");
+ switch (Endianness)
+ {
+ case 'B' : Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, "Big"); break;
+ case 'L' : Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, "Little"); break;
+ default : ;
+ }
+ }
+
+ if (Count_Get(Stream_Audio))
+ {
+ if (Count_Get(Stream_Audio)==1 && Retrieve(Stream_Audio, 0, Audio_BitRate).empty() && BitRate!=(int64u)-1)
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate);
+
+ if (!IsSub && NotPCM_SizePerFrame!=(int64u)-1 && NotPCM_SizePerFrame && FrameRate)
+ {
+ int64u BitRate=float64_int64s(NotPCM_SizePerFrame*8*FrameRate);
+ int64u SamplingRate=Retrieve(Stream_Audio, 0, Audio_SamplingRate).To_int64u();
+ if (Container_Bits && SamplingRate)
+ {
+ float Ratio=((float)BitRate)/(Container_Bits*SamplingRate*2);
+ if (Ratio>=0.99 && Ratio<=1.01)
+ BitRate=Container_Bits*SamplingRate*2;
+ }
+ Fill(Stream_General, 0, General_OverallBitRate, BitRate);
+ }
+ }
+ else if (From_MpegPs)
+ {
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ Fill(Stream_Audio, 0, Audio_MuxingMode, "AES3");
+ Fill(Stream_Audio, 0, Audio_Codec, "AES3");
+ Fill(Stream_Audio, 0, Audio_Channel_s_, 2+2*number_channels);
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, Aes3_ChannelsPositions(number_channels));
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, Aes3_ChannelsPositions2(number_channels));
+ Fill(Stream_Audio, 0, Audio_BitDepth, 16+4*bits_per_sample);
+ if (FrameInfo.PTS!=(int64u)-1 && PTS_Begin!=(int64u)-1 && FrameInfo.PTS!=PTS_Begin)
+ {
+ Fill(Stream_Audio, 0, Audio_SamplingRate, SamplingRate);
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate);
+ }
+ }
+ else
+ {
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "AES3");
+ }
+
+ if (!From_Raw && !From_Aes3 && !IsPcm && IsParsingNonPcm)
+ {
+ for (size_t Pos=0; Pos<Count_Get(Stream_Audio); Pos++)
+ {
+ switch (Endianness)
+ {
+ case 'B' : Fill(Stream_Audio, Pos, Audio_Format_Settings_Endianness, "Big"); break;
+ case 'L' : Fill(Stream_Audio, Pos, Audio_Format_Settings_Endianness, "Little"); break;
+ default : ;
+ }
+ Fill(Stream_Audio, Pos, Audio_Format_Settings_Mode, Container_Bits);
+ if (Retrieve(Stream_Audio, Pos, Audio_BitDepth).empty())
+ Fill(Stream_Audio, Pos, Audio_BitDepth, Stream_Bits);
+ }
+ }
+
+ if (From_Raw)
+ {
+ for (size_t Pos=0; Pos<Count_Get(Stream_Audio); Pos++)
+ Fill(Stream_Audio, Pos, Audio_Format_Settings_Endianness, "Little");
+ }
+
+ if (!IsSub && File_Size!=(int64u)-1 && Frame_Size!=(int64u)-1)
+ {
+ for (size_t Pos=0; Pos<Count_Get(Stream_Audio); Pos++)
+ Fill(Stream_Audio, Pos, Audio_FrameCount, File_Size/Frame_Size);
+ Fill(Stream_General, 0, General_DataSize, ((File_Size-Buffer_TotalBytes_FirstSynched)/Frame_Size)*Frame_Size);
+ }
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aes3::Read_Buffer_Init()
+{
+ if (From_MpegPs)
+ {
+ MustSynchronize=false;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aes3::Read_Buffer_Continue()
+{
+ if (Frame_Count==0)
+ {
+ PTS_Begin=FrameInfo.PTS;
+ Frame_Size=Element_Size;
+ }
+
+ if (IsPcm)
+ {
+ #if MEDIAINFO_DEMUX
+ if (ByteSize)
+ Element_Size=(Buffer_Size/ByteSize)*ByteSize;
+ else
+ Element_Size=Buffer_Size;
+ if (Demux_UnpacketizeContainer && !(!IsAes3 && StreamIDs_Size>=2 && ParserIDs[StreamIDs_Size-2]==MediaInfo_Parser_ChannelGrouping))
+ {
+ FrameInfo.PTS=FrameInfo.DTS;
+ if (SampleRate && ByteSize)
+ FrameInfo.DUR=Element_Size*1000000000/(SampleRate*ByteSize);
+ Demux_random_access=true;
+ Element_Code=(int64u)-1;
+ Demux(Buffer, (size_t)Element_Size, ContentType_MainStream);
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ Skip_XX(Element_Size, "Data");
+
+ Frame_Count_InThisBlock++;
+ if (IsPcm_Frame_Count)
+ {
+ Frame_Count_InThisBlock++; //If IsPcm_Frame_Count is set, 2 frames were needed in order to detect PCM
+ IsPcm_Frame_Count=0;
+ }
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ #if MEDIAINFO_DEMUX
+ if (FrameInfo.DTS!=(int64u)-1 && FrameInfo.DUR!=(int64u)-1)
+ {
+ FrameInfo.DTS+=FrameInfo.DUR;
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ return;
+ }
+ if (From_Raw)
+ {
+ Raw();
+ return;
+ }
+ if (From_MpegPs)
+ {
+ Frame_FromMpegPs();
+ return;
+ }
+
+ //Special cases
+ if (!From_Aes3 && !Status[IsAccepted])
+ {
+ Synchronize();
+ if (!IsParsingNonPcm)
+ {
+ IsPcm_Frame_Count++;
+ Buffer_Offset=0;
+ if ((IsSub && Buffer_Size>32*1024) || (IsSub && IsPcm_Frame_Count>1) || ChannelCount==1)
+ {
+ //Raw PCM
+ MustSynchronize=false;
+ IsPcm=true;
+ Read_Buffer_Continue();
+
+ Accept("PCM");
+ Finish();
+
+ return;
+ }
+
+ Element_WaitForMoreData();
+ return;
+ }
+ }
+
+ if (!From_Aes3 && Frame_Count==0)
+ {
+ //Guard band
+ Buffer_Offset_Temp=Buffer_Offset;
+ if (ByteSize==6)
+ {
+ while(Buffer_Offset_Temp+6<=Buffer_Size && CC3(Buffer+Buffer_Offset_Temp)==0x000000)
+ Buffer_Offset_Temp+=6;
+
+ if (Buffer_Offset_Temp+6>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ }
+ else if (ByteSize==8)
+ {
+ while(Buffer_Offset_Temp+8<=Buffer_Size && CC4(Buffer+Buffer_Offset_Temp)==0x00000000)
+ Buffer_Offset_Temp+=8;
+
+ if (Buffer_Offset_Temp+8>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ }
+ else
+ {
+ if (Buffer_Offset_Temp+8>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ if (CC8(Buffer+Buffer_Offset_Temp)==0x0000000000000000LL)
+ {
+ while(Buffer_Offset_Temp+2<=Buffer_Size && CC2(Buffer+Buffer_Offset_Temp)==0x0000)
+ Buffer_Offset_Temp+=2;
+
+ if (Buffer_Offset_Temp+2>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ }
+ }
+ if (Buffer_Offset_Temp-Buffer_Offset)
+ {
+ Skip_XX(Buffer_Offset_Temp-Buffer_Offset, "Guard band");
+ }
+ }
+}
+
+#if MEDIAINFO_SEEK
+//---------------------------------------------------------------------------
+void File_Aes3::Read_Buffer_Unsynched()
+{
+ if (File_GoTo==0)
+ Synched_Init();
+
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1 && Frame_Duration!=(int64u)-1 && Frame_Size!=(int64u)-1)
+ {
+ Frame_Count_NotParsedIncluded=File_GoTo/Frame_Size;
+ if (Frame_Count_NotParsedIncluded*Frame_Size<File_GoTo)
+ Frame_Count_NotParsedIncluded++;
+ FrameInfo.DTS=Frame_Count_NotParsedIncluded*Frame_Duration;
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_Aes3::Read_Buffer_Seek (size_t Method, int64u Value, int64u /*ID*/)
+{
+ //Init
+ if (!Duration_Detected && File_Size!=(int64u)-1 && (Frame_Size==(int64u)-1 || Frame_Duration==(int64u)-1))
+ {
+ MediaInfo_Internal MI;
+ MI.Option(_T("File_KeepInfo"), _T("1"));
+ Ztring ParseSpeed_Save=MI.Option(_T("ParseSpeed_Get"), _T(""));
+ Ztring Demux_Save=MI.Option(_T("Demux_Get"), _T(""));
+ MI.Option(_T("ParseSpeed"), _T("0"));
+ MI.Option(_T("Demux"), Ztring());
+ size_t MiOpenResult=MI.Open(File_Name);
+ MI.Option(_T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
+ MI.Option(_T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
+ if (!MiOpenResult)
+ return 0;
+
+ int64u FrameCount=MI.Get(Stream_Audio, 0, _T("FrameCount")).To_int64u();
+ int64u Duration=MI.Get(Stream_Audio, 0, _T("Duration")).To_int64u();
+ int64u DataSize=MI.Get(Stream_General, 0, _T("DataSize")).To_int64u();
+ if (FrameCount && Duration)
+ Frame_Duration=Duration*1000000/FrameCount; //In nanoseconds
+ if (FrameCount && DataSize)
+ Frame_Size=DataSize/FrameCount;
+
+ Duration_Detected=true;
+ }
+
+ //Parsing
+ switch (Method)
+ {
+ case 0 :
+ GoTo(Value);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 1 :
+ GoTo(File_Size*Value/10000);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 2 : //Timestamp
+ {
+ if (Frame_Duration==(int64u)-1 || Frame_Size==(int64u)-1)
+ return (size_t)-1; //Not supported
+
+ Unsynch_Frame_Count=float64_int64s(((float64)Value)/Frame_Duration);
+ GoTo(Unsynch_Frame_Count*Frame_Size);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ case 3 : //FrameNumber
+ {
+ if (Frame_Size==(int64u)-1)
+ return (size_t)-1; //Not supported
+
+ Unsynch_Frame_Count=Value;
+ GoTo(Unsynch_Frame_Count*Frame_Size);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ default : return (size_t)-1; //Not supported
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Aes3::Synchronize()
+{
+ if (IsPcm)
+ return false; //No sync with raw PCM, must return immediatly and wait for more data
+
+ //Synchronizing
+ while (Buffer_Offset+16<=Buffer_Size)
+ {
+ if ((ByteSize==0 || ByteSize==4) && ((Buffer_TotalBytes+Buffer_Offset)%4)==0)
+ {
+ if (Buffer[Buffer_Offset ]==0xF8
+ && Buffer[Buffer_Offset+1]==0x72
+ && Buffer[Buffer_Offset+2]==0x4E
+ && Buffer[Buffer_Offset+3]==0x1F) //SMPTE 337M 16-bit, BE
+ {
+ ByteSize=4;
+ Container_Bits=16;
+ Stream_Bits=16;
+ Endianness='B'; //BE
+ break; //while()
+ }
+ if (Buffer[Buffer_Offset ]==0x72
+ && Buffer[Buffer_Offset+1]==0xF8
+ && Buffer[Buffer_Offset+2]==0x1F
+ && Buffer[Buffer_Offset+3]==0x4E) //SMPTE 337M 16-bit, LE
+ {
+ ByteSize=4;
+ Container_Bits=16;
+ Stream_Bits=16;
+ Endianness='L'; //LE
+ break; //while()
+ }
+ }
+ if ((ByteSize==0 || ByteSize==5) && ((Buffer_TotalBytes+Buffer_Offset)%5)==0)
+ {
+ if (Buffer[Buffer_Offset ]==0x6F
+ && Buffer[Buffer_Offset+1]==0x87
+ && Buffer[Buffer_Offset+2]==0x25
+ && Buffer[Buffer_Offset+3]==0x4E
+ && Buffer[Buffer_Offset+4]==0x1F) //SMPTE 337M 20-bit, BE
+ {
+ ByteSize=5;
+ Container_Bits=20;
+ Stream_Bits=20;
+ Endianness='B'; //BE
+ break; //while()
+ }
+ }
+ if ((ByteSize==0 || ByteSize==6) && ((Buffer_TotalBytes+Buffer_Offset)%6)==0)
+ {
+ if (Buffer[Buffer_Offset ]==0x96
+ && Buffer[Buffer_Offset+1]==0xF8
+ && Buffer[Buffer_Offset+2]==0x72
+ && Buffer[Buffer_Offset+3]==0xA5
+ && Buffer[Buffer_Offset+4]==0x4E
+ && Buffer[Buffer_Offset+5]==0x1F) //SMPTE 337M 24-bit, BE
+ {
+ ByteSize=6;
+ Container_Bits=24;
+ Stream_Bits=24;
+ Endianness='B'; //BE
+ break; //while()
+ }
+ if (Buffer[Buffer_Offset ]==0x72
+ && Buffer[Buffer_Offset+1]==0xF8
+ && Buffer[Buffer_Offset+2]==0x96
+ && Buffer[Buffer_Offset+3]==0x1F
+ && Buffer[Buffer_Offset+4]==0x4E
+ && Buffer[Buffer_Offset+5]==0x5A) //SMPTE 337M 24-bit, LE
+ {
+ ByteSize=6;
+ Container_Bits=24;
+ Stream_Bits=24;
+ Endianness='L'; //LE
+ break; //while()
+ }
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0xF8
+ && Buffer[Buffer_Offset+2]==0x72
+ && Buffer[Buffer_Offset+3]==0x00
+ && Buffer[Buffer_Offset+4]==0x4E
+ && Buffer[Buffer_Offset+5]==0x1F) //16-bit in 24-bit, BE
+ {
+ ByteSize=6;
+ Container_Bits=24;
+ Stream_Bits=16;
+ Endianness='B'; //BE
+ break; //while()
+ }
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x72
+ && Buffer[Buffer_Offset+2]==0xF8
+ && Buffer[Buffer_Offset+3]==0x00
+ && Buffer[Buffer_Offset+4]==0x1F
+ && Buffer[Buffer_Offset+5]==0x4E) //16-bit in 24-bit, LE
+ {
+ ByteSize=6;
+ Container_Bits=24;
+ Stream_Bits=16;
+ Endianness='L'; //LE
+ break; //while()
+ }
+ if (Buffer[Buffer_Offset ]==0x6F
+ && Buffer[Buffer_Offset+1]==0x87
+ && Buffer[Buffer_Offset+2]==0x20
+ && Buffer[Buffer_Offset+3]==0x54
+ && Buffer[Buffer_Offset+4]==0xE1
+ && Buffer[Buffer_Offset+5]==0xF0) //20-bit in 24-bit, BE
+ {
+ ByteSize=6;
+ Container_Bits=24;
+ Stream_Bits=20;
+ Endianness='B'; //BE
+ break; //while()
+ }
+ if (Buffer[Buffer_Offset ]==0x20
+ && Buffer[Buffer_Offset+1]==0x87
+ && Buffer[Buffer_Offset+2]==0x6F
+ && Buffer[Buffer_Offset+3]==0xF0
+ && Buffer[Buffer_Offset+4]==0xE1
+ && Buffer[Buffer_Offset+5]==0x54) //20-bit in 24-bit, LE
+ {
+ ByteSize=6;
+ Container_Bits=24;
+ Stream_Bits=20;
+ Endianness='L'; //LE
+ break; //while()
+ }
+ }
+ if ((ByteSize==0 || ByteSize==8) && ((Buffer_TotalBytes+Buffer_Offset)%8)==0)
+ {
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0xF8
+ && Buffer[Buffer_Offset+3]==0x72
+ && Buffer[Buffer_Offset+4]==0x00
+ && Buffer[Buffer_Offset+5]==0x00
+ && Buffer[Buffer_Offset+6]==0x4E
+ && Buffer[Buffer_Offset+7]==0x1F) //16-bit in 32-bit, BE
+ {
+ ByteSize=8;
+ Container_Bits=32;
+ Stream_Bits=16;
+ Endianness='B'; //BE
+ break; //while()
+ }
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x72
+ && Buffer[Buffer_Offset+3]==0xF8
+ && Buffer[Buffer_Offset+4]==0x00
+ && Buffer[Buffer_Offset+5]==0x00
+ && Buffer[Buffer_Offset+6]==0x1F
+ && Buffer[Buffer_Offset+7]==0x4E) //16-bit in 32-bit, LE
+ {
+ ByteSize=8;
+ Container_Bits=32;
+ Stream_Bits=16;
+ Endianness='L'; //LE
+ break; //while()
+ }
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x6F
+ && Buffer[Buffer_Offset+2]==0x87
+ && Buffer[Buffer_Offset+3]==0x20
+ && Buffer[Buffer_Offset+4]==0x00
+ && Buffer[Buffer_Offset+5]==0x54
+ && Buffer[Buffer_Offset+6]==0xE1
+ && Buffer[Buffer_Offset+7]==0xF0) //20-bit in 32-bit, BE
+ {
+ ByteSize=8;
+ Container_Bits=32;
+ Stream_Bits=20;
+ Endianness='B'; //BE
+ break; //while()
+ }
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x20
+ && Buffer[Buffer_Offset+2]==0x87
+ && Buffer[Buffer_Offset+3]==0x6F
+ && Buffer[Buffer_Offset+4]==0x00
+ && Buffer[Buffer_Offset+5]==0xF0
+ && Buffer[Buffer_Offset+6]==0xE1
+ && Buffer[Buffer_Offset+7]==0x54) //20-bit in 32-bit, LE
+ {
+ ByteSize=8;
+ Container_Bits=32;
+ Stream_Bits=20;
+ Endianness='L'; //LE
+ break; //while()
+ }
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x96
+ && Buffer[Buffer_Offset+2]==0xF8
+ && Buffer[Buffer_Offset+3]==0x72
+ && Buffer[Buffer_Offset+4]==0x00
+ && Buffer[Buffer_Offset+5]==0xA5
+ && Buffer[Buffer_Offset+6]==0x4E
+ && Buffer[Buffer_Offset+7]==0x1F) //24-bit in 32-bit, BE
+ {
+ ByteSize=8;
+ Container_Bits=32;
+ Stream_Bits=24;
+ Endianness='B'; //BE
+ break; //while()
+ }
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x72
+ && Buffer[Buffer_Offset+2]==0xF8
+ && Buffer[Buffer_Offset+3]==0x96
+ && Buffer[Buffer_Offset+4]==0x00
+ && Buffer[Buffer_Offset+5]==0x1F
+ && Buffer[Buffer_Offset+6]==0x4E
+ && Buffer[Buffer_Offset+7]==0xA5) //24-bit in 32-bit, LE
+ {
+ ByteSize=8;
+ Container_Bits=32;
+ Stream_Bits=24;
+ Endianness='L'; //LE
+ break; //while()
+ }
+ }
+
+ if (ByteSize)
+ Buffer_Offset+=ByteSize;
+ else
+ Buffer_Offset++;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+16>Buffer_Size)
+ {
+ return false;
+ }
+
+ //Synched
+ IsParsingNonPcm=true;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Aes3::Synched_Test()
+{
+ //Skip NULL padding
+ if (!From_Aes3)
+ {
+ size_t Buffer_Offset_Temp=Buffer_Offset;
+ if (ByteSize==4)
+ {
+ while ((Buffer_TotalBytes+Buffer_Offset_Temp)%4) //Padding in part of the AES3 block
+ {
+ if (Buffer_Offset_Temp+1>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return false;
+ }
+ if (Buffer[Buffer_Offset_Temp])
+ {
+ Trusted_IsNot("Bad sync");
+ return true;
+ }
+ Buffer_Offset_Temp++;
+ }
+ while(Buffer_Offset_Temp+4<=Buffer_Size && CC4(Buffer+Buffer_Offset_Temp)==0x00000000)
+ Buffer_Offset_Temp+=4;
+ if (Buffer_Offset_Temp+4>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return false;
+ }
+ }
+ if (ByteSize==6)
+ {
+ while ((Buffer_TotalBytes+Buffer_Offset_Temp)%6) //Padding in part of the AES3 block
+ {
+ if (Buffer_Offset_Temp+1>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return false;
+ }
+ if (Buffer[Buffer_Offset_Temp])
+ {
+ Trusted_IsNot("Bad sync");
+ return true;
+ }
+ Buffer_Offset_Temp++;
+ }
+ while(Buffer_Offset_Temp+6<=Buffer_Size && CC6(Buffer+Buffer_Offset_Temp)==0x000000000000LL)
+ Buffer_Offset_Temp+=6;
+ if (Buffer_Offset_Temp+6>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return false;
+ }
+ }
+ else if (ByteSize==8)
+ {
+ while ((Buffer_TotalBytes+Buffer_Offset_Temp)%8) //Padding in part of the AES3 block
+ {
+ if (Buffer_Offset_Temp+1>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return false;
+ }
+ if (Buffer[Buffer_Offset_Temp])
+ {
+ Trusted_IsNot("Bad sync");
+ return true;
+ }
+ Buffer_Offset_Temp++;
+ }
+ while(Buffer_Offset_Temp+8<=Buffer_Size && CC8(Buffer+Buffer_Offset_Temp)==0x0000000000000000LL)
+ Buffer_Offset_Temp+=8;
+ if (Buffer_Offset_Temp+8>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return false;
+ }
+ }
+
+ if (Frame_Count && NotPCM_SizePerFrame==(int64u)-1)
+ NotPCM_SizePerFrame=Buffer_Offset_Temp;
+ #if MEDIAINFO_TRACE
+ if (Buffer_Offset_Temp-Buffer_Offset)
+ {
+ Element_Size=Buffer_Offset_Temp-Buffer_Offset;
+ Skip_XX(Buffer_Offset_Temp-Buffer_Offset, "Guard band");
+ }
+ #endif //MEDIAINFO_TRACE
+ Buffer_Offset=Buffer_Offset_Temp;
+ }
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+16>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ switch (Endianness)
+ {
+ case 'B' :
+ switch (Container_Bits)
+ {
+ case 16 : if (CC4(Buffer+Buffer_Offset)!=0xF8724E1F) {Synched=false; return true;} break;
+ case 20 : if (CC5(Buffer+Buffer_Offset)!=0x6F87254E1FLL) {Synched=false; return true;} break;
+ case 24 :
+ switch (Stream_Bits)
+ {
+ case 16 : if (CC6(Buffer+Buffer_Offset)!=0xF872004E1F00LL) {Synched=false; return true;} break;
+ case 20 : if (CC6(Buffer+Buffer_Offset)!=0x6F872054E1F0LL) {Synched=false; return true;} break;
+ case 24 : if (CC6(Buffer+Buffer_Offset)!=0x96F872A54E1FLL) {Synched=false; return true;} break;
+ default : ;
+ }
+ break;
+ case 32 :
+ switch (Stream_Bits)
+ {
+ case 16 : if (CC6(Buffer+Buffer_Offset)!=0x0000F87200004E1FLL) {Synched=false; return true;} break;
+ case 20 : if (CC6(Buffer+Buffer_Offset)!=0x006F87200054E1F0LL) {Synched=false; return true;} break;
+ case 24 : if (CC6(Buffer+Buffer_Offset)!=0x0096F87200A5F41FLL) {Synched=false; return true;} break;
+ default : ;
+ }
+ break;
+ default : ;
+ }
+ break;
+ case 'L' :
+ switch (Container_Bits)
+ {
+ case 16 : if (CC4(Buffer+Buffer_Offset)!=0x72F81F4E) {Synched=false; return true;} break;
+ case 24 :
+ switch (Stream_Bits)
+ {
+ case 16 : if (CC6(Buffer+Buffer_Offset)!=0x0072F8001F4ELL) {Synched=false; return true;} break;
+ case 20 : if (CC6(Buffer+Buffer_Offset)!=0x20876FF0E154LL) {Synched=false; return true;} break;
+ case 24 : if (CC6(Buffer+Buffer_Offset)!=0x72F8961F4EA5LL) {Synched=false; return true;} break;
+ default : ;
+ }
+ break;
+ case 32 :
+ switch (Stream_Bits)
+ {
+ case 16 : if (CC8(Buffer+Buffer_Offset)!=0x000072F800001F4ELL) {Synched=false; return true;} break;
+ case 20 : if (CC8(Buffer+Buffer_Offset)!=0x0020876F00F0E154LL) {Synched=false; return true;} break;
+ case 24 : if (CC8(Buffer+Buffer_Offset)!=0x0072F896001F4EA5LL) {Synched=false; return true;} break;
+ default : ;
+ }
+ break;
+ default : ;
+ }
+ break;
+ default : ; //Should never happen
+ }
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Aes3::Synched_Init()
+{
+ if (Frame_Count_NotParsedIncluded==(int64u)-1)
+ Frame_Count_NotParsedIncluded=0;
+ if (FrameInfo.DTS==(int64u)-1)
+ FrameInfo.DTS=0;
+}
+
+//***************************************************************************
+// Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Aes3::Header_Parse()
+{
+ if (IsPcm)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ //Parsing
+ int32u Size=0;
+ switch (Endianness)
+ {
+ case 'B' :
+ switch (Container_Bits)
+ {
+ case 16 : Size=BigEndian2int16u(Buffer+Buffer_Offset+6) ; break;
+ case 20 : Size=BigEndian2int24u(Buffer+Buffer_Offset+7)&0x0FFFFF; break;
+ case 24 :
+ switch (Stream_Bits)
+ {
+ case 16 : Size=BigEndian2int16u(Buffer+Buffer_Offset+9) ; break;
+ case 20 : Size=BigEndian2int24u(Buffer+Buffer_Offset+9)>>4; break;
+ case 24 : Size=BigEndian2int24u(Buffer+Buffer_Offset+9) ; break;
+ default : ;
+ }
+ break;
+ case 32 :
+ switch (Stream_Bits)
+ {
+ case 16 : Size=BigEndian2int16u(Buffer+Buffer_Offset+0xC) ; break;
+ case 20 : Size=BigEndian2int24u(Buffer+Buffer_Offset+0xC)>>4; break;
+ case 24 : Size=BigEndian2int24u(Buffer+Buffer_Offset+0xC) ; break;
+ default : ;
+ }
+ break;
+ default : ;
+ }
+ break;
+ case 'L' :
+ switch (Container_Bits)
+ {
+ case 16 : Size=LittleEndian2int16u(Buffer+Buffer_Offset+6) ; break;
+ case 24 :
+ switch (Stream_Bits)
+ {
+ case 16 : Size=LittleEndian2int16u(Buffer+Buffer_Offset+0xA) ; break;
+ case 20 : Size=LittleEndian2int24u(Buffer+Buffer_Offset+0x9)>>4; break;
+ case 24 : Size=LittleEndian2int24u(Buffer+Buffer_Offset+0x9) ; break;
+ default : ;
+ }
+ break;
+ case 32 :
+ switch (Stream_Bits)
+ {
+ case 16 : Size=LittleEndian2int16u(Buffer+Buffer_Offset+0xE) ; break;
+ case 20 : Size=LittleEndian2int24u(Buffer+Buffer_Offset+0xD)>>4; break;
+ case 24 : Size=LittleEndian2int24u(Buffer+Buffer_Offset+0xD) ; break;
+ default : ;
+ }
+ break;
+ default : ;
+ }
+ break;
+ default : ; //Should never happen
+ }
+
+ //Adaptation
+ if (Container_Bits!=Stream_Bits)
+ {
+ Size*=Container_Bits; Size/=Stream_Bits;
+ }
+
+ //Coherency test
+ if (!IsSub && !Status[IsAccepted])
+ {
+ size_t Offset=Buffer_Offset+(size_t)(Container_Bits*4/8+Size/8);
+ while (Offset<Buffer_Size && Buffer[Offset]==0x00)
+ Offset++;
+ if (Offset+ByteSize>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ Offset/=ByteSize;
+ Offset*=ByteSize;
+ bool IsOK=true;
+ for (size_t Pos=0; Pos<ByteSize; Pos++)
+ if (Buffer[Buffer_Offset+Pos]!=Buffer[Offset+Pos])
+ {
+ IsOK=false;
+ break;
+ }
+ if (!IsOK)
+ {
+ Trusted_IsNot("Bad sync");
+ Buffer_Offset++;
+ return;
+ }
+ }
+
+ //Filling
+ Header_Fill_Size(Container_Bits*4/8+Size/8);
+ Header_Fill_Code(0, "AES3");
+}
+
+//---------------------------------------------------------------------------
+void File_Aes3::Data_Parse()
+{
+ if (!Status[IsAccepted])
+ Accept("AES3");
+
+ if (Container_Bits==Stream_Bits && Endianness=='B')
+ Frame();
+ else
+ Frame_WithPadding();
+}
+
+//---------------------------------------------------------------------------
+void File_Aes3::Raw()
+{
+ //SMPTE 331M
+ int16u Audio_Sample_Count;
+ int8u Channels_valid;
+ BS_Begin();
+ Skip_SB( "FVUCP Valid Flag");
+ Skip_S1(4, "Reserved");
+ Skip_S1(3, "5-sequence count");
+ BS_End();
+ Get_L2 (Audio_Sample_Count, "Audio Sample Count");
+ Get_B1 (Channels_valid, "Channels valid");
+
+ //Parsing
+ if (QuantizationBits==16)
+ bits_per_sample=0; //16 bits
+ else
+ bits_per_sample=2; //24 bits
+ switch (bits_per_sample)
+ {
+ case 0 : //16 bits
+ {
+ int8u* Info=new int8u[(size_t)(Element_Size/2)];
+ size_t Info_Offset=0;
+
+ while (Element_Offset+8*4<=Element_Size)
+ {
+ for (int8u Pos=0; Pos<8; Pos++)
+ {
+ if (Channels_valid&(1<<Pos))
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ Info[Info_Offset+0] = (Buffer[Buffer_Pos+1]>>4) | ((Buffer[Buffer_Pos+2]<<4)&0xF0 );
+ Info[Info_Offset+1] = (Buffer[Buffer_Pos+2]>>4) | ((Buffer[Buffer_Pos+3]<<4)&0xF0 );
+
+ Info_Offset+=2;
+ }
+ Element_Offset+=4;
+ }
+ }
+ Element_Offset=4;
+
+ #if MEDIAINFO_DEMUX
+ FrameInfo.PTS=FrameInfo.DTS;
+ if (SampleRate)
+ FrameInfo.DUR=(Element_Size-4)/4*1000000000/(SampleRate*8);
+ Demux_random_access=true;
+ Element_Code=(int64u)-1;
+ Demux(Info, Info_Offset, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ delete[] Info;
+
+ Skip_XX(Element_Size-4, "Data");
+
+ Frame_Count_InThisBlock++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ #if MEDIAINFO_DEMUX
+ if (FrameInfo.DTS!=(int64u)-1 && FrameInfo.DUR!=(int64u)-1)
+ {
+ FrameInfo.DTS+=FrameInfo.DUR;
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+ break;
+ case 2 : //24 bits
+ {
+ int8u* Info=new int8u[(size_t)(Element_Size*3/4)];
+ size_t Info_Offset=0;
+
+ while (Element_Offset+8*4<=Element_Size)
+ {
+ for (int8u Pos=0; Pos<8; Pos++)
+ {
+ if (Channels_valid&(1<<Pos))
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ Info[Info_Offset+0] = (Buffer[Buffer_Pos+0]>>4) | ((Buffer[Buffer_Pos+1]<<4)&0xF0 );
+ Info[Info_Offset+1] = (Buffer[Buffer_Pos+1]>>4) | ((Buffer[Buffer_Pos+2]<<4)&0xF0 );
+ Info[Info_Offset+2] = (Buffer[Buffer_Pos+2]>>4) | ((Buffer[Buffer_Pos+3]<<4)&0xF0 );
+
+ Info_Offset+=3;
+ }
+ Element_Offset+=4;
+ }
+ }
+ Element_Offset=4;
+
+ #if MEDIAINFO_DEMUX
+ FrameInfo.PTS=FrameInfo.DTS;
+ if (SampleRate)
+ FrameInfo.DUR=(Element_Size-4)/4*1000000000/(SampleRate*8);
+ Demux_random_access=true;
+ Element_Code=(int64u)-1;
+ Demux(Info, Info_Offset, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ delete[] Info;
+
+ Skip_XX(Element_Size-4, "Data");
+
+ Frame_Count_InThisBlock++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ #if MEDIAINFO_DEMUX
+ if (FrameInfo.DTS!=(int64u)-1 && FrameInfo.DUR!=(int64u)-1)
+ {
+ FrameInfo.DTS+=FrameInfo.DUR;
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+ break;
+ default :
+ Skip_XX(Element_Size-4, "Data");
+ }
+
+ FILLING_BEGIN();
+ if (!Status[IsAccepted])
+ {
+ Accept("AES3");
+
+ int8u Channels=0;
+ for (int8u Pos=0; Pos<8; Pos++)
+ {
+ if (Channels_valid&(1<<Pos))
+ Channels++;
+ Element_Offset+=4;
+ }
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Channels);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Aes3::Frame()
+{
+ //Parsing
+ int32u length_code;
+ Element_Begin1("Header");
+ BS_Begin();
+ Skip_S3(Stream_Bits, "Pa");
+ Skip_S3(Stream_Bits, "Pb");
+ Element_Begin1("Pc");
+ Skip_S1( 3, "data_stream_number");
+ Skip_S1( 5, "data_type_dependent");
+ Skip_SB( "error_flag");
+ Info_S1( 2, data_mode, "data_mode"); Param_Info2(16+4*data_mode, " bits");
+ Get_S1 ( 5, data_type, "data_type"); Param_Info1(Aes3_NonPCM_data_type[data_type]);
+ if (Stream_Bits>16)
+ Skip_S1( 4, "reserved");
+ if (Stream_Bits>20)
+ Skip_S1( 4, "reserved");
+ Element_End0();
+ Get_S3 (Stream_Bits, length_code, "length_code"); Param_Info2(length_code/8, " bytes");
+ BS_End();
+ Element_End0();
+
+ if (Parser==NULL)
+ {
+ switch(data_type)
+ {
+ //SMPTE ST338
+ case 1 : //AC-3
+ case 16 : //E-AC-3 (professional)
+ case 21 : //E-AC-3 (consumer)
+ Parser=new File_Ac3();
+ ((File_Ac3*)Parser)->Frame_Count_Valid=2;
+ break;
+ case 4 : //MPEG-1 Layer 1
+ case 5 : //MPEG-1 Layer 2/3, MPEG-2 Layer 1/2/3 without extension
+ case 6 : //MPEG-2 Layer 1/2/3 with extension
+ case 8 : //MPEG-2 Layer 1 low frequency
+ case 9 : //MPEG-2 Layer 2/3 low frequency
+ Parser=new File_Mpega();
+ break;
+ case 7 : //MPEG-2 AAC in ADTS
+ case 19 : //MPEG-2 AAC in ADTS low frequency
+ Parser=new File_Aac();
+ ((File_Aac*)Parser)->Mode=File_Aac::Mode_ADTS;
+ break;
+ case 10 : //MPEG-4 AAC in ADTS or LATM
+ case 11 : //MPEG-4 AAC in ADTS or LATM
+ Parser=new File_Aac();
+ break;
+ case 28 : //Dolby E
+ Parser=new File_DolbyE();
+ break;
+ default : ;
+ }
+
+ if (Parser)
+ {
+ Open_Buffer_Init(Parser);
+ }
+ }
+ if (Parser)
+ {
+ #if MEDIAINFO_DEMUX
+ FrameInfo.PTS=FrameInfo.DTS;
+ if (SampleRate && ByteSize)
+ FrameInfo.DUR=(Element_Size-Element_Offset)*1000000000/(SampleRate*ByteSize);
+ Demux_random_access=true;
+ Element_Code=(int64u)-1;
+ Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset), ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ Parser->FrameInfo=FrameInfo;
+ Open_Buffer_Continue(Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+ #if MEDIAINFO_DEMUX
+ if (Parser->FrameInfo.DUR!=FrameInfo.DUR && Parser->FrameInfo.DUR!=(int64u)-1)
+ FrameInfo.DUR=Parser->FrameInfo.DUR;
+ if (FrameInfo.DUR!=(int64u)-1)
+ FrameInfo.DTS+=FrameInfo.DUR;
+ else if (Parser->FrameInfo.DTS!=(int64u)-1)
+ FrameInfo=Parser->FrameInfo;
+ else
+ FrameInfo.DTS=(int64u)-1;
+ #endif //MEDIAINFO_DEMUX
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ if (!Status[IsFilled] && Parser->Status[IsFilled])
+ {
+ Merge(*Parser);
+ int64u OverallBitRate=Parser->Retrieve(Stream_General, 0, General_OverallBitRate).To_int64u();
+ if (OverallBitRate)
+ {
+ OverallBitRate*=Element_Size; OverallBitRate/=Element_Size-Stream_Bits*4/8;
+ Fill(Stream_General, 0, General_OverallBitRate, Ztring::ToZtring(OverallBitRate)+_T(" / ")+Parser->Retrieve(Stream_General, 0, General_OverallBitRate));
+ }
+ int64u BitRate=Parser->Retrieve(Stream_Audio, 0, Audio_BitRate).To_int64u();
+ if (BitRate)
+ FrameRate=((float64)BitRate)/((Element_Size-Element_Offset)*8);
+ Fill("AES3");
+ }
+ if (Parser->Status[IsFinished])
+ Finish("AES3");
+ Element_Offset=Element_Size;
+ }
+ else
+ Finish("AES3");
+}
+
+//---------------------------------------------------------------------------
+void File_Aes3::Frame_WithPadding()
+{
+ #if MEDIAINFO_DEMUX
+ FrameInfo.PTS=FrameInfo.DTS;
+ if (SampleRate && ByteSize)
+ FrameInfo.DUR=Element_Size*1000000000/(SampleRate*ByteSize);
+ Demux_random_access=true;
+ Element_Code=(int64u)-1;
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ int8u* Info=new int8u[(size_t)Element_Size];
+ size_t Info_Offset=0;
+
+ if (Container_Bits==16 && Stream_Bits==16 && Endianness=='L')
+ {
+ while (Element_Offset+4<=Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ Info[Info_Offset+0]= Buffer[Buffer_Pos+1];
+ Info[Info_Offset+1]= Buffer[Buffer_Pos+0];
+ Info[Info_Offset+2]= Buffer[Buffer_Pos+3];
+ Info[Info_Offset+3]= Buffer[Buffer_Pos+2];
+ Info_Offset+=4;
+ Element_Offset+=4;
+ }
+ if (Element_Offset+2<=Element_Size) //Only in half of the AES3 stream
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ Info[Info_Offset+0]= Buffer[Buffer_Pos+1];
+ Info[Info_Offset+1]= Buffer[Buffer_Pos+0];
+ Info_Offset+=2;
+ Element_Offset+=2;
+ }
+ }
+ if (Container_Bits==24 && Stream_Bits==16 && Endianness=='L')
+ {
+ while (Element_Offset+6<=Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ Info[Info_Offset+0]= Buffer[Buffer_Pos+2];
+ Info[Info_Offset+1]= Buffer[Buffer_Pos+1];
+ Info[Info_Offset+2]= Buffer[Buffer_Pos+5];
+ Info[Info_Offset+3]= Buffer[Buffer_Pos+4];
+ Info_Offset+=4;
+ Element_Offset+=6;
+ }
+ }
+ if (Container_Bits==24 && Stream_Bits==20 && Endianness=='L')
+ {
+ while (Element_Offset+6<=Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ Info[Info_Offset+0]= Buffer[Buffer_Pos+2];
+ Info[Info_Offset+1]= Buffer[Buffer_Pos+1];
+ Info[Info_Offset+2]=((Buffer[Buffer_Pos+0]&0xF0) ) | ((Buffer[Buffer_Pos+5]&0xF0)>>4);
+ Info[Info_Offset+3]=((Buffer[Buffer_Pos+5]&0x0F)<<4) | ((Buffer[Buffer_Pos+4]&0xF0)>>4);
+ Info[Info_Offset+4]=((Buffer[Buffer_Pos+4]&0x0F)<<4) | ((Buffer[Buffer_Pos+3]&0xF0)>>4);
+ Info_Offset+=5;
+ Element_Offset+=6;
+ }
+ }
+ if (Container_Bits==32 && Stream_Bits==16 && Endianness=='L')
+ {
+ while (Element_Offset+8<=Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ Info[Info_Offset+0]= Buffer[Buffer_Pos+3];
+ Info[Info_Offset+1]= Buffer[Buffer_Pos+2];
+ Info[Info_Offset+2]= Buffer[Buffer_Pos+7];
+ Info[Info_Offset+3]= Buffer[Buffer_Pos+6];
+ Info_Offset+=4;
+ Element_Offset+=8;
+ }
+ }
+ if (Container_Bits==32 && Stream_Bits==20 && Endianness=='L')
+ {
+ while (Element_Offset+8<=Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ Info[Info_Offset+0]= Buffer[Buffer_Pos+3];
+ Info[Info_Offset+1]= Buffer[Buffer_Pos+2];
+ Info[Info_Offset+2]=((Buffer[Buffer_Pos+1]&0xF0) ) | ((Buffer[Buffer_Pos+7]&0xF0)>>4);
+ Info[Info_Offset+3]=((Buffer[Buffer_Pos+7]&0x0F)<<4) | ((Buffer[Buffer_Pos+6]&0xF0)>>4);
+ Info[Info_Offset+4]=((Buffer[Buffer_Pos+6]&0x0F)<<4) | ((Buffer[Buffer_Pos+5]&0xF0)>>4);
+ Info_Offset+=5;
+ Element_Offset+=8;
+ }
+ }
+ if (Container_Bits==32 && Stream_Bits==24 && Endianness=='L')
+ {
+ while (Element_Offset+8<=Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ Info[Info_Offset+0]= Buffer[Buffer_Pos+3];
+ Info[Info_Offset+1]= Buffer[Buffer_Pos+2];
+ Info[Info_Offset+2]= Buffer[Buffer_Pos+1];
+ Info[Info_Offset+3]= Buffer[Buffer_Pos+7];
+ Info[Info_Offset+4]= Buffer[Buffer_Pos+6];
+ Info[Info_Offset+5]= Buffer[Buffer_Pos+5];
+ Info_Offset+=6;
+ Element_Offset+=8;
+ }
+ }
+
+ if (Container_Bits==24 && Stream_Bits==20 && Endianness=='B')
+ {
+ while (Element_Offset+6<=Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ Info[Info_Offset+0]= Buffer[Buffer_Pos+0];
+ Info[Info_Offset+1]= Buffer[Buffer_Pos+1];
+ Info[Info_Offset+2]=((Buffer[Buffer_Pos+2]&0xF0) ) | ((Buffer[Buffer_Pos+3]&0xF0)>>4);
+ Info[Info_Offset+3]=((Buffer[Buffer_Pos+3]&0x0F)<<4) | ((Buffer[Buffer_Pos+4]&0xF0)>>4);
+ Info[Info_Offset+4]=((Buffer[Buffer_Pos+4]&0x0F)<<4) | ((Buffer[Buffer_Pos+5]&0xF0)>>4);
+ Info_Offset+=5;
+ Element_Offset+=6;
+ }
+ }
+
+ if (Element_Offset==0)
+ {
+ Skip_XX(Element_Size, "Data");
+ Finish();
+ delete[] Info;
+ return;
+ }
+
+ Parser_Parse(Info, Info_Offset);
+ delete[] Info;
+}
+
+//---------------------------------------------------------------------------
+static inline int8u Reverse8(int n)
+{
+ // Input: bit order is 76543210
+ //Output: bit order is 45670123
+ n=((n>>1)&0x55) | ((n<<1) & 0xaa);
+ n=((n>>2)&0x33) | ((n<<2) & 0xcc);
+ n=((n>>4)&0x0f) | ((n<<4) & 0xf0);
+ return (int8u)n;
+}
+
+//---------------------------------------------------------------------------
+void File_Aes3::Frame_FromMpegPs()
+{
+ //SMPTE 302M
+ int16u audio_packet_size=0;
+ Get_B2 (audio_packet_size, "audio_packet_size");
+ BS_Begin();
+ Get_S1 (2, number_channels, "number_channels"); Param_Info2(2+2*number_channels, " channels");
+ Info_S1(8, channel_identification, "channel_identification");
+ Get_S1 (2, bits_per_sample, "bits_per_sample"); Param_Info2(16+4*bits_per_sample, " bits");
+ Info_S1(4, alignment_bits, "alignment_bits");
+ BS_End();
+
+ //Enough data
+ if (Element_Size<4+(int64u)audio_packet_size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ if (Element_Size!=4+(int64u)audio_packet_size)
+ {
+ Trusted_IsNot("Wrong size");
+ Skip_XX(Element_Size-4, "Problem?");
+ return;
+ }
+
+ if (!Status[IsAccepted])
+ {
+ Accept("AES3");
+ Container_Bits=Stream_Bits=16+4*bits_per_sample;
+ Endianness='L';
+ if (Container_Bits%8)
+ Container_Bits+=4; //Rounded to next byte
+ }
+
+ //Parsing
+ switch (bits_per_sample)
+ {
+ case 0 : //16 bits
+ {
+ int8u* Info=new int8u[(size_t)Element_Size-4];
+ size_t Info_Offset=0;
+
+ while (Element_Offset<Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ //Channel 1 (16 bits, as "s16l" codec)
+ Info[Info_Offset+0]= Reverse8(Buffer[Buffer_Pos+0]);
+ Info[Info_Offset+1]= Reverse8(Buffer[Buffer_Pos+1]);
+
+ //Channel 2 (16 bits, as "s16l" codec)
+ Info[Info_Offset+2]=(Reverse8(Buffer[Buffer_Pos+2])>>4) | ((Reverse8(Buffer[Buffer_Pos+3])<<4)&0xF0);
+ Info[Info_Offset+3]=(Reverse8(Buffer[Buffer_Pos+3])>>4) | ((Reverse8(Buffer[Buffer_Pos+4])<<4)&0xF0);
+
+ Info_Offset+=4;
+ Element_Offset+=5;
+ }
+
+ #if MEDIAINFO_DEMUX
+ FrameInfo.PTS=FrameInfo.DTS;
+ if (SampleRate)
+ FrameInfo.DUR=(Element_Size-4)/4*1000000000/(SampleRate*8);
+ Demux_random_access=true;
+ Element_Code=(int64u)-1;
+ Demux(Info, Info_Offset, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ for (size_t Pos=0; Pos<Info_Offset; Pos++)
+ if (Info[Pos])
+ {
+ if (Pos+16<Info_Offset && Info[Pos]==0x72 && Info[Pos+1]==0xF8 && Info[Pos+2]==0x1F && Info[Pos+3]==0x4E)
+ IsParsingNonPcm=true;
+ else
+ IsParsingNonPcm=false;
+
+ break;
+ }
+
+ if (IsParsingNonPcm)
+ {
+ IsParsingNonPcm=true;
+ Parser_Parse(Info, Info_Offset);
+ }
+ else
+ {
+ Skip_XX(Element_Size-Element_Offset, "Data");
+
+ #if MEDIAINFO_DEMUX
+ if (FrameInfo.DTS!=(int64u)-1 && FrameInfo.DUR!=(int64u)-1)
+ {
+ FrameInfo.DTS+=FrameInfo.DUR;
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ delete[] Info;
+ }
+ break;
+ case 1 : //20 bits
+ {
+ int8u* Info=new int8u[(size_t)Element_Size-4];
+ size_t Info_Offset=0;
+
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_PCM_20bitTo16bit_Get() && (StreamIDs_Size==0))
+ {
+ while (Element_Offset<Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ //Channel 1 (24 bits, as "s16l" codec, 4 lowest bits are discarded)
+ Info[Info_Offset+0]=(Reverse8(Buffer[Buffer_Pos+0])>>4 ) | ((Reverse8(Buffer[Buffer_Pos+1])<<4)&0xF0);
+ Info[Info_Offset+1]=(Reverse8(Buffer[Buffer_Pos+1])>>4 ) | ((Reverse8(Buffer[Buffer_Pos+2])<<4)&0xF0);
+
+ //Channel 2 (24 bits, as "s16l" codec, 4 lowest bits are discarded)
+ Info[Info_Offset+2]=(Reverse8(Buffer[Buffer_Pos+3])>>4) | ((Reverse8(Buffer[Buffer_Pos+4])<<4)&0xF0);
+ Info[Info_Offset+3]=(Reverse8(Buffer[Buffer_Pos+4])>>4) | ((Reverse8(Buffer[Buffer_Pos+5])<<4)&0xF0);
+
+ Info_Offset+=4;
+ Element_Offset+=6;
+ }
+
+ FrameInfo.PTS=FrameInfo.DTS;
+ if (SampleRate)
+ FrameInfo.DUR=(Element_Size-4)/4*1000000000/(SampleRate*8);
+ Demux_random_access=true;
+ Element_Code=(int64u)-1;
+ Demux(Info, Info_Offset, ContentType_MainStream);
+
+ Info_Offset=0;
+ Element_Offset=4;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ while (Element_Offset<Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ //Channel 1 (24 bits, as "s24l" codec, 4 highest bits are set to 0)
+ Info[Info_Offset+0]= ((Reverse8(Buffer[Buffer_Pos+0])<<4)&0xF0);
+ Info[Info_Offset+1]=(Reverse8(Buffer[Buffer_Pos+0])>>4 ) | ((Reverse8(Buffer[Buffer_Pos+1])<<4)&0xF0);
+ Info[Info_Offset+2]=(Reverse8(Buffer[Buffer_Pos+1])>>4 ) | ((Reverse8(Buffer[Buffer_Pos+2])<<4)&0xF0);
+
+ //Channel 2 (24 bits, as "s24l" codec, 4 highest bits are set to 0)
+ Info[Info_Offset+3]= ((Reverse8(Buffer[Buffer_Pos+3])<<4)&0xF0);
+ Info[Info_Offset+4]=(Reverse8(Buffer[Buffer_Pos+3])>>4) | ((Reverse8(Buffer[Buffer_Pos+4])<<4)&0xF0);
+ Info[Info_Offset+5]=(Reverse8(Buffer[Buffer_Pos+4])>>4) | ((Reverse8(Buffer[Buffer_Pos+5])<<4)&0xF0);
+
+ Info_Offset+=6;
+ Element_Offset+=6;
+ }
+
+ #if MEDIAINFO_DEMUX
+ if (!(Config->Demux_PCM_20bitTo16bit_Get() && (StreamIDs_Size==0)))
+ {
+ FrameInfo.PTS=FrameInfo.DTS;
+ if (SampleRate)
+ FrameInfo.DUR=(Element_Size-4)/4*1000000000/(SampleRate*8);
+ Demux_random_access=true;
+ Element_Code=(int64u)-1;
+ Demux(Info, Info_Offset, ContentType_MainStream);
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ for (size_t Pos=0; Pos<Info_Offset; Pos++)
+ if (Info[Pos])
+ {
+ if (Pos+16<Info_Offset && Info[Pos]==0x20 && Info[Pos+1]==0x87 && Info[Pos+2]==0x6F && Info[Pos+3]==0xF0 && Info[Pos+4]==0xE1 && Info[Pos+5]==0x54)
+ IsParsingNonPcm=true;
+ else
+ IsParsingNonPcm=false;
+
+ break;
+ }
+
+ if (IsParsingNonPcm)
+ {
+ IsParsingNonPcm=true;
+ Parser_Parse(Info, Info_Offset);
+ }
+ else
+ {
+ Skip_XX(Element_Size-Element_Offset, "Data");
+
+ #if MEDIAINFO_DEMUX
+ if (FrameInfo.DTS!=(int64u)-1 && FrameInfo.DUR!=(int64u)-1)
+ {
+ FrameInfo.DTS+=FrameInfo.DUR;
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ delete[] Info;
+ }
+ break;
+ case 2 : //24 bits
+ {
+ int8u* Info=new int8u[(size_t)Element_Size-4];
+ size_t Info_Offset=0;
+
+ while (Element_Offset<Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ //Channel 1 (24 bits, as "s24l" codec)
+ Info[Info_Offset+0] = Reverse8(Buffer[Buffer_Pos+0] );
+ Info[Info_Offset+1] = Reverse8(Buffer[Buffer_Pos+1] );
+ Info[Info_Offset+2] = Reverse8(Buffer[Buffer_Pos+2] );
+
+ //Channel 2 (24 bits, as "s24l" codec)
+ Info[Info_Offset+3] = (Reverse8(Buffer[Buffer_Pos+3])>>4) | ((Reverse8(Buffer[Buffer_Pos+4])<<4)&0xF0 );
+ Info[Info_Offset+4] = (Reverse8(Buffer[Buffer_Pos+4])>>4) | ((Reverse8(Buffer[Buffer_Pos+5])<<4)&0xF0 );
+ Info[Info_Offset+5] = (Reverse8(Buffer[Buffer_Pos+5])>>4) | ((Reverse8(Buffer[Buffer_Pos+6])<<4)&0xF0 );
+
+ Info_Offset+=6;
+ Element_Offset+=7;
+ }
+
+ #if MEDIAINFO_DEMUX
+ FrameInfo.PTS=FrameInfo.DTS;
+ if (SampleRate)
+ FrameInfo.DUR=(Element_Size-4)/4*1000000000/(SampleRate*8);
+ Demux_random_access=true;
+ Element_Code=(int64u)-1;
+ Demux(Info, Info_Offset, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ for (size_t Pos=0; Pos<Info_Offset; Pos++)
+ if (Info[Pos])
+ {
+ if (Pos+16<Info_Offset && ((Info[Pos]==0x72 && Info[Pos+1]==0xF8 && Info[Pos+2]==0x96 && Info[Pos+3]==0x1F && Info[Pos+4]==0x4E && Info[Pos+5]==0xA5) //24-bit
+ || (Info[Pos]==0x20 && Info[Pos+1]==0x87 && Info[Pos+2]==0x6F && Info[Pos+3]==0xF0 && Info[Pos+4]==0xE1 && Info[Pos+5]==0x54))) //20-bit
+ IsParsingNonPcm=true;
+ else
+ IsParsingNonPcm=false;
+
+ break;
+ }
+
+ if (IsParsingNonPcm)
+ {
+ IsParsingNonPcm=true;
+ Parser_Parse(Info, Info_Offset);
+ }
+ else
+ {
+ Skip_XX(Element_Size-Element_Offset, "Data");
+
+ #if MEDIAINFO_DEMUX
+ if (FrameInfo.DTS!=(int64u)-1 && FrameInfo.DUR!=(int64u)-1)
+ {
+ FrameInfo.DTS+=FrameInfo.DUR;
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ delete[] Info;
+ }
+ break;
+ default :
+ Skip_XX(Element_Size, "Data");
+ }
+
+ //Filling
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ if ((!IsParsingNonPcm || (Parser && Parser->Status[IsFinished])) && Frame_Count>=2)
+ {
+ //Filling
+ Finish("AES3");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Aes3::Parser_Parse(const int8u* Parser_Buffer, size_t Parser_Buffer_Size)
+{
+ if (Parser==NULL)
+ {
+ Parser=new File_Aes3();
+ ((File_Aes3*)Parser)->From_Aes3=true;
+ if (SampleRate)
+ ((File_Aes3*)Parser)->SampleRate=SampleRate;
+ #if MEDIAINFO_DEMUX
+ if (From_MpegPs) //TODO: separate AES from MPEG-PS/TS
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ Open_Buffer_Init(Parser);
+ }
+ Element_Offset=0;
+ Parser->FrameInfo=FrameInfo;
+ Open_Buffer_Continue(Parser, Parser_Buffer, Parser_Buffer_Size);
+ #if MEDIAINFO_DEMUX
+ if (Parser->FrameInfo.DUR!=FrameInfo.DUR && Parser->FrameInfo.DUR!=(int64u)-1)
+ FrameInfo.DUR=Parser->FrameInfo.DUR;
+ if (FrameInfo.DUR!=(int64u)-1)
+ FrameInfo.DTS+=FrameInfo.DUR;
+ else if (Parser->FrameInfo.DTS!=(int64u)-1)
+ FrameInfo=Parser->FrameInfo;
+ else
+ FrameInfo.DTS=(int64u)-1;
+ #endif //MEDIAINFO_DEMUX
+ Element_Offset=Element_Size;
+
+ if (!From_MpegPs)
+ {
+ Frame_Count_InThisBlock++;
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ }
+
+ if (!Status[IsFilled] && Parser->Status[IsFilled])
+ {
+ //Filling
+ Merge(*Parser);
+ ZtringList OverallBitRates; OverallBitRates.Separator_Set(0, _T(" / ")); OverallBitRates.Write(Parser->Retrieve(Stream_General, 0, General_OverallBitRate));
+ if (!OverallBitRates.empty())
+ {
+ int64u OverallBitRate=OverallBitRates[0].To_int64u();
+ if (OverallBitRate)
+ {
+ OverallBitRate*=Element_Offset; OverallBitRate/=Parser_Buffer_Size;
+ OverallBitRates[0].From_Number(OverallBitRate);
+ }
+ Fill(Stream_General, 0, General_OverallBitRate, OverallBitRates.Read(), true);
+ }
+ FrameRate=((File_Aes3*)Parser)->FrameRate;
+ Fill("AES3");
+ if (!From_MpegPs)
+ Finish("AES3");
+ }
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_AES3_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aes3.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aes3.h
new file mode 100644
index 000000000..e5e202432
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Aes3.h
@@ -0,0 +1,114 @@
+// File_Aes3 - Info Info for AES3 packetized streams
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about PCM files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Aes3H
+#define MediaInfo_File_Aes3H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Aes3
+//***************************************************************************
+
+class File_Aes3 : public File__Analyze
+{
+public :
+ //In
+ int64u SampleRate;
+ size_t ByteSize;
+ int32u QuantizationBits;
+ int32u ChannelCount;
+ bool From_Raw;
+ bool From_MpegPs;
+ bool From_Aes3;
+ bool IsAes3;
+ int8u Endianness;
+
+ //Out
+ float64 FrameRate;
+
+ //Constructor/Destructor
+ File_Aes3();
+ ~File_Aes3();
+
+private :
+ //Streams management
+ void Streams_Accept();
+ void Streams_Fill();
+
+ //Buffer - Global
+ void Read_Buffer_Init ();
+ void Read_Buffer_Continue ();
+ #if MEDIAINFO_SEEK
+ void Read_Buffer_Unsynched();
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+ void Synched_Init();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Raw();
+ void Frame();
+ void Frame_WithPadding();
+ void Frame_FromMpegPs();
+
+ //Temp
+ int64u Frame_Size;
+ int64u Frame_Duration;
+ int64u IsPcm_Frame_Count;
+ int64u NotPCM_SizePerFrame;
+ int8u number_channels;
+ int8u bits_per_sample;
+ int8u Container_Bits;
+ int8u Stream_Bits;
+ int8u data_type;
+ bool IsParsingNonPcm;
+ bool IsPcm;
+
+ //Parser
+ File__Analyze* Parser;
+ void Parser_Parse(const int8u* Parser_Buffer, size_t Parser_Buffer_Size);
+
+ #if MEDIAINFO_SEEK
+ bool Duration_Detected;
+ #endif //MEDIAINFO_SEEK
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Als.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Als.cpp
new file mode 100644
index 000000000..5b0e8f648
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Als.cpp
@@ -0,0 +1,151 @@
+// File_Als - Info for MPEG-4 ALS files
+// Copyright (C) 2009-2011 Lionel Duchateau, kurtnoise@free.fr
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MPEG-4 ALS files
+// http://www.nue.tu-berlin.de/forschung/projekte/lossless/mp4als.html
+// http://wiki.multimedia.cx/index.php?title=MPEG-4_Audio_Lossless_Coding_%28ALS%29
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_ALS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Als.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Als::File_Als()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Als::Streams_Finish()
+{
+ //Filling
+ int64u CompressedSize=File_Size-TagsSize;
+ float32 CompressionRatio=((float32)UncompressedSize)/CompressedSize;
+
+ Fill(Stream_Audio, 0, Audio_StreamSize, CompressedSize);
+ Fill(Stream_Audio, 0, Audio_Compression_Ratio, CompressionRatio);
+
+ File__Tags_Helper::Streams_Finish();
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Als::FileHeader_Begin()
+{
+ if (!File__Tags_Helper::FileHeader_Begin())
+ return false;
+
+ //Synchro
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ if (CC4(Buffer+Buffer_Offset)!=0x414C5300) //"ALS\0"
+ {
+ File__Tags_Helper::Reject("ALS");
+ return false;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Als::FileHeader_Parse()
+{
+ //Parsing
+ int32u SampleRate, Samples;
+ int16u Channels;
+ int8u BitsPerSample, FileType;
+ Skip_C4( "signature");
+ Get_B4 (SampleRate, "sample rate");
+ Get_B4 (Samples, "samples");
+ Get_B2 (Channels, "channels-1"); Param_Info2(Channels+1, " channel(s)");
+ BS_Begin();
+ Get_S1 (3, FileType, "file type"); // WAV, RIFF, AIFF
+ Get_S1 (3, BitsPerSample, "bits per sample"); Param_Info2((BitsPerSample+1)*8, " bits");
+ Skip_SB( "floating point");
+ Skip_SB( "samples are big-endian");
+ BS_End();
+
+ FILLING_BEGIN()
+ if (SampleRate==0)
+ return;
+ Duration=((int64u)Samples)*1000/SampleRate;
+ if (Duration==0)
+ return;
+ UncompressedSize=Samples*Channels*(BitsPerSample+1/8);
+ if (UncompressedSize==0)
+ return;
+
+ File__Tags_Helper::Accept("ALS");
+
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "ALS");
+ Fill(Stream_Audio, 0, Audio_Codec, "ALS");
+ Fill(Stream_Audio, 0, Audio_BitDepth, (BitsPerSample+1)*8);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels+1);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, SampleRate);
+ Fill(Stream_Audio, 0, Audio_Duration, Duration);
+
+ //No more need data
+ File__Tags_Helper::Finish("ALS");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_ALS_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Als.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Als.h
new file mode 100644
index 000000000..85f4e72a1
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Als.h
@@ -0,0 +1,63 @@
+// File_Als - Info for MPEG-4 ALS files
+// Copyright (C) 2009-2009 Lionel Duchateau, kurtnoise@free.fr
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_AlsH
+#define MediaInfo_File_AlsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Tag/File__Tags.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Als
+//***************************************************************************
+
+class File_Als : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //Constructor/Destructor
+ File_Als();
+
+private :
+ //Streams management
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Global
+ void Read_Buffer_Continue() {File__Tags_Helper::Read_Buffer_Continue();}
+
+ //Temp
+ int64u Duration;
+ int64u UncompressedSize;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amr.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amr.cpp
new file mode 100644
index 000000000..a57a7dd1f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amr.cpp
@@ -0,0 +1,275 @@
+// File_Amr - Info for AMR files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AMR_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Amr.h"
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+int16u Amr_BitRate[]=
+{
+ 5200,
+ 5600,
+ 6400,
+ 7200,
+ 8000,
+ 8400,
+ 10800,
+ 12800,
+ 3600,
+ 3600,
+ 3600,
+ 3600,
+ 0,
+ 0,
+ 0,
+ 400,
+};
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Amr::File_Amr()
+:File__Analyze()
+{
+ //Temp
+ Header_Size=(int64u)-1;
+ Frame_Number=0;
+ FrameType=(int8u)-1;
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Amr::FileHeader_Begin()
+{
+ if (!Codec.empty()) //Test of header only if it is a file --> The codec field is empty
+ return true;
+
+ //Testing
+ if (Buffer_Size<5)
+ return false; //Must wait for more data
+ if (CC5(Buffer)!=0x2321414D52LL) //"#!AMR"
+ {
+ Reject("AMR");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Amr::Streams_Fill()
+{
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "AMR");
+ Fill(Stream_Audio, 0, Audio_Codec, "AMR");
+ if (!Codec.empty())
+ {
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Mpeg4, Codec, InfoCodecID_Profile)==_T("Narrow band"))
+ IsWB=false;
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Mpeg4, Codec, InfoCodecID_Profile)==_T("Wide band"))
+ IsWB=true;
+ Channels=1;
+ }
+ if (Channels==0)
+ return; //No more info
+
+ if (Header_Size!=(int64u)-1)
+ Fill(Stream_General, 0, General_StreamSize, Header_Size);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Channels);
+ if (IsWB)
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Profile, "Wide band");
+ Fill(Stream_Audio, 0, Audio_Codec, "sawb", Unlimited, true, true);
+ if (Codec.empty()) //If there is a container, trusting the container sampling rate
+ Fill(Stream_Audio, 0, Audio_SamplingRate, 16000);
+ Fill(Stream_Audio, 0, Audio_BitDepth, 14);
+ //Fill(Stream_Audio, 0, Audio_InternetMediaType, "audio/AMR-WB", Unlimited, true, true);
+ }
+ else
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Profile, "Narrow band");
+ Fill(Stream_Audio, 0, Audio_Codec, "samr", Unlimited, true, true);
+ if (Codec.empty()) //If there is a container, trusting the container sampling rate
+ Fill(Stream_Audio, 0, Audio_SamplingRate, 8000);
+ Fill(Stream_Audio, 0, Audio_BitDepth, 13);
+ if (FrameType!=(int8u)-1 && Amr_BitRate[FrameType] && FrameTypes.size()==1)
+ {
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR");
+ Fill(Stream_Audio, 0, Audio_BitRate, Amr_BitRate[FrameType]);
+ Fill(Stream_General, 0, General_OverallBitRate, Amr_BitRate[FrameType]);
+ if (File_Size!=(int64u)-1)
+ {
+ Fill(Stream_Audio, 0, Audio_Duration, ((float32)(File_Size-Header_Size))*8*1000/Amr_BitRate[FrameType]);
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Amr::Streams_Finish()
+{
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Amr::FileHeader_Parse()
+{
+ //From a container
+ if (!Codec.empty())
+ {
+ Accept("AMR");
+ Finish("AMR");
+ return;
+ }
+
+ //Parsing
+ int64u Signature;
+ Skip_C5( "Signature (Common)");
+ Peek_B8(Signature);
+ if ((Signature&0xFF00000000000000LL)==0x0A00000000000000LL) //\n
+ {
+ IsWB=false;
+ Channels=1;
+ }
+ else if ((Signature&0xFFFFFFFFFFFFFF00LL)==0x5F4D43312E300A00LL) //_MC1.0\n
+ {
+ IsWB=false;
+ Channels=2; //Or more, see later
+ }
+ else if ((Signature&0xFFFFFF0000000000LL)==0x2D57420000000000LL) //-WB
+ {
+ Skip_C3( "Signature (WB)");
+ IsWB=true;
+
+ Peek_B8(Signature);
+ if ((Signature&0xFF00000000000000LL)==0x0A00000000000000LL) //\n
+ {
+ Channels=1;
+ }
+ else if ((Signature&0xFFFFFFFFFFFFFF00LL)==0x5F4D43312E300A00LL) //_MC1.0\n
+ {
+ Channels=2; //Or more, see later
+ }
+ }
+ else
+ Channels=0;
+ Skip_B1( "Signature (Carriage return)");
+ /*
+ if (Channels==2) //Mutli-channels
+ {
+ BS_Begin();
+ Skip_S4(28, "Reserved");
+ Get_S1 ( 4, Channels, "Channels");
+ }
+ */
+ Header_Size=(int8u)Element_Offset;
+
+
+ FILLING_BEGIN();
+ Accept("AMR");
+
+ if (Channels!=1 || IsWB)
+ Finish("AMR");
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Amr::Header_Parse()
+{
+ BS_Begin();
+ Skip_SB( "Frame Following");
+ Get_S1 ( 4, FrameType, "Frame Type");
+ Skip_SB( "Frame Quality");
+ Skip_SB( "Unknown");
+ Skip_SB( "Unknown");
+ BS_End();
+
+ //Filling
+ if (Amr_BitRate[FrameType]==0)
+ {
+ Finish("AMR");
+ return;
+ }
+ Header_Fill_Size(Amr_BitRate[FrameType]/400);
+ Header_Fill_Code(0, "frame");
+}
+
+//---------------------------------------------------------------------------
+void File_Amr::Data_Parse()
+{
+ Element_Info1(Frame_Number);
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+
+
+ FILLING_BEGIN();
+ Frame_Number++;
+ FrameTypes[FrameType]++;
+ if (Frame_Number>=32)
+ Finish("AMR");
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_AMR_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amr.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amr.h
new file mode 100644
index 000000000..879bc8e95
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amr.h
@@ -0,0 +1,75 @@
+// File_Amr - Info for AMR files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Musepack files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_AmrH
+#define MediaInfo_File_AmrH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Amr
+//***************************************************************************
+
+class File_Amr : public File__Analyze
+{
+public :
+ //In
+ ZenLib::Ztring Codec;
+
+public :
+ File_Amr();
+
+protected :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse ();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Temp
+ size_t Frame_Number;
+ std::map<int8u, size_t> FrameTypes;
+ int64u Header_Size;
+ int8u FrameType;
+ int8u Channels;
+ bool IsWB;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amv.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amv.cpp
new file mode 100644
index 000000000..28558f713
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amv.cpp
@@ -0,0 +1,59 @@
+// File_Amv - Info for AMV files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AMV_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Amv.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Amv::Read_Buffer_Continue()
+{
+ Reject("AMV");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_AMV_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amv.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amv.h
new file mode 100644
index 000000000..63b5c5907
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Amv.h
@@ -0,0 +1,49 @@
+// File_Amv - Info for AMV files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about asian AMV files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_AmvH
+#define MediaInfo_File_AmvH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Amv
+//***************************************************************************
+
+class File_Amv : public File__Analyze
+{
+protected :
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ape.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ape.cpp
new file mode 100644
index 000000000..60194f5a9
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ape.cpp
@@ -0,0 +1,221 @@
+// File_Ape - Info for Ape files
+// Copyright (C) 2003-2009 Jasper van de Gronde, th.v.d.gronde@hccnet.nl
+// Copyright (C) 2003-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_APE_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Ape.h"
+using namespace std;
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+int32u Ape_SamplesPerFrame(int16u Version, int16u CompressionLevel)
+{
+ if (Version>=3950)
+ return 73728*4;
+ else if (Version>=3900)
+ return 73728;
+ else if (Version>=3800 && CompressionLevel==4000)
+ return 73728;
+ else
+ return 9216;
+}
+
+//---------------------------------------------------------------------------
+const char* Ape_Codec_Settings(int16u Setting)
+{
+ switch (Setting)
+ {
+ case 1000 : return "Fast";
+ case 2000 : return "Normal";
+ case 3000 : return "High";
+ case 4000 : return "Extra-high";
+ case 5000 : return "Insane";
+ default : return "";
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Ape::File_Ape()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ape::Streams_Finish()
+{
+ //Filling
+ int64u CompressedSize=File_Size-TagsSize;
+ float32 CompressionRatio=((float32)UncompressedSize)/CompressedSize;
+ int64u BitRate=Duration?(CompressedSize*8*1000/Duration):0;
+
+ Fill(Stream_Audio, 0, Audio_Compression_Ratio, CompressionRatio);
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate);
+
+ File__Tags_Helper::Streams_Finish();
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Ape::FileHeader_Begin()
+{
+ if (!File__Tags_Helper::FileHeader_Begin())
+ return false;
+
+ //Testing
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ if (CC4(Buffer+Buffer_Offset)!=0x4D414320) //"MAC "
+ {
+ File__Tags_Helper::Reject("APE");
+ return false;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Ape::FileHeader_Parse()
+{
+ //Parsing
+ int32u SampleRate=0, TotalFrames=0, FinalFrameSamples=0, SamplesPerFrame=0, SeekElements;
+ int16u Version, CompressionLevel=0, Flags=0, Channels=0, Resolution=0;
+ bool Resolution8=false, Resolution24=false, no_wav_header;
+ Skip_C4( "Identifier");
+ Get_L2 (Version, "Version");
+ if (Version<3980) //<3.98
+ {
+ Get_L2 (CompressionLevel, "CompressionLevel"); Param_Info1(Ape_Codec_Settings(CompressionLevel));
+ Get_L2 (Flags, "FormatFlags");
+ Get_Flags (Flags, 0, Resolution8, "8-bit");
+ Skip_Flags(Flags, 1, "crc-32");
+ Skip_Flags(Flags, 2, "peak_level");
+ Get_Flags (Flags, 3, Resolution24, "24-bit");
+ Skip_Flags(Flags, 4, "seek_elements");
+ Get_Flags (Flags, 5, no_wav_header, "no_wav_header");
+ if (Resolution8)
+ Resolution=8;
+ else if (Resolution24)
+ Resolution=24;
+ else
+ Resolution=16;
+ Get_L2 (Channels, "Channels");
+ Get_L4 (SampleRate, "SampleRate");
+ Skip_L4( "WavHeaderDataBytes");
+ Skip_L4( "WavTerminatingBytes");
+ Get_L4 (TotalFrames, "TotalFrames");
+ Get_L4 (FinalFrameSamples, "FinalFrameSamples");
+ SamplesPerFrame=Ape_SamplesPerFrame(Version, CompressionLevel);
+ Skip_L4( "PeakLevel");
+ Get_L4 (SeekElements, "SeekElements");
+ if (!no_wav_header)
+ Skip_XX(44, "RIFF header");
+ Skip_XX(SeekElements*4, "Seek table");
+ }
+ else
+ {
+ Skip_L2( "Version_High");
+ Skip_L4( "DescriptorBytes");
+ Skip_L4( "HeaderBytes");
+ Skip_L4( "SeekTableBytes");
+ Skip_L4( "WavHeaderDataBytes");
+ Skip_L4( "APEFrameDataBytes");
+ Skip_L4( "APEFrameDataBytesHigh");
+ Skip_L4( "WavTerminatingDataBytes");
+ Skip_L16( "FileMD5");
+ Get_L2 (CompressionLevel, "CompressionLevel"); Param_Info1(Ape_Codec_Settings(CompressionLevel));
+ Get_L2 (Flags, "FormatFlags");
+ Get_L4 (SamplesPerFrame, "BlocksPerFrame");
+ Get_L4 (FinalFrameSamples, "FinalFrameBlocks");
+ Get_L4 (TotalFrames, "TotalFrames");
+ Get_L2 (Resolution, "BitsPerSample");
+ Get_L2 (Channels, "Channels");
+ Get_L4 (SampleRate, "SampleRate");
+ }
+
+ FILLING_BEGIN();
+ //Coherancy
+ int32u Samples=(TotalFrames-1)*SamplesPerFrame+FinalFrameSamples;
+ if (Samples==0 || SampleRate==0 || Channels==0 || Resolution==0)
+ {
+ File__Tags_Helper::Reject("APE");
+ return;
+ }
+
+ //Filling
+ File__Tags_Helper::Accept("APE");
+ File__Tags_Helper::Streams_Fill();
+
+ Duration=((int64u)Samples)*1000/SampleRate;
+ UncompressedSize=Samples*Channels*(Resolution/8);
+
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "Monkey's Audio");
+ Fill(Stream_Audio, 0, Audio_Encoded_Library_Settings, Ape_Codec_Settings(CompressionLevel));
+ Fill(Stream_Audio, 0, Audio_Codec, "APE");
+ Fill(Stream_Audio, 0, Audio_BitDepth, Resolution);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Channels);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, SampleRate);
+ Fill(Stream_Audio, 0, Audio_Duration, Duration);
+
+ //No more need data
+ File__Tags_Helper::Finish("APE");
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_APE_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ape.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ape.h
new file mode 100644
index 000000000..efcf1e380
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ape.h
@@ -0,0 +1,67 @@
+// File_Ape - Info for Ape Audio files
+// Copyright (C) 2003-2009 Jasper van de Gronde, th.v.d.gronde@hccnet.nl
+// Copyright (C) 2003-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Ape files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_ApeH
+#define MediaInfo_File_ApeH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Tag/File__Tags.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Ape
+//***************************************************************************
+
+class File_Ape : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //Constructor/Destructor
+ File_Ape();
+
+private :
+ //Streams management
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Global
+ void Read_Buffer_Continue() {File__Tags_Helper::Read_Buffer_Continue();}
+
+ //Temp
+ int64u Duration;
+ int64u UncompressedSize;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Au.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Au.cpp
new file mode 100644
index 000000000..241fbd35c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Au.cpp
@@ -0,0 +1,187 @@
+// File_Au - Info for AU files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Source: http://wiki.multimedia.cx/index.php?title=Au/snd
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AU_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Au.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Au_Format(int32u sample_format)
+{
+ switch (sample_format)
+ {
+ case 1 : return "ADPCM";
+ case 2 : return "PCM";
+ case 3 : return "PCM";
+ case 4 : return "PCM";
+ case 5 : return "PCM";
+ case 6 : return "PCM";
+ case 7 : return "PCM";
+ case 8 : return "fragmented sampled data";
+ case 10 : return "DSP program";
+ case 11 : return "PCM";
+ case 12 : return "PCM";
+ case 13 : return "PCM";
+ case 14 : return "PCM";
+ case 17 : return "ADPCM";
+ case 18 : return "PCM";
+ case 19 : return "PCM";
+ case 20 : return "PCM";
+ case 21 : return "Music Kit DSP commands";
+ case 22 : return "Music Kit DSP samples";
+ case 23 : return "ADPCM";
+ case 24 : return "ADPCM";
+ case 25 : return "ADPCM";
+ case 26 : return "ADPCM";
+ case 27 : return "ADPCM";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Au_sample_format(int32u sample_format)
+{
+ switch (sample_format)
+ {
+ case 1 : return "8-bit mu-law";
+ case 2 : return "8-bit signed linear";
+ case 3 : return "16-bit signed linear";
+ case 4 : return "24-bit signed linear";
+ case 5 : return "32-bit signed linear";
+ case 6 : return "floating-point";
+ case 7 : return "double precision float";
+ case 8 : return "fragmented sampled data";
+ case 10 : return "DSP program";
+ case 11 : return "8-bit fixed-point";
+ case 12 : return "16-bit fixed-point";
+ case 13 : return "24-bit fixed-point";
+ case 14 : return "32-bit fixed-point";
+ case 17 : return "mu-law squelch";
+ case 18 : return "16-bit linear with emphasis";
+ case 19 : return "16-bit linear with compression";
+ case 20 : return "16-bit linear with emphasis and compression";
+ case 21 : return "Music Kit DSP commands";
+ case 22 : return "Music Kit DSP samples";
+ case 23 : return "G.721 ADPCM";
+ case 24 : return "G.722 ADPCM";
+ case 25 : return "G.723 ADPCM";
+ case 26 : return "5-bit G.723 ADPCM";
+ case 27 : return "8-bit a-law";
+ default : return "";
+ }
+}
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Au::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ if (CC4(Buffer)!=0x2E736E64) //".snd"
+ {
+ Reject("AU");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Au::FileHeader_Parse()
+{
+ //Parsing
+ Ztring arbitrary;
+ int32u data_start, data_size, sample_format, sample_rate, channels;
+ Skip_B4( "Magic");
+ Get_B4 (data_start, "data_start");
+ Get_B4 (data_size, "data_size");
+ Get_B4 (sample_format, "sample_format");
+ Get_B4 (sample_rate, "sample_rate");
+ Get_B4 (channels, "channels");
+ if (data_start>24)
+ Get_Local(data_start-24, arbitrary, "arbitrary data");
+
+ FILLING_BEGIN();
+ Accept("AU");
+
+ Fill(Stream_General, 0, General_Format, "AU");
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, Au_Format(sample_format));
+ Fill(Stream_Audio, 0, Audio_CodecID, Au_sample_format(sample_format));
+ Fill(Stream_Audio, 0, Audio_Codec, Au_sample_format(sample_format));
+ Fill(Stream_Audio, 0, Audio_Channel_s_, channels);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, sample_rate);
+ if (File_Size!=(int64u)-1)
+ data_size=(int32u)File_Size-data_start; //Priority for File size
+ if (sample_rate && data_size!=0 && data_size!=0xFFFFFFFF)
+ Fill(Stream_Audio, 0, Audio_Duration, ((int64u)data_size)*1000/sample_rate);
+ Fill(Stream_Audio, 0, Audio_StreamSize, File_Size-Element_Offset);
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR");
+ Fill(Stream_General, 0, General_Comment, arbitrary);
+
+ //No more need data
+ Finish("AU");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_AU_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Au.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Au.h
new file mode 100644
index 000000000..f031db2f4
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Au.h
@@ -0,0 +1,50 @@
+// File_Au - Info for AU files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about AU files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_AuH
+#define MediaInfo_File_AuH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Au
+//***************************************************************************
+
+class File_Au : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Celt.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Celt.cpp
new file mode 100644
index 000000000..b891768e0
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Celt.cpp
@@ -0,0 +1,161 @@
+// File_Celt - Info for CELT files
+// Copyright (C) 2010-2011 Lionel Duchateau, kurtnoise@free.fr
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Note : the buffer must be given in ONE call
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_CELT_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Celt.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Celt::File_Celt()
+:File__Analyze()
+{
+ //Internal
+ Identification_Done=false;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Celt::Header_Parse()
+{
+ //Filling
+ Header_Fill_Code(0, "CELT");
+ Header_Fill_Size(Element_Size);
+}
+
+//---------------------------------------------------------------------------
+void File_Celt::Data_Parse()
+{
+ //Parsing
+ if (Identification_Done)
+ Comment();
+ else
+ Identification();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Celt::Identification()
+{
+ Element_Name("Identification");
+
+ //Parsing
+ Ztring celt_version;
+ int32u Celt_version_id, sample_rate, nb_channels;
+ Skip_Local(8, "celt_codec_id");
+ Get_Local(20, celt_version, "celt_version");
+ Get_L4 (Celt_version_id, "celt_version_id");
+ Skip_L4( "header_size");
+ Get_L4 (sample_rate, "rate");
+ Get_L4 (nb_channels, "nb_channels");
+ Skip_L4( "frame_size");
+ Skip_L4( "overlap");
+ Skip_L4( "bytes_per_packet");
+ Skip_L4( "extra_headers");
+
+ //Filling
+ FILLING_BEGIN()
+ Accept("CELT");
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "CELT");
+ Fill(Stream_Audio, 0, Audio_Codec, "CELT");
+
+ if (!celt_version.empty())
+ {
+ //Fill(Stream_Audio, 0, Audio_Encoded_Library, celt_version); //Need more info about hte different possibilities, in the meanwhile trusting more the comment part
+ Fill(Stream_Audio, 0, Audio_SamplingRate, sample_rate);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, nb_channels);
+ }
+
+ FILLING_END();
+
+ //Filling
+ Identification_Done=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Celt::Comment()
+{
+ Element_Name("Comment?");
+
+ while (Element_Offset<Element_Size)
+ {
+ Ztring value;
+ int32u size;
+ Get_L4(size, "size");
+ if (size)
+ Get_Local(size, value, "value");
+
+ //Filling
+ if (value.find(_T("CELT "))!=std::string::npos)
+ {
+ Ztring Version=value.SubString(_T("CELT "), _T(" ("));
+ Fill(Stream_Audio, 0, Audio_Encoded_Library, _T("CELT ")+Version);
+ Fill(Stream_Audio, 0, Audio_Encoded_Library_Name, _T("CELT"));
+ Fill(Stream_Audio, 0, Audio_Encoded_Library_Version, Version);
+ }
+ else if (!value.empty())
+ Fill(Stream_Audio, 0, "Comment", value);
+ }
+
+ Finish("CELT");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_CELT_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Celt.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Celt.h
new file mode 100644
index 000000000..19c2b765d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Celt.h
@@ -0,0 +1,65 @@
+// File_Celt - Info for CELT files
+// Copyright (C) 2010-2011 Lionel Duchateau, kurtnoise@free.fr
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about CELT files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_CeltH
+#define MediaInfo_File_CeltH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Celt
+//***************************************************************************
+
+class File_Celt : public File__Analyze
+{
+public :
+ File_Celt();
+
+private :
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Identification();
+ void Comment();
+
+ //Temp
+ int8u Identification_Done;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ChannelGrouping.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ChannelGrouping.cpp
new file mode 100644
index 000000000..29033c206
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ChannelGrouping.cpp
@@ -0,0 +1,333 @@
+// File_ChannelGrouping - Regrouping PCM streams
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AES3_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_ChannelGrouping.h"
+#if defined(MEDIAINFO_AES3_YES)
+ #include "MediaInfo/Audio/File_Aes3.h"
+#endif
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+File_ChannelGrouping::File_ChannelGrouping()
+{
+ //Configuration
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_ChannelGrouping;
+ StreamIDs_Width[0]=0;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ #endif //MEDIAINFO_DEMUX
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(0); //Container1
+ #endif //MEDIAINFO_TRACE
+ IsRawStream=true;
+
+ //In
+ ByteDepth=0;
+ Common=NULL;
+ Channel_Pos=0;
+ Channel_Total=1;
+ SampleRate=0;
+ Endianness=0;
+ IsAes3=false;
+
+ //Temp
+ Buffer_Offset_AlreadyInCommon=0;
+ IsPcm_Frame_Count=0;
+}
+
+File_ChannelGrouping::~File_ChannelGrouping()
+{
+ if (Channel_Pos==0)
+ {
+ for (size_t Pos=0; Pos<Common->Channels.size(); Pos++)
+ delete Common->Channels[Pos]; //Common->Channels[Pos]=NULL;
+ delete Common; //Common=NULL;
+ }
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_ChannelGrouping::Streams_Fill()
+{
+ if (Common->Parser->Count_Get(Stream_Audio)==0 || Common->Parser->Get(Stream_Audio, 0, Audio_Format)==_T("PCM"))
+ {
+ Fill(Stream_General, 0, General_Format, "PCM");
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ Fill(Stream_Audio, 0, Audio_Codec, "PCM");
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR");
+ switch (Endianness)
+ {
+ case 'B' : Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, "Big"); break;
+ case 'L' : Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, "Little"); break;
+ default : ;
+ }
+ return;
+ }
+
+ if (!Common->IsAes3)
+ return; //Nothing to do
+
+ Fill(Stream_General, 0, General_Format, "ChannelGrouping");
+
+ if (Common->Channel_Master!=Channel_Pos)
+ return;
+ Fill(Common->Parser);
+ Merge(*Common->Parser);
+}
+
+//---------------------------------------------------------------------------
+void File_ChannelGrouping::Streams_Finish()
+{
+ if (!Common->IsAes3)
+ return; //Nothing to do
+
+ if (Common->Channel_Master!=Channel_Pos)
+ return;
+ Finish(Common->Parser);
+ //Merge(*Common->Parser);
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_ChannelGrouping::Read_Buffer_Init()
+{
+ if (Common==NULL)
+ {
+ Common=new common;
+ Common->Parser=new File_Aes3;
+ ((File_Aes3*)Common->Parser)->SampleRate=SampleRate;
+ ((File_Aes3*)Common->Parser)->ByteSize=ByteDepth*Channel_Total;
+ ((File_Aes3*)Common->Parser)->IsAes3=IsAes3;
+ Common->Channels.resize(Channel_Total);
+ for (size_t Pos=0; Pos<Common->Channels.size(); Pos++)
+ Common->Channels[Pos]=new common::channel;
+ Element_Code=(int64u)-1;
+ Open_Buffer_Init(Common->Parser);
+ }
+
+ Accept(); //Forcing acceptance, no possibility to choose something else or detect PCM
+ #if MEDIAINFO_DEMUX
+ Demux_UnpacketizeContainer=Config->Demux_Unpacketize_Get();
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_ChannelGrouping::Read_Buffer_Continue()
+{
+ //Handling of multiple frames in one block
+ if (Buffer_Size-Buffer_Offset_AlreadyInCommon==0)
+ {
+ if (Common->Parser && Common->Parser->Buffer_Size)
+ Open_Buffer_Continue(Common->Parser, Common->MergedChannel.Buffer+Common->MergedChannel.Buffer_Offset, 0);
+ Element_WaitForMoreData();
+ return;
+ }
+
+ //If basic PCM is already detected
+ if (!IsAes3 && Common->IsPcm)
+ {
+ if (Buffer_Size==Buffer_Offset_AlreadyInCommon)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ Buffer_Offset_AlreadyInCommon=0;
+
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ Demux_Offset=Buffer_Size;
+ FrameInfo.PTS=FrameInfo.DTS;
+ if (FrameInfo.DUR!=(int64u)-1 && IsPcm_Frame_Count)
+ FrameInfo.DUR*=IsPcm_Frame_Count+1;
+ Demux_UnpacketizeContainer_Demux();
+ #endif //MEDIAINFO_DEMUX
+
+ Skip_XX(Element_Size, "Data");
+
+ if (IsPcm_Frame_Count)
+ {
+ Frame_Count+=IsPcm_Frame_Count;
+ Frame_Count_InThisBlock+=IsPcm_Frame_Count;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded+=IsPcm_Frame_Count;
+ IsPcm_Frame_Count=0;
+ }
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+
+ if (!Status[IsFilled])
+ {
+ Finish();
+ }
+
+ return;
+ }
+ else if (Buffer_Size && Buffer_Size>Buffer_Offset_AlreadyInCommon && !Common->IsAes3)
+ IsPcm_Frame_Count++;
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer)
+ {
+ Common->Parser->Demux_UnpacketizeContainer=true;
+ Common->Parser->Demux_Level=2; //Container
+ Demux_Level=4; //Intermediate
+ }
+ Demux(Common->MergedChannel.Buffer+Common->MergedChannel.Buffer_Offset, Common->MergedChannel.Buffer_Size-Common->MergedChannel.Buffer_Offset, ContentType_MainStream);
+ #endif //MEDIAINFO_EVENTS
+
+ //Copying to Channel buffer
+ if (Common->Channels[Channel_Pos]->Buffer_Size+Buffer_Size-Buffer_Offset_AlreadyInCommon>Common->Channels[Channel_Pos]->Buffer_Size_Max)
+ Common->Channels[Channel_Pos]->resize(Common->Channels[Channel_Pos]->Buffer_Size+Buffer_Size-Buffer_Offset_AlreadyInCommon);
+ memcpy(Common->Channels[Channel_Pos]->Buffer+Common->Channels[Channel_Pos]->Buffer_Size, Buffer+Buffer_Offset_AlreadyInCommon, Buffer_Size-Buffer_Offset_AlreadyInCommon);
+ Common->Channels[Channel_Pos]->Buffer_Size+=Buffer_Size-Buffer_Offset_AlreadyInCommon;
+ if (!Common->IsAes3 && !Common->IsPcm)
+ Buffer_Offset_AlreadyInCommon=Buffer_Size;
+ else
+ Buffer_Offset_AlreadyInCommon=0;
+ Common->Channel_Current++;
+ if (Common->Channel_Current>=Channel_Total)
+ Common->Channel_Current=0;
+
+ //Copying to merged channel
+ size_t Minimum=(size_t)-1;
+ for (size_t Pos=0; Pos<Common->Channels.size(); Pos++)
+ if (Minimum>Common->Channels[Pos]->Buffer_Size-Common->Channels[Pos]->Buffer_Offset)
+ Minimum=Common->Channels[Pos]->Buffer_Size-Common->Channels[Pos]->Buffer_Offset;
+ while (Minimum>=ByteDepth)
+ {
+ for (size_t Pos=0; Pos<Common->Channels.size(); Pos++)
+ {
+ if (Common->MergedChannel.Buffer_Size+Minimum>Common->MergedChannel.Buffer_Size_Max)
+ Common->MergedChannel.resize(Common->MergedChannel.Buffer_Size+Minimum);
+ memcpy(Common->MergedChannel.Buffer+Common->MergedChannel.Buffer_Size, Common->Channels[Pos]->Buffer+Common->Channels[Pos]->Buffer_Offset, ByteDepth);
+ Common->Channels[Pos]->Buffer_Offset+=ByteDepth;
+ Common->MergedChannel.Buffer_Size+=ByteDepth;
+ }
+ Minimum-=ByteDepth;
+ }
+
+ if (Common->MergedChannel.Buffer_Size-Common->MergedChannel.Buffer_Offset)
+ {
+ if (FrameInfo_Next.DTS!=(int64u)-1)
+ Common->Parser->FrameInfo=FrameInfo_Next; //AES3 parse has its own buffer management
+ else
+ Common->Parser->FrameInfo=FrameInfo;
+ Open_Buffer_Continue(Common->Parser, Common->MergedChannel.Buffer+Common->MergedChannel.Buffer_Offset, Common->MergedChannel.Buffer_Size-Common->MergedChannel.Buffer_Offset);
+ Common->MergedChannel.Buffer_Offset=Common->MergedChannel.Buffer_Size;
+ }
+
+ if (!Common->IsAes3)
+ {
+ if (!Status[IsFilled] && Common->Parser->Status[IsAccepted])
+ {
+ if (Common->Parser->Get(Stream_Audio, 0, Audio_Format)==_T("PCM"))
+ Common->IsPcm=true;
+ else
+ {
+ Common->IsAes3=true;
+ if (Common->Channel_Master==(size_t)-1)
+ Common->Channel_Master=Channel_Pos;
+ Buffer_Offset_AlreadyInCommon=0;
+ Fill();
+ }
+ }
+ else if (Common->MergedChannel.Buffer_Size==0 && IsPcm_Frame_Count>=2)
+ Common->IsPcm=true;
+ }
+
+ if (Common->IsAes3 || Common->IsPcm)
+ {
+ Buffer_Offset=Buffer_Size;
+ Buffer_Offset_AlreadyInCommon=0;
+ }
+ else
+ Element_WaitForMoreData();
+
+ if (Common->Parser->Status[IsFinished])
+ Finish();
+
+ //Optimize buffer
+ for (size_t Pos=0; Pos<Common->Channels.size(); Pos++)
+ Common->Channels[Pos]->optimize();
+ Common->MergedChannel.optimize();
+}
+
+//---------------------------------------------------------------------------
+void File_ChannelGrouping::Read_Buffer_Unsynched()
+{
+ if (Common->Parser)
+ Common->Parser->Open_Buffer_Unsynch();
+
+ Buffer_Offset_AlreadyInCommon=0;
+ Common->MergedChannel.Buffer_Offset=0;
+ Common->MergedChannel.Buffer_Size=0;
+ for (size_t Pos=0; Pos<Common->Channels.size(); Pos++)
+ {
+ Common->Channels[Pos]->Buffer_Offset=0;
+ Common->Channels[Pos]->Buffer_Size=0;
+ }
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_AES3_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ChannelGrouping.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ChannelGrouping.h
new file mode 100644
index 000000000..f626678fe
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ChannelGrouping.h
@@ -0,0 +1,147 @@
+// File_ChannelGrouping - Regrouping PCM streams
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Some containers use mono stream for AES3 (Stereo) grouping
+// We need to group the 2-mono streams in one before sending
+// data to AES parser
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_ChannelGroupingH
+#define MediaInfo_File_ChannelGroupingH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <cstring>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_ChannelGrouping
+//***************************************************************************
+
+class File_ChannelGrouping : public File__Analyze
+{
+public :
+ //In
+ size_t ByteDepth;
+ struct common
+ {
+ struct channel
+ {
+ int8u* Buffer;
+ size_t Buffer_Offset;
+ size_t Buffer_Size;
+ size_t Buffer_Size_Max;
+
+ channel()
+ {
+ Buffer=new int8u[32768];
+ Buffer_Offset=0;
+ Buffer_Size=0;
+ Buffer_Size_Max=32768;
+ }
+
+ ~channel()
+ {
+ delete[] Buffer; //Buffer=NULL;
+ }
+
+ void resize(size_t NewSize)
+ {
+ if (NewSize<Buffer_Size_Max)
+ return;
+ int8u* Old=Buffer;
+ if (NewSize<2*Buffer_Size_Max)
+ Buffer_Size_Max*=2;
+ else
+ Buffer_Size_Max=NewSize;
+ Buffer=new int8u[Buffer_Size_Max];
+ std::memcpy(Buffer, Old, Buffer_Size);
+ delete[] Old; //Old=NULL;
+ }
+
+ void optimize()
+ {
+ if (Buffer_Offset<Buffer_Size_Max/2)
+ return;
+ std::memcpy(Buffer, Buffer+Buffer_Offset, Buffer_Size-Buffer_Offset);
+ Buffer_Size-=Buffer_Offset;
+ Buffer_Offset=0;
+ }
+
+ };
+ vector<channel*> Channels;
+ channel MergedChannel;
+ size_t Channel_Current;
+ size_t Channel_Master;
+ File__Analyze* Parser;
+ bool IsPcm;
+ bool IsAes3;
+
+ common()
+ {
+ Channel_Current=0;
+ Channel_Master=(size_t)-1;
+ Parser=NULL;
+ IsPcm=false;
+ IsAes3=false;
+ }
+
+ ~common()
+ {
+ delete Parser; //Parser=NULL;
+ }
+ };
+ int64u StreamID;
+ common* Common;
+ size_t Channel_Pos;
+ size_t Channel_Total;
+ int64u SampleRate;
+ int8u Endianness;
+ bool IsAes3;
+
+ //Constructor/Destructor
+ File_ChannelGrouping();
+ ~File_ChannelGrouping();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - Global
+ void Read_Buffer_Init ();
+ void Read_Buffer_Continue ();
+ void Read_Buffer_Unsynched ();
+
+ //Temp
+ size_t Buffer_Offset_AlreadyInCommon;
+ int64u IsPcm_Frame_Count;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_DolbyE.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_DolbyE.cpp
new file mode 100644
index 000000000..e8e47a0ae
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_DolbyE.cpp
@@ -0,0 +1,126 @@
+// File_DolbyE - Info for Dolby E
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// This is a place holder for Dolby E parser
+// But open-source version of MediaInfo has *no* Dolby E support
+// If you want Dolby E support,
+// contact http://www.dolby.com/about/contact_us/contactus.aspx?goto=28
+// for a license before asking it in MediaInfo
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DOLBYE_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_DolbyE.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_DolbyE::File_DolbyE()
+:File__Analyze()
+{
+ //Configuration
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=32*1024;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DolbyE::Streams_Fill()
+{
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_DolbyE::FileHeader_Begin()
+{
+ Reject("Dolby E");
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_DolbyE::Synchronize()
+{
+ //Synched
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_DolbyE::Synched_Test()
+{
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DolbyE::Header_Parse()
+{
+}
+
+//---------------------------------------------------------------------------
+void File_DolbyE::Data_Parse()
+{
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_DOLBYE_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_DolbyE.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_DolbyE.h
new file mode 100644
index 000000000..186b4c073
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_DolbyE.h
@@ -0,0 +1,64 @@
+// File_DolbyE - Info Info for Dolby E
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Dolby E files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_DolbyEH
+#define MediaInfo_File_DolbyEH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_DolbyE
+//***************************************************************************
+
+class File_DolbyE : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_DolbyE();
+
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Dts.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Dts.cpp
new file mode 100644
index 000000000..428faa29e
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Dts.cpp
@@ -0,0 +1,1333 @@
+// File_Dts - Info for DTS files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DTS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Dts.h"
+#include "ZenLib/Utils.h"
+#include "ZenLib/BitStream.h"
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* DTS_FrameType[]=
+{
+ "Termination",
+ "Normal",
+};
+
+//---------------------------------------------------------------------------
+const int32u DTS_SamplingRate[]=
+{
+ 0, 8000, 16000, 32000, 0, 0, 11025, 22050,
+ 44100, 0, 0, 12000, 24000, 48000, 96000, 192000,
+};
+
+//---------------------------------------------------------------------------
+const int32u DTS_BitRate[]=
+{
+ 32000, 56000, 64000, 96000, 112000, 128000, 192000, 224000,
+ 256000, 320000, 384000, 448000, 512000, 576000, 640000, 754500,
+ 960000, 1024000, 1152000, 1280000, 1344000, 1408000, 1411200, 1472000,
+ 1509750, 1920000, 2048000, 3072000, 3840000, 0, 0, 0,
+};
+
+//---------------------------------------------------------------------------
+const int8u DTS_Channels[]=
+{
+ 1, 2, 2, 2, 2, 3, 3, 4,
+ 4, 5, 6, 6, 6, 7, 8, 8,
+};
+
+//---------------------------------------------------------------------------
+const int8u DTS_Resolution[]=
+{16, 20, 24, 24};
+
+//---------------------------------------------------------------------------
+const char* DTS_ChannelPositions[16]=
+{
+ "Front: C",
+ "Front: C C",
+ "Front: L R",
+ "Front: L R",
+ "Front: L R",
+ "Front: L C R",
+ "Front: L R, Side: C",
+ "Front: L C R, Side: C",
+ "Front: L R, Side: L R",
+ "Front: L C R, Side: L R",
+ "Front: L R, Side: L R, Back: L R",
+ "Front: L C R, Side: L R",
+ "Front: L R, Side: L R, Back: L R",
+ "Front: L C R, Side: L R, Back: L R",
+ "Front: L R, Side: L R, Back: L C C R",
+ "Front: L C R, Side: L R, Back: L C R",
+};
+
+//---------------------------------------------------------------------------
+const char* DTS_ChannelPositions2[16]=
+{
+ "1/0/0",
+ "2/0/0",
+ "2/0/0",
+ "2/0/0",
+ "2/0/0",
+ "3/0/0",
+ "2/1/0",
+ "3/1/0",
+ "2/2/0",
+ "3/2/0",
+ "2/2/2",
+ "3/2/0",
+ "2/2/2",
+ "3/2/2",
+ "2/2/4",
+ "3/2/3",
+};
+
+//---------------------------------------------------------------------------
+const char* DTS_ExtensionAudioDescriptor[]=
+{
+ "Channel Extension",
+ "Reserved",
+ "Frequency Extension",
+ "Channel Extension + Frequency Extension",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* DTS_HD_RefClockCode[]=
+{
+ "1/32000",
+ "1/44100",
+ "1/48000",
+ "",
+};
+
+//---------------------------------------------------------------------------
+std::string DTS_HD_SpeakerActivityMask (int16u SpeakerActivityMask)
+{
+ std::string Text;
+ if ((SpeakerActivityMask&0x0003)==0x0003)
+ Text+="Front: L C R";
+ else
+ {
+ if (SpeakerActivityMask&0x0001)
+ Text+="Front: C";
+ if (SpeakerActivityMask&0x0002)
+ Text+="Front: L R";
+ }
+
+ if (SpeakerActivityMask&0x0004)
+ Text+=", Side: L R";
+
+ if (SpeakerActivityMask&0x0010)
+ Text+=", Back: C";
+
+ if ((SpeakerActivityMask&0x00A0)==0x00A0)
+ Text+=", High: L C R";
+ else
+ {
+ if (SpeakerActivityMask&0x0020)
+ Text+=", High: L R";
+ if (SpeakerActivityMask&0x0080)
+ Text+=", High: C";
+ }
+
+ if (SpeakerActivityMask&0x0800)
+ Text+=", Side: L R";
+
+ if (SpeakerActivityMask&0x0040)
+ Text+=", Back: L R";
+
+ if (SpeakerActivityMask&0x0100)
+ Text+=", TopCtrSrrd";
+ if (SpeakerActivityMask&0x0200)
+ Text+=", Ctr: L R";
+ if (SpeakerActivityMask&0x0400)
+ Text+=", Wide: L R";
+ if (SpeakerActivityMask&0x2000)
+ Text+=", HiSide: L R";
+
+ if ((SpeakerActivityMask&0xC000)==0x0C00)
+ Text+=", HiRear: L C R";
+ else
+ {
+ if (SpeakerActivityMask&0x4000)
+ Text+=", HiRear: C";
+ if (SpeakerActivityMask&0x8000)
+ Text+=", HiRear: L R";
+ }
+
+ if (SpeakerActivityMask&0x0008)
+ Text+=", LFE";
+ if (SpeakerActivityMask&0x1000)
+ Text+=", LFE2";
+
+ return Text;
+}
+
+//---------------------------------------------------------------------------
+std::string DTS_HD_SpeakerActivityMask2 (int16u SpeakerActivityMask)
+{
+ std::string Text;
+ if ((SpeakerActivityMask&0x0003)==0x0003)
+ Text+="3";
+ else
+ {
+ if (SpeakerActivityMask&0x0001)
+ Text+="1";
+ else if (SpeakerActivityMask&0x0002)
+ Text+="2";
+ else
+ Text+="0";
+ }
+
+ if (SpeakerActivityMask&0x0004)
+ Text+="/2";
+ else if ((SpeakerActivityMask&0x0840)==0x0000)
+ Text+="/0";
+
+ if (SpeakerActivityMask&0x0010)
+ Text+="/1";
+ else if ((SpeakerActivityMask&0x0840)==0x0000)
+ Text+="/0";
+
+ if ((SpeakerActivityMask&0x00A0)==0x00A0)
+ Text+=".3";
+ else
+ {
+ if (SpeakerActivityMask&0x0020)
+ Text+=".2";
+ if (SpeakerActivityMask&0x0080)
+ Text+=".2";
+ }
+
+ if (SpeakerActivityMask&0x0800)
+ Text+="/2";
+ if (SpeakerActivityMask&0x0040)
+ Text+="/2";
+
+ if (SpeakerActivityMask&0x0100)
+ Text+=".1";
+ if (SpeakerActivityMask&0x0200)
+ Text+=".2";
+ if (SpeakerActivityMask&0x0400)
+ Text+=".2";
+ if (SpeakerActivityMask&0x2000)
+ Text+=".2";
+
+ if ((SpeakerActivityMask&0xC000)==0x0C00)
+ Text+=".3";
+ else
+ {
+ if (SpeakerActivityMask&0x4000)
+ Text+=".1";
+ if (SpeakerActivityMask&0x8000)
+ Text+=".2";
+ }
+
+ if (SpeakerActivityMask&0x0008)
+ Text+=".1";
+ if (SpeakerActivityMask&0x1000)
+ Text+=".1";
+
+ return Text;
+}
+
+//---------------------------------------------------------------------------
+const char* DTS_HD_TypeDescriptor[]=
+{
+ "Music",
+ "Effects",
+ "Dialog",
+ "Commentary",
+ "Visually Impaired",
+ "Hearing Impaired",
+ "Isolated Music Object",
+ "Music and Effects",
+ "Dialog and Commentary",
+ "Effects and Commentary",
+ "Isolated Music Object and Commentary",
+ "Isolated Music Object and Effects",
+ "Karaoke",
+ "Music, Effects, Dialog",
+ "Complete Audio Presentation",
+ "",
+};
+
+//---------------------------------------------------------------------------
+int32u DTS_HD_MaximumSampleRate[]=
+{
+ 8000,
+ 16000,
+ 32000,
+ 64000,
+ 128000,
+ 22050,
+ 44100,
+ 88200,
+ 176400,
+ 352800,
+ 12000,
+ 24000,
+ 48000,
+ 96000,
+ 192000,
+ 384000,
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Dts::File_Dts()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("Dts");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Dts;
+ StreamIDs_Width[0]=0;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(8); //Stream
+ #endif //MEDIAINFO_TRACE
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=32*1024;
+ PTS_DTS_Needed=true;
+ IsRawStream=true;
+
+ //In
+ Frame_Count_Valid=MediaInfoLib::Config.ParseSpeed_Get()>=0.3?32:2;
+
+ //Temp
+ Parser=NULL;
+ HD_size=0;
+ Primary_Frame_Byte_Size_minus_1=0;
+ HD_SpeakerActivityMask=(int16u)-1;
+ channel_arrangement=(int8u)-1;
+ channel_arrangement_XCh=(int8u)-1;
+ sample_frequency=(int8u)-1;
+ sample_frequency_X96k=(int8u)-1;
+ bit_rate=(int8u)-1;
+ lfe_effects=(int8u)-1;
+ bits_per_sample=(int8u)-1;
+ ExtensionAudioDescriptor=(int8u)-1;
+ HD_BitResolution=(int8u)-1;
+ HD_MaximumSampleRate=(int8u)-1;
+ HD_TotalNumberChannels=(int8u)-1;
+ HD_ExSSFrameDurationCode=(int8u)-1;
+ ExtendedCoding=false;
+ ES=false;
+ Core_Exists=false;
+}
+
+//---------------------------------------------------------------------------
+File_Dts::~File_Dts()
+{
+ //Pointers
+ delete Parser;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dts::Streams_Fill()
+{
+ Fill(Stream_General, 0, General_Format, "DTS");
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "DTS");
+
+ if (Parser) //LE or 14-bit
+ return; //filled by the parser
+
+ if (!Profile.empty())
+ Fill(Stream_Audio, 0, Audio_Format_Profile, Profile+(Core_Exists?_T(" / Core"):_T("")));
+ else if (ES)
+ Fill(Stream_Audio, 0, Audio_Format_Profile, "ES");
+ Fill(Stream_General, 0, General_Format_Profile, Retrieve(Stream_Audio, 0, Audio_Format_Profile));
+ Fill(Stream_Audio, 0, Audio_Codec, (Profile.find(_T("MA"))==0 || Profile.find(_T("HRA"))==0)?"DTS-HD":"DTS");
+
+ //HD data
+ if ((ExtendedCoding && (ExtensionAudioDescriptor==0 || ExtensionAudioDescriptor==3 || ExtensionAudioDescriptor==6)))
+ {
+ switch(channel_arrangement_XCh)
+ {
+ case 1 :
+ Fill(Stream_Audio, 0, Audio_Channel_s_, 7);
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, Ztring("Front: L C R, Side: L R, Back: C")+(lfe_effects?_T(", LFE"):_T("")));
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, Ztring("3/2/1")+(lfe_effects?_T(".1"):_T(".0")));
+ break;
+ case 2 :
+ Fill(Stream_Audio, 0, Audio_Channel_s_, 8);
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, Ztring("Front: L C R, Side: L R, Back: L R")+(lfe_effects?_T(", LFE"):_T("")));
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, Ztring("3/2/2")+(lfe_effects?_T(".1"):_T(".0")));
+ break;
+ default:;
+ }
+ }
+ else
+ {
+ if (HD_SpeakerActivityMask!=(int16u)-1)
+ {
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, DTS_HD_SpeakerActivityMask(HD_SpeakerActivityMask).c_str());
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, DTS_HD_SpeakerActivityMask2(HD_SpeakerActivityMask).c_str());
+ }
+ if(HD_BitResolution!=(int8u)-1)
+ Fill(Stream_Audio, 0, Audio_BitDepth, HD_BitResolution);
+ if(HD_MaximumSampleRate!=(int8u)-1)
+ Fill(Stream_Audio, 0, Audio_SamplingRate, DTS_HD_MaximumSampleRate[HD_MaximumSampleRate]);
+ else if (sample_frequency_X96k!=(int8u)-1)
+ Fill(Stream_Audio, 0, Audio_SamplingRate, DTS_SamplingRate[sample_frequency_X96k]);
+ if(HD_TotalNumberChannels!=(int8u)-1)
+ Fill(Stream_Audio, 0, Audio_Channel_s_, HD_TotalNumberChannels);
+ if (bit_rate<29 || Profile==_T("Express"))
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate_Get(true), 0);
+ if (Profile==_T("Express"))
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR");
+ }
+
+ //Core data
+ if (Core_Exists)
+ {
+ if ((Profile.find(_T("MA"))==0?_T("VBR"):_T("CBR"))!=Retrieve(Stream_Audio, 0, Audio_BitRate_Mode))
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, Profile.find(_T("MA"))==0?"VBR":"CBR");
+ if (DTS_SamplingRate[sample_frequency]!=Retrieve(Stream_Audio, 0, Audio_SamplingRate).To_int32u())
+ Fill(Stream_Audio, 0, Audio_SamplingRate, DTS_SamplingRate[sample_frequency]);
+ Ztring BitRate;
+ if (bit_rate<29 || Profile==_T("Express"))
+ BitRate=Ztring::ToZtring(BitRate_Get(), 0);
+ else if (bit_rate==29)
+ BitRate=_T("Open");
+ else if (bit_rate==30)
+ BitRate=_T("Variable");
+ else if (bit_rate==31)
+ BitRate=_T("LossLess");
+ if (BitRate!=Retrieve(Stream_Audio, 0, Audio_BitRate))
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate);
+ if (Profile.find(_T("MA"))==0 || bit_rate==31)
+ Fill(Stream_Audio, 0, Audio_Compression_Mode, "Lossless / Lossy", Unlimited, true, true);
+
+ int8u Channels;
+ Ztring ChannelPositions, ChannelPositions2;
+ if (channel_arrangement<16)
+ {
+ Channels=DTS_Channels[channel_arrangement]+(lfe_effects?1:0);
+ ChannelPositions.From_Local(DTS_ChannelPositions[channel_arrangement]);
+ ChannelPositions2.From_Local(DTS_ChannelPositions2[channel_arrangement]);
+ }
+ else
+ {
+ Channels=8;
+ ChannelPositions.From_Local("User defined");
+ }
+ if (lfe_effects)
+ {
+ ChannelPositions+=_T(", LFE");
+ ChannelPositions2+=_T(".1");
+ }
+ if (Channels!=Retrieve(Stream_Audio, 0, Audio_Channel_s_).To_int8u())
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Channels);
+ if (ChannelPositions!=Retrieve(Stream_Audio, 0, Audio_ChannelPositions))
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, ChannelPositions);
+ if (ChannelPositions2!=Retrieve(Stream_Audio, 0, Audio_ChannelPositions_String2))
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, ChannelPositions2);
+ if (DTS_Resolution[bits_per_sample]!=Retrieve(Stream_Audio, 0, Audio_BitDepth).To_int8u())
+ Fill(Stream_Audio, 0, Audio_BitDepth, DTS_Resolution[bits_per_sample]);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Dts::Streams_Finish()
+{
+ if (Parser) //LE or 14-bit
+ {
+ Parser->Finish();
+ Merge(*Parser, Stream_Audio, 0, 0);
+ Fill(Stream_Audio, 0, Audio_MuxingMode, BigEndian?"BE":"LE");
+ Fill(Stream_Audio, 0, Audio_MuxingMode, Word?"16":"14");
+ return;
+ }
+
+ if (FrameInfo.PTS!=(int64u)-1 && FrameInfo.PTS>PTS_Begin)
+ {
+ Fill(Stream_Audio, 0, Audio_Duration, float64_int64s(((float64)(FrameInfo.PTS-PTS_Begin))/1000000));
+ Fill(Stream_Audio, 0, Audio_FrameCount, float64_int64s(((float64)(FrameInfo.PTS-PTS_Begin))/1000000/32));
+ }
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Dts::FileHeader_Begin()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ //False positives detection: Detect WAV files, the parser can't detect it easily, there is only 70 bytes of beginning for saying WAV
+ switch (CC4(Buffer))
+ {
+ case 0x52494646 : //"RIFF"
+ case 0x000001FD : //MPEG-PS private
+ Finish("DTS");
+ return false;
+ default : ;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Dts::Synchronize()
+{
+ //Synchronizing
+ while (Buffer_Offset+6<=Buffer_Size)
+ {
+ int64u Value=CC6(Buffer+Buffer_Offset);
+ if ((Value&0xFFFFFFFFFC00LL)==0x7FFE8001FC00LL //16 bits and big endian Core
+ || (Value&0xFFFFFFFF00FCLL)==0xFE7F018000FCLL //16 bits and little endian Core
+ || (Value&0xFFFFFFFFF7F0LL)==0x1FFFE80007F0LL //14 bits and big endian Core
+ || (Value&0xFFFFFFFFF0F7LL)==0xFF1F00E8F007LL //14 bits and little endian Core
+ || (Value&0xFFFFFFFF0000LL)==0x645820250000LL) //16 bits and big endian HD
+ break;
+ Buffer_Offset++;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+6>Buffer_Size)
+ {
+ if (Buffer_Offset+5==Buffer_Size)
+ {
+ int64u Value=CC5(Buffer+Buffer_Offset);
+ if ((Value&0xFFFFFFFFFCLL)!=0x7FFE8001FCLL //16 bits and big endian Core
+ && (Value&0xFFFFFFFF00LL)!=0xFE7F018000LL //16 bits and little endian Core
+ && (Value&0xFFFFFFFFF7LL)!=0x1FFFE80007LL //14 bits and big endian Core
+ && (Value&0xFFFFFFFFF0LL)!=0xFF1F00E8F0LL //14 bits and little endian Core
+ && (Value&0xFFFFFFFF00LL)!=0x6458202500LL) //16 bits and big endian HD
+ Buffer_Offset++;
+ }
+ if (Buffer_Offset+4==Buffer_Size)
+ {
+ int32u Value=CC4(Buffer+Buffer_Offset);
+ if (Value!=0x7FFE8001 //16 bits and big endian Core
+ && Value!=0xFE7F0180 //16 bits and little endian Core
+ && Value!=0x1FFFE800 //14 bits and big endian Core
+ && Value!=0xFF1F00E8 //14 bits and little endian Core
+ && Value!=0x64582025) //16 bits and big endian HD
+ Buffer_Offset++;
+ }
+ if (Buffer_Offset+3==Buffer_Size)
+ {
+ int32u Value=CC3(Buffer+Buffer_Offset);
+ if (Value!=0x7FFE80 //16 bits and big endian Core
+ && Value!=0xFE7F01 //16 bits and little endian Core
+ && Value!=0x1FFFE8 //14 bits and big endian Core
+ && Value!=0xFF1F00 //14 bits and little endian Core
+ && Value!=0x645820) //16 bits and big endian HD
+ Buffer_Offset++;
+ }
+ if (Buffer_Offset+2==Buffer_Size)
+ {
+ int16u Value=CC2(Buffer+Buffer_Offset);
+ if (Value!=0x7FFE //16 bits and big endian Core
+ && Value!=0xFE7F //16 bits and little endian Core
+ && Value!=0x1FFF //14 bits and big endian Core
+ && Value!=0xFF1F //14 bits and little endian Core
+ && Value!=0x6458) //16 bits and big endian HD
+ Buffer_Offset++;
+ }
+ if (Buffer_Offset+1==Buffer_Size)
+ {
+ int8u Value=CC1(Buffer+Buffer_Offset);
+ if (Value!=0x7F //16 bits and big endian Core
+ && Value!=0xFE //16 bits and little endian Core
+ && Value!=0x1F //14 bits and big endian Core
+ && Value!=0xFF //14 bits and little endian Core
+ && Value!=0x64) //16 bits and big endian HD
+ Buffer_Offset++;
+ }
+ return false;
+ }
+
+ //Configuration - 14 bits or Little Endian
+ switch (CC1(Buffer+Buffer_Offset))
+ {
+ default : Word=true; BigEndian=true; break; //16 bits and big endian bitstream
+ case 0xFE : Word=true; BigEndian=false; break; //16 bits and little endian bitstream
+ case 0x1F : Word=false; BigEndian=true; break; //14 bits and big endian bitstream
+ case 0xFF : Word=false; BigEndian=false; break; //14 bits and little endian bitstream
+ }
+
+ //Synched
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Dts::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ int32u Value=CC4(Buffer+Buffer_Offset);
+ switch (Value)
+ {
+ case 0x7FFE8001 : //16 bits and big endian Core
+ case 0xFE7F0180 : //16 bits and little endian Core
+ case 0x1FFFE800 : //14 bits and big endian Core
+ case 0xFF1F00E8 : //14 bits and little endian Core
+ case 0x64582025 : //16 bits and big endian HD
+ break;
+ default : Synched=false;
+ }
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Demux
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+bool File_Dts::Demux_UnpacketizeContainer_Test()
+{
+ int32u Value=CC4(Buffer+Buffer_Offset);
+ if (Value==0x7FFE8001)
+ {
+ int16u Size=((BigEndian2int24u(Buffer+Buffer_Offset+5)>>4)&0x3FFF)+1;
+ Demux_Offset=Buffer_Offset+Size;
+
+ if (Buffer_Offset+Size>Buffer_Size && File_Offset+Buffer_Size!=File_Size)
+ return false; //No complete frame
+
+ Demux_UnpacketizeContainer_Demux();
+ }
+
+ return true;
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dts::Read_Buffer_Continue()
+{
+ //Exception handling
+ int8u* Dest=NULL;
+ try
+ {
+
+ //Mapping to an understable bitstream if needed
+ if (MustSynchronize && !Synchro_Manage())
+ return; //Wait for more data
+ if (Synched && (!Word || !BigEndian))
+ {
+ //Preparing new buffer
+ size_t Dest_Size=Word?Buffer_Size:(Buffer_Size*14/16);
+ Dest=new int8u[Dest_Size];
+ if (Word)
+ {
+ for (size_t Pos=0; Pos+1<Buffer_Size; Pos+=2)
+ {
+ Dest[Pos+1]=Buffer[Pos ];
+ Dest[Pos ]=Buffer[Pos+1];
+ }
+ }
+ else
+ {
+ for (size_t Pos=0; Pos+7<Buffer_Size; Pos+=8)
+ {
+ int64u Value;
+ if (BigEndian)
+ Value =(((int64u)( BigEndian2int16u(Buffer+Pos )&0x3FFF))<<42)
+ | (((int64u)( BigEndian2int16u(Buffer+Pos+2)&0x3FFF))<<28)
+ | (((int64u)( BigEndian2int16u(Buffer+Pos+4)&0x3FFF))<<14)
+ | (((int64u)( BigEndian2int16u(Buffer+Pos+6)&0x3FFF)) );
+ else
+ Value =(((int64u)(LittleEndian2int16u(Buffer+Pos )&0x3FFF))<<42)
+ | (((int64u)(LittleEndian2int16u(Buffer+Pos+2)&0x3FFF))<<28)
+ | (((int64u)(LittleEndian2int16u(Buffer+Pos+4)&0x3FFF))<<14)
+ | (((int64u)(LittleEndian2int16u(Buffer+Pos+6)&0x3FFF)) );
+ int56u2BigEndian(Dest+Pos/8*7, Value);
+ }
+ }
+
+ //Parsing
+ if (Parser==NULL)
+ {
+ Parser=new File_Dts;
+ ((File_Dts*)Parser)->Frame_Count_Valid=Frame_Count_Valid;
+ Open_Buffer_Init(Parser);
+ }
+ Demux(Dest, Dest_Size, ContentType_MainStream);
+ Open_Buffer_Continue(Parser, Dest, Dest_Size);
+ if (!Status[IsFilled] && Parser->Status[IsFilled])
+ {
+ Accept("DTS");
+ Fill("DTS");
+ }
+ if (!Status[IsFinished] && Parser->Status[IsFinished])
+ Finish("DTS");
+
+ delete[] Dest;
+ Buffer_Offset+=Buffer_Size;
+ }
+
+ //Exception handling
+ }
+ catch(...)
+ {
+ delete[] Dest;
+ }
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dts::Header_Parse()
+{
+ //Parsing
+ int32u Sync;
+ Get_B4 (Sync, "Sync");
+ if (Sync==0x64582025)
+ {
+ //HD
+ int16u header_size;
+ int8u SubStreamIndex, NumAssets, NumAudioPresent;
+ bool isBlownUpHeader, StaticFieldsPresent;
+ Skip_B1( "Unknown");
+ BS_Begin();
+ Get_S1 (2, SubStreamIndex, "Substream index");
+ Get_SB (isBlownUpHeader, "Is blown up header");
+ if (isBlownUpHeader)
+ {
+ Get_S2 (12, header_size, "Header size"); header_size++; Param_Info2(header_size, " bytes");
+ Get_S3 (20, HD_size, "HD block size"); HD_size++; Param_Info2(HD_size, " bytes");
+ }
+ else
+ {
+ Get_S2 ( 8, header_size, "Header size"); header_size++; Param_Info2(header_size, " bytes");
+ Get_S3 (16, HD_size, "HD block size"); HD_size++; Param_Info2(HD_size, " bytes");
+ }
+ TESTELSE_SB_GET(StaticFieldsPresent, "Static fields present");
+ std::vector<int32u> ActiveExSSMasks;
+ Info_S1(2, RefClockCode, "Reference clock code"); Param_Info1(DTS_HD_RefClockCode[RefClockCode]);
+ Get_S1 (3, HD_ExSSFrameDurationCode, "ExSS frame duration code"); HD_ExSSFrameDurationCode++; Param_Info1(HD_ExSSFrameDurationCode);
+ TEST_SB_SKIP( "Timestamp flag");
+ Skip_S5(36, "Timestamp");
+ TEST_SB_END();
+ Get_S1 (3, NumAudioPresent, "Num audio present"); NumAudioPresent++; Param_Info2(NumAudioPresent, " channels");
+ Get_S1 (3, NumAssets, "Num assets"); NumAssets++; Param_Info2(NumAssets, " assets");
+ Element_Begin1("Active masks");
+ for (int8u Pos=0; Pos<NumAudioPresent; Pos++)
+ {
+ int32u ActiveExSSMask;
+ Get_S4 (SubStreamIndex+1, ActiveExSSMask, "Active ExSS mask");
+ ActiveExSSMasks.push_back(ActiveExSSMask);
+ }
+ Element_End0();
+ Element_Begin1("Active masks 2");
+ for (int8u Pos=0; Pos<NumAudioPresent; Pos++)
+ for (int8u Pos2=0; Pos2<SubStreamIndex+1; Pos2+=2)
+ if (ActiveExSSMasks[Pos]%2)
+ Skip_S1(8, "Active ExSS Mask");
+ Element_End0();
+ TEST_SB_SKIP( "Mix metadata Enabled");
+ int8u Bits4MixOutMask, NumMixOutConfigs;
+ Skip_S1(2, "Mix metadata adjustment level");
+ Get_S1 (2, Bits4MixOutMask, "Bits4Mix out mask"); Bits4MixOutMask=4+Bits4MixOutMask*4; Param_Info2(Bits4MixOutMask, " bits");
+ Get_S1 (2, NumMixOutConfigs, "Number of mix out configs"); NumMixOutConfigs++; Param_Info2(NumMixOutConfigs, " configs");
+ for (int8u Pos=0; Pos<NumMixOutConfigs; Pos++)
+ Skip_S1(Bits4MixOutMask, "MixOutChMask");
+ TEST_SB_END();
+ TESTELSE_SB_ELSE("Static fields present");
+ NumAudioPresent=1;
+ NumAssets=1;
+ TESTELSE_SB_END();
+ Asset_Sizes.clear();
+ Element_Begin1("Sizes");
+ for (int8u Pos=0; Pos<NumAssets; Pos++)
+ {
+ int32u Size;
+ if (isBlownUpHeader)
+ {
+ Get_S3 (20, Size, "Size"); Size++; Param_Info2(Size, " bytes");
+ }
+ else
+ {
+ Get_S3 (16, Size, "Size"); Size++; Param_Info2(Size, " bytes");
+ }
+ Asset_Sizes.push_back(Size);
+ }
+ Element_End0();
+ for (int8u Asset_Pos=0; Asset_Pos<NumAssets; Asset_Pos++)
+ {
+ Element_Begin1("Asset");
+ int16u AssetSize;
+ Get_S2 (9, AssetSize, "Asset size");
+ AssetSize++; Param_Info2(AssetSize, " bytes?");
+ Skip_S1(3, "Descriptor data for asset index");
+ if (StaticFieldsPresent)
+ {
+ TEST_SB_SKIP( "Asset type descriptor present");
+ Info_S1( 4, TypeDescriptor, "Asset type descriptor"); Param_Info1(DTS_HD_TypeDescriptor[TypeDescriptor]);
+ TEST_SB_END();
+ TEST_SB_SKIP( "Language descriptor present");
+ Info_S3(24, LanguageDescriptor, "Language descriptor"); Param_Info1(Ztring().From_CC3(LanguageDescriptor));
+ TEST_SB_END();
+ TEST_SB_SKIP( "Info text present");
+ int16u InfoTextByteSize;
+ Get_S2(10, InfoTextByteSize, "Info text size"); InfoTextByteSize++; Param_Info2(InfoTextByteSize, "bytes");
+ for (int16u Pos=0; Pos<InfoTextByteSize; Pos++)
+ Skip_S1(8, "Info text");
+ TEST_SB_END();
+ Get_S1 (5, HD_BitResolution, "Bit resolution"); HD_BitResolution++; Param_Info2(HD_BitResolution, " bits");
+ Get_S1 (4, HD_MaximumSampleRate, "Maximum sample rate"); Param_Info2(DTS_HD_MaximumSampleRate[HD_MaximumSampleRate], " Hz");
+ Get_S1 (8, HD_TotalNumberChannels, "Total number of channels"); HD_TotalNumberChannels++; Param_Info2(HD_TotalNumberChannels, " channels");
+ TEST_SB_SKIP( "1 to 1 map channels to speakers");
+ int8u SpeakerActivityMaskBits, SpeakerRemapSetsCount;
+ if (HD_TotalNumberChannels>2)
+ Skip_SB( "Embedded stereo flag"); //else is 0
+ if (HD_TotalNumberChannels>6)
+ Skip_SB( "Embedded 6 Channels flag"); //else is 0
+ TESTELSE_SB_SKIP( "Speaker mask enabled");
+ Get_S1 (2, SpeakerActivityMaskBits, "Speaker activity mask bits"); Param_Info2(4+SpeakerActivityMaskBits*4, " bits");
+ SpeakerActivityMaskBits=4+SpeakerActivityMaskBits*4;
+ Get_S2 (SpeakerActivityMaskBits, HD_SpeakerActivityMask, "Speaker activity mask"); Param_Info1(DTS_HD_SpeakerActivityMask(HD_SpeakerActivityMask).c_str());
+ TESTELSE_SB_ELSE( "Speaker mask enabled");
+ SpeakerActivityMaskBits=0;
+ TESTELSE_SB_END();
+ Get_S1 (3, SpeakerRemapSetsCount, "Speaker remap sets count");
+ for (int8u Pos=0; Pos<SpeakerRemapSetsCount; Pos++)
+ Skip_S2(SpeakerActivityMaskBits, "Standard speaker layout mask");
+ for (int8u Pos=0; Pos<SpeakerRemapSetsCount; Pos++)
+ {
+ int8u NumDecCh4Remap;
+ Get_S1(5, NumDecCh4Remap, "NumDecCh4Remap");
+ //Not finnished!
+ }
+ TEST_SB_END();
+ Element_End0();
+ }
+ }
+ BS_End();
+ Skip_XX(header_size-Element_Offset, "Unknown");
+
+ //Filling
+ Header_Fill_Size(HD_size);
+ Header_Fill_Code(1, "HD");
+ }
+ else
+ {
+ //Frame
+ int8u EncoderSoftwareRevision;
+ bool crc_present;
+ BS_Begin();
+ Info_SB( FrameType, "Frame Type"); Param_Info1(DTS_FrameType[FrameType]);
+ Skip_S1( 5, "Deficit Sample Count");
+ Get_SB ( crc_present, "CRC Present");
+ Skip_S1( 7, "Number of PCM Sample Blocks");
+ Get_S2 (14, Primary_Frame_Byte_Size_minus_1, "Primary Frame Byte Size minus 1");
+ Primary_Frame_Byte_Size_minus_1+=1;
+ if (!Word) Primary_Frame_Byte_Size_minus_1=Primary_Frame_Byte_Size_minus_1*8/14*2; Param_Info2(Primary_Frame_Byte_Size_minus_1, " bytes"); //Word is on 14 bits!
+ Get_S1 ( 6, channel_arrangement, "Audio Channel Arrangement"); Param_Info2(DTS_Channels[channel_arrangement], " channels");
+ Get_S1 ( 4, sample_frequency, "Core Audio Sampling Frequency"); Param_Info2(DTS_SamplingRate[sample_frequency], " Hz");
+ Get_S1 ( 5, bit_rate, "Transmission Bit Rate"); Param_Info2(DTS_BitRate[bit_rate], " bps");
+ Skip_SB( "Embedded Down Mix Enabled");
+ Skip_SB( "Embedded Dynamic Range");
+ Skip_SB( "Embedded Time Stamp");
+ Skip_SB( "Auxiliary Data");
+ Skip_SB( "HDCD");
+ Get_S1 ( 3, ExtensionAudioDescriptor, "Extension Audio Descriptor"); Param_Info1(DTS_ExtensionAudioDescriptor[ExtensionAudioDescriptor]);
+ Get_SB ( ExtendedCoding, "Extended Coding");
+ Skip_SB( "Audio Sync Word Insertion");
+ Get_S1 ( 2, lfe_effects, "Low Frequency Effects");
+ Skip_SB( "Predictor History");
+ if (crc_present)
+ Skip_S2(16, "Header CRC Check");
+ Skip_SB( "Multirate Interpolator");
+ Get_S1 ( 4, EncoderSoftwareRevision, "Encoder Software Revision");
+ Skip_S1( 2, "Copy History");
+ Get_S1 ( 2, bits_per_sample, "Source PCM Resolution"); Param_Info1(Ztring::ToZtring(DTS_Resolution[bits_per_sample])+_T(" bits"));
+ Get_SB ( ES, "ES");
+ Skip_SB( "Front Sum/Difference");
+ Skip_SB( "Surrounds Sum/Difference");
+ Skip_S1( 4, "Dialog Normalisation Parameter");
+ switch (EncoderSoftwareRevision)
+ {
+ case 6 :
+ Skip_S1( 4, "Dialog Normalisation Parameter");
+ break;
+ case 7 :
+ Skip_S1( 4, "Dialog Normalisation Parameter");
+ break;
+ default :
+ Skip_S1( 4, "Unspecified");
+ break;
+ }
+ BS_End();
+
+ //Filling
+ Header_Fill_Size(Primary_Frame_Byte_Size_minus_1);
+ Header_Fill_Code(0);
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dts::Data_Parse()
+{
+ //Partial frame
+ if ((Element_Code==0 && Header_Size+Element_Size<Primary_Frame_Byte_Size_minus_1)
+ || (Element_Code==1 && Header_Size+Element_Size<HD_size))
+ {
+ Element_Name("Partial frame");
+ Skip_XX(Element_Size, "Data");
+ return;
+ }
+
+ //Name
+ Element_Info1(Ztring::ToZtring(Frame_Count));
+
+ //PTS
+ Element_Info1C((FrameInfo.PTS!=(int64u)-1), _T("PTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/1000000)));
+
+ //Counting
+ if (File_Offset+Buffer_Offset+Element_Size==File_Size)
+ Frame_Count_Valid=Frame_Count; //Finish frames in case of there are less than Frame_Count_Valid frames
+ if (Element_Code==0 || !Core_Exists)
+ {
+ if (Frame_Count==0)
+ PTS_Begin=FrameInfo.PTS;
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ float64 BitRate=BitRate_Get();
+ if (BitRate)
+ {
+ FrameInfo.DUR=float64_int64s(((float64)(Element_Size+Header_Size))*8/BitRate*1000000000);
+ if (FrameInfo.DTS!=(int64u)-1)
+ FrameInfo.DTS+=FrameInfo.DUR;
+ if (FrameInfo.PTS!=(int64u)-1)
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+ }
+
+ //If filled
+ if (Status[IsFilled])
+ {
+ Skip_XX(Element_Size, "Data");
+ return;
+ }
+
+ //Parsing
+ switch(Element_Code)
+ {
+ case 0 : Core(); break;
+ case 1 : HD(); break;
+ default : Skip_XX(Element_Size, "Data");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dts::Core()
+{
+ Element_Name("Frame");
+
+ //It exists (not in XSA streams)
+ Core_Exists=true;
+
+ //Looking for extensions
+ int64u Core_Size=Element_Size, XCh_Sync=Element_Size, XXCh_Sync=Element_Size, X96k_Sync=Element_Size;
+ if (ExtendedCoding)
+ {
+ //XCh
+ if (ExtensionAudioDescriptor==0 || ExtensionAudioDescriptor==3)
+ for (size_t Pos=0; Pos+4<=Element_Size; Pos++)
+ if (CC4(Buffer+Buffer_Offset+Pos)==0x5A5A5A5A)
+ XCh_Sync=Pos;
+
+ //XXCh
+ if (ExtensionAudioDescriptor==6)
+ for (size_t Pos=0; Pos+4<=Element_Size; Pos++)
+ if (CC4(Buffer+Buffer_Offset+Pos)==0x47004A03)
+ XXCh_Sync=Pos;
+
+ //X96k
+ if (ExtensionAudioDescriptor==2 || ExtensionAudioDescriptor==3)
+ for (size_t Pos=0; Pos+4<=Element_Size; Pos++)
+ if (CC4(Buffer+Buffer_Offset+Pos)==0x1D95F262)
+ X96k_Sync=Pos;
+
+ //Finding core size
+ if (XCh_Sync<Core_Size)
+ Core_Size=XCh_Sync;
+ if (XXCh_Sync<Core_Size)
+ Core_Size=XXCh_Sync;
+ if (X96k_Sync<Core_Size)
+ Core_Size=X96k_Sync;
+ }
+
+ //Parsing
+ Skip_XX(Core_Size, "Core data");
+ if (ExtendedCoding && (ExtensionAudioDescriptor==2 || ExtensionAudioDescriptor==3))
+ {
+ Element_Begin0();
+ Skip_B4( "Magic");
+ Core_X96k(XCh_Sync-Element_Offset);
+ Element_End0();
+ }
+ if (ExtendedCoding && (ExtensionAudioDescriptor==0 || ExtensionAudioDescriptor==3))
+ {
+ Element_Begin0();
+ Skip_B4( "Magic");
+ Core_XCh(Element_Size-Element_Offset);
+ Element_End0();
+ }
+ if (ExtendedCoding && ExtensionAudioDescriptor==6)
+ {
+ Element_Begin0();
+ Skip_B4( "Magic");
+ Core_XXCh(Element_Size-Element_Offset);
+ Element_End0();
+ }
+
+ //Filling
+ FILLING_BEGIN();
+ if (Count_Get(Stream_Audio)==0 && Frame_Count>=Frame_Count_Valid)
+ {
+ Accept("DTS");
+ Fill("DTS");
+
+ //No more need data
+ if (!IsSub && MediaInfoLib::Config.ParseSpeed_Get()<1)
+ Finish("DTS");
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dts::Core_XCh(int64u Size)
+{
+ //Parsing
+ Element_Name("XCh (6.1 channels)");
+ int16u XChFSIZE;
+ int8u AMODE;
+ BS_Begin();
+ Get_S2 (10, XChFSIZE, "Primary Frame Byte Size");
+ Get_S1 ( 4, AMODE, "Extension Channel Arrangement");
+ BS_End();
+ if (XChFSIZE==Element_Size-(Element_Offset-6))
+ XChFSIZE--; //Compatibility reason (from specs)
+ if ((int64u)XChFSIZE+1-6<=Size-2)
+ Skip_XX(XChFSIZE+1-6, "XCh data");
+ else
+ Skip_XX(Size-2, "XCh data (with problem)");
+
+ FILLING_BEGIN();
+ channel_arrangement_XCh=AMODE;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dts::Core_XXCh(int64u Size)
+{
+ Element_Name("XXCh (6.1 or 7.1 channels)");
+ int8u ChannelsAdded;
+ BS_Begin();
+ Skip_S1 (8, "?");
+ Get_S1 (2, ChannelsAdded, "Channels added?");
+ Skip_S1 (6, "?");
+ BS_End();
+ Skip_XX(Size-2, "Data");
+
+ FILLING_BEGIN();
+ channel_arrangement_XCh=ChannelsAdded;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dts::Core_X96k(int64u Size)
+{
+ //Parsing
+ Element_Name("X96k (96 KHz)");
+ int16u FSIZE96;
+ int8u REVNO;
+ BS_Begin();
+ Get_S2 (12, FSIZE96, "96 kHz Extension Frame Byte Data Size");
+ Get_S1 ( 4, REVNO, "Revision Number");
+ BS_End();
+ Skip_XX(Size-2, "X96k data"); //FSIZE96 is until end, not X96k size
+
+ FILLING_BEGIN();
+ sample_frequency_X96k=14; //96KHz
+ Profile="96/24";
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dts::HD()
+{
+ //Parsing
+ while (Element_Offset<Element_Size)
+
+ {
+ //Looking for size
+ int64u Next=Element_Offset+4;
+ while (Next+4<=Element_Size)
+ {
+ int32u CC=CC4(Buffer+Buffer_Offset+(size_t)Next);
+ if (CC==0x0A801921
+ || CC==0x1D95F262
+ || CC==0x41A29547
+ || CC==0x47004A03
+ || CC==0x5A5A5A5A
+ || CC==0x655E315E)
+ break;
+ Next++;
+ }
+ if (Next+4>Element_Size)
+ Next=Element_Size;
+
+ Element_Begin0();
+ int32u Magic;
+ Get_B4 (Magic, "Magic");
+ switch (Magic)
+ {
+ case 0x0A801921 : HD_XSA(Next-Element_Offset); break;
+ case 0x1D95F262 : HD_X96k(Next-Element_Offset); break;
+ case 0x41A29547 : HD_XLL(Next-Element_Offset); break;
+ case 0x47004A03 : HD_XXCh(Next-Element_Offset); break;
+ case 0x5A5A5A5A : HD_XCh(Next-Element_Offset); break;
+ case 0x655E315E : HD_XBR(Next-Element_Offset); break;
+ default :
+ //Magic value is unknown
+ if (Profile.empty())
+ Profile="HD";
+ Skip_XX(Next-Element_Offset, "Data");
+ }
+ Element_End0();
+ }
+
+ //Filling
+ FILLING_BEGIN();
+ if (Count_Get(Stream_Audio)==0 && Frame_Count>=Frame_Count_Valid)
+ {
+ Accept("DTS");
+ Fill("DTS");
+
+ //No more need data
+ if (!IsSub && MediaInfoLib::Config.ParseSpeed_Get()<1)
+ Finish("DTS");
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dts::HD_XCh(int64u Size)
+{
+ //Parsing
+ Element_Name("XCh (6.1 channels)");
+ Skip_XX(Size, "Data");
+
+ FILLING_BEGIN();
+ channel_arrangement_XCh=1;
+ if (Profile.empty())
+ Profile="HRA";
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dts::HD_XXCh(int64u Size)
+{
+ Element_Name("XXCh (6.1 or 7.1 channels)");
+ int8u ChannelsAdded;
+ BS_Begin();
+ Skip_S1 (8, "?");
+ Get_S1 (2, ChannelsAdded, "Channels added?");
+ Skip_S1 (6, "?");
+ BS_End();
+ Skip_XX(Size-2, "Data");
+
+ FILLING_BEGIN();
+ channel_arrangement_XCh=ChannelsAdded;
+ if (Profile.empty())
+ Profile="HRA";
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dts::HD_X96k(int64u Size)
+{
+ //Parsing
+ Element_Name("X96k (96 KHz)");
+ Skip_XX(Size, "Data");
+
+ FILLING_BEGIN();
+ sample_frequency=14; //96KHz
+ Profile="HRA";
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dts::HD_XLL(int64u Size)
+{
+ Element_Name("XLL (LossLess)");
+ Skip_XX(Size, "Data");
+
+ FILLING_BEGIN();
+ Profile="MA";
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dts::HD_XBR(int64u Size)
+{
+ Element_Name("XBR (BitRate extension)");
+ Skip_XX(Size, "Data");
+
+ FILLING_BEGIN();
+ Profile="HRA";
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dts::HD_XSA(int64u Size)
+{
+ Element_Name("XSA (low bitrate)");
+ Skip_XX(Size, "Data");
+
+ FILLING_BEGIN();
+ Profile="Express";
+ FILLING_END();
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+float64 File_Dts::BitRate_Get(bool WithHD)
+{
+ if (bit_rate<29 || Profile==_T("Express"))
+ {
+ float64 BitRate;
+ if (Profile==_T("Express"))
+ BitRate=0; //No core bitrate
+ else
+ BitRate=(float64)DTS_BitRate[bit_rate];
+ if (WithHD && HD_ExSSFrameDurationCode!=(int8u)-1)
+ {
+ int32u SamplePerFrames=HD_ExSSFrameDurationCode;
+ switch (HD_MaximumSampleRate)
+ {
+ case 0 : // 8000
+ case 10 : // 12000
+ SamplePerFrames*= 128; break;
+ case 1 : // 16000
+ case 5 : // 22050
+ case 11 : // 24000
+ SamplePerFrames*= 256; break;
+ case 2 : // 32000
+ case 6 : // 44100
+ case 12 : // 48000
+ SamplePerFrames*= 512; break;
+ case 3 : // 64000
+ case 7 : // 88200
+ case 13 : // 96000
+ SamplePerFrames*=1024; break;
+ case 4 : //128000
+ case 8 : //176400
+ case 14 : //192000
+ SamplePerFrames*=2048; break;
+ case 9 : //352800
+ case 15 : //384000
+ SamplePerFrames*=4096; break;
+ default : SamplePerFrames= 0; break; //Can never happen (4 bits)
+ }
+ if (SamplePerFrames)
+ BitRate+=HD_size*8*DTS_HD_MaximumSampleRate[HD_MaximumSampleRate]/SamplePerFrames;
+ }
+ //if (Primary_Frame_Byte_Size_minus_1 && Profile==_T("HRA"))
+ // BitRate*=1+((float64)HD_size)/Primary_Frame_Byte_Size_minus_1; //HD block are not in the nominal bitrate
+ return BitRate;
+ }
+ else
+ return 0;
+}
+
+//---------------------------------------------------------------------------
+} //NameSpace
+
+#endif //MEDIAINFO_DTS_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Dts.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Dts.h
new file mode 100644
index 000000000..d5f5b64ba
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Dts.h
@@ -0,0 +1,118 @@
+// File_Dts - Info for DTS files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_DtsH
+#define MediaInfo_DtsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#ifdef ES
+ #undef ES //Solaris defines this somewhere
+#endif
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Dts
+//***************************************************************************
+
+class File_Dts : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+
+ //Constructor/Destructor
+ File_Dts();
+ ~File_Dts();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test();
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Core();
+ void Core_XCh(int64u Size);
+ void Core_XXCh(int64u Size);
+ void Core_X96k(int64u Size);
+ void HD();
+ void HD_XCh(int64u Size);
+ void HD_XXCh(int64u Size);
+ void HD_X96k(int64u Size);
+ void HD_XLL(int64u Size);
+ void HD_XBR(int64u Size);
+ void HD_XSA(int64u Size);
+
+ //Temp
+ std::map<int32u, int64u> HD_Sizes;
+ std::vector<ZenLib::int32u> Asset_Sizes;
+ Ztring Profile;
+ File__Analyze* Parser; //14 bits or Little Endian
+ int32u HD_size;
+ int16u Primary_Frame_Byte_Size_minus_1;
+ int16u HD_SpeakerActivityMask;
+ int8u channel_arrangement;
+ int8u channel_arrangement_XCh;
+ int8u sample_frequency;
+ int8u sample_frequency_X96k;
+ int8u bit_rate;
+ int8u lfe_effects;
+ int8u bits_per_sample;
+ int8u ExtensionAudioDescriptor;
+ int8u HD_BitResolution;
+ int8u HD_MaximumSampleRate;
+ int8u HD_TotalNumberChannels;
+ int8u HD_ExSSFrameDurationCode;
+ bool ExtendedCoding;
+ bool Word;
+ bool BigEndian;
+ bool ES;
+ bool Core_Exists;
+
+ //Helpers
+ float64 BitRate_Get(bool WithHD=false);
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ExtendedModule.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ExtendedModule.cpp
new file mode 100644
index 000000000..4c174407e
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ExtendedModule.cpp
@@ -0,0 +1,120 @@
+// File_ExtendedModule - Info for Extended Module files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WXMHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILXMY or FXMNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_XM_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_ExtendedModule.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_ExtendedModule::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<38)
+ return false; //Must wait for more data
+
+ if (CC8(Buffer)!=0x457874656E646564LL || CC8(Buffer+8)!=0x204D6F64756C653ALL //"Extended Module: "
+ || CC1(Buffer+16)!=0x20 || CC1(Buffer+37)!=0x1A)
+ {
+ Reject("Extended Module");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_ExtendedModule::Read_Buffer_Continue()
+{
+ //Parsing
+ Ztring ModuleName, TrackerName;
+ int32u HeaderSize;
+ int16u Length, Channels, Patterns, Instruments, Flags, Tempo, BPM;
+ int8u VersionMinor, VersionMajor;
+ Skip_String(17, "Signature");
+ Get_Local(20, ModuleName, "Module name");
+ Skip_L1( "0x1A");
+ Get_Local(20, TrackerName, "Tracker name");
+ Get_L1 (VersionMinor, "Version (minor)");
+ Get_L1 (VersionMajor, "Version (major)");
+ Get_L4 (HeaderSize, "Header size");
+ Get_L2 (Length, "Song Length");
+ Skip_L2( "Restart position");
+ Get_L2 (Channels, "Number of channels");
+ Get_L2 (Patterns, "Number of patterns");
+ Get_L2 (Instruments, "Number of instruments");
+ Get_L2 (Flags, "Flags");
+ Get_L2 (Tempo, "Tempo");
+ Get_L2 (BPM, "BPM");
+ Skip_XX(256, "Pattern order table");
+
+ FILLING_BEGIN();
+ Accept("Extended Module");
+
+ Fill(Stream_General, 0, General_Format, "Extended Module");
+ Fill(Stream_General, 0, General_Format_Version, Ztring::ToZtring(VersionMajor)+_T(".")+Ztring::ToZtring(VersionMinor/10)+Ztring::ToZtring(VersionMinor%10));
+ Fill(Stream_General, 0, General_Track, ModuleName.Trim(_T(' ')));
+ Fill(Stream_General, 0, General_Encoded_Application, TrackerName.Trim(_T(' ')));
+ Fill(Stream_General, 0, "Tempo", Tempo);
+ Fill(Stream_General, 0, "BPM", BPM);
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, "Sampler, Channels", Channels);
+ Fill(Stream_Audio, 0, "Sampler, Patterns", Patterns);
+ Fill(Stream_Audio, 0, "Sampler, Instruments", Instruments);
+
+ //No more need data
+ Finish("Extended Module");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_XM_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ExtendedModule.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ExtendedModule.h
new file mode 100644
index 000000000..66a48322b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ExtendedModule.h
@@ -0,0 +1,52 @@
+// File_ExtendedModule - Info for Extended Module files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WXMHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILXMY or FXMNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Extended Module files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_ExtendedModuleH
+#define MediaInfo_File_ExtendedModuleH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_ExtendedModule
+//***************************************************************************
+
+class File_ExtendedModule : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Flac.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Flac.cpp
new file mode 100644
index 000000000..ebe2239c5
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Flac.cpp
@@ -0,0 +1,267 @@
+// File_Flac - Info for Flac files
+// Copyright (C) 2003-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_FLAC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Flac.h"
+#include "MediaInfo/Tag/File_VorbisCom.h"
+#include "base64.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+extern const char* Id3v2_PictureType(int8u Type); //In Tag/File_Id3v2.cpp
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Flac::File_Flac()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+
+ //In
+ VorbisHeader=false;
+
+ //Temp
+ Last_metadata_block=false;
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Flac::FileHeader_Begin()
+{
+ if (!File__Tags_Helper::FileHeader_Begin())
+ return false;
+
+ //Element_Size
+ if (Buffer_Size<Buffer_Offset+4+(VorbisHeader?9:0))
+ return false; //Must wait for more data
+
+ if (CC4(Buffer+Buffer_Offset+(VorbisHeader?9:0))!=0x664C6143) //"fLaC"
+ {
+ File__Tags_Helper::Finish("Flac");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Flac::FileHeader_Parse()
+{
+ //Parsing
+ if (VorbisHeader)
+ {
+ Skip_B1( "Signature");
+ Skip_Local(4, "Signature");
+ Skip_B1( "Major version");
+ Skip_B1( "Minor version");
+ Skip_B2( "Number of header");
+ }
+ Skip_C4( "Signature");
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Flac::Header_Parse()
+{
+ //Parsing
+ int32u Length;
+ int8u BLOCK_TYPE;
+ BS_Begin();
+ Get_SB ( Last_metadata_block, "Last-metadata-block");
+ Get_S1 (7, BLOCK_TYPE, "BLOCK_TYPE");
+ BS_End();
+ Get_B3 (Length, "Length");
+
+ //Filling
+ Header_Fill_Code(BLOCK_TYPE, Ztring().From_CC1(BLOCK_TYPE));
+ Header_Fill_Size(Element_Offset+Length);
+}
+
+//---------------------------------------------------------------------------
+void File_Flac::Data_Parse()
+{
+ #define CASE_INFO(_NAME) \
+ case Flac::_NAME : Element_Info1(#_NAME); _NAME(); break;
+
+ //Parsing
+ switch ((int16u)Element_Code)
+ {
+ CASE_INFO(STREAMINFO);
+ CASE_INFO(PADDING);
+ CASE_INFO(APPLICATION);
+ CASE_INFO(SEEKTABLE);
+ CASE_INFO(VORBIS_COMMENT);
+ CASE_INFO(CUESHEET);
+ CASE_INFO(PICTURE);
+ default : Skip_XX(Element_Size, "Data");
+ }
+
+ if (Last_metadata_block)
+ {
+ if (!IsSub)
+ Fill(Stream_Audio, 0, Audio_StreamSize, File_Size-(File_Offset+Buffer_Offset+Element_Size));
+
+ //No more need data
+ File__Tags_Helper::Finish("Flac");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Flac::STREAMINFO()
+{
+ //Parsing
+ int64u Samples;
+ int32u FrameSize_Min, FrameSize_Max, SampleRate;
+ int8u Channels, BitPerSample;
+ Skip_B2( "BlockSize_Min"); //The minimum block size (in samples) used in the stream.
+ Skip_B2( "BlockSize_Max"); //The maximum block size (in samples) used in the stream. (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
+ Get_B3 ( FrameSize_Min, "FrameSize_Min"); //The minimum frame size (in bytes) used in the stream. May be 0 to imply the value is not known.
+ Get_B3 ( FrameSize_Max, "FrameSize_Max"); //The maximum frame size (in bytes) used in the stream. May be 0 to imply the value is not known.
+ BS_Begin();
+ Get_S3 (20, SampleRate, "SampleRate"); //Sample rate in Hz. Though 20 bits are available, the maximum sample rate is limited by the structure of frame headers to 1048570Hz. Also, a value of 0 is invalid.
+ Get_S1 ( 3, Channels, "Channels"); Param_Info2(Channels+1, " channels"); //(number of channels)-1. FLAC supports from 1 to 8 channels
+ Get_S1 ( 5, BitPerSample, "BitPerSample"); Param_Info2(BitPerSample+1, " bits"); //(bits per sample)-1. FLAC supports from 4 to 32 bits per sample. Currently the reference encoder and decoders only support up to 24 bits per sample.
+ Get_S5 (36, Samples, "Samples");
+ BS_End();
+ Skip_B16( "MD5 signature of the unencoded audio data");
+
+ FILLING_BEGIN()
+ if (SampleRate==0)
+ return;
+ File__Tags_Helper::Accept("FLAC");
+
+ File__Tags_Helper::Streams_Fill();
+
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "FLAC");
+ Fill(Stream_Audio, 0, Audio_Codec, "FLAC");
+ if (FrameSize_Min==FrameSize_Max && FrameSize_Min!=0 ) // 0 means it is unknown
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR");
+ else
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "VBR");
+ Fill(Stream_Audio, 0, Audio_SamplingRate, SampleRate);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Channels+1);
+ Fill(Stream_Audio, 0, Audio_BitDepth, BitPerSample+1);
+ if (!IsSub)
+ Fill(Stream_Audio, 0, Audio_Duration, Samples*1000/SampleRate);
+
+ Buffer_MaximumSize=4*1024*1024;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Flac::APPLICATION()
+{
+ //Parsing
+ Skip_C4( "Application");
+ if (Element_Size>4)
+ Skip_XX(Element_Size-4, "(Application specific)");
+}
+
+//---------------------------------------------------------------------------
+void File_Flac::VORBIS_COMMENT()
+{
+ //Parsing
+ #if defined(MEDIAINFO_VORBISCOM_YES)
+ File_VorbisCom VorbisCom;
+ VorbisCom.StreamKind_Specific=Stream_Audio;
+ Open_Buffer_Init(&VorbisCom);
+ Open_Buffer_Continue(&VorbisCom);
+ File__Analyze::Finish(&VorbisCom);
+ Merge(VorbisCom, Stream_General, 0, 0);
+ Merge(VorbisCom, Stream_Audio, 0, 0);
+ Merge(VorbisCom, Stream_Menu, 0, 0);
+ #else
+ Skip_XX(Element_Offset, "Data");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Flac::PICTURE()
+{
+ //Parsing
+ int32u PictureType, MimeType_Size, Description_Size, Data_Size;
+ Ztring MimeType, Description;
+ Get_B4 (PictureType, "Picture type"); Element_Info1(Id3v2_PictureType((int8u)PictureType));
+ Get_B4 (MimeType_Size, "MIME type size");
+ Get_Local(MimeType_Size, MimeType, "MIME type");
+ Get_B4 (Description_Size, "Description size");
+ Get_UTF8(Description_Size, Description, "Description");
+ Skip_B4( "Width");
+ Skip_B4( "Height");
+ Skip_B4( "Color depth");
+ Skip_B4( "Number of colors used");
+ Get_B4 (Data_Size, "Data size");
+ if (Element_Offset+Data_Size>Element_Size)
+ return; //There is a problem
+ std::string Data_Raw((const char*)(Buffer+(size_t)(Buffer_Offset+Element_Offset)), Data_Size);
+ std::string Data_Base64(Base64::encode(Data_Raw));
+ Skip_XX(Element_Size-Element_Offset, "Data");
+
+ //Filling
+ Fill(Stream_General, 0, General_Cover, "Yes");
+ Fill(Stream_General, 0, General_Cover_Description, Description);
+ Fill(Stream_General, 0, General_Cover_Type, Id3v2_PictureType((int8u)PictureType));
+ Fill(Stream_General, 0, General_Cover_Mime, MimeType);
+ Fill(Stream_General, 0, General_Cover_Data, Data_Base64);
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_FLAC_YES
+
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Flac.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Flac.h
new file mode 100644
index 000000000..4711d169f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Flac.h
@@ -0,0 +1,95 @@
+// File_Flac - Info for Flac Audio files
+// Copyright (C) 2003-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Flac files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_FlacH
+#define MediaInfo_File_FlacH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Tag/File__Tags.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Flac
+//***************************************************************************
+
+class File_Flac : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //In
+ bool VorbisHeader;
+
+ //Constructor/Destructor
+ File_Flac();
+
+private :
+ //Streams management
+ void Streams_Finish() {File__Tags_Helper::Streams_Finish();}
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Global
+ void Read_Buffer_Continue() {File__Tags_Helper::Read_Buffer_Continue();}
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void STREAMINFO();
+ void PADDING() {Skip_XX(Element_Size, "Data");}
+ void APPLICATION();
+ void SEEKTABLE() {Skip_XX(Element_Size, "Data");}
+ void VORBIS_COMMENT();
+ void CUESHEET() {Skip_XX(Element_Size, "Data");}
+ void PICTURE();
+
+ //Temp
+ bool Last_metadata_block;
+};
+
+//***************************************************************************
+// Const
+//***************************************************************************
+
+namespace Flac
+{
+ const int16u STREAMINFO =0x00;
+ const int16u PADDING =0x01;
+ const int16u APPLICATION =0x02;
+ const int16u SEEKTABLE =0x03;
+ const int16u VORBIS_COMMENT =0x04;
+ const int16u CUESHEET =0x05;
+ const int16u PICTURE =0x06;
+}
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ImpulseTracker.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ImpulseTracker.cpp
new file mode 100644
index 000000000..5746a83bb
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ImpulseTracker.cpp
@@ -0,0 +1,140 @@
+// File_ImpulseTracker - Info for Impulse Tracker files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_IT_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_ImpulseTracker.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_ImpulseTracker::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ if (CC4(Buffer)!=0x494D504D) //"IMPM"
+ {
+ Reject("Impulse Tracker");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_ImpulseTracker::Read_Buffer_Continue()
+{
+ //Parsing
+ Ztring SongName;
+ int16u OrdNum, InsNum, SmpNum, PatNum, Flags, Special;
+ int8u VersionMajor, VersionMinor, SoftwareVersionMajor, SoftwareVersionMinor, IS, TS;
+ bool Stereo;
+ Skip_B4( "Signature");
+
+ Get_Local(26, SongName, "Song name");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Get_L2 (OrdNum, "Orders count");
+ Get_L2 (InsNum, "Instruments count");
+ Get_L2 (SmpNum, "Samples count");
+ Get_L2 (PatNum, "Paterns count");
+ Get_L1 (SoftwareVersionMinor, "Cwt/v (Minor)");
+ Get_L1 (SoftwareVersionMajor, "Cwt/v (Major)");
+ Get_L1 (VersionMinor, "Cwt (Minor)");
+ Get_L1 (VersionMajor, "Cwt (Major)");
+ Get_L2 (Flags, "Flags");
+ Get_Flags (Flags, 0, Stereo, "Stereo");
+ Skip_Flags(Flags, 1, "Vol0MixOptimizations");
+ Skip_Flags(Flags, 2, "Use instruments/Samples");
+ Skip_Flags(Flags, 3, "Linear/Amiga slides");
+ Skip_Flags(Flags, 4, "Old/IT Effects");
+ Get_L2 (Special, "Special");
+ Skip_Flags(Special, 0, "Song Message attached");
+ Skip_L1( "Global volume");
+ Skip_L1( "Mix volume");
+ Get_L1 (IS, "Initial Speed");
+ Get_L1 (TS, "Initial Temp");
+ Skip_L1( "Panning separation between channels");
+ Skip_L1( "0");
+ Skip_L2( "Message Length");
+ Skip_L4( "Message Offset");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Skip_XX(64, "Chnl Pan");
+ Skip_XX(64, "Chnl Vol");
+ Skip_XX(OrdNum, "Orders");
+ Skip_XX(InsNum*4, "Instruments");
+ Skip_XX(SmpNum*4, "Samples");
+ Skip_XX(PatNum*4, "Patterns");
+
+ FILLING_BEGIN();
+ Accept("Impulse Tracker");
+
+ Fill(Stream_General, 0, General_Format, "Impulse Tracker");
+ Fill(Stream_General, 0, General_Format_Version, Ztring(_T("Version "))+Ztring::ToZtring(VersionMajor)+_T(".")+Ztring::ToZtring(VersionMinor/16)+Ztring::ToZtring(VersionMinor%16));
+ Fill(Stream_General, 0, General_Track, SongName);
+ Fill(Stream_General, 0, General_Encoded_Application, Ztring(_T("Impulse Tracker ")+Ztring::ToZtring(SoftwareVersionMajor)+_T(".")+Ztring::ToZtring(SoftwareVersionMinor/16)+Ztring::ToZtring(SoftwareVersionMinor%16)));
+ Fill(Stream_General, 0, "BPM", TS);
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Stereo?2:1);
+
+ //No more need data
+ Finish("Impulse Tracker");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_IT_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ImpulseTracker.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ImpulseTracker.h
new file mode 100644
index 000000000..ce721a57b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ImpulseTracker.h
@@ -0,0 +1,52 @@
+// File_ImpulseTracker - Info for Impulse Tracker files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Impulse Tracker files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_ImpulseTrackerH
+#define MediaInfo_File_ImpulseTrackerH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_ImpulseTracker
+//***************************************************************************
+
+class File_ImpulseTracker : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_La.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_La.cpp
new file mode 100644
index 000000000..5e4955f12
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_La.cpp
@@ -0,0 +1,158 @@
+// File_La - Info for LA files
+// Copyright (C) 2009-2011 Lionel Duchateau, kurtnoise@free.fr
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_LA_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_La.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_La::File_La()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_La::Streams_Finish()
+{
+ //Filling
+ int64u CompressedSize=File_Size-TagsSize;
+ float32 CompressionRatio=((float32)UncompressedSize)/CompressedSize;
+
+ Fill(Stream_Audio, 0, Audio_StreamSize, CompressedSize);
+ Fill(Stream_Audio, 0, Audio_Compression_Ratio, CompressionRatio);
+
+ File__Tags_Helper::Streams_Finish();
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_La::FileHeader_Begin()
+{
+ if (!File__Tags_Helper::FileHeader_Begin())
+ return false;
+
+ //Synchro
+ if (Buffer_Offset+2>Buffer_Size)
+ return false;
+ if (CC3(Buffer+Buffer_Offset)!=0x4C4130) //"LA0"
+ {
+ File__Tags_Helper::Reject("LA");
+ return false;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_La::FileHeader_Parse()
+{
+ //Parsing
+ Ztring Major, Minor;
+ int32u SampleRate, Samples, BytesPerSecond, UnCompSize, WAVEChunk, FmtSize, FmtChunk, CRC32;
+ int16u RawFormat, Channels, BytesPerSample, BitsPerSample;
+
+ Skip_Local(2, "signature");
+ Get_Local (1, Major, "major_version");
+ Get_Local (1, Minor, "minor_version");
+ Get_L4 (UnCompSize, "uncompressed_size");
+ Get_L4 (WAVEChunk, "chunk");
+ Skip_L4( "fmt_size");
+ Get_L4 (FmtChunk, "fmt_chunk");
+ Get_L4 (FmtSize, "fmt_size");
+ Get_L2 (RawFormat, "raw_format");
+ Get_L2 (Channels, "channels"); Param_Info2(Channels, " channel(s)");
+ Get_L4 (SampleRate, "sample_rate");
+ Get_L4 (BytesPerSecond, "bytes_per_second");
+ Get_L2 (BytesPerSample, "bytes_per_sample");
+ Get_L2 (BitsPerSample, "bits_per_sample");
+ Get_L4 (Samples, "samples");
+ Skip_L1( "flags");
+ Get_L4 (CRC32, "crc");
+
+ FILLING_BEGIN()
+ if (SampleRate==0)
+ return;
+ Duration=((int64u)Samples/Channels)*1000/SampleRate; // Seems that it's samples per channels otherwise Duration is doubled ??!!
+ if (Duration==0)
+ return;
+ UncompressedSize=(Samples)*Channels*(BitsPerSample/8);
+ if (UncompressedSize==0)
+ return;
+
+ File__Tags_Helper::Accept("LA");
+ Fill(Stream_General, 0, General_Format_Version, Major+_T('.')+Minor);
+
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "LA");
+ Fill(Stream_Audio, 0, Audio_Codec, "LA");
+ Fill(Stream_Audio, 0, Audio_Format_Version, Major+_T('.')+Minor);
+ Fill(Stream_Audio, 0, Audio_BitDepth, BitsPerSample);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Channels);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, SampleRate);
+ Fill(Stream_Audio, 0, Audio_Duration, Duration);
+
+ //No more need data
+ File__Tags_Helper::Finish("LA");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_LA_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_La.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_La.h
new file mode 100644
index 000000000..3d263fd20
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_La.h
@@ -0,0 +1,63 @@
+// File_La - Info for LA files
+// Copyright (C) 2009-2009 Lionel Duchateau, kurtnoise@free.fr
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_LaH
+#define MediaInfo_File_LaH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Tag/File__Tags.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_La
+//***************************************************************************
+
+class File_La : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //Constructor/Destructor
+ File_La();
+
+private :
+ //Streams management
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Global
+ void Read_Buffer_Continue() {File__Tags_Helper::Read_Buffer_Continue();}
+
+ //Temp
+ int64u Duration;
+ int64u UncompressedSize;
+ bool seekable;
+ bool high;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Midi.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Midi.cpp
new file mode 100644
index 000000000..37f7ce61b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Midi.cpp
@@ -0,0 +1,59 @@
+// File_Midi - Info for MIDI files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MIDI_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Midi.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Midi::Read_Buffer_Continue()
+{
+ Reject("MIDI");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_MIDI_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Midi.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Midi.h
new file mode 100644
index 000000000..7097dc98d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Midi.h
@@ -0,0 +1,49 @@
+// File_Midi - Info for MIDI files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MIDI files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_MidiH
+#define MediaInfo_File_MidiH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Midi
+//***************************************************************************
+
+class File_Midi : public File__Analyze
+{
+protected :
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Module.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Module.cpp
new file mode 100644
index 000000000..e08a5a847
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Module.cpp
@@ -0,0 +1,116 @@
+// File_Module - Info for Module files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WXMHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILXMY or FXMNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MOD_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Module.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Module::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<1084)
+ return false; //Must wait for more data
+
+ int32u Signature=CC4(Buffer+1080);
+ switch (Signature)
+ {
+ case 0x4D2E4B2E : //M.K.
+ case 0x4D214B21 : //M!K!
+ case 0x664C5434 : //FLT4
+ case 0x664C5438 : //FLT8
+ case 0x3663684E : //6CHN
+ case 0x3863684E : //8CHN
+ break;
+ default : Reject("Module");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Module::Read_Buffer_Continue()
+{
+ //Parsing
+ Ztring ModuleName, SamplesName;
+ Get_Local (20, ModuleName, "Module name");
+ for (int8u Pos=0; Pos<31; Pos++)
+ {
+ Element_Begin0();
+ Get_Local(22, SamplesName, "Sample's name"); Element_Name(SamplesName);
+ Skip_B2( "Sample length");
+ Skip_B1( "Finetune value for the sample");
+ Skip_B1( "Volume of the sample");
+ Skip_B2( "Start of sample repeat offset");
+ Skip_B2( "Length of sample repeat");
+ Element_End0();
+ }
+ Skip_B1( "Number of song positions");
+ Skip_B1( "0x8F");
+ Skip_XX(128, "Pattern table");
+ Skip_C4( "Signature");
+
+ FILLING_BEGIN();
+ Accept("Module");
+
+ Fill(Stream_General, 0, General_Format, "Module");
+
+ Stream_Prepare(Stream_Audio);
+
+ //No more need data
+ Finish("Module");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_MOD_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Module.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Module.h
new file mode 100644
index 000000000..65ba53169
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Module.h
@@ -0,0 +1,53 @@
+// File_Module - Info for Module files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WXMHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILXMY or FXMNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Module files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_ModuleH
+#define MediaInfo_File_ModuleH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Module
+//***************************************************************************
+
+class File_Module : public File__Analyze
+{
+public :
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpc.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpc.cpp
new file mode 100644
index 000000000..bdf078bc4
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpc.cpp
@@ -0,0 +1,224 @@
+// File_Mpc - Info for Musepack files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Source: http://trac.musepack.net/trac/wiki/SV7Specification
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos (Common)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPC_YES) || defined(MEDIAINFO_MPCSV8_YES)
+//---------------------------------------------------------------------------
+
+#include "ZenLib/Conf.h"
+using namespace ZenLib;
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern const int16u Mpc_SampleFreq[]=
+{
+ 44100, //CD
+ 48000, //DAT, DVC, ADR
+ 37800, //CD-ROM-XA
+ 32000, //DSR, DAT-LP, DVC-LP
+};
+
+//---------------------------------------------------------------------------
+} //NameSpace
+
+//---------------------------------------------------------------------------
+#endif //...
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+//
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Mpc.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Mpc_Profile[]=
+{
+ "no profile",
+ "Unstable/Experimental",
+ "",
+ "",
+ "",
+ "Below Telephone (q=0)",
+ "Below Telephone (q=1)",
+ "Telephone (q=2)",
+ "Thumb (q=3)",
+ "Radio (q=4)",
+ "Standard (q=5)",
+ "Xtreme (q=6)",
+ "Insane (q=7)",
+ "BrainDead (q=8)",
+ "Above BrainDead (q=9)",
+ "Above BrainDead (q=10)",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpc_Link[]=
+{
+ "Starts or ends with a very low level",
+ "Ends loudly",
+ "Starts loudly",
+ "Starts loudly and ends loudly",
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Mpc::File_Mpc()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+}
+
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Mpc::FileHeader_Begin()
+{
+ //Tags
+ if (!File__Tags_Helper::FileHeader_Begin())
+ return false;
+
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+
+ //Test
+ if (CC3(Buffer)!=0x4D502B || (CC1(Buffer+3)&0x0F)!=7) //"MP+" version 7
+ {
+ File__Tags_Helper::Reject("Musepack SV7");
+ return false;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpc::FileHeader_Parse()
+{
+ //Parsing
+ Element_Begin1("SV7 header");
+ Ztring Encoder;
+ int32u FrameCount;
+ int16u TitleGain, AlbumGain;
+ int8u Profile, Link, SampleFreq, EncoderVersion;
+
+ Skip_C3( "Signature");
+ BS_Begin();
+ Skip_S1(4, "PNS");
+ Skip_S1(4, "Version");
+ BS_End();
+
+ Get_L4 (FrameCount, "FrameCount");
+
+ Skip_L2( "MaxLevel");
+ BS_Begin();
+ Get_S1 (4, Profile, "Profile"); Param_Info1(Mpc_Profile[Profile]);
+ Get_S1 (2, Link, "Link"); Param_Info1(Mpc_Link[Link]);
+ Get_S1 (2, SampleFreq, "SampleFreq"); Param_Info1(Mpc_SampleFreq[SampleFreq]);
+ Skip_SB( "IntensityStereo");
+ Skip_SB( "MidSideStereo");
+ Skip_S1(6, "MaxBand");
+ BS_End();
+
+ Skip_L2( "TitlePeak");
+ Get_L2 (TitleGain, "TitleGain"); Param_Info3(((float32)((int16s)TitleGain))/1000, 2, " dB");
+
+ Skip_L2( "AlbumPeak");
+ Get_L2 (AlbumGain, "AlbumGain"); Param_Info3(((float32)((int16s)TitleGain))/1000, 2, " dB");
+
+ BS_Begin();
+ Skip_S2(16, "unused");
+ Skip_S1( 4, "LastFrameLength (part 1)");
+ Skip_SB( "FastSeekingSafe");
+ Skip_S1( 3, "unused");
+ Skip_SB( "TrueGapless");
+ Skip_S1( 7, "LastFrameLength (part 2)");
+ BS_End();
+
+ Get_L1 (EncoderVersion, "EncoderVersion");
+ Encoder.From_Number(((float)EncoderVersion)/100, 2); if (EncoderVersion%10==0); else if (EncoderVersion%2==0) Encoder+=_T(" Beta"); else if (EncoderVersion%2==1) Encoder+=_T(" Alpha"); Param_Info1(Encoder);
+
+ Element_End0();
+
+ FILLING_BEGIN();
+ File__Tags_Helper::Accept("Musepack SV7");
+
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, Mpc_SampleFreq[SampleFreq]);
+ Fill(Stream_Audio, 0, Audio_SamplingCount, FrameCount*1152);
+ Fill(Stream_Audio, 0, Audio_Format, "Musepack SV7");
+ Fill(Stream_Audio, 0, Audio_Codec, "SV7");
+ Fill(Stream_Audio, 0, Audio_Codec_Settings, Mpc_Profile[Profile]);
+ Fill(Stream_Audio, 0, Audio_Encoded_Library, Encoder);
+ Fill(Stream_Audio, 0, Audio_BitDepth, 16); //MPC support only 16 bits
+ Fill(Stream_Audio, 0, Audio_Duration, ((int64u)FrameCount)*1152*1000/Mpc_SampleFreq[SampleFreq]);
+ if (FrameCount)
+ Fill(Stream_Audio, 0, Audio_BitRate, (File_Size-25)*8*Mpc_SampleFreq[SampleFreq]/FrameCount/1152);
+
+ //No more need data
+ File__Tags_Helper::Finish("Musepack SV7");
+ FILLING_END();
+}
+
+} //Namespace
+
+#endif //MEDIAINFO_MPC_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpc.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpc.h
new file mode 100644
index 000000000..351780812
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpc.h
@@ -0,0 +1,62 @@
+// File_Mpc - Info for Musepack files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Musepack files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_MpcH
+#define MediaInfo_File_MpcH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Tag/File__Tags.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Mpc
+//***************************************************************************
+
+class File_Mpc : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //Constructor/Destructor
+ File_Mpc();
+
+private :
+ //Streams management
+ void Streams_Finish() {File__Tags_Helper::Streams_Finish();}
+
+ //Buffer - Global
+ void Read_Buffer_Continue() {File__Tags_Helper::Read_Buffer_Continue();}
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_MpcSv8.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_MpcSv8.cpp
new file mode 100644
index 000000000..d712f0788
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_MpcSv8.cpp
@@ -0,0 +1,257 @@
+// File_MpcSv8 - Info for Musepack (SV8) files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Source: http://trac.musepack.net/trac/wiki/SV8Specification
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPCSV8_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_MpcSv8.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+extern const int16u Mpc_SampleFreq[];
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+namespace Elements
+{
+ const int32u AP=0x4150;
+ const int32u CT=0x4354;
+ const int32u EI=0x4549;
+ const int32u RG=0x5247;
+ const int32u SE=0x5345;
+ const int32u SH=0x5348;
+ const int32u SO=0x534F;
+ const int32u ST=0x5354;
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_MpcSv8::File_MpcSv8()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+}
+
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_MpcSv8::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ if (CC4(Buffer)!=0x4D50434B) //"MPCK"
+ {
+ File__Tags_Helper::Reject("Musepack SV8");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpcSv8::FileHeader_Parse()
+{
+ //Parsing
+ Skip_C4( "Magic Number");
+
+ FILLING_BEGIN();
+ File__Tags_Helper::Accept("MpcSv8");
+
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "Musepack SV8");
+ Fill(Stream_Audio, 0, Audio_Codec, "SV8");
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_MpcSv8::Header_Begin()
+{
+ //Tags
+ if (!File__Tags_Helper::Header_Begin())
+ return false;
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_MpcSv8::Header_Parse()
+{
+ //Parsing
+ int64u Size;
+ int16u Key;
+ Get_C2 (Key, "Key");
+ Get_VS (Size, "Size");
+
+ //Filling
+ Header_Fill_Code(Key, Ztring().From_CC4(Key<<16)); //Quick filling for CC2 with text
+ Header_Fill_Size(Key==Elements::AP?Element_Offset:Size); //We don't need the data of audio packet, and we will stop here...
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpcSv8::Data_Parse()
+{
+ #define CASE_INFO(_NAME, _DETAIL) \
+ case Elements::_NAME : Element_Info1(_DETAIL); _NAME(); break;
+
+ //Parsing
+ switch (Element_Code)
+ {
+ CASE_INFO(AP, "Audio Packet");
+ CASE_INFO(CT, "Chapter-Tag");
+ CASE_INFO(EI, "Encoder Info");
+ CASE_INFO(RG, "Replay Gain");
+ CASE_INFO(SE, "Stream End");
+ CASE_INFO(SH, "Stream Header");
+ CASE_INFO(SO, "Seek Table Offset");
+ CASE_INFO(ST, "Seek Table");
+ default : Skip_XX(Element_Size, "Data");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpcSv8::AP()
+{
+ //No more need data
+ File__Tags_Helper::Finish("MpcSv8");
+}
+
+//---------------------------------------------------------------------------
+void File_MpcSv8::EI()
+{
+ //Parsing
+ int8u Quality, Version1, Version2, Version3;
+ bool PNS;
+ BS_Begin();
+ Get_S1 (7, Quality, "Quality");
+ Get_SB ( PNS, "PNS");
+ BS_End();
+ Get_B1 (Version1, "Major version");
+ Get_B1 (Version2, "Minor version");
+ Get_B1 (Version3, "Build");
+}
+
+//---------------------------------------------------------------------------
+void File_MpcSv8::RG()
+{
+ //Parsing
+ int16u TitleGain, AlbumGain;
+ Skip_B1( "Version");
+ Get_L2 (TitleGain, "Title gain"); Param_Info3(((float32)((int16s)TitleGain))/1000, 2, " dB");
+ Skip_L2( "Title peak");
+ Get_L2 (AlbumGain, "Album gain"); Param_Info3(((float32)((int16s)TitleGain))/1000, 2, " dB");
+ Skip_L2( "Album peak");
+}
+
+//---------------------------------------------------------------------------
+void File_MpcSv8::SH()
+{
+ //Parsing
+ int64u SampleCount;
+ int8u Version, SampleFrequency, ChannelCount;
+ bool MidSideStereo;
+ Skip_B4( "CRC32");
+ Get_B1 (Version, "Version");
+ Get_VS (SampleCount, "Sample count");
+ Skip_VS( "Beginning silence");
+ BS_Begin();
+ Get_S1 (3, SampleFrequency, "Sample frequency"); Param_Info1(Mpc_SampleFreq[SampleFrequency]);
+ Skip_S1(5, "Max used bands");
+ Get_S1 (4, ChannelCount, "Channel count");
+ Get_SB ( MidSideStereo, "Mid side stereo used");
+ Skip_S1(3, "Audio block frames");
+ BS_End();
+
+ //Filling
+ FILLING_BEGIN();
+ Fill(Stream_Audio, 0, Audio_SamplingRate, Mpc_SampleFreq[SampleFrequency]);
+ if (SampleCount)
+ {
+ Fill(Stream_Audio, 0, Audio_SamplingCount, SampleCount);
+ Fill(Stream_Audio, 0, Audio_Duration, SampleCount*1000/Mpc_SampleFreq[SampleFrequency]);
+ Fill(Stream_Audio, 0, Audio_BitRate, File_Size*8*Mpc_SampleFreq[SampleFrequency]/SampleCount); //Should be more precise...
+ }
+ Fill(Stream_Audio, 0, Audio_BitDepth, 16); //MPC support only 16 bits
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_MpcSv8::SO()
+{
+ //Parsing
+ Skip_VS( "Offset");
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPCSV8_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_MpcSv8.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_MpcSv8.h
new file mode 100644
index 000000000..00e036906
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_MpcSv8.h
@@ -0,0 +1,77 @@
+// File_MpcSv8 - Info for Musepack (SV8) files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Musepack files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_MpcSv8H
+#define MediaInfo_File_MpcSv8H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Tag/File__Tags.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_MpcSv8
+//***************************************************************************
+
+class File_MpcSv8 : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //Constructor/Destructor
+ File_MpcSv8();
+
+private :
+ //Streams management
+ void Streams_Finish() {File__Tags_Helper::Streams_Finish();}
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Global
+ void Read_Buffer_Continue() {File__Tags_Helper::Read_Buffer_Continue();}
+
+ //Buffer - Per element
+ bool Header_Begin();
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void AP();
+ void CT() {Skip_XX(Element_Size, "Data");}
+ void EI();
+ void RG();
+ void SE() {Skip_XX(Element_Size, "Data");}
+ void SH();
+ void SO();
+ void ST() {Skip_XX(Element_Size, "Data");}
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpega.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpega.cpp
new file mode 100644
index 000000000..b1f996d33
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpega.cpp
@@ -0,0 +1,1591 @@
+// File_Mpega - Info for MPEG Audio files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// A good start : http://www.codeproject.com/audio/MPEGAudioInfo.asp
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Constants (Common)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEGA_YES) || defined(MEDIAINFO_MPEGTS_YES) || defined(MEDIAINFO_MPEGPS_YES)
+//---------------------------------------------------------------------------
+
+#include "ZenLib/Conf.h"
+using namespace ZenLib;
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+const char* Mpega_Version[4]=
+{
+ "MPA2.5",
+ "",
+ "MPA2",
+ "MPA1"
+};
+
+//---------------------------------------------------------------------------
+const char* Mpega_Layer[4]=
+{
+ "",
+ "L3",
+ "L2",
+ "L1",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpega_Format_Profile_Version[4]=
+{
+ "Version 2.5",
+ "",
+ "Version 2",
+ "Version 1"
+};
+
+//---------------------------------------------------------------------------
+const char* Mpega_Format_Profile_Layer[4]=
+{
+ "",
+ "Layer 3",
+ "Layer 2",
+ "Layer 1",
+};
+
+//---------------------------------------------------------------------------
+} //NameSpace
+
+//---------------------------------------------------------------------------
+#endif //...
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+//
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEGA_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Mpega.h"
+#include "ZenLib/BitStream.h"
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Mpega_Version_String[4]=
+{
+ "MPEG-2.5 Audio",
+ "",
+ "MPEG-2 Audio",
+ "MPEG-1 Audio",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpega_Layer_String[4]=
+{
+ "",
+ " layer 3",
+ " layer 2",
+ " layer 1",
+};
+
+//---------------------------------------------------------------------------
+const int16u Mpega_BitRate[4][4][16]=
+{
+ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //MPEG Audio 2.5 layer X
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}, //MPEG Audio 2.5 layer 3
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}, //MPEG Audio 2.5 layer 2
+ {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0}}, //MPEG Audio 2.5 layer 1
+ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //MPEG Audio X layer X
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //MPEG Audio X layer 3
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //MPEG Audio X layer 2
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //MPEG Audio X layer 1
+ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //MPEG Audio 2 layer X
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}, //MPEG Audio 2 layer 3
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}, //MPEG Audio 2 layer 2
+ {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0}}, //MPEG Audio 2 layer 1
+ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //MPEG Audio 1 layer X
+ {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0}, //MPEG Audio 1 layer 3
+ {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0}, //MPEG Audio 1 layer 2
+ {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0}}, //MPEG Audio 1 layer 1
+};
+
+//---------------------------------------------------------------------------
+const int16u Mpega_SamplingRate[4][4]=
+{
+ {11025, 12000, 8000, 0}, //MPEG Audio 2.5
+ { 0, 0, 0, 0}, //MPEG Audio X
+ {22050, 24000, 16000, 0}, //MPEG Audio 2
+ {44100, 48000, 32000, 0}, //MPEG Audio 1
+};
+
+//---------------------------------------------------------------------------
+const int16u Mpega_Channels[4]=
+{
+ 2,
+ 2,
+ 2,
+ 1,
+};
+
+//---------------------------------------------------------------------------
+const char* Mpega_Codec_Profile[4]=
+{
+ "",
+ "Joint stereo",
+ "Dual mono",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpega_Codec_Profile_Extension[]=
+{
+ "",
+ "Intensity Stereo",
+ "MS Stereo",
+ "Intensity Stereo + MS Stereo",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpega_Emphasis[]=
+{
+ "",
+ "50/15ms",
+ "Reserved",
+ "CCITT",
+};
+
+//---------------------------------------------------------------------------
+const char* Lame_BitRate_Mode[]=
+{
+ "",
+ "CBR",
+ "VBR",
+ "VBR",
+ "VBR",
+ "VBR",
+ "VBR",
+ "",
+ "CBR",
+ "VBR",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Lame_Method[]=
+{
+ "",
+ "CBR",
+ "ABR",
+ "VBR (rh)",
+ "VBR (mtrh)",
+ "VBR (rh)",
+ "VBR",
+ "",
+ "CBR (2-pass)",
+ "ABR (2-pass)",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const int8u Mpega_Coefficient[4][4] = //Samples per Frame / 8
+{
+ { 0, 72, 144, 12}, //MPEG Audio 2.5
+ { 0, 0, 0, 0}, //MPEG Audio X
+ { 0, 72, 144, 12}, //MPEG Audio 2
+ { 0, 144, 144, 12}, //MPEG Audio 1
+};
+
+//---------------------------------------------------------------------------
+const int8u Mpega_SlotSize[4]= //A frame is coposed of slots
+{
+ 0, // Layer X
+ 1, // Layer3
+ 1, // Layer2
+ 4, // Layer1
+};
+
+//---------------------------------------------------------------------------
+const int16u Mpega_CRC12_Table[]=
+{
+ 0x000, 0x80f, 0x811, 0x01e, 0x82d, 0x022, 0x03c, 0x833,
+ 0x855, 0x05a, 0x044, 0x84b, 0x078, 0x877, 0x869, 0x066,
+ 0x8a5, 0x0aa, 0x0b4, 0x8bb, 0x088, 0x887, 0x899, 0x096,
+ 0x0f0, 0x8ff, 0x8e1, 0x0ee, 0x8dd, 0x0d2, 0x0cc, 0x8c3,
+ 0x945, 0x14a, 0x154, 0x95b, 0x168, 0x967, 0x979, 0x176,
+ 0x110, 0x91f, 0x901, 0x10e, 0x93d, 0x132, 0x12c, 0x923,
+ 0x1e0, 0x9ef, 0x9f1, 0x1fe, 0x9cd, 0x1c2, 0x1dc, 0x9d3,
+ 0x9b5, 0x1ba, 0x1a4, 0x9ab, 0x198, 0x997, 0x989, 0x186,
+ 0xa85, 0x28a, 0x294, 0xa9b, 0x2a8, 0xaa7, 0xab9, 0x2b6,
+ 0x2d0, 0xadf, 0xac1, 0x2ce, 0xafd, 0x2f2, 0x2ec, 0xae3,
+ 0x220, 0xa2f, 0xa31, 0x23e, 0xa0d, 0x202, 0x21c, 0xa13,
+ 0xa75, 0x27a, 0x264, 0xa6b, 0x258, 0xa57, 0xa49, 0x246,
+ 0x3c0, 0xbcf, 0xbd1, 0x3de, 0xbed, 0x3e2, 0x3fc, 0xbf3,
+ 0xb95, 0x39a, 0x384, 0xb8b, 0x3b8, 0xbb7, 0xba9, 0x3a6,
+ 0xb65, 0x36a, 0x374, 0xb7b, 0x348, 0xb47, 0xb59, 0x356,
+ 0x330, 0xb3f, 0xb21, 0x32e, 0xb1d, 0x312, 0x30c, 0xb03,
+ 0xd05, 0x50a, 0x514, 0xd1b, 0x528, 0xd27, 0xd39, 0x536,
+ 0x550, 0xd5f, 0xd41, 0x54e, 0xd7d, 0x572, 0x56c, 0xd63,
+ 0x5a0, 0xdaf, 0xdb1, 0x5be, 0xd8d, 0x582, 0x59c, 0xd93,
+ 0xdf5, 0x5fa, 0x5e4, 0xdeb, 0x5d8, 0xdd7, 0xdc9, 0x5c6,
+ 0x440, 0xc4f, 0xc51, 0x45e, 0xc6d, 0x462, 0x47c, 0xc73,
+ 0xc15, 0x41a, 0x404, 0xc0b, 0x438, 0xc37, 0xc29, 0x426,
+ 0xce5, 0x4ea, 0x4f4, 0xcfb, 0x4c8, 0xcc7, 0xcd9, 0x4d6,
+ 0x4b0, 0xcbf, 0xca1, 0x4ae, 0xc9d, 0x492, 0x48c, 0xc83,
+ 0x780, 0xf8f, 0xf91, 0x79e, 0xfad, 0x7a2, 0x7bc, 0xfb3,
+ 0xfd5, 0x7da, 0x7c4, 0xfcb, 0x7f8, 0xff7, 0xfe9, 0x7e6,
+ 0xf25, 0x72a, 0x734, 0xf3b, 0x708, 0xf07, 0xf19, 0x716,
+ 0x770, 0xf7f, 0xf61, 0x76e, 0xf5d, 0x752, 0x74c, 0xf43,
+ 0xec5, 0x6ca, 0x6d4, 0xedb, 0x6e8, 0xee7, 0xef9, 0x6f6,
+ 0x690, 0xe9f, 0xe81, 0x68e, 0xebd, 0x6b2, 0x6ac, 0xea3,
+ 0x660, 0xe6f, 0xe71, 0x67e, 0xe4d, 0x642, 0x65c, 0xe53,
+ 0xe35, 0x63a, 0x624, 0xe2b, 0x618, 0xe17, 0xe09, 0x606
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Mpega::File_Mpega()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+
+ //Configuration
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+ PTS_DTS_Needed=true;
+ IsRawStream=true;
+
+ //In
+ Frame_Count_Valid=MediaInfoLib::Config.ParseSpeed_Get()>=0.5?128:(MediaInfoLib::Config.ParseSpeed_Get()>=0.3?32:4);
+ FrameIsAlwaysComplete=false;
+ CalculateDelay=false;
+
+ //Temp - BitStream info
+ Surround_Frames=0;
+ Block_Count[0]=0;
+ Block_Count[1]=0;
+ Block_Count[2]=0;
+ Channels_Count[0]=0;
+ Channels_Count[1]=0;
+ Channels_Count[2]=0;
+ Channels_Count[3]=0;
+ Extension_Count[0]=0;
+ Extension_Count[1]=0;
+ Extension_Count[2]=0;
+ Extension_Count[3]=0;
+ Emphasis_Count[0]=0;
+ Emphasis_Count[1]=0;
+ Emphasis_Count[2]=0;
+ Emphasis_Count[3]=0;
+ Scfsi=0;
+ Scalefac=0;
+ Reservoir=0;
+ LastSync_Offset=(int64u)-1;
+ VBR_FileSize=0;
+ VBR_Frames=0;
+ Reservoir_Max=0;
+ Xing_Scale=0;
+ BitRate=0;
+ MpegPsPattern_Count=0;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpega::Streams_Fill()
+{
+ //VBR detection without header
+ if (VBR_Frames==0)
+ {
+ //How much kinds of bitrates?
+ if (BitRate_Count.size()>1)
+ BitRate_Mode=_T("VBR");
+ }
+
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "MPEG Audio");
+ Fill(Stream_Audio, 0, Audio_Format_Version, Mpega_Format_Profile_Version[ID]);
+ Fill(Stream_Audio, 0, Audio_Format_Profile, Mpega_Format_Profile_Layer[layer]);
+ if (mode && mode<4)
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Settings, Mpega_Codec_Profile[mode]);
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Mode, Mpega_Codec_Profile[mode]);
+ }
+ if (mode_extension && mode_extension<4)
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Settings, Mpega_Codec_Profile_Extension[mode_extension]);
+ Fill(Stream_Audio, 0, Audio_Format_Settings_ModeExtension, Mpega_Codec_Profile_Extension[mode_extension]);
+ }
+ if (emphasis && emphasis<4)
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Settings, Mpega_Emphasis[emphasis]);
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Emphasis, Mpega_Emphasis[emphasis]);
+ }
+ Fill(Stream_Audio, 0, Audio_Codec, Ztring(Mpega_Version[ID])+Ztring(Mpega_Layer[layer]));
+ Fill(Stream_Audio, 0, Audio_Codec_String, Ztring(Mpega_Version_String[ID])+Ztring(Mpega_Layer_String[layer]), true);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, Mpega_SamplingRate[ID][sampling_frequency]);
+ if (mode<4)
+ {
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Mpega_Channels[mode]);
+ Fill(Stream_Audio, 0, Audio_Codec_Profile, Mpega_Codec_Profile[mode]);
+ }
+
+ //Bitrate, if CBR
+ if (VBR_Frames==0 && BitRate_Mode!=_T("VBR"))
+ {
+ BitRate_Mode=_T("CBR");
+ BitRate=Mpega_BitRate[ID][layer][bitrate_index]*1000;
+ Fill(Stream_General, 0, General_OverallBitRate, BitRate);
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate);
+ if (CalculateDelay && Buffer_TotalBytes_FirstSynched>10 && BitRate>0)
+ {
+ Fill(Stream_Audio, 0, Audio_Delay, Buffer_TotalBytes_FirstSynched*8*1000/BitRate, 0);
+ Fill(Stream_Audio, 0, Audio_Delay_Source, "Stream");
+ }
+ }
+
+ //Bitrate mode
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, BitRate_Mode);
+ Fill(Stream_Audio, 0, Audio_BitRate_Minimum, BitRate_Minimum);
+ Fill(Stream_Audio, 0, Audio_BitRate_Nominal, BitRate_Nominal);
+
+ //Tags
+ File__Tags_Helper::Streams_Fill();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpega::Streams_Finish()
+{
+ //Reservoir
+ //Fill("Reservoir_Avg", Reservoir/Frame_Count);
+ //Fill("Reservoir_Max", Reservoir_Max);
+ //size_t Granules=(Mpeg==3?2:1);
+ //size_t Ch=Mpega_Channels[Channels];
+ //Fill("Scalefactors", Ztring::ToZtring(Scalefac*100/(Granules*Ch*Frame_Count))+_T('%'));
+
+ //VBR_FileSize calculation
+ if (!IsSub && (File_Size!=(int64u)-1 || LastSync_Offset!=(int64u)-1) && VBR_FileSize==0)
+ {
+ //We calculate VBR_FileSize from the last synch or File_Size
+ if (LastSync_Offset!=(int64u)-1)
+ {
+ VBR_FileSize=LastSync_Offset;
+ VBR_FileSize-=File_BeginTagSize;
+ }
+ else
+ {
+ VBR_FileSize=File_Size;
+ VBR_FileSize-=File_BeginTagSize;
+ VBR_FileSize-=File_EndTagSize;
+ }
+ }
+
+ //Bitrate calculation if VBR
+ int64u FrameCount=0;
+ if (VBR_Frames>0)
+ {
+ FrameCount=VBR_Frames;
+ float32 FrameLength=((float32)(VBR_FileSize?VBR_FileSize:File_Size-File_EndTagSize-File_BeginTagSize))/VBR_Frames;
+ size_t Divider;
+ if (ID==3 && layer==3) //MPEG 1 layer 1
+ Divider=384/8;
+ else if ((ID==2 || ID==0) && layer==3) ///MPEG 2 or 2.5 layer 1
+ Divider=192/8;
+ else if ((ID==2 || ID==0) && layer==1) //MPEG 2 or 2.5 layer 3
+ Divider=576/8;
+ else
+ Divider=1152/8;
+ if (ID<4 && sampling_frequency<4)
+ BitRate=(int32u)(FrameLength*Mpega_SamplingRate[ID][sampling_frequency]/Divider);
+ BitRate_Mode=_T("VBR");
+ }
+ //if (BitRate_Count.size()>1)
+ //{
+ // Ztring BitRate_VBR;
+ // if (!BitRate_VBR.empty())
+ // BitRate_VBR+=_T(' ');
+ // BitRate_VBR+=Ztring::ToZtring(8);
+ // BitRate_VBR+=_T(':');
+ // BitRate_VBR+=Ztring::ToZtring(BitRate_Count[8]);
+ // Fill("BitRate_VBR", Ztring::ToZtring(BitRate_Count[8]));
+ //}
+ if (VBR_FileSize)
+ {
+ if (BitRate)
+ {
+ Fill(Stream_General, 0, General_Duration, VBR_FileSize*8*1000/BitRate, 10, true);
+ Fill(Stream_General, 0, General_OverallBitRate, BitRate, 10, true);
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate, 10, true);
+ if (CalculateDelay && Buffer_TotalBytes_FirstSynched>10 && BitRate>0)
+ {
+ Fill(Stream_Audio, 0, Audio_Delay, Buffer_TotalBytes_FirstSynched*8*1000/BitRate, 0, true);
+ Fill(Stream_Audio, 0, Audio_Delay_Source, "Stream", Unlimited, true, true);
+ }
+ }
+ Fill(Stream_Audio, 0, Audio_StreamSize, VBR_FileSize);
+ }
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, BitRate_Mode, true);
+
+ //Encoding library
+ if (!Encoded_Library.empty())
+ Fill(Stream_General, 0, General_Encoded_Library, Encoded_Library, true);
+ if (Encoded_Library.empty())
+ Encoded_Library_Guess();
+ Fill(Stream_Audio, 0, Audio_Encoded_Library, Encoded_Library, true);
+ Fill(Stream_Audio, 0, Audio_Encoded_Library_Settings, Encoded_Library_Settings, true);
+
+ //Surround
+ if (Surround_Frames>=Frame_Count*0.9)
+ {
+ //Fill(Stream_Audio, 0, Audio_Channel_s_, 6);
+ }
+
+ if (FrameInfo.PTS!=(int64u)-1 && FrameInfo.PTS>PTS_Begin)
+ {
+ Fill(Stream_Audio, 0, Audio_Duration, float64_int64s(((float64)(FrameInfo.PTS-PTS_Begin))/1000000));
+ if (Retrieve(Stream_Audio, 0, Audio_BitRate_Mode)==_T("CBR"))
+ {
+ int16u Samples;
+ if (ID==3 && layer==3) //MPEG 1 layer 1
+ Samples=384;
+ else if ((ID==2 || ID==0) && layer==1) //MPEG 2 or 2.5 layer 3
+ Samples=576;
+ else
+ Samples=1152;
+
+ float64 Frame_Duration=((float64)1)/Mpega_SamplingRate[ID][sampling_frequency]*Samples;
+ FrameCount=float64_int64s(((float64)(FrameInfo.PTS-PTS_Begin))/1000000000/Frame_Duration);
+ }
+ }
+
+ if (FrameCount==0 && VBR_FileSize && Retrieve(Stream_Audio, 0, Audio_BitRate_Mode)==_T("CBR") && Mpega_SamplingRate[ID][sampling_frequency])
+ {
+ size_t Size=(Mpega_Coefficient[ID][layer]*Mpega_BitRate[ID][layer][bitrate_index]*1000/Mpega_SamplingRate[ID][sampling_frequency])*Mpega_SlotSize[layer];
+ if (Size)
+ FrameCount=float64_int64s(((float64)VBR_FileSize)/Size);
+ }
+
+ if (FrameCount)
+ {
+ int16u Samples;
+ if (ID==3 && layer==3) //MPEG 1 layer 1
+ Samples=384;
+ else if ((ID==2 || ID==0) && layer==1) //MPEG 2 or 2.5 layer 3
+ Samples=576;
+ else
+ Samples=1152;
+ Fill(Stream_Audio, 0, Audio_FrameCount, FrameCount, 10, true);
+ Fill(Stream_Audio, 0, Audio_SamplingCount, FrameCount*Samples, 10, true);
+ }
+
+ File__Tags_Helper::Streams_Finish();
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Mpega::FileHeader_Begin()
+{
+ //Buffer size
+ if (Buffer_Size<8)
+ return File_Size<8; //Must wait for more data
+
+ //Detecting WAV/SWF/FLV/ELF/DPG/WM/MZ/DLG files
+ int32u Magic4=CC4(Buffer);
+ int32u Magic3=Magic4>>8;
+ int16u Magic2=Magic4>>16;
+ if (Magic4==0x52494646 || Magic3==0x465753 || Magic3==0x464C56 || Magic4==0x7F454C46 || Magic4==0x44504730 || Magic4==0x3026B275 || Magic2==0x4D5A || Magic4==0x000001BA || Magic4==0x000001B3 || Magic4==0x00000100 || CC8(Buffer+Buffer_Offset)==0x444C472056312E30LL)
+ {
+ File__Tags_Helper::Reject("MPEG Audio");
+ return false;
+ }
+
+ //Seems OK
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Mpega::Synchronize()
+{
+ //Tags
+ bool Tag_Found_Begin;
+ if (!File__Tags_Helper::Synchronize(Tag_Found_Begin))
+ return false;
+ if (Tag_Found_Begin)
+ return true;
+
+ //Synchronizing
+ while (Buffer_Offset+4<=Buffer_Size)
+ {
+ while (Buffer_Offset+4<=Buffer_Size)
+ {
+ if (Buffer[Buffer_Offset ]==0xFF
+ && (Buffer[Buffer_Offset+1]&0xE0)==0xE0
+ && (Buffer[Buffer_Offset+2]&0xF0)!=0xF0
+ && (Buffer[Buffer_Offset+2]&0x0C)!=0x0C)
+ break; //while()
+
+ //Tags
+ bool Tag_Found_Synchro;
+ if (!File__Tags_Helper::Synchronize(Tag_Found_Synchro))
+ return false;
+ if (Tag_Found_Synchro)
+ return true;
+
+ //Better detect MPEG-PS
+ if (Frame_Count==0
+ && Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x01
+ && Buffer[Buffer_Offset+3]==0xBA)
+ {
+ MpegPsPattern_Count++;
+ if (MpegPsPattern_Count>=2)
+ {
+ File__Tags_Helper::Reject("MPEG Audio");
+ return false;
+ }
+ }
+
+ Buffer_Offset++;
+ }
+
+ if (Buffer_Offset+4<=Buffer_Size)//Testing if size is coherant
+ {
+ //Retrieving some info
+ int8u ID0 =(CC1(Buffer+Buffer_Offset+1)>>3)&0x03;
+ int8u layer0 =(CC1(Buffer+Buffer_Offset+1)>>1)&0x03;
+ int8u bitrate_index0 =(CC1(Buffer+Buffer_Offset+2)>>4)&0x0F;
+ int8u sampling_frequency0=(CC1(Buffer+Buffer_Offset+2)>>2)&0x03;
+ int8u padding_bit0 =(CC1(Buffer+Buffer_Offset+2)>>1)&0x01;
+ //Coherancy
+ if (Mpega_SamplingRate[ID0][sampling_frequency0]==0 || Mpega_Coefficient[ID0][layer0]==0 || Mpega_BitRate[ID0][layer0][bitrate_index0]==0 || Mpega_SlotSize[layer0]==0)
+ Buffer_Offset++; //False start
+ else
+ {
+ //Testing next start, to be sure
+ size_t Size0=(Mpega_Coefficient[ID0][layer0]*Mpega_BitRate[ID0][layer0][bitrate_index0]*1000/Mpega_SamplingRate[ID0][sampling_frequency0]+(padding_bit0?1:0))*Mpega_SlotSize[layer0];
+ if (IsSub && Buffer_Offset+Size0==Buffer_Size)
+ break;
+ if (File_Offset+Buffer_Offset+Size0!=File_Size-File_EndTagSize)
+ {
+ if (Buffer_Offset+Size0+4>Buffer_Size)
+ return false; //Need more data
+
+ //Tags
+ bool Tag_Found0;
+ if (!File__Tags_Helper::Synchronize(Tag_Found0, Size0))
+ return false;
+ if (Tag_Found0)
+ return true;
+ if (File_Offset+Buffer_Offset+Size0==File_Size-File_EndTagSize)
+ break;
+
+ //Testing
+ if ((CC2(Buffer+Buffer_Offset+Size0)&0xFFE0)!=0xFFE0 || (CC1(Buffer+Buffer_Offset+Size0+2)&0xF0)==0xF0 || (CC1(Buffer+Buffer_Offset+Size0+2)&0x0C)==0x0C)
+ {
+ //Testing VBRI in a malformed frame
+ bool VbriFound=false;
+ for (size_t Pos=Buffer_Offset+3; Pos+4<Buffer_Offset+Size0; Pos++)
+ {
+ if (Buffer[Pos ]==0x56
+ && Buffer[Pos+1]==0x42
+ && Buffer[Pos+2]==0x52
+ && Buffer[Pos+3]==0x49)
+ {
+ VbriFound=true;
+ break;
+ }
+ if (Buffer[Pos])
+ break; //Only NULL bytes are authorized before VBRI header
+ }
+ if (VbriFound)
+ break;
+ Buffer_Offset++;
+ }
+ else
+ {
+ //Retrieving some info
+ int8u ID1 =(CC1(Buffer+Buffer_Offset+Size0+1)>>3)&0x03;
+ int8u layer1 =(CC1(Buffer+Buffer_Offset+Size0+1)>>1)&0x03;
+ int8u bitrate_index1 =(CC1(Buffer+Buffer_Offset+Size0+2)>>4)&0x0F;
+ int8u sampling_frequency1=(CC1(Buffer+Buffer_Offset+Size0+2)>>2)&0x03;
+ int8u padding_bit1 =(CC1(Buffer+Buffer_Offset+Size0+2)>>1)&0x01;
+ //Coherancy
+ if (Mpega_SamplingRate[ID1][sampling_frequency1]==0 || Mpega_Coefficient[ID1][layer1]==0 || Mpega_BitRate[ID1][layer1][bitrate_index1]==0 || Mpega_SlotSize[layer1]==0)
+ Buffer_Offset++; //False start
+ else
+ {
+ //Testing next start, to be sure
+ size_t Size1=(Mpega_Coefficient[ID1][layer1]*Mpega_BitRate[ID1][layer1][bitrate_index1]*1000/Mpega_SamplingRate[ID1][sampling_frequency1]+(padding_bit1?1:0))*Mpega_SlotSize[layer1];
+ if (IsSub && Buffer_Offset+Size0+Size1==Buffer_Size)
+ break;
+ if (File_Offset+Buffer_Offset+Size0+Size1!=File_Size-File_EndTagSize)
+ {
+ if (Buffer_Offset+Size0+Size1+4>Buffer_Size)
+ return false; //Need more data
+
+ //Tags
+ bool Tag_Found1;
+ if (!File__Tags_Helper::Synchronize(Tag_Found1, Size0+Size1))
+ return false;
+ if (Tag_Found1)
+ return true;
+ if (File_Offset+Buffer_Offset+Size0+Size1==File_Size-File_EndTagSize)
+ break;
+
+ //Testing
+ if ((CC2(Buffer+Buffer_Offset+Size0+Size1)&0xFFE0)!=0xFFE0 || (CC1(Buffer+Buffer_Offset+Size0+Size1+2)&0xF0)==0xF0 || (CC1(Buffer+Buffer_Offset+Size0+Size1+2)&0x0C)==0x0C)
+ Buffer_Offset++;
+ else
+ {
+ //Retrieving some info
+ int8u ID2 =(CC1(Buffer+Buffer_Offset+Size0+Size1+1)>>3)&0x03;
+ int8u layer2 =(CC1(Buffer+Buffer_Offset+Size0+Size1+1)>>1)&0x03;
+ int8u bitrate_index2 =(CC1(Buffer+Buffer_Offset+Size0+Size1+2)>>4)&0x0F;
+ int8u sampling_frequency2=(CC1(Buffer+Buffer_Offset+Size0+Size1+2)>>2)&0x03;
+ int8u padding_bit2 =(CC1(Buffer+Buffer_Offset+Size0+Size1+2)>>1)&0x01;
+ //Coherancy
+ if (Mpega_SamplingRate[ID2][sampling_frequency2]==0 || Mpega_Coefficient[ID2][layer2]==0 || Mpega_BitRate[ID2][layer2][bitrate_index2]==0 || Mpega_SlotSize[layer2]==0)
+ Buffer_Offset++; //False start
+ else
+ {
+ //Testing next start, to be sure
+ size_t Size2=(Mpega_Coefficient[ID2][layer2]*Mpega_BitRate[ID2][layer2][bitrate_index2]*1000/Mpega_SamplingRate[ID2][sampling_frequency2]+(padding_bit2?1:0))*Mpega_SlotSize[layer2];
+ if (IsSub && Buffer_Offset+Size0+Size1+Size2==Buffer_Size)
+ break;
+ if (File_Offset+Buffer_Offset+Size0+Size1+Size2!=File_Size-File_EndTagSize)
+ {
+ if (Buffer_Offset+Size0+Size1+Size2+4>Buffer_Size)
+ {
+ if (IsSub || File_Offset+Buffer_Offset+Size0+Size1+Size2<File_Size)
+ break;
+ return false; //Need more data
+ }
+
+ //Tags
+ bool Tag_Found2;
+ if (!File__Tags_Helper::Synchronize(Tag_Found2, Size0+Size1+Size2))
+ return false;
+ if (Tag_Found2)
+ return true;
+ if (File_Offset+Buffer_Offset+Size0+Size1+Size2==File_Size-File_EndTagSize)
+ break;
+
+ //Testing
+ if ((CC2(Buffer+Buffer_Offset+Size0+Size1+Size2)&0xFFE0)!=0xFFE0 || (CC1(Buffer+Buffer_Offset+Size0+Size1+Size2+2)&0xF0)==0xF0 || (CC1(Buffer+Buffer_Offset+Size0+Size1+Size2+2)&0x0C)==0x0C)
+ Buffer_Offset++;
+ else
+ break; //while()
+ }
+ else
+ break; //while()
+ }
+ }
+ }
+ else
+ break; //while()
+ }
+ }
+ }
+ else
+ break; //while()
+ }
+ }
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+4>Buffer_Size)
+ {
+ if (Buffer_Offset+3==Buffer_Size && (CC2(Buffer+Buffer_Offset)&0xFFE0)!=0xFFE0)
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && (CC2(Buffer+Buffer_Offset)&0xFFE0)!=0xFFE0)
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x00)
+ Buffer_Offset++;
+ return false;
+ }
+
+ //Synched is OK
+ if (!Status[IsAccepted])
+ File__Tags_Helper::Accept("MPEG Audio");
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Mpega::Synched_Test()
+{
+ //Tags
+ if (!File__Tags_Helper::Synched_Test())
+ return false;
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (Buffer[Buffer_Offset ]!=0xFF
+ || (Buffer[Buffer_Offset+1]&0xE0)!=0xE0
+ || (Buffer[Buffer_Offset+2]&0xF0)==0xF0
+ || (Buffer[Buffer_Offset+2]&0x0C)==0x0C)
+ {
+ Synched=false;
+ return true;
+ }
+
+ //Retrieving some info
+ int8u ID0 =(CC1(Buffer+Buffer_Offset+1)>>3)&0x03;
+ int8u layer0 =(CC1(Buffer+Buffer_Offset+1)>>1)&0x03;
+ int8u bitrate_index0 =(CC1(Buffer+Buffer_Offset+2)>>4)&0x0F;
+ int8u sampling_frequency0=(CC1(Buffer+Buffer_Offset+2)>>2)&0x03;
+ if (Mpega_SamplingRate[ID0][sampling_frequency0]==0 || Mpega_Coefficient[ID0][layer0]==0 || Mpega_BitRate[ID0][layer0][bitrate_index0]==0 || Mpega_SlotSize[layer0]==0)
+ {
+ Synched=false;
+ return true;
+ }
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Demux
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+bool File_Mpega::Demux_UnpacketizeContainer_Test()
+{
+ //Retrieving some info
+ int8u ID0 =(CC1(Buffer+Buffer_Offset+1)>>3)&0x03;
+ int8u layer0 =(CC1(Buffer+Buffer_Offset+1)>>1)&0x03;
+ int8u bitrate_index0 =(CC1(Buffer+Buffer_Offset+2)>>4)&0x0F;
+ int8u sampling_frequency0=(CC1(Buffer+Buffer_Offset+2)>>2)&0x03;
+ int8u padding_bit0 =(CC1(Buffer+Buffer_Offset+2)>>1)&0x01;
+ Demux_Offset=Buffer_Offset+(Mpega_Coefficient[ID0][layer0]*Mpega_BitRate[ID0][layer0][bitrate_index0]*1000/Mpega_SamplingRate[ID0][sampling_frequency0]+(padding_bit0?1:0))*Mpega_SlotSize[layer0];
+
+ if (Demux_Offset>Buffer_Size)
+ return false;
+
+ Demux_UnpacketizeContainer_Demux();
+
+ return true;
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpega::Header_Parse()
+{
+ //Parsing
+ BS_Begin();
+ Skip_S2(11, "syncword");
+ Get_S1 (2, ID, "ID"); Param_Info1(Mpega_Version[ID]);
+ Get_S1 (2, layer, "layer"); Param_Info1(Mpega_Layer[layer]);
+ Get_SB ( protection_bit, "protection_bit");
+ Get_S1 (4, bitrate_index, "bitrate_index"); Param_Info2(Mpega_BitRate[ID][layer][bitrate_index], " Kbps");
+ Get_S1 (2, sampling_frequency, "sampling_frequency"); Param_Info2(Mpega_SamplingRate[ID][sampling_frequency], " Hz");
+ Get_SB ( padding_bit, "padding_bit");
+ Skip_SB( "private_bit");
+ Get_S1 (2, mode, "mode"); Param_Info2(Mpega_Channels[mode], " channels"); Param_Info1(Mpega_Codec_Profile[mode]);
+ Get_S1 (2, mode_extension, "mode_extension"); Param_Info1(Mpega_Codec_Profile_Extension[mode_extension]);
+ Get_SB ( copyright, "copyright");
+ Get_SB ( original_home, "original_home");
+ Get_S1 (2, emphasis, "emphasis"); Param_Info1(Mpega_Emphasis[emphasis]);
+ BS_End();
+
+ //Coherancy
+ if (Mpega_SamplingRate[ID][sampling_frequency]==0 || Mpega_Coefficient[ID][layer]==0 || Mpega_BitRate[ID][layer][bitrate_index]==0 || Mpega_SlotSize[layer]==0)
+ {
+ Element_Offset=1;
+ Header_Fill_Size(1);
+ Header_Fill_Code(0, "False start");
+ Synched=false;
+ return;
+ }
+
+ //Filling
+ int64u Size=(Mpega_Coefficient[ID][layer]*Mpega_BitRate[ID][layer][bitrate_index]*1000/Mpega_SamplingRate[ID][sampling_frequency]+(padding_bit?1:0))*Mpega_SlotSize[layer];
+ Header_Fill_Size(Size);
+ Header_Fill_Code(0, "audio_data");
+
+ //Filling error detection
+ sampling_frequency_Count[sampling_frequency]++;
+ mode_Count[mode]++;
+
+ FILLING_BEGIN();
+ FILLING_END();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpega::Data_Parse()
+{
+ //If false start
+ if (Element_Size==0)
+ {
+ Element_DoNotShow();
+ return;
+ }
+
+ //Partial frame
+ if (Header_Size+Element_Size<(int64u)((Mpega_Coefficient[ID][layer]*Mpega_BitRate[ID][layer][bitrate_index]*1000/Mpega_SamplingRate[ID][sampling_frequency]+(padding_bit?1:0))*Mpega_SlotSize[layer]))
+ {
+ Element_Name("Partial frame");
+ Skip_XX(Element_Size, "Data");
+ return;
+ }
+
+ //PTS
+ Element_Info1C((FrameInfo.PTS!=(int64u)-1), _T("PTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/1000000)));
+
+ //Name
+ Element_Info1(_T("Frame ")+Ztring::ToZtring(Frame_Count));
+
+ //VBR and library headers
+ if (Frame_Count<3) //No need to do it too much
+ {
+ if (!Header_Xing())
+ Header_VBRI();
+ }
+
+ //Counting
+ if (File_Offset+Buffer_Offset+Element_Size==File_Size-File_EndTagSize)
+ Frame_Count_Valid=Frame_Count; //Finish MPEG Audio frames in case of there are less than Frame_Count_Valid frames
+ if (Frame_Count==0)
+ PTS_Begin=FrameInfo.PTS;
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ LastSync_Offset=File_Offset+Buffer_Offset+Element_Size;
+ {
+ int16u Samples;
+ if (ID==3 && layer==3) //MPEG 1 layer 1
+ Samples=384;
+ else if ((ID==2 || ID==0) && layer==1) //MPEG 2 or 2.5 layer 3
+ Samples=576;
+ else
+ Samples=1152;
+ FrameInfo.DUR=float64_int64s(((float64)1)/Mpega_SamplingRate[ID][sampling_frequency]*Samples*1000000000);
+ if (FrameInfo.DTS!=(int64u)-1)
+ FrameInfo.DTS+=FrameInfo.DUR;
+ if (FrameInfo.PTS!=(int64u)-1)
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+
+ //LAME
+ if (Encoded_Library.empty() && (Frame_Count<Frame_Count_Valid || File_Offset+Buffer_Offset+Element_Size==File_Size-File_EndTagSize)) //Can be elsewhere... At the start, or end frame
+ Header_Encoders();
+
+ //Filling
+ BitRate_Count[Mpega_BitRate[ID][layer][bitrate_index]]++;
+ Channels_Count[mode]++;
+ Extension_Count[mode_extension]++;
+ Emphasis_Count[emphasis]++;
+
+ if (Status[IsFilled])
+ {
+ Skip_XX(Element_Size, "Data");
+ return;
+ }
+
+ //Parsing
+ int16u main_data_end;
+ if (protection_bit)
+ Skip_B2( "crc_check");
+ BS_Begin();
+ if (ID==3) //MPEG-1
+ Get_S2 (9, main_data_end, "main_data_end");
+ else
+ Get_S2 (8, main_data_end, "main_data_end");
+ if ((int32u)main_data_end>Reservoir_Max)
+ Reservoir_Max=main_data_end;
+ Reservoir+=main_data_end;
+ if (ID==3) //MPEG-1
+ {
+ if (mode==3) //Mono
+ Skip_S1(5, "private_bits");
+ else
+ Skip_S1(3, "private_bits");
+ }
+ else
+ {
+ if (mode==3) //Mono
+ Skip_S1(1, "private_bits");
+ else
+ Skip_S1(2, "private_bits");
+ }
+ if (ID==3) //MPEG-1
+ {
+ Element_Begin1("scfsi");
+ for(int8u ch=0; ch<Mpega_Channels[mode]; ch++)
+ for(int8u scfsi_band=0; scfsi_band<4; scfsi_band++)
+ {
+ bool scfsi;
+ Get_SB ( scfsi, "scfsi");
+ if (scfsi)
+ Scfsi++;
+ }
+ Element_End0();
+ }
+ for(int8u gr=0; gr<(ID==3?2:1); gr++)
+ {
+ Element_Begin1("granule");
+ if (mode>=4)
+ return;
+ for(int8u ch=0; ch<Mpega_Channels[mode]; ch++)
+ {
+ Element_Begin1("channel");
+ Skip_S2(12, "part2_3_length");
+ Skip_S2(9, "big_values");
+ Skip_S1(8, "global_gain");
+ if (ID==3) //MPEG-1
+ Skip_S1(4, "scalefac_compress");
+ else
+ Skip_S2(9, "scalefac_compress");
+ bool blocksplit_flag;
+ Get_SB ( blocksplit_flag, "blocksplit_flag");
+ if (blocksplit_flag==1)
+ {
+ int8u block_type;
+ bool mixed_block_flag;
+ Get_S1 (2, block_type, "block_type");
+ Get_SB ( mixed_block_flag, "mixed_block_flag");
+ for (int8u region=0; region<2; region++)
+ Skip_S1(5, "table_select");
+ for (int8u window=0; window<3; window++)
+ Skip_S1(3, "subblock_gain");
+ if (block_type == 2)
+ {
+ if (mixed_block_flag==1)
+ {
+ Param_Info1("Mixed");
+ Block_Count[2]++; //Mixed
+ }
+ else
+ {
+ Param_Info1("Short");
+ Block_Count[1]++; //Short
+ }
+ }
+ else
+ {
+ Param_Info1("Long");
+ Block_Count[0]++; //Long
+ }
+ }
+ else
+ {
+ for (int8u region=0; region<3; region++)
+ Skip_S1(5, "table_select");
+ Skip_S1(4, "region0_count");
+ Skip_S1(3, "region1_count");
+ Param_Info1("Long");
+ Block_Count[0]++; //Long
+ }
+ if (ID==3) //MPEG-1
+ Skip_SB( "preflag");
+ bool scalefac;
+ Get_SB ( scalefac, "scalefac_scale");
+ if (scalefac)
+ Scalefac++;
+ Skip_SB( "count1table_select");
+ Element_End0();
+ } //channels
+ Element_End0();
+ } //granules
+ BS_End();
+
+ //MP3 Surround detection
+ for (int64u Element_Offset_S=Element_Offset; Element_Offset_S+4<Element_Size; Element_Offset_S++)
+ {
+ if ( Buffer[(size_t)(Buffer_Offset+Element_Offset_S )] ==0xCF
+ && (Buffer[(size_t)(Buffer_Offset+Element_Offset_S+1)]&0xF0)==0x30) //12 bits, 0xCF3x
+ {
+ int8u Surround_Size=((Buffer[(size_t)(Buffer_Offset+Element_Offset_S+1)]&0x0F)<<4)
+ | ((Buffer[(size_t)(Buffer_Offset+Element_Offset_S+2)]&0xF0)>>4);
+ int16u CRC12 =((Buffer[(size_t)(Buffer_Offset+Element_Offset_S+2)]&0x0F)<<8)
+ | Buffer[(size_t)(Buffer_Offset+Element_Offset_S+3)];
+ if (Element_Offset_S+Surround_Size-4>Element_Size)
+ break;
+
+ //CRC
+ int16u CRC12_Calculated=0x0FFF;
+ int8u* Data=(int8u*)Buffer+(size_t)(Buffer_Offset+Element_Offset_S+4);
+ if (Element_Offset_S+Surround_Size+4>=Element_Size)
+ break;
+ for (int8u Surround_Pos=0; Surround_Pos<Surround_Size-4; Surround_Pos++)
+ CRC12_Calculated=0x0FFF & (((CRC12_Calculated<<8)&0xff00)^Mpega_CRC12_Table[((CRC12_Calculated>>4) ^ *Data++) & 0xff]);
+ if (CRC12_Calculated!=CRC12)
+ break;
+
+ //Parsing
+ Skip_XX(Element_Offset_S-Element_Offset, "data");
+ BS_Begin();
+ Element_Begin1("Surround");
+ Skip_S2(12, "Sync");
+ Skip_S1( 8, "Size");
+ Skip_S2(12, "CRC12");
+ BS_End();
+ Skip_XX(Surround_Size-4, "data");
+ Element_End0();
+
+ //Filling
+ Surround_Frames++;
+ break;
+ }
+ }
+
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "data");
+
+ FILLING_BEGIN();
+ //Filling
+ if (IsSub && BitRate_Count.size()>1 && !Encoded_Library.empty())
+ Frame_Count_Valid=Frame_Count;
+ if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid)
+ {
+ Fill("MPEG Audio");
+
+ //Jumping
+ if (!IsSub && MediaInfoLib::Config.ParseSpeed_Get()<1.0)
+ {
+ File__Tags_Helper::GoToFromEnd(16*1024, "MPEG-A");
+ LastSync_Offset=(int64u)-1;
+ }
+ }
+
+ //Detect Id3v1 tags inside a frame
+ if (!IsSub && File_Offset+Buffer_Offset+(size_t)Element_Size>File_Size-File_EndTagSize)
+ {
+ Open_Buffer_Unsynch();
+ File__Analyze::Data_GoTo(File_Size-File_EndTagSize, "Tags inside a frame, parsing the tags");
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpega::Data_Parse_Fill()
+{
+}
+
+//---------------------------------------------------------------------------
+bool File_Mpega::Header_Xing()
+{
+ int32u Xing_Header_Offset;
+ if (ID==3) //MPEG-1
+ if (mode==3) //Mono
+ Xing_Header_Offset=21-4;
+ else
+ Xing_Header_Offset=36-4;
+ else //MPEG-2 or 2.5
+ if (mode==3) //Mono
+ Xing_Header_Offset=13-4;
+ else
+ Xing_Header_Offset=21-4;
+ if (Buffer_Offset+Xing_Header_Offset+128<Buffer_Size)
+ {
+ const int8u* Xing_Header=Buffer+Buffer_Offset+Xing_Header_Offset;
+ if (CC4(Xing_Header)==CC4("Xing") || CC4(Xing_Header)==CC4("Info"))
+ {
+ //This is a "tag"
+ Element_Info1("Tag (Xing)");
+
+ //Parsing
+ Element_Begin1("Xing");
+ Element_Begin1("Xing header");
+ Skip_XX(Xing_Header_Offset, "Junk");
+ int32u Flags;
+ bool FrameCount, FileSize, TOC, Scale, Lame;
+ Skip_C4( "Xing");
+ Get_B4 (Flags, "Flags");
+ Get_Flags(Flags, 0, FrameCount, "FrameCount");
+ Get_Flags(Flags, 1, FileSize, "FileSize");
+ Get_Flags(Flags, 2, TOC, "TOC");
+ Get_Flags(Flags, 3, Scale, "Scale");
+ Get_Flags(Flags, 4, Lame, "Lame");
+ int32u Xing_Header_Size=8
+ +(FrameCount? 4:0) //FrameCount
+ +(FileSize? 4:0) //FileSize
+ +(TOC? 100:0) //TOC
+ +(Scale? 4:0) //Scale
+ +(Lame? 348:0); //Lame
+ Element_End0();
+ //Element size
+ if (Xing_Header_Size>Element_Size-Xing_Header_Offset)
+ return false; //Error tag size
+
+ //Parsing
+ if (FrameCount)
+ Get_B4 (VBR_Frames, "FrameCount"); //FrameCount exclude this frame
+ if (FileSize)
+ {
+ int32u VBR_FileSize_Temp;
+ Get_B4 (VBR_FileSize_Temp, "FileSize");
+ if (VBR_FileSize_Temp>4+Element_Size)
+ VBR_FileSize=VBR_FileSize_Temp-4-Element_Size; //FileSize include the Xing element
+ }
+ if (TOC)
+ Skip_XX(100, "TOC");
+ if (Scale)
+ Get_B4 (Xing_Scale, "Scale");
+ Ztring Lib;
+ Element_End0();
+ Peek_Local(4, Lib);
+ if (Lame || Lib==_T("LAME") || Lib==_T("GOGO") || Lib==_T("L3.9"))
+ Header_Encoders_Lame();
+
+ if (CC4(Xing_Header)==CC4("Info"))
+ VBR_Frames=0; //This is not a VBR file
+
+ //Clearing Error detection
+ sampling_frequency_Count.clear();
+ mode_Count.clear();
+
+ return true;
+ }
+ }
+ return false;
+}
+
+//---------------------------------------------------------------------------
+bool File_Mpega::Header_VBRI()
+{
+ const size_t Fraunhofer_Header_Offset=36-4;
+ if (Buffer_Offset+Fraunhofer_Header_Offset+32<Buffer_Size)
+ {
+ const int8u* Fraunhofer_Header=Buffer+Buffer_Offset+Fraunhofer_Header_Offset;
+ if (CC4(Fraunhofer_Header)==CC4("VBRI") && CC2(Fraunhofer_Header+4)==0x0001) //VBRI v1 only
+ {
+ //This is a "tag"
+
+ Element_Info1("Tag (VBRI)");
+
+ //Parsing
+ int32u VBR_FileSize_Temp;
+ int16u TableSize, TableScale, EntryBytes;
+ Skip_XX(Fraunhofer_Header_Offset, "Junk");
+ Element_Begin1("VBRI");
+ Skip_C4( "Sync");
+ Skip_B2( "Version");
+ Skip_B2( "Delay");
+ Skip_B2( "Quality");
+ Get_B4 (VBR_FileSize_Temp, "StreamBytes");
+ Get_B4 (VBR_Frames, "StreamFrames"); //Multiplied by SamplesPerFrame (1152 for >=32KHz, else 576) --> Duration in samples
+ Get_B2 (TableSize, "TableSize");
+ Get_B2 (TableScale, "TableScale");
+ Get_B2 (EntryBytes, "EntryBytes");
+ Skip_B2( "EntryFrames"); //Count of frames per entry
+ Element_Begin1("Table");
+ for (int16u Pos=0; Pos<TableSize; Pos++)
+ {
+ switch (EntryBytes)
+ {
+ case 1 : {Info_B1(Entry, "Entry"); Param_Info2 (Entry*TableScale, " bytes");} break;
+ case 2 : {Info_B2(Entry, "Entry"); Param_Info2 (Entry*TableScale, " bytes");} break;
+ case 4 : {Info_B4(Entry, "Entry"); Param_Info2 (Entry*TableScale, " bytes");} break;
+ default: Skip_XX(EntryBytes, "Entry");
+ }
+ }
+ Element_End0();
+ Element_End0();
+ VBR_FileSize=VBR_FileSize_Temp;
+
+ //Clearing Error detection
+ sampling_frequency_Count.clear();
+ mode_Count.clear();
+
+ return true;
+ }
+ }
+ return false;
+}
+
+//---------------------------------------------------------------------------
+bool File_Mpega::Header_Encoders()
+{
+ std::string BufferS((const char*)(Buffer+Buffer_Offset), (size_t)Element_Size);
+ size_t Buffer_Pos;
+
+ //Lame
+ Buffer_Pos=BufferS.find("LAME");
+ if (Buffer_Pos!=std::string::npos && Buffer_Pos<=Element_Size-8)
+ {
+ Element_Info1("With tag (Lame)");
+ Element_Offset=Buffer_Pos;
+ if (Element_Offset+20<=Element_Size)
+ Get_Local(20, Encoded_Library, "Encoded_Library");
+ else
+ Get_Local( 8, Encoded_Library, "Encoded_Library");
+ Encoded_Library.Trim(_T('A'));
+ Encoded_Library.Trim(_T('U'));
+ Encoded_Library.Trim(_T('\xAA'));
+ Element_Offset=0; //Reseting it
+ return true;
+ }
+
+ //RCA
+ Buffer_Pos=BufferS.find("RCA mp3PRO Encoder");
+ if (Buffer_Pos!=std::string::npos && Buffer_Pos<Element_Size-23)
+ {
+ Element_Info1("With tag (RCA)");
+ Encoded_Library="RCA ";
+ Encoded_Library+=Ztring((const char*)(Buffer+Buffer_Offset+18), 5);
+ return true;
+ }
+
+ //Thomson
+ Buffer_Pos=BufferS.find("THOMSON mp3PRO Encoder");
+ if (Buffer_Pos!=std::string::npos && Buffer_Pos<Element_Size-29)
+ {
+ Element_Info1("With tag (Thomson)");
+ Encoded_Library="Thomson ";
+ Encoded_Library+=Ztring((const char*)(Buffer+Buffer_Offset+22), 6);
+ return true;
+ }
+
+ //Gogo (old)
+ Buffer_Pos=BufferS.find("MPGE");
+ if (Buffer_Pos!=std::string::npos)
+ {
+ Element_Info1("With tag (Gogo)");
+ Encoded_Library="Gogo <3.0";
+ return true;
+ }
+
+ //Gogo (new)
+ Buffer_Pos=BufferS.find("GOGO");
+ if (Buffer_Pos!=std::string::npos)
+ {
+ Element_Info1("With tag (Gogo)");
+ Encoded_Library="Gogo >=3.0";
+ return true;
+ }
+
+ return false;
+}
+
+void File_Mpega::Header_Encoders_Lame()
+{
+ Peek_Local(8, Encoded_Library);
+ if (Encoded_Library.find(_T("L3.99"))==0)
+ Encoded_Library.insert(1, _T("AME")); //Ugly version string in Lame 3.99.1 "L3.99r1\0"
+ if ((Encoded_Library>=_T("LAME3.90")) && Element_IsNotFinished())
+ {
+ int8u Flags, lowpass, EncodingFlags, BitRate, StereoMode;
+ Param_Info1(Ztring(_T("V "))+Ztring::ToZtring((100-Xing_Scale)/10));
+ Param_Info1(Ztring(_T("q "))+Ztring::ToZtring((100-Xing_Scale)%10));
+ Get_Local(9, Encoded_Library, "Encoded_Library");
+ Get_B1 (Flags, "Flags");
+ if ((Flags&0xF0)<=0x20) //Rev. 0 or 1, http://gabriel.mp3-tech.org/mp3infotag.html and Rev. 2 was seen.
+ {
+ Param_Info1(Lame_Method[Flags&0x0F]);
+ BitRate_Mode=Lame_BitRate_Mode[Flags&0x0F];
+ if ((Flags&0x0F)==1 || (Flags&0x0F)==8) //2 possible values for CBR
+ VBR_Frames=0;
+ }
+ Get_B1 (lowpass, "Lowpass filter value"); Param_Info2(lowpass*100, " Hz");
+ Skip_B4( "Peak signal amplitude");
+ Skip_B2( "Radio Replay Gain");
+ Skip_B2( "Audiophile Replay Gain");
+ Get_B1 (EncodingFlags, "Encoding Flags"); Param_Info1(Ztring(_T("ATH Type="))+Ztring::ToZtring(Flags&0x0F));
+ Skip_Flags(EncodingFlags, 4, "nspsytune");
+ Skip_Flags(EncodingFlags, 5, "nssafejoint");
+ Skip_Flags(EncodingFlags, 6, "nogap (after)");
+ Skip_Flags(EncodingFlags, 7, "nogap (before)");
+ Get_B1 (BitRate, "BitRate");
+ Skip_B3( "Encoder delays");
+ BS_Begin();
+ Skip_S1(2, "Source sample frequency");
+ Skip_SB( "unwise settings used");
+ Get_S1 (3, StereoMode, "Stereo mode");
+ Skip_S1(2, "noise shapings");
+ BS_End();
+ Skip_B1( "MP3 Gain");
+ Skip_B2( "Preset and surround info");
+ Skip_B4( "MusicLength");
+ Skip_B2( "MusicCRC");
+ Skip_B2( "CRC-16 of Info Tag");
+
+ FILLING_BEGIN();
+ Encoded_Library_Settings+=_T("-m ");
+ switch(StereoMode)
+ {
+ case 0 : Encoded_Library_Settings+=_T("m"); break;
+ case 1 : Encoded_Library_Settings+=_T("s"); break;
+ case 2 : Encoded_Library_Settings+=_T("d"); break;
+ case 3 : Encoded_Library_Settings+=_T("j"); break;
+ case 4 : Encoded_Library_Settings+=_T("f"); break;
+ case 5 : Encoded_Library_Settings+=_T("a"); break;
+ case 6 : Encoded_Library_Settings+=_T("i"); break;
+ default: ;
+ }
+ if (Xing_Scale<=100) //Xing_Scale is used for LAME quality
+ {
+ Encoded_Library_Settings+=_T( " -V ")+Ztring::ToZtring((100-Xing_Scale)/10);
+ Encoded_Library_Settings+=_T( " -q ")+Ztring::ToZtring((100-Xing_Scale)%10);
+ }
+ if (lowpass)
+ Encoded_Library_Settings+=(Encoded_Library_Settings.empty()?_T("-lowpass "):_T(" -lowpass "))+((lowpass%10)?Ztring::ToZtring(((float)lowpass)/10, 1):Ztring::ToZtring(lowpass/10));
+ switch (Flags&0x0F)
+ {
+ case 2 :
+ case 9 : //ABR
+ Encoded_Library_Settings+=_T(" --abr"); break;
+ case 3 : //VBR (old/rh)
+ Encoded_Library_Settings+=_T(" --vbr-old"); break;
+ case 4 : //VBR (new/mtrh)
+ Encoded_Library_Settings+=_T(" --vbr-new"); break;
+ case 5 : //VBR (?/mt)
+ Encoded_Library_Settings+=_T(" --vbr-mt"); break;
+ default : ;
+ }
+ if (BitRate!=0x00 && BitRate!=0xFF)
+ {
+ switch (Flags&0x0F)
+ {
+ case 1 :
+ case 8 : //CBR
+ Encoded_Library_Settings+=_T(" -b ")+Ztring::ToZtring(BitRate);
+ break;
+ case 2 :
+ case 9 : //ABR
+ BitRate_Nominal.From_Number(BitRate*1000);
+ Encoded_Library_Settings+=_T(" ")+Ztring::ToZtring(BitRate);
+ break;
+ case 3 : //VBR (old/rh)
+ case 4 : //VBR (new/mtrh)
+ case 5 : //VBR (?/mt)
+ BitRate_Minimum.From_Number(BitRate*1000);
+ Encoded_Library_Settings+=_T(" -b ")+Ztring::ToZtring(BitRate);
+ break;
+ default : ;
+ }
+ }
+ FILLING_END();
+ }
+ else
+ Get_Local(20, Encoded_Library, "Encoded_Library");
+}
+
+void File_Mpega::Encoded_Library_Guess()
+{
+ //TODO: Not yet enough precise
+
+ /*
+ if (Block_Count[1]==0) //No short blocks
+ {
+ if (mode==2) //Dual Mono
+ {
+ if (Scfsi>0) //scfsi used
+ {}
+ else //no scfsi
+ {
+ if (Scalefac>0) //scalefacors used
+ {}
+ else //scalefacors not used
+ Encoded_Library="Shine";
+ }
+ }
+ else //Other than dual mono
+ {
+ if (Extension_Count[1]>0 || Extension_Count[3]>0) //Intensity Stereo
+ Encoded_Library="Xing (very old)";
+ else //No Intensity Stereo
+ {
+ if (Scfsi>0) //Scfsi used
+ Encoded_Library="Xing (new)";
+ else //Scsfi not used
+ {
+ if (Channels_Count[2]>0) //Joint Stereo
+ {
+ if (Channels_Count[0]>0) //also includes no Joint Stereo frames
+ {
+ if (padding_bit) //Padding
+ {
+ if (original_home)
+ Encoded_Library="FhG (l3enc)";
+ else
+ Encoded_Library="FhG (fastenc or mp3enc)";
+ }
+ else //No padding
+ Encoded_Library="FhG (ACM or producer pro)";
+ }
+ else //No stereo frames: joint stereo was forced
+ {
+ if (padding_bit && !original_home && !copyright)
+ Encoded_Library="QDesign (fast mode)";
+ }
+ }
+ else
+ {
+ if (Channels_Count[0]>0 && Scalefac==0 && !original_home) //Stereo
+ Encoded_Library="Plugger";
+ else
+ Encoded_Library="Xing (old)";
+ }
+ }
+ }
+ }
+ }
+ else //Short blocks
+ {
+ if (Scfsi) //scfsi used
+ {
+ if (Scalefac>0) //Scalefactor used
+ Encoded_Library="Gogo (after 3.0)"; //Could be lame, but with a label, detected elsewhere before
+ else
+ Encoded_Library="Lame (old) or m3e";
+ }
+ else //Scfsi not used
+ {
+ if (Scalefac>0) //Scalefactor used
+ {
+ if (padding_bit)
+ {
+ if (original_home)
+ {
+ //10 last bytes
+ //int sum = get_final_sum(data);
+ //if (sum==0)
+ // return guess = _T("FhG (fastenc, low quality mode)");
+ //else if (sum==10 * 0xFF)
+ // return guess = _T("FhG (l3enc)");
+ //else if (sum==5 * 0x20)
+ // return guess = _T("FhG (fastenc, medium or high quality mode)");
+ //else
+ // return guess = _T("FhG (l3enc or fastenc)");
+ }
+ else
+ {
+ if (Channels_Count[1]>0 && Extension_Count[1]>0) //Joint Stereo and some Intensity Stereo
+ Encoded_Library="Thomson mp3PRO Encoder";
+ else
+ Encoded_Library="FhG (fastenc or mp3enc)";
+ }
+ }
+ else //No padding
+ {
+ if (BitRate_Mode.find(_T("VBR"))==0) //VBR
+ Encoded_Library="FhG (fastenc)";
+ else
+ Encoded_Library="FhG (ACM or producer pro)";
+ }
+ }
+ else //scalefactors not used
+ {
+ if (Channels_Count[1]>0) //Joint Stereo
+ {
+ if (padding_bit && !original_home && !copyright)
+ Encoded_Library="QDesign";
+ }
+ else //Joint Stereo not used
+ {
+ if (BitRate_Mode.find(_T("VBR"))==0) //VBR
+ Encoded_Library="Lame (old)";
+ else //CBR
+ {
+
+ if (mode==2) //Dual Mono
+ {
+ if (padding_bit)
+ Encoded_Library="Blade";
+ else
+ Encoded_Library="dist10 encoder or other encoder";
+ }
+ else //Stereo or Mono
+ {
+ //if (data.av_reservoir < 40 && !data.vbr) //ISO based encoders are unable to properly use bit reservoir... average reservoir usage is about 10
+ //{
+ // if (data.padding)
+ // return guess = _T("Blade");
+ // else
+ // return guess = _T("dist10 encoder or other encoder");
+ //}
+ //else
+ // return guess = _T("Gogo (before 3.0)");
+ }
+ }
+ }
+ }
+ }
+ }
+ */
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPEGA_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpega.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpega.h
new file mode 100644
index 000000000..45140d289
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Mpega.h
@@ -0,0 +1,118 @@
+// File_Mpega - Info for MPEG Audio files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_MpegaH
+#define MediaInfo_File_MpegaH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Tag/File__Tags.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Mpega
+//***************************************************************************
+
+class File_Mpega : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ bool FrameIsAlwaysComplete;
+ bool CalculateDelay;
+
+ //Constructor/Destructor
+ File_Mpega();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+
+ //Buffer - Demux
+ bool Demux_UnpacketizeContainer_Test();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+ void Data_Parse_Fill();
+
+ //Element
+ bool Header_Xing();
+ bool Header_VBRI();
+ bool Header_Encoders();
+ void Header_Encoders_Lame();
+ void Encoded_Library_Guess();
+
+ //Temp
+ Ztring BitRate_Mode;
+ Ztring BitRate_Nominal;
+ Ztring BitRate_Minimum;
+ Ztring Encoded_Library;
+ Ztring Encoded_Library_Settings;
+ std::map<int16u, size_t> BitRate_Count;
+ std::map<int8u, size_t> sampling_frequency_Count;
+ std::map<int8u, size_t> mode_Count;
+ size_t Surround_Frames;
+ size_t Block_Count[3]; //long, short, mixed
+ size_t Channels_Count[4]; //Stereo, Join Stereo, Dual mono, mono
+ size_t Extension_Count[4]; //No, IS, MS, IS+MS
+ size_t Emphasis_Count[4]; //No, 50/15ms, Reserved, CCITT
+ size_t Scfsi; //Total
+ size_t Scalefac; //Total
+ size_t Reservoir; //Total
+ int64u LastSync_Offset;
+ int64u VBR_FileSize;
+ int32u VBR_Frames;
+ int32u Reservoir_Max;
+ int32u Xing_Scale;
+ int32u BitRate; //Average
+ int8u ID;
+ int8u layer;
+ int8u bitrate_index;
+ int8u sampling_frequency;
+ int8u mode;
+ int8u mode_extension;
+ int8u emphasis;
+ bool protection_bit;
+ bool padding_bit;
+ bool copyright;
+ bool original_home;
+ size_t MpegPsPattern_Count;
+
+ //Helpers
+ bool Element_Name_IsOK();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Pcm.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Pcm.cpp
new file mode 100644
index 000000000..28aaed436
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Pcm.cpp
@@ -0,0 +1,488 @@
+// File_Pcm - Info for PCM files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_PCM_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Pcm.h"
+#if MEDIAINFO_DEMUX
+ #include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#endif //MEDIAINFO_DEMUX
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+int32u Pcm_VOB_BitDepth[]=
+{
+ 16,
+ 20,
+ 24,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+int32u Pcm_VOB_Frequency[]=
+{
+ 48000,
+ 32000,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+const char* Pcm_VOB_ChannelsPositions(int8u channel_assignment)
+{
+ switch (channel_assignment)
+ {
+ case 1 : return "Front: C"; //1 channel
+ case 3 : return "Front: L R"; //2 channels
+ case 4 : return "Front: L C R"; //3 channels
+ case 5 : return "Front: L R, LFE"; //3 channels
+ case 6 : return "Front: L C R, LFE"; //4 channels
+ case 7 : return "Front: L R, Side: L R"; //4 channels
+ case 8 : return "Front: L C R, Side: L R"; //5 channels
+ case 9 : return "Front: L C R, Side: L R, LFE"; //6 channels
+ case 10 : return "Front: L C R, Side: L R, Back: L R"; //7 channels
+ case 11 : return "Front: L C R, Side: L R, Back: L R, LFE"; //8 channels
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Pcm_VOB_ChannelsPositions2(int8u channel_assignment)
+{
+ switch (channel_assignment)
+ {
+ case 1 : return "1/0/0.0"; //1 channel
+ case 3 : return "2/0/0.0"; //2 channels
+ case 4 : return "3/0/0.0"; //3 channels
+ case 5 : return "2/0/0.1"; //3 channels
+ case 6 : return "3/0/0.1"; //4 channels
+ case 7 : return "2/2/0.0"; //4 channels
+ case 8 : return "3/2/0.0"; //5 channels
+ case 9 : return "3/2/0.1"; //6 channels
+ case 10 : return "3/2/2.0"; //7 channels
+ case 11 : return "3/2/2.1"; //8 channels
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+int8u Pcm_M2TS_channel_assignment[16]=
+{
+ 0,
+ 1,
+ 0,
+ 2,
+ 3,
+ 3,
+ 4,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+int32u Pcm_M2TS_sampling_frequency[16]=
+{
+ 0,
+ 48000,
+ 0,
+ 0,
+ 96000,
+ 192000,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+int8u Pcm_M2TS_bits_per_sample[4]=
+{
+ 0,
+ 16,
+ 20,
+ 24,
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Pcm::File_Pcm()
+{
+ //Configuration
+ ParserName=_T("PCM");
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(8); //Stream
+ #endif //MEDIAINFO_TRACE
+ IsRawStream=true;
+ PTS_DTS_Needed=true;
+
+ //In
+ BitDepth=0;
+ Channels=0;
+ IsRawPcm=true;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Pcm::Streams_Fill()
+{
+ if (Count_Get(Stream_Audio)==0)
+ {
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ Fill(Stream_Audio, 0, Audio_Codec, "PCM");
+ }
+
+ //Filling
+ Ztring Firm, Endianness, Sign, ITU, Resolution;
+ if (Codec==_T("EVOB")) {Firm=_T(""); Endianness=_T("Big"); Sign=_T("Signed");} //PCM Signed 16 bits Big Endian, Interleavement is for 2 samples*2 channels L0-1/L0-0/R0-1/R0-0/L1-1/L1-0/R1-1/R1-0/L0-2/R0-2/L1-2/R1-2, http://wiki.multimedia.cx/index.php?title=PCM
+ else if (Codec==_T("VOB")) {Firm=_T(""); Endianness=_T("Big"); Sign=_T("Signed");} //PCM Signed 16 bits Big Endian, Interleavement is for 2 samples*2 channels L0-1/L0-0/R0-1/R0-0/L1-1/L1-0/R1-1/R1-0/L0-2/R0-2/L1-2/R1-2, http://wiki.multimedia.cx/index.php?title=PCM
+ else if (Codec==_T("M2TS")) {Firm=_T(""); Endianness=_T("Big"); Sign=_T("Signed");} //PCM Signed Big Endian
+ else if (Codec==_T("A_PCM/INT/BIG")) {Firm=_T(""); Endianness=_T("Big");}
+ else if (Codec==_T("A_PCM/INT/LITTLE")) {Firm=_T(""); Endianness=_T("Little");}
+ else if (Codec==_T("A_PCM/INT/FLOAT")) {Firm=_T(""); Endianness=_T("Big"); Sign=_T("Float");}
+ else if (Codec==_T("fl32")) { Endianness=_T("Big"); Sign=_T("Float"); Resolution=_T("32");}
+ else if (Codec==_T("fl64")) { Endianness=_T("Big"); Sign=_T("Float"); Resolution=_T("64");}
+ else if (Codec==_T("in24")) { Endianness=_T("Big"); Sign=_T("Unsigned"); Resolution=_T("24");}
+ else if (Codec==_T("in32")) { Endianness=_T("Big"); Sign=_T("Unsigned"); Resolution=_T("32");}
+ else if (Codec==_T("lpcm")) { Endianness=_T("Big"); Sign=_T("Unsigned");}
+ else if (Codec==_T("raw ")) { Endianness=_T("Little"); Sign=_T("Unsigned");}
+ else if (Codec==_T("twos")) { Endianness=_T("Big"); Sign=_T("Signed");}
+ else if (Codec==_T("sowt")) { Endianness=_T("Little"); Sign=_T("Signed");}
+ else if (Codec==_T("SWF ADPCM")) {Firm=_T("SWF");}
+ else if (Codec==_T("1")) { if (BitDepth)
+ {
+ if (BitDepth>8)
+ { Endianness=_T("Little"); Sign=_T("Signed");}
+ else
+ { Sign=_T("Unsigned");}
+ }
+ }
+ else if (Codec==_T("2")) {Firm=_T("Microsoft");}
+ else if (Codec==_T("3")) { Endianness=_T("Float");}
+ else if (Codec==_T("10")) {Firm=_T("OKI");}
+ else if (Codec==_T("11")) {Firm=_T("Intel");}
+ else if (Codec==_T("12")) {Firm=_T("Mediaspace");}
+ else if (Codec==_T("13")) {Firm=_T("Sierra");}
+ else if (Codec==_T("14")) {Firm=_T("Antex");}
+ else if (Codec==_T("17")) {Firm=_T("Dialogic");}
+ else if (Codec==_T("18")) {Firm=_T("Mediavision");}
+ else if (Codec==_T("20")) {Firm=_T("Yamaha");}
+ else if (Codec==_T("33")) {Firm=_T("Antex");}
+ else if (Codec==_T("36")) {Firm=_T("DSP Solution");}
+ else if (Codec==_T("38")) {Firm=_T("Natural MicroSystems");}
+ else if (Codec==_T("39")) {Firm=_T("Crystal Semiconductor");}
+ else if (Codec==_T("3B")) {Firm=_T("Rockwell");}
+ else if (Codec==_T("40")) {Firm=_T("Antex Electronics");}
+ else if (Codec==_T("42")) {Firm=_T("IBM");}
+ else if (Codec==_T("45")) {Firm=_T("Microsoft"); ITU=_T("G.726");}
+ else if (Codec==_T("64")) {Firm=_T("Apicom"); ITU=_T("G.726");}
+ else if (Codec==_T("65")) {Firm=_T("Apicom"); ITU=_T("G.722");}
+ else if (Codec==_T("85")) {Firm=_T("DataFusion Systems"); ITU=_T("G.726");}
+ else if (Codec==_T("8B")) {Firm=_T("Infocom"); ITU=_T("G.721");}
+ else if (Codec==_T("97")) {Firm=_T("ZyXEL");}
+ else if (Codec==_T("100")) {Firm=_T("Rhetorex");}
+ else if (Codec==_T("125")) {Firm=_T("Sanyo");}
+ else if (Codec==_T("140")) {Firm=_T("Dictaphone"); ITU=_T("G.726");}
+ else if (Codec==_T("170")) {Firm=_T("Unisys");}
+ else if (Codec==_T("175")) {Firm=_T("SyCom"); ITU=_T("G.726");}
+ else if (Codec==_T("178")) {Firm=_T("Knownledge");}
+ else if (Codec==_T("200")) {Firm=_T("Creative");}
+ else if (Codec==_T("210")) {Firm=_T("Uher");}
+ else if (Codec==_T("285")) {Firm=_T("Norcom Voice Systems");}
+ else if (Codec==_T("1001")) {Firm=_T("Olivetti");}
+ else if (Codec==_T("1C03")) {Firm=_T("Lucent"); ITU=_T("G.723");}
+ else if (Codec==_T("1C0C")) {Firm=_T("Lucent"); ITU=_T("G.723");}
+ else if (Codec==_T("4243")) {ITU=_T("G.726");}
+ else if (Codec==_T("A105")) {ITU=_T("G.726");}
+ else if (Codec==_T("A107")) {ITU=_T("G.726");}
+
+ Fill(Stream_Audio, 0, Audio_Codec_String, "PCM");
+ Fill(Stream_Audio, 0, Audio_Codec_Family, "PCM");
+ if (!Firm.empty())
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Settings, Firm);
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Firm, Firm);
+ Fill(Stream_Audio, 0, Audio_Codec_Settings, Firm);
+ Fill(Stream_Audio, 0, Audio_Codec_Settings_Firm, Firm);
+ }
+ if (!Endianness.empty())
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Settings, Endianness);
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, Endianness);
+ Fill(Stream_Audio, 0, Audio_Codec_Settings, Endianness);
+ Fill(Stream_Audio, 0, Audio_Codec_Settings_Endianness, Endianness);
+ }
+ if (!Sign.empty())
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Settings, Sign);
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Sign, Sign);
+ Fill(Stream_Audio, 0, Audio_Codec_Settings, Sign);
+ Fill(Stream_Audio, 0, Audio_Codec_Settings_Sign, Sign);
+ }
+ if (!ITU.empty())
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Settings, ITU);
+ Fill(Stream_Audio, 0, Audio_Format_Settings_ITU, ITU);
+ Fill(Stream_Audio, 0, Audio_Codec_Settings, ITU);
+ Fill(Stream_Audio, 0, Audio_Codec_Settings_ITU, ITU);
+ }
+ if (!Resolution.empty())
+ Fill(Stream_Audio, 0, Audio_BitDepth, Resolution);
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR", Unlimited, true, true);
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Pcm::Read_Buffer_Continue()
+{
+ if (!Status[IsAccepted] && IsRawPcm) //No need of data
+ {
+ Accept();
+ Finish();
+ }
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Pcm::Header_Parse()
+{
+ //Filling
+ Header_Fill_Code(0, "Block");
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer && IsRawPcm && BitDepth && Channels)
+ Header_Fill_Size((Element_Size/(BitDepth*Channels/8))*(BitDepth*Channels/8)); //A complete sample
+ else
+ #endif //MEDIAINFO_DEMUX
+ Header_Fill_Size(Element_Size);
+}
+
+//---------------------------------------------------------------------------
+void File_Pcm::Data_Parse()
+{
+ Accept();
+
+ //Parsing
+ if (Codec==_T("VOB") || Codec==_T("EVOB"))
+ VOB();
+ else if (Codec==_T("M2TS"))
+ M2TS();
+ else
+ {
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer && Demux_TotalBytes<=Buffer_TotalBytes+Buffer_Offset)
+ {
+ Demux_Offset=(size_t)Element_Size;
+ Demux_UnpacketizeContainer_Demux();
+ }
+ #endif //MEDIAINFO_DEMUX
+ Skip_XX(Element_Size, "Data"); //It is impossible to detect... Default is no detection, only filling
+
+ Accept();
+ }
+
+ Finish();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Pcm::VOB()
+{
+ //Parsing
+ int8u BitDepth, Frequency, NumberOfChannelsMinusOne;
+ Skip_B1( "Frame number");
+ Skip_B2( "Bytes to skip (+1?)");
+ Skip_B1( "Unknown");
+ BS_Begin();
+ Get_S1 (2, BitDepth, "Bit depth"); Param_Info1(Pcm_VOB_BitDepth[BitDepth]);
+ Get_S1 (2, Frequency, "Frequency"); Param_Info1(Pcm_VOB_Frequency[Frequency]);
+ Skip_SB( "Unknown");
+ Get_S1 (3, NumberOfChannelsMinusOne, "Number of channels (minus 1)");
+ BS_End();
+ Skip_B1( "Start code");
+
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_PCM_20bitTo16bit_Get() && BitDepth==1) //20-bit
+ {
+ int8u* Info=new int8u[(size_t)((Element_Size-6)*4/5)];
+ size_t Info_Offset=0;
+
+ while (Element_Offset+5*(NumberOfChannelsMinusOne+1)<=Element_Size)
+ {
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+
+ std::memcpy(Info+Info_Offset, Buffer+Buffer_Pos, 4*(NumberOfChannelsMinusOne+1));
+
+ Info_Offset+=4*(NumberOfChannelsMinusOne+1);
+ Element_Offset+=5*(NumberOfChannelsMinusOne+1);
+ }
+ Element_Offset=6;
+
+ FrameInfo.PTS=FrameInfo.DTS;
+ if (Pcm_VOB_Frequency[Frequency])
+ FrameInfo.DUR=(Element_Size-6)/5*1000000000/Pcm_VOB_Frequency[Frequency];
+ Demux_random_access=true;
+ Element_Code=(int64u)-1;
+ Demux(Info, Info_Offset, ContentType_MainStream);
+
+ delete[] Info;
+
+ Skip_XX(Element_Size-6, "Data");
+ }
+ else
+ {
+ Demux_Offset=Buffer_Offset+(size_t)Element_Size;
+ Buffer_Offset+=6; //Header is dropped
+ Demux_UnpacketizeContainer_Demux();
+ Buffer_Offset-=6;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ Skip_XX(Element_Size-6, "Data");
+
+ FILLING_BEGIN();
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ if (FrameInfo.DTS!=(int64u)-1 && FrameInfo.DUR!=(int64u)-1)
+ {
+ FrameInfo.DTS+=FrameInfo.DUR;
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+ if (Count_Get(Stream_Audio)==0)
+ {
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ Fill(Stream_Audio, 0, Audio_Codec, "PCM");
+ Fill(Stream_Audio, 0, Audio_BitDepth, Pcm_VOB_BitDepth[BitDepth]);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, Pcm_VOB_Frequency[Frequency]);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, NumberOfChannelsMinusOne+1);
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, Pcm_VOB_ChannelsPositions(NumberOfChannelsMinusOne+1));
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, Pcm_VOB_ChannelsPositions2(NumberOfChannelsMinusOne+1));
+ Fill(Stream_Audio, 0, Audio_BitRate, Pcm_VOB_Frequency[Frequency]*(NumberOfChannelsMinusOne+1)*16);
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR", Unlimited, true, true);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Pcm::M2TS()
+{
+ //Parsing
+ int16u audio_data_payload_size;
+ int8u channel_assignment, sampling_frequency, bits_per_sample;
+ Get_B2 ( audio_data_payload_size, "audio_data_payload_size");
+ BS_Begin();
+ Get_S1 (4, channel_assignment, "channel_assignment"); Param_Info2(Pcm_M2TS_channel_assignment[channel_assignment], " channel(s)");
+ Get_S1 (4, sampling_frequency, "sampling_frequency"); Param_Info2(Pcm_M2TS_sampling_frequency[sampling_frequency], " Hz");
+ Get_S1 (2, bits_per_sample, "bits_per_sample"); Param_Info2(Pcm_M2TS_bits_per_sample[bits_per_sample], " bits");
+ Skip_SB( "start_flag");
+ Skip_S1(5, "reserved");
+ BS_End();
+ Skip_XX(audio_data_payload_size, "audio_data_payload");
+
+ FILLING_BEGIN_PRECISE();
+ Accept("PCM");
+
+ if (Count_Get(Stream_Audio)==0)
+ {
+ int8u Channels=Pcm_M2TS_channel_assignment[channel_assignment];
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ Fill(Stream_Audio, 0, Audio_Codec, "PCM");
+ Fill(Stream_Audio, 0, Audio_MuxingMode, "Blu-ray");
+ if (Channels)
+ {
+ if (Pcm_M2TS_sampling_frequency[sampling_frequency])
+ Fill(Stream_Audio, 0, Audio_SamplingRate, Pcm_M2TS_sampling_frequency[sampling_frequency]);
+ if (Pcm_M2TS_bits_per_sample[bits_per_sample])
+ Fill(Stream_Audio, 0, Audio_BitDepth, Pcm_M2TS_bits_per_sample[bits_per_sample]);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Channels);
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, Pcm_VOB_ChannelsPositions(channel_assignment));
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, Pcm_VOB_ChannelsPositions2(channel_assignment));
+ if (Pcm_M2TS_sampling_frequency[sampling_frequency] && Pcm_M2TS_bits_per_sample[bits_per_sample])
+ {
+ if (Channels%2)
+ Fill(Stream_Audio, 0, Audio_BitRate_Encoded, Pcm_M2TS_sampling_frequency[sampling_frequency]*(Channels+1)*Pcm_M2TS_bits_per_sample[bits_per_sample]); //Always by pair
+ Fill(Stream_Audio, 0, Audio_BitRate, Pcm_M2TS_sampling_frequency[sampling_frequency]*Channels*Pcm_M2TS_bits_per_sample[bits_per_sample]);
+ }
+ }
+ }
+
+ Finish("PCM");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_PCM_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Pcm.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Pcm.h
new file mode 100644
index 000000000..6b500716f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Pcm.h
@@ -0,0 +1,70 @@
+// File_Pcm - Info for PCM files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about PCM files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_PcmH
+#define MediaInfo_File_PcmH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Pcm
+//***************************************************************************
+
+class File_Pcm : public File__Analyze
+{
+public :
+ //In
+ ZenLib::Ztring Codec;
+ int16u BitDepth;
+ int16u Channels;
+ bool IsRawPcm;
+
+ //Constructor/Destructor
+ File_Pcm();
+
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void VOB();
+ void M2TS();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ps2Audio.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ps2Audio.cpp
new file mode 100644
index 000000000..7c50849ec
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ps2Audio.cpp
@@ -0,0 +1,135 @@
+// File_Ps2Audio - Info for PS2 Audio in MPEG files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_PS2A_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Ps2Audio.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ps2Audio::Read_Buffer_Continue()
+{
+ //Parsing
+ while (Element_Offset<Element_Size)
+ {
+ int32u ID;
+ Peek_B4(ID);
+ switch (ID)
+ {
+ case 0x53536264 : SSbd(); break;
+ case 0x53536864 : SShd(); break;
+ default : Element_Offset=Element_Size; Reject("PS2 Audio");
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Ps2Audio::SSbd()
+{
+ if (Count_Get(Stream_Audio)!=1)
+ {
+ Trusted_IsNot("Element should not be here");
+ return;
+ }
+
+ Element_Begin1("SSbd (Body)");
+ int32u Size;
+ Skip_C4( "ID");
+ Get_L4 (Size, "Size");
+ Skip_XX(Element_Size-Element_Offset, "Data (Partial)");
+ Element_End0();
+
+ FILLING_BEGIN();
+ Fill(Stream_Audio, 0, Audio_StreamSize, Size);
+ if (BitRate)
+ Fill(Stream_Audio, 0, Audio_Duration, ((int64u)Size)*1000*8/BitRate);
+
+ Finish("PS2 Audio");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Ps2Audio::SShd()
+{
+ Element_Begin1("SShd (Header)");
+ //Parsing
+ int32u Size, Format, SamplingRate, Channels;
+ Skip_C4( "ID");
+ Get_L4 (Size, "Size");
+ if (Size!=0x18)
+ {
+ Trusted_IsNot("Bad size");
+ return;
+ }
+ Get_L4 (Format, "Format");
+ Get_L4 (SamplingRate, "Sampling rate");
+ Get_L4 (Channels, "Channels");
+ Skip_L4( "Bytes per channel");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Element_End0();
+
+ FILLING_BEGIN();
+ Accept("PS2 Audio");
+
+ BitRate=SamplingRate*Channels*16; //Always 16 bits
+
+ Stream_Prepare(Stream_Audio);
+ Ztring FormatS;
+ switch(Format)
+ {
+ case 0x00000001 : FormatS=_T("PCM"); break;
+ case 0x00000010 : FormatS=_T("ADPCM"); break;
+ default : ;
+ }
+ Fill(Stream_Audio, 0, Audio_Format, FormatS);
+ Fill(Stream_Audio, 0, Audio_Codec, FormatS);
+ Fill(Stream_Audio, 0, Audio_MuxingMode, "PS2");
+ Fill(Stream_Audio, 0, Audio_SamplingRate, SamplingRate);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Channels);
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate);
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_PS2A_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ps2Audio.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ps2Audio.h
new file mode 100644
index 000000000..33ccc98be
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Ps2Audio.h
@@ -0,0 +1,52 @@
+// File_Ps2Audio - Info for PS2 Audio in MPEG files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Ps2AudioH
+#define MediaInfo_Ps2AudioH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Ps2Audio
+//***************************************************************************
+
+class File_Ps2Audio : public File__Analyze
+{
+private :
+ //Buffer - Global
+ void Read_Buffer_Continue();
+
+ //Elements
+ void SSbd();
+ void SShd();
+
+ //Temp
+ int32u BitRate;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Rkau.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Rkau.cpp
new file mode 100644
index 000000000..77a9ef197
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Rkau.cpp
@@ -0,0 +1,155 @@
+// File_Rkau - Info for RKAU files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+// Copyright (C) 2011-2011 Lionel DUCHATEAU, kurtnoise@free.fr
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_RKAU_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Rkau.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Rkau::File_Rkau()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Rkau::Streams_Finish()
+{
+ //Filling
+ int64u CompressedSize=File_Size-TagsSize;
+ float32 CompressionRatio=((float32)UncompressedSize)/CompressedSize;
+
+ Fill(Stream_Audio, 0, Audio_StreamSize, CompressedSize);
+ Fill(Stream_Audio, 0, Audio_Compression_Ratio, CompressionRatio);
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "VBR");
+
+ File__Tags_Helper::Streams_Finish();
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Rkau::FileHeader_Begin()
+{
+ if (!File__Tags_Helper::FileHeader_Begin())
+ return false;
+
+ //Synchro
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+ if (CC3(Buffer+Buffer_Offset)!=0x524B41) //"RKA"
+ {
+ File__Tags_Helper::Reject("RKAU");
+ return false;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Rkau::FileHeader_Parse()
+{
+ //Parsing
+ Ztring version;
+ int32u SampleRate, source_bytes;
+ int8u Channels, BitsPerSample, Quality, Flags;
+ bool joint_stereo, streaming, vrq_lossy_mode;
+
+ Skip_Local(3, "Signature");
+ Get_Local (1, version, "Version");
+ Get_L4 (source_bytes, "SourceBytes");
+ Get_L4 (SampleRate, "SampleRate");
+ Get_L1 (Channels, "Channels");
+ Get_L1 (BitsPerSample, "BitsPerSample");
+ Get_L1 (Quality, "Quality");
+ Get_L1 (Flags, "Flags");
+ Get_Flags (Flags, 0, joint_stereo, "JointStereo");
+ Get_Flags (Flags, 1, streaming, "Streaming");
+ Get_Flags (Flags, 2, vrq_lossy_mode, "VRQLossyMode");
+
+ FILLING_BEGIN();
+ if (SampleRate==0)
+ return;
+ Duration=(((int64u)source_bytes*1000)/4)/SampleRate;
+ if (Duration==0)
+ return;
+ UncompressedSize=Channels*(BitsPerSample/8);
+ if (UncompressedSize==0)
+ return;
+
+ //Filling data
+ File__Tags_Helper::Accept("RKAU");
+
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "RK Audio");
+ Fill(Stream_Audio, 0, Audio_Codec, "Rkau");
+ Fill(Stream_Audio, 0, Audio_Encoded_Library, _T("1.0") + version);
+ Fill(Stream_Audio, 0, Audio_Compression_Mode, (Quality==0)?"Lossless":"Lossy");
+ Fill(Stream_Audio, 0, Audio_BitDepth, BitsPerSample);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Channels);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, SampleRate);
+ Fill(Stream_Audio, 0, Audio_Duration, Duration);
+
+ FILLING_END();
+
+ //No more needed data
+ File__Tags_Helper::Finish("RKAU");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_RKAU_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Rkau.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Rkau.h
new file mode 100644
index 000000000..2eaba8cb3
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Rkau.h
@@ -0,0 +1,66 @@
+// File_Rkau - Info for RKAU files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+// Copyright (C) 2011-2011 Lionel DUCHATEAU, kurtnoise@free.fr
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about RKAU files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_RkauH
+#define MediaInfo_File_RkauH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Tag/File__Tags.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Rkau
+//***************************************************************************
+
+class File_Rkau : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //Constructor/Destructor
+ File_Rkau();
+
+private :
+ //Streams management
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Global
+ void Read_Buffer_Continue() {File__Tags_Helper::Read_Buffer_Continue();}
+
+ //Temp
+ int64u Duration;
+ int64u UncompressedSize;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ScreamTracker3.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ScreamTracker3.cpp
new file mode 100644
index 000000000..f6e8e1e44
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ScreamTracker3.cpp
@@ -0,0 +1,138 @@
+// File_ScreamTracker3 - Info for ScreamTracker3 files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WXMHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILXMY or FXMNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_S3M_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_ScreamTracker3.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_ScreamTracker3::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<44)
+ return false; //Must wait for more data
+
+ if (CC1(Buffer+28)!=0x1A || CC4(Buffer+44)!=0x5343524D) //"SCRM"
+ {
+ Reject("Scream Tracker 3");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_ScreamTracker3::Read_Buffer_Continue()
+{
+ //Parsing
+ Ztring SongName;
+ int16u OrdNum, InsNum, PatNum, Flags, Special;
+ int8u SoftwareVersionMajor, SoftwareVersionMinor, IS, TS;
+ Get_Local(28, SongName, "Song name");
+ Skip_L1( "0x1A");
+ Skip_L1( "Type");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Get_L2 (OrdNum, "Orders count");
+ Get_L2 (InsNum, "Instruments count");
+ Get_L2 (PatNum, "Paterns count");
+ Get_L2 (Flags, "Flags");
+ Skip_Flags(Flags, 0, "st2vibrato");
+ Skip_Flags(Flags, 1, "st2tempo");
+ Skip_Flags(Flags, 2, "amigaslides");
+ Skip_Flags(Flags, 3, "0vol optimizations");
+ Skip_Flags(Flags, 4, "amiga limits");
+ Skip_Flags(Flags, 5, "enable filter/sfx with sb");
+ Skip_Flags(Flags, 6, "st3.00 volumeslides");
+ Skip_Flags(Flags, 7, "pecial custom data in file");
+ Get_L1 (SoftwareVersionMajor, "Cwt/v (Major)");
+ Get_L1 (SoftwareVersionMinor, "Cwt/v (Minor)");
+ Skip_L2( "File format information");
+ Skip_B4( "Signature");
+ Skip_L1( "global volume");
+ Get_L1 (IS, "Initial Speed");
+ Get_L1 (TS, "Initial Temp");
+ Skip_L1( "master volume");
+ Skip_L1( "ultra click removal");
+ Skip_L1( "Default channel pan positions are present");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Skip_L1( "Unknown");
+ Get_L2 (Special, "Special");
+ Skip_XX(32, "Channel settings");
+ Skip_XX(OrdNum, "Orders");
+ Skip_XX(InsNum*2, "Instruments");
+ Skip_XX(PatNum*2, "Patterns");
+
+ FILLING_BEGIN();
+ Accept("Scream Tracker 3");
+
+ Fill(Stream_General, 0, General_Format, "Scream Tracker 3");
+ Fill(Stream_General, 0, General_Track, SongName);
+ if ((SoftwareVersionMajor&0xF0)==0x10)
+ Fill(Stream_General, 0, General_Encoded_Application, Ztring(_T("Scream Tracker ")+Ztring::ToZtring(SoftwareVersionMajor)+_T(".")+Ztring::ToZtring(SoftwareVersionMinor/16)+Ztring::ToZtring(SoftwareVersionMinor%16)));
+ Fill(Stream_General, 0, "BPM", TS);
+
+ Stream_Prepare(Stream_Audio);
+
+ Finish("Scream Tracker 3");
+ FILLING_END();
+
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_S3M_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ScreamTracker3.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ScreamTracker3.h
new file mode 100644
index 000000000..981d81daf
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_ScreamTracker3.h
@@ -0,0 +1,52 @@
+// File_ScreamTracker3 - Info for ScreamTracker3 files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WXMHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILXMY or FXMNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about ScreamTracker3 files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_ScreamTracker3H
+#define MediaInfo_File_ScreamTracker3H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_ScreamTracker3
+//***************************************************************************
+
+class File_ScreamTracker3 : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Speex.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Speex.cpp
new file mode 100644
index 000000000..fb03c602d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Speex.cpp
@@ -0,0 +1,165 @@
+// File_Speex - Info for Speex files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Note : the buffer must be given in ONE call
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_SPEEX_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Speex.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Speex::File_Speex()
+:File__Analyze()
+{
+ //Internal
+ Identification_Done=false;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Speex::Header_Parse()
+{
+ //Filling
+ Header_Fill_Code(0, "Speex");
+ Header_Fill_Size(Element_Size);
+}
+
+//---------------------------------------------------------------------------
+void File_Speex::Data_Parse()
+{
+ //Parsing
+ if (Identification_Done)
+ Comment();
+ else
+ Identification();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Speex::Identification()
+{
+ Element_Name("Identification");
+
+ //Parsing
+ Ztring speex_version;
+ int32u Speex_version_id, header_size, rate, nb_channels, bitrate, vbr;
+ Skip_Local(8, "speex_string");
+ Get_Local(20, speex_version, "speex_version");
+ Get_L4 (Speex_version_id, "Speex_version_id");
+ if (Speex_version_id==1)
+ {
+ Get_L4 (header_size, "header_size");
+ Get_L4 (rate, "rate");
+ Skip_L4( "mode");
+ Skip_L4( "mode_bitstream_version");
+ Get_L4 (nb_channels, "nb_channels");
+ Get_L4 (bitrate, "bitrate");
+ Skip_L4( "frame_size");
+ Get_L4 (vbr, "vbr");
+ Skip_L4( "frames_per_packet");
+ Skip_L4( "extra_headers");
+ Skip_L4( "reserved1");
+ Skip_L4( "reserved2");
+ if (header_size<Element_Size)
+ Skip_XX(Element_Size-header_size, "Unknown");
+
+ //Filling
+ FILLING_BEGIN()
+ Accept("Speex");
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "Speex");
+ Fill(Stream_Audio, 0, Audio_Codec, "Speex");
+ if (Speex_version_id==1)
+ {
+ if (!speex_version.empty())
+ Fill(Stream_Audio, 0, Audio_Encoded_Library, speex_version);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, rate);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, nb_channels);
+ if (bitrate!=(int32u)-1)
+ Fill(Stream_Audio, 0, Audio_BitRate, bitrate);
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, vbr?"VBR":"CBR");
+ }
+ FILLING_END();
+ }
+
+ //Filling
+ Identification_Done=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Speex::Comment()
+{
+ Element_Name("Comment?");
+
+ while (Element_Offset<Element_Size)
+ {
+ Ztring value;
+ int32u size;
+ Get_L4(size, "size");
+ if (size)
+ Get_Local(size, value, "value");
+
+ //Filling
+ if (!value.empty())
+ Fill(Stream_Audio, 0, "Comment", value);
+ }
+
+ Finish("Speex");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_SPEEX_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Speex.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Speex.h
new file mode 100644
index 000000000..cf5df2cd6
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Speex.h
@@ -0,0 +1,64 @@
+// File_Speex - Info for Speex files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Speex files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_SpeexH
+#define MediaInfo_File_SpeexH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Speex
+//***************************************************************************
+
+class File_Speex : public File__Analyze
+{
+public :
+ File_Speex();
+
+private :
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Identification();
+ void Comment();
+
+ //Temp
+ int8u Identification_Done;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tak.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tak.cpp
new file mode 100644
index 000000000..fa99a420d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tak.cpp
@@ -0,0 +1,311 @@
+// File_Tak - Info for Tak files
+// Copyright (C) 2009-2011 Lionel Duchateau, kurtnoise@free.fr
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Specifications : http://linuxstb.cream.org/tak_format.html
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_TAK_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Tak.h"
+#if defined(MEDIAINFO_RIFF_YES)
+ #include "MediaInfo/Multiple/File_Riff.h"
+#endif
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Const
+//***************************************************************************
+
+namespace Elements
+{
+ const int16u ENDOFMETADATA =0x00;
+ const int16u STREAMINFO =0x01;
+ const int16u SEEKTABLE =0x02;
+ const int16u WAVEMETADATA =0x03;
+ const int16u ENCODERINFO =0x04;
+ const int16u PADDING =0x05;
+}
+
+//***************************************************************************
+// Const
+//***************************************************************************
+
+int8u Tak_samplesize[]=
+{
+ 8,
+ 16,
+ 24,
+ 0,
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Tak::File_Tak()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Tak::FileHeader_Begin()
+{
+ if (!File__Tags_Helper::FileHeader_Begin())
+ return false;
+
+ //Synchro
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ if (CC4(Buffer+Buffer_Offset)!=0x7442614B) //"tBaK"
+ {
+ File__Tags_Helper::Reject("TAK");
+ return false;
+ }
+
+ return true;
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Tak::FileHeader_Parse()
+{
+ Skip_C4( "Signature");
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Tak::Header_Parse()
+{
+ //Parsing
+ int32u block_length;
+ int8u block_type;
+ Get_L1 (block_type, "Block Type");
+ Get_L3 (block_length, "Block Length");
+
+ //Filling
+ Header_Fill_Code(block_type, Ztring().From_CC1(block_type));
+ Header_Fill_Size(Element_Offset+block_length);
+}
+
+//---------------------------------------------------------------------------
+void File_Tak::Data_Parse()
+{
+ #define CASE_INFO(_NAME) \
+ case Elements::_NAME : Element_Info1(#_NAME); _NAME(); break;
+
+ //Parsing
+ switch (Element_Code)
+ {
+ CASE_INFO(ENDOFMETADATA);
+ CASE_INFO(STREAMINFO);
+ CASE_INFO(SEEKTABLE);
+ CASE_INFO(WAVEMETADATA);
+ CASE_INFO(ENCODERINFO);
+ CASE_INFO(PADDING);
+ default : Skip_XX(Element_Size, "Data");
+ }
+
+ Element_Offset=Element_Size;
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Tak::ENDOFMETADATA()
+{
+ //Filling
+ Fill(Stream_General, 0, General_StreamSize, 0); //File_Offset+Buffer_Offset+Element_Size);
+ Fill(Stream_Audio, 0, Audio_StreamSize, File_Size-(File_Offset+Buffer_Offset+Element_Size));
+ File__Tags_Helper::Finish("TAK");
+}
+
+//---------------------------------------------------------------------------
+void File_Tak::STREAMINFO()
+{
+ //Parsing
+ int32u num_samples_hi, samplerate;
+ int8u num_samples_lo, framesizecode, samplesize;
+ bool channels;
+
+ Skip_L1 ( "unknown");
+ BS_Begin();
+ Get_S1 ( 2, num_samples_lo, "num_samples (lo)");
+ Get_S1 ( 3, framesizecode, "framesizecode");
+ Skip_S1( 2, "unknown");
+ BS_End();
+ Get_L4 (num_samples_hi, "num_samples (hi)"); Param_Info2((((int64u)num_samples_hi)<<2 | num_samples_lo), " samples");
+ Get_L3 (samplerate, "samplerate"); Param_Info2((samplerate/16)+6000, " Hz");
+ BS_Begin();
+ Skip_S1( 4, "unknown");
+ Get_SB ( channels, "channels"); Param_Info1(channels?"Stereo":"Mono");
+ Get_S1 ( 2, samplesize, "samplesize"); Param_Info1(Tak_samplesize[samplesize]);
+ Skip_SB( "unknown");
+ BS_End();
+ Skip_L3( "crc");
+
+ FILLING_BEGIN()
+ //Coherency
+ if (samplerate==0)
+ return;
+
+ //Computing
+ int64u Samples=((int64u)num_samples_hi)<<2 | num_samples_lo;
+ int32u SamplingRate=(samplerate/16)+6000;
+
+ //Filling
+ File__Tags_Helper::Accept("TAK");
+
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "TAK");
+ Fill(Stream_Audio, 0, Audio_Codec, "TAK");
+ Fill(Stream_Audio, 0, Audio_SamplingRate, SamplingRate);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, channels?2:1);
+ if (Tak_samplesize[samplesize])
+ Fill(Stream_Audio, 0, Audio_BitDepth, Tak_samplesize[samplesize]);
+ Fill(Stream_Audio, 0, Audio_Duration, Samples*1000/SamplingRate);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Tak::SEEKTABLE()
+{
+ //Parsing
+ int16u num_seekpoints;
+ Get_L2 (num_seekpoints, "num_seekpoints");
+ Skip_L1 ( "unknown");
+ Skip_L1 ( "seek interval");
+ Element_Begin1("seekpoints");
+ for (int16u Pos=0; Pos<num_seekpoints; Pos++)
+ Skip_L5 ( "seekpoint");
+ Element_End0();
+ Skip_L3( "crc");
+}
+
+//---------------------------------------------------------------------------
+void File_Tak::WAVEMETADATA()
+{
+ //Parsing
+ int32u HeaderLength, FooterLength;
+ Get_L3 (HeaderLength, "HeaderLength");
+ Get_L3 (FooterLength, "FooterLength");
+ #if defined(MEDIAINFO_RIFF_YES)
+ //Creating the parser
+ File_Riff MI;
+ Open_Buffer_Init(&MI);
+
+ //Parsing
+ Open_Buffer_Continue(&MI, HeaderLength);
+ Element_Offset+=HeaderLength;
+
+ //Filling
+ //Finish(&MI);
+ //Merge(MI, StreamKind_Last, 0, StreamPos_Last);
+
+ //The RIFF header is for PCM
+ //Clear(Stream_Audio, StreamPos_Last, Audio_ID);
+ //Fill(Stream_Audio, StreamPos_Last, Audio_Format, "TAK", Unlimited, true, true);
+ //Fill(Stream_Audio, StreamPos_Last, Audio_Codec, "TAK", Unlimited, true, true);
+ //Clear(Stream_Audio, StreamPos_Last, Audio_CodecID);
+ //Clear(Stream_Audio, StreamPos_Last, Audio_CodecID_Hint);
+ //Clear(Stream_Audio, StreamPos_Last, Audio_CodecID_Url);
+ //Clear(Stream_Audio, StreamPos_Last, Audio_BitRate);
+ //Clear(Stream_Audio, StreamPos_Last, Audio_BitRate_Mode);
+ //Clear(Stream_Audio, StreamPos_Last, Audio_Codec_CC);
+ #else
+ Skip_XX(HeaderLength, "Wave header");
+ #endif
+ if (FooterLength)
+ Skip_XX(FooterLength, "Wave footer");
+ Skip_L3( "crc");
+}
+
+//---------------------------------------------------------------------------
+void File_Tak::ENCODERINFO()
+{
+ //Parsing
+ int8u Revision, Minor, Major, Preset_hi, Preset_lo;
+ Get_L1 (Revision, "Revision");
+ Get_L1 (Minor, "Minor");
+ Get_L1 (Major, "Major");
+ BS_Begin();
+ Get_S1 (4, Preset_hi, "Preset (hi)");
+ Get_S1 (4, Preset_lo, "Preset (lo)");
+ BS_End();
+
+ FILLING_BEGIN();
+ Ztring Version=Ztring::ToZtring(Major)+_T('.')+Ztring::ToZtring(Minor)+_T('.')+Ztring::ToZtring(Revision);
+ Ztring Preset=_T("-p")+Ztring::ToZtring(Preset_lo);
+ switch (Preset_hi)
+ {
+ case 0x00 : break;
+ case 0x01 : Preset+=_T('e'); break;
+ case 0x02 : Preset+=_T('m'); break;
+ default : Preset+=_T('-')+Ztring::ToZtring(Preset_hi, 16); //Unknown
+ }
+
+ Fill(Stream_Audio, 0, Audio_Encoded_Library, "TAK");
+ Fill(Stream_Audio, 0, Audio_Encoded_Library_String, _T("TAK ")+Version);
+ Fill(Stream_Audio, 0, Audio_Encoded_Library_Name, "TAK");
+ Fill(Stream_Audio, 0, Audio_Encoded_Library_Version, Version);
+ Fill(Stream_Audio, 0, Audio_Encoded_Library_Settings, Preset);
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_TAK_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tak.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tak.h
new file mode 100644
index 000000000..10b7ed24e
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tak.h
@@ -0,0 +1,77 @@
+// File_Tak - Info for Tak Audio files
+// Copyright (C) 2009-2009 Lionel Duchateau, kurtnoise@free.fr
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Tak files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_TakH
+#define MediaInfo_File_TakH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Tag/File__Tags.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Tak
+//***************************************************************************
+
+class File_Tak : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //In
+ bool VorbisHeader;
+
+ //Constructor/Destructor
+ File_Tak();
+
+private :
+ //Streams management
+ void Streams_Finish() {File__Tags_Helper::Streams_Finish();}
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Global
+ void Read_Buffer_Continue() {File__Tags_Helper::Read_Buffer_Continue();}
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void ENDOFMETADATA();
+ void STREAMINFO();
+ void SEEKTABLE();
+ void WAVEMETADATA();
+ void ENCODERINFO();
+ void PADDING() {Skip_XX(Element_Size, "Padding");}
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tta.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tta.cpp
new file mode 100644
index 000000000..20c9db826
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tta.cpp
@@ -0,0 +1,145 @@
+// File_Tta - Info for TTA files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Source : http://tta.sourceforge.net/codec.format
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_TTA_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Tta.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Tta::File_Tta()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Tta::Streams_Finish()
+{
+ //Filling
+ int64u CompressedSize=File_Size-TagsSize;
+ float32 CompressionRatio=((float32)UncompressedSize)/CompressedSize;
+
+ Fill(Stream_Audio, 0, Audio_StreamSize, CompressedSize);
+ Fill(Stream_Audio, 0, Audio_Compression_Ratio, CompressionRatio);
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "VBR");
+
+ File__Tags_Helper::Streams_Finish();
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Tta::FileHeader_Begin()
+{
+ if (!File__Tags_Helper::FileHeader_Begin())
+ return false;
+
+ //Synchro
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ if (CC4(Buffer+Buffer_Offset)!=0x54544131) //"TTA1"
+ {
+ File__Tags_Helper::Reject("TTA");
+ return false;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Tta::FileHeader_Parse()
+{
+ //Parsing
+ int32u SampleRate, Samples, CRC32;
+ int16u AudioFormat, Channels, BitsPerSample;
+ Skip_C4( "Signature");
+ Get_L2 (AudioFormat, "AudioFormat");
+ Get_L2 (Channels, "NumChannels");
+ Get_L2 (BitsPerSample, "BitsPerSample");
+ Get_L4 (SampleRate, "SampleRate");
+ Get_L4 (Samples, "DataLength");
+ Get_L4 (CRC32, "CRC32");
+
+ FILLING_BEGIN();
+ if (SampleRate==0)
+ return;
+ Duration=((int64u)Samples)*1000/SampleRate;
+ if (Duration==0)
+ return;
+ UncompressedSize=Samples*Channels*(BitsPerSample/8);
+ if (UncompressedSize==0)
+ return;
+
+ //Filling data
+ File__Tags_Helper::Accept("TTA");
+
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "TTA");
+ Fill(Stream_Audio, 0, Audio_Codec, "TTA ");
+ Fill(Stream_Audio, 0, Audio_BitDepth, BitsPerSample);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, SampleRate);
+ Fill(Stream_Audio, 0, Audio_Duration, Duration);
+ FILLING_END();
+
+ //No more need data
+ File__Tags_Helper::Finish("TTA");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_TTA_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tta.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tta.h
new file mode 100644
index 000000000..e196f84da
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Tta.h
@@ -0,0 +1,65 @@
+// File_Tta - Info for TTA files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about TTA files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_TtaH
+#define MediaInfo_File_TtaH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Tag/File__Tags.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Tta
+//***************************************************************************
+
+class File_Tta : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //Constructor/Destructor
+ File_Tta();
+
+private :
+ //Streams management
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Global
+ void Read_Buffer_Continue() {File__Tags_Helper::Read_Buffer_Continue();}
+
+ //Temp
+ int64u Duration;
+ int64u UncompressedSize;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_TwinVQ.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_TwinVQ.cpp
new file mode 100644
index 000000000..3c466ab2b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_TwinVQ.cpp
@@ -0,0 +1,214 @@
+// File_TwinVQ - Info for TwiVQ files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Source: http://wiki.multimedia.cx/index.php?title=VQF
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_TWINVQ_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_TwinVQ.h"
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* TwinVQ_samplerate(int32u samplerate)
+{
+ switch (samplerate)
+ {
+ case 11 : return "11025";
+ case 22 : return "22050";
+ case 44 : return "44100";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+namespace Elements
+{
+ const int32u _c__=0x28632920;
+ const int32u AUTH=0x41555448;
+ const int32u COMM=0x434F4D4D;
+ const int32u COMT=0x434F4D54;
+ const int32u DATA=0x44415441;
+ const int32u DSIZ=0x4453495A;
+ const int32u FILE=0x46494C45;
+ const int32u NAME=0x4E414D45;
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_TwinVQ::FileHeader_Begin()
+{
+ //Testing
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ if (CC4(Buffer+Buffer_Offset)!=0x5457494E) //"TWIN"
+ {
+ Reject("TwinVQ");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_TwinVQ::FileHeader_Parse()
+{
+ //Parsing
+ Skip_C4( "magic");
+ Skip_Local(8, "version");
+ Skip_B4( "subchunks_size");
+
+ FILLING_BEGIN();
+ Accept("TwinVQ");
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "TwinVQ");
+ Fill(Stream_Audio, 0, Audio_Codec, "TwinVQ");
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_TwinVQ::Header_Parse()
+{
+ //Parsing
+ int32u id, size;
+ Get_C4 (id, "id");
+ Get_B4 (size, "size");
+
+ //Filling
+ Header_Fill_Code(id, Ztring().From_CC4(id));
+ Header_Fill_Size(8+(id==Elements::DATA?0:size)); //DATA chunk indicates the end of the header, with no chunk size
+}
+
+//---------------------------------------------------------------------------
+void File_TwinVQ::Data_Parse()
+{
+ #define ELEMENT_CASE(_NAME, _DETAIL) \
+ case Elements::_NAME : Element_Info1(_DETAIL); _NAME(); break;
+
+ //Parsing
+ switch (Element_Code)
+ {
+ ELEMENT_CASE(_c__, "Copyright");
+ ELEMENT_CASE(AUTH, "Author");
+ ELEMENT_CASE(COMM, "Mandatory information");
+ ELEMENT_CASE(COMT, "Comment");
+ ELEMENT_CASE(DATA, "Data");
+ ELEMENT_CASE(DSIZ, "Data size");
+ ELEMENT_CASE(FILE, "Filename");
+ ELEMENT_CASE(NAME, "Song title");
+ default : Skip_XX(Element_Size, "Unknown");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_TwinVQ::COMM()
+{
+ //Parsing
+ int32u channel_mode, bitrate, samplerate;
+ Get_B4 (channel_mode, "channel_mode");
+ Get_B4 (bitrate, "bitrate");
+ Get_B4 (samplerate, "samplerate");
+ Skip_B4( "security_level");
+
+ //Filling
+ Fill(Stream_Audio, 0, Audio_Channel_s_, channel_mode+1);
+ Fill(Stream_Audio, 0, Audio_BitRate, bitrate*1000);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, TwinVQ_samplerate(samplerate));
+ if (!IsSub && File_Size!=(int64u)-1)
+ Fill(Stream_Audio, 0, Audio_StreamSize, File_Size);
+}
+
+//---------------------------------------------------------------------------
+void File_TwinVQ::DATA()
+{
+ //This is the end of the parsing (DATA chunk format is unknown)
+ Finish("TwinVQ");
+}
+
+//---------------------------------------------------------------------------
+void File_TwinVQ::DSIZ()
+{
+ //Parsing
+ Skip_B4( "Value");
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_TwinVQ::_____char()
+{
+ //Parsing
+ Skip_Local(Element_Size, "Value");
+}
+
+//---------------------------------------------------------------------------
+void File_TwinVQ::_____char(const char* Parameter)
+{
+ //Parsing
+ Ztring Value;
+ Get_Local(Element_Size, Value, "Value");
+
+ //Filling
+ Fill(Stream_General, 0, Parameter, Value);
+}
+
+} //Namespace
+
+#endif //MEDIAINFO_TWINVQ_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_TwinVQ.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_TwinVQ.h
new file mode 100644
index 000000000..fe010f54f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_TwinVQ.h
@@ -0,0 +1,70 @@
+// File_TwinVQ - Info for TwinVQ files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Musepack files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_TwinVQH
+#define MediaInfo_File_TwinVQH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_TwinVQ
+//***************************************************************************
+
+class File_TwinVQ : public File__Analyze
+{
+private :
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void _c__() {_____char("Copyright");}
+ void ALBM() {_____char("Album");}
+ void AUTH() {_____char("Performer");}
+ void COMM();
+ void COMT() {_____char("Comment");}
+ void DATA();
+ void DSIZ();
+ void FILE() {_____char();}
+ void NAME() {_____char("Title");}
+
+ //Helpers
+ void _____char();
+ void _____char(const char* Parameter);
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Vorbis.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Vorbis.cpp
new file mode 100644
index 000000000..35b0576ef
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Vorbis.cpp
@@ -0,0 +1,261 @@
+// File_Vorbis - Info for Vorbis files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Note : the buffer must be given in ONE call
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_VORBIS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Vorbis.h"
+#include <cmath>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+int8u ilog(int32u Value)
+{
+ int8u ToReturn=0;
+ while(Value)
+ {
+ ToReturn++;
+ Value>>=1;
+ }
+ return ToReturn;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Vorbis::Header_Parse()
+{
+ //Filling
+ Header_Fill_Code(0, "Vorbis");
+ Header_Fill_Size(Buffer_Size);
+}
+
+//---------------------------------------------------------------------------
+void File_Vorbis::Data_Parse()
+{
+ //Parsing
+ if (Status[IsAccepted])
+ Setup();
+ else
+ Identification();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Vorbis::Identification()
+{
+ Element_Name("Identification");
+
+ //Parsing
+ int32u Version, SamplingRate, BitRate_Maximum, BitRate_Nominal, BitRate_Minimum;
+ int8u Channels;
+ Skip_B1 ( "Signature");
+ Skip_Local(6, "Signature");
+ Get_L4 (Version, "Version");
+ if (Version>0)
+ return; //Not supported
+ Get_L1 (Channels, "Channels");
+ Get_L4 (SamplingRate, "SamplingRate");
+ Get_L4 (BitRate_Maximum, "BitRate_Maximum");
+ Get_L4 (BitRate_Nominal, "BitRate_Nominal");
+ Get_L4 (BitRate_Minimum, "BitRate_Minimum");
+ BS_Begin();
+ Skip_BS(4, "BlockSize_0"); //2^Value
+ Skip_BS(4, "BlockSize_1"); //2^Value
+ BS_End();
+ Skip_L1( "Framing");
+
+ //Filling
+ FILLING_BEGIN()
+ Accept("Vorbis");
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format, "Vorbis");
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, "Vorbis");
+ if (BitRate_Maximum!=0 && BitRate_Maximum<0x80000000) //This is a signed value, and negative values are not OK
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate_Maximum, BitRate_Maximum);
+ if (BitRate_Nominal!=0 && BitRate_Nominal<0x80000000) //This is a signed value, and negative values are not OK
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate, BitRate_Nominal);
+ if (BitRate_Minimum!=0 && BitRate_Minimum<0x80000000) //This is a signed value, and negative values are not OK
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate_Minimum, BitRate_Minimum);
+ if (BitRate_Nominal && BitRate_Maximum==BitRate_Nominal && BitRate_Nominal==BitRate_Minimum)
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate_Mode, "CBR");
+ else
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate_Mode, "VBR");
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, SamplingRate);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Vorbis::Setup()
+{
+ Element_Name("Setup");
+
+ //Parsing
+ Skip_Local(6, "Signature");
+ int32u codebook, codebook_dimensions, codebook_entries, ordered, codebook_lookup_type;
+ int8u vorbis_codebook_count;
+ Get_L1 (vorbis_codebook_count, "vorbis_codebook_count");
+ BS_Begin_LE(); //Vorbis bitstream is Little Endian
+ vorbis_codebook_count+=1;
+ for (int Pos=0; Pos<vorbis_codebook_count; Pos++)
+ {
+ Element_Begin1("codebook");
+ Get_T3 (24, codebook, "codebook");
+ if (codebook!=0x564342)
+ return;
+ Get_BT (16, codebook_dimensions, "codebook_dimensions");
+ Get_BT (24, codebook_entries, "codebook_entries");
+ Get_BT (1, ordered, "ordered");
+ if (!ordered)
+ {
+ int32u sparse;
+ Get_BT (1, sparse, "sparse");
+ for (int32u Pos2=0; Pos2<codebook_entries; Pos2++)
+ {
+ if (sparse)
+ {
+ int32u flag;
+ Get_BT (1, flag, "flag");
+ if (flag)
+ {
+ Info_BT(5, length, "length");
+ }
+ }
+ else
+ {
+ Info_BT(5, length, "length");
+ }
+ }
+ }
+ else
+ {
+ Skip_BT(5, "length");
+ int32u num;
+ for(int8u i=0; i<codebook_entries; )
+ {
+ Get_BT (ilog(codebook_entries-i), num, "num");
+ for(int32u j=0; j<num && i<codebook_entries; j++, i++);
+ }
+ }
+ Get_BT (4, codebook_lookup_type, "codebook_lookup_type");
+ if (codebook_lookup_type>2)
+ return; //Not decodable
+ if (codebook_lookup_type>0)
+ {
+ int8u codebook_value_bits;
+ Info_BT(32, codebook_minimum_value, "codebook_minimum_value");
+ Info_BT(32, codebook_delta_value, "codebook_delta_value");
+ Get_T1 ( 4, codebook_value_bits, "codebook_value_bits");
+ codebook_value_bits++;
+ Info_BT( 1, codebook_sequence_p, "codebook_sequence_p");
+ int32s vals;
+ if (codebook_lookup_type==1)
+ {
+ vals=(int32u)floor(pow((float)codebook_entries,1.f/codebook_dimensions));
+ for (;;)
+ {
+ int32u acc=1, acc1=1;
+ for(int32u i=0; i<codebook_dimensions; i++)
+ {
+ acc*=vals;
+ acc1*=vals+1;
+ }
+ if(acc<=codebook_entries && acc1>codebook_entries)
+ break;
+ else if(acc>codebook_entries)
+ vals--;
+ else
+ vals++;
+ }
+ }
+ else //codebook_lookup_type==2
+ vals=codebook_entries*codebook_dimensions;
+ int32u codebook_multiplicands;
+ for(int i=0; i<vals; i++)
+ Get_BT (codebook_value_bits, codebook_multiplicands, "codebook_multiplicands");
+ }
+ Element_End0();
+ }
+
+ //Time domain transforms
+ int32u vorbis_time_count;
+ Get_BT (6, vorbis_time_count, "vorbis_time_count");
+ for (int32u Pos=0; Pos<vorbis_time_count+1; Pos++)
+ Skip_BT(16, "zero");
+
+ //Floors
+ int32u vorbis_floor_count;
+ Get_BT (6, vorbis_floor_count, "vorbis_floor_count");
+ for (int32u Pos=0; Pos<vorbis_floor_count; Pos++)
+ {
+ int16u vorbis_floor_types;
+ Get_T2(16, vorbis_floor_types, "vorbis_floor_types");
+
+ FILLING_BEGIN();
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Floor, vorbis_floor_types);
+ Fill(Stream_Audio, 0, Audio_Codec_Settings_Floor, vorbis_floor_types);
+ if (vorbis_floor_types==0)
+ {
+ Fill(Stream_Audio, 0, Audio_Format_Settings, "Floor0");
+ Fill(Stream_Audio, 0, Audio_Codec_Settings, "Floor0");
+ }
+ FILLING_END();
+ //Must continue parsing...
+ }
+ BS_End_LE();
+
+ Finish("Vorbis");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_VORBIS_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Vorbis.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Vorbis.h
new file mode 100644
index 000000000..d789534d5
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Vorbis.h
@@ -0,0 +1,58 @@
+// File_Vorbis - Info for Vorbis files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Vorbis files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_VorbisH
+#define MediaInfo_File_VorbisH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Vorbis
+//***************************************************************************
+
+class File_Vorbis : public File__Analyze
+{
+private :
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Identification();
+ void Setup();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Wvpk.cpp b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Wvpk.cpp
new file mode 100644
index 000000000..1800b3467
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Wvpk.cpp
@@ -0,0 +1,734 @@
+// File_Wvpk - Info for WavPack files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Source : http://www.wavpack.com/file_format.txt
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_WVPK_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Audio/File_Wvpk.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const int16u Wvpk_Resolution[]=
+{
+ 8,
+ 16,
+ 24,
+ 32,
+};
+
+//---------------------------------------------------------------------------
+const int32u Wvpk_SamplingRate[]=
+{
+ 6000,
+ 8000,
+ 9600,
+ 11025,
+ 12000,
+ 16000,
+ 22050,
+ 24000,
+ 32000,
+ 44100,
+ 48000,
+ 64000,
+ 88200,
+ 96000,
+ 192000,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+const char* Wvpk_id(int8u ID)
+{
+ switch (ID)
+ {
+ case 0x00 : return "could be used to pad WavPack blocks";
+ case 0x02 : return "decorrelation terms & deltas";
+ case 0x03 : return "initial decorrelation weights";
+ case 0x04 : return "decorrelation sample history";
+ case 0x05 : return "initial entropy variables";
+ case 0x06 : return "entropy variables specific to hybrid mode";
+ case 0x07 : return "info needed for hybrid lossless (wvc) mode";
+ case 0x08 : return "specific info for floating point decode";
+ case 0x09 : return "specific info for decoding integers > 24 bits";
+ case 0x0A : return "normal compressed audio bitstream (wv file)";
+ case 0x0B : return "correction file bitstream (wvc file)";
+ case 0x0C : return "special extended bitstream for floating point data or integers > 24 bit";
+ case 0x0D : return "contains channel count and channel_mask";
+ case 0x21 : return "RIFF header for .wav files (before audio)";
+ case 0x22 : return "RIFF trailer for .wav files (after audio)";
+ case 0x25 : return "some encoding details for info purposes";
+ case 0x26 : return "16-byte MD5 sum of raw audio data";
+ case 0x27 : return "non-standard sampling rate info";
+ default: return "";
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Wvpk::File_Wvpk()
+:File__Analyze(), File__Tags_Helper()
+{
+ //File__Tags_Helper
+ Base=this;
+
+ //Configuration
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=32*1024;
+
+ //In
+ Frame_Count_Valid=2;
+ FromMKV=false;
+ FromMKV_CodecPrivateParsed=false;
+
+ //Temp - Technical info
+ total_samples_FirstFrame=(int32u)-1;
+ block_index_FirstFrame=0;
+ block_index_LastFrame=0;
+ SamplingRate=(int8u)-1;
+ num_channels=0;
+ channel_mask=0;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Wvpk::Streams_Finish()
+{
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "VBR");
+
+ //Specific case
+ if (FromMKV)
+ return;
+
+ //Duration
+ if (SamplingRate<15)
+ {
+ int64u Duration=(((int64u)(block_index_LastFrame+block_samples_LastFrame-block_index_FirstFrame))*1000/Wvpk_SamplingRate[SamplingRate]); //Don't forget the last frame with block_samples...
+ int64u CompressedSize=File_Size-TagsSize;
+ int64u UncompressedSize=Duration*(mono?1:2)*Wvpk_Resolution[(resolution1?1:0)*2+(resolution0?1:0)]*Wvpk_SamplingRate[SamplingRate]/8/1000;
+ float32 CompressionRatio=((float32)UncompressedSize)/CompressedSize;
+ Fill(Stream_Audio, 0, Audio_StreamSize, CompressedSize, 3, true);
+ Fill(Stream_Audio, 0, Audio_Duration, Duration, 10, true);
+ Fill(Stream_Audio, 0, Audio_Compression_Ratio, CompressionRatio, 3, true);
+ }
+
+ File__Tags_Helper::Streams_Finish();
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Wvpk::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<2)
+ return false; //Must wait for more data
+
+ if (CC2(Buffer)==0x4D5A) //"MZ"
+ {
+ File__Tags_Helper::Reject("WavPack");
+ return false; //Executable with WavPack data are currently not well supported --> It is preferable to set them as executable
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Wvpk::Synchronize()
+{
+ //Specific case
+ if (FromMKV)
+ return true;
+
+ //Tags
+ bool Tag_Found;
+ if (!File__Tags_Helper::Synchronize(Tag_Found))
+ return false;
+ if (Tag_Found)
+ return true;
+
+ //Synchronizing
+ while (Buffer_Offset+4<=Buffer_Size)
+ {
+ while (Buffer_Offset+4<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x77
+ || Buffer[Buffer_Offset+1]!=0x76
+ || Buffer[Buffer_Offset+2]!=0x70
+ || Buffer[Buffer_Offset+3]!=0x6B)) //"wvpk"
+ Buffer_Offset++;
+
+ if (Buffer_Offset+4<=Buffer_Size)//Testing if size is coherant
+ {
+ //Testing next start, to be sure
+ size_t Size=LittleEndian2int32u(Buffer+Buffer_Offset+4)+8;
+ if (Buffer_Offset+Size+4>Buffer_Size)
+ return false; //Need more data
+
+ //Testing
+ if (Buffer[Buffer_Offset+Size ]!=0x77
+ || Buffer[Buffer_Offset+Size+1]!=0x76
+ || Buffer[Buffer_Offset+Size+2]!=0x70
+ || Buffer[Buffer_Offset+Size+3]!=0x6B) //"wvpk"
+ Buffer_Offset++;
+ else
+ break; //while()
+ }
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+4>Buffer_Size)
+ {
+ if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x777670) //"wvp"
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x7776) //"wv"
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x77) //"w"
+ Buffer_Offset++;
+ return false;
+ }
+
+ //Synched is OK
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Wvpk::Synched_Test()
+{
+ //Specific case
+ if (FromMKV)
+ return true;
+
+ //Tags
+ if (!File__Tags_Helper::Synched_Test())
+ return false;
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (Buffer[Buffer_Offset ]!=0x77
+ || Buffer[Buffer_Offset+1]!=0x76
+ || Buffer[Buffer_Offset+2]!=0x70
+ || Buffer[Buffer_Offset+3]!=0x6B) //"wvpk"
+ Synched=false;
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Wvpk::Read_Buffer_Continue()
+{
+ //Tags
+ if (!FromMKV)
+ File__Tags_Helper::Read_Buffer_Continue();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Wvpk::Header_Parse()
+{
+ //Specific cases
+ if (FromMKV)
+ {
+ Header_Fill_Size(Element_Size);
+ Header_Fill_Code(0, "Block");
+ return;
+ }
+
+ //Parsing
+ int32u ckSize;
+ Skip_C4( "ckID");
+ Get_L4 (ckSize, "ckSize");
+
+ //Filling
+ Header_Fill_Size(8+ckSize);
+ Header_Fill_Code(0, "Block");
+}
+
+//---------------------------------------------------------------------------
+void File_Wvpk::Data_Parse()
+{
+ //Specific
+ if (FromMKV && !FromMKV_CodecPrivateParsed)
+ {
+ //Parsing
+ Get_L2 (version, "version");
+
+ FILLING_BEGIN();
+ FromMKV_CodecPrivateParsed=true;
+ FILLING_END();
+ return;
+ }
+
+ //Counting
+ Frame_Count++;
+
+ //Parsing
+ Element_Begin1("Block Header");
+ if (!FromMKV)
+ Get_L2 (version, "version");
+ if (version/0x100==0x4)
+ {
+ while (Element_Offset<Element_Size)
+ {
+ int32u total_samples=(int32u)-1, block_index=(int32u)-1, block_samples=0, flags, blocksize=(int32u)-1;
+ bool initial_block=true, final_block=true;
+ if (!FromMKV)
+ {
+ Skip_L1( "track_no");
+ Skip_L1( "index_no");
+ Get_L4 (total_samples, "total_samples");
+ Get_L4 (block_index, "block_index");
+ }
+ if (!FromMKV || (FromMKV && Element_Offset==0))
+ Get_L4 (block_samples, "block_samples");
+ if (block_samples!=0) //empty frames have other values empty
+ {
+ if (!FromMKV)
+ {
+ if (block_index==0) //Only the frame with block_index==0
+ total_samples_FirstFrame=total_samples; //Note: total_samples is not trustable for a cutted file
+ if (Frame_Count==1)
+ block_index_FirstFrame=block_index; //Save the block_index of the first block
+ block_index_LastFrame=block_index;
+ block_samples_LastFrame=block_samples;
+ }
+ Get_L4 (flags, "flags");
+ Get_Flags (flags, 0, resolution0, "resolution0");
+ Get_Flags (flags, 1, resolution1, "resolution1");
+ Get_Flags (flags, 2, mono, "mono");
+ Get_Flags (flags, 3, hybrid, "hybrid");
+ Get_Flags (flags, 4, joint_stereo, "joint stereo");
+ Get_Flags (flags, 5, cross_channel_decorrelation, "cross-channel decorrelation");
+ Skip_Flags(flags, 6, "hybrid noise shaping");
+ Skip_Flags(flags, 7, "floating point data");
+ Skip_Flags(flags, 8, "extended size integers");
+ Skip_Flags(flags, 9, "hybrid mode parameters control bitrate");
+ Skip_Flags(flags, 10, "hybrid noise balanced between channels");
+ Get_Flags (flags, 11, initial_block, "initial block in sequence");
+ Get_Flags (flags, 12, final_block, "final block in sequence");
+ Skip_Flags(flags, 13, "amount of data left-shift after decode");
+ Skip_Flags(flags, 14, "amount of data left-shift after decode");
+ Skip_Flags(flags, 15, "amount of data left-shift after decode");
+ Skip_Flags(flags, 16, "amount of data left-shift after decode");
+ Skip_Flags(flags, 17, "amount of data left-shift after decode");
+ Skip_Flags(flags, 18, "maximum magnitude of decoded data");
+ Skip_Flags(flags, 19, "maximum magnitude of decoded data");
+ Skip_Flags(flags, 20, "maximum magnitude of decoded data");
+ Skip_Flags(flags, 21, "maximum magnitude of decoded data");
+ Skip_Flags(flags, 22, "maximum magnitude of decoded data");
+ Skip_Flags(flags, 23, "sampling rate");
+ Skip_Flags(flags, 24, "sampling rate");
+ Skip_Flags(flags, 25, "sampling rate");
+ Skip_Flags(flags, 26, "sampling rate"); SamplingRate=(int8u)(((flags>>23)&0xF)); Param_Info1(Wvpk_SamplingRate[SamplingRate]);
+ Skip_Flags(flags, 27, "reserved");
+ Skip_Flags(flags, 28, "reserved");
+ Skip_Flags(flags, 29, "use IIR for negative hybrid noise shaping");
+ Skip_Flags(flags, 30, "false stereo");
+ Skip_Flags(flags, 31, "reserved");
+ }
+ else
+ {
+ Skip_L4( "flags (empty)");
+
+ //Counting
+ Frame_Count--; //This is not a real frame
+ }
+ Skip_L4( "crc");
+ Element_End0();
+
+ int64u End=Element_Size;
+ if (FromMKV && !(initial_block && final_block))
+ {
+ Get_L4 (blocksize, "blocksize");
+ End=Element_Offset+blocksize;
+ if (End>=Element_Size)
+ End=Element_Size;
+ }
+
+ //Sub-block
+ int8u id;
+ while (Element_Offset<End)
+ {
+ Element_Begin0();
+ int32u word_size;
+ bool large, odd_size;
+ BS_Begin();
+ Get_SB (large, "large");
+ Get_SB (odd_size, "odd_size");
+ Get_S1 (6, id, "id"); Element_Info1(Wvpk_id(id));
+ BS_End();
+ if (large)
+ {
+ Get_L3 (word_size, "word_size");
+ }
+ else
+ {
+ int8u word_size1;
+ Get_L1 (word_size1, "word_size");
+ word_size=word_size1;
+ }
+ if (word_size==0 && odd_size)
+ Size=0; //Problem!
+ else
+ Size=word_size*2-(odd_size?1:0);
+ Element_Name(Ztring().From_CC1(id));
+ switch (id)
+ {
+ case 0x07 : id_07(); break;
+ case 0x0D : id_0D(); break;
+ case 0x25 : id_25(); break;
+ default : if (word_size)
+ Skip_XX(Size, "data");
+ }
+ if (odd_size)
+ Skip_XX(1, "padding");
+ Element_End0();
+ }
+ }
+ }
+
+ //Filling
+ if (!Status[IsAccepted] && Frame_Count>=Frame_Count_Valid)
+ {
+ File__Tags_Helper::Accept("WavPack");
+ Data_Parse_Fill();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wvpk::Data_Parse_Fill()
+{
+ //Filling
+ File__Tags_Helper::Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "WavPack");
+ Ztring Version_Minor=Ztring::ToZtring(version%0x100);
+ if (Version_Minor.size()==1)
+ Version_Minor.insert(0, 1, _T('0'));
+ Fill(Stream_Audio, 0, Audio_Format_Profile, Ztring::ToZtring(version/0x100)+_T('.')+Version_Minor);
+ Fill(Stream_Audio, 0, Audio_Codec, "Wavpack");
+ Fill(Stream_Audio, 0, Audio_BitDepth, Wvpk_Resolution[(resolution1?1:0)*2+(resolution0?1:0)]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, num_channels?num_channels:(mono?1:2));
+ if (channel_mask)
+ {
+ Ztring Channels_Positions, Channels_Positions2;
+ if (channel_mask&0x00C7)
+ {
+ int8u Count=0;
+ Channels_Positions+=_T("Front:");
+ if (channel_mask&0x0001)
+ {
+ Channels_Positions+=_T(" L");
+ Count++;
+ }
+ if (channel_mask&0x0004)
+ {
+ Channels_Positions+=_T(" C");
+ Count++;
+ }
+ if (channel_mask&0x0040)
+ {
+ Channels_Positions+=_T(" C");
+ Count++;
+ }
+ if (channel_mask&0x0080)
+ {
+ Channels_Positions+=_T(" C");
+ Count++;
+ }
+ if (channel_mask&0x0002)
+ {
+ Channels_Positions+=_T(" R");
+ Count++;
+ }
+ Channels_Positions2+=Ztring::ToZtring(Count);
+ }
+ if (channel_mask&0x0600)
+ {
+ int8u Count=0;
+ if (!Channels_Positions.empty())
+ Channels_Positions+=_T(", ");
+ Channels_Positions+=_T("Side:");
+ if (channel_mask&0x0200)
+ {
+ Channels_Positions+=_T(" L");
+ Count++;
+ }
+ if (channel_mask&0x0400)
+ {
+ Channels_Positions+=_T(" R");
+ Count++;
+ }
+ Channels_Positions2+=_T('.')+Ztring::ToZtring(Count);
+ }
+ else
+ Channels_Positions2+=_T("/0");
+ if (channel_mask&0x0130)
+ {
+ int8u Count=0;
+ if (!Channels_Positions.empty())
+ Channels_Positions+=_T(", ");
+ Channels_Positions+=_T("Back:");
+ if (channel_mask&0x0010)
+ {
+ Channels_Positions+=_T(" L");
+ Count++;
+ }
+ if (channel_mask&0x0100)
+ {
+ Channels_Positions+=_T(" C");
+ Count++;
+ }
+ if (channel_mask&0x0020)
+ {
+ Channels_Positions+=_T(" R");
+ Count++;
+ }
+ Channels_Positions2+=_T('/')+Ztring::ToZtring(Count);
+ }
+ else
+ Channels_Positions2+=_T("/0");
+ if (channel_mask&0x0008)
+ {
+ if (!Channels_Positions.empty())
+ Channels_Positions+=_T(", ");
+ Channels_Positions+=_T("LFE");
+ Channels_Positions2+=_T(".1");
+ }
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, Channels_Positions);
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, Channels_Positions2);
+ }
+
+ if (!FromMKV && SamplingRate<15)
+ {
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, Wvpk_SamplingRate[SamplingRate]);
+ if (total_samples_FirstFrame!=(int32u)-1) //--> this is a valid value
+ Fill(Stream_Audio, 0, Audio_Duration, ((int64u)total_samples_FirstFrame)*1000/Wvpk_SamplingRate[SamplingRate]);
+ }
+ Fill(Stream_Audio, 0, Audio_Format_Settings, hybrid?"Hybrid lossy":"Lossless");
+ Fill(Stream_Audio, 0, Audio_Codec_Settings, hybrid?"hybrid lossy":"lossless");
+ Fill(Stream_Audio, 0, Audio_Encoded_Library_Settings, Encoded_Library_Settings);
+
+ //No more need data
+ File__Tags_Helper::GoToFromEnd(512*1024, "WavPack");
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Wvpk::id_07()
+{
+ //Parsing
+ Skip_XX(Size, "Data (Not decoded yet)");
+
+ FILLING_BEGIN();
+ if (Retrieve(Stream_Audio, 0, Audio_Compression_Mode).empty())
+ Fill(Stream_Audio, 0, Audio_Compression_Mode, "Lossless");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Wvpk::id_0D()
+{
+ //Parsing
+ Get_L1 (num_channels, "num_channels");
+ switch (Size)
+ {
+ case 1 :
+ break;
+ case 2 :
+ {
+ int8u channel_mask_1;
+ Get_L1 (channel_mask_1, "channel_mask");
+ channel_mask=channel_mask_1;
+ }
+ break;
+ case 3 :
+ {
+ int16u channel_mask_2;
+ Get_L2 (channel_mask_2, "channel_mask");
+ channel_mask=channel_mask_2;
+ }
+ break;
+ case 4 :
+ Get_L3 (channel_mask, "channel_mask");
+ break;
+ case 5 :
+ Get_L4 (channel_mask, "channel_mask");
+ break;
+ default : Skip_XX(Size, "unknown");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wvpk::id_25()
+{
+ //Parsing
+ int32u flags;
+ int8u extra=1;
+ Get_L3 (flags, "flags");
+ Skip_Flags(flags, 0, "");
+ Skip_Flags(flags, 1, "fast mode");
+ Skip_Flags(flags, 2, "");
+ Skip_Flags(flags, 3, "high quality mode");
+
+ Skip_Flags(flags, 4, "very high quality mode");
+ Skip_Flags(flags, 5, "bitrate is kbps, not bits/sample");
+ Skip_Flags(flags, 6, "automatic noise shaping");
+ Skip_Flags(flags, 7, "shaping mode specified");
+
+ Skip_Flags(flags, 8, "joint-stereo mode specified");
+ Skip_Flags(flags, 9, "dynamic noise shaping");
+ Skip_Flags(flags, 10, "create executable");
+ Skip_Flags(flags, 11, "create correction file");
+
+ Skip_Flags(flags, 12, "maximize bybrid compression");
+ Skip_Flags(flags, 13, "");
+ Skip_Flags(flags, 14, "");
+ Skip_Flags(flags, 15, "calc noise in hybrid mode");
+
+ Skip_Flags(flags, 16, "lossy mode");
+ Skip_Flags(flags, 17, "extra processing mode");
+ Skip_Flags(flags, 18, "no wvx stream w/ floats & big ints");
+ Skip_Flags(flags, 19, "store MD5 signature");
+
+ Skip_Flags(flags, 20, "merge blocks of equal redundancy (for lossyWAV)");
+ Skip_Flags(flags, 21, "");
+ Skip_Flags(flags, 22, "");
+ Skip_Flags(flags, 23, "optimize for mono streams posing as stereo");
+ if (flags&0x20000 && Size>=4)
+ {
+ Get_L1(extra, "extra");
+ }
+
+ if ((flags&0x20000 && Size>4) || (!(flags&0x20000) && Size>3))
+ Skip_XX(Size-3-(flags&0x20000?1:0), "unknown");
+
+ //Filling
+ if (flags&0x000001)
+ Encoded_Library_Settings+=_T(" -?");
+ if (flags&0x000002)
+ Encoded_Library_Settings+=_T(" -f");
+ if (flags&0x000004)
+ Encoded_Library_Settings+=_T(" -?");
+ if (flags&0x000008)
+ Encoded_Library_Settings+=_T(" -h");
+ if (flags&0x000010)
+ Encoded_Library_Settings+=_T(" -hh");
+ if (flags&0x000020)
+ Encoded_Library_Settings+=_T(" -?(bitrate is kbps, not bits/sample)");
+ if (flags&0x000040)
+ Encoded_Library_Settings+=_T(" -?(automatic noise shaping)");
+ if (flags&0x000080)
+ Encoded_Library_Settings+=_T(" -sn");
+ if (flags&0x000100)
+ Encoded_Library_Settings+=_T(" -jn");
+ if (flags&0x000200)
+ Encoded_Library_Settings+=_T(" -use-dns");
+ if (flags&0x000400)
+ Encoded_Library_Settings+=_T(" -e");
+ if (flags&0x000800)
+ Encoded_Library_Settings+=_T(" -c");
+ if (flags&0x001000)
+ Encoded_Library_Settings+=_T(" -cc");
+ if (flags&0x002000)
+ Encoded_Library_Settings+=_T(" -?");
+ if (flags&0x004000)
+ Encoded_Library_Settings+=_T(" -?");
+ if (flags&0x008000)
+ Encoded_Library_Settings+=_T(" -n");
+ if (flags&0x010000)
+ Encoded_Library_Settings+=_T(" -?(lossy mode)");
+ if (flags&0x020000)
+ {
+ Encoded_Library_Settings+=_T(" -x");
+ if (extra)
+ Encoded_Library_Settings+=Ztring::ToZtring(extra);
+ }
+ if (flags&0x04000)
+ Encoded_Library_Settings+=_T(" -?");
+ if (flags&0x080000)
+ Encoded_Library_Settings+=_T(" -m");
+ if (flags&0x100000)
+ Encoded_Library_Settings+=_T(" --merge-blocks");
+ if (flags&0x200000)
+ Encoded_Library_Settings+=_T(" -?");
+ if (flags&0x400000)
+ Encoded_Library_Settings+=_T(" -?");
+ if (flags&0x800000)
+ Encoded_Library_Settings+=_T(" --optimize-mono");
+ if (!Encoded_Library_Settings.empty())
+ Encoded_Library_Settings.erase(Encoded_Library_Settings.begin());
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_WVPK_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Wvpk.h b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Wvpk.h
new file mode 100644
index 000000000..16259e823
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Audio/File_Wvpk.h
@@ -0,0 +1,97 @@
+// File_Wvpk - Info for WavePack files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about WavePack files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_WvpkH
+#define MediaInfo_File_WvpkH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Tag/File__Tags.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Wvpk
+//***************************************************************************
+
+class File_Wvpk : public File__Analyze, public File__Tags_Helper
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ bool FromMKV;
+ bool FromMKV_CodecPrivateParsed;
+
+ //Constructor - Destructor
+ File_Wvpk();
+
+private :
+ //Streams management
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+ void Data_Parse_Fill();
+
+ //Elements
+ void id_07();
+ void id_0D();
+ void id_25();
+
+ //Temp - Technical info
+ int32u total_samples_FirstFrame;
+ int32u block_index_FirstFrame;
+ int32u block_index_LastFrame;
+ int32u block_samples_LastFrame;
+ bool resolution0;
+ bool resolution1;
+ bool mono;
+ bool hybrid;
+ bool joint_stereo;
+ bool cross_channel_decorrelation;
+ int8u SamplingRate;
+ int8u num_channels;
+ int32u channel_mask;
+ int32u Size;
+ int16u version;
+ Ztring Encoded_Library_Settings;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate_MpegTs.cpp b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate_MpegTs.cpp
new file mode 100644
index 000000000..d037df74b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate_MpegTs.cpp
@@ -0,0 +1,492 @@
+// File__Duplicate_MpegTs - Duplication of some formats
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Duplication helper for some specific formats
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEGPS_YES) || defined(MEDIAINFO_MPEGTS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Duplicate/File__Duplicate_MpegTs.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "ZenLib/ZtringList.h"
+#include "ZenLib/File.h"
+#include <cstring>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+// CRC_32_Table
+// A CRC is computed like this:
+// Init: int32u CRC_32 = 0xFFFFFFFF;
+// for each data byte do
+// CRC_32=(CRC_32<<8) ^ CRC_32_Table[(CRC_32>>24)^(data_byte)];
+extern int32u Psi_CRC_32_Table[256];
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+File__Duplicate_MpegTs::File__Duplicate_MpegTs (const Ztring &Target)
+: File__Duplicate__Base()
+{
+ Writer.Configure(Target);
+
+ //Current
+ program_map_PIDs.resize(0x2000, 0);
+ elementary_PIDs.resize(0x2000, 0);
+ elementary_PIDs_program_map_PIDs.resize(0x2000, 0);
+}
+
+//***************************************************************************
+// Set
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File__Duplicate_MpegTs::Configure (const Ztring &Value, bool ToRemove)
+{
+ //Form: "program_number"
+ if (Value.find(_T("program_number="))==0)
+ {
+ int16u program_number=Ztring(Value.substr(15, std::string::npos)).To_int16u();
+ if (ToRemove)
+ {
+ if (Wanted_program_numbers.find(program_number)!=Wanted_program_numbers.end())
+ Wanted_program_numbers.erase(program_number);
+ else if (Remove_program_numbers.find(program_number)==Remove_program_numbers.end())
+ Remove_program_numbers.insert(program_number);
+ }
+ else
+ {
+ if (Remove_program_numbers.find(program_number)!=Remove_program_numbers.end())
+ Remove_program_numbers.erase(program_number);
+ if (Wanted_program_numbers.find(program_number)==Wanted_program_numbers.end())
+ Wanted_program_numbers.insert(program_number);
+ }
+ if (!PAT.empty())
+ PAT.begin()->second.ConfigurationHasChanged=true;
+ }
+ //Form: "program_map_PID"
+ else if (Value.find(_T("program_map_PID="))==0)
+ {
+ int16u program_map_PID=Ztring(Value.substr(16, std::string::npos)).To_int16u();
+ if (ToRemove)
+ {
+ if (Wanted_program_map_PIDs.find(program_map_PID)!=Wanted_program_map_PIDs.end())
+ Wanted_program_map_PIDs.erase(program_map_PID);
+ else if (Remove_program_map_PIDs.find(program_map_PID)==Remove_program_map_PIDs.end())
+ Remove_program_map_PIDs.insert(program_map_PID);
+ }
+ else
+ {
+ if (Remove_program_map_PIDs.find(program_map_PID)!=Remove_program_map_PIDs.end())
+ Remove_program_map_PIDs.erase(program_map_PID);
+ if (Wanted_program_map_PIDs.find(program_map_PID)==Wanted_program_map_PIDs.end())
+ Wanted_program_map_PIDs.insert(program_map_PID);
+ }
+ if (PMT.find(program_map_PID)!=PMT.end())
+ PMT[program_map_PID].ConfigurationHasChanged=true;
+ }
+ //Form: "elementary_PID"
+ else if (Value.find(_T("elementary_PID="))==0)
+ {
+ int16u elementary_PID=Ztring(Value.substr(15, std::string::npos)).To_int16u();
+ if (ToRemove)
+ {
+ if (Wanted_elementary_PIDs.find(elementary_PID)!=Wanted_elementary_PIDs.end())
+ Wanted_elementary_PIDs.erase(elementary_PID);
+ else if (Remove_elementary_PIDs.find(elementary_PID)==Remove_elementary_PIDs.end())
+ Remove_elementary_PIDs.insert(elementary_PID);
+ }
+ else
+ {
+ if (Remove_elementary_PIDs.find(elementary_PID)!=Remove_elementary_PIDs.end())
+ Remove_elementary_PIDs.erase(elementary_PID);
+ if (Wanted_elementary_PIDs.find(elementary_PID)==Wanted_elementary_PIDs.end())
+ Wanted_elementary_PIDs.insert(elementary_PID);
+ }
+ if (PMT.find(elementary_PIDs_program_map_PIDs[elementary_PID])!=PMT.end())
+ PMT[elementary_PIDs_program_map_PIDs[elementary_PID]].ConfigurationHasChanged=true;
+ }
+ //Old
+ else
+ {
+ int16u program_number=Ztring(Value).To_int16u();
+ if (ToRemove)
+ {
+ if (Wanted_program_numbers.find(program_number)!=Wanted_program_numbers.end())
+ Wanted_program_numbers.erase(program_number);
+ else if (Remove_program_numbers.find(program_number)==Remove_program_numbers.end())
+ Remove_program_numbers.insert(program_number);
+ }
+ else
+ {
+ if (Remove_program_numbers.find(program_number)!=Remove_program_numbers.end())
+ Remove_program_numbers.erase(program_number);
+ if (Wanted_program_numbers.find(program_number)==Wanted_program_numbers.end())
+ Wanted_program_numbers.insert(program_number);
+ }
+ if (!PAT.empty())
+ PAT.begin()->second.ConfigurationHasChanged=true;
+ }
+
+ //Can be disabled?
+ if (Wanted_program_numbers.empty()
+ && Wanted_program_map_PIDs.empty()
+ && Wanted_elementary_PIDs.empty()
+ && Remove_program_numbers.empty()
+ && Remove_program_map_PIDs.empty()
+ && Remove_elementary_PIDs.empty())
+ return true; //It can be erased
+ else
+ return false; //We always need it
+}
+
+//***************************************************************************
+// Write
+//***************************************************************************
+
+bool File__Duplicate_MpegTs::Write (int16u PID, const int8u* ToAdd, size_t ToAdd_Size)
+{
+ if (elementary_PIDs[PID])
+ {
+ Writer.Write(ToAdd, ToAdd_Size);
+ return false;
+ }
+ else if (program_map_PIDs[PID])
+ return Manage_PMT(ToAdd, ToAdd_Size);
+ else if (PID==0x0000)
+ return Manage_PAT(ToAdd, ToAdd_Size);
+ else
+ return false;
+}
+
+bool File__Duplicate_MpegTs::Manage_PAT (const int8u* ToAdd, size_t ToAdd_Size)
+{
+ if (!Parsing_Begin(ToAdd, ToAdd_Size, PAT))
+ return false;
+
+ //Programs
+ program_map_PIDs.clear();
+ program_map_PIDs.resize(0x2000, 0);
+ elementary_PIDs.clear();
+ elementary_PIDs.resize(0x2000, 0);
+ while (FromTS.Offset+4<=FromTS.End)
+ {
+ //For each program
+ int16u program_number =CC2(FromTS.Buffer+FromTS.Offset+0);
+ int16u program_map_PID=CC2(FromTS.Buffer+FromTS.Offset+2)&0x1FFF;
+ if (Wanted_program_numbers.find(program_number) !=Wanted_program_numbers.end()
+ || Wanted_program_map_PIDs.find(program_map_PID)!=Wanted_program_map_PIDs.end())
+ {
+ //Integrating it
+ program_map_PIDs[program_map_PID]=1;
+ std::memcpy(PAT[StreamID].Buffer+PAT[StreamID].Offset, FromTS.Buffer+FromTS.Offset, 4);
+ PAT[StreamID].Offset+=4;
+ PMT[program_number].ConfigurationHasChanged=true;
+ }
+ FromTS.Offset+=4;
+ }
+
+ Parsing_End(PAT);
+
+ //Reseting
+ std::vector<int16u> StreamID_List;
+ for (std::map<int16u, buffer>::iterator PAT_=PAT.begin(); PAT_!=PAT.end(); PAT_++)
+ if (PAT_->first!=StreamID)
+ StreamID_List.push_back(PAT_->first);
+ for (size_t Pos=0; Pos<StreamID_List.size(); Pos++)
+ PAT[StreamID_List[Pos]].FromTS_version_number_Last=0xFF;
+
+ return true;
+}
+
+bool File__Duplicate_MpegTs::Manage_PMT (const int8u* ToAdd, size_t ToAdd_Size)
+{
+ if (!Parsing_Begin(ToAdd, ToAdd_Size, PMT))
+ return false;
+
+ //Testing program_number
+ if (Wanted_program_numbers.find(StreamID)==Wanted_program_numbers.end()
+ && Wanted_program_map_PIDs.find(elementary_PIDs_program_map_PIDs[StreamID])==Wanted_program_numbers.end())
+ {
+ delete[] PMT[StreamID].Buffer; PMT[StreamID].Buffer=NULL;
+ return false;
+ }
+
+ //program_info_length
+ int16u program_info_length=CC2(FromTS.Buffer+FromTS.Offset+2)&0x0FFF;
+ std::memcpy(PMT[StreamID].Buffer+PMT[StreamID].Offset, FromTS.Buffer+FromTS.Offset, 4+program_info_length);
+ FromTS.Offset+=4+program_info_length;
+ PMT[StreamID].Offset+=4+program_info_length;
+
+ //elementary_PIDs
+ while (FromTS.Offset+5<=FromTS.End)
+ {
+ //For each elementary_PID
+ int16u elementary_PID=CC2(FromTS.Buffer+FromTS.Offset+1)&0x1FFF;
+ int16u ES_info_length=CC2(FromTS.Buffer+FromTS.Offset+3)&0x0FFF;
+ if (Wanted_elementary_PIDs.empty() || Wanted_elementary_PIDs.find(elementary_PID)!=Wanted_elementary_PIDs.end())
+ {
+ //Integrating it
+ elementary_PIDs[elementary_PID]=1;
+ elementary_PIDs_program_map_PIDs[elementary_PID]=StreamID;
+ std::memcpy(PMT[StreamID].Buffer+PMT[StreamID].Offset, FromTS.Buffer+FromTS.Offset, 5+ES_info_length);
+ PMT[StreamID].Offset+=5+ES_info_length;
+ }
+ else
+ elementary_PIDs[elementary_PID]=0;
+ FromTS.Offset+=5+ES_info_length;
+ }
+
+ Parsing_End(PMT);
+ return true;
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+bool File__Duplicate_MpegTs::Parsing_Begin (const int8u* ToAdd, size_t ToAdd_Size, std::map<int16u, buffer> &ToModify_)
+{
+ //Managing big chunks
+ int16u PID=((ToAdd[1]&0x1F)<<8)|ToAdd[2]; //BigEndian2int16u(ToAdd+1)&0x1FFF;
+ if (ToAdd[1]&0x40) //payload_unit_start_indicator
+ {
+ FromTS.Buffer=ToAdd;
+ FromTS.Size=ToAdd_Size;
+ FromTS.Offset=0;
+ }
+ else
+ {
+ if (BigBuffers.find(PID)==BigBuffers.end())
+ return false; //Start is missing
+ if (ToAdd_Size<4 || BigBuffers[PID].Buffer_Size+ToAdd_Size-4>BigBuffers[PID].Buffer_Size_Max)
+ return false; //Problem
+ std::memcpy(BigBuffers[PID].Buffer+BigBuffers[PID].Buffer_Size, ToAdd+4, ToAdd_Size-4);
+ BigBuffers[PID].Buffer_Size+=ToAdd_Size-4;
+
+ FromTS.Buffer=BigBuffers[PID].Buffer;
+ FromTS.Size=BigBuffers[PID].Buffer_Size;
+ FromTS.Offset=0;
+ }
+
+ //adaptation_field_length
+ int8u adaptation_field_length=0;
+ if (CC1(FromTS.Buffer+3)&0x20) //adaptation_field_control (adaptation) == true
+ adaptation_field_length=1+CC1(FromTS.Buffer+4);
+
+ //pointer_field
+ FromTS.Offset+=4+adaptation_field_length;
+ int8u pointer_field=CC1(FromTS.Buffer+FromTS.Offset);
+
+ //table_id
+ FromTS.Offset+=1+pointer_field;
+ int8u table_id=FromTS.Buffer[FromTS.Offset];
+ if (table_id!=0x00 && table_id!=0x02) //Currently only PAT and PMT are handled
+ return false;
+
+ //section_length
+ FromTS.Offset++;
+ if (FromTS.Offset+2>FromTS.Size)
+ return false;
+ FromTS.Begin=FromTS.Offset-1;
+ int16u section_length=CC2(FromTS.Buffer+FromTS.Offset)&0x0FFF;
+ FromTS.End=4+adaptation_field_length+section_length;
+
+ //Positionning just after section_length
+ FromTS.Offset+=2;
+
+ //Retrieving StreamID
+ StreamID=CC2(FromTS.Buffer+FromTS.Offset);
+ buffer &ToModify=ToModify_[StreamID];
+
+ //version_number
+ int8u FromTS_version_number=(CC1(FromTS.Buffer+FromTS.Offset+2)>>1)&0x1F;
+ if (ToModify.version_number==0xFF && FromTS.End<=FromTS.Size-4) //Only if we have enough data
+ ToModify.version_number=FromTS_version_number;
+ if (ToModify.continuity_counter==0xFF && FromTS.End<=FromTS.Size-4) //Only if we have enough data
+ ToModify.continuity_counter=FromTS.Buffer[3]&0xF;
+ if (FromTS_version_number!=ToModify.FromTS_version_number_Last || ToModify.ConfigurationHasChanged)
+ {
+ if (FromTS.End<=FromTS.Size-4) //Only if we have enough data
+ {
+ ToModify.version_number++;
+ if (ToModify.version_number>0x1F)
+ ToModify.version_number=0;
+ ToModify.FromTS_version_number_Last=FromTS_version_number;
+ ToModify.ConfigurationHasChanged=false;
+ }
+ }
+ else
+ {
+ if (ToModify.Buffer==NULL)
+ return false;
+
+ //This is the same as before --> Copying the last version, except continuity_counter (incremented)
+ for (size_t Pos=0; Pos<ToModify.Size; Pos+=188)
+ {
+ ToModify.continuity_counter++;
+ if (ToModify.continuity_counter>0x0F)
+ ToModify.continuity_counter=0x00;
+ ToModify.Buffer[Pos+3]&=0xF0;
+ ToModify.Buffer[Pos+3]|=ToModify.continuity_counter;
+ }
+
+ //Managing big chunks
+ if (BigBuffers.find(PID)!=BigBuffers.end())
+ BigBuffers.erase(BigBuffers.find(PID));
+
+ Writer.Write(ToModify.Buffer, ToModify.Size);
+ return false;
+ }
+
+ //Test if we have enough data
+ if (FromTS.End>FromTS.Size-4)
+ {
+ //Waiting for more data
+ if (BigBuffers[PID].Buffer==NULL)
+ {
+ //Saving the data (not done at the beginning)
+ BigBuffers[PID].Buffer_Size=FromTS.Size;
+ BigBuffers[PID].Buffer_Size_Max=FromTS.End+188;
+ BigBuffers[PID].Buffer=new int8u[BigBuffers[PID].Buffer_Size_Max];
+ std::memcpy(BigBuffers[PID].Buffer, ToAdd, ToAdd_Size);
+ }
+ return false;
+ }
+
+ //Verifying CRC
+ int32u CRC_32=0xFFFFFFFF;
+ for (int32u CRC_32_Offset=(int32u)FromTS.Begin; CRC_32_Offset<FromTS.End+4; CRC_32_Offset++) //After syncword
+ CRC_32=(CRC_32<<8) ^ Psi_CRC_32_Table[(CRC_32>>24)^(FromTS.Buffer[CRC_32_Offset])];
+ if (CRC_32)
+ return false; //Problem
+
+ //Copying
+ if (ToModify.Buffer!=NULL && ToModify.Size<FromTS.Size)
+ {delete[] ToModify.Buffer; ToModify.Buffer=NULL;}
+ if (ToModify.Buffer==NULL)
+ ToModify.Buffer=new int8u[FromTS.Size+(FromTS.Size/188)*4];
+ std::memcpy(ToModify.Buffer, FromTS.Buffer, FromTS.Begin+8); //Only up to last_section_number included
+ ToModify.Offset=FromTS.Offset;
+ ToModify.Begin=FromTS.Begin;
+ ToModify.End=FromTS.End;
+ ToModify.Size=FromTS.Size;
+
+ //Changing version_number
+ int8u ToReplace=FromTS.Buffer[FromTS.Offset+2];
+ ToReplace&=0xC1; //11000001, for removing old version_number
+ ToReplace|=ToModify.version_number<<1; //merging, with 1 bit offset
+ ToModify.Buffer[ToModify.Offset+2]=ToReplace;
+
+ //Positionning after last_section_number
+ ToModify.Offset+=5;
+ FromTS.Offset+=5;
+
+ return true;
+}
+
+void File__Duplicate_MpegTs::Parsing_End (std::map<int16u, buffer> &ToModify_)
+{
+ buffer &ToModify=ToModify_[StreamID];
+
+ ToModify.End=ToModify.Offset;
+ if (ToModify.End+4>ToModify.Size)
+ return; //There was an error somewhere!
+
+ //section_length
+ int8u ToReplace=CC1(ToModify.Buffer+ToModify.Begin+1)&0xF0; //before section_length
+ int16u section_length=(int16u)(ToModify.End-ToModify.Begin+1); //+4 for CRC, -3 for header size
+ ToReplace|=section_length>>8;
+ ToModify.Buffer[ToModify.Begin+1+0]=ToReplace;
+ ToModify.Buffer[ToModify.Begin+1+1]=(int8u)(section_length&0xFF);
+
+ //CRC32
+ int32u CRC_32=0xFFFFFFFF;
+ for (size_t Buffer_CRC_Pos=ToModify.Begin; Buffer_CRC_Pos<ToModify.End; Buffer_CRC_Pos++)
+ CRC_32=(CRC_32<<8) ^ Psi_CRC_32_Table[(CRC_32>>24)^(ToModify.Buffer[Buffer_CRC_Pos])];
+
+ ToModify.Buffer[ToModify.Offset+0]=(CRC_32>>24)&0xFF;
+ ToModify.Buffer[ToModify.Offset+1]=(CRC_32>>16)&0xFF;
+ ToModify.Buffer[ToModify.Offset+2]=(CRC_32>> 8)&0xFF;
+ ToModify.Buffer[ToModify.Offset+3]= CRC_32 &0xFF;
+
+ //Managing big chunks
+ for (size_t Pos=188; Pos<ToModify.Size; Pos+=188)
+ {
+ std::memmove(ToModify.Buffer+Pos+4, ToModify.Buffer+Pos, ToModify.Size-Pos);
+ std::memcpy(ToModify.Buffer+Pos, ToModify.Buffer, 4);
+ ToModify.Buffer[Pos+1]&=0xBF; //Removing payload_unit_start_indicator
+ ToModify.Offset+=4;
+ ToModify.Size+=4;
+
+ ToModify.continuity_counter++;
+ if (ToModify.continuity_counter>0x0F)
+ ToModify.continuity_counter=0x00;
+ ToModify.Buffer[Pos+3]&=0xF0;
+ ToModify.Buffer[Pos+3]|=ToModify.continuity_counter;
+ }
+ while (ToModify.Size-(ToModify.Offset+4)>188)
+ ToModify.Size-=188;
+
+ //Padding
+ for (size_t Buffer_CRC_Pos=ToModify.End+4; Buffer_CRC_Pos<ToModify.Size; Buffer_CRC_Pos++)
+ ToModify.Buffer[Buffer_CRC_Pos]=0xFF;
+
+ Writer.Write(ToModify.Buffer, ToModify.Size);
+
+ //Managing big chunks
+ int16u PID=((ToModify.Buffer[1]&0x1F)<<8)|ToModify.Buffer[2]; //BigEndian2int16u(ToAdd+1)&0x1FFF;
+ if (BigBuffers.find(PID)!=BigBuffers.end())
+ BigBuffers.erase(BigBuffers.find(PID));
+}
+
+//***************************************************************************
+// Output_Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t File__Duplicate_MpegTs::Output_Buffer_Get (unsigned char** Output_Buffer)
+{
+ return Writer.Output_Buffer_Get(Output_Buffer);
+}
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate_MpegTs.h b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate_MpegTs.h
new file mode 100644
index 000000000..4dfdb3686
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate_MpegTs.h
@@ -0,0 +1,158 @@
+// File__Duplicate_MpegTs - Duplication of some formats
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef File__Duplicate_MpegTsH
+#define File__Duplicate_MpegTsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Duplicate/File__Duplicate__Base.h"
+#include "MediaInfo/Duplicate/File__Duplicate__Writer.h"
+#include "ZenLib/ZtringListList.h"
+#include <set>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File__Duplicate_MpegTs
+//***************************************************************************
+
+class File__Duplicate_MpegTs : public File__Duplicate__Base
+{
+public :
+ //Constructor/Destructor
+ File__Duplicate_MpegTs(const Ztring &Target);
+
+ //Set
+ bool Configure (const Ztring &Value, bool ToRemove);
+
+ //Write
+ bool Write (int16u PID, const int8u* ToAdd=NULL, size_t ToAdd_Size=0);
+
+ //Output buffer
+ size_t Output_Buffer_Get (unsigned char** Output_Buffer=NULL);
+
+//private :
+ File__Duplicate__Writer Writer;
+
+ //Configuration
+ std::set<int16u> Wanted_program_numbers;
+ std::set<int16u> Wanted_program_map_PIDs;
+ std::set<int16u> Wanted_elementary_PIDs;
+ std::set<int16u> Remove_program_numbers;
+ std::set<int16u> Remove_program_map_PIDs;
+ std::set<int16u> Remove_elementary_PIDs;
+
+ //Current
+ std::vector<int8u> program_map_PIDs;
+ std::vector<int8u> elementary_PIDs;
+ std::vector<int16u> elementary_PIDs_program_map_PIDs;
+
+ struct buffer
+ {
+ int8u* Buffer;
+ size_t Offset;
+ size_t Begin; //After pointer_field
+ size_t End; //Before CRC
+ size_t Size;
+ int8u continuity_counter;
+ int8u version_number;
+ int8u FromTS_version_number_Last;
+ bool ConfigurationHasChanged;
+
+ buffer()
+ {
+ Buffer=NULL;
+ Offset=0;
+ Begin=0;
+ End=0;
+ Size=0;
+ continuity_counter=0xFF;
+ version_number=0xFF;
+ FromTS_version_number_Last=0xFF;
+ ConfigurationHasChanged=true;
+ }
+ ~buffer()
+ {
+ delete[] Buffer; //Buffer=NULL;
+ }
+ };
+
+ struct buffer_const
+ {
+ const int8u* Buffer;
+ size_t Offset;
+ size_t Begin; //After pointer_field
+ size_t End; //Before CRC
+ size_t Size;
+
+ buffer_const()
+ {
+ Buffer=NULL;
+ Offset=0;
+ Begin=0;
+ End=0;
+ Size=0;
+ }
+ };
+
+ struct buffer_big
+ {
+ int8u* Buffer;
+ size_t Buffer_Size;
+ size_t Buffer_Size_Max;
+
+ buffer_big()
+ {
+ Buffer=NULL;
+ Buffer_Size=0;
+ Buffer_Size_Max=0;
+ }
+ ~buffer_big()
+ {
+ delete[] Buffer; //Buffer=NULL;
+ }
+ };
+
+ //Data
+ bool Manage_PAT(const int8u* ToAdd, size_t ToAdd_Size);
+ bool Manage_PMT(const int8u* ToAdd, size_t ToAdd_Size);
+
+ //Buffers
+ buffer_const FromTS;
+ std::map<int16u, buffer> PAT;
+ std::map<int16u, buffer> PMT;
+ std::map<int16u, buffer_big> BigBuffers; //key is pid
+
+ //Helpers
+ bool Parsing_Begin(const int8u* ToAdd, size_t ToAdd_Size, std::map<int16u, buffer> &ToModify);
+ void Parsing_End(std::map<int16u, buffer> &ToModify);
+
+ //Temp
+ int16u StreamID;
+};
+
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Base.cpp b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Base.cpp
new file mode 100644
index 000000000..e513446f6
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Base.cpp
@@ -0,0 +1,51 @@
+// File__Duplicate__Base - Duplication of some formats
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Duplication helper for some specific formats
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+#include "MediaInfo/Duplicate/File__Duplicate__Base.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+File__Duplicate__Base::File__Duplicate__Base ()
+{
+}
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Base.h b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Base.h
new file mode 100644
index 000000000..e9d8043ad
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Base.h
@@ -0,0 +1,51 @@
+// File__Duplicate__Base - Duplication of some formats
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef File__Duplicate__BaseH
+#define File__Duplicate__BaseH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "ZenLib/ZtringListList.h"
+#include <map>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File__Duplicate__Base
+//***************************************************************************
+
+class File__Duplicate__Base
+{
+public :
+ //Constructor/Destructor
+ File__Duplicate__Base();
+ //~File__Duplicate__Base();
+
+};
+
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Writer.cpp b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Writer.cpp
new file mode 100644
index 000000000..fd8a1d196
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Writer.cpp
@@ -0,0 +1,167 @@
+// File__Duplicate__Writer - Duplication of some formats
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Duplication helper for some specific formats
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+#include "MediaInfo/Duplicate/File__Duplicate__Writer.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "ZenLib/ZtringList.h"
+#include "ZenLib/File.h"
+#include <cstring>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File__Duplicate__Writer::File__Duplicate__Writer ()
+{
+ //Out
+ Output_Buffer_Configured=false;
+
+ //Buffer
+ Method=method_none;
+ Buffer=NULL;
+ Buffer_Size=0;
+ Buffer_Size_Max=0;
+ File_Pointer=NULL;
+ Registered_Count=0; //Count of registerd streams
+}
+
+//---------------------------------------------------------------------------
+File__Duplicate__Writer::~File__Duplicate__Writer ()
+{
+ //Buffer
+ delete (File*)File_Pointer; //File_Pointer=NULL
+}
+
+//***************************************************************************
+// Configure
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Duplicate__Writer::Configure (const Ztring &Target)
+{
+ //Form: "memory://pointer:size" <--Memory block is specified by user
+ //WARNING: pointer must be in ***DECIMAL*** format.
+ //Example: "memory://123456789:1316"
+ if (Target.find(_T("memory://"))==0 && Target.find(_T(":"), 9)!=std::string::npos)
+ {
+ size_t SemiColumn_Pos=Target.find(_T(":"), 9);
+ Ztring Address=Target.substr(9, SemiColumn_Pos-9);
+ Ztring Size=Target.substr(SemiColumn_Pos+1);
+ Method=method_buffer;
+ Buffer=(int8u*)Address.To_int64u();
+ Buffer_Size_Max=(size_t)Size.To_int64u();
+ }
+
+ //Form: "file://filename" or <--the exported filename is specified by user
+ else if (Target.find(_T("file://"))==0)
+ {
+ Method=method_filename;
+ File_Name=Target.substr(7, std::string::npos);
+ }
+}
+
+//***************************************************************************
+// Write
+//***************************************************************************
+
+void File__Duplicate__Writer::Write (const int8u* ToAdd, size_t ToAdd_Size)
+{
+ //Integrity
+ if (ToAdd==NULL || ToAdd_Size==0)
+ return;
+
+ //Writing
+ switch (Method)
+ {
+ //File based
+ case method_filename :
+ //Open the file if not yet done
+ if (File_Pointer==NULL)
+ {
+ File_Pointer=new File;
+ ((File*)File_Pointer)->Open(File_Name, File::Access_Write_Append);
+ }
+ //Write to the file
+ ((File*)File_Pointer)->Write(ToAdd, ToAdd_Size);
+ break;
+
+ //Memory based
+ case method_buffer :
+ //Testing if enough place
+ if (Buffer_Size+ToAdd_Size>Buffer_Size_Max)
+ {
+ Buffer_Size=0; //Buffer underrun, cleaning the buffer
+ if (ToAdd_Size>Buffer_Size_Max)
+ ToAdd_Size=0; //Buffer is too small, writing nothing
+ }
+
+ //Copying buffer
+ std::memcpy(Buffer+Buffer_Size, ToAdd, ToAdd_Size);
+ Buffer_Size+=ToAdd_Size;
+ break;
+ default : ;
+ }
+}
+
+//***************************************************************************
+// Output_Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t File__Duplicate__Writer::Output_Buffer_Get ()
+{
+ size_t Output_Buffer_Size=Buffer_Size;
+ Buffer_Size=0; //Can be erased later...
+ return Output_Buffer_Size;
+}
+
+//---------------------------------------------------------------------------
+size_t File__Duplicate__Writer::Output_Buffer_Get (unsigned char** Output_Buffer)
+{
+ if (Output_Buffer)
+ *Output_Buffer=Buffer;
+ size_t Output_Buffer_Size=Buffer_Size;
+ Buffer_Size=0; //Can be erased later...
+ return Output_Buffer_Size;
+}
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Writer.h b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Writer.h
new file mode 100644
index 000000000..22b6580eb
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Duplicate/File__Duplicate__Writer.h
@@ -0,0 +1,81 @@
+// File__Duplicate__Writer - Duplication of some formats
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef File__Duplicate__WriterH
+#define File__Duplicate__WriterH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "ZenLib/ZtringListList.h"
+#include <map>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File__Duplicate__Writer
+//***************************************************************************
+
+class File__Duplicate__Writer
+{
+public :
+ //Constructor/Destructor
+ File__Duplicate__Writer();
+ ~File__Duplicate__Writer();
+
+ //Out
+ bool Output_Buffer_Configured;
+
+ //Configure
+ void Configure (const Ztring &Target);
+ void UnRegister(); //
+
+ //Write
+ void Write (const int8u* ToAdd, size_t ToAdd_Size);
+
+ //Output buffer
+ size_t Output_Buffer_Get ();
+ size_t Output_Buffer_Get (unsigned char** Output_Buffer);
+
+private :
+ //Buffer
+ enum method
+ {
+ method_none,
+ method_buffer,
+ method_filename,
+ };
+ method Method;
+ int8u* Buffer;
+ size_t Buffer_Size;
+ size_t Buffer_Size_Max;
+ Ztring File_Name;
+ void* File_Pointer; //ZenLib::File*
+public :
+ size_t Registered_Count;
+};
+
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Export/Export_Mpeg7.cpp b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_Mpeg7.cpp
new file mode 100644
index 000000000..810c248b8
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_Mpeg7.cpp
@@ -0,0 +1,1563 @@
+// File__Analyze - Base for analyze files
+// Copyright (C) 2009-2011 Jerome Martinez, Zen@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Export/Export_Mpeg7.h"
+#include "MediaInfo/File__Analyse_Automatic.h"
+#include <ctime>
+#ifdef SS
+ #undef SS //Solaris defines this somewhere
+#endif
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const Char* Mpeg7_Type(MediaInfo_Internal &MI) //TO ADAPT
+{
+ if (MI.Count_Get(Stream_Image))
+ {
+ if (MI.Count_Get(Stream_Video) || MI.Count_Get(Stream_Audio))
+ return _T("Multimedia");
+ else
+ return _T("Image");
+ }
+ else if (MI.Count_Get(Stream_Video))
+ {
+ if (MI.Count_Get(Stream_Audio))
+ return _T("AudioVisual");
+ else
+ return _T("Video");
+ }
+ else if (MI.Count_Get(Stream_Audio))
+ return _T("Audio");
+
+ //Not known
+ const Ztring &Format=MI.Get(Stream_General, 0, General_Format);
+ if (Format==_T("AVI") || Format==_T("DV") || Format==_T("MPEG-4") || Format==_T("MPEG-PS") || Format==_T("MPEG-TS") || Format==_T("QuickTime") || Format==_T("Windows Media"))
+ return _T("Video");
+ if (Format==_T("MPEG Audio") || Format==_T("Wave"))
+ return _T("Audio");
+ if (Format==_T("BMP") || Format==_T("GIF") || Format==_T("JPEG") || Format==_T("JPEG 2000") || Format==_T("JPEG 2000") || Format==_T("PNG") || Format==_T("TIFF"))
+ return _T("Image");
+ return _T("Multimedia");
+}
+
+//---------------------------------------------------------------------------
+int32u Mpeg7_ContentCS_termID(MediaInfo_Internal &MI)
+{
+ if (MI.Count_Get(Stream_Image))
+ {
+ if (MI.Count_Get(Stream_Video) || MI.Count_Get(Stream_Audio))
+ return 20000;
+ else
+ return 40100;
+ }
+ else if (MI.Count_Get(Stream_Video))
+ {
+ if (MI.Count_Get(Stream_Audio))
+ return 20000;
+ else
+ return 40200;
+ }
+ else if (MI.Count_Get(Stream_Audio))
+ return 10000;
+
+ //Not known
+ const Ztring &Format=MI.Get(Stream_General, 0, General_Format);
+ if (Format==_T("AVI") || Format==_T("DV") || Format==_T("MPEG-4") || Format==_T("MPEG-PS") || Format==_T("MPEG-TS") || Format==_T("QuickTime") || Format==_T("Windows Media"))
+ return 40200;
+ if (Format==_T("MPEG Audio") || Format==_T("Wave"))
+ return 10000;
+ if (Format==_T("BMP") || Format==_T("GIF") || Format==_T("JPEG") || Format==_T("JPEG 2000") || Format==_T("JPEG 2000") || Format==_T("PNG") || Format==_T("TIFF"))
+ return 40100;
+ return 500000;
+}
+
+Ztring Mpeg7_ContentCS_Name(int32u termID, MediaInfo_Internal &) //xxyyzz: xx=main number, yy=sub-number, zz=sub-sub-number
+{
+ switch (termID/10000)
+ {
+ case 1 : return _T("Audio");
+ case 2 : return _T("Audiovisual");
+ case 3 : return _T("Scene");
+ case 4 : switch ((termID%10000)/100)
+ {
+ case 1 : return _T("Image");
+ case 2 : return _T("Video");
+ case 3 : return _T("Graphics");
+ }
+ case 50 : return Ztring(); //Unknown
+ default : return Ztring();
+ }
+}
+
+//---------------------------------------------------------------------------
+int32u Mpeg7_FileFormatCS_termID_MediaInfo(MediaInfo_Internal &MI)
+{
+ const Ztring &Format=MI.Get(Stream_General, 0, General_Format);
+
+ if (Format==_T("MPEG Audio"))
+ {
+ if (MI.Get(Stream_Audio, 0, Audio_Format_Profile).find(_T("2"))!=string::npos)
+ return 500000; //mp2
+ if (MI.Get(Stream_Audio, 0, Audio_Format_Profile).find(_T("1"))!=string::npos)
+ return 510000; //mp1
+ return 0;
+ }
+ if (Format==_T("Wave") && MI.Get(Stream_General, 0, General_Format_Profile)==_T("RF64"))
+ return 520000; //Wav (RF64)
+ if (Format==_T("Wave64"))
+ return 530000;
+ return 0;
+}
+
+//---------------------------------------------------------------------------
+int32u Mpeg7_FileFormatCS_termID(MediaInfo_Internal &MI)
+{
+ const Ztring &Format=MI.Get(Stream_General, 0, General_Format);
+
+ if (Format==_T("AVI"))
+ return 70000;
+ if (Format==_T("BMP"))
+ return 110000;
+ if (Format==_T("GIF"))
+ return 120000;
+ if (Format==_T("DV"))
+ return 60000;
+ if (Format==_T("JPEG"))
+ return 10000;
+ if (Format==_T("JPEG 2000") || Format==_T("JPEG 2000"))
+ return 20000;
+ if (Format==_T("MPEG Audio"))
+ return (MI.Get(Stream_Audio, 0, Audio_Format_Profile).find(_T("3"))!=string::npos)?40000:0;
+ if (Format==_T("MPEG-4"))
+ return 50000;
+ if (Format==_T("MPEG-PS"))
+ return 30100;
+ if (Format==_T("MPEG-TS"))
+ return 30200;
+ if (Format==_T("PNG"))
+ return 150000;
+ if (Format==_T("QuickTime"))
+ return 160000;
+ if (Format==_T("TIFF"))
+ return 180000;
+ if (Format==_T("Wave"))
+ {
+ if (!MI.Get(Stream_General, 0, General_Format_Profile).empty())
+ return Mpeg7_FileFormatCS_termID_MediaInfo(MI); //Out of specs
+ else
+ return 90000;
+ }
+ if (Format==_T("Windows Media"))
+ return 190000;
+ if (Format==_T("ZIP"))
+ return 100000;
+
+ //Out of specs
+ return Mpeg7_FileFormatCS_termID_MediaInfo(MI);
+}
+
+Ztring Mpeg7_FileFormatCS_Name(int32u termID, MediaInfo_Internal &MI) //xxyyzz: xx=main number, yy=sub-number, zz=sub-sub-number
+{
+ switch (termID/10000)
+ {
+ case 1 : return _T("jpeg");
+ case 2 : return _T("JPEG 2000");
+ case 3 : switch ((termID%10000)/100)
+ {
+ case 1 : return _T("mpeg-ps");
+ case 2 : return _T("mpeg-ts");
+ default: return _T("mpeg");
+ }
+ case 4 : return _T("mp3");
+ case 5 : return _T("mp4");
+ case 6 : return _T("dv");
+ case 7 : return _T("avi");
+ case 8 : return _T("bdf");
+ case 9 : return _T("wav");
+ case 10 : return _T("zip");
+ case 11 : return _T("bmp");
+ case 12 : return _T("gif");
+ case 13 : return _T("photocd");
+ case 14 : return _T("ppm");
+ case 15 : return _T("png");
+ case 16 : return _T("quicktime");
+ case 17 : return _T("spiff");
+ case 18 : return _T("tiff");
+ case 19 : return _T("asf");
+ case 20 : return _T("iff");
+ case 21 : return _T("miff");
+ case 22 : return _T("pcx");
+ //Out of specs --> MediaInfo CS
+ case 50 : return _T("mp1");
+ case 51 : return _T("mp2");
+ case 52 : return _T("wav-rf64");
+ case 53 : return _T("wave64");
+ default : return MI.Get(Stream_General, 0, General_Format);
+ }
+}
+
+//---------------------------------------------------------------------------
+int32u Mpeg7_VisualCodingFormatCS_termID(MediaInfo_Internal &MI, size_t StreamPos)
+{
+ const Ztring &Format=MI.Get(Stream_Video, StreamPos, Video_Format);
+ const Ztring &Version=MI.Get(Stream_Video, StreamPos, Video_Format_Version);
+ const Ztring &Profile=MI.Get(Stream_Video, StreamPos, Video_Format_Profile);
+
+ if (Format==_T("MPEG Video"))
+ {
+ if (Version.find(_T("1"))!=string::npos)
+ return 10000;
+ if (Version.find(_T("2"))!=string::npos)
+ {
+ if (Profile.find(_T("Simple@"))!=string::npos)
+ {
+ if (Profile.find(_T("Main"))!=string::npos)
+ return 20101;
+ return 20100;
+ }
+ if (Profile.find(_T("Main@"))!=string::npos)
+ {
+ if (Profile.find(_T("Low"))!=string::npos)
+ return 20201;
+ if (Profile.find(_T("@Main"))!=string::npos)
+ return 20202;
+ if (Profile.find(_T("High 1440"))!=string::npos)
+ return 20203;
+ if (Profile.find(_T("High"))!=string::npos)
+ return 20204;
+ return 20200;
+ }
+ if (Profile.find(_T("SNR Scalable@"))!=string::npos)
+ {
+ if (Profile.find(_T("Low"))!=string::npos)
+ return 20301;
+ if (Profile.find(_T("Main"))!=string::npos)
+ return 20302;
+ return 20300;
+ }
+ if (Profile.find(_T("Spatial Sclable@"))!=string::npos)
+ {
+ if (Profile.find(_T("Main"))!=string::npos)
+ return 20401;
+ if (Profile.find(_T("High 1440"))!=string::npos)
+ return 20402;
+ if (Profile.find(_T("High"))!=string::npos)
+ return 20403;
+ return 20400;
+ }
+ if (Profile.find(_T("High@"))!=string::npos)
+ {
+ if (Profile.find(_T("Main"))!=string::npos)
+ return 20501;
+ if (Profile.find(_T("High 1440"))!=string::npos)
+ return 20502;
+ if (Profile.find(_T("High"))!=string::npos)
+ return 20503;
+ return 20500;
+ }
+ if (Profile.find(_T("Multi-view@"))!=string::npos)
+ {
+ if (Profile.find(_T("Main"))!=string::npos)
+ return 20601;
+ return 20600;
+ }
+ if (Profile.find(_T("4:2:2@"))!=string::npos)
+ {
+ if (Profile.find(_T("Main"))!=string::npos)
+ return 20701;
+ return 20700;
+ }
+ return 20000;
+ }
+ }
+ if (Format==_T("MPEG-4 Visual"))
+ {
+ if (Profile.find(_T("Simple@"))==0)
+ {
+ if (Profile.find(_T("L0"))!=string::npos)
+ return 30101;
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 30102;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 30103;
+ if (Profile.find(_T("L3"))!=string::npos)
+ return 30104;
+ if (Profile.find(_T("L4"))!=string::npos)
+ return 30105;
+ if (Profile.find(_T("L5"))!=string::npos)
+ return 30106;
+ return 30100;
+ }
+ if (Profile.find(_T("Simple Scalable@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 30201;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 30202;
+ if (Profile.find(_T("L3"))!=string::npos)
+ return 30203;
+ return 30200;
+ }
+ if (Profile.find(_T("Advanced Simple@"))==0)
+ {
+ if (Profile.find(_T("L0"))!=string::npos)
+ return 30301;
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 30302;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 30303;
+ if (Profile.find(_T("L3"))!=string::npos)
+ return 30304;
+ if (Profile.find(_T("L4"))!=string::npos)
+ return 30305;
+ if (Profile.find(_T("L5"))!=string::npos)
+ return 30306;
+ return 30100;
+ }
+ if (Profile.find(_T("Core@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 30401;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 30402;
+ return 30400;
+ }
+ if (Profile.find(_T("Core Scalable@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 30501;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 30502;
+ if (Profile.find(_T("L3"))!=string::npos)
+ return 30503;
+ return 30500;
+ }
+ if (Profile.find(_T("Advanced Core@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 30601;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 30602;
+ return 30600;
+ }
+ if (Profile.find(_T("Main@"))==0)
+ {
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 30701;
+ if (Profile.find(_T("L3"))!=string::npos)
+ return 30702;
+ if (Profile.find(_T("L4"))!=string::npos)
+ return 30703;
+ return 30700;
+ }
+ if (Profile.find(_T("N-bit@"))==0)
+ {
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 30801;
+ return 30800;
+ }
+ if (Profile.find(_T("Advanced Real Time Simple@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 30901;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 30902;
+ if (Profile.find(_T("L3"))!=string::npos)
+ return 30903;
+ if (Profile.find(_T("L4"))!=string::npos)
+ return 30904;
+ return 30900;
+ }
+ if (Profile.find(_T("Advanced Coding Efficiency@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 31001;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 31002;
+ if (Profile.find(_T("L3"))!=string::npos)
+ return 31003;
+ if (Profile.find(_T("L4"))!=string::npos)
+ return 31004;
+ return 31000;
+ }
+ if (Profile.find(_T("Simple Studio@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 31101;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 31102;
+ if (Profile.find(_T("L3"))!=string::npos)
+ return 31103;
+ if (Profile.find(_T("L4"))!=string::npos)
+ return 31104;
+ return 31100;
+ }
+ if (Profile.find(_T("Core Studio@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 31201;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 31202;
+ if (Profile.find(_T("L3"))!=string::npos)
+ return 31203;
+ if (Profile.find(_T("L4"))!=string::npos)
+ return 31204;
+ return 31200;
+ }
+ if (Profile.find(_T("Fine Granularity Scalable@"))==0)
+ {
+ if (Profile.find(_T("L0"))!=string::npos)
+ return 31301;
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 31302;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 31303;
+ if (Profile.find(_T("L3"))!=string::npos)
+ return 31304;
+ if (Profile.find(_T("L4"))!=string::npos)
+ return 31305;
+ if (Profile.find(_T("L5"))!=string::npos)
+ return 31306;
+ return 31300;
+ }
+ if (Profile.find(_T("Simple Face Animation@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 31401;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 31402;
+ return 31400;
+ }
+ if (Profile.find(_T("Simple FBA@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 31501;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 31502;
+ return 31500;
+ }
+ if (Profile.find(_T("Basic Animated Texture@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 31601;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 31602;
+ return 31600;
+ }
+ if (Profile.find(_T("Scalable Texture@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 31701;
+ return 31700;
+ }
+ if (Profile.find(_T("Advanced Scalable Texture@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 31801;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 31802;
+ if (Profile.find(_T("L3"))!=string::npos)
+ return 31803;
+ return 31800;
+ }
+ if (Profile.find(_T("Hybrid@"))==0)
+ {
+ if (Profile.find(_T("L1"))!=string::npos)
+ return 31901;
+ if (Profile.find(_T("L2"))!=string::npos)
+ return 31902;
+ return 31900;
+ }
+ return 30000;
+ }
+ if (Format==_T("JPEG"))
+ return 50000;
+ if (Format==_T("JPEG 2000"))
+ {
+ const Ztring &CodecID=MI.Get(Stream_Video, StreamPos, Video_CodecID);
+ if (CodecID==_T("mjp2"))
+ return 60100;
+ if (CodecID==_T("mjs2"))
+ return 60200;
+ return 60000;
+ }
+ if (Format==_T("H.261"))
+ return 70000;
+ if (Format==_T("H.263"))
+ return 80000;
+
+ return 0;
+}
+
+Ztring Mpeg7_VisualCodingFormatCS_Name(int32u termID, MediaInfo_Internal &MI, size_t StreamPos) //xxyyzz: xx=main number, yy=sub-number, zz=sub-sub-number
+{
+ switch (termID/10000)
+ {
+ case 1 : return _T("MPEG-1 Video");
+ case 2 : switch ((termID%10000)/100)
+ {
+ case 1 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-2 Video Simple Profile @ Main Level");
+ default: return _T("MPEG-2 Video Simple Profile");
+ }
+ case 2 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-2 Video Main Profile @ Low Level");
+ case 2 : return _T("MPEG-2 Video Main Profile @ Main Level");
+ case 3 : return _T("MPEG-2 Video Main Profile @ High 1440 Level");
+ case 4 : return _T("MPEG-2 Video Main Profile @ High Level");
+ default: return _T("MPEG-2 Video Main Profile");
+ }
+ case 3 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-2 Video SNR Scalable Profile @ Low Level");
+ case 2 : return _T("MPEG-2 Video SNR Scalable Profile @ Main Level");
+ default: return _T("MPEG-2 Video SNR Scalable Profile");
+ }
+ case 4 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-2 Video Spatial Scalable Profile @ Main Level");
+ case 2 : return _T("MPEG-2 Video Spatial Scalable Profile @ High 1440 Level");
+ case 3 : return _T("MPEG-2 Video Spatial Scalable Profile @ High Level");
+ default: return _T("MPEG-2 Video Spatial Scalable Profile");
+ }
+ case 5 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-2 Video High Profile @ Main Level");
+ case 2 : return _T("MPEG-2 Video High Profile @ High 1440 Level");
+ case 3 : return _T("MPEG-2 Video High Profile @ High Level");
+ default: return _T("MPEG-2 Video High Profile");
+ }
+ case 6 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-2 Video Multiview Profile @ Main Level");
+ default: return _T("MPEG-2 Video Multiview Profile");
+ }
+ case 7 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-2 Video 4:2:2 Profile @ Main Level");
+ default: return _T("MPEG-2 Video 4:2:2 Profile");
+ }
+ default: return _T("MPEG-2 Video");
+ }
+ case 3 : switch ((termID%10000)/100)
+ {
+ case 1 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Simple Profile @ Level 0");
+ case 2 : return _T("MPEG-4 Visual Simple Profile @ Level 1");
+ case 3 : return _T("MPEG-4 Visual Simple Profile @ Level 2");
+ case 4 : return _T("MPEG-4 Visual Simple Profile @ Level 3");
+ default: return _T("MPEG-4 Visual Simple Profile");
+ }
+ case 2 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Simple Scalable Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Visual Simple Scalable Profile @ Level 2");
+ default: return _T("MPEG-4 Visual Simple Scalable Profile");
+ }
+ case 3 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Advanced Visual Simple Profile @ Level 0");
+ case 2 : return _T("MPEG-4 Advanced Visual Simple Profile @ Level 1");
+ case 3 : return _T("MPEG-4 Advanced Visual Simple Profile @ Level 2");
+ case 4 : return _T("MPEG-4 Advanced Visual Simple Profile @ Level 3");
+ case 5 : return _T("MPEG-4 Advanced Visual Simple Profile @ Level 4");
+ case 6 : return _T("MPEG-4 Advanced Visual Simple Profile @ Level 5");
+ default: return _T("MPEG-4 Advanced Visual Simple Profile");
+ }
+ case 4 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Core Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Visual Core Profile @ Level 2");
+ default: return _T("MPEG-4 Visual Core Profile");
+ }
+ case 5 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Core-Scalable Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Visual Core-Scalable Profile @ Level 2");
+ case 3 : return _T("MPEG-4 Visual Core-Scalable Profile @ Level 3");
+ default: return _T("MPEG-4 Visual Core-Scalable Profile");
+ }
+ case 6 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual AdvancedCore Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Visual AdvancedCore Profile @ Level 2");
+ default: return _T("MPEG-4 Visual AdvancedCore Profile");
+ }
+ case 7 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Main Profile @ Level 2");
+ case 2 : return _T("MPEG-4 Visual Main Profile @ Level 3");
+ case 3 : return _T("MPEG-4 Visual Main Profile @ Level 4");
+ default: return _T("MPEG-4 Visual Main Profile");
+ }
+ case 8 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual N-bit Profile @ Level 2");
+ default: return _T("MPEG-4 Visual Main Profile");
+ }
+ case 9 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Advanced Real Time Simple Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Visual Advanced Real Time Simple Profile @ Level 2");
+ case 3 : return _T("MPEG-4 Visual Advanced Real Time Simple Profile @ Level 3");
+ case 4 : return _T("MPEG-4 Visual Advanced Real Time Simple Profile @ Level 4");
+ default: return _T("MPEG-4 Visual Advanced Real Time Simple Profile");
+ }
+ case 10 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Advanced Coding Efficiency Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Visual Advanced Coding Efficiency Profile @ Level 2");
+ case 3 : return _T("MPEG-4 Visual Advanced Coding Efficiency Profile @ Level 3");
+ case 4 : return _T("MPEG-4 Visual Advanced Coding Efficiency Profile @ Level 4");
+ default: return _T("MPEG-4 Visual Advanced Coding Efficiency Profile");
+ }
+ case 11 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Simple Studio Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Visual Simple Studio Profile @ Level 2");
+ case 3 : return _T("MPEG-4 Visual Simple Studio Profile @ Level 3");
+ case 4 : return _T("MPEG-4 Visual Simple Studio Profile @ Level 4");
+ default: return _T("MPEG-4 Visual Simple Studio Profile");
+ }
+ case 12 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Core Studio Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Visual Core Studio Profile @ Level 2");
+ case 3 : return _T("MPEG-4 Visual Core Studio Profile @ Level 3");
+ case 4 : return _T("MPEG-4 Visual Core Studio Profile @ Level 4");
+ default: return _T("MPEG-4 Visual Core Studio Profile");
+ }
+ case 13 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Fine Granularity Scalable Profile @ Level 0");
+ case 2 : return _T("MPEG-4 Visual Fine Granularity Scalable Profile @ Level 1");
+ case 3 : return _T("MPEG-4 Visual Fine Granularity Scalable Profile @ Level 2");
+ case 4 : return _T("MPEG-4 Visual Fine Granularity Scalable Profile @ Level 3");
+ case 5 : return _T("MPEG-4 Visual Fine Granularity Scalable Profile @ Level 4");
+ case 6 : return _T("MPEG-4 Visual Fine Granularity Scalable Profile @ Level 5");
+ default: return _T("MPEG-4 Visual Fine Granularity Scalable Profile");
+ }
+ case 14 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Simple Face Animation Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Simple Face Animation Profile @ Level 2");
+ default: return _T("MPEG-4 Simple Face Animation Profile");
+ }
+ case 15 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Simple FBA Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Simple FBA Profile @ Level 2");
+ default: return _T("MPEG-4 Simple FBA Profile");
+ }
+ case 16 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Basic Animated Texture Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Basic Animated Texture Profile @ Level 2");
+ default: return _T("MPEG-4 Basic Animated Texture Profile");
+ }
+ case 17 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Advanced Scalable Texture Profile @ Level 1");
+ default: return _T("MPEG-4 Advanced Scalable Texture Profile");
+ }
+ case 18 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Advanced Scalable Texture Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Visual Advanced Scalable Texture Profile @ Level 2");
+ case 3 : return _T("MPEG-4 Visual Advanced Scalable Texture Profile @ Level 3");
+ default: return _T("MPEG-4 Visual Advanced Scalable Texture Profile");
+ }
+ case 19 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-4 Visual Hybrid Profile @ Level 1");
+ case 2 : return _T("MPEG-4 Visual Hybrid Profile @ Level 2");
+ default: return _T("MPEG-4 Visual Hybrid Profile");
+ }
+ default: return _T("MPEG-4 Visual");
+ }
+ case 4 : return _T("JPEG");
+ case 5 : return _T("MJPEG");
+ case 6 : return _T("JPEG2000");
+ case 7 : return _T("H261");
+ case 8 : return _T("H263");
+ default: return MI.Get(Stream_Video, StreamPos, Video_Format);
+ }
+}
+
+//---------------------------------------------------------------------------
+Ztring Mpeg7_Visual_colorDomain(MediaInfo_Internal &MI, size_t StreamPos)
+{
+ const Ztring &Colorimetry=MI.Get(Stream_Video, StreamPos, Video_Colorimetry);
+ if (Colorimetry.find(_T("4:"))!=string::npos)
+ return _T(" colorDomain=\"color\"");
+ if (Colorimetry==_T("Gray"))
+ return _T(" colorDomain=\"graylevel\"");
+ return _T("");
+}
+
+//---------------------------------------------------------------------------
+int32u Mpeg7_SystemCS_termID(MediaInfo_Internal &MI, size_t StreamPos)
+{
+ if (MI.Get(Stream_Video, StreamPos, Video_Standard)==_T("PAL"))
+ return 10000;
+ if (MI.Get(Stream_Video, StreamPos, Video_Standard)==_T("SECAM"))
+ return 20000;
+ if (MI.Get(Stream_Video, StreamPos, Video_Standard)==_T("NTSC"))
+ return 30000;
+ return 0;
+}
+
+Ztring Mpeg7_SystemCS_Name(int32u termID) //xxyyzz: xx=main number, yy=sub-number, zz=sub-sub-number
+{
+ switch (termID/10000)
+ {
+ case 1 : return _T("PAL");
+ case 2 : return _T("SECAM");
+ case 3 : return _T("NTSC");
+ default : return Ztring();
+ }
+}
+
+//---------------------------------------------------------------------------
+int32u Mpeg7_AudioCodingFormatCS_termID(MediaInfo_Internal &MI, size_t StreamPos)
+{
+ const Ztring &Format=MI.Get(Stream_Audio, StreamPos, Audio_Format);
+ const Ztring &Version=MI.Get(Stream_Audio, StreamPos, Audio_Format_Version);
+ const Ztring &Profile=MI.Get(Stream_Audio, StreamPos, Audio_Format_Profile);
+
+ if (Format==_T("AC-3"))
+ return 10000;
+ if (Format==_T("DTS"))
+ return 20000;
+ if (Format==_T("MPEG Audio"))
+ {
+ if (Version.find(_T("1"))!=string::npos)
+ {
+ if (Profile.find(_T("1"))!=string::npos)
+ return 30100;
+ if (Profile.find(_T("2"))!=string::npos)
+ return 30200;
+ if (Profile.find(_T("3"))!=string::npos)
+ return 30300;
+ return 30000;
+ }
+ if (Version.find(_T("2"))!=string::npos)
+ {
+ if (Profile.find(_T("1"))!=string::npos)
+ return 40100;
+ if (Profile.find(_T("2"))!=string::npos)
+ return 40200;
+ if (Profile.find(_T("3"))!=string::npos)
+ return 40300;
+ return 40000;
+ }
+ return 0;
+ }
+ if (Format==_T("PCM"))
+ return 80000;
+
+ return 0;
+}
+
+Ztring Mpeg7_AudioCodingFormatCS_Name(int32u termID, MediaInfo_Internal &MI, size_t StreamPos) //xxyyzz: xx=main number, yy=sub-number, zz=sub-sub-number
+{
+ switch (termID/10000)
+ {
+ case 1 : return _T("AC3");
+ case 2 : return _T("DTS");
+ case 3 : switch ((termID%10000)/100)
+ {
+ case 1 : return _T("MPEG-1 Audio Layer I");
+ case 2 : return _T("MPEG-1 Audio Layer II");
+ case 3 : return _T("MPEG-1 Audio Layer III");
+ default: return _T("MPEG-1 Audio");
+ }
+ case 4 : switch ((termID%10000)/100)
+ {
+ case 1 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-2 Audio Low Sampling Rate Layer I");
+ case 2 : return _T("MPEG-2 Audio Low Sampling Rate Layer II");
+ case 3 : return _T("MPEG-2 Audio Low Sampling Rate Layer III");
+ default: return _T("MPEG-2 Audio Low Sampling Rate");
+ }
+ case 2 : switch (termID%100)
+ {
+ case 1 : return _T("MPEG-2 Backward Compatible Multi-Channel Layer I");
+ case 2 : return _T("MPEG-2 Backward Compatible Multi-Channel Layer II");
+ case 3 : return _T("MPEG-2 Backward Compatible Multi-Channel Layer III");
+ default: return _T("MPEG-2 Backward Compatible Multi-Channel");
+ }
+ default: return _T("MPEG-2 Audio");
+ }
+ case 8 : return _T("Linear PCM");
+ default: return MI.Get(Stream_Audio, StreamPos, Video_Format);
+ }
+}
+
+//---------------------------------------------------------------------------
+int32u Mpeg7_AudioPresentationCS_termID(MediaInfo_Internal &MI, size_t StreamPos)
+{
+ const Ztring &Channels=MI.Get(Stream_Audio, StreamPos, Audio_Channel_s_);
+ const Ztring &ChannelPositions2=MI.Get(Stream_Audio, StreamPos, Audio_ChannelPositions_String2);
+ if (Channels==_T("6") && ChannelPositions2==_T("3/2.1"))
+ return 50000;
+ if (Channels==_T("8") && ChannelPositions2==_T("3/2/2.1"))
+ return 60000;
+ if (Channels==_T("2"))
+ return 30000;
+ if (Channels==_T("1"))
+ return 20000;
+ return 0;
+}
+
+Ztring Mpeg7_AudioPresentationCS_Name(int32u termID, MediaInfo_Internal &, size_t)
+{
+ switch (termID/10000)
+ {
+ case 2 : return _T("mono");
+ case 3 : return _T("stereo");
+ case 5 : return _T("Home theater 5.1");
+ case 6 : return _T("Movie theater");
+ default: return Ztring();
+ }
+}
+
+//---------------------------------------------------------------------------
+Ztring Mpeg7_AudioEmphasis(MediaInfo_Internal &MI, size_t StreamPos)
+{
+ const Ztring &Emphasis=MI.Get(Stream_Audio, StreamPos, Audio_Format_Settings_Emphasis);
+ if (Emphasis==_T("50/15ms"))
+ return _T("50over15Microseconds");
+ if (Emphasis==_T("CCITT"))
+ return _T("ccittJ17");
+ if (Emphasis==_T("Reserved"))
+ return _T("reserved");
+ return _T("none");
+}
+
+//---------------------------------------------------------------------------
+Ztring Mpeg7_MediaTimePoint(MediaInfo_Internal &MI)
+{
+ if (MI.Count_Get(Stream_Video)==1 && MI.Get(Stream_General, 0, General_Format)==_T("MPEG-PS"))
+ {
+ int64u Delay=(int64u)(MI.Get(Stream_Video, 0, Video_Delay).To_float64()*90);
+ int64u Rate=90000;
+ int64u DD=Delay/(24*60*60*Rate);
+ Delay=Delay%(24*60*60*Rate);
+ int64u HH=Delay/(60*60*Rate);
+ Delay=Delay%(60*60*Rate);
+ int64u MM=Delay/(60*Rate);
+ Delay=Delay%(60*Rate);
+ int64u SS=Delay/Rate;
+ Delay=Delay%Rate;
+ Ztring ToReturn;
+ if (DD)
+ ToReturn+=Ztring::ToZtring(DD);
+ ToReturn+=_T('T');
+ ToReturn+=(HH<10?_T("0"):_T(""))+Ztring::ToZtring(HH)+_T(':');
+ ToReturn+=(MM<10?_T("0"):_T(""))+Ztring::ToZtring(MM)+_T(':');
+ ToReturn+=(SS<10?_T("0"):_T(""))+Ztring::ToZtring(SS)+_T(':');
+ ToReturn+=Ztring::ToZtring(Delay)+_T('F');
+ ToReturn+=Ztring::ToZtring(Rate);
+ return ToReturn;
+ }
+
+ //Default: In milliseconds
+ int64u Milliseconds=MI.Get(Stream_Video, 0, Video_Delay).To_int64u();
+ int64u DD=Milliseconds/(24*60*60*1000);
+ Milliseconds=Milliseconds%(24*60*60*1000);
+ int64u HH=Milliseconds/(60*60*1000);
+ Milliseconds=Milliseconds%(60*60*1000);
+ int64u MM=Milliseconds/(60*1000);
+ Milliseconds=Milliseconds%(60*1000);
+ int64u SS=Milliseconds/1000;
+ int64u NN=Milliseconds%1000;
+ int64u FF=1000;
+ Ztring ToReturn;
+ if (DD)
+ ToReturn+=Ztring::ToZtring(DD);
+ ToReturn+=_T('T');
+ ToReturn+=(HH<10?_T("0"):_T(""))+Ztring::ToZtring(HH)+_T(':');
+ ToReturn+=(MM<10?_T("0"):_T(""))+Ztring::ToZtring(MM)+_T(':');
+ ToReturn+=(SS<10?_T("0"):_T(""))+Ztring::ToZtring(SS)+_T(':');
+ ToReturn+=Ztring::ToZtring(NN)+_T('F');
+ ToReturn+=Ztring::ToZtring(FF);
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+Ztring Mpeg7_MediaDuration(MediaInfo_Internal &MI)
+{
+ if (MI.Count_Get(Stream_Video)==1)
+ {
+ int64u FrameCount=MI.Get(Stream_Video, 0, Video_FrameCount).To_int64u();
+ int64u FrameRate=MI.Get(Stream_Video, 0, Video_FrameRate).To_int64u();
+ if (FrameRate==0)
+ return Ztring();
+ int64u DD=FrameCount/(24*60*60*FrameRate);
+ FrameCount=FrameCount%(24*60*60*FrameRate);
+ int64u HH=FrameCount/(60*60*FrameRate);
+ FrameCount=FrameCount%(60*60*FrameRate);
+ int64u MM=FrameCount/(60*FrameRate);
+ FrameCount=FrameCount%(60*FrameRate);
+ int64u SS=FrameCount/FrameRate;
+ FrameCount=FrameCount%FrameRate;
+ Ztring ToReturn;
+ ToReturn+=_T('P');
+ if (DD)
+ ToReturn+=Ztring::ToZtring(DD)+_T('D');
+ ToReturn+=_T('T');
+ ToReturn+=Ztring::ToZtring(HH)+_T('H');
+ ToReturn+=Ztring::ToZtring(MM)+_T('M');
+ ToReturn+=Ztring::ToZtring(SS)+_T('S');
+ ToReturn+=Ztring::ToZtring(FrameCount)+_T('N');
+ ToReturn+=Ztring::ToZtring(FrameRate)+_T('F');
+ return ToReturn;
+ }
+
+ if (MI.Count_Get(Stream_Audio)==1)
+ {
+ int64u SamplingCount=MI.Get(Stream_Audio, 0, Audio_SamplingCount).To_int64u();
+ int64u SamplingRate=MI.Get(Stream_Audio, 0, Audio_SamplingRate).To_int64u();
+ if (SamplingRate==0)
+ return Ztring();
+ int64u DD=SamplingCount/(24*60*60*SamplingRate);
+ SamplingCount=SamplingCount%(24*60*60*SamplingRate);
+ int64u HH=SamplingCount/(60*60*SamplingRate);
+ SamplingCount=SamplingCount%(60*60*SamplingRate);
+ int64u MM=SamplingCount/(60*SamplingRate);
+ SamplingCount=SamplingCount%(60*SamplingRate);
+ int64u SS=SamplingCount/SamplingRate;
+ SamplingCount=SamplingCount%SamplingRate;
+ Ztring ToReturn;
+ ToReturn+=_T('P');
+ if (DD)
+ ToReturn+=Ztring::ToZtring(DD)+_T('D');
+ ToReturn+=_T('T');
+ ToReturn+=Ztring::ToZtring(HH)+_T('H');
+ ToReturn+=Ztring::ToZtring(MM)+_T('M');
+ ToReturn+=Ztring::ToZtring(SS)+_T('S');
+ ToReturn+=Ztring::ToZtring(SamplingCount)+_T('N');
+ ToReturn+=Ztring::ToZtring(SamplingRate)+_T('F');
+ return ToReturn;
+ }
+
+ //Default: In milliseconds
+ int64u Milliseconds=MI.Get(Stream_General, 0, General_Duration).To_int64u();
+ int64u DD=Milliseconds/(24*60*60*1000);
+ Milliseconds=Milliseconds%(24*60*60*1000);
+ int64u HH=Milliseconds/(60*60*1000);
+ Milliseconds=Milliseconds%(60*60*1000);
+ int64u MM=Milliseconds/(60*1000);
+ Milliseconds=Milliseconds%(60*1000);
+ int64u SS=Milliseconds/1000;
+ int64u NN=Milliseconds%1000;
+ int64u FF=1000;
+ Ztring ToReturn;
+ ToReturn+=_T('P');
+ if (DD)
+ ToReturn+=Ztring::ToZtring(DD)+_T('D');
+ ToReturn+=_T('T');
+ ToReturn+=Ztring::ToZtring(HH)+_T('H');
+ ToReturn+=Ztring::ToZtring(MM)+_T('M');
+ ToReturn+=Ztring::ToZtring(SS)+_T('S');
+ ToReturn+=Ztring::ToZtring(NN)+_T('N');
+ ToReturn+=Ztring::ToZtring(FF)+_T('F');
+ return ToReturn;
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Export_Mpeg7::Export_Mpeg7 ()
+{
+}
+
+//---------------------------------------------------------------------------
+Export_Mpeg7::~Export_Mpeg7 ()
+{
+}
+
+//***************************************************************************
+// Input
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Ztring Mpeg7_Transform_Visual(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos)
+{
+ ToReturn+=_T("\t\t\t\t\t\t\t<mpeg7:VisualCoding>\n");
+
+ //Format
+ ToReturn+=_T("\t\t\t\t\t\t\t\t<mpeg7:Format");
+ int32u VisualCodingFormatCS_termID=Mpeg7_VisualCodingFormatCS_termID(MI, StreamPos);
+ if (VisualCodingFormatCS_termID)
+ {
+ ToReturn+=_T(" href=\"urn:mpeg:mpeg7:cs:VisualCodingFormatCS:2001:");
+ ToReturn+=Ztring::ToZtring(VisualCodingFormatCS_termID/10000);
+ ToReturn+=_T("\"");
+ }
+ ToReturn+=Mpeg7_Visual_colorDomain(MI, StreamPos); //Algo puts empty string if not known
+ ToReturn+=_T(">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t<mpeg7:Name xml:lang=\"en\">"); ToReturn+=Mpeg7_VisualCodingFormatCS_Name((VisualCodingFormatCS_termID/10000)*10000, MI, StreamPos); ToReturn+=_T("</mpeg7:Name>\n");
+ if (VisualCodingFormatCS_termID%10000)
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t<mpeg7:Term termID=\"");
+ ToReturn+=Ztring::ToZtring(VisualCodingFormatCS_termID/10000);
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring((VisualCodingFormatCS_termID%10000)/100);
+ ToReturn+=_T("\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Name xml:lang=\"en\">"); ToReturn+=Mpeg7_VisualCodingFormatCS_Name((VisualCodingFormatCS_termID/100)*100, MI, StreamPos); ToReturn+=_T("</mpeg7:Name>\n");
+ if (VisualCodingFormatCS_termID%100)
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Term termID=\"");
+ ToReturn+=Ztring::ToZtring(VisualCodingFormatCS_termID/10000);
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring((VisualCodingFormatCS_termID%10000)/100);
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring(VisualCodingFormatCS_termID%100);
+ ToReturn+=_T("\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Name xml:lang=\"en\">"); ToReturn+=Mpeg7_VisualCodingFormatCS_Name(VisualCodingFormatCS_termID, MI, StreamPos); ToReturn+=_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t</mpeg7:Term>\n");
+ }
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t</mpeg7:Term>\n");
+ }
+ ToReturn+=_T("\t\t\t\t\t\t\t\t</mpeg7:Format>\n");
+
+ //Pixel
+ if (!MI.Get(Stream_Video, 0, Video_PixelAspectRatio).empty()
+ || !MI.Get(Stream_Video, 0, Video_Resolution).empty())
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t\t<mpeg7:Pixel");
+ if (!MI.Get(Stream_Video, 0, Video_PixelAspectRatio).empty())
+ {
+ ToReturn+=_T(" aspectRatio=\"");
+ ToReturn+=MI.Get(Stream_Video, 0, Video_PixelAspectRatio);
+ ToReturn+=_T("\"");
+ }
+ if (!MI.Get(Stream_Video, 0, Video_Resolution).empty())
+ {
+ ToReturn+=_T(" bitsPer=\"");
+ ToReturn+=MI.Get(Stream_Video, 0, Video_Resolution);
+ ToReturn+=_T("\"");
+ }
+ ToReturn+=_T("/>\n");
+ }
+
+ //Frame
+ ToReturn+=_T("\t\t\t\t\t\t\t\t<mpeg7:Frame aspectRatio=\"")+MI.Get(Stream_Video, 0, Video_DisplayAspectRatio); ToReturn+=_T("\" height=\""); ToReturn+=MI.Get(Stream_Video, 0, Video_Height); ToReturn+=_T("\" width=\""); ToReturn+=MI.Get(Stream_Video, 0, Video_Width); ToReturn+=_T("\" rate=\""); ToReturn+=MI.Get(Stream_Video, 0, Video_FrameRate); ToReturn+=_T("\" structure=\""); ToReturn+=MI.Get(Stream_Video, 0, Video_ScanType).MakeLowerCase(); ToReturn+=_T("\"/>\n");
+
+ //Colorimetry
+ if (MI.Get(Stream_Video, StreamPos, Video_Colorimetry).find(_T("4:2:0"))!=string::npos)
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t\t<mpeg7:ColorSampling> <!-- YUV 4:2:0 Interlaced -->\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t<mpeg7:Lattice height=\"720\" width=\"486\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t<mpeg7:Field temporalOrder=\"0\" positionalOrder=\"0\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Name>Luminance</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Offset horizontal=\"0.0\" vertical=\"0.0\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Period horizontal=\"1.0\" vertical=\"2.0\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t</mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Name>ChrominanceBlueDifference</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Offset horizontal=\"0.0\" vertical=\"0.5\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Period horizontal=\"2.0\" vertical=\"4.0\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t</mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Name>ChrominanceRedDifference</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Offset horizontal=\"0.0\" vertical=\"0.5\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Period horizontal=\"2.0\" vertical=\"4.0\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t</mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t</mpeg7:Field>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t<mpeg7:Field temporalOrder=\"1\" positionalOrder=\"1\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Name>Luminance</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Offset horizontal=\"0.0\" vertical=\"1.0\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Period horizontal=\"1.0\" vertical=\"2.0\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t</mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Name>ChrominanceBlueDifference</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Offset horizontal=\"0.0\" vertical=\"2.5\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Period horizontal=\"2.0\" vertical=\"4.0\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t</mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Name>ChrominanceRedDifference</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Offset horizontal=\"0.0\" vertical=\"2.5\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Period horizontal=\"4.0\" vertical=\"2.0\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t</mpeg7:Component>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t</mpeg7:Field>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t</mpeg7:ColorSampling>\n");
+ }
+
+ ToReturn+=_T("\t\t\t\t\t\t\t</mpeg7:VisualCoding>\n");
+
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+Ztring Mpeg7_Transform_Audio(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos)
+{
+ ToReturn+=_T("\t\t\t\t\t\t\t<mpeg7:AudioCoding>\n");
+
+ //Format
+ ToReturn+=_T("\t\t\t\t\t\t\t\t<mpeg7:Format");
+ int32u AudioCodingFormatCS_termID=Mpeg7_AudioCodingFormatCS_termID(MI, StreamPos);
+ if (AudioCodingFormatCS_termID)
+ {
+ ToReturn+=_T(" href=\"urn:mpeg:mpeg7:cs:AudioCodingFormatCS:2001:");
+ ToReturn+=Ztring::ToZtring(AudioCodingFormatCS_termID/10000);
+ ToReturn+=_T("\"");
+ }
+ ToReturn+=_T(">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t<mpeg7:Name xml:lang=\"en\">"); ToReturn+=Mpeg7_AudioCodingFormatCS_Name((AudioCodingFormatCS_termID/10000)*10000, MI, StreamPos); ToReturn+=_T("</mpeg7:Name>\n");
+ if (AudioCodingFormatCS_termID%10000)
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t<mpeg7:Term termID=\"");
+ ToReturn+=Ztring::ToZtring(AudioCodingFormatCS_termID/10000);
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring((AudioCodingFormatCS_termID%10000)/100);
+ ToReturn+=_T("\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Name xml:lang=\"en\">"); ToReturn+=Mpeg7_AudioCodingFormatCS_Name((AudioCodingFormatCS_termID/100)*100, MI, StreamPos); ToReturn+=_T("</mpeg7:Name>\n");
+ if (AudioCodingFormatCS_termID%100)
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Term termID=\"");
+ ToReturn+=Ztring::ToZtring(AudioCodingFormatCS_termID/10000);
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring((AudioCodingFormatCS_termID%10000)/100);
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring(AudioCodingFormatCS_termID%100);
+ ToReturn+=_T("\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Name xml:lang=\"en\">"); ToReturn+=Mpeg7_AudioCodingFormatCS_Name(AudioCodingFormatCS_termID, MI, StreamPos); ToReturn+=_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t</mpeg7:Term>\n");
+ }
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t</mpeg7:Term>\n");
+ }
+ ToReturn+=_T("\t\t\t\t\t\t\t\t</mpeg7:Format>\n");
+
+ //AudioChannels
+ ToReturn+=_T("\t\t\t\t\t\t\t\t<mpeg7:AudioChannels>"); ToReturn+=MI.Get(Stream_Audio, StreamPos, Audio_Channel_s_); ToReturn+=_T("</mpeg7:AudioChannels>\n");
+
+ //Sample
+ ToReturn+=_T("\t\t\t\t\t\t\t\t<mpeg7:Sample rate=\""); ToReturn+=MI.Get(Stream_Audio, StreamPos, Audio_SamplingRate); ToReturn+=_T("\""); if (!MI.Get(Stream_Audio, StreamPos, Audio_BitDepth).empty()) {ToReturn+=_T(" bitsPer=\""); ToReturn+=MI.Get(Stream_Audio, StreamPos, Audio_BitDepth); ToReturn+=_T("\"");} ToReturn+=_T("/>\n");
+
+ //Emphasis
+ if (MI.Get(Stream_Audio, StreamPos, Audio_Format)==_T("MPEG Audio"))
+ ToReturn+=_T("\t\t\t\t\t\t\t\t<mpeg7:Emphasis>")+Mpeg7_AudioEmphasis(MI, StreamPos)+_T("</mpeg7:Emphasis>\n");
+
+ //Presentation
+ int32u AudioPresentationCS_termID=Mpeg7_AudioPresentationCS_termID(MI, StreamPos);
+ if (AudioPresentationCS_termID)
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t\t<mpeg7:Presentation href=\"urn:mpeg:mpeg7:cs:AudioPresentationCS:2001:");
+ ToReturn+=Ztring::ToZtring(AudioPresentationCS_termID/10000);
+ if (AudioPresentationCS_termID%10000)
+ {
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring((AudioPresentationCS_termID%10000)/100);
+ if (AudioPresentationCS_termID%100)
+ {
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring(AudioPresentationCS_termID%100);
+ }
+ }
+ ToReturn+=_T("\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t<mpeg7:Name>")+Mpeg7_AudioPresentationCS_Name(AudioPresentationCS_termID, MI, StreamPos)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t</mpeg7:Presentation>\n");
+ }
+
+ ToReturn+=_T("\t\t\t\t\t\t\t</mpeg7:AudioCoding>\n");
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+Ztring Export_Mpeg7::Transform(MediaInfo_Internal &MI)
+{
+ //Current date/time is ISO format
+ time_t Time=time(NULL);
+ Ztring TimeS; TimeS.Date_From_Seconds_1970((int32u)Time);
+ TimeS.FindAndReplace(_T("UTC "), _T(""));
+ TimeS.FindAndReplace(_T(" "), _T("T"));
+ TimeS+=_T("+00:00");
+
+ Ztring ToReturn;
+
+ //Mpeg7
+ ToReturn+=_T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ ToReturn+=_T("<!-- Generated at ")+TimeS+_T(" by ")+MediaInfoLib::Config.Info_Version_Get()+_T(" -->\n");
+ ToReturn+=_T("<mpeg7:Mpeg7 xmlns=\"urn:mpeg:mpeg7:schema:2004\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:mpeg7=\"urn:mpeg:mpeg7:schema:2004\" xsi:schemaLocation=\"urn:mpeg:mpeg7:schema:2004 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-7_schema_files/mpeg7-v2.xsd\">\n");
+
+ //Description - DescriptionMetadata
+ {
+ ToReturn+=_T("\t<mpeg7:DescriptionMetadata>\n");
+ Ztring FileName=MI.Get(Stream_General, 0, General_FileName);
+ Ztring Extension=MI.Get(Stream_General, 0, General_FileExtension);
+ if (!Extension.empty())
+ FileName+=_T('.')+Extension;
+ if (!FileName.empty())
+ ToReturn+=_T("\t\t<mpeg7:PrivateIdentifier>")+FileName+_T("</mpeg7:PrivateIdentifier>\n");
+ ToReturn+=_T("\t\t<mpeg7:CreationTime>")+TimeS+_T("</mpeg7:CreationTime>\n");
+ ToReturn+=_T("\t\t<mpeg7:Instrument>\n");
+ ToReturn+=_T("\t\t\t<mpeg7:Tool>\n");
+ ToReturn+=_T("\t\t\t\t<mpeg7:Name>")+MediaInfoLib::Config.Info_Version_Get()+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t</mpeg7:Tool>\n");
+ ToReturn+=_T("\t\t</mpeg7:Instrument>\n");
+ ToReturn+=_T("\t</mpeg7:DescriptionMetadata>\n");
+ }
+
+ //Description - CreationDescription
+ if (!MI.Get(Stream_General, 0, General_Movie).empty()
+ || !MI.Get(Stream_General, 0, General_Track).empty()
+ || !MI.Get(Stream_General, 0, General_Album).empty()
+ || !MI.Get(Stream_General, 0, General_Encoded_Library).empty()
+ || !MI.Get(Stream_General, 0, General_Performer).empty())
+ {
+ ToReturn+=_T("\t<mpeg7:Description xsi:type=\"CreationDescriptionType\">\n");
+ ToReturn+=_T("\t\t<mpeg7:CreationInformation>\n");
+ ToReturn+=_T("\t\t\t<mpeg7:Creation>\n");
+ if (!MI.Get(Stream_General, 0, General_Movie).empty())
+ ToReturn+=_T("\t\t\t\t<mpeg7:Title type=\"songTitle\">")+MI.Get(Stream_General, 0, General_Movie)+_T("</mpeg7:Title>\n");
+ if (!MI.Get(Stream_General, 0, General_Track).empty())
+ ToReturn+=_T("\t\t\t\t<mpeg7:Title type=\"songTitle\">")+MI.Get(Stream_General, 0, General_Title)+_T("</mpeg7:Title>\n");
+ if (!MI.Get(Stream_General, 0, General_Album).empty())
+ ToReturn+=_T("\t\t\t\t<mpeg7:Title type=\"albumTitle\">")+MI.Get(Stream_General, 0, General_Album)+_T("</mpeg7:Title>\n");
+ if (!MI.Get(Stream_General, 0, General_WrittenBy).empty())
+ {
+ ToReturn+=_T("\t\t\t\t<mpeg7:Creator>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Role href=\"urn:mpeg:mpeg7:cs:RoleCS:2001:AUTHOR\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Agent xsi:type=\"PersonGroupType\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:Name>")+MI.Get(Stream_General, 0, General_WrittenBy)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:Agent>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:Creator>\n");
+ }
+ if (!MI.Get(Stream_General, 0, General_Performer).empty())
+ {
+ ToReturn+=_T("\t\t\t\t<mpeg7:Creator>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Role href=\"urn:mpeg:mpeg7:cs:RoleCS:2001:PERFORMER\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Agent xsi:type=\"PersonGroupType\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:Name>")+MI.Get(Stream_General, 0, General_Performer)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:Agent>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:Creator>\n");
+ }
+ if (!MI.Get(Stream_General, 0, General_ExecutiveProducer).empty())
+ {
+ ToReturn+=_T("\t\t\t\t<mpeg7:Creator>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Role href=\"urn:mpeg:mpeg7:cs:RoleCS:2001:EXECUTIVE-PRODUCER\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Agent xsi:type=\"PersonGroupType\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:Name>")+MI.Get(Stream_General, 0, General_ExecutiveProducer)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:Agent>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:Creator>\n");
+ }
+ if (!MI.Get(Stream_General, 0, General_Producer).empty())
+ {
+ ToReturn+=_T("\t\t\t\t<mpeg7:Creator>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Role href=\"urn:mpeg:mpeg7:cs:RoleCS:2001:PRODUCER\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Agent xsi:type=\"PersonGroupType\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:Name>")+MI.Get(Stream_General, 0, General_Producer)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:Agent>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:Creator>\n");
+ }
+ if (!MI.Get(Stream_General, 0, General_Director).empty())
+ {
+ ToReturn+=_T("\t\t\t\t<mpeg7:Creator>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Role href=\"urn:mpeg:mpeg7:cs:RoleCS:2001:PRODUCER\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Agent xsi:type=\"PersonGroupType\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:Name>")+MI.Get(Stream_General, 0, General_Director)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:Agent>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:Creator>\n");
+ }
+ if (!MI.Get(Stream_General, 0, General_Composer).empty())
+ {
+ ToReturn+=_T("\t\t\t\t<mpeg7:Creator>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Role href=\"urn:mpeg:mpeg7:cs:RoleCS:2001:COMPOSER\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Agent xsi:type=\"PersonGroupType\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:Name>")+MI.Get(Stream_General, 0, General_Composer)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:Agent>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:Creator>\n");
+ }
+ if (!MI.Get(Stream_General, 0, General_CostumeDesigner).empty())
+ {
+ ToReturn+=_T("\t\t\t\t<mpeg7:Creator>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Role href=\"urn:mpeg:mpeg7:cs:RoleCS:2001:COSTUME-SUPERVISOR\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Agent xsi:type=\"PersonGroupType\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:Name>")+MI.Get(Stream_General, 0, General_CostumeDesigner)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:Agent>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:Creator>\n");
+ }
+ if (!MI.Get(Stream_General, 0, General_ProductionDesigner).empty())
+ {
+ ToReturn+=_T("\t\t\t\t<mpeg7:Creator>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Role href=\"urn:mpeg:mpeg7:cs:RoleCS:2001:PRODUCTION-DESIGNER\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Agent xsi:type=\"PersonGroupType\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:Name>")+MI.Get(Stream_General, 0, General_ProductionDesigner)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:Agent>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:Creator>\n");
+ }
+ if (!MI.Get(Stream_General, 0, General_Publisher).empty())
+ {
+ ToReturn+=_T("\t\t\t\t<mpeg7:Creator>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Role href=\"urn:mpeg:mpeg7:cs:RoleCS:2001:PUBLISHER\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Agent xsi:type=\"PersonGroupType\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:Name>")+MI.Get(Stream_General, 0, General_Publisher)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:Agent>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:Creator>\n");
+ }
+ if (!MI.Get(Stream_General, 0, General_DistributedBy).empty())
+ {
+ ToReturn+=_T("\t\t\t\t<mpeg7:Creator>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Role href=\"urn:mpeg:mpeg7:cs:RoleCS:2001:DISTRIBUTOR\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Agent xsi:type=\"PersonGroupType\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:Name>")+MI.Get(Stream_General, 0, General_DistributedBy)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:Agent>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:Creator>\n");
+ }
+ if (!MI.Get(Stream_General, 0, General_Encoded_Library).empty())
+ {
+ ToReturn+=_T("\t\t\t\t<mpeg7:CreationTool>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:Tool>\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:Name>")+MI.Get(Stream_General, 0, General_Encoded_Library)+_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:Tool>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:CreationTool>\n");
+ }
+ ToReturn+=_T("\t\t\t</mpeg7:Creation>\n");
+ ToReturn+=_T("\t\t</mpeg7:CreationInformation>\n");
+ ToReturn+=_T("\t</mpeg7:Description>\n");
+ }
+
+ //Description - ContentEntity
+ ToReturn+=_T("\t<mpeg7:Description xsi:type=\"ContentEntityType\">\n");
+
+ //MultimediaContent
+ ToReturn+=_T("\t\t<mpeg7:MultimediaContent xsi:type=\""); ToReturn+=Mpeg7_Type(MI); ToReturn+=_T("Type\">\n");
+
+ //(Type)
+ ToReturn+=_T("\t\t\t<mpeg7:"); ToReturn+=Mpeg7_Type(MI); ToReturn+=_T(">\n");
+
+ //MediaFormat header
+ ToReturn+=_T("\t\t\t\t<mpeg7:MediaInformation>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:MediaProfile>\n");
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:MediaFormat>\n");
+
+ //Content
+ ToReturn+=_T("\t\t\t\t\t\t\t<mpeg7:Content");
+ int32u ContentCS_termID=Mpeg7_ContentCS_termID(MI);
+ if (ContentCS_termID>=500000) //Out of spec
+ ToReturn+=_T(" href=\"urn:x-mpeg7-mediainfo:cs:ContentCS:2009:");
+ else
+ ToReturn+=_T(" href=\"urn:mpeg:mpeg7:cs:ContentCS:2001:");
+ ToReturn+=Ztring::ToZtring(ContentCS_termID/10000);
+ if (ContentCS_termID%10000)
+ {
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring((ContentCS_termID%10000)/100);
+ if (ContentCS_termID%100)
+ {
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring(ContentCS_termID%100);
+ }
+ }
+ ToReturn+=_T("\"");
+ ToReturn+=_T(">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t<mpeg7:Name xml:lang=\"en\">"); ToReturn+=Mpeg7_ContentCS_Name(ContentCS_termID, MI); ToReturn+=_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t</mpeg7:Content>\n");
+
+ //FileFormat
+ if (!MI.Get(Stream_General, 0, General_Format).empty())
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t<mpeg7:FileFormat");
+ int32u FileFormatCS_termID=Mpeg7_FileFormatCS_termID(MI);
+ if (FileFormatCS_termID)
+ {
+ if (FileFormatCS_termID>=500000) //Out of spec
+ ToReturn+=_T(" href=\"urn:x-mpeg7-mediainfo:cs:FileFormatCS:2009:");
+ else
+ ToReturn+=_T(" href=\"urn:mpeg:mpeg7:cs:FileFormatCS:2001:");
+ ToReturn+=Ztring::ToZtring(FileFormatCS_termID/10000);
+ ToReturn+=_T("\"");
+ }
+ ToReturn+=_T(">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t<mpeg7:Name xml:lang=\"en\">"); ToReturn+=Mpeg7_FileFormatCS_Name((FileFormatCS_termID/10000)*10000, MI); ToReturn+=_T("</mpeg7:Name>\n");
+ if (FileFormatCS_termID%10000)
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t<mpeg7:Term termID=\"");
+ ToReturn+=Ztring::ToZtring(FileFormatCS_termID/10000);
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring((FileFormatCS_termID%10000)/100);
+ ToReturn+=_T("\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Name xml:lang=\"en\">"); ToReturn+=Mpeg7_FileFormatCS_Name((FileFormatCS_termID/100)*100, MI); ToReturn+=_T("</mpeg7:Name>\n");
+ if (FileFormatCS_termID%100)
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t<mpeg7:Term termID=\"");
+ ToReturn+=Ztring::ToZtring(FileFormatCS_termID/10000);
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring((FileFormatCS_termID%10000)/100);
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring(FileFormatCS_termID%100);
+ ToReturn+=_T("\">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t\t<mpeg7:Name xml:lang=\"en\">"); ToReturn+=Mpeg7_FileFormatCS_Name(FileFormatCS_termID, MI); ToReturn+=_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t\t</mpeg7:Term>\n");
+ }
+ ToReturn+=_T("\t\t\t\t\t\t\t\t\t</mpeg7:Term>\n");
+ }
+ ToReturn+=_T("\t\t\t\t\t\t\t</mpeg7:FileFormat>\n");
+ }
+
+ //FileSize
+ ToReturn+=_T("\t\t\t\t\t\t\t<mpeg7:FileSize>"); ToReturn+=MI.Get(Stream_General, 0, General_FileSize); ToReturn+=_T("</mpeg7:FileSize>\n");
+
+ //System
+ if (!MI.Get(Stream_Video, 0, Video_Standard).empty())
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t<mpeg7:System");
+ int32u SystemCS_termID=Mpeg7_SystemCS_termID(MI, 0); //2 video streams are not supported
+ if (SystemCS_termID)
+ {
+ ToReturn+=_T(" href=\"urn:mpeg:mpeg7:cs:SystemCS:2001:");
+ ToReturn+=Ztring::ToZtring(SystemCS_termID/10000);
+ if (SystemCS_termID%10000)
+ {
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring((SystemCS_termID%10000)/100);
+ if (SystemCS_termID%100)
+ {
+ ToReturn+=_T(".");
+ ToReturn+=Ztring::ToZtring(SystemCS_termID%100);
+ }
+ }
+ ToReturn+=_T("\"");
+ }
+ ToReturn+=_T(">\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t\t<mpeg7:Name xml:lang=\"en\">"); ToReturn+=Mpeg7_SystemCS_Name(SystemCS_termID); ToReturn+=_T("</mpeg7:Name>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t</mpeg7:System>\n");
+ }
+
+ //BitRate
+ if (!MI.Get(Stream_General, 0, General_OverallBitRate).empty())
+ {
+ ToReturn+=_T("\t\t\t\t\t\t\t<mpeg7:BitRate");
+ bool IsCBR=true;
+ bool IsVBR=true;
+ for (size_t StreamKind=Stream_Video; StreamKind<=Stream_Audio; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<MI.Count_Get((stream_t)StreamKind); StreamPos++)
+ {
+ if (IsCBR && MI.Get((stream_t)StreamKind, StreamPos, _T("BitRate_Mode"))==_T("VBR"))
+ IsCBR=false;
+ if (IsVBR && MI.Get((stream_t)StreamKind, StreamPos, _T("BitRate_Mode"))==_T("CBR"))
+ IsVBR=false;
+ }
+ if (IsCBR && IsVBR)
+ {
+ IsCBR=false;
+ IsVBR=false;
+ }
+ if (IsCBR)
+ ToReturn+=_T(" variable=\"false\"");
+ if (IsVBR)
+ ToReturn+=_T(" variable=\"true\"");
+ ToReturn+=_T(">"); ToReturn+=MI.Get(Stream_General, 0, General_OverallBitRate); ToReturn+=_T("</mpeg7:BitRate>\n");
+ }
+
+ //xxxCoding
+ for (size_t Pos=0; Pos<MI.Count_Get(Stream_Video); Pos++)
+ Mpeg7_Transform_Visual(ToReturn, MI, Pos);
+ for (size_t Pos=0; Pos<MI.Count_Get(Stream_Audio); Pos++)
+ Mpeg7_Transform_Audio(ToReturn, MI, Pos);
+
+ //MediaFormat header
+ ToReturn+=_T("\t\t\t\t\t\t</mpeg7:MediaFormat>\n");
+
+ //MediaTranscodingHints, intraFrameDistance and anchorFrameDistance
+ if (!MI.Get(Stream_Video, 0, Video_Format_Settings_GOP).empty())
+ {
+ Ztring M=MI.Get(Stream_Video, 0, Video_Format_Settings_GOP).SubString(_T("M="), _T(","));
+ Ztring N=MI.Get(Stream_Video, 0, Video_Format_Settings_GOP).SubString(_T("N="), _T(""));
+ ToReturn+=_T("\t\t\t\t\t\t<mpeg7:MediaTranscodingHints>\n");
+ ToReturn+=_T("\t\t\t\t\t\t\t<mpeg7:CodingHints");
+ if (!N.empty())
+ ToReturn+=_T(" intraFrameDistance=\"")+N;
+ if (!M.empty())
+ ToReturn+=_T("\" anchorFrameDistance=\"")+M;
+ ToReturn+=_T("\"/>\n");
+ ToReturn+=_T("\t\t\t\t\t\t</mpeg7:MediaTranscodingHints>\n");
+ }
+
+ ToReturn+=_T("\t\t\t\t\t</mpeg7:MediaProfile>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:MediaInformation>\n");
+
+ if (MI.Count_Get(Stream_Video)==1 || MI.Count_Get(Stream_Audio)==1)
+ {
+ //MediaTimePoint
+ ToReturn+=_T("\t\t\t\t<mpeg7:MediaTime>\n");
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:MediaTimePoint>")+Mpeg7_MediaTimePoint(MI)+_T("</mpeg7:MediaTimePoint>\n");
+
+ //MediaDuration
+ ToReturn+=_T("\t\t\t\t\t<mpeg7:MediaDuration>"); ToReturn+=Mpeg7_MediaDuration(MI); ToReturn+=_T("</mpeg7:MediaDuration>\n");
+ ToReturn+=_T("\t\t\t\t</mpeg7:MediaTime>\n");
+ }
+
+ //Mpeg7 footer
+ ToReturn+=_T("\t\t\t</mpeg7:"); ToReturn+=Mpeg7_Type(MI); ToReturn+=_T(">\n");
+ ToReturn+=_T("\t\t</mpeg7:MultimediaContent>\n");
+ ToReturn+=_T("\t</mpeg7:Description>\n");
+ ToReturn+=_T("</mpeg7:Mpeg7>\n");
+
+ //Carriage return
+ ToReturn.FindAndReplace(_T("\n"), EOL, 0, Ztring_Recursive);
+
+ //Find and replace
+ ZtringListList ToReplace=MediaInfoLib::Config.Inform_Replace_Get_All();
+ for (size_t Pos=0; Pos<ToReplace.size(); Pos++)
+ ToReturn.FindAndReplace(ToReplace[Pos][0], ToReplace[Pos][1], 0, Ztring_Recursive);
+
+ return ToReturn;
+}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+} //NameSpace
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Export/Export_Mpeg7.h b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_Mpeg7.h
new file mode 100644
index 000000000..6c7454f4a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_Mpeg7.h
@@ -0,0 +1,52 @@
+// Reader_File - All information about media files
+// Copyright (C) 2009-2011 Jerome Martinez, Zen@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Convert to MPEG-7 XML
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef Export_Mpeg7H
+#define Export_Mpeg7H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo_Internal.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+/// @brief Export_Mpeg7
+//***************************************************************************
+
+class Export_Mpeg7
+{
+public :
+ //Constructeur/Destructeur
+ Export_Mpeg7 ();
+ ~Export_Mpeg7 ();
+
+ //Input
+ Ztring Transform(MediaInfo_Internal &MI);
+};
+
+} //NameSpace
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Export/Export_PBCore.cpp b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_PBCore.cpp
new file mode 100644
index 000000000..5cef7025c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_PBCore.cpp
@@ -0,0 +1,404 @@
+// File__Analyze - Base for analyze files
+// Copyright (C) 2009-2011 Jerome Martinez, Zen@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Export/Export_PBCore.h"
+#include "MediaInfo/File__Analyse_Automatic.h"
+#include <ctime>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Ztring PBCore_MediaType(MediaInfo_Internal &MI)
+{
+ if (MI.Count_Get(Stream_Video))
+ return _T("Video");
+ else if (MI.Count_Get(Stream_Audio))
+ return _T("Sound");
+ else if (MI.Count_Get(Stream_Image))
+ return _T("Static Image");
+ else if (MI.Count_Get(Stream_Text))
+ return _T("Text");
+ else
+ return Ztring();
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Export_PBCore::Export_PBCore ()
+{
+}
+
+//---------------------------------------------------------------------------
+Export_PBCore::~Export_PBCore ()
+{
+}
+
+//***************************************************************************
+// Input
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void PBCore_Transform__Common_Begin(Ztring &ToReturn, MediaInfo_Internal &MI, stream_t StreamKind, size_t StreamPos)
+{
+ //essenceTrackIdentifier
+ if (!MI.Get(StreamKind, StreamPos, _T("ID")).empty())
+ {
+ ToReturn+=_T("\t\t\t<essenceTrackIdentifier>")+MI.Get(StreamKind, StreamPos, _T("ID"))+_T("</essenceTrackIdentifier>\n");
+ ToReturn+=_T("\t\t\t<essenceTrackIdentifierSource>ID (Mediainfo)</essenceTrackIdentifierSource>\n");
+ }
+ else if (!MI.Get(StreamKind, StreamPos, _T("UniqueID")).empty())
+ {
+ ToReturn+=_T("\t\t\t<essenceTrackIdentifier>")+MI.Get(StreamKind, StreamPos, _T("UniqueID"))+_T("</essenceTrackIdentifier>\n");
+ ToReturn+=_T("\t\t\t<essenceTrackIdentifierSource>UniqueID (Mediainfo)</essenceTrackIdentifierSource>\n");
+ }
+ else if (!MI.Get(StreamKind, StreamPos, _T("StreamKindID")).empty())
+ {
+ ToReturn+=_T("\t\t\t<essenceTrackIdentifier>")+MI.Get(StreamKind, StreamPos, _T("StreamKindID"))+_T("</essenceTrackIdentifier>\n");
+ ToReturn+=_T("\t\t\t<essenceTrackIdentifierSource>StreamKindID (Mediainfo)</essenceTrackIdentifierSource>\n");
+ }
+
+ //essenceTrackStandard
+ if (StreamKind==Stream_Video && !MI.Get(Stream_Video, StreamPos, Video_Standard).empty()) //Video only, but must be placed here
+ ToReturn+=_T("\t\t\t<essenceTrackStandard>")+MI.Get(Stream_Video, StreamPos, Video_Standard)+_T("</essenceTrackStandard>\n");
+
+ //essenceTrackLanguage
+ if (!MI.Get(StreamKind, StreamPos, _T("Language")).empty())
+ ToReturn+=_T("\t\t\t<essenceTrackLanguage>")+MediaInfoLib::Config.Iso639_2_Get(MI.Get(StreamKind, StreamPos, _T("Language")))+_T("</essenceTrackLanguage>\n");
+
+ //essenceTrackEncoding
+ if (!MI.Get(StreamKind, StreamPos, _T("Format")).empty())
+ {
+ ToReturn+=_T("\t\t\t<essenceTrackEncoding>");
+ ToReturn+=MI.Get(StreamKind, StreamPos, _T("Format"));
+ if (!MI.Get(StreamKind, StreamPos, _T("Format_Profile")).empty()) ToReturn+=_T(' ')+MI.Get(StreamKind, StreamPos, _T("Format_Profile"));
+ if (!MI.Get(StreamKind, StreamPos, _T("CodecID")).empty()) ToReturn+=_T(" (")+MI.Get(StreamKind, StreamPos, _T("CodecID"))+_T(')');
+ ToReturn+=_T("</essenceTrackEncoding>\n");
+ }
+
+ //essenceTrackDataRate
+ if (!MI.Get(StreamKind, StreamPos, _T("BitRate")).empty())
+ {
+ ToReturn+=_T("\t\t\t<essenceTrackDataRate>");
+ ToReturn+=MI.Get(StreamKind, StreamPos, _T("BitRate"));
+ if (!MI.Get(StreamKind, StreamPos, _T("BitRate_Mode")).empty())
+ ToReturn+=_T(' ')+MI.Get(StreamKind, StreamPos, _T("BitRate_Mode"));
+ ToReturn+=_T("</essenceTrackDataRate>\n");
+ }
+
+ //essenceTrackDuration
+ if (!MI.Get(StreamKind, StreamPos, _T("Duration")).empty())
+ ToReturn+=_T("\t\t\t<essenceTrackDuration>")+MI.Get(StreamKind, StreamPos, _T("Duration"))+_T("</essenceTrackDuration>\n");
+
+ //essenceTrackBitDepth
+ if (!MI.Get(StreamKind, StreamPos, _T("Resolution")).empty())
+ ToReturn+=_T("\t\t\t<essenceTrackBitDepth version=\"PBCoreXSD_Ver_1.2_D1\">")+MI.Get(StreamKind, StreamPos, _T("Resolution"))+_T("</essenceTrackBitDepth>\n");
+}
+
+//---------------------------------------------------------------------------
+void PBCore_Transform__Common_End(Ztring &ToReturn, MediaInfo_Internal &MI, stream_t StreamKind, size_t StreamPos)
+{
+ //essenceTrackAnnotation - all fields (except *_String*) separated by |
+ Ztring Temp;
+ for (size_t Pos=0; Pos<MI.Count_Get(StreamKind, StreamPos); Pos++)
+ if (MI.Get(StreamKind, StreamPos, Pos, Info_Name).find(_T("String"))==std::string::npos && !MI.Get(StreamKind, StreamPos, Pos).empty())
+ Temp+=MI.Get(StreamKind, StreamPos, Pos, Info_Name)+_T(": ")+MI.Get(StreamKind, StreamPos, Pos)+_T('|');
+ if (!Temp.empty())
+ {
+ Temp.resize(Temp.size()-1);
+ ToReturn+=_T("\t\t\t<essenceTrackAnnotation>"); ToReturn+=Temp; ToReturn+=_T("</essenceTrackAnnotation>\n");
+ }
+}
+
+//---------------------------------------------------------------------------
+void PBCore_Transform_Video(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos)
+{
+ ToReturn+=_T("\t\t<pbcoreEssenceTrack>\n");
+
+ //essenceTrackType
+ ToReturn+=_T("\t\t\t<essenceTrackType>Video</essenceTrackType>\n");
+
+ //Common
+ PBCore_Transform__Common_Begin(ToReturn, MI, Stream_Video, StreamPos);
+
+ //essenceTrackFrameSize
+ if (!MI.Get(Stream_Video, StreamPos, Video_Width).empty())
+ ToReturn+=_T("\t\t\t<essenceTrackFrameSize>")+MI.Get(Stream_Video, StreamPos, Video_Width)+_T('x')+MI.Get(Stream_Video, StreamPos, Video_Height)+_T("</essenceTrackFrameSize>\n");
+
+ //essenceTrackAspectRatio
+ if (!MI.Get(Stream_Video, StreamPos, Video_DisplayAspectRatio).empty())
+ ToReturn+=_T("\t\t\t<essenceTrackAspectRatio>")+MI.Get(Stream_Video, StreamPos, Video_DisplayAspectRatio)+_T("</essenceTrackAspectRatio>\n");
+
+ //essenceTrackFrameRate
+ if (!MI.Get(Stream_Video, StreamPos, Video_FrameRate).empty())
+ {
+ ToReturn+=_T("\t\t\t<essenceTrackFrameRate>");
+ ToReturn+=MI.Get(Stream_Video, StreamPos, Video_FrameRate);
+ if (!MI.Get(Stream_Video, StreamPos, Video_FrameRate_Mode).empty())
+ ToReturn+=_T(' ')+MI.Get(Stream_Video, StreamPos, Video_FrameRate_Mode);
+ ToReturn+=_T("</essenceTrackFrameRate>\n");
+ }
+
+ //Comon
+ PBCore_Transform__Common_End(ToReturn, MI, Stream_Video, StreamPos);
+
+ ToReturn+=_T("\t\t</pbcoreEssenceTrack>\n");
+}
+
+//---------------------------------------------------------------------------
+void PBCore_Transform_Audio(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos)
+{
+ ToReturn+=_T("\t\t<pbcoreEssenceTrack>\n");
+
+ //essenceTrackType
+ ToReturn+=_T("\t\t\t<essenceTrackType>Audio</essenceTrackType>\n");
+
+ //Common
+ PBCore_Transform__Common_Begin(ToReturn, MI, Stream_Audio, StreamPos);
+
+ if (!MI.Get(Stream_Audio, StreamPos, Audio_SamplingRate).empty())
+ ToReturn+=_T("\t\t\t<essenceTrackSamplingRate>")+MI.Get(Stream_Audio, StreamPos, Audio_SamplingRate)+_T("</essenceTrackSamplingRate>\n");
+
+ //Comon
+ PBCore_Transform__Common_End(ToReturn, MI, Stream_Audio, StreamPos);
+
+ ToReturn+=_T("\t\t</pbcoreEssenceTrack>\n");
+}
+
+//---------------------------------------------------------------------------
+void PBCore_Transform_Text(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos)
+{
+ //Init
+ Ztring Format=MI.Get(Stream_Text, StreamPos, Text_Format);
+
+ ToReturn+=_T("\t\t<pbcoreEssenceTrack>\n");
+
+ //essenceTrackType
+ ToReturn+=_T("\t\t\t<essenceTrackType>");
+ if (Format==_T("EIA-608") || Format==_T("EIA-708"))
+ ToReturn+=_T("caption");
+ else
+ ToReturn+=_T("text");
+ ToReturn+=_T("</essenceTrackType>\n");
+
+ //Common
+ PBCore_Transform__Common_Begin(ToReturn, MI, Stream_Text, StreamPos);
+
+ //Common
+ PBCore_Transform__Common_End(ToReturn, MI, Stream_Text, StreamPos);
+
+ ToReturn+=_T("\t\t</pbcoreEssenceTrack>\n");
+}
+
+//---------------------------------------------------------------------------
+void PBCore_Transform_Menu(Ztring &ToReturn, MediaInfo_Internal &MI, size_t StreamPos)
+{
+ //Only if TimeCode
+ if (MI.Get(Stream_Menu, StreamPos, Menu_Format)!=_T("TimeCode"))
+ return;
+
+ ToReturn+=_T("\t\t<pbcoreEssenceTrack>\n");
+
+ //essenceTrackType
+ ToReturn+=_T("\t\t\t<essenceTrackType>timecode</essenceTrackType>\n");
+
+ //Common
+ PBCore_Transform__Common_Begin(ToReturn, MI, Stream_Menu, StreamPos);
+
+ //Common
+ PBCore_Transform__Common_End(ToReturn, MI, Stream_Menu, StreamPos);
+
+ ToReturn+=_T("\t\t</pbcoreEssenceTrack>\n");
+}
+
+//---------------------------------------------------------------------------
+Ztring Export_PBCore::Transform(MediaInfo_Internal &MI)
+{
+ //Current date/time is ISO format
+ time_t Time=time(NULL);
+ Ztring TimeS; TimeS.Date_From_Seconds_1970((int32u)Time);
+ TimeS.FindAndReplace(_T("UTC "), _T(""));
+ TimeS.FindAndReplace(_T(" "), _T("T"));
+ TimeS+=_T('Z');
+
+ Ztring ToReturn;
+ ToReturn+=_T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ ToReturn+=_T("<PBCoreDescriptionDocument xsi:schemaLocation=\"http://www.pbcore.org/PBCore/PBCoreNamespace.html http://www.pbcore.org/PBCore/PBCoreXSD_Ver_1-2-1.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.pbcore.org/PBCore/PBCoreNamespace.html\">\n");
+ ToReturn+=_T("\t<!-- Generated at ")+TimeS+_T(" by ")+MediaInfoLib::Config.Info_Version_Get()+_T(" -->\n");
+ ToReturn+=_T("\t<!-- Warning: MediaInfo outputs only pbcoreInstantiation, other mandatory PBCore data is junk -->\n");
+ ToReturn+=_T("\t<pbcoreIdentifier>\n");
+ ToReturn+=_T("\t\t<identifier>***</identifier>\n");
+ ToReturn+=_T("\t\t<identifierSource>***</identifierSource>\n");
+ ToReturn+=_T("\t</pbcoreIdentifier>\n");
+ ToReturn+=_T("\t<pbcoreTitle>\n");
+ ToReturn+=_T("\t\t<title>***</title>\n");
+ ToReturn+=_T("\t</pbcoreTitle>\n");
+ ToReturn+=_T("\t<pbcoreDescription>\n");
+ ToReturn+=_T("\t\t<description>***</description>\n");
+ ToReturn+=_T("\t\t<descriptionType>***</descriptionType>\n");
+ ToReturn+=_T("\t</pbcoreDescription>\n");
+ ToReturn+=_T("\t<pbcoreInstantiation>\n");
+
+
+ //pbcoreFormatID
+ ToReturn+=_T("\t\t<pbcoreFormatID>\n");
+ //formatIdentifier
+ ToReturn+=_T("\t\t\t<formatIdentifier>")+MI.Get(Stream_General, 0, General_FileName)+_T("</formatIdentifier>\n");
+ //formatIdentifierSource
+ ToReturn+=_T("\t\t\t<formatIdentifierSource version=\"PBCoreXSD_Ver_1.2_D1\">File Name</formatIdentifierSource>\n");
+ ToReturn+=_T("\t\t</pbcoreFormatID>\n");
+
+ //formatDigital
+ if (!MI.Get(Stream_General, 0, General_InternetMediaType).empty())
+ {
+ ToReturn+=_T("\t\t<formatDigital>");
+ ToReturn+=MI.Get(Stream_General, 0, General_InternetMediaType);
+ ToReturn+=_T("</formatDigital>\n");
+ }
+ else
+ {
+ //TODO: how to implement formats without Media Type?
+ ToReturn+=_T("\t\t<formatDigital>");
+ if (MI.Count_Get(Stream_Video))
+ ToReturn+=_T("video/x-");
+ else if (MI.Count_Get(Stream_Image))
+ ToReturn+=_T("image/x-");
+ else if (MI.Count_Get(Stream_Audio))
+ ToReturn+=_T("audio/x-");
+ else
+ ToReturn+=_T("application/x-");
+ ToReturn+=Ztring(MI.Get(Stream_General, 0, _T("Format"))).MakeLowerCase();
+ ToReturn+=_T("</formatDigital>\n");
+ }
+
+ //formatLocation
+ ToReturn+=_T("\t\t<formatLocation>")+MI.Get(Stream_General, 0, General_CompleteName)+_T("</formatLocation>\n");
+
+ //dateCreated
+ if (!MI.Get(Stream_General, 0, General_Encoded_Date).empty())
+ {
+ Ztring dateCreated=MI.Get(Stream_General, 0, General_Recorded_Date);
+ dateCreated.FindAndReplace(_T("UTC"), _T("-"));
+ dateCreated.FindAndReplace(_T(" "), _T("T"));
+ dateCreated+=_T('Z');
+ ToReturn+=_T("\t\t<dateCreated>")+dateCreated+_T("</dateCreated>\n");
+ }
+
+ //dateIssued
+ if (!MI.Get(Stream_General, 0, General_Recorded_Date).empty())
+ {
+ Ztring dateIssued=MI.Get(Stream_General, 0, General_Recorded_Date);
+ dateIssued.FindAndReplace(_T("UTC"), _T("-"));
+ dateIssued.FindAndReplace(_T(" "), _T("T"));
+ dateIssued+=_T('Z');
+ ToReturn+=_T("\t\t<dateIssued>")+dateIssued+_T("</dateIssued>\n");
+ }
+
+ //formatMediaType
+ if (!PBCore_MediaType(MI).empty())
+ ToReturn+=_T("\t\t<formatMediaType version=\"PBCoreXSD_Ver_1.2_D1\">")+PBCore_MediaType(MI)+_T("</formatMediaType>\n");
+ else
+ ToReturn+=_T("\t\t<formatMediaType version=\"PBCoreXSD_Ver_1.2_D1\">application/octet-stream</formatMediaType>\n");
+
+ //formatGenerations
+ ToReturn+=_T("\t\t<formatGenerations version=\"PBCoreXSD_Ver_1.2_D1\" />\n");
+
+ //formatFileSize
+ if (!MI.Get(Stream_General, 0, General_FileSize).empty())
+ ToReturn+=_T("\t\t<formatFileSize>")+MI.Get(Stream_General, 0, General_FileSize)+_T("</formatFileSize>\n");
+
+ //formatTimeStart
+ if (!MI.Get(Stream_Video, 0, Video_Delay_Original_String3).empty())
+ ToReturn+=_T("\t\t<formatTimeStart>")+MI.Get(Stream_Video, 0, Video_Delay_Original_String3)+_T("</formatTimeStart>\n");
+ else if (!MI.Get(Stream_Video, 0, Video_Delay_String3).empty())
+ ToReturn+=_T("\t\t<formatTimeStart>")+MI.Get(Stream_Video, 0, Video_Delay_String3)+_T("</formatTimeStart>\n");
+
+ //formatDuration
+ if (!MI.Get(Stream_General, 0, General_Duration_String3).empty())
+ ToReturn+=_T("\t\t<formatDuration>")+MI.Get(Stream_General, 0, General_Duration_String3)+_T("</formatDuration>\n");
+
+ //formatDataRate
+ if (!MI.Get(Stream_General, 0, General_OverallBitRate).empty())
+ {
+ ToReturn+=_T("\t\t<formatDataRate>");
+ ToReturn+=MI.Get(Stream_General, 0, General_OverallBitRate);
+ if (!MI.Get(Stream_General, 0, General_OverallBitRate_Mode).empty())
+ ToReturn+=_T(' ')+MI.Get(Stream_General, 0, General_OverallBitRate_Mode);
+ ToReturn+=_T("</formatDataRate>\n");
+ }
+
+ //formatTracks
+ ToReturn+=_T("\t\t<formatTracks>")+Ztring::ToZtring(MI.Count_Get(Stream_Video)+MI.Count_Get(Stream_Audio)+MI.Count_Get(Stream_Image)+MI.Count_Get(Stream_Text))+_T("</formatTracks>\n");
+
+ //Video streams
+ for (size_t StreamPos=0; StreamPos<MI.Count_Get(Stream_Video); StreamPos++)
+ PBCore_Transform_Video(ToReturn, MI, StreamPos);
+
+ //Audio streams
+ for (size_t StreamPos=0; StreamPos<MI.Count_Get(Stream_Audio); StreamPos++)
+ PBCore_Transform_Audio(ToReturn, MI, StreamPos);
+
+ //Text streams
+ for (size_t StreamPos=0; StreamPos<MI.Count_Get(Stream_Text); StreamPos++)
+ PBCore_Transform_Text(ToReturn, MI, StreamPos);
+
+ //Menu streams
+ for (size_t StreamPos=0; StreamPos<MI.Count_Get(Stream_Menu); StreamPos++)
+ PBCore_Transform_Menu(ToReturn, MI, StreamPos);
+
+ ToReturn+=_T("\t</pbcoreInstantiation>\n");
+ ToReturn+=_T("</PBCoreDescriptionDocument>\n");
+
+ //Carriage return
+ ToReturn.FindAndReplace(_T("\n"), EOL, 0, Ztring_Recursive);
+
+ return ToReturn;
+}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+} //NameSpace
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Export/Export_PBCore.h b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_PBCore.h
new file mode 100644
index 000000000..5341b0d63
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_PBCore.h
@@ -0,0 +1,52 @@
+// Reader_File - All information about media files
+// Copyright (C) 2009-2011 Jerome Martinez, Zen@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Convert to PBCore XML
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef Export_PBCoreH
+#define Export_PBCoreH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo_Internal.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+/// @brief Export_PBCore
+//***************************************************************************
+
+class Export_PBCore
+{
+public :
+ //Constructeur/Destructeur
+ Export_PBCore ();
+ ~Export_PBCore ();
+
+ //Input
+ Ztring Transform(MediaInfo_Internal &MI);
+};
+
+} //NameSpace
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Export/Export_reVTMD.cpp b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_reVTMD.cpp
new file mode 100644
index 000000000..9c65a0f7e
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_reVTMD.cpp
@@ -0,0 +1,9 @@
+// reVTMD is disabled due to its non-free licensing.
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Export/Export_reVTMD.h b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_reVTMD.h
new file mode 100644
index 000000000..46141228a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Export/Export_reVTMD.h
@@ -0,0 +1 @@
+// reVTMD is disabled due to its non-free licensing. \ No newline at end of file
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File_Dummy.cpp b/src/thirdparty/MediaInfo/MediaInfo/File_Dummy.cpp
new file mode 100644
index 000000000..a9f777f17
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File_Dummy.cpp
@@ -0,0 +1,326 @@
+// File_Dummy - Fill with Name of tags
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DUMMY_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File_Dummy.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dummy::FileHeader_Parse()
+{
+ File_Name=_T("D:\\Example\\"); File_Name+=KindOfDummy;
+ if (KindOfDummy==_T("Album"))
+ {
+ Fill_Dummy_General();
+ Fill_Dummy_Audio();
+ }
+ else if (KindOfDummy==_T("Comic"))
+ {
+ Fill_Dummy_General();
+ Fill_Dummy_Video();
+ }
+ else if (KindOfDummy==_T("Movie"))
+ {
+ Fill_Dummy_General();
+ Fill_Dummy_Video();
+ Fill_Dummy_Video();
+ Fill_Dummy_Audio();
+ Fill_Dummy_Audio();
+ Fill_Dummy_Audio();
+ Fill_Dummy_Audio();
+ Fill_Dummy_Text();
+ Fill_Dummy_Text();
+ Fill_Dummy_Text();
+ Fill_Dummy_Text();
+ Fill_Dummy_Chapters();
+ Fill_Dummy_Chapters();
+ }
+ else
+ {
+ File_Name=_T("D:\\WhatIsIt.mkv");
+ Fill(Stream_General, 0, General_Domain, "Starwars saga");
+ Fill(Stream_General, 0, General_Movie, "Starwars 4");
+ Fill(Stream_General, 0, General_Movie_More, "A new hope");
+ Fill(Stream_General, 0, General_Director, "Georges Lucas");
+ Fill(Stream_General, 0, General_Released_Date, "1977");
+ Fill(Stream_General, 0, General_FileSize, "734000000");
+ Fill(Stream_General, 0, General_Format, "Matroska");
+ Fill(Stream_General, 0, General_Format_Url, "http://mediainfo.sourceforge.net");
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Codec, "XVID");
+ Fill(Stream_Video, 0, Video_Codec_Url, "http://mediainfo.sourceforge.net");
+ Fill(Stream_Video, 0, Video_BitRate, "800000");
+ Fill(Stream_Video, 0, Video_Width, "720");
+ Fill(Stream_Video, 0, Video_Height, "320");
+ Fill(Stream_Video, 0, Video_FrameRate, "24.976");
+ Fill(Stream_Video, 0, Video_BitDepth, "8");
+ Fill(Stream_Video, 0, Video_Language, "en");
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "AC-3");
+ Fill(Stream_Audio, 0, Audio_Codec, "AC3");
+ Fill(Stream_Audio, 0, Audio_Codec_Url, "http://mediainfo.sourceforge.net");
+ Fill(Stream_Audio, 0, Audio_BitRate, "384000");
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR");
+ Fill(Stream_Audio, 0, Audio_Channel_s_, "6");
+ Fill(Stream_Audio, 0, Audio_SamplingRate, "48000");
+ Fill(Stream_Audio, 0, Audio_Language, "en");
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Codec, "SSA");
+ Fill(Stream_Text, 0, Text_Codec_Url, "http://mediainfo.sourceforge.net");
+ Fill(Stream_Text, 0, Text_Language, "en");
+ Fill(Stream_Text, 0, Text_Language_More, "Forced");
+ Stream_Prepare(Stream_Chapters);
+ Fill(Stream_Chapters, 0, Chapters_Total, "16");
+ Fill(Stream_Chapters, 0, Chapters_Language, "en");
+ }
+
+ Accept();
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dummy::Fill_Dummy_General()
+{
+ Fill(Stream_General, 0, General_Format, "Format");
+ Fill(Stream_General, 0, General_Format_Url, "http://mediainfo.sourceforge.net");
+ Fill(Stream_General, 0, General_Format_Extensions, "fmt fmt fmt");
+ Fill(Stream_General, 0, General_FileSize, "1000000");
+ Fill(Stream_General, 0, General_Duration, "10000");
+ Fill(Stream_General, 0, General_Domain, "Domain");
+ Fill(Stream_General, 0, General_Collection, "Collection");
+ Fill(Stream_General, 0, General_Season, "Season");
+ Fill(Stream_General, 0, General_Season_Position_Total, "Season/Position_Total");
+ if (KindOfDummy==_T("Album"))
+ {
+ Fill(Stream_General, 0, General_Album, "Album name");
+ Fill(Stream_General, 0, General_Album_More, "More information about the album");
+ Fill(Stream_General, 0, General_Part, "Part");
+ Fill(Stream_General, 0, General_Part_Position_Total, "Part/Position_Total");
+ Fill(Stream_General, 0, General_Part_Position, "Part/Position");
+ Fill(Stream_General, 0, General_Track, "Track");
+ Fill(Stream_General, 0, General_Track_Position, "Track/Position");
+ Fill(Stream_General, 0, General_Track_More, "More information about the track");
+ }
+ else if (KindOfDummy==_T("Comic"))
+ {
+ Fill(Stream_General, 0, General_Comic, "Comic name");
+ Fill(Stream_General, 0, General_Comic_More, "More information about the comic");
+ }
+ else //if (KindOfDummy==_T("Movie"))
+ {
+ Fill(Stream_General, 0, General_Movie, "Movie name");
+ Fill(Stream_General, 0, General_Movie_More, "More information about the movie");
+ }
+ Fill(Stream_General, 0, General_Performer, "Performer");
+ Fill(Stream_General, 0, General_Performer_Sort, "Performer/Sort");
+ Fill(Stream_General, 0, General_Performer_Url, "Performer/Url");
+ Fill(Stream_General, 0, General_Original_Performer, "Original/Performer");
+ Fill(Stream_General, 0, General_Accompaniment, "Accompaniment");
+ Fill(Stream_General, 0, General_Composer, "Composer");
+ Fill(Stream_General, 0, General_Composer_Nationality, "Composer/Nationality");
+ Fill(Stream_General, 0, General_Arranger, "Arranger");
+ Fill(Stream_General, 0, General_Lyricist, "Lyricist");
+ Fill(Stream_General, 0, General_Original_Lyricist, "Original/Lyricist");
+ Fill(Stream_General, 0, General_Conductor, "Conductor");
+ Fill(Stream_General, 0, General_Actor, "Actor");
+ Fill(Stream_General, 0, General_Actor_Character, "Actor_Character");
+ Fill(Stream_General, 0, General_WrittenBy, "WrittenBy");
+ Fill(Stream_General, 0, General_ScreenplayBy, "ScreenplayBy");
+ Fill(Stream_General, 0, General_Director, "Director");
+ Fill(Stream_General, 0, General_AssistantDirector, "AssistantDirector");
+ Fill(Stream_General, 0, General_DirectorOfPhotography, "DirectorOfPhotography");
+ Fill(Stream_General, 0, General_ArtDirector, "ArtDirector");
+ Fill(Stream_General, 0, General_EditedBy, "EditedBy");
+ Fill(Stream_General, 0, General_Producer, "Producer");
+ Fill(Stream_General, 0, General_CoProducer, "CoProducer");
+ Fill(Stream_General, 0, General_ExecutiveProducer, "ExecutiveProducer");
+ Fill(Stream_General, 0, General_ProductionDesigner, "ProductionDesigner");
+ Fill(Stream_General, 0, General_CostumeDesigner, "CostumeDesigner");
+ Fill(Stream_General, 0, General_Choregrapher, "Choregrapher");
+ Fill(Stream_General, 0, General_SoundEngineer, "SoundEngineer");
+ Fill(Stream_General, 0, General_MasteredBy, "MasteredBy");
+ Fill(Stream_General, 0, General_RemixedBy, "RemixedBy");
+ Fill(Stream_General, 0, General_ProductionStudio, "ProductionStudio");
+ Fill(Stream_General, 0, General_Label, "Label");
+ Fill(Stream_General, 0, General_Publisher, "Publisher");
+ Fill(Stream_General, 0, General_Publisher_URL, "Publisher/URL");
+ Fill(Stream_General, 0, General_DistributedBy, "DistributedBy");
+ Fill(Stream_General, 0, General_EncodedBy, "EncodedBy");
+ Fill(Stream_General, 0, General_ThanksTo, "ThanksTo");
+ Fill(Stream_General, 0, General_ServiceName, "ServiceNeme");
+ Fill(Stream_General, 0, General_ServiceProvider, "ServiceProvider");
+ Fill(Stream_General, 0, General_Service_Url, "Service/URL");
+ Fill(Stream_General, 0, General_ContentType, "ContentType");
+ Fill(Stream_General, 0, General_Subject, "Subject");
+ Fill(Stream_General, 0, General_Synopsis, "Synopsis");
+ Fill(Stream_General, 0, General_Summary, "Summary");
+ Fill(Stream_General, 0, General_Description, "Description");
+ Fill(Stream_General, 0, General_Keywords, "Keywords");
+ Fill(Stream_General, 0, General_Period, "Period");
+ Fill(Stream_General, 0, General_LawRating, "LawRating");
+ Fill(Stream_General, 0, General_Written_Date, "Written_Date");
+ Fill(Stream_General, 0, General_Recorded_Date, "Recorded_Date");
+ Fill(Stream_General, 0, General_Released_Date, "Released_Date");
+ Fill(Stream_General, 0, General_Mastered_Date, "Mastered_Date");
+ Fill(Stream_General, 0, General_Encoded_Date, "Encoded_Date");
+ Fill(Stream_General, 0, General_Tagged_Date, "Tagged_Date");
+ Fill(Stream_General, 0, General_Original_Released_Date, "Original/Released_Date");
+ Fill(Stream_General, 0, General_Written_Location, "Written_Location");
+ Fill(Stream_General, 0, General_Recorded_Location, "Recorded_Location");
+ Fill(Stream_General, 0, General_Archival_Location, "Archival_Location");
+ Fill(Stream_General, 0, General_Genre, "Genre");
+ Fill(Stream_General, 0, General_Mood, "Mood");
+ Fill(Stream_General, 0, General_Comment, "Comment");
+ Fill(Stream_General, 0, General_Rating , "Rating ");
+ Fill(Stream_General, 0, General_Encoded_Application, "Encoded_Application");
+ Fill(Stream_General, 0, General_Encoded_Library, "Encoded_Library");
+ Fill(Stream_General, 0, General_Encoded_Library_Settings, "Encoded_Library_Settings");
+ Fill(Stream_General, 0, General_Copyright, "Copyright");
+ Fill(Stream_General, 0, General_Producer_Copyright, "Producer_Copyright");
+ Fill(Stream_General, 0, General_TermsOfUse, "TermsOfUse");
+ Fill(Stream_General, 0, General_Copyright_Url, "Copyright/Url");
+ Fill(Stream_General, 0, General_ISRC, "ISRC");
+ Fill(Stream_General, 0, General_ISBN, "ISBN");
+ Fill(Stream_General, 0, General_BarCode, "BarCode");
+ Fill(Stream_General, 0, General_LCCN, "LCCN");
+ Fill(Stream_General, 0, General_CatalogNumber, "CatalogNumber");
+ Fill(Stream_General, 0, General_LabelCode, "LabelCode");
+ Fill(Stream_General, 0, General_Cover, "Y");
+ Fill(Stream_General, 0, General_Cover_Data, "Cover_Datas");
+ Fill(Stream_General, 0, General_Summary, "Summary");
+ Fill(Stream_General, 0, General_BPM, "100");
+}
+
+//---------------------------------------------------------------------------
+void File_Dummy::Fill_Dummy_Video()
+{
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_ID, "ID");
+ Fill(Stream_Video, 0, Video_UniqueID, "UniqueID");
+ Fill(Stream_Video, 0, Video_Title, "Title");
+ Fill(Stream_Video, 0, Video_Codec, "Codec");
+ Fill(Stream_Video, 0, Video_Codec_Info, "Codec/Info");
+ Fill(Stream_Video, 0, Video_Codec_Url, "http://--Codec/Url--");
+ Fill(Stream_Video, 0, Video_BitRate, "10000");
+ Fill(Stream_Video, 0, Video_BitRate_Mode, "BitRate_Mode");
+ Fill(Stream_Video, 0, Video_Encoded_Library, "Encoded_Library");
+ Fill(Stream_Video, 0, Video_Encoded_Library_Settings, "Encoded_Library_Settings");
+ if (KindOfDummy==_T("Album"))
+ {
+ Fill(Stream_Video, 0, Video_Width, "2000");
+ Fill(Stream_Video, 0, Video_Height, "3000");
+ }
+ else //if (KindOfDummy==_T("Movie"))
+ {
+ Fill(Stream_Video, 0, Video_DisplayAspectRatio, "2");
+ Fill(Stream_Video, 0, Video_FrameRate, "24.976");
+ Fill(Stream_Video, 0, Video_FrameCount, "FrameCount");
+ Fill(Stream_Video, 0, Video_BitDepth, "8");
+ Fill(Stream_Video, 0, Video_Bits__Pixel_Frame_, "Bits/(Pixel*Frame)");
+ Fill(Stream_Video, 0, Video_Delay, "100");
+ Fill(Stream_Video, 0, Video_Duration, "990000");
+ }
+ Fill(Stream_Video, 0, Video_Language, "eng");
+ Fill(Stream_Video, 0, Video_Language_More, "Language_More");
+}
+
+//---------------------------------------------------------------------------
+void File_Dummy::Fill_Dummy_Audio()
+{
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_ID, "ID");
+ Fill(Stream_Audio, 0, Audio_UniqueID, "UniqueID");
+ Fill(Stream_Audio, 0, Audio_Title, "Title");
+ Fill(Stream_Audio, 0, Audio_Format, "Format");
+ Fill(Stream_Audio, 0, Audio_Format_Info, "Format/Info");
+ Fill(Stream_Audio, 0, Audio_Format_Url, "http://--Format/Url--");
+ Fill(Stream_Audio, 0, Audio_Codec, "Codec");
+ Fill(Stream_Audio, 0, Audio_Codec_Info, "Codec/Info");
+ Fill(Stream_Audio, 0, Audio_Codec_Url, "http://--Codec/Url--");
+ Fill(Stream_Audio, 0, Audio_BitRate, "1000");
+ Fill(Stream_Audio, 0, Audio_BitRate_Mode, "BitRate_Mode");
+ Fill(Stream_Audio, 0, Audio_Encoded_Library, "Encoded_Library");
+ Fill(Stream_Audio, 0, Audio_Encoded_Library_Settings, "Encoded_Library_Settings");
+ Fill(Stream_Audio, 0, Audio_Channel_s_, 2);
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, "ChannelPositions");
+ Fill(Stream_Audio, 0, Audio_SamplingRate, "48000");
+ Fill(Stream_Audio, 0, Audio_SamplingCount, "SamplingCount");
+ Fill(Stream_Audio, 0, Audio_BitDepth, "BitDepth");
+ Fill(Stream_Audio, 0, Audio_Delay, "10");
+ Fill(Stream_Audio, 0, Audio_Duration, "100000");
+ Fill(Stream_Audio, 0, Audio_Language, "fre");
+ Fill(Stream_Audio, 0, Audio_Language_More, "Language_More");
+}
+
+//---------------------------------------------------------------------------
+void File_Dummy::Fill_Dummy_Text()
+{
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_ID, "ID");
+ Fill(Stream_Text, 0, Text_UniqueID, "UniqueID");
+ Fill(Stream_Text, 0, Text_Title, "Title");
+ Fill(Stream_Text, 0, Text_Codec, "Codec");
+ Fill(Stream_Text, 0, Text_Codec_Url, "http://--Codec/Url--");
+ Fill(Stream_Text, 0, Text_Delay, "100");
+ Fill(Stream_Text, 0, Text_Duration, "100");
+ Fill(Stream_Text, 0, Text_Language, "de");
+ Fill(Stream_Text, 0, Text_Language_More, "Language_More");
+ Fill(Stream_Text, 0, Text_Summary, "Summary");
+}
+
+//---------------------------------------------------------------------------
+void File_Dummy::Fill_Dummy_Chapters()
+{
+ Stream_Prepare(Stream_Chapters);
+ Fill(Stream_Chapters, 0, Chapters_ID, "ID");
+ Fill(Stream_Chapters, 0, Chapters_UniqueID, "UniqueID");
+ Fill(Stream_Chapters, 0, Chapters_Title, "Title");
+ Fill(Stream_Chapters, 0, Chapters_Total, "Total");
+ Fill(Stream_Chapters, 0, Chapters_Language, "de");
+}
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File_Dummy.h b/src/thirdparty/MediaInfo/MediaInfo/File_Dummy.h
new file mode 100644
index 000000000..f33faad3b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File_Dummy.h
@@ -0,0 +1,60 @@
+// File_Dummy - Fill with Name of tags
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Fill with Name of tags
+// Used to give an example to the GUI of what MediaInfo can do
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_DummyH
+#define MediaInfo_File_DummyH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Dummy
+//***************************************************************************
+
+class File_Dummy : public File__Analyze
+{
+public :
+ Ztring KindOfDummy;
+
+protected :
+ //Buffer - File header
+ void FileHeader_Parse ();
+
+private :
+ void Fill_Dummy_General();
+ void Fill_Dummy_Video();
+ void Fill_Dummy_Audio();
+ void Fill_Dummy_Text();
+ void Fill_Dummy_Chapters();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File_Other.cpp b/src/thirdparty/MediaInfo/MediaInfo/File_Other.cpp
new file mode 100644
index 000000000..ad0885c8f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File_Other.cpp
@@ -0,0 +1,190 @@
+// File_Other - Use magic number to detect only the format
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_OTHER_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File_Other.h"
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Other::Read_Buffer_Continue()
+{
+ //Integrity
+ if (Buffer_Size<16)
+ return;
+
+ Ztring Format;
+ if (CC4(Buffer)==0xC5C6CBC3) {Format=_T("RISC OS Chunk data");}
+ else if (CC4(Buffer)==0x110000EF) {Format=_T("RISC OS AIF executable");}
+ else if (CC4(Buffer)==CC4("Draw")) {Format=_T("RISC OS Draw");}
+ else if (CC4(Buffer)==CC4("FONT")) {Format=_T("RISC OS Font");}
+ else if (CC8(Buffer)==CC8("Maestro\r")) {Format=_T("RISC OS music file");}
+ else if (CC4(Buffer)==CC4("FC14")) {Format=_T("Amiga Future Composer");}
+ else if (CC4(Buffer)==CC4("SMOD")) {Format=_T("Amiga Future Composer");}
+ else if (CC4(Buffer)==CC4("AON4")) {Format=_T("Amiga Art Of Noise");}
+ else if (CC8(Buffer+1)==CC8("MUGICIAN")) {Format=_T("Amiga Mugician");}
+ else if (Buffer_Size>=66 && CC8(Buffer+58)==CC8("SIDMON I")) {Format=_T("Amiga Sidmon");}
+ else if (CC8(Buffer)==CC8("Synth4.0")) {Format=_T("Amiga Synthesis");}
+ else if (CC4(Buffer)==CC4("ARP.")) {Format=_T("Amiga Holy Noise");}
+ else if (CC4(Buffer)==CC4("BeEp")) {Format=_T("Amiga JamCracker");}
+ else if (CC4(Buffer)==CC4("COSO")) {Format=_T("Amiga Hippel-COSO");}
+ else if (CC3(Buffer)==CC3("LSX")) {Format=_T("Amiga LZX");}
+ else if (CC4(Buffer)==CC4("MOVI")) {Format=_T("Silicon Graphics movie");}
+ else if (CC4(Buffer+10)==CC4("Vivo")) {Format=_T("Vivo");}
+ else if (CC4(Buffer+1)==CC4("VRML")) {Format=_T("VRML");}
+ else if (CC5(Buffer)==CC5("HVQM4")) {Format=_T("GameCube Movie");}
+ else if (CC8(Buffer)==CC8("KW-DIRAC"))
+ {
+ Accept("Dirac");
+
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "Dirac");
+
+ Finish("Dirac");
+ return;
+ }
+ else if (CC5(Buffer)==CC5("ustar")) {Format=_T("Tar archive");}
+ //TODO: all archive magic numbers
+ else if (CC4(Buffer+1)==CC4("MSCB")) {Format=_T("MS Cabinet");}
+ else if (CC4(Buffer)==CC4(".snd")) {Format=_T("SUN Audio");}
+ else if (CC4(Buffer)==0x2E736400) {Format=_T("DEC Audio");}
+ else if (CC4(Buffer)==CC4("MThd")) {Format=_T("MIDI");}
+ else if (CC4(Buffer)==CC4("CTMF")) {Format=_T("CMF");}
+ else if (CC3(Buffer)==CC3("SBI")) {Format=_T("SoundBlaster");}
+ else if (CC4(Buffer)==CC4("EMOD")) {Format=_T("Ext. MOD");}
+ //TODO: Other Sound magic numbers
+ else if (CC7(Buffer)==CC7("BLENDER")) {Format=_T("Blender");}
+ else if (CC4(Buffer)==CC4("AC10")) {Format=_T("AutoCAD"); ;}
+ else if (CC2(Buffer)==0x1F9D) {Format=_T("Compress");}
+ else if (CC2(Buffer)==0x1F8B) {Format=_T("GZip");}
+ else if (CC2(Buffer)==0x1F1E) {Format=_T("Huffman");}
+ else if (CC3(Buffer)==CC3("BZh")) {Format=_T("BZip2");}
+ else if (CC2(Buffer)==CC2("BZ")) {Format=_T("BZip1");}
+ else if (CC3(Buffer)==CC3("NES")) {Format=_T("NES ROM");}
+ else if (Buffer_Size>=0x108 && CC4(Buffer+0x104)==0xCEED6666) {Format=_T("GameBoy");}
+ else if (Buffer_Size>=0x104 && CC4(Buffer+0x100)==CC4("SEGA")) {Format=_T("MegaDrive");}
+ else if (Buffer_Size>=0x284 && CC4(Buffer+0x280)==CC4("EAGN")) {Format=_T("SupeMegaDrive");}
+ else if (Buffer_Size>=0x284 && CC4(Buffer+0x280)==CC4("EAMG")) {Format=_T("SupeMegaDrive");}
+ else if (CC4(Buffer)==0x21068028) {Format=_T("Dreamcast");}
+ else if (CC4(Buffer)==CC4("LCDi")) {Format=_T("Dreamcast");}
+ else if (CC4(Buffer)==0x37804012) {Format=_T("Nintendo64");}
+ else if (CC8(Buffer)==CC8("PS-X EXE")) {Format=_T("Playstation");}
+ else if (CC4(Buffer)==CC4("LCDi")) {Format=_T("Dreamcast");}
+ else if (CC4(Buffer)==CC4("XBEH")) {Format=_T("X-Box");}
+ else if (CC4(Buffer)==CC4("XIP0")) {Format=_T("X-Box");}
+ else if (CC4(Buffer)==CC4("XTF0")) {Format=_T("X-Box");}
+ else if (CC2(Buffer)==0x8008) {Format=_T("Lynx");}
+ else if (CC7(Buffer)==CC7("\x01ZZZZZ\x01")) {Format=_T("");}
+ else if (CC6(Buffer)==CC6("1\x0A\x0D""00:"))
+ {
+ Accept("SRT");
+
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Format, "SRT");
+
+ Finish("SRT");
+ return;
+ }
+ else if ((CC1(Buffer+0)==CC1("[") && CC1(Buffer+2)==CC1("S") && CC1(Buffer+22)==CC1("o") && CC1(Buffer+24)==CC1("]")) //Unicode Text is : "[Script Info]
+ || (CC1(Buffer+2)==CC1("[") && CC1(Buffer+4)==CC1("S") && CC1(Buffer+24)==CC1("o") && CC1(Buffer+26)==CC1("]")))
+ {
+ Accept("SSA");
+
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Format, "SSA");
+
+ Finish("SSA");
+ return;
+ }
+ else if (CC4(Buffer)==CC4("RIFF") && CC4(Buffer+8)==CC4("AMV ")) {Format=_T("AMV");}
+ else if (CC4(Buffer)==CC4("RIFF") && CC4(Buffer+8)==CC4("WEBP"))
+ {
+ Accept("WEBP");
+
+ Stream_Prepare(Stream_Image);
+ Fill(Stream_Image, 0, Image_Format, "WebP");
+
+ Finish("WEBP");
+ return;
+ }
+ else if (CC4(Buffer)==0x414D5697) {Format=_T("MTV");}
+ else if (CC6(Buffer)==CC6("Z\0W\0F\0"))
+ {
+ Accept("ZWF");
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "ZWF");
+
+ Finish("ZWF");
+ return;
+ }
+ else if (CC4(Buffer)==0x616A6B67) //"ajkg"
+ {
+ Accept("Shorten");
+
+ Fill(Stream_General, 0, General_Format_Version, CC1(Buffer+4));
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "Shorten");
+
+ Finish("Shorten");
+ return;
+ }
+ else if (CC4(Buffer)==CC4("")) {Format=_T("");}
+
+ if (Format.empty())
+ {
+ Reject();
+ return;
+ }
+
+ Accept();
+
+ Fill(Stream_General, 0, General_Format, Format);
+
+ Finish();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_OTHER_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File_Other.h b/src/thirdparty/MediaInfo/MediaInfo/File_Other.h
new file mode 100644
index 000000000..3cfcea5b3
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File_Other.h
@@ -0,0 +1,51 @@
+// File_Other - Use magic number to detect only the format
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Use magic number to detect only the format
+// Theses formats are not planned to be expanded, this is only to detect
+// well all files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_OtherH
+#define MediaInfo_File_OtherH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Other
+//***************************************************************************
+
+class File_Other : public File__Analyze
+{
+protected :
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File_Unknown.cpp b/src/thirdparty/MediaInfo/MediaInfo/File_Unknown.cpp
new file mode 100644
index 000000000..8dc0aef9a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File_Unknown.cpp
@@ -0,0 +1,67 @@
+// File_Unknown - Empty container
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_UNKNOWN_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File_Unknown.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Unknown::Read_Buffer_Init()
+{
+ Accept("Unknown");
+ Finish("Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Unknown::Read_Buffer_Continue()
+{
+ Skip_XX(Element_Size, "Unknown");
+}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_UNKNOWN_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File_Unknown.h b/src/thirdparty/MediaInfo/MediaInfo/File_Unknown.h
new file mode 100644
index 000000000..e41c9b7c0
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File_Unknown.h
@@ -0,0 +1,53 @@
+// File_Unknown - Empty container
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Empty container
+// This is only to have a void parser
+// It fill basic fields (filename...) only
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_UnknownH
+#define MediaInfo_File_UnknownH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Unknown
+//***************************************************************************
+
+class File_Unknown : public File__Analyze
+{
+protected :
+ //Buffer - Global
+ void Read_Buffer_Init ();
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Analyse_Automatic.h b/src/thirdparty/MediaInfo/MediaInfo/File__Analyse_Automatic.h
new file mode 100644
index 000000000..5dd80e4b2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Analyse_Automatic.h
@@ -0,0 +1,1324 @@
+// Enums - Automaticly generated enums for MediaInfo
+// Copyright (C) 2008-2008 Jerome Martinez, Zen@MediaArea.net
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Automaticly generated methods for MediaInfo
+// Don't modify, this will be deleted at the next automatic update
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File__Analyze_AutomaticH
+#define MediaInfo_File__Analyze_AutomaticH
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+enum generic
+{
+ Generic_Format,
+ Generic_Format_Info,
+ Generic_Format_Url,
+ Generic_Format_Commercial,
+ Generic_Format_Commercial_IfAny,
+ Generic_Format_Version,
+ Generic_Format_Profile,
+ Generic_Format_Compression,
+ Generic_Format_Settings,
+ Generic_InternetMediaType,
+ Generic_CodecID,
+ Generic_CodecID_Info,
+ Generic_CodecID_Hint,
+ Generic_CodecID_Url,
+ Generic_CodecID_Description,
+ Generic_Codec,
+ Generic_Codec_String,
+ Generic_Codec_Info,
+ Generic_Codec_Url,
+ Generic_Codec_CC,
+ Generic_Duration,
+ Generic_Duration_String,
+ Generic_Duration_String1,
+ Generic_Duration_String2,
+ Generic_Duration_String3,
+ Generic_Source_Duration,
+ Generic_Source_Duration_String,
+ Generic_Source_Duration_String1,
+ Generic_Source_Duration_String2,
+ Generic_Source_Duration_String3,
+ Generic_BitRate_Mode,
+ Generic_BitRate_Mode_String,
+ Generic_BitRate,
+ Generic_BitRate_String,
+ Generic_BitRate_Minimum,
+ Generic_BitRate_Minimum_String,
+ Generic_BitRate_Nominal,
+ Generic_BitRate_Nominal_String,
+ Generic_BitRate_Maximum,
+ Generic_BitRate_Maximum_String,
+ Generic_BitRate_Encoded,
+ Generic_BitRate_Encoded_String,
+ Generic_FrameCount,
+ Generic_Source_FrameCount,
+ Generic_ColorSpace,
+ Generic_ChromaSubsampling,
+ Generic_Resolution,
+ Generic_Resolution_String,
+ Generic_BitDepth,
+ Generic_BitDepth_String,
+ Generic_Compression_Mode,
+ Generic_Compression_Mode_String,
+ Generic_Compression_Ratio,
+ Generic_Delay,
+ Generic_Delay_String,
+ Generic_Delay_String1,
+ Generic_Delay_String2,
+ Generic_Delay_String3,
+ Generic_Delay_String4,
+ Generic_Delay_Settings,
+ Generic_Delay_Source,
+ Generic_Delay_Source_String,
+ Generic_Delay_Original,
+ Generic_Delay_Original_String,
+ Generic_Delay_Original_String1,
+ Generic_Delay_Original_String2,
+ Generic_Delay_Original_String3,
+ Generic_Delay_Original_String4,
+ Generic_Delay_Original_Settings,
+ Generic_Delay_Original_Source,
+ Generic_Video_Delay,
+ Generic_Video_Delay_String,
+ Generic_Video_Delay_String1,
+ Generic_Video_Delay_String2,
+ Generic_Video_Delay_String3,
+ Generic_Video_Delay_String4,
+ Generic_StreamSize,
+ Generic_StreamSize_String,
+ Generic_StreamSize_String1,
+ Generic_StreamSize_String2,
+ Generic_StreamSize_String3,
+ Generic_StreamSize_String4,
+ Generic_StreamSize_String5,
+ Generic_StreamSize_Proportion,
+ Generic_Source_StreamSize,
+ Generic_Source_StreamSize_String,
+ Generic_Source_StreamSize_String1,
+ Generic_Source_StreamSize_String2,
+ Generic_Source_StreamSize_String3,
+ Generic_Source_StreamSize_String4,
+ Generic_Source_StreamSize_String5,
+ Generic_Source_StreamSize_Proportion,
+ Generic_StreamSize_Encoded,
+ Generic_StreamSize_Encoded_String,
+ Generic_StreamSize_Encoded_String1,
+ Generic_StreamSize_Encoded_String2,
+ Generic_StreamSize_Encoded_String3,
+ Generic_StreamSize_Encoded_String4,
+ Generic_StreamSize_Encoded_String5,
+ Generic_StreamSize_Encoded_Proportion,
+ Generic_Source_StreamSize_Encoded,
+ Generic_Source_StreamSize_Encoded_String,
+ Generic_Source_StreamSize_Encoded_String1,
+ Generic_Source_StreamSize_Encoded_String2,
+ Generic_Source_StreamSize_Encoded_String3,
+ Generic_Source_StreamSize_Encoded_String4,
+ Generic_Source_StreamSize_Encoded_String5,
+ Generic_Source_StreamSize_Encoded_Proportion,
+ Generic_Language,
+ Generic_ServiceName,
+ Generic_ServiceProvider,
+};
+
+//---------------------------------------------------------------------------
+enum general
+{
+ General_Count,
+ General_Status,
+ General_StreamCount,
+ General_StreamKind,
+ General_StreamKind_String,
+ General_StreamKindID,
+ General_StreamKindPos,
+ General_StreamOrder,
+ General_Inform,
+ General_ID,
+ General_ID_String,
+ General_UniqueID,
+ General_UniqueID_String,
+ General_MenuID,
+ General_MenuID_String,
+ General_GeneralCount,
+ General_VideoCount,
+ General_AudioCount,
+ General_TextCount,
+ General_ChaptersCount,
+ General_ImageCount,
+ General_MenuCount,
+ General_Video_Format_List,
+ General_Video_Format_WithHint_List,
+ General_Video_Codec_List,
+ General_Video_Language_List,
+ General_Audio_Format_List,
+ General_Audio_Format_WithHint_List,
+ General_Audio_Codec_List,
+ General_Audio_Language_List,
+ General_Text_Format_List,
+ General_Text_Format_WithHint_List,
+ General_Text_Codec_List,
+ General_Text_Language_List,
+ General_Chapters_Format_List,
+ General_Chapters_Format_WithHint_List,
+ General_Chapters_Codec_List,
+ General_Chapters_Language_List,
+ General_Image_Format_List,
+ General_Image_Format_WithHint_List,
+ General_Image_Codec_List,
+ General_Image_Language_List,
+ General_Menu_Format_List,
+ General_Menu_Format_WithHint_List,
+ General_Menu_Codec_List,
+ General_Menu_Language_List,
+ General_CompleteName,
+ General_FolderName,
+ General_FileName,
+ General_FileExtension,
+ General_Format,
+ General_Format_String,
+ General_Format_Info,
+ General_Format_Url,
+ General_Format_Extensions,
+ General_Format_Commercial,
+ General_Format_Commercial_IfAny,
+ General_Format_Version,
+ General_Format_Profile,
+ General_Format_Compression,
+ General_Format_Settings,
+ General_InternetMediaType,
+ General_CodecID,
+ General_CodecID_String,
+ General_CodecID_Info,
+ General_CodecID_Hint,
+ General_CodecID_Url,
+ General_CodecID_Description,
+ General_Interleaved,
+ General_Codec,
+ General_Codec_String,
+ General_Codec_Info,
+ General_Codec_Url,
+ General_Codec_Extensions,
+ General_Codec_Settings,
+ General_Codec_Settings_Automatic,
+ General_FileSize,
+ General_FileSize_String,
+ General_FileSize_String1,
+ General_FileSize_String2,
+ General_FileSize_String3,
+ General_FileSize_String4,
+ General_Duration,
+ General_Duration_String,
+ General_Duration_String1,
+ General_Duration_String2,
+ General_Duration_String3,
+ General_Duration_Start,
+ General_Duration_End,
+ General_OverallBitRate_Mode,
+ General_OverallBitRate_Mode_String,
+ General_OverallBitRate,
+ General_OverallBitRate_String,
+ General_OverallBitRate_Minimum,
+ General_OverallBitRate_Minimum_String,
+ General_OverallBitRate_Nominal,
+ General_OverallBitRate_Nominal_String,
+ General_OverallBitRate_Maximum,
+ General_OverallBitRate_Maximum_String,
+ General_Delay,
+ General_Delay_String,
+ General_Delay_String1,
+ General_Delay_String2,
+ General_Delay_String3,
+ General_StreamSize,
+ General_StreamSize_String,
+ General_StreamSize_String1,
+ General_StreamSize_String2,
+ General_StreamSize_String3,
+ General_StreamSize_String4,
+ General_StreamSize_String5,
+ General_StreamSize_Proportion,
+ General_HeaderSize,
+ General_DataSize,
+ General_FooterSize,
+ General_IsStreamable,
+ General_Album_ReplayGain_Gain,
+ General_Album_ReplayGain_Gain_String,
+ General_Album_ReplayGain_Peak,
+ General_Encryption,
+ General_Title,
+ General_Title_More,
+ General_Title_Url,
+ General_Domain,
+ General_Collection,
+ General_Season,
+ General_Season_Position,
+ General_Season_Position_Total,
+ General_Movie,
+ General_Movie_More,
+ General_Movie_Country,
+ General_Movie_Url,
+ General_Album,
+ General_Album_More,
+ General_Album_Sort,
+ General_Album_Performer,
+ General_Album_Performer_Sort,
+ General_Album_Performer_Url,
+ General_Comic,
+ General_Comic_More,
+ General_Comic_Position_Total,
+ General_Part,
+ General_Part_Position,
+ General_Part_Position_Total,
+ General_Track,
+ General_Track_More,
+ General_Track_Url,
+ General_Track_Sort,
+ General_Track_Position,
+ General_Track_Position_Total,
+ General_Grouping,
+ General_Chapter,
+ General_SubTrack,
+ General_Original_Album,
+ General_Original_Movie,
+ General_Original_Part,
+ General_Original_Track,
+ General_Compilation,
+ General_Compilation_String,
+ General_Performer,
+ General_Performer_Sort,
+ General_Performer_Url,
+ General_Original_Performer,
+ General_Accompaniment,
+ General_Composer,
+ General_Composer_Nationality,
+ General_Arranger,
+ General_Lyricist,
+ General_Original_Lyricist,
+ General_Conductor,
+ General_Director,
+ General_AssistantDirector,
+ General_DirectorOfPhotography,
+ General_SoundEngineer,
+ General_ArtDirector,
+ General_ProductionDesigner,
+ General_Choregrapher,
+ General_CostumeDesigner,
+ General_Actor,
+ General_Actor_Character,
+ General_WrittenBy,
+ General_ScreenplayBy,
+ General_EditedBy,
+ General_CommissionedBy,
+ General_Producer,
+ General_CoProducer,
+ General_ExecutiveProducer,
+ General_MusicBy,
+ General_DistributedBy,
+ General_OriginalSourceForm_DistributedBy,
+ General_MasteredBy,
+ General_EncodedBy,
+ General_RemixedBy,
+ General_ProductionStudio,
+ General_ThanksTo,
+ General_Publisher,
+ General_Publisher_URL,
+ General_Label,
+ General_Genre,
+ General_Mood,
+ General_ContentType,
+ General_Subject,
+ General_Description,
+ General_Keywords,
+ General_Summary,
+ General_Synopsis,
+ General_Period,
+ General_LawRating,
+ General_LawRating_Reason,
+ General_ICRA,
+ General_Released_Date,
+ General_Original_Released_Date,
+ General_Recorded_Date,
+ General_Encoded_Date,
+ General_Tagged_Date,
+ General_Written_Date,
+ General_Mastered_Date,
+ General_File_Created_Date,
+ General_File_Created_Date_Local,
+ General_File_Modified_Date,
+ General_File_Modified_Date_Local,
+ General_Recorded_Location,
+ General_Written_Location,
+ General_Archival_Location,
+ General_Encoded_Application,
+ General_Encoded_Application_Url,
+ General_Encoded_Library,
+ General_Encoded_Library_String,
+ General_Encoded_Library_Name,
+ General_Encoded_Library_Version,
+ General_Encoded_Library_Date,
+ General_Encoded_Library_Settings,
+ General_Cropped,
+ General_Dimensions,
+ General_DotsPerInch,
+ General_Lightness,
+ General_OriginalSourceMedium,
+ General_OriginalSourceForm,
+ General_OriginalSourceForm_NumColors,
+ General_OriginalSourceForm_Name,
+ General_OriginalSourceForm_Cropped,
+ General_OriginalSourceForm_Sharpness,
+ General_Tagged_Application,
+ General_BPM,
+ General_ISRC,
+ General_ISBN,
+ General_BarCode,
+ General_LCCN,
+ General_CatalogNumber,
+ General_LabelCode,
+ General_Owner,
+ General_Copyright,
+ General_Copyright_Url,
+ General_Producer_Copyright,
+ General_TermsOfUse,
+ General_ServiceName,
+ General_ServiceChannel,
+ General_Service_Url,
+ General_ServiceProvider,
+ General_ServiceProviderr_Url,
+ General_ServiceType,
+ General_NetworkName,
+ General_OriginalNetworkName,
+ General_Country,
+ General_TimeZone,
+ General_Cover,
+ General_Cover_Description,
+ General_Cover_Type,
+ General_Cover_Mime,
+ General_Cover_Data,
+ General_Lyrics,
+ General_Comment,
+ General_Rating,
+ General_Added_Date,
+ General_Played_First_Date,
+ General_Played_Last_Date,
+ General_Played_Count,
+ General_EPG_Positions_Begin,
+ General_EPG_Positions_End,
+};
+
+//---------------------------------------------------------------------------
+enum video
+{
+ Video_Count,
+ Video_Status,
+ Video_StreamCount,
+ Video_StreamKind,
+ Video_StreamKind_String,
+ Video_StreamKindID,
+ Video_StreamKindPos,
+ Video_StreamOrder,
+ Video_Inform,
+ Video_ID,
+ Video_ID_String,
+ Video_UniqueID,
+ Video_UniqueID_String,
+ Video_MenuID,
+ Video_MenuID_String,
+ Video_Format,
+ Video_Format_Info,
+ Video_Format_Url,
+ Video_Format_Commercial,
+ Video_Format_Commercial_IfAny,
+ Video_Format_Version,
+ Video_Format_Profile,
+ Video_Format_Compression,
+ Video_MultiView_BaseProfile,
+ Video_MultiView_Count,
+ Video_MultiView_Layout,
+ Video_Format_Settings,
+ Video_Format_Settings_BVOP,
+ Video_Format_Settings_BVOP_String,
+ Video_Format_Settings_QPel,
+ Video_Format_Settings_QPel_String,
+ Video_Format_Settings_GMC,
+ Video_Format_Settings_GMC_String,
+ Video_Format_Settings_Matrix,
+ Video_Format_Settings_Matrix_String,
+ Video_Format_Settings_Matrix_Data,
+ Video_Format_Settings_CABAC,
+ Video_Format_Settings_CABAC_String,
+ Video_Format_Settings_RefFrames,
+ Video_Format_Settings_RefFrames_String,
+ Video_Format_Settings_Pulldown,
+ Video_Format_Settings_FrameMode,
+ Video_Format_Settings_GOP,
+ Video_Format_Settings_FrameStructures,
+ Video_Format_Settings_Wrapping,
+ Video_InternetMediaType,
+ Video_MuxingMode,
+ Video_CodecID,
+ Video_CodecID_String,
+ Video_CodecID_Info,
+ Video_CodecID_Hint,
+ Video_CodecID_Url,
+ Video_CodecID_Description,
+ Video_Codec,
+ Video_Codec_String,
+ Video_Codec_Family,
+ Video_Codec_Info,
+ Video_Codec_Url,
+ Video_Codec_CC,
+ Video_Codec_Profile,
+ Video_Codec_Description,
+ Video_Codec_Settings,
+ Video_Codec_Settings_PacketBitStream,
+ Video_Codec_Settings_BVOP,
+ Video_Codec_Settings_QPel,
+ Video_Codec_Settings_GMC,
+ Video_Codec_Settings_GMC_String,
+ Video_Codec_Settings_Matrix,
+ Video_Codec_Settings_Matrix_Data,
+ Video_Codec_Settings_CABAC,
+ Video_Codec_Settings_RefFrames,
+ Video_Duration,
+ Video_Duration_String,
+ Video_Duration_String1,
+ Video_Duration_String2,
+ Video_Duration_String3,
+ Video_Duration_String4,
+ Video_Duration_FirstFrame,
+ Video_Duration_FirstFrame_String,
+ Video_Duration_FirstFrame_String1,
+ Video_Duration_FirstFrame_String2,
+ Video_Duration_FirstFrame_String3,
+ Video_Duration_LastFrame,
+ Video_Duration_LastFrame_String,
+ Video_Duration_LastFrame_String1,
+ Video_Duration_LastFrame_String2,
+ Video_Duration_LastFrame_String3,
+ Video_Source_Duration,
+ Video_Source_Duration_String,
+ Video_Source_Duration_String1,
+ Video_Source_Duration_String2,
+ Video_Source_Duration_String3,
+ Video_Source_Duration_FirstFrame,
+ Video_Source_Duration_FirstFrame_String,
+ Video_Source_Duration_FirstFrame_String1,
+ Video_Source_Duration_FirstFrame_String2,
+ Video_Source_Duration_FirstFrame_String3,
+ Video_Source_Duration_LastFrame,
+ Video_Source_Duration_LastFrame_String,
+ Video_Source_Duration_LastFrame_String1,
+ Video_Source_Duration_LastFrame_String2,
+ Video_Source_Duration_LastFrame_String3,
+ Video_BitRate_Mode,
+ Video_BitRate_Mode_String,
+ Video_BitRate,
+ Video_BitRate_String,
+ Video_BitRate_Minimum,
+ Video_BitRate_Minimum_String,
+ Video_BitRate_Nominal,
+ Video_BitRate_Nominal_String,
+ Video_BitRate_Maximum,
+ Video_BitRate_Maximum_String,
+ Video_BitRate_Encoded,
+ Video_BitRate_Encoded_String,
+ Video_Width,
+ Video_Width_String,
+ Video_Width_Offset,
+ Video_Width_Offset_String,
+ Video_Width_Original,
+ Video_Width_Original_String,
+ Video_Height,
+ Video_Height_String,
+ Video_Height_Offset,
+ Video_Height_Offset_String,
+ Video_Height_Original,
+ Video_Height_Original_String,
+ Video_PixelAspectRatio,
+ Video_PixelAspectRatio_String,
+ Video_PixelAspectRatio_Original,
+ Video_PixelAspectRatio_Original_String,
+ Video_DisplayAspectRatio,
+ Video_DisplayAspectRatio_String,
+ Video_DisplayAspectRatio_Original,
+ Video_DisplayAspectRatio_Original_String,
+ Video_ActiveFormatDescription,
+ Video_ActiveFormatDescription_String,
+ Video_ActiveFormatDescription_MuxingMode,
+ Video_Rotation,
+ Video_Rotation_String,
+ Video_FrameRate_Mode,
+ Video_FrameRate_Mode_String,
+ Video_FrameRate_Mode_Original,
+ Video_FrameRate_Mode_Original_String,
+ Video_FrameRate,
+ Video_FrameRate_String,
+ Video_FrameRate_Original,
+ Video_FrameRate_Original_String,
+ Video_FrameRate_Minimum,
+ Video_FrameRate_Minimum_String,
+ Video_FrameRate_Nominal,
+ Video_FrameRate_Nominal_String,
+ Video_FrameRate_Maximum,
+ Video_FrameRate_Maximum_String,
+ Video_FrameCount,
+ Video_Source_FrameCount,
+ Video_Standard,
+ Video_Resolution,
+ Video_Resolution_String,
+ Video_Colorimetry,
+ Video_ColorSpace,
+ Video_ChromaSubsampling,
+ Video_BitDepth,
+ Video_BitDepth_String,
+ Video_ScanType,
+ Video_ScanType_String,
+ Video_ScanOrder,
+ Video_ScanOrder_String,
+ Video_Interlacement,
+ Video_Interlacement_String,
+ Video_Compression_Mode,
+ Video_Compression_Mode_String,
+ Video_Compression_Ratio,
+ Video_Bits__Pixel_Frame_,
+ Video_Delay,
+ Video_Delay_String,
+ Video_Delay_String1,
+ Video_Delay_String2,
+ Video_Delay_String3,
+ Video_Delay_String4,
+ Video_Delay_Settings,
+ Video_Delay_Source,
+ Video_Delay_Source_String,
+ Video_Delay_Original,
+ Video_Delay_Original_String,
+ Video_Delay_Original_String1,
+ Video_Delay_Original_String2,
+ Video_Delay_Original_String3,
+ Video_Delay_Original_String4,
+ Video_Delay_Original_Settings,
+ Video_Delay_Original_Source,
+ Video_StreamSize,
+ Video_StreamSize_String,
+ Video_StreamSize_String1,
+ Video_StreamSize_String2,
+ Video_StreamSize_String3,
+ Video_StreamSize_String4,
+ Video_StreamSize_String5,
+ Video_StreamSize_Proportion,
+ Video_Source_StreamSize,
+ Video_Source_StreamSize_String,
+ Video_Source_StreamSize_String1,
+ Video_Source_StreamSize_String2,
+ Video_Source_StreamSize_String3,
+ Video_Source_StreamSize_String4,
+ Video_Source_StreamSize_String5,
+ Video_Source_StreamSize_Proportion,
+ Video_StreamSize_Encoded,
+ Video_StreamSize_Encoded_String,
+ Video_StreamSize_Encoded_String1,
+ Video_StreamSize_Encoded_String2,
+ Video_StreamSize_Encoded_String3,
+ Video_StreamSize_Encoded_String4,
+ Video_StreamSize_Encoded_String5,
+ Video_StreamSize_Encoded_Proportion,
+ Video_Source_StreamSize_Encoded,
+ Video_Source_StreamSize_Encoded_String,
+ Video_Source_StreamSize_Encoded_String1,
+ Video_Source_StreamSize_Encoded_String2,
+ Video_Source_StreamSize_Encoded_String3,
+ Video_Source_StreamSize_Encoded_String4,
+ Video_Source_StreamSize_Encoded_String5,
+ Video_Source_StreamSize_Encoded_Proportion,
+ Video_Alignment,
+ Video_Alignment_String,
+ Video_Title,
+ Video_Encoded_Application,
+ Video_Encoded_Application_Url,
+ Video_Encoded_Library,
+ Video_Encoded_Library_String,
+ Video_Encoded_Library_Name,
+ Video_Encoded_Library_Version,
+ Video_Encoded_Library_Date,
+ Video_Encoded_Library_Settings,
+ Video_Language,
+ Video_Language_String,
+ Video_Language_String1,
+ Video_Language_String2,
+ Video_Language_String3,
+ Video_Language_String4,
+ Video_Language_More,
+ Video_Default,
+ Video_Default_String,
+ Video_Forced,
+ Video_Forced_String,
+ Video_Encoded_Date,
+ Video_Tagged_Date,
+ Video_Encryption,
+ Video_BufferSize,
+};
+
+//---------------------------------------------------------------------------
+enum audio
+{
+ Audio_Count,
+ Audio_Status,
+ Audio_StreamCount,
+ Audio_StreamKind,
+ Audio_StreamKind_String,
+ Audio_StreamKindID,
+ Audio_StreamKindPos,
+ Audio_StreamOrder,
+ Audio_Inform,
+ Audio_ID,
+ Audio_ID_String,
+ Audio_UniqueID,
+ Audio_UniqueID_String,
+ Audio_MenuID,
+ Audio_MenuID_String,
+ Audio_Format,
+ Audio_Format_Info,
+ Audio_Format_Url,
+ Audio_Format_Commercial,
+ Audio_Format_Commercial_IfAny,
+ Audio_Format_Version,
+ Audio_Format_Profile,
+ Audio_Format_Compression,
+ Audio_Format_Settings,
+ Audio_Format_Settings_SBR,
+ Audio_Format_Settings_SBR_String,
+ Audio_Format_Settings_PS,
+ Audio_Format_Settings_PS_String,
+ Audio_Format_Settings_Mode,
+ Audio_Format_Settings_ModeExtension,
+ Audio_Format_Settings_Emphasis,
+ Audio_Format_Settings_Floor,
+ Audio_Format_Settings_Firm,
+ Audio_Format_Settings_Endianness,
+ Audio_Format_Settings_Sign,
+ Audio_Format_Settings_Law,
+ Audio_Format_Settings_ITU,
+ Audio_Format_Settings_Wrapping,
+ Audio_InternetMediaType,
+ Audio_MuxingMode,
+ Audio_MuxingMode_MoreInfo,
+ Audio_CodecID,
+ Audio_CodecID_String,
+ Audio_CodecID_Info,
+ Audio_CodecID_Hint,
+ Audio_CodecID_Url,
+ Audio_CodecID_Description,
+ Audio_Codec,
+ Audio_Codec_String,
+ Audio_Codec_Family,
+ Audio_Codec_Info,
+ Audio_Codec_Url,
+ Audio_Codec_CC,
+ Audio_Codec_Description,
+ Audio_Codec_Profile,
+ Audio_Codec_Settings,
+ Audio_Codec_Settings_Automatic,
+ Audio_Codec_Settings_Floor,
+ Audio_Codec_Settings_Firm,
+ Audio_Codec_Settings_Endianness,
+ Audio_Codec_Settings_Sign,
+ Audio_Codec_Settings_Law,
+ Audio_Codec_Settings_ITU,
+ Audio_Duration,
+ Audio_Duration_String,
+ Audio_Duration_String1,
+ Audio_Duration_String2,
+ Audio_Duration_String3,
+ Audio_Duration_FirstFrame,
+ Audio_Duration_FirstFrame_String,
+ Audio_Duration_FirstFrame_String1,
+ Audio_Duration_FirstFrame_String2,
+ Audio_Duration_FirstFrame_String3,
+ Audio_Duration_LastFrame,
+ Audio_Duration_LastFrame_String,
+ Audio_Duration_LastFrame_String1,
+ Audio_Duration_LastFrame_String2,
+ Audio_Duration_LastFrame_String3,
+ Audio_Source_Duration,
+ Audio_Source_Duration_String,
+ Audio_Source_Duration_String1,
+ Audio_Source_Duration_String2,
+ Audio_Source_Duration_String3,
+ Audio_Source_Duration_FirstFrame,
+ Audio_Source_Duration_FirstFrame_String,
+ Audio_Source_Duration_FirstFrame_String1,
+ Audio_Source_Duration_FirstFrame_String2,
+ Audio_Source_Duration_FirstFrame_String3,
+ Audio_Source_Duration_LastFrame,
+ Audio_Source_Duration_LastFrame_String,
+ Audio_Source_Duration_LastFrame_String1,
+ Audio_Source_Duration_LastFrame_String2,
+ Audio_Source_Duration_LastFrame_String3,
+ Audio_BitRate_Mode,
+ Audio_BitRate_Mode_String,
+ Audio_BitRate,
+ Audio_BitRate_String,
+ Audio_BitRate_Minimum,
+ Audio_BitRate_Minimum_String,
+ Audio_BitRate_Nominal,
+ Audio_BitRate_Nominal_String,
+ Audio_BitRate_Maximum,
+ Audio_BitRate_Maximum_String,
+ Audio_BitRate_Encoded,
+ Audio_BitRate_Encoded_String,
+ Audio_Channel_s_,
+ Audio_Channel_s__String,
+ Audio_ChannelPositions,
+ Audio_ChannelPositions_String2,
+ Audio_ChannelLayout,
+ Audio_SamplingRate,
+ Audio_SamplingRate_String,
+ Audio_SamplingCount,
+ Audio_Source_SamplingCount,
+ Audio_FrameRate,
+ Audio_FrameRate_String,
+ Audio_FrameCount,
+ Audio_Source_FrameCount,
+ Audio_Resolution,
+ Audio_Resolution_String,
+ Audio_BitDepth,
+ Audio_BitDepth_String,
+ Audio_Compression_Mode,
+ Audio_Compression_Mode_String,
+ Audio_Compression_Ratio,
+ Audio_Delay,
+ Audio_Delay_String,
+ Audio_Delay_String1,
+ Audio_Delay_String2,
+ Audio_Delay_String3,
+ Audio_Delay_String4,
+ Audio_Delay_Settings,
+ Audio_Delay_Source,
+ Audio_Delay_Source_String,
+ Audio_Delay_Original,
+ Audio_Delay_Original_String,
+ Audio_Delay_Original_String1,
+ Audio_Delay_Original_String2,
+ Audio_Delay_Original_String3,
+ Audio_Delay_Original_String4,
+ Audio_Delay_Original_Settings,
+ Audio_Delay_Original_Source,
+ Audio_Video_Delay,
+ Audio_Video_Delay_String,
+ Audio_Video_Delay_String1,
+ Audio_Video_Delay_String2,
+ Audio_Video_Delay_String3,
+ Audio_Video_Delay_String4,
+ Audio_Video0_Delay,
+ Audio_Video0_Delay_String,
+ Audio_Video0_Delay_String1,
+ Audio_Video0_Delay_String2,
+ Audio_Video0_Delay_String3,
+ Audio_Video0_Delay_String4,
+ Audio_ReplayGain_Gain,
+ Audio_ReplayGain_Gain_String,
+ Audio_ReplayGain_Peak,
+ Audio_StreamSize,
+ Audio_StreamSize_String,
+ Audio_StreamSize_String1,
+ Audio_StreamSize_String2,
+ Audio_StreamSize_String3,
+ Audio_StreamSize_String4,
+ Audio_StreamSize_String5,
+ Audio_StreamSize_Proportion,
+ Audio_Source_StreamSize,
+ Audio_Source_StreamSize_String,
+ Audio_Source_StreamSize_String1,
+ Audio_Source_StreamSize_String2,
+ Audio_Source_StreamSize_String3,
+ Audio_Source_StreamSize_String4,
+ Audio_Source_StreamSize_String5,
+ Audio_Source_StreamSize_Proportion,
+ Audio_StreamSize_Encoded,
+ Audio_StreamSize_Encoded_String,
+ Audio_StreamSize_Encoded_String1,
+ Audio_StreamSize_Encoded_String2,
+ Audio_StreamSize_Encoded_String3,
+ Audio_StreamSize_Encoded_String4,
+ Audio_StreamSize_Encoded_String5,
+ Audio_StreamSize_Encoded_Proportion,
+ Audio_Source_StreamSize_Encoded,
+ Audio_Source_StreamSize_Encoded_String,
+ Audio_Source_StreamSize_Encoded_String1,
+ Audio_Source_StreamSize_Encoded_String2,
+ Audio_Source_StreamSize_Encoded_String3,
+ Audio_Source_StreamSize_Encoded_String4,
+ Audio_Source_StreamSize_Encoded_String5,
+ Audio_Source_StreamSize_Encoded_Proportion,
+ Audio_Alignment,
+ Audio_Alignment_String,
+ Audio_Interleave_VideoFrames,
+ Audio_Interleave_Duration,
+ Audio_Interleave_Duration_String,
+ Audio_Interleave_Preload,
+ Audio_Interleave_Preload_String,
+ Audio_Title,
+ Audio_Encoded_Library,
+ Audio_Encoded_Library_String,
+ Audio_Encoded_Library_Name,
+ Audio_Encoded_Library_Version,
+ Audio_Encoded_Library_Date,
+ Audio_Encoded_Library_Settings,
+ Audio_Language,
+ Audio_Language_String,
+ Audio_Language_String1,
+ Audio_Language_String2,
+ Audio_Language_String3,
+ Audio_Language_String4,
+ Audio_Language_More,
+ Audio_Default,
+ Audio_Default_String,
+ Audio_Forced,
+ Audio_Forced_String,
+ Audio_Encoded_Date,
+ Audio_Tagged_Date,
+ Audio_Encryption,
+};
+
+//---------------------------------------------------------------------------
+enum text
+{
+ Text_Count,
+ Text_Status,
+ Text_StreamCount,
+ Text_StreamKind,
+ Text_StreamKind_String,
+ Text_StreamKindID,
+ Text_StreamKindPos,
+ Text_StreamOrder,
+ Text_Inform,
+ Text_ID,
+ Text_ID_String,
+ Text_UniqueID,
+ Text_UniqueID_String,
+ Text_MenuID,
+ Text_MenuID_String,
+ Text_Format,
+ Text_Format_Info,
+ Text_Format_Url,
+ Text_Format_Commercial,
+ Text_Format_Commercial_IfAny,
+ Text_Format_Version,
+ Text_Format_Profile,
+ Text_Format_Compression,
+ Text_Format_Settings,
+ Text_Format_Settings_Wrapping,
+ Text_InternetMediaType,
+ Text_MuxingMode,
+ Text_MuxingMode_MoreInfo,
+ Text_CodecID,
+ Text_CodecID_String,
+ Text_CodecID_Info,
+ Text_CodecID_Hint,
+ Text_CodecID_Url,
+ Text_CodecID_Description,
+ Text_Codec,
+ Text_Codec_String,
+ Text_Codec_Info,
+ Text_Codec_Url,
+ Text_Codec_CC,
+ Text_Duration,
+ Text_Duration_String,
+ Text_Duration_String1,
+ Text_Duration_String2,
+ Text_Duration_String3,
+ Text_Duration_String4,
+ Text_Duration_FirstFrame,
+ Text_Duration_FirstFrame_String,
+ Text_Duration_FirstFrame_String1,
+ Text_Duration_FirstFrame_String2,
+ Text_Duration_FirstFrame_String3,
+ Text_Duration_LastFrame,
+ Text_Duration_LastFrame_String,
+ Text_Duration_LastFrame_String1,
+ Text_Duration_LastFrame_String2,
+ Text_Duration_LastFrame_String3,
+ Text_Source_Duration,
+ Text_Source_Duration_String,
+ Text_Source_Duration_String1,
+ Text_Source_Duration_String2,
+ Text_Source_Duration_String3,
+ Text_Source_Duration_FirstFrame,
+ Text_Source_Duration_FirstFrame_String,
+ Text_Source_Duration_FirstFrame_String1,
+ Text_Source_Duration_FirstFrame_String2,
+ Text_Source_Duration_FirstFrame_String3,
+ Text_Source_Duration_LastFrame,
+ Text_Source_Duration_LastFrame_String,
+ Text_Source_Duration_LastFrame_String1,
+ Text_Source_Duration_LastFrame_String2,
+ Text_Source_Duration_LastFrame_String3,
+ Text_BitRate_Mode,
+ Text_BitRate_Mode_String,
+ Text_BitRate,
+ Text_BitRate_String,
+ Text_BitRate_Minimum,
+ Text_BitRate_Minimum_String,
+ Text_BitRate_Nominal,
+ Text_BitRate_Nominal_String,
+ Text_BitRate_Maximum,
+ Text_BitRate_Maximum_String,
+ Text_BitRate_Encoded,
+ Text_BitRate_Encoded_String,
+ Text_Width,
+ Text_Width_String,
+ Text_Height,
+ Text_Height_String,
+ Text_FrameRate_Mode,
+ Text_FrameRate_Mode_String,
+ Text_FrameRate,
+ Text_FrameRate_String,
+ Text_FrameRate_Minimum,
+ Text_FrameRate_Minimum_String,
+ Text_FrameRate_Nominal,
+ Text_FrameRate_Nominal_String,
+ Text_FrameRate_Maximum,
+ Text_FrameRate_Maximum_String,
+ Text_FrameRate_Original,
+ Text_FrameRate_Original_String,
+ Text_FrameCount,
+ Text_Source_FrameCount,
+ Text_ColorSpace,
+ Text_ChromaSubsampling,
+ Text_Resolution,
+ Text_Resolution_String,
+ Text_BitDepth,
+ Text_BitDepth_String,
+ Text_Compression_Mode,
+ Text_Compression_Mode_String,
+ Text_Compression_Ratio,
+ Text_Delay,
+ Text_Delay_String,
+ Text_Delay_String1,
+ Text_Delay_String2,
+ Text_Delay_String3,
+ Text_Delay_String4,
+ Text_Delay_Settings,
+ Text_Delay_Source,
+ Text_Delay_Source_String,
+ Text_Delay_Original,
+ Text_Delay_Original_String,
+ Text_Delay_Original_String1,
+ Text_Delay_Original_String2,
+ Text_Delay_Original_String3,
+ Text_Delay_Original_String4,
+ Text_Delay_Original_Settings,
+ Text_Delay_Original_Source,
+ Text_Video_Delay,
+ Text_Video_Delay_String,
+ Text_Video_Delay_String1,
+ Text_Video_Delay_String2,
+ Text_Video_Delay_String3,
+ Text_Video_Delay_String4,
+ Text_Video0_Delay,
+ Text_Video0_Delay_String,
+ Text_Video0_Delay_String1,
+ Text_Video0_Delay_String2,
+ Text_Video0_Delay_String3,
+ Text_Video0_Delay_String4,
+ Text_StreamSize,
+ Text_StreamSize_String,
+ Text_StreamSize_String1,
+ Text_StreamSize_String2,
+ Text_StreamSize_String3,
+ Text_StreamSize_String4,
+ Text_StreamSize_String5,
+ Text_StreamSize_Proportion,
+ Text_Source_StreamSize,
+ Text_Source_StreamSize_String,
+ Text_Source_StreamSize_String1,
+ Text_Source_StreamSize_String2,
+ Text_Source_StreamSize_String3,
+ Text_Source_StreamSize_String4,
+ Text_Source_StreamSize_String5,
+ Text_Source_StreamSize_Proportion,
+ Text_StreamSize_Encoded,
+ Text_StreamSize_Encoded_String,
+ Text_StreamSize_Encoded_String1,
+ Text_StreamSize_Encoded_String2,
+ Text_StreamSize_Encoded_String3,
+ Text_StreamSize_Encoded_String4,
+ Text_StreamSize_Encoded_String5,
+ Text_StreamSize_Encoded_Proportion,
+ Text_Source_StreamSize_Encoded,
+ Text_Source_StreamSize_Encoded_String,
+ Text_Source_StreamSize_Encoded_String1,
+ Text_Source_StreamSize_Encoded_String2,
+ Text_Source_StreamSize_Encoded_String3,
+ Text_Source_StreamSize_Encoded_String4,
+ Text_Source_StreamSize_Encoded_String5,
+ Text_Source_StreamSize_Encoded_Proportion,
+ Text_Title,
+ Text_Encoded_Library,
+ Text_Encoded_Library_String,
+ Text_Encoded_Library_Name,
+ Text_Encoded_Library_Version,
+ Text_Encoded_Library_Date,
+ Text_Encoded_Library_Settings,
+ Text_Language,
+ Text_Language_String,
+ Text_Language_String1,
+ Text_Language_String2,
+ Text_Language_String3,
+ Text_Language_String4,
+ Text_Language_More,
+ Text_Default,
+ Text_Default_String,
+ Text_Forced,
+ Text_Forced_String,
+ Text_Summary,
+ Text_Encoded_Date,
+ Text_Tagged_Date,
+ Text_Encryption,
+};
+
+//---------------------------------------------------------------------------
+enum chapters
+{
+ Chapters_Count,
+ Chapters_StreamCount,
+ Chapters_StreamKind,
+ Chapters_StreamKind_String,
+ Chapters_StreamKindID,
+ Chapters_StreamKindPos,
+ Chapters_StreamOrder,
+ Chapters_Inform,
+ Chapters_ID,
+ Chapters_ID_String,
+ Chapters_UniqueID,
+ Chapters_MenuID,
+ Chapters_MenuID_String,
+ Chapters_Format,
+ Chapters_Format_Info,
+ Chapters_Format_Url,
+ Chapters_Codec,
+ Chapters_Codec_String,
+ Chapters_Codec_Info,
+ Chapters_Codec_Url,
+ Chapters_Total,
+ Chapters_Title,
+ Chapters_Language_String,
+ Chapters_Language_String1,
+ Chapters_Language_String2,
+ Chapters_Language_String3,
+ Chapters_Language_String4,
+ Chapters_Language_More,
+ Chapters_Default,
+ Chapters_Default_String,
+ Chapters_Forced,
+ Chapters_Forced_String,
+};
+
+//---------------------------------------------------------------------------
+enum image
+{
+ Image_Count,
+ Image_Status,
+ Image_StreamCount,
+ Image_StreamKind,
+ Image_StreamKind_String,
+ Image_StreamKindID,
+ Image_StreamKindPos,
+ Image_StreamOrder,
+ Image_Inform,
+ Image_ID,
+ Image_ID_String,
+ Image_UniqueID,
+ Image_UniqueID_String,
+ Image_MenuID,
+ Image_MenuID_String,
+ Image_Title,
+ Image_Format,
+ Image_Format_Info,
+ Image_Format_Url,
+ Image_Format_Commercial,
+ Image_Format_Commercial_IfAny,
+ Image_Format_Version,
+ Image_Format_Profile,
+ Image_Format_Compression,
+ Image_Format_Settings,
+ Image_Format_Settings_Wrapping,
+ Image_InternetMediaType,
+ Image_CodecID,
+ Image_CodecID_String,
+ Image_CodecID_Info,
+ Image_CodecID_Hint,
+ Image_CodecID_Url,
+ Image_CodecID_Description,
+ Image_Codec,
+ Image_Codec_String,
+ Image_Codec_Family,
+ Image_Codec_Info,
+ Image_Codec_Url,
+ Image_Width,
+ Image_Width_String,
+ Image_Width_Offset,
+ Image_Width_Offset_String,
+ Image_Width_Original,
+ Image_Width_Original_String,
+ Image_Height,
+ Image_Height_String,
+ Image_Height_Offset,
+ Image_Height_Offset_String,
+ Image_Height_Original,
+ Image_Height_Original_String,
+ Image_PixelAspectRatio,
+ Image_PixelAspectRatio_String,
+ Image_PixelAspectRatio_Original,
+ Image_PixelAspectRatio_Original_String,
+ Image_DisplayAspectRatio,
+ Image_DisplayAspectRatio_String,
+ Image_DisplayAspectRatio_Original,
+ Image_DisplayAspectRatio_Original_String,
+ Image_ColorSpace,
+ Image_ChromaSubsampling,
+ Image_Resolution,
+ Image_Resolution_String,
+ Image_BitDepth,
+ Image_BitDepth_String,
+ Image_Compression_Mode,
+ Image_Compression_Mode_String,
+ Image_Compression_Ratio,
+ Image_StreamSize,
+ Image_StreamSize_String,
+ Image_StreamSize_String1,
+ Image_StreamSize_String2,
+ Image_StreamSize_String3,
+ Image_StreamSize_String4,
+ Image_StreamSize_String5,
+ Image_StreamSize_Proportion,
+ Image_Encoded_Library,
+ Image_Encoded_Library_String,
+ Image_Encoded_Library_Name,
+ Image_Encoded_Library_Version,
+ Image_Encoded_Library_Date,
+ Image_Encoded_Library_Settings,
+ Image_Language,
+ Image_Language_String,
+ Image_Language_String1,
+ Image_Language_String2,
+ Image_Language_String3,
+ Image_Language_String4,
+ Image_Language_More,
+ Image_Default,
+ Image_Default_String,
+ Image_Forced,
+ Image_Forced_String,
+ Image_Summary,
+ Image_Encoded_Date,
+ Image_Tagged_Date,
+ Image_Encryption,
+};
+
+//---------------------------------------------------------------------------
+enum menu
+{
+ Menu_Count,
+ Menu_Status,
+ Menu_StreamCount,
+ Menu_StreamKind,
+ Menu_StreamKind_String,
+ Menu_StreamKindID,
+ Menu_StreamKindPos,
+ Menu_StreamOrder,
+ Menu_Inform,
+ Menu_ID,
+ Menu_ID_String,
+ Menu_UniqueID,
+ Menu_UniqueID_String,
+ Menu_MenuID,
+ Menu_MenuID_String,
+ Menu_Format,
+ Menu_Format_Info,
+ Menu_Format_Url,
+ Menu_Format_Commercial,
+ Menu_Format_Commercial_IfAny,
+ Menu_Format_Version,
+ Menu_Format_Profile,
+ Menu_Format_Compression,
+ Menu_Format_Settings,
+ Menu_CodecID,
+ Menu_CodecID_String,
+ Menu_CodecID_Info,
+ Menu_CodecID_Hint,
+ Menu_CodecID_Url,
+ Menu_CodecID_Description,
+ Menu_Codec,
+ Menu_Codec_String,
+ Menu_Codec_Info,
+ Menu_Codec_Url,
+ Menu_Duration,
+ Menu_Duration_String,
+ Menu_Duration_String1,
+ Menu_Duration_String2,
+ Menu_Duration_String3,
+ Menu_Duration_Start,
+ Menu_Duration_End,
+ Menu_Delay,
+ Menu_Delay_String,
+ Menu_Delay_String1,
+ Menu_Delay_String2,
+ Menu_Delay_String3,
+ Menu_Delay_String4,
+ Menu_Delay_Settings,
+ Menu_Delay_Source,
+ Menu_List_StreamKind,
+ Menu_List_StreamPos,
+ Menu_List,
+ Menu_List_String,
+ Menu_Title,
+ Menu_Language,
+ Menu_Language_String,
+ Menu_Language_String1,
+ Menu_Language_String2,
+ Menu_Language_String3,
+ Menu_Language_String4,
+ Menu_Language_More,
+ Menu_ServiceName,
+ Menu_ServiceChannel,
+ Menu_Service_Url,
+ Menu_ServiceProvider,
+ Menu_ServiceProviderr_Url,
+ Menu_ServiceType,
+ Menu_NetworkName,
+ Menu_Original_NetworkName,
+ Menu_Countries,
+ Menu_TimeZones,
+ Menu_Chapters_Pos_Begin,
+ Menu_Chapters_Pos_End,
+};
+
+} //NameSpace
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Analyze.cpp b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze.cpp
new file mode 100644
index 000000000..d70703e18
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze.cpp
@@ -0,0 +1,3085 @@
+// File__Analyze - Base for analyze files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#if MEDIAINFO_IBI
+ #if MEDIAINFO_SEEK
+ #include "MediaInfo/Multiple/File_Ibi.h"
+ #endif //MEDIAINFO_SEEK
+ #include "MediaInfo/Multiple/File_Ibi_Creation.h"
+#endif //MEDIAINFO_IBI
+#include <cstring>
+using namespace std;
+using namespace tinyxml2;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File__Analyze::File__Analyze ()
+:File__Base()
+{
+ //Info for speed optimization
+ #if MEDIAINFO_TRACE
+ Config_Trace_Level=MediaInfoLib::Config.Trace_Level_Get();
+ Config_Trace_Layers=MediaInfoLib::Config.Trace_Layers_Get();
+ Config_Trace_Format=MediaInfoLib::Config.Trace_Format_Get();
+ Trace_DoNotSave=false;
+ Trace_Layers.set();
+ Trace_Layers_Update();
+ #endif //MEDIAINFO_TRACE
+ Config_Demux=MediaInfoLib::Config.Demux_Get();
+ Config_ParseSpeed=MediaInfoLib::Config.ParseSpeed_Get();
+ Config_LineSeparator=MediaInfoLib::Config.LineSeparator_Get();
+ IsSub=false;
+ IsRawStream=false;
+
+ //In
+ #if MEDIAINFO_EVENTS
+ StreamIDs_Size=1;
+ ParserIDs[0]=0x0;
+ StreamIDs[0]=0;
+ StreamIDs_Width[0]=0;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=1; //Frame
+ Demux_random_access=false;
+ Demux_UnpacketizeContainer=false;
+ Demux_IntermediateItemFound=true;
+ Demux_Offset=0;
+ Demux_TotalBytes=0;
+ Demux_EventWasSent_Accept_Specific=false;
+ #endif //MEDIAINFO_DEMUX
+ PTS_DTS_Needed=false;
+ PTS_Begin=(int64u)-1;
+ PTS_End=0;
+ DTS_Begin=(int64u)-1;
+ DTS_End=0;
+
+ //Out
+ Frame_Count=0;
+ Frame_Count_Previous=0;
+ Frame_Count_InThisBlock=0;
+ Field_Count=0;
+ Field_Count_Previous=0;
+ Field_Count_InThisBlock=0;
+ Frame_Count_NotParsedIncluded=(int64u)-1;
+
+ //Configuration
+ DataMustAlwaysBeComplete=true;
+ MustUseAlternativeParser=false;
+ MustSynchronize=false;
+
+ //Buffer
+ #if MEDIAINFO_SEEK
+ Seek_Duration_Detected=false;
+ #endif //MEDIAINFO_SEEK
+ Buffer=NULL;
+ Buffer_Temp=NULL;
+ Buffer_Size=0;
+ Buffer_Temp_Size=0;
+ Buffer_Temp_Size_Max=0;
+ Buffer_Offset=0;
+ Buffer_Offset_Temp=0;
+ Buffer_MinimumSize=0;
+ Buffer_MaximumSize=1024*1024;
+ Buffer_TotalBytes_FirstSynched=0;
+ Buffer_TotalBytes=0;
+ if (MediaInfoLib::Config.FormatDetection_MaximumOffset_Get())
+ Buffer_TotalBytes_FirstSynched_Max=MediaInfoLib::Config.FormatDetection_MaximumOffset_Get();
+ else
+ Buffer_TotalBytes_FirstSynched_Max=1024*1024;
+ if (Buffer_TotalBytes_FirstSynched_Max<(int64u)-1-64*1024*1024)
+ Buffer_TotalBytes_Fill_Max=Buffer_TotalBytes_FirstSynched_Max+64*1024*1024;
+ else
+ Buffer_TotalBytes_Fill_Max=(int64u)-1;
+ Buffer_PaddingBytes=0;
+ Stream_BitRateFromContainer=0;
+
+ //EOF
+ EOF_AlreadyDetected=(Config_ParseSpeed==1.0)?true:false;
+
+ //Synchro
+ MustParseTheHeaderFile=true;
+ Synched=false;
+ MustExtendParsingDuration=false;
+ Trusted=Error;
+ Trusted_Multiplier=1;
+
+ //Header
+ Header_Size=0;
+
+ //Element
+ Element_Offset=0;
+ Element_Size=0;
+
+ //Elements
+ Element.resize(64);
+ Element[0].Code=0;
+ Element[0].Next=File_Size;
+ Element[0].WaitForMoreData=false;
+ Element[0].UnTrusted=false;
+ Element[0].IsComplete=false;
+ #if MEDIAINFO_TRACE
+ if (Config_Trace_Level!=0)
+ {
+ //ToShow part
+ Element[0].ToShow.Name.clear();
+ Element[0].ToShow.Info.clear();
+ Element[0].ToShow.Details.clear();
+ Element[0].ToShow.NoShow=false;
+ }
+ #endif //MEDIAINFO_TRACE
+ Element_Level_Base=0;
+ Element_Level=0;
+
+ //BitStream
+ BS=new BitStream_Fast;
+ BT=new BitStream_LE;
+
+ //Temp
+ Status[IsAccepted]=false;
+ Status[IsFilled]=false;
+ Status[IsUpdated]=false;
+ Status[IsFinished]=false;
+ ShouldContinueParsing=false;
+
+ //Events data
+ PES_FirstByte_IsAvailable=false;
+
+ Unsynch_Frame_Count=(int64u)-1;
+ #if MEDIAINFO_IBI
+ Config_Ibi_Create=false;
+ Ibi_SynchronizationOffset_Current=0;
+ Ibi_SynchronizationOffset_BeginOfFrame=0;
+ IbiStream=NULL;
+ #endif //MEDIAINFO_IBI
+}
+
+//---------------------------------------------------------------------------
+File__Analyze::~File__Analyze ()
+{
+ //Buffer
+ delete[] Buffer_Temp; //Buffer_Temp=NULL;
+
+ //BitStream
+ delete BS; //BS=NULL;
+ delete BT; //BS=NULL;
+
+ #if MEDIAINFO_IBI
+ if (!IsSub)
+ delete IbiStream; //IbiStream=NULL;
+ #endif //MEDIAINFO_IBI
+}
+
+//***************************************************************************
+// Open
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Open_Buffer_Init (int64u File_Size_)
+{
+ //Preparing
+ File_Size=File_Size_;
+ Element[0].Next=File_Size;
+
+ //Buffer - Global
+ Read_Buffer_Init();
+
+ //Integrity
+ if (File_Offset>File_Size)
+ {
+ Reject();
+ return; //There is a problem
+ }
+
+ //Jump handling
+ if (File_GoTo!=(int64u)-1)
+ {
+ Open_Buffer_Unsynch();
+ File_GoTo=(int64u)-1;
+ }
+
+ //Configuring
+ if (MediaInfoLib::Config.FormatDetection_MaximumOffset_Get())
+ Buffer_TotalBytes_FirstSynched_Max=MediaInfoLib::Config.FormatDetection_MaximumOffset_Get();
+ if (Config->File_IsSub_Get())
+ IsSub=true;
+ #if MEDIAINFO_DEMUX
+ if (Demux_Level==1 && !IsSub && Config->Demux_Unpacketize_Get()) //If Demux_Level is Frame
+ {
+ Demux_Level=2; //Container
+ Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #if MEDIAINFO_EVENTS
+ if (StreamIDs_Size && IsRawStream)
+ StreamIDs[StreamIDs_Size-1]=(int64u)-1;
+ if (!IsSub)
+ {
+ ZtringListList SubFile_IDs;
+ SubFile_IDs.Separator_Set(0, EOL);
+ SubFile_IDs.Separator_Set(1, _T(","));
+ SubFile_IDs.Write(Config->SubFile_IDs_Get());
+ if (!SubFile_IDs.empty())
+ {
+ StreamIDs_Size=1+SubFile_IDs.size();
+ StreamIDs[SubFile_IDs.size()]=IsRawStream?(int64u)-1:StreamIDs[0];
+ StreamIDs_Width[SubFile_IDs.size()]=StreamIDs_Width[0];
+ ParserIDs[SubFile_IDs.size()]=ParserIDs[0];
+ for (size_t Pos=0; Pos<SubFile_IDs.size(); Pos++)
+ {
+ StreamIDs[Pos]=SubFile_IDs[Pos](0).To_int64u();
+ StreamIDs_Width[Pos]=SubFile_IDs[Pos](1).To_int8u();
+ ParserIDs[Pos]=SubFile_IDs[Pos](2).To_int8u();
+ }
+ }
+ }
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_IBI
+ if (!IsSub)
+ IbiStream=new ibi::stream;
+ Config_Ibi_Create=Config->Ibi_Create_Get() && Config_ParseSpeed==1.0;
+ #endif //MEDIAINFO_IBI
+}
+
+void File__Analyze::Open_Buffer_Init (File__Analyze* Sub)
+{
+ Open_Buffer_Init(Sub, File_Size);
+}
+
+void File__Analyze::Open_Buffer_Init (File__Analyze* Sub, int64u File_Size_)
+{
+ //Integrity
+ if (Sub==NULL)
+ return;
+
+ //Parsing
+ #if MEDIAINFO_TRACE
+ Sub->Init(Config, Details);
+ #else //MEDIAINFO_TRACE
+ Sub->Init(Config);
+ #endif //MEDIAINFO_TRACE
+ #if MEDIAINFO_EVENTS
+ Sub->ParserIDs[StreamIDs_Size]=Sub->ParserIDs[0];
+ Sub->StreamIDs_Width[StreamIDs_Size]=Sub->StreamIDs_Width[0];
+ for (size_t Pos=0; Pos<StreamIDs_Size; Pos++)
+ {
+ Sub->ParserIDs[Pos]=ParserIDs[Pos];
+ Sub->StreamIDs[Pos]=StreamIDs[Pos];
+ Sub->StreamIDs_Width[Pos]=StreamIDs_Width[Pos];
+ }
+ Sub->StreamIDs[StreamIDs_Size-1]=Element_Code;
+ Sub->StreamIDs_Size=StreamIDs_Size+1;
+ #endif //MEDIAINFO_EVENTS
+ Sub->IsSub=true;
+ Sub->File_Name_WithoutDemux=IsSub?File_Name_WithoutDemux:File_Name;
+ Sub->Open_Buffer_Init(File_Size_);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Open_Buffer_Continue (const int8u* ToAdd, size_t ToAdd_Size)
+{
+ Frame_Count_InThisBlock=0;
+
+ //Integrity
+ if (Status[IsFinished])
+ return;
+ //{File F; F.Open(Ztring(_T("d:\\direct"))+Ztring::ToZtring((size_t)this, 16), File::Access_Write_Append); F.Write(ToAdd, ToAdd_Size);}
+
+ //Demand to go elsewhere
+ if (File_GoTo!=(int64u)-1)
+ {
+ if (File_GoTo<File_Offset)
+ return; //Seek must be done before
+ if (File_GoTo>=File_Offset+ToAdd_Size)
+ {
+ File_Offset+=ToAdd_Size;
+ return; //No need of this piece of data
+ }
+ }
+
+ if (Buffer_Temp_Size) //There is buffered data from before
+ {
+ //Allocating new buffer if needed
+ if (Buffer_Temp_Size+ToAdd_Size>Buffer_Temp_Size_Max)
+ {
+ int8u* Old=Buffer_Temp;
+ size_t Buffer_Temp_Size_Max_ToAdd=ToAdd_Size>32768?ToAdd_Size:32768;
+ if (Buffer_Temp_Size_Max_ToAdd<Buffer_Temp_Size_Max) Buffer_Temp_Size_Max_ToAdd=Buffer_Temp_Size_Max;
+ Buffer_Temp_Size_Max+=Buffer_Temp_Size_Max_ToAdd;
+ Buffer_Temp=new int8u[Buffer_Temp_Size_Max];
+ std::memcpy(Buffer_Temp, Old, Buffer_Temp_Size);
+ delete[] Old; //Old=NULL;
+ }
+
+ //Copying buffer
+ if (ToAdd_Size>0)
+ {
+ std::memcpy(Buffer_Temp+Buffer_Size, ToAdd, ToAdd_Size);
+ Buffer_Temp_Size+=ToAdd_Size;
+ }
+
+ //Buffer
+ Buffer=Buffer_Temp;
+ Buffer_Size=Buffer_Temp_Size;
+ }
+ else
+ {
+ Buffer=ToAdd;
+ Buffer_Size=ToAdd_Size;
+ }
+
+ //Preparing
+ Buffer_Offset=0;
+ Trusted=(Buffer_Size>2*8*1024?Buffer_Size/8/1024:2)*Trusted_Multiplier; //Never less than 2 acceptable errors
+
+ //Demand to go elsewhere
+ if (File_GoTo!=(int64u)-1)
+ {
+ //The needed offset is in the new buffer
+ Buffer_Offset+=(size_t)(File_GoTo-File_Offset);
+ File_GoTo=(int64u)-1;
+ }
+
+ //Parsing
+ if (!IsSub)
+ Config->State_Set(((float)Buffer_TotalBytes)/Config->File_Size);
+ if (Buffer_Size>=Buffer_MinimumSize || File_Offset+Buffer_Size==File_Size) //Parsing only if we have enough buffer
+ while (Open_Buffer_Continue_Loop());
+
+ //Should parse again?
+ if (((File_GoTo==File_Size && File_Size!=(int64u)-1) || File_Offset+Buffer_Offset>=File_Size)
+ #if MEDIAINFO_DEMUX
+ && !Config->Demux_EventWasSent
+ #endif //MEDIAINFO_DEMUX
+ )
+ {
+ if (!BookMark_Code.empty())
+ BookMark_Get();
+
+ if (File_GoTo>=File_Size)
+ {
+ Element_Show(); //If Element_Level is >0, we must show what is in the details buffer
+ while (Element_Level>0)
+ Element_End0(); //This is Finish, must flush
+ Buffer_Clear();
+ File_Offset=File_Size;
+ ForceFinish();
+ return;
+ }
+ }
+
+ //Demand to go elsewhere
+ if (File_GoTo!=(int64u)-1)
+ {
+ if (Config->File_IsSeekable_Get())
+ {
+ if (File_GoTo>=File_Size)
+ File_GoTo=File_Size;
+ Buffer_Clear();
+ }
+ else
+ File_Offset+=Buffer_Offset;
+
+ return;
+ }
+ if (Buffer_Offset>=Buffer_Size)
+ {
+ if (Buffer_Offset>Buffer_Size)
+ File_GoTo=File_Offset+Buffer_Offset;
+ Buffer_Clear();
+ return;
+ }
+
+ //Buffer handling
+ if (Buffer_Offset!=Buffer_Size) //all is not used
+ {
+ if (File_Offset+Buffer_Size>=File_Size //No more data will come
+ #if MEDIAINFO_DEMUX
+ && !Config->Demux_EventWasSent
+ #endif //MEDIAINFO_DEMUX
+ )
+ {
+ Buffer_TotalBytes+=Buffer_Size;
+ ForceFinish();
+ return;
+ }
+
+ if (Buffer_Temp_Size==0) //If there was no copy
+ {
+ #if MEDIAINFO_DEMUX
+ if (!IsSub && Config->Demux_EventWasSent && Config->File_Buffer_Repeat_IsSupported && Buffer_Offset==0) //If there was no byte consumed
+ {
+ Config->File_Buffer_Repeat=true;
+ }
+ else
+ #endif //MEDIAINFO_DEMUX
+ {
+ if (Buffer_Temp!=NULL && Buffer_Temp_Size_Max<ToAdd_Size-Buffer_Offset)
+ {
+ delete[] Buffer_Temp; Buffer_Temp=NULL; Buffer_Temp_Size=0; Buffer_Temp_Size_Max=0;
+ }
+ if (Buffer_Temp==NULL)
+ {
+ size_t Buffer_Temp_Size_Max_ToAdd=ToAdd_Size-Buffer_Offset>32768?ToAdd_Size-Buffer_Offset:32768;
+ if (Buffer_Temp_Size_Max_ToAdd<Buffer_Temp_Size_Max) Buffer_Temp_Size_Max_ToAdd=Buffer_Temp_Size_Max;
+ Buffer_Temp_Size_Max=Buffer_Temp_Size_Max_ToAdd;
+ Buffer_Temp=new int8u[Buffer_Temp_Size_Max];
+ }
+ Buffer_Temp_Size=ToAdd_Size-Buffer_Offset;
+ std::memcpy(Buffer_Temp, ToAdd+Buffer_Offset, Buffer_Temp_Size);
+ }
+ }
+ else if (Buffer_Offset) //Already a copy, just moving it
+ {
+ std::memmove(Buffer_Temp, Buffer_Temp+Buffer_Offset, Buffer_Size-Buffer_Offset);
+ Buffer_Temp_Size=Buffer_Size-Buffer_Offset;
+ }
+ }
+ else if (Buffer_Temp_Size)
+ Buffer_Temp_Size=0;
+
+ //Reserving unused data
+ if ((int64u)-1-Buffer_Offset<File_Offset) //In case of unknown filesize, File_Offset may be (int64u)-1
+ Buffer_Offset=(size_t)((int64u)-1-File_Offset);
+ Buffer_Size-=Buffer_Offset;
+ File_Offset+=Buffer_Offset;
+ if (Buffer_Offset_Temp>=Buffer_Offset)
+ Buffer_Offset_Temp-=Buffer_Offset;
+ Buffer_Offset=0;
+
+ //Is it OK?
+ if (Buffer_Size>Buffer_MaximumSize)
+ {
+ ForceFinish();
+ return;
+ }
+}
+
+void File__Analyze::Open_Buffer_Continue (File__Analyze* Sub, const int8u* ToAdd, size_t ToAdd_Size)
+{
+ if (Sub==NULL)
+ return;
+
+ //Sub
+ if (Sub->File_GoTo!=(int64u)-1)
+ Sub->File_GoTo=(int64u)-1;
+ Sub->File_Offset=File_Offset+Buffer_Offset+Element_Offset;
+ if (Sub->File_Size!=File_Size)
+ {
+ for (size_t Pos=0; Pos<Sub->Element_Level; Pos++)
+ if (Sub->Element[Pos].Next==Sub->File_Size)
+ Sub->Element[Pos].Next=File_Size;
+ Sub->File_Size=File_Size;
+ }
+ #if MEDIAINFO_TRACE
+ Sub->Element_Level_Base=Element_Level_Base+Element_Level;
+ #endif
+
+ //{File F; F.Open(Ztring(_T("d:\\direct"))+Ztring::ToZtring((size_t)this, 16), File::Access_Write_Append); F.Write(ToAdd, ToAdd_Size);}
+
+ //Adaptating File_Offset
+ if (Sub!=this && Sub->Buffer_Size<=Sub->File_Offset)
+ Sub->File_Offset-=Sub->Buffer_Size;
+
+ //Parsing
+ Sub->PES_FirstByte_IsAvailable=PES_FirstByte_IsAvailable;
+ Sub->PES_FirstByte_Value=PES_FirstByte_Value;
+ if (Sub->FrameInfo_Previous.DTS!=(int64u)-1)
+ {
+ if (Sub->Buffer_Size)
+ Sub->FrameInfo_Previous.Buffer_Offset=Sub->Buffer_Size;
+
+ Sub->FrameInfo_Next=Sub->FrameInfo;
+ Sub->FrameInfo=Sub->FrameInfo_Previous;
+ Sub->FrameInfo_Previous=frame_info();
+
+ Sub->Frame_Count_Previous=Sub->Frame_Count;
+ Sub->Field_Count_Previous=Sub->Field_Count;
+ }
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Sub->Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded;
+ #if MEDIAINFO_DEMUX
+ bool Demux_EventWasSent_Save=Config->Demux_EventWasSent;
+ Config->Demux_EventWasSent=false;
+ #endif //MEDIAINFO_DEMUX
+ Sub->Open_Buffer_Continue(ToAdd, ToAdd_Size);
+ #if MEDIAINFO_DEMUX
+ if (Demux_EventWasSent_Save)
+ Config->Demux_EventWasSent=true;
+ #endif //MEDIAINFO_DEMUX
+ if (Sub->Buffer_Size)
+ {
+ Sub->FrameInfo_Previous=Sub->FrameInfo;
+ Sub->FrameInfo=Sub->FrameInfo_Next;
+ Sub->FrameInfo_Next=frame_info();
+ }
+
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ //Details handling
+ if (!Sub->Element[0].ToShow.Details.empty() && !Trace_DoNotSave)
+ {
+ //Line separator
+ if (!Element[Element_Level].ToShow.Details.empty())
+ Element[Element_Level].ToShow.Details+=Config_LineSeparator;
+
+ //From Sub
+ while(Sub->Element_Level)
+ Sub->Element_End0();
+ Element[Element_Level].ToShow.Details+=Sub->Element[0].ToShow.Details;
+ Sub->Element[0].ToShow.Details.clear();
+ }
+ else
+ Element[Element_Level].ToShow.NoShow=true; //We don't want to show this item because there is no info in it
+ }
+ #endif
+}
+
+//---------------------------------------------------------------------------
+bool File__Analyze::Open_Buffer_Continue_Loop ()
+{
+ //Header
+ if (MustParseTheHeaderFile)
+ {
+ if (!FileHeader_Manage())
+ return false; //Wait for more data
+ if (Status[IsFinished] || File_GoTo!=(int64u)-1)
+ return false; //Finish
+ }
+
+ //Parsing specific
+ Element_Offset=0;
+ Element_Size=Buffer_Size;
+ Element[Element_Level].WaitForMoreData=false;
+ Read_Buffer_Continue();
+ if (Element_IsWaitingForMoreData())
+ return false; //Wait for more data
+ Buffer_Offset+=(size_t)Element_Offset;
+ if ((Status[IsFinished] && !ShouldContinueParsing) || Buffer_Offset>Buffer_Size || File_GoTo!=(int64u)-1)
+ return false; //Finish
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return false;
+ #endif //MEDIAINFO_DEMUX
+
+ //Parsing;
+ while (Buffer_Parse());
+ Buffer_TotalBytes+=Buffer_Offset;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return false;
+ #endif //MEDIAINFO_DEMUX
+
+ //Parsing specific
+ Read_Buffer_AfterParsing();
+
+ //Handling of File_GoTo with already buffered data
+ if (File_GoTo!=(int64u)-1 && File_GoTo>=File_Offset && File_GoTo<=File_Offset+Buffer_Size)
+ {
+ if (Buffer_Temp_Size==0) //If there was no copy
+ {
+ Buffer_Temp_Size=(size_t)(File_Offset+Buffer_Size-File_GoTo);
+ if (Buffer_Temp!=NULL && Buffer_Temp_Size_Max<Buffer_Temp_Size)
+ {
+ delete[] Buffer_Temp; Buffer_Temp=NULL; Buffer_Temp_Size=0; Buffer_Temp_Size_Max=0;
+ }
+ if (Buffer_Temp==NULL)
+ {
+ size_t Buffer_Temp_Size_Max_ToAdd=Buffer_Temp_Size>32768?Buffer_Temp_Size:32768;
+ if (Buffer_Temp_Size_Max_ToAdd<Buffer_Temp_Size_Max) Buffer_Temp_Size_Max_ToAdd=Buffer_Temp_Size_Max;
+ Buffer_Temp_Size_Max=Buffer_Temp_Size_Max_ToAdd;
+ Buffer_Temp=new int8u[Buffer_Temp_Size_Max];
+ }
+ std::memcpy(Buffer_Temp, Buffer+Buffer_Size-Buffer_Temp_Size, Buffer_Temp_Size);
+ }
+ else //Already a copy, just moving it
+ {
+ Buffer_Temp_Size=(size_t)(File_Offset+Buffer_Size-File_GoTo);
+ std::memmove(Buffer_Temp, Buffer+Buffer_Size-Buffer_Temp_Size, Buffer_Temp_Size);
+ }
+ File_Offset+=Buffer_Size-Buffer_Temp_Size;
+ Buffer=Buffer_Temp;
+ Buffer_Offset=0;
+ Buffer_Size=Buffer_Temp_Size;
+ File_GoTo=(int64u)-1;
+ return true;
+ }
+
+ //Jumping to the end of the file if needed
+ if (!IsSub && !EOF_AlreadyDetected && Config_ParseSpeed<1 && Count_Get(Stream_General))
+ {
+ Element[Element_Level].WaitForMoreData=false;
+ Detect_EOF();
+ if ((File_GoTo!=(int64u)-1 && File_GoTo>File_Offset+Buffer_Offset) || (Status[IsFinished] && !ShouldContinueParsing))
+ {
+ EOF_AlreadyDetected=true;
+ return false;
+ }
+ }
+
+ return false;
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File__Analyze::Open_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ #if MEDIAINFO_DEMUX
+ Config->Demux_EventWasSent=false;
+ #endif //MEDIAINFO_DEMUX
+
+ size_t ToReturn=Read_Buffer_Seek(Method, Value, ID);
+
+ if (File_GoTo!=(int64u)-1)
+ Buffer_Clear();
+
+ return ToReturn;
+}
+#endif //MEDIAINFO_SEEK
+
+//---------------------------------------------------------------------------
+void File__Analyze::Open_Buffer_Position_Set (int64u File_Offset_)
+{
+ if (File_Offset_==(int64u)-1)
+ return;
+
+ File_Offset=File_Offset_-Buffer_Temp_Size;
+ File_GoTo=(int64u)-1;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Open_Buffer_Unsynch ()
+{
+ Status[IsFinished]=false;
+ FrameInfo=frame_info();
+ FrameInfo_Previous=frame_info();
+ FrameInfo_Next=frame_info();
+ Frame_Count_NotParsedIncluded=Unsynch_Frame_Count;
+ Unsynch_Frame_Count=(int64u)-1;
+ PTS_End=0;
+ DTS_End=0;
+ #if MEDIAINFO_DEMUX
+ Demux_IntermediateItemFound=true;
+ Demux_Offset=0;
+ Demux_TotalBytes=Buffer_TotalBytes;
+ Config->Demux_EventWasSent=false;
+ #endif //MEDIAINFO_DEMUX
+
+ //Clearing duration
+ if (Synched)
+ {
+ for (size_t StreamKind=(size_t)Stream_General; StreamKind<(size_t)Stream_Menu; StreamKind++)
+ {
+ size_t StreamPos_Count=Count_Get((stream_t)StreamKind);
+ for (size_t StreamPos=0; StreamPos<StreamPos_Count; StreamPos++)
+ Clear((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_Duration));
+ }
+ }
+
+ //if (Synched)
+ if (!MustSynchronize || (MustSynchronize && File_Offset_FirstSynched!=(int64u)-1)) //Synched at least once
+ {
+ Synched=false;
+ Read_Buffer_Unsynched();
+ Ibi_Read_Buffer_Unsynched();
+ }
+ Buffer_Clear();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Open_Buffer_Update ()
+{
+ Streams_Update();
+
+ Status[File__Analyze::IsUpdated]=false;
+ for (size_t Pos=File__Analyze::User_16; Pos<File__Analyze::User_16+16; Pos++)
+ Status[Pos]=false;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Open_Buffer_Finalize (bool NoBufferModification)
+{
+ //File with unknown size (stream...), finnishing
+ if (!NoBufferModification && File_Size==(int64u)-1)
+ {
+ File_Size=File_Offset+Buffer_Size;
+ Open_Buffer_Continue((const int8u*)NULL, 0);
+ }
+
+ //Element must be Finish
+ while (Element_Level>0)
+ Element_End0();
+
+ //Buffer - Global
+ Fill();
+ if (!NoBufferModification)
+ {
+ ForceFinish();
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return;
+ #endif //MEDIAINFO_DEMUX
+ Buffer_Clear();
+ }
+
+ #if MEDIAINFO_TRACE
+ if (Details && Details->empty())
+ Details->assign(Element[0].ToShow.Details);
+ #endif //MEDIAINFO_TRACE
+
+ #if MEDIAINFO_EVENTS
+ if (Status[IsAccepted])
+ {
+ struct MediaInfo_Event_General_End_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_End, 0);
+ Event.Stream_Bytes_Analyzed=Buffer_TotalBytes;
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_General_End_0));
+ }
+ #endif //MEDIAINFO_EVENTS
+}
+
+void File__Analyze::Open_Buffer_Finalize (File__Analyze* Sub)
+{
+ if (Sub==NULL)
+ return;
+
+ //Finalize
+ Open_Buffer_Init(Sub);
+ Sub->Open_Buffer_Finalize();
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File__Analyze::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ #if MEDIAINFO_IBI
+ if (!IsSub)
+ return Ibi_Read_Buffer_Seek(Method, Value, ID);
+ #endif //MEDIAINFO_IBI
+
+ return (size_t)-1; //Not supported
+}
+#endif //MEDIAINFO_SEEK
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File__Analyze::Read_Buffer_Seek_OneFramePerFile (size_t Method, int64u Value, int64u ID)
+{
+ //Parsing
+ switch (Method)
+ {
+ case 0 :
+ GoTo(Value);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 1 :
+ GoTo(File_Size*Value/10000);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 2 : //Timestamp
+ if (Config->Demux_Rate_Get()==0)
+ return (size_t)-1; //Not supported
+ Value=float64_int64s(((float64)Value)/1000000000*Config->Demux_Rate_Get());
+ case 3 : //FrameNumber
+ {
+ if (Value>=Config->File_Names.size())
+ return 2; //Invalid value
+ int64u Offset=0;
+ for (size_t Pos=0; Pos<Value; Pos++)
+ Offset+=Config->File_Sizes[Pos];
+ GoTo(Offset);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ default : return (size_t)-1; //Not supported
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//---------------------------------------------------------------------------
+void File__Analyze::Read_Buffer_Unsynched_OneFramePerFile()
+{
+ int64u GoTo=File_GoTo;
+ for (Frame_Count_NotParsedIncluded=0; Frame_Count_NotParsedIncluded<Config->File_Sizes.size(); Frame_Count_NotParsedIncluded++)
+ {
+ if (GoTo>=Config->File_Sizes[Frame_Count_NotParsedIncluded])
+ GoTo-=Config->File_Sizes[Frame_Count_NotParsedIncluded];
+ else
+ break;
+ }
+
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Rate_Get())
+ {
+ FrameInfo.DTS=float64_int64s(Frame_Count_NotParsedIncluded*((float64)1000000000)/Config->Demux_Rate_Get());
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+bool File__Analyze::Buffer_Parse()
+{
+ //End of this level?
+ if (File_Offset+Buffer_Offset>=Element[Element_Level].Next)
+ {
+ //There is no loop handler, so we make the level down here
+ while (Element_Level>0 && File_Offset+Buffer_Offset>=Element[Element_Level].Next)
+ Element_End0(); //This is a buffer restart, must sync to Element level
+ if (File_Offset+Buffer_Offset==File_Size)
+ return false; //End of file
+ MustUseAlternativeParser=false; //Reset it if we go out of an element
+ }
+
+ //Synchro
+ if (MustSynchronize)
+ do
+ {
+ if (!Synchro_Manage())
+ return false; //Wait for more data
+ }
+ while (!Synched);
+ #if MEDIAINFO_DEMUX
+ else if (Demux_TotalBytes<=Buffer_TotalBytes+Buffer_Offset)
+ {
+ if (Demux_UnpacketizeContainer && !Demux_UnpacketizeContainer_Test())
+ {
+ Demux_Offset-=Buffer_Offset;
+ return false; //Wait for more data
+ }
+ if (Config->Demux_EventWasSent)
+ return false;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ //Header
+ if (!Header_Manage())
+ return false; //Wait for more data
+
+ //Data
+ if (!Data_Manage())
+ return false; //Wait for more data
+
+ return Buffer_Offset!=Buffer_Size;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Buffer_Clear()
+{
+ //Buffer
+ BS->Attach(NULL, 0);
+ delete[] Buffer_Temp; Buffer_Temp=NULL;
+ if (!Status[IsFinished])
+ File_Offset+=Buffer_Size;
+ else
+ File_Offset=File_Size;
+ Buffer_Size=0;
+ Buffer_Temp_Size=0;
+ Buffer_Offset=0;
+ Buffer_Offset_Temp=0;
+ Buffer_MinimumSize=0;
+
+ //Details
+ #if MEDIAINFO_TRACE
+ Element[Element_Level].WaitForMoreData=false; //We must finalize the details
+ Element[Element_Level].IsComplete=true; //We must finalize the details
+ #endif //MEDIAINFO_TRACE
+
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File__Analyze::Synchronize_0x000001()
+{
+ //Synchronizing
+ while(Buffer_Offset+3<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x01))
+ {
+ Buffer_Offset+=2;
+ while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Buffer_Offset+=2;
+ if ((Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset-1]==0x00) || Buffer_Offset>=Buffer_Size)
+ Buffer_Offset--;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+3==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x01))
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00))
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && Buffer[Buffer_Offset ]!=0x00)
+ Buffer_Offset++;
+
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ //Synched is OK
+ Synched=true;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File__Analyze::FileHeader_Begin_0x000001()
+{
+ //Element_Size
+ if (Buffer_Size<192*4)
+ return true; //Not enough buffer for a test
+
+ //Detecting OldDirac/WAV/SWF/FLV/ELF/DPG/WM files
+ int64u Magic8=CC8(Buffer);
+ int32u Magic4=Magic8>>32;
+ int32u Magic3=Magic4>> 8;
+ int16u Magic2=Magic4>>16;
+ if (Magic8==0x4B572D4449524143LL || Magic4==0x52494646 || Magic3==0x465753 || Magic3==0x464C56 || Magic4==0x7F454C46 || Magic4==0x44504730 || Magic4==0x3026B275 || Magic2==0x4D5A)
+ {
+ Reject();
+ return false;
+ }
+
+ //GXF
+ if (CC5(Buffer)==0x0000000001 && CC2(Buffer+14)==0xE1E2)
+ {
+ Reject();
+ return false;
+ }
+
+ //Detecting MPEG-4 files (ftyp/mdat/skip/free)
+ Magic4=CC4(Buffer+4);
+ switch (Magic4)
+ {
+ case 0x66747970 : //ftyp
+ case 0x6D646174 : //mdat
+ case 0x736B6970 : //skip
+ case 0x66726565 : //free
+ Reject();
+ return false;
+ default : break;
+ }
+
+ //Detect TS files, and the parser is not enough precise to detect them later
+ size_t Buffer_Offset=0;
+ while (Buffer_Offset<188 && Buffer[Buffer_Offset]!=0x47) //Look for first Sync word
+ Buffer_Offset++;
+ if (Buffer_Offset<188 && Buffer[Buffer_Offset+188]==0x47 && Buffer[Buffer_Offset+188*2]==0x47 && Buffer[Buffer_Offset+188*3]==0x47)
+ {
+ Status[IsFinished]=true;
+ return false;
+ }
+ Buffer_Offset=0;
+
+ //Detect BDAV files, and the parser is not enough precise to detect them later
+ while (Buffer_Offset<192 && CC1(Buffer+Buffer_Offset+4)!=0x47) //Look for first Sync word
+ Buffer_Offset++;
+ if (Buffer_Offset<192 && CC1(Buffer+Buffer_Offset+192+4)==0x47 && CC1(Buffer+Buffer_Offset+192*2+4)==0x47 && CC1(Buffer+Buffer_Offset+192*3+4)==0x47)
+ {
+ Status[IsFinished]=true;
+ return false;
+ }
+ Buffer_Offset=0;
+
+ //All should be OK...
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File__Analyze::FileHeader_Begin_XML(XMLDocument &Document)
+{
+ //Element_Size
+ if (File_Size<32 || File_Size>1024*1024)
+ {
+ Reject();
+ return false; //XML files are not expected to be so big
+ }
+
+ //Element_Size
+ if (Buffer_Size<File_Size)
+ return false; //Must wait for more data
+
+ //XML header
+ Ztring Data;
+ if ((Buffer[0]=='<'
+ && Buffer[1]=='?'
+ && Buffer[2]=='x'
+ && Buffer[3]=='m'
+ && Buffer[4]=='l')
+ || (Buffer[0]==0xEF
+ && Buffer[1]==0xBB
+ && Buffer[2]==0xBF
+ && Buffer[3]=='<'
+ && Buffer[4]=='?'
+ && Buffer[5]=='x'
+ && Buffer[6]=='m'
+ && Buffer[7]=='l'))
+ Data.From_UTF8((const char*)Buffer, Buffer_Size);
+ else if ((Buffer[0]=='<'
+ && Buffer[1]==0x00
+ && Buffer[2]=='?'
+ && Buffer[3]==0x00
+ && Buffer[4]=='x'
+ && Buffer[5]==0x00
+ && Buffer[6]=='m'
+ && Buffer[7]==0x00
+ && Buffer[8]=='l'
+ && Buffer[9]==0x00)
+ || (Buffer[0]==0xFF
+ && Buffer[1]==0xFE
+ && Buffer[2]=='<'
+ && Buffer[3]==0x00
+ && Buffer[4]=='?'
+ && Buffer[5]==0x00
+ && Buffer[6]=='x'
+ && Buffer[7]==0x00
+ && Buffer[8]=='m'
+ && Buffer[9]==0x00
+ && Buffer[10]=='l'
+ && Buffer[11]==0x00))
+ Data.From_UTF16LE((const char*)Buffer, Buffer_Size);
+ else if ((Buffer[0]==0x00
+ && Buffer[1]=='<'
+ && Buffer[2]==0x00
+ && Buffer[3]=='?'
+ && Buffer[4]==0x00
+ && Buffer[5]=='x'
+ && Buffer[6]==0x00
+ && Buffer[7]=='m'
+ && Buffer[8]==0x00
+ && Buffer[9]=='l')
+ || (Buffer[0]==0xFE
+ && Buffer[1]==0xFF
+ && Buffer[2]==0x00
+ && Buffer[3]=='<'
+ && Buffer[4]==0x00
+ && Buffer[5]=='?'
+ && Buffer[6]==0x00
+ && Buffer[7]=='x'
+ && Buffer[8]==0x00
+ && Buffer[9]=='m'
+ && Buffer[10]==0x00
+ && Buffer[11]=='l'))
+ Data.From_UTF16BE((const char*)Buffer, Buffer_Size);
+ else
+ {
+ Reject();
+ return false;
+ }
+
+ string DataUTF8=Data.To_UTF8();
+ if (Document.Parse(DataUTF8.c_str()))
+ {
+ Reject();
+ return false;
+ }
+
+ return true;
+}
+
+//***************************************************************************
+// Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File__Analyze::Synchro_Manage()
+{
+ //Testing if synchro is OK
+ if (Synched)
+ {
+ if (!Synchro_Manage_Test())
+ return false;
+ }
+
+ //Trying to synchronize
+ if (!Synched)
+ {
+ //Buffer_TotalBytes_Fill_Max
+ if (!Status[IsFilled] && Buffer_TotalBytes>=Buffer_TotalBytes_Fill_Max)
+ {
+ Reject(); //There was a wrong detection
+ return false;
+ }
+ if (!Synchronize())
+ {
+ if (Status[IsFinished])
+ Finish(); //Finish
+ if (!IsSub && File_Offset_FirstSynched==(int64u)-1 && Buffer_TotalBytes+Buffer_Offset>=Buffer_TotalBytes_FirstSynched_Max)
+ Reject();
+ return false; //Wait for more data
+ }
+ Synched=true;
+ if (File_Offset_FirstSynched==(int64u)-1)
+ {
+ Synched_Init();
+ Buffer_TotalBytes_FirstSynched+=Buffer_TotalBytes+Buffer_Offset;
+ File_Offset_FirstSynched=File_Offset+Buffer_Offset;
+ }
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return false;
+ #endif //MEDIAINFO_DEMUX
+ if (!Synchro_Manage_Test())
+ return false;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File__Analyze::Synchro_Manage_Test()
+{
+ //Testing if synchro is OK
+ if (Synched)
+ {
+ if (!Synched_Test())
+ return false;
+ #if MEDIAINFO_DEMUX
+ if (Synched && Demux_TotalBytes<=Buffer_TotalBytes+Buffer_Offset)
+ {
+ if (Demux_UnpacketizeContainer && !Demux_UnpacketizeContainer_Test())
+ {
+ Demux_Offset-=Buffer_Offset;
+ return false; //Wait for more data
+ }
+ if (Config->Demux_EventWasSent)
+ return false;
+ }
+ #endif //MEDIAINFO_DEMUX
+ if ((FrameInfo_Next.DTS!=(int64u)-1 || FrameInfo_Next.PTS!=(int64u)-1) && Buffer_Offset+Element_Offset>=FrameInfo.Buffer_Offset)
+ {
+ FrameInfo=FrameInfo_Next;
+ FrameInfo_Next=frame_info();
+ }
+ if (!Synched)
+ {
+ Element[Element_Level].IsComplete=true; //Else the trusting algo will think it
+ Trusted_IsNot("Synchronisation lost");
+ }
+ }
+
+ //Trying to synchronize
+ if (!Synched)
+ {
+ if (!Synchronize())
+ {
+ if (Status[IsFinished])
+ Finish(); //Finish
+ if (!IsSub && File_Offset_FirstSynched==(int64u)-1 && Buffer_TotalBytes+Buffer_Offset>=Buffer_TotalBytes_FirstSynched_Max)
+ Reject();
+ return false; //Wait for more data
+ }
+ Synched=true;
+ if (File_Offset_FirstSynched==(int64u)-1)
+ {
+ Synched_Init();
+ Buffer_TotalBytes_FirstSynched+=Buffer_TotalBytes+Buffer_Offset;
+ File_Offset_FirstSynched=File_Offset+Buffer_Offset;
+ }
+ if (!Synched_Test())
+ return false;
+ #if MEDIAINFO_DEMUX
+ if (Synched && Demux_TotalBytes<=Buffer_TotalBytes+Buffer_Offset)
+ {
+ if (Demux_UnpacketizeContainer && !Demux_UnpacketizeContainer_Test())
+ {
+ Demux_Offset-=Buffer_Offset;
+ return false; //Wait for more data
+ }
+ if (Config->Demux_EventWasSent)
+ return false;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ return true;
+}
+
+//***************************************************************************
+// File Header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File__Analyze::FileHeader_Manage()
+{
+ //From the parser
+ if (!Status[IsAccepted] && !FileHeader_Begin())
+ {
+ if (Status[IsFinished]) //Newest parsers set this bool if there is an error
+ Reject();
+ if (File_Offset+Buffer_Size>=File_Size)
+ Reject();
+ return false; //Wait for more data
+ }
+
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return false;
+ #endif //MEDIAINFO_DEMUX
+
+ //From the parser
+ Element_Size=Buffer_Size;
+ Element_Begin1("File Header");
+ FileHeader_Parse();
+ if (Element_Offset==0)
+ Element_DoNotShow();
+ Element_End0();
+ if (Status[IsFinished]) //Newest parsers set this bool if there is an error
+ {
+ Finish();
+ return false;
+ }
+
+ //Testing the parser result
+ if (Element_IsWaitingForMoreData() || Element[Element_Level].UnTrusted) //Wait or problem
+ {
+ //The header is not complete, need more data
+ #if MEDIAINFO_TRACE
+ Element[Element_Level].ToShow.Details.clear();
+ #endif //MEDIAINFO_TRACE
+ return false;
+ }
+
+ //Positionning
+ Buffer_Offset+=(size_t)Element_Offset;
+
+ MustParseTheHeaderFile=false;
+ return true;
+}
+
+//***************************************************************************
+// Header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File__Analyze::Header_Manage()
+{
+ //Test
+ if (Buffer_Offset>=Buffer_Size)
+ return false;
+
+ //Header begin
+ Element_Size=Element[Element_Level].Next-(File_Offset+Buffer_Offset);
+ Element_Offset=0;
+ if (!Header_Begin())
+ {
+ //Jumping to the end of the file if needed
+ if (!EOF_AlreadyDetected && Config_ParseSpeed<1 && File_GoTo==(int64u)-1)
+ {
+ Element[Element_Level].WaitForMoreData=false;
+ Detect_EOF();
+ if ((File_GoTo!=(int64u)-1 && File_GoTo>File_Offset+Buffer_Offset) || (Status[IsFinished] && !ShouldContinueParsing))
+ EOF_AlreadyDetected=true;
+ }
+ return false; //Wait for more data
+ }
+
+ //Going in a lower level
+ Element_Size=Element[Element_Level].Next-(File_Offset+Buffer_Offset+Element_Offset);
+ Element[Element_Level].UnTrusted=false;
+ if (Buffer_Offset+Element_Size>Buffer_Size)
+ {
+ Element_Size=Buffer_Size-Buffer_Offset;
+ Element[Element_Level].IsComplete=false;
+ }
+ else
+ Element[Element_Level].IsComplete=true;
+ if (Element_Size==0)
+ return false;
+ Element_Offset=0;
+ Element_Begin0(); //Element
+ #if MEDIAINFO_TRACE
+ Data_Level=Element_Level;
+ #endif //MEDIAINFO_TRACE
+ Element_Begin1("Header"); //Header
+
+ //Header parsing
+ Header_Parse();
+
+ //Testing the parser result
+ if (Element[Element_Level].UnTrusted) //Problem
+ {
+ Header_Fill_Code(0, "Problem");
+ Header_Fill_Size(Element_Size);
+ }
+
+ if (Element_IsWaitingForMoreData() || ((DataMustAlwaysBeComplete && Element[Element_Level-1].Next>File_Offset+Buffer_Size) || File_GoTo!=(int64u)-1) //Wait or want to have a comple data chunk
+ #if MEDIAINFO_DEMUX
+ || (Config->Demux_EventWasSent)
+ #endif //MEDIAINFO_DEMUX
+ )
+ {
+ //The header is not complete, need more data
+ Element[Element_Level].WaitForMoreData=true;
+ Element_End0(); //Header
+ Element_End0(); //Element
+ return false;
+ }
+
+ //Filling
+ Element[Element_Level].WaitForMoreData=false;
+ Element[Element_Level].IsComplete=true;
+
+ //ToShow
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ if (Element[Element_Level-1].ToShow.Name.empty())
+ Element[Element_Level-1].ToShow.Name=_T("Unknown");
+ Element[Element_Level].ToShow.Size=Element_Offset;
+ Element[Element_Level].ToShow.Header_Size=0;
+ Element[Element_Level-1].ToShow.Header_Size=Header_Size;
+ if (Element_Offset==0)
+ Element_DoNotShow();
+ }
+ #endif //MEDIAINFO_TRACE
+
+ //Integrity
+ if (Element[Element_Level-1].Next<(File_Offset+Buffer_Offset+Element_Offset))
+ Element[Element_Level-1].Next=File_Offset+Buffer_Offset+Element_Offset; //Size is not good
+
+ //Positionning
+ Element_Size=Element[Element_Level-1].Next-(File_Offset+Buffer_Offset+Element_Offset);
+ Header_Size=Element_Offset;
+ Buffer_Offset+=(size_t)Header_Size;
+ Element_Offset=0;
+ if (Buffer_Offset+Element_Size>Buffer_Size)
+ {
+ if (Buffer_Size>Buffer_Offset)
+ Element_Size=Buffer_Size-Buffer_Offset;
+ else
+ Element_Size=0; //There is an error in the parsing
+ Element[Element_Level-1].IsComplete=false;
+ }
+
+ Element_End0(); //Header
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Header_Parse()
+{
+ //Filling
+ Header_Fill_Code(0);
+ Header_Fill_Size(Element_Size);
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Header_Fill_Code(int64u Code, const Ztring &Name)
+{
+ //Filling
+ Element[Element_Level-1].Code=Code;
+
+ //ToShow
+ if (Config_Trace_Level!=0)
+ {
+ Element_Level--;
+ Element_Name(Name);
+ Element_Level++;
+ }
+}
+#endif //MEDIAINFO_TRACE
+
+void File__Analyze::Header_Fill_Code(int64u Code)
+{
+ //Filling
+ Element[Element_Level-1].Code=Code;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Header_Fill_Size(int64u Size)
+{
+ if (Size==0)
+ Trusted_IsNot("Header can't be 0");
+
+ if (Element[Element_Level].UnTrusted)
+ return;
+
+ //Integrity
+ if (Size<Element_Offset)
+ Size=Element_Offset; //At least what we read before!!!
+
+ //Filling
+ if (Element_Level==1)
+ Element[0].Next=File_Offset+Buffer_Offset+Size;
+ else if (File_Offset+Buffer_Offset+Size>Element[Element_Level-2].Next)
+ Element[Element_Level-1].Next=Element[Element_Level-2].Next;
+ else
+ Element[Element_Level-1].Next=File_Offset+Buffer_Offset+Size;
+ Element[Element_Level-1].IsComplete=true;
+
+ //ToShow
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ Element[Element_Level-1].ToShow.Pos=File_Offset+Buffer_Offset;
+ Element[Element_Level-1].ToShow.Size=Element[Element_Level-1].Next-(File_Offset+Buffer_Offset);
+ }
+ #endif //MEDIAINFO_TRACE
+}
+
+//***************************************************************************
+// Data
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File__Analyze::Data_Manage()
+{
+ Element_WantNextLevel=false;
+ if (!Element[Element_Level].UnTrusted)
+ {
+ Element_Code=Element[Element_Level].Code;
+ //size_t Element_Level_Save=Element_Level;
+ Data_Parse();
+ BS->Attach(NULL, 0); //Clear it
+ //Element_Level=Element_Level_Save;
+
+
+ if ((FrameInfo_Next.DTS!=(int64u)-1 || FrameInfo_Next.PTS!=(int64u)-1) && (Buffer_Offset+Element_Offset>=FrameInfo.Buffer_Offset || Frame_Count>Frame_Count_Previous || Field_Count>Field_Count_Previous))
+ {
+ FrameInfo=FrameInfo_Next;
+ FrameInfo_Next=frame_info();
+
+ if (Frame_Count_Previous<Frame_Count)
+ Frame_Count_Previous=Frame_Count;
+ if (Field_Count_Previous<Field_Count)
+ Field_Count_Previous=Field_Count;
+ }
+
+ //Testing the parser result
+ if (Element_IsWaitingForMoreData())
+ {
+ //The data is not complete, need more data
+ Element_End0(); //Element
+ Buffer_Offset-=(size_t)Header_Size;
+ return false;
+ }
+
+ Element[Element_Level].IsComplete=true;
+ }
+
+ //If no need of more
+ if (File_GoTo!=(int64u)-1 || (Status[IsFinished] && !ShouldContinueParsing))
+ {
+ if (!Element_WantNextLevel)
+ Element_End0(); //Element
+ return false;
+ }
+
+ //Next element
+ if (!Element_WantNextLevel)
+ {
+ if (Element[Element_Level].Next<=File_Offset+Buffer_Size)
+ {
+ if (Element_Offset<(size_t)(Element[Element_Level].Next-File_Offset-Buffer_Offset))
+ Element_Offset=(size_t)(Element[Element_Level].Next-File_Offset-Buffer_Offset);
+ }
+ else if (!Status[IsFinished])
+ {
+ GoTo(Element[Element_Level].Next);
+ if (!Element_WantNextLevel)
+ Element_End0(); //Element
+ return false;
+ }
+ }
+ if (File_GoTo==(int64u)-1 && Buffer_Offset+Element_Offset>Buffer_Size && File_Offset!=File_Size)
+ {
+ GoTo(File_Offset+Buffer_Offset+Element_Offset); //Preparing to go far
+ if (!Element_WantNextLevel)
+ Element_End0(); //Element
+ return false;
+ }
+
+ Buffer_Offset+=(size_t)Element_Offset;
+ Header_Size=0;
+ Element_Size=0;
+ Element_Offset=0;
+
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ {
+ if (!Element_WantNextLevel)
+ Element_End0();
+ return false;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ #if MEDIAINFO_TRACE
+ if (Element_Level>0)
+ Element[Element_Level-1].ToShow.NoShow=Element[Element_Level].ToShow.NoShow; //If data must not be shown, we hide the header too
+ else
+ Element[0].ToShow.NoShow=false; //This should never happen, but in case of
+ #endif //MEDIAINFO_TRACE
+ Element_End0(); //Element
+ if (Element_WantNextLevel)
+ Element_Level++;
+ Element[Element_Level].UnTrusted=false;
+
+ //Jumping to the end of the file if needed
+ if (!EOF_AlreadyDetected && Config_ParseSpeed<1 && File_GoTo==(int64u)-1)
+ {
+ Element[Element_Level].WaitForMoreData=false;
+ Detect_EOF();
+ if ((File_GoTo!=(int64u)-1 && File_GoTo>File_Offset+Buffer_Offset) || (Status[IsFinished] && !ShouldContinueParsing))
+ {
+ EOF_AlreadyDetected=true;
+ return false;
+ }
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Data_Info (const Ztring &Parameter)
+{
+ size_t Element_Level_Temp=Element_Level;
+ Element_Level=Data_Level;
+ Element_Info(Parameter);
+ Element_Level=Element_Level_Temp;
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Data_Accept (const char* ParserName)
+{
+ if (Status[IsAccepted] || Status[IsFinished])
+ return;
+
+ if (ParserName)
+ Info(Ztring(ParserName)+_T(", accepted"));
+
+ Accept(ParserName);
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Data_Finish (const char* ParserName)
+{
+ if (ShouldContinueParsing)
+ {
+ //if (ParserName)
+ // Info(Ztring(ParserName)+_T(", wants to finish, but should continue parsing"));
+ return;
+ }
+
+ if (ParserName)
+ Info(Ztring(ParserName)+_T(", finished"));
+
+ Finish();
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Data_Reject (const char* ParserName)
+{
+ Status[IsAccepted]=false;
+ Status[IsFinished]=true;
+ Clear();
+
+ if (ParserName)// && File_Offset+Buffer_Offset+Element_Size<File_Size)
+ Info(Ztring(ParserName)+_T(", rejected"));
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Data_GoTo (int64u GoTo_, const char* ParserName)
+{
+ Element_Show();
+
+ if (ShouldContinueParsing)
+ {
+ if (ParserName)
+ Info(Ztring(ParserName)+_T(", wants to go to somewhere, but should continue parsing"));
+ return;
+ }
+
+ if (IsSub)
+ {
+ if (ParserName)
+ Info(Ztring(ParserName)+_T(", wants to go to somewhere, but is sub, waiting data"));
+ return;
+ }
+
+ Info(Ztring(ParserName)+_T(", jumping to offset ")+Ztring::ToZtring(GoTo_, 16));
+ GoTo(GoTo_);
+ Element_End0();
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Data_GoToFromEnd (int64u GoToFromEnd, const char* ParserName)
+{
+ if (IsSub && Config_ParseSpeed==1)
+ return;
+
+ if (GoToFromEnd>File_Size)
+ {
+ if (ParserName)
+ Info(Ztring(ParserName)+_T(", wants to go to somewhere, but not valid"));
+ return;
+ }
+
+ Data_GoTo(File_Size-GoToFromEnd, ParserName);
+}
+#endif //MEDIAINFO_TRACE
+
+
+//***************************************************************************
+// Element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+Ztring Log_Offset (int64u OffsetToShow, MediaInfo_Config::trace_Format Config_Trace_Format)
+{
+ if (OffsetToShow==(int64u)-1)
+ return _T(" ");
+ int64u Offset=OffsetToShow%0x100000000ULL; //Only 32 bits
+ Ztring Pos1; Pos1.From_Number(Offset, 16);
+ Ztring Pos2;
+ Pos2.resize(8-Pos1.size(), _T('0'));
+ Pos2+=Pos1;
+ Pos2.MakeUpperCase();
+ switch (Config_Trace_Format)
+ {
+ case MediaInfo_Config::Trace_Format_Tree : Pos2+=_T(' '); break;
+ case MediaInfo_Config::Trace_Format_CSV : Pos2+=_T(','); break;
+ default : ;
+ }
+ return Pos2;
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+void File__Analyze::Element_Begin()
+{
+ //Level
+ Element_Level++;
+
+ //Element
+ Element[Element_Level].Code=0;
+ Element[Element_Level].Next=Element[Element_Level-1].Next;
+ Element[Element_Level].WaitForMoreData=Element[Element_Level-1].WaitForMoreData;
+ Element[Element_Level].UnTrusted=Element[Element_Level-1].UnTrusted;
+ Element[Element_Level].IsComplete=Element[Element_Level-1].IsComplete;
+
+ //ToShow
+ #if MEDIAINFO_TRACE
+ Element[Element_Level].ToShow.Pos=File_Offset+Buffer_Offset+Element_Offset+BS->OffsetBeforeLastCall_Get(); //TODO: change this, used in Element_End0()
+ if (Trace_Activated)
+ {
+ Element[Element_Level].ToShow.Size=Element[Element_Level].Next-(File_Offset+Buffer_Offset+Element_Offset+BS->OffsetBeforeLastCall_Get());
+ Element[Element_Level].ToShow.Header_Size=0;
+ Element[Element_Level].ToShow.Name.clear();
+ Element[Element_Level].ToShow.Info.clear();
+ Element[Element_Level].ToShow.Details.clear();
+ Element[Element_Level].ToShow.NoShow=false;
+ }
+ #endif //MEDIAINFO_TRACE
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Element_Begin(const Ztring &Name)
+{
+ //Level
+ Element_Level++;
+
+ //Element
+ Element[Element_Level].Code=0;
+ Element[Element_Level].Next=Element[Element_Level-1].Next;
+ Element[Element_Level].WaitForMoreData=false;
+ Element[Element_Level].UnTrusted=Element[Element_Level-1].UnTrusted;
+ Element[Element_Level].IsComplete=Element[Element_Level-1].IsComplete;
+
+ //ToShow
+ Element[Element_Level].ToShow.Pos=File_Offset+Buffer_Offset+Element_Offset+BS->OffsetBeforeLastCall_Get(); //TODO: change this, used in Element_End0()
+ if (Trace_Activated)
+ {
+ Element[Element_Level].ToShow.Size=Element[Element_Level].Next-(File_Offset+Buffer_Offset+Element_Offset+BS->OffsetBeforeLastCall_Get());
+ Element[Element_Level].ToShow.Header_Size=0;
+ Element_Name(Name);
+ Element[Element_Level].ToShow.Info.clear();
+ Element[Element_Level].ToShow.Details.clear();
+ Element[Element_Level].ToShow.NoShow=false;
+ }
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Element_Name(const Ztring &Name)
+{
+ //ToShow
+ if (Trace_Activated)
+ {
+ if (!Name.empty())
+ {
+ Ztring Name2=Name;
+ Name2.FindAndReplace(_T("\r\n"), _T("__"), 0, Ztring_Recursive);
+ Name2.FindAndReplace(_T("\r"), _T("_"), 0, Ztring_Recursive);
+ Name2.FindAndReplace(_T("\n"), _T("_"), 0, Ztring_Recursive);
+ if (Name2[0]==_T(' '))
+ Name2[0]=_T('_');
+ Element[Element_Level].ToShow.Name=Name2;
+ }
+ else
+ Element[Element_Level].ToShow.Name=_T("(Empty)");
+ }
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Element_Info(const Ztring &Parameter)
+{
+ //Coherancy
+ if (Config_Trace_Level==0 || !(Trace_Layers.to_ulong()&Config_Trace_Layers.to_ulong()) || Element[Element_Level].ToShow.Details.size()>64*1024*1024)
+ return;
+
+ //Needed?
+ if (Config_Trace_Level<=0.7)
+ return;
+
+ //ToShow
+ Ztring Parameter2(Parameter);
+ Parameter2.FindAndReplace(_T("\r\n"), _T(" / "));
+ Parameter2.FindAndReplace(_T("\r"), _T(" / "));
+ Parameter2.FindAndReplace(_T("\n"), _T(" / "));
+ switch (Config_Trace_Format)
+ {
+ case MediaInfo_Config::Trace_Format_Tree :
+ case MediaInfo_Config::Trace_Format_CSV : Element[Element_Level].ToShow.Info+=_T(" - "); break;
+ default : ;
+ }
+ Element[Element_Level].ToShow.Info+=Parameter2;
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Element_End(const Ztring &Name)
+{
+ //ToShow
+ if (Trace_Activated)
+ {
+ Element[Element_Level].ToShow.Size=Element[Element_Level].Next-Element[Element_Level].ToShow.Pos;
+ if (!Name.empty())
+ Element[Element_Level].ToShow.Name=Name;
+ }
+
+ Element_End_Common_Flush();
+}
+#endif //MEDIAINFO_TRACE
+
+//***************************************************************************
+// Element - Common
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Element_End_Common_Flush()
+{
+ #if MEDIAINFO_TRACE
+ //Size if not filled
+ if (File_Offset+Buffer_Offset+Element_Offset+BS->Offset_Get()<Element[Element_Level].Next)
+ Element[Element_Level].ToShow.Size=File_Offset+Buffer_Offset+Element_Offset+BS->Offset_Get()-Element[Element_Level].ToShow.Pos;
+ #endif //MEDIAINFO_TRACE
+
+ //Level
+ if (Element_Level==0)
+ return;
+
+ //Element level
+ Element_Level--;
+
+ //Element
+ Element[Element_Level].UnTrusted=Element[Element_Level+1].UnTrusted;
+ Element[Element_Level].WaitForMoreData=Element[Element_Level+1].WaitForMoreData;
+
+ #if MEDIAINFO_TRACE
+ Element_End_Common_Flush_Details();
+ #endif //MEDIAINFO_TRACE
+}
+
+#if MEDIAINFO_TRACE
+//---------------------------------------------------------------------------
+void File__Analyze::Element_End_Common_Flush_Details()
+{
+ if (Trace_Activated)
+ {
+ if (!Element[Element_Level+1].WaitForMoreData && (Element[Element_Level+1].IsComplete || !Element[Element_Level+1].UnTrusted) && !Element[Element_Level+1].ToShow.NoShow)// && Config_Trace_Level!=0 && Element[Element_Level].ToShow.Details.size()<=64*1024*1024)
+ {
+ //Element
+ if (!Element[Element_Level+1].ToShow.Name.empty())
+ {
+ if (!Element[Element_Level].ToShow.Details.empty())
+ Element[Element_Level].ToShow.Details+=Config_LineSeparator;
+ Element[Element_Level].ToShow.Details+=Element_End_Common_Flush_Build();
+ Element[Element_Level+1].ToShow.Name.clear();
+ }
+
+ //Info
+ if (!Element[Element_Level+1].ToShow.Details.empty())
+ {
+ if (!Element[Element_Level].ToShow.Details.empty())
+ Element[Element_Level].ToShow.Details+=Config_LineSeparator;
+ Element[Element_Level].ToShow.Details+=Element[Element_Level+1].ToShow.Details;
+ Element[Element_Level+1].ToShow.Details.clear();
+ }
+ }
+ }
+}
+#endif //MEDIAINFO_TRACE
+
+#if MEDIAINFO_TRACE
+//---------------------------------------------------------------------------
+Ztring File__Analyze::Element_End_Common_Flush_Build()
+{
+ Ztring ToReturn;
+
+ //Show Offset
+ if (Config_Trace_Level>0.7)
+ {
+ ToReturn+=Log_Offset(Element[Element_Level+1].ToShow.Pos, Config_Trace_Format);
+ }
+
+ //Name
+ switch (Config_Trace_Format)
+ {
+ case MediaInfo_Config::Trace_Format_Tree : ToReturn.resize(ToReturn.size()+Element_Level_Base+Element_Level, _T(' ')); break;
+ case MediaInfo_Config::Trace_Format_CSV :
+ ToReturn+=_T("G,");
+ ToReturn+=Ztring::ToZtring(Element_Level_Base+Element_Level);
+ ToReturn+=_T(',');
+ break;
+ default : ;
+ }
+ ToReturn+=Element[Element_Level+1].ToShow.Name;
+
+ //Info
+ ToReturn+=Element[Element_Level+1].ToShow.Info;
+ Element[Element_Level+1].ToShow.Info.clear();
+
+ //Size
+ if (Config_Trace_Level>0.3)
+ {
+ switch (Config_Trace_Format)
+ {
+ case MediaInfo_Config::Trace_Format_Tree :
+ ToReturn+=_T(" (");
+ break;
+ case MediaInfo_Config::Trace_Format_CSV :
+ ToReturn+=_T(",(");
+ break;
+ default : ;
+ }
+ ToReturn+=Ztring::ToZtring(Element[Element_Level+1].ToShow.Size);
+ if (Element[Element_Level+1].ToShow.Header_Size>0)
+ {
+ ToReturn+=_T("/");
+ ToReturn+=Ztring::ToZtring(Element[Element_Level+1].ToShow.Size-Element[Element_Level+1].ToShow.Header_Size);
+ }
+ ToReturn+=_T(" bytes)");
+ }
+
+ return ToReturn;
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+void File__Analyze::Element_Prepare (int64u Size)
+{
+ Element_Offset=0;
+ Element_Size=Size;
+ #if MEDIAINFO_TRACE
+ Element[Element_Level].ToShow.Size=Size;
+ #endif //MEDIAINFO_TRACE
+}
+//***************************************************************************
+// Param
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Param(const Ztring& Parameter, const Ztring& Value)
+{
+ if (Config_Trace_Level==0 || !(Trace_Layers.to_ulong()&Config_Trace_Layers.to_ulong()))
+ return;
+
+ //Position
+ int64u Pos=Element_Offset+BS->OffsetBeforeLastCall_Get();
+
+ //Coherancy
+ if (Element[Element_Level].UnTrusted)
+ return;
+
+ const size_t Padding_Value=40;
+
+ //Line separator
+ if (!Element[Element_Level].ToShow.Details.empty())
+ Element[Element_Level].ToShow.Details+=Config_LineSeparator;
+
+ //Show Offset
+ if (Config_Trace_Level>0.7)
+ {
+ Element[Element_Level].ToShow.Details+=Log_Offset(Pos==(int64u)-1?Pos:(File_Offset+Buffer_Offset+Pos), Config_Trace_Format);
+ }
+
+ //Show Parameter+Value
+ switch (Config_Trace_Format)
+ {
+ case MediaInfo_Config::Trace_Format_Tree :
+ {
+ //Show Parameter
+ Ztring Param; Param=Parameter;
+ if (Param.size()>Padding_Value) Param.resize(Padding_Value);
+ Element[Element_Level].ToShow.Details.resize(Element[Element_Level].ToShow.Details.size()+Element_Level_Base+Element_Level, _T(' '));
+ Element[Element_Level].ToShow.Details+=Param;
+
+ //Show Value
+ if (!Value.empty())
+ {
+ Element[Element_Level].ToShow.Details+=_T(": ");
+ Element[Element_Level].ToShow.Details.resize(Element[Element_Level].ToShow.Details.size()+Padding_Value-Param.size()-Element_Level+1, _T(' '));
+ Ztring Value2(Value);
+ Value2.FindAndReplace(_T("\r\n"), _T(" / "), 0, Ztring_Recursive);
+ Value2.FindAndReplace(_T("\r"), _T(" / "), 0, Ztring_Recursive);
+ Value2.FindAndReplace(_T("\n"), _T(" / "), 0, Ztring_Recursive);
+ Element[Element_Level].ToShow.Details+=Value2;
+ }
+ }
+ break;
+ case MediaInfo_Config::Trace_Format_CSV :
+ Element[Element_Level].ToShow.Details+=_T("T,");
+ Element[Element_Level].ToShow.Details+=Ztring::ToZtring(Element_Level_Base+Element_Level);
+ Element[Element_Level].ToShow.Details+=_T(',');
+ Element[Element_Level].ToShow.Details+=Parameter;
+ Element[Element_Level].ToShow.Details+=_T(',');
+ Element[Element_Level].ToShow.Details+=Value;
+ break;
+ default : ;
+ }
+}
+#endif //MEDIAINFO_TRACE
+
+//***************************************************************************
+// Information
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Info(const Ztring& Value, size_t Element_Level_Minus)
+{
+ if (Config_Trace_Format==MediaInfo_Config::Trace_Format_CSV)
+ return; //Do not display info
+
+ //Handling a different level (only Element_Level_Minus to 1 is currently well supported)
+ size_t Element_Level_Final=Element_Level;
+ if (Element_Level_Minus<=Element_Level)
+ {
+ if (Element_Level_Minus==1)
+ {
+ Element_Level--;
+ Element_End_Common_Flush_Details();
+ Element_Level++;
+ }
+ Element_Level_Final-=Element_Level_Minus;
+ }
+
+ if (Config_Trace_Level==0 || !(Trace_Layers.to_ulong()&Config_Trace_Layers.to_ulong()))
+ return;
+
+ //Coherancy
+ if (Element[Element_Level_Final].UnTrusted)
+ return;
+
+ //Line separator
+ if (!Element[Element_Level_Final].ToShow.Details.empty())
+ Element[Element_Level_Final].ToShow.Details+=Config_LineSeparator;
+
+ //Preparing
+ Ztring ToShow; ToShow.resize(Element_Level_Final, _T(' '));
+ ToShow+=_T("--- ");
+ ToShow+=Value;
+ ToShow+=_T(" ---");
+ Ztring Separator; Separator.resize(Element_Level_Final, _T(' '));
+ Separator.resize(ToShow.size(), _T('-'));
+
+ //Show Offset
+ Ztring Offset;
+ if (Config_Trace_Level>0.7)
+ Offset=Log_Offset(File_Offset+Buffer_Offset+Element_Offset+BS->Offset_Get(), Config_Trace_Format);
+ Offset.resize(Offset.size()+Element_Level_Base, _T(' '));
+
+ //Show Value
+ Element[Element_Level_Final].ToShow.Details+=Offset;
+ Element[Element_Level_Final].ToShow.Details+=Separator;
+ Element[Element_Level_Final].ToShow.Details+=Config_LineSeparator;
+ Element[Element_Level_Final].ToShow.Details+=Offset;
+ Element[Element_Level_Final].ToShow.Details+=ToShow;
+ Element[Element_Level_Final].ToShow.Details+=Config_LineSeparator;
+ Element[Element_Level_Final].ToShow.Details+=Offset;
+ Element[Element_Level_Final].ToShow.Details+=Separator;
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Param_Info (const Ztring &Text)
+{
+ //Coherancy
+ if (Element[Element_Level].UnTrusted)
+ return;
+ if (Config_Trace_Level==0 || !(Trace_Layers.to_ulong()&Config_Trace_Layers.to_ulong()) || Element[Element_Level].ToShow.Details.size()>64*1024*1024)
+ return;
+
+ //Needed?
+ if (Config_Trace_Level<=0.7)
+ return;
+
+ //Filling
+ Element[Element_Level].ToShow.Details+=_T(" - ")+Text;
+}
+#endif //MEDIAINFO_TRACE
+
+//***************************************************************************
+// Next code planning
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::NextCode_Add (int64u Code)
+{
+ NextCode[Code]=true;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::NextCode_Clear ()
+{
+ NextCode.clear();
+}
+
+//---------------------------------------------------------------------------
+bool File__Analyze::NextCode_Test ()
+{
+ if (NextCode.find(Element_Code)==NextCode.end())
+ {
+ Trusted_IsNot("Frames are not in the right order");
+ return false;
+ }
+
+ return true;
+}
+
+//***************************************************************************
+// Element trusting
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Trusted_IsNot (const char* Reason)
+#else //MEDIAINFO_TRACE
+void File__Analyze::Trusted_IsNot ()
+#endif //MEDIAINFO_TRACE
+{
+ Element_Offset=Element_Size;
+ BS->Attach(NULL, 0);
+
+ if (!Element[Element_Level].UnTrusted)
+ {
+ #if MEDIAINFO_TRACE
+ Param(Reason, 0);
+ #endif //MEDIAINFO_TRACE
+
+ //Enough data?
+ if (!Element[Element_Level].IsComplete)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ Element[Element_Level].UnTrusted=true;
+ Synched=false;
+ if (!Status[IsFilled] && Trusted>0)
+ Trusted--;
+ }
+
+ if (Trusted==0)
+ Reject();
+}
+
+//***************************************************************************
+// Actions
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Accept (const char* ParserName_Char)
+#else //MEDIAINFO_TRACE
+void File__Analyze::Accept ()
+#endif //MEDIAINFO_TRACE
+{
+ if (Status[IsAccepted] || Status[IsFinished])
+ return;
+
+ #if MEDIAINFO_TRACE
+ if (ParserName.empty())
+ ParserName.From_Local(ParserName_Char);
+
+ if (!ParserName.empty())
+ {
+ bool MustElementBegin=Element_Level?true:false;
+ if (Element_Level>0)
+ Element_End0(); //Element
+ Info(ParserName+_T(", accepted"));
+ if (MustElementBegin)
+ Element_Level++;
+ }
+ #endif //MEDIAINFO_TRACE
+
+ Status[IsAccepted]=true;
+ if (Count_Get(Stream_General)==0)
+ {
+ Stream_Prepare(Stream_General);
+ Streams_Accept();
+ }
+
+ #if MEDIAINFO_EVENTS
+ if (!IsSub)
+ {
+ struct MediaInfo_Event_General_Parser_Selected_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_Parser_Selected, 0);
+ std::memset(Event.Name, 0, 16);
+ if (!ParserName.empty())
+ strncpy(Event.Name, ParserName.To_Local().c_str(), 15);
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_General_Parser_Selected_0));
+
+ #if MEDIAINFO_DEMUX
+ if (!Demux_EventWasSent_Accept_Specific && Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ Config->Demux_EventWasSent=true;
+ #endif //MEDIAINFO_DEMUX
+ }
+ #endif //MEDIAINFO_EVENTS
+}
+
+void File__Analyze::Accept (File__Analyze* Parser)
+{
+ if (Parser==NULL)
+ return;
+
+ Parser->Accept();
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Update (const char* ParserName_Char)
+#else //MEDIAINFO_TRACE
+void File__Analyze::Update ()
+#endif //MEDIAINFO_TRACE
+{
+ if (!Status[IsAccepted])
+ return;
+
+ Open_Buffer_Update();
+}
+
+void File__Analyze::Update (File__Analyze* Parser)
+{
+ if (Parser==NULL)
+ return;
+
+ Parser->Update();
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Fill (const char* ParserName_Char)
+#else //MEDIAINFO_TRACE
+void File__Analyze::Fill ()
+#endif //MEDIAINFO_TRACE
+{
+ if (!Status[IsAccepted] || Status[IsFilled] || Status[IsFinished])
+ return;
+
+ #if MEDIAINFO_TRACE
+ if (ParserName.empty())
+ ParserName.From_Local(ParserName_Char);
+
+ if (!ParserName.empty())
+ {
+ bool MustElementBegin=Element_Level?true:false;
+ if (Element_Level>0)
+ Element_End0(); //Element
+ Info(ParserName+_T(", filling"));
+ if (MustElementBegin)
+ Element_Level++;
+ }
+ #endif //MEDIAINFO_TRACE
+
+ Streams_Fill();
+ Status[IsFilled]=true;
+ Status[IsUpdated]=true;
+
+ //Instantaneous bitrate at the "fill" level
+ if (File_Size==(int64u)-1 && FrameInfo.PTS!=(int64u)-1 && PTS_Begin!=(int64u)-1 && FrameInfo.PTS-PTS_Begin && StreamKind_Last!=Stream_General && StreamKind_Last!=Stream_Max)
+ {
+ Fill(StreamKind_Last, 0, "BitRate_Instantaneous", Buffer_TotalBytes*8*1000000000/(FrameInfo.PTS-PTS_Begin));
+ (*Stream_More)[StreamKind_Last][0](Ztring().From_Local("BitRate_Instantaneous"), Info_Options)=_T("N NI");
+ }
+}
+
+void File__Analyze::Fill (File__Analyze* Parser)
+{
+ if (Parser==NULL)
+ return;
+
+ Parser->Fill();
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Finish (const char* ParserName_Char)
+#else //MEDIAINFO_TRACE
+void File__Analyze::Finish ()
+#endif //MEDIAINFO_TRACE
+{
+ if (Status[IsFinished])
+ return;
+
+ if (!ShouldContinueParsing && !Status[IsFilled])
+ Fill();
+
+ if (ShouldContinueParsing || Config_ParseSpeed==1)
+ {
+ #if MEDIAINFO_TRACE
+ if (!ParserName.empty())
+ {
+ bool MustElementBegin=Element_Level?true:false;
+ if (Element_Level>0)
+ Element_End0(); //Element
+ //Info(Ztring(ParserName)+_T(", wants to finish, but should continue parsing"));
+ if (MustElementBegin)
+ Element_Level++;
+ }
+ #endif //MEDIAINFO_TRACE
+
+ return;
+ }
+
+ ForceFinish();
+}
+
+void File__Analyze::Finish (File__Analyze* Parser)
+{
+ ForceFinish(Parser); //The base parser wants, and is prepared to it, so nothing can be cancelled --> ForceFinish() instead of Finish()
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::ForceFinish (const char* ParserName_Char)
+#else //MEDIAINFO_TRACE
+void File__Analyze::ForceFinish ()
+#endif //MEDIAINFO_TRACE
+{
+ if (Status[IsFinished])
+ return;
+
+ #if MEDIAINFO_TRACE
+ if (ParserName.empty())
+ ParserName.From_Local(ParserName_Char);
+
+ if (!ParserName.empty())
+ {
+ bool MustElementBegin=Element_Level?true:false;
+ if (Element_Level>0)
+ Element_End0(); //Element
+ Info(ParserName+_T(", finished"));
+ if (MustElementBegin)
+ Element_Level++;
+ }
+ #endif //MEDIAINFO_TRACE
+
+ if (Status[IsAccepted])
+ {
+ Fill();
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return;
+ #endif //MEDIAINFO_DEMUX
+ Streams_Finish();
+ Ibi_Stream_Finish();
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return;
+ #endif //MEDIAINFO_DEMUX
+ if (Status[IsUpdated])
+ {
+ Open_Buffer_Update();
+ if (IsSub)
+ Status[IsUpdated]=true; //We want that container merges the result
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return;
+ #endif //MEDIAINFO_DEMUX
+ }
+ Streams_Finish_Global();
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return;
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ Status[IsFinished]=true;
+
+ //Real stream size
+ if (Config_ParseSpeed==1 && IsRawStream && Buffer_TotalBytes)
+ {
+ //Exception with text streams embedded in video
+ if (StreamKind_Last==Stream_Text)
+ StreamKind_Last=Stream_Video;
+
+ Fill(StreamKind_Last, 0, "StreamSize", Buffer_TotalBytes, 10, true);
+ }
+}
+
+void File__Analyze::ForceFinish (File__Analyze* Parser)
+{
+ if (Parser==NULL)
+ return;
+
+ if (File_Offset+Buffer_Offset+Element_Size>=File_Size)
+ {
+ Element_Size=0;
+ Parser->Buffer_Offset=(size_t)(Parser->File_Size-Parser->File_Offset);
+ }
+
+ Parser->ForceFinish();
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Reject (const char* ParserName)
+#else //MEDIAINFO_TRACE
+void File__Analyze::Reject ()
+#endif //MEDIAINFO_TRACE
+{
+ Status[IsAccepted]=false;
+ Status[IsFinished]=true;
+ Clear();
+
+ #if MEDIAINFO_TRACE
+ if (ParserName)// && File_Offset+Buffer_Offset+Element_Size<File_Size)
+ {
+ bool MustElementBegin=Element_Level?true:false;
+ if (Element_Level>0)
+ Element_End0(); //Element
+ Info(Ztring(ParserName)+_T(", rejected"));
+ if (MustElementBegin)
+ Element_Level++;
+ }
+ #endif //MEDIAINFO_TRACE
+}
+
+void File__Analyze::Reject (File__Analyze* Parser)
+{
+ if (Parser==NULL)
+ return;
+
+ Parser->Reject();
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::GoTo (int64u GoTo, const char* ParserName)
+{
+ if (!Status[IsAccepted])
+ {
+ Reject();
+ return;
+ }
+
+ Element_Show();
+
+ if (IsSub && Config_ParseSpeed==1)
+ return;
+
+ if (GoTo==File_Size)
+ {
+ if (!BookMark_Code.empty())
+ BookMark_Get();
+ if (File_GoTo==(int64u)-1)
+ ForceFinish();
+ return;
+ }
+
+ if (ShouldContinueParsing)
+ {
+ if (ParserName)
+ {
+ bool MustElementBegin=Element_Level?true:false;
+ if (Element_Level>0)
+ Element_End0(); //Element
+ Info(Ztring(ParserName)+_T(", wants to go to somewhere, but should continue parsing"));
+ if (MustElementBegin)
+ Element_Level++;
+ }
+ return;
+ }
+
+ if (IsSub)
+ {
+ if (ParserName)
+ {
+ bool MustElementBegin=Element_Level?true:false;
+ if (Element_Level>0)
+ Element_End0(); //Element
+ Info(Ztring(ParserName)+_T(", wants to go to somewhere, but is sub, waiting data"));
+ if (MustElementBegin)
+ Element_Level++;
+ }
+ return;
+ }
+
+ if (ParserName)
+ {
+ bool MustElementBegin=Element_Level?true:false;
+ if (Element_Level>0)
+ Element_End0(); //Element
+ Info(Ztring(ParserName)+_T(", jumping to offset ")+Ztring::ToZtring(GoTo, 16));
+ if (MustElementBegin)
+ Element_Level++; //Element
+ }
+
+ File_GoTo=GoTo;
+
+ #if MEDIAINFO_EVENTS
+ struct MediaInfo_Event_General_Move_Request_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_Move_Request, 0);
+ Event.Stream_Offset=File_GoTo;
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_General_Move_Request_0));
+ #endif //MEDIAINFO_EVENTS
+}
+#else //MEDIAINFO_TRACE
+void File__Analyze::GoTo (int64u GoTo)
+{
+ if (!Status[IsAccepted])
+ {
+ Reject();
+ return;
+ }
+
+ if (IsSub && Config_ParseSpeed==1)
+ return;
+
+ if (GoTo==File_Size)
+ {
+ if (!BookMark_Code.empty())
+ BookMark_Get();
+ if (File_GoTo==(int64u)-1)
+ ForceFinish();
+ return;
+ }
+
+ if (ShouldContinueParsing)
+ {
+ return;
+ }
+
+ if (IsSub)
+ {
+ return;
+ }
+
+ File_GoTo=GoTo;
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::GoToFromEnd (int64u GoToFromEnd, const char* ParserName)
+{
+ if (GoToFromEnd>File_Size)
+ {
+ if (ParserName)
+ {
+ bool MustElementBegin=Element_Level?true:false;
+ if (Element_Level>0)
+ Element_End0(); //Element
+ Info(Ztring(ParserName)+_T(", wants to go to somewhere, but not valid"));
+ if (MustElementBegin)
+ Element_Level++;
+ }
+ return;
+ }
+
+ GoTo(File_Size-GoToFromEnd, ParserName);
+}
+#else //MEDIAINFO_TRACE
+void File__Analyze::GoToFromEnd (int64u GoToFromEnd)
+{
+ if (GoToFromEnd>File_Size)
+ return;
+
+ GoTo(File_Size-GoToFromEnd);
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+int64u File__Analyze::Element_Code_Get (size_t Level)
+{
+ return Element[Level].Code;
+}
+
+//---------------------------------------------------------------------------
+int64u File__Analyze::Element_TotalSize_Get (size_t LevelLess)
+{
+ return Element[Element_Level-LevelLess].Next-(File_Offset+Buffer_Offset);
+}
+
+//---------------------------------------------------------------------------
+bool File__Analyze::Element_IsComplete_Get ()
+{
+ return Element[Element_Level].IsComplete;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Element_ThisIsAList ()
+{
+ Element_WantNextLevel=true;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Element_WaitForMoreData ()
+{
+ //if (File_Offset+Buffer_Size<File_Size)
+ Element[Element_Level].WaitForMoreData=true;
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Element_DoNotTrust (const char* Reason)
+#else //MEDIAINFO_TRACE
+void File__Analyze::Element_DoNotTrust ()
+#endif //MEDIAINFO_TRACE
+{
+ Element[Element_Level].WaitForMoreData=false;
+ Element[Element_Level].IsComplete=true;
+ #if MEDIAINFO_TRACE
+ Trusted_IsNot(Reason);
+ #else //MEDIAINFO_TRACE
+ Trusted_IsNot();
+ #endif //MEDIAINFO_TRACE
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Element_DoNotShow ()
+{
+ Element[Element_Level].ToShow.NoShow=true;
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Element_Show ()
+{
+ Element[Element_Level].ToShow.NoShow=false;
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+bool File__Analyze::Element_Show_Get ()
+{
+ return !Element[Element_Level].ToShow.NoShow;
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Element_Show_Add (const Ztring &ToShow)
+{
+ if (ToShow.empty())
+ return;
+
+ //Line separator
+ if (!Element[Element_Level].ToShow.Details.empty())
+ Element[Element_Level].ToShow.Details+=Config_LineSeparator;
+
+ //From Sub
+ Element[Element_Level].ToShow.Details+=ToShow;
+}
+#endif //MEDIAINFO_TRACE
+
+#if MEDIAINFO_TRACE
+void File__Analyze::Trace_Layers_Update(size_t Layer)
+{
+ if (Layer!=(size_t)-1)
+ {
+ Trace_Layers.reset();
+ Trace_Layers.set(Layer);
+ }
+ Trace_Activated=(Config_Trace_Level!=0 && (Trace_Layers&Config_Trace_Layers)!=0);
+}
+#endif //MEDIAINFO_TRACE
+
+//***************************************************************************
+// Status
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File__Analyze::Element_IsOK ()
+{
+ return !Element[Element_Level].WaitForMoreData && !Element[Element_Level].UnTrusted;
+}
+
+//---------------------------------------------------------------------------
+bool File__Analyze::Element_IsNotFinished ()
+{
+ if (BS->Remain()>0 || Element_Offset+BS->Offset_Get()<Element_Size)
+ return true;
+ else
+ return false;
+}
+
+//---------------------------------------------------------------------------
+bool File__Analyze::Element_IsWaitingForMoreData ()
+{
+ return Element[Element_Level].WaitForMoreData;
+}
+
+//***************************************************************************
+// BookMarks
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::BookMark_Set (size_t Element_Level_ToSet)
+{
+ Element_Level_ToSet=Element_Level;
+ BookMark_Element_Level=Element_Level_ToSet;
+ BookMark_Code.resize(BookMark_Element_Level+1);
+ BookMark_Next.resize(BookMark_Element_Level+1);
+ for (size_t Pos=0; Pos<=BookMark_Element_Level; Pos++)
+ {
+ BookMark_Code[Pos]=Element[Pos].Code;
+ BookMark_Next[Pos]=Element[Pos].Next;
+ }
+ BookMark_GoTo=File_Offset+Buffer_Offset+Element_Offset;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::BookMark_Get ()
+{
+ if (!BookMark_Needed())
+ return;
+
+ Element_Show();
+ while (Element_Level>0)
+ Element_End0();
+ while (Element_Level<BookMark_Element_Level)
+ {
+ Element_Begin1("Restarting parsing...");
+ Element_WantNextLevel=true;
+ }
+
+ for (size_t Pos=0; Pos<=Element_Level; Pos++)
+ {
+ Element[Pos].Code=BookMark_Code[Pos];
+ Element[Pos].Next=BookMark_Next[Pos];
+ }
+ BookMark_Code.clear();
+ BookMark_Next.clear();
+ if (File_GoTo==(int64u)-1)
+ File_GoTo=BookMark_GoTo;
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File__Analyze::Details_Clear()
+{
+ Details->clear();
+ Element[0].ToShow.Details.clear();
+}
+#endif //MEDIAINFO_TRACE
+
+//***************************************************************************
+// Demux
+//***************************************************************************
+#if MEDIAINFO_DEMUX
+void File__Analyze::Demux (const int8u* Buffer, size_t Buffer_Size, contenttype Content_Type)
+{
+ if (!(Config_Demux&Demux_Level))
+ return;
+
+ if (!Buffer_Size)
+ return;
+
+ #if MEDIAINFO_DEMUX && MEDIAINFO_SEEK
+ if (Config->Demux_IsSeeking)
+ return;
+ #endif //MEDIAINFO_SEEK
+
+ #if MEDIAINFO_EVENTS
+ //Demux
+ if (StreamIDs_Size)
+ StreamIDs[StreamIDs_Size-1]=Element_Code;
+ struct MediaInfo_Event_Global_Demux_3 Event;
+ if (StreamIDs_Size && StreamIDs_Size<17)
+ Event.EventCode=MediaInfo_EventCode_Create(ParserIDs[StreamIDs_Size-1], MediaInfo_Event_Global_Demux, 3);
+ else
+ Event.EventCode=MediaInfo_EventCode_Create(0x00, MediaInfo_Event_Global_Demux, 3);
+ Event.Stream_Offset=File_Offset+Buffer_Offset;
+ Event.PCR=FrameInfo.PCR;
+ Event.DTS=(FrameInfo.DTS==(int64u)-1?FrameInfo.PTS:FrameInfo.DTS);
+ Event.PTS=FrameInfo.PTS;
+ Event.DUR=FrameInfo.DUR;
+ Event.StreamIDs_Size=StreamIDs_Size;
+ Event.StreamIDs=(MediaInfo_int64u*)StreamIDs;
+ Event.StreamIDs_Width=(MediaInfo_int8u*)StreamIDs_Width;
+ Event.ParserIDs=(MediaInfo_int8u* )ParserIDs;
+ Event.Content_Type=(int8u)Content_Type;
+ Event.Content_Size=Buffer_Size;
+ Event.Content=Buffer;
+ Event.Flags=0;
+ Event.FrameNumber=Frame_Count_NotParsedIncluded;
+ if (Demux_random_access)
+ Event.Flags|=0x1; //Bit 0
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_Global_Demux_3), IsSub?File_Name_WithoutDemux:File_Name);
+ Event.EventCode&=0xFFFFFF00; //Force to version 2
+ Event.EventCode|=0x00000002; //Force to version 2
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_Global_Demux_2), IsSub?File_Name_WithoutDemux:File_Name);
+ Event.EventCode&=0xFFFFFF00; //Force to version 1
+ Event.EventCode|=0x00000001; //Force to version 1
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_Global_Demux_1), IsSub?File_Name_WithoutDemux:File_Name);
+ Event.EventCode&=0xFFFFFF00; //Force to version 0
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_Global_Demux_0), IsSub?File_Name_WithoutDemux:File_Name);
+ if (StreamIDs_Size)
+ StreamIDs[StreamIDs_Size-1]=(int64u)-1;
+ if (Config->NextPacket_Get())
+ Config->Demux_EventWasSent=true;
+ if (StreamIDs_Size)
+ StreamIDs[StreamIDs_Size-1]=(int64u)-1;
+ #endif //MEDIAINFO_EVENTS
+}
+#endif //MEDIAINFO_DEMUX
+
+#if MEDIAINFO_DEMUX
+void File__Analyze::Demux_UnpacketizeContainer_Demux (bool random_access)
+{
+ Demux_random_access=random_access;
+
+ if (StreamIDs_Size>=2)
+ Element_Code=StreamIDs[StreamIDs_Size-2];
+ StreamIDs_Size--;
+ Demux(Buffer+Buffer_Offset, Demux_Offset-Buffer_Offset, ContentType_MainStream);
+ StreamIDs_Size++;
+ if (StreamIDs_Size>=2)
+ StreamIDs[StreamIDs_Size-2]=Element_Code;
+ Demux_UnpacketizeContainer_Demux_Clear();
+}
+
+bool File__Analyze::Demux_UnpacketizeContainer_Test_OneFramePerFile ()
+{
+ if (Buffer_Size<Config->File_Sizes[Config->File_Names_Pos-1])
+ {
+ size_t* File_Buffer_Size_Hint_Pointer=Config->File_Buffer_Size_Hint_Pointer_Get();
+ if (File_Buffer_Size_Hint_Pointer)
+ (*File_Buffer_Size_Hint_Pointer)=(size_t)Config->File_Sizes[Config->File_Names_Pos-1];
+ return false;
+ }
+
+ if (Config->Demux_Rate_Get())
+ {
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ FrameInfo.DTS=float64_int64s(Frame_Count_NotParsedIncluded*1000000000/Config->Demux_Rate_Get());
+ else
+ FrameInfo.DTS=(int64u)-1;
+ FrameInfo.PTS=FrameInfo.DTS;
+ FrameInfo.DUR=float64_int64s(1000000000/Config->Demux_Rate_Get());
+ }
+ Demux_Offset=Buffer_Size;
+ Demux_UnpacketizeContainer_Demux();
+
+ return true;
+}
+
+void File__Analyze::Demux_UnpacketizeContainer_Demux_Clear ()
+{
+ Demux_TotalBytes=Buffer_TotalBytes+Demux_Offset;
+ Demux_Offset=0;
+ //if (Frame_Count || Field_Count)
+ // Element_End0();
+ //Element_Begin1("Frame or Field");
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// IBI
+//***************************************************************************
+#if MEDIAINFO_IBI
+void File__Analyze::Ibi_Read_Buffer_Unsynched ()
+{
+ Ibi_SynchronizationOffset_Current=(int64u)-1;
+
+ if (IbiStream==NULL)
+ return;
+
+ IbiStream->Unsynch();
+ for (size_t Pos=0; Pos<IbiStream->Infos.size(); Pos++)
+ {
+ if (File_GoTo==IbiStream->Infos[Pos].StreamOffset)
+ {
+ FrameInfo.DTS=(IbiStream->Infos[Pos].Dts!=(int64u)-1)?float64_int64s((((float64)IbiStream->Infos[Pos].Dts)*1000000000*IbiStream->DtsFrequencyDenominator/IbiStream->DtsFrequencyNumerator)):(int64u)-1;
+ Frame_Count_NotParsedIncluded=IbiStream->Infos[Pos].FrameNumber;
+ break;
+ }
+ }
+}
+
+size_t File__Analyze::Ibi_Read_Buffer_Seek (size_t Method, int64u Value, int64u /*ID*/)
+{
+ //Init
+ if (!Seek_Duration_Detected)
+ {
+ if (!IsSub)
+ {
+ //External IBI
+ std::string IbiFile=Config->Ibi_Get();
+ if (!IbiFile.empty())
+ {
+ IbiStream->Infos.clear(); //TODO: support IBI data from different inputs
+
+ File_Ibi MI;
+ Open_Buffer_Init(&MI, IbiFile.size());
+ MI.Ibi=new ibi;
+ MI.Open_Buffer_Continue((const int8u*)IbiFile.c_str(), IbiFile.size());
+ (*IbiStream)=(*MI.Ibi->Streams.begin()->second);
+ }
+ }
+
+ Seek_Duration_Detected=true;
+ }
+
+ //Parsing
+ switch (Method)
+ {
+ case 0 :
+ GoTo(Value);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 1 :
+ GoTo(File_Size*Value/10000);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 2 : //Timestamp
+ #if MEDIAINFO_IBI
+ {
+ if (!(IbiStream->DtsFrequencyNumerator==1000000000 && IbiStream->DtsFrequencyDenominator==1))
+ {
+ float64 ValueF=(float64)Value;
+ ValueF/=1000000000; //Value is in ns
+ ValueF/=IbiStream->DtsFrequencyDenominator;
+ ValueF*=IbiStream->DtsFrequencyNumerator;
+ Value=float64_int64s(ValueF);
+ }
+
+ for (size_t Pos=0; Pos<IbiStream->Infos.size(); Pos++)
+ {
+ if (Value<=IbiStream->Infos[Pos].Dts)
+ {
+ if (Value<IbiStream->Infos[Pos].Dts && Pos)
+ Pos--;
+
+ //Checking continuity of Ibi
+ if (!IbiStream->Infos[Pos].IsContinuous && Pos+1<IbiStream->Infos.size())
+ {
+ Config->Demux_IsSeeking=true;
+ GoTo((IbiStream->Infos[Pos].StreamOffset+IbiStream->Infos[Pos+1].StreamOffset)/2);
+ Open_Buffer_Unsynch();
+
+ return 1;
+ }
+
+ Config->Demux_IsSeeking=false;
+
+ GoTo(IbiStream->Infos[Pos].StreamOffset);
+ Open_Buffer_Unsynch();
+
+ return 1;
+ }
+ }
+
+ if (IbiStream->Infos.empty())
+ GoTo(0);
+ else if (!IbiStream->Infos[IbiStream->Infos.size()-1].IsContinuous)
+ GoTo(IbiStream->Infos[IbiStream->Infos.size()-1].StreamOffset);
+ else
+ return 2; //Invalid value
+ return 1;
+ }
+ #else //MEDIAINFO_IBI
+ return (size_t)-2; //Not supported / IBI disabled
+ #endif //MEDIAINFO_IBI
+ case 3 : //FrameNumber
+ #if MEDIAINFO_IBI
+ {
+ for (size_t Pos=0; Pos<IbiStream->Infos.size(); Pos++)
+ {
+ if (Value<=IbiStream->Infos[Pos].FrameNumber)
+ {
+ if (Value<IbiStream->Infos[Pos].FrameNumber && Pos)
+ Pos--;
+
+ //Checking continuity of Ibi
+ if (!IbiStream->Infos[Pos].IsContinuous && Pos+1<IbiStream->Infos.size())
+ {
+ Config->Demux_IsSeeking=true;
+ GoTo((IbiStream->Infos[Pos].StreamOffset+IbiStream->Infos[Pos+1].StreamOffset)/2);
+ Open_Buffer_Unsynch();
+
+ return 1;
+ }
+
+ Config->Demux_IsSeeking=false;
+
+ GoTo(IbiStream->Infos[Pos].StreamOffset);
+ Open_Buffer_Unsynch();
+
+ return 1;
+ }
+ }
+
+ if (IbiStream->Infos.empty())
+ GoTo(0);
+ else if (!IbiStream->Infos[IbiStream->Infos.size()-1].IsContinuous)
+ GoTo(IbiStream->Infos[IbiStream->Infos.size()-1].StreamOffset);
+ else
+ return 2; //Invalid value
+ return 1;
+ }
+ #else //MEDIAINFO_IBI
+ return (size_t)-2; //Not supported / IBI disabled
+ #endif //MEDIAINFO_IBI
+ default : return (size_t)-1; //Not supported
+ }
+}
+
+void File__Analyze::Ibi_Stream_Finish ()
+{
+ if (IsSub || IbiStream==NULL || IbiStream->Infos.empty())
+ return;
+
+ if (File_Offset+Buffer_Size==File_Size)
+ {
+ ibi::stream::info IbiInfo;
+ IbiInfo.StreamOffset=File_Offset+Buffer_Size;
+ IbiInfo.FrameNumber=Frame_Count_NotParsedIncluded;
+ IbiInfo.Dts=(FrameInfo.DTS!=(int64u)-1)?float64_int64s(((float64)FrameInfo.DTS)/1000000000*IbiStream->DtsFrequencyDenominator/IbiStream->DtsFrequencyNumerator):(int64u)-1;
+ IbiInfo.IsContinuous=true;
+ IbiStream->Add(IbiInfo);
+ }
+
+ if (Config_Ibi_Create)
+ {
+ ibi Ibi;
+ Ibi.Streams[(int64u)-1]=new ibi::stream(*IbiStream);
+
+ //IBI Creation
+ File_Ibi_Creation IbiCreation(Ibi);
+ Ztring IbiText=IbiCreation.Finish();
+ if (!IbiText.empty())
+ Fill(Stream_General, 0, "IBI", IbiText);
+ }
+}
+
+void File__Analyze::Ibi_Stream_Finish (int64u Numerator, int64u Denominator)
+{
+ if (IsSub || IbiStream==NULL)
+ return;
+
+ if (IbiStream->DtsFrequencyNumerator==1000000000 && IbiStream->DtsFrequencyDenominator==1 && !IbiStream->Infos.empty())
+ {
+ IbiStream->DtsFrequencyNumerator=Numerator;
+ IbiStream->DtsFrequencyDenominator=Denominator;
+ for (size_t Pos=0; Pos<IbiStream->Infos.size(); Pos++)
+ if (IbiStream->Infos[Pos].Dts!=(int64u)-1)
+ IbiStream->Infos[Pos].Dts=float64_int64s(((float64)IbiStream->Infos[Pos].Dts)/1000000000/Denominator*Numerator);;
+ }
+}
+
+void File__Analyze::Ibi_Add ()
+{
+ if (IbiStream==NULL)
+ return;
+
+ ibi::stream::info IbiInfo;
+ IbiInfo.StreamOffset=IsSub?Ibi_SynchronizationOffset_Current:(File_Offset+Buffer_Offset);
+ IbiInfo.FrameNumber=Frame_Count_NotParsedIncluded;
+ IbiInfo.Dts=FrameInfo.DTS;
+ IbiStream->Add(IbiInfo);
+
+ if (Frame_Count_NotParsedIncluded==(int64u)-1)
+ Frame_Count_NotParsedIncluded=IbiStream->Infos[IbiStream->Infos_Pos-1].FrameNumber;
+}
+
+#endif //MEDIAINFO_IBI
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Analyze.h b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze.h
new file mode 100644
index 000000000..891510fc9
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze.h
@@ -0,0 +1,1484 @@
+// File__Analysze - Base for analyze files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File__AnalyzeH
+#define MediaInfo_File__AnalyzeH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+#include "MediaInfo/File__Base.h"
+#include "MediaInfo/File__Analyse_Automatic.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "ZenLib/BitStream_Fast.h"
+#include "ZenLib/BitStream_LE.h"
+#include "ZenLib/int128u.h"
+#include "ZenLib/ZtringListList.h"
+#include <vector>
+#include <bitset>
+#if MEDIAINFO_IBI
+ #include "MediaInfo/Multiple/File_Ibi_Creation.h"
+#endif //MEDIAINFO_IBI
+#include "tinyxml2.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class MediaInfo_Internal;
+
+#if !MEDIAINFO_TRACE
+ #include "MediaInfo/File__Analyze_MinimizeSize.h"
+#else
+
+//***************************************************************************
+// Class File__Base
+//***************************************************************************
+
+class File__Analyze : public File__Base
+{
+public :
+ //***************************************************************************
+ // Constructor/Destructor
+ //***************************************************************************
+
+ File__Analyze();
+ virtual ~File__Analyze();
+
+ //***************************************************************************
+ // Open
+ //***************************************************************************
+
+ void Open_Buffer_Init ( int64u File_Size);
+ void Open_Buffer_Init (File__Analyze* Sub);
+ void Open_Buffer_Init (File__Analyze* Sub, int64u File_Size);
+ void Open_Buffer_Continue ( const int8u* Buffer, size_t Buffer_Size);
+ void Open_Buffer_Continue (File__Analyze* Sub, const int8u* Buffer, size_t Buffer_Size);
+ void Open_Buffer_Continue (File__Analyze* Sub, size_t Buffer_Size) {Open_Buffer_Continue(Sub, Buffer+Buffer_Offset+(size_t)Element_Offset, Buffer_Size); Element_Offset+=Buffer_Size;}
+ void Open_Buffer_Continue (File__Analyze* Sub) {Open_Buffer_Continue(Sub, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset)); Element_Offset=Element_Size;}
+ void Open_Buffer_Position_Set(int64u File_Offset);
+ #if MEDIAINFO_SEEK
+ size_t Open_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+ void Open_Buffer_Update ();
+ void Open_Buffer_Update (File__Analyze* Sub);
+ void Open_Buffer_Unsynch ();
+ void Open_Buffer_Finalize (bool NoBufferModification=false);
+ void Open_Buffer_Finalize (File__Analyze* Sub);
+
+ //***************************************************************************
+ // In/Out (for parsers)
+ //***************************************************************************
+
+ //In
+ Ztring ParserName;
+ #if MEDIAINFO_EVENTS
+ size_t StreamIDs_Size;
+ int64u StreamIDs[16];
+ int8u StreamIDs_Width[16];
+ int8u ParserIDs[16];
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ int8u Demux_Level; //bit 0=frame, bit 1=container, bit 2=elementary (eg MPEG-TS), default with frame set
+ bool Demux_random_access;
+ bool Demux_UnpacketizeContainer;
+ bool Demux_IntermediateItemFound;
+ size_t Demux_Offset;
+ int64u Demux_TotalBytes;
+ #endif //MEDIAINFO_DEMUX
+ Ztring File_Name_WithoutDemux;
+ bool PTS_DTS_Needed;
+ struct frame_info
+ {
+ int64u Buffer_Offset;
+ int64u PCR; //In nanoseconds
+ int64u PTS; //In nanoseconds
+ int64u DTS; //In nanoseconds
+ int64u DUR; //In nanoseconds
+
+ frame_info()
+ {
+ Buffer_Offset=0;
+ PCR=(int64u)-1;
+ PTS=(int64u)-1;
+ DTS=(int64u)-1;
+ DUR=(int64u)-1;
+ }
+ };
+ frame_info FrameInfo;
+ frame_info FrameInfo_Previous;
+ frame_info FrameInfo_Next;
+
+ //Out
+ int64u PTS_Begin; //In nanoseconds
+ int64u PTS_End; //In nanoseconds
+ int64u DTS_Begin; //In nanoseconds
+ int64u DTS_End; //In nanoseconds
+ int64u Frame_Count;
+ int64u Frame_Count_Previous;
+ int64u Frame_Count_InThisBlock;
+ int64u Field_Count;
+ int64u Field_Count_Previous;
+ int64u Field_Count_InThisBlock;
+ int64u Frame_Count_NotParsedIncluded;
+ bool Synched; //Data is synched
+ bool MustExtendParsingDuration; //Data has some substreams difficult to detect (e.g. captions), must wait a bit before final filling
+
+protected :
+ //***************************************************************************
+ // Streams management
+ //***************************************************************************
+
+ virtual void Streams_Accept() {};
+ virtual void Streams_Fill() {};
+ virtual void Streams_Update() {};
+ virtual void Streams_Finish() {};
+
+ //***************************************************************************
+ // Synchro
+ //***************************************************************************
+
+ virtual bool Synchronize() {Synched=true; return true;}; //Look for the synchro
+ virtual bool Synched_Test() {return true;}; //Test is synchro is OK
+ virtual void Synched_Init() {}; //When synched, we can Init data
+ bool Synchro_Manage();
+ bool Synchro_Manage_Test();
+
+ //***************************************************************************
+ // Buffer
+ //***************************************************************************
+
+ //Buffer
+ virtual void Read_Buffer_Init () {}; //Temp, should be in File__Base caller
+ virtual void Read_Buffer_Continue () {}; //Temp, should be in File__Base caller
+ virtual void Read_Buffer_AfterParsing () {}; //Temp, should be in File__Base caller
+ #if MEDIAINFO_SEEK
+ virtual size_t Read_Buffer_Seek (size_t, int64u, int64u); //Temp, should be in File__Base caller
+ size_t Read_Buffer_Seek_OneFramePerFile (size_t, int64u, int64u);
+ #endif //MEDIAINFO_SEEK
+ virtual void Read_Buffer_Unsynched () {}; //Temp, should be in File__Base caller
+ void Read_Buffer_Unsynched_OneFramePerFile ();
+ virtual void Read_Buffer_Finalize () {}; //Temp, should be in File__Base caller
+ bool Buffer_Parse();
+
+ //***************************************************************************
+ // BitStream init
+ //***************************************************************************
+
+ void BS_Begin();
+ void BS_Begin_LE(); //Little Endian version
+ void BS_End();
+ void BS_End_LE(); //Little Endian version
+
+ //***************************************************************************
+ // File Header
+ //***************************************************************************
+
+ //File Header - Management
+ bool FileHeader_Manage ();
+
+ //File Header - Begin
+ virtual bool FileHeader_Begin () {return true;};
+
+ //File Header - Parse
+ virtual void FileHeader_Parse () {Element_DoNotShow();};
+
+ //***************************************************************************
+ // Header
+ //***************************************************************************
+
+ //Header - Management
+ bool Header_Manage ();
+
+ //Header - Begin
+ virtual bool Header_Begin () {return true;};
+
+ //Header - Parse
+ virtual void Header_Parse ();
+
+ //Header - Info
+ void Header_Fill_Code (int64u Code);
+ void Header_Fill_Code (int64u Code, const Ztring &Name);
+ void Header_Fill_Size (int64u Size);
+
+ //***************************************************************************
+ // Data
+ //***************************************************************************
+
+ //Header - Management
+ bool Data_Manage ();
+
+ //Data - Parse
+ virtual void Data_Parse () {};
+
+ //Data - Info
+ void Data_Info (const Ztring &Parameter);
+ inline void Data_Info_From_Milliseconds (int64u Parameter) {Data_Info(Ztring().Duration_From_Milliseconds(Parameter));}
+
+ //Data - Get info
+ size_t Data_Remain () {return (size_t)(Element_Size-(Element_Offset+BS->Offset_Get()));};
+ size_t Data_BS_Remain () {return (size_t)BS->Remain();};
+
+ //Data - Detect EOF
+ virtual void Detect_EOF () {};
+ bool EOF_AlreadyDetected;
+
+ //Data - Helpers
+ void Data_Accept (const char* ParserName);
+ void Data_Reject (const char* ParserName);
+ void Data_Finish (const char* ParserName);
+ void Data_GoTo (int64u GoTo, const char* ParserName);
+ void Data_GoToFromEnd (int64u GoToFromEnd, const char* ParserName);
+
+ //***************************************************************************
+ // Elements
+ //***************************************************************************
+
+ //Elements - Begin
+ void Element_Begin ();
+ void Element_Begin (const Ztring &Name);
+ inline void Element_Begin (const char *Name) {Element_Begin(Ztring().From_UTF8(Name));}
+ #define Element_Begin0() Element_Begin()
+ #define Element_Begin1(_NAME) Element_Begin(_NAME)
+ #define Element_Trace_Begin0() Element_Begin()
+ #define Element_Trace_Begin1(_NAME) Element_Begin(_NAME)
+
+ //Elements - Name
+ void Element_Name (const Ztring &Name);
+ inline void Element_Name (const char* Name) {Element_Name(Ztring().From_UTF8(Name));}
+
+ //Elements - Info
+ void Element_Info (const Ztring &Parameter);
+ inline void Element_Info (const char* Parameter) {Element_Info(Ztring().From_UTF8(Parameter));}
+ inline void Element_Info (const char* Parameter, const char* Measure) {Element_Info(Ztring().From_UTF8(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Element_Info (int8s Parameter, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Element_Info (int8u Parameter, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Element_Info (int16s Parameter, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Element_Info (int16u Parameter, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Element_Info (int32s Parameter, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Element_Info (int32u Parameter, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Element_Info (int64s Parameter, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Element_Info (int64u Parameter, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Element_Info (int128u Parameter, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ #ifdef SIZE_T_IS_LONG
+ inline void Element_Info (size_t Parameter, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ #endif //SIZE_T_IS_LONG
+ inline void Element_Info (float32 Parameter, int8u AfterComma=3, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter, AfterComma)+Ztring().From_UTF8(Measure));}
+ inline void Element_Info (float64 Parameter, int8u AfterComma=3, const char* Measure=NULL) {Element_Info(Ztring::ToZtring(Parameter, AfterComma)+Ztring().From_UTF8(Measure));}
+ #define Element_Info1(_A) Element_Info(_A)
+ #define Element_Info2(_A,_B) Element_Info(_A, _B)
+ #define Element_Info3(_A,_B,_C) Element_Info(_A, _B, _C)
+ #define Element_Info1C(_CONDITION,_A) if (_CONDITION) Element_Info(_A)
+ inline void Element_Info_From_Milliseconds (int64u Parameter) {Element_Info(Ztring().Duration_From_Milliseconds(Parameter));}
+
+ //Elements - End
+ inline void Element_End () {Element_End_Common_Flush();}
+ void Element_End (const Ztring &Name);
+ inline void Element_End (const char *Name) {Element_End(Ztring().From_UTF8(Name));}
+ #define Element_End0() Element_End()
+ #define Element_End1(_NAME) Element_End(_NAME)
+ #define Element_Trace_End0() Element_End()
+ #define Element_Trace_End1(_NAME) Element_End(_NAME)
+
+ //Elements - Preparation of element from external app
+ void Element_Prepare (int64u Size);
+
+protected :
+ //Element - Common
+ void Element_End_Common_Flush();
+ void Element_End_Common_Flush_Details();
+ Ztring Element_End_Common_Flush_Build();
+public :
+
+ //***************************************************************************
+ // Param
+ //***************************************************************************
+
+ //TODO: put this in Ztring()
+ Ztring ToZtring(const char* Value, size_t Value_Size=Unlimited, bool Utf8=true)
+ {
+ if (Utf8)
+ return Ztring().From_UTF8(Value, Value_Size);
+ else
+ return Ztring().From_Local(Value, Value_Size);
+ }
+ #define VALUE(Value) \
+ Ztring::ToZtring(Value).MakeUpperCase()+_T(" (0x")+Ztring::ToZtring(Value, 16).MakeUpperCase()+_T(")")
+
+ //Param - Main
+ void Param (const Ztring &Parameter, const Ztring& Value);
+ inline void Param (const char* Parameter, const Ztring& Value) {Param(Ztring().From_Local(Parameter), Value);};
+ inline void Param (const char* Parameter, const std::string& Value) {Param(Parameter, Ztring().From_Local(Value.c_str()));}
+ inline void Param (const char* Parameter, const char* Value, size_t Value_Size=Unlimited, bool Utf8=true) {Param(Parameter, ToZtring(Value, Value_Size, Utf8));}
+ inline void Param (const char* Parameter, const int8u* Value, size_t Value_Size=Unlimited, bool Utf8=true) {Param(Parameter, (const char*)Value, Value_Size, Utf8);}
+ inline void Param (const char* Parameter, bool Value) {if (Value) Param(Parameter, "Yes"); else Param(Parameter, "No");}
+ inline void Param (const char* Parameter, int8u Value) {Param(Parameter, Ztring::ToZtring(Value)+_T(" (0x")+Ztring().From_CC1(Value)+_T(")"));}
+ inline void Param (const char* Parameter, int8s Value) {Param(Parameter, Ztring::ToZtring(Value)+_T(" (0x")+Ztring().From_CC1(Value)+_T(")"));}
+ inline void Param (const char* Parameter, int16u Value) {Param(Parameter, Ztring::ToZtring(Value)+_T(" (0x")+Ztring().From_CC2(Value)+_T(")"));}
+ inline void Param (const char* Parameter, int16s Value) {Param(Parameter, Ztring::ToZtring(Value)+_T(" (0x")+Ztring().From_CC2(Value)+_T(")"));}
+ inline void Param (const char* Parameter, int32u Value) {Param(Parameter, Ztring::ToZtring(Value)+_T(" (0x")+Ztring::ToZtring(Value, 16)+_T(")"));}
+ inline void Param (const char* Parameter, int32s Value) {Param(Parameter, Ztring::ToZtring(Value)+_T(" (0x")+Ztring::ToZtring(Value, 16)+_T(")"));}
+ inline void Param (const char* Parameter, int64u Value) {Param(Parameter, Ztring::ToZtring(Value)+_T(" (0x")+Ztring::ToZtring(Value, 16)+_T(")"));}
+ inline void Param (const char* Parameter, int64s Value) {Param(Parameter, Ztring::ToZtring(Value)+_T(" (0x")+Ztring::ToZtring(Value, 16)+_T(")"));}
+ inline void Param (const char* Parameter, int128u Value){Param(Parameter, Ztring::ToZtring(Value)+_T(" (0x")+Ztring::ToZtring(Value, 16)+_T(")"));}
+ inline void Param_GUID (const char* Parameter, int128u Value){Param(Parameter, Ztring().From_GUID(Value));}
+ inline void Param_UUID (const char* Parameter, int128u Value){Param(Parameter, Ztring().From_UUID(Value));}
+ #ifdef SIZE_T_IS_LONG
+ inline void Param (const char* Parameter, size_t Value, intu Radix=16) {Param(Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase()+_T(" (")+Ztring::ToZtring(Value, 10).MakeUpperCase()+_T(")"));}
+ #endif //SIZE_T_IS_LONG
+ inline void Param (const char* Parameter, float32 Value, int8u AfterComma=3) {Param(Parameter, Ztring::ToZtring(Value, AfterComma));}
+ inline void Param (const char* Parameter, float64 Value, int8u AfterComma=3) {Param(Parameter, Ztring::ToZtring(Value, AfterComma));}
+ inline void Param (const char* Parameter, float80 Value, int8u AfterComma=3) {Param(Parameter, Ztring::ToZtring(Value, AfterComma));}
+ inline void Param (const int32u Parameter, const Ztring& Value) {Param(Ztring().From_CC4(Parameter), Value);};
+ inline void Param (const int16u Parameter, const Ztring& Value) {Param(Ztring().From_CC2(Parameter), Value);};
+ #define Param1(_A) Param_(_A)
+ #define Param2(_A,_B) Param(_A, _B)
+ #define Param3(_A,_B,_C) Param(_A, _B, _C)
+
+ //Param - Info
+ void Param_Info (const Ztring &Parameter);
+ inline void Param_Info (const char* Parameter) {Param_Info(Ztring().From_UTF8(Parameter));}
+ inline void Param_Info (const char* Parameter, const char* Measure) {Param_Info(Ztring().From_UTF8(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Param_Info (int64u Parameter, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Param_Info (int64s Parameter, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Param_Info (int32u Parameter, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Param_Info (int32s Parameter, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Param_Info (int16u Parameter, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Param_Info (int16s Parameter, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Param_Info (int8u Parameter, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Param_Info (int8s Parameter, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ inline void Param_Info (float32 Parameter, int8u AfterComma=3, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter, AfterComma)+Ztring().From_UTF8(Measure));}
+ inline void Param_Info (float64 Parameter, int8u AfterComma=3, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter, AfterComma)+Ztring().From_UTF8(Measure));}
+ inline void Param_Info (float80 Parameter, int8u AfterComma=3, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter, AfterComma)+Ztring().From_UTF8(Measure));}
+ #ifdef SIZE_T_IS_LONG
+ inline void Param_Info (size_t Parameter, const char* Measure=NULL) {Param_Info(Ztring::ToZtring(Parameter)+Ztring().From_UTF8(Measure));}
+ #endif //SIZE_T_IS_LONG
+ #define Param_Info1(_A) Param_Info(_A)
+ #define Param_Info2(_A,_B) Param_Info(_A, _B)
+ #define Param_Info3(_A,_B,_C) Param_Info(_A, _B, _C)
+ #define Param_Info1C(_CONDITION,_A) if (_CONDITION) Param_Info(_A)
+ #define Param_Info2C(_CONDITION,_A,_B) if (_CONDITION) Param_Info(_A, _B)
+ #define Param_Info3C(_CONDITION,_A,_B,_C) if (_CONDITION) Param_Info(_A, _B, _C)
+ inline void Param_Info_From_Milliseconds (int64u Parameter) {Param_Info(Ztring().Duration_From_Milliseconds(Parameter));}
+
+ //***************************************************************************
+ // Information
+ //***************************************************************************
+
+ void Info (const Ztring& Value, size_t Element_Level_Minus=0);
+
+ //***************************************************************************
+ // Big Endian (Integer, Float, Fixed-Point)
+ //***************************************************************************
+
+ void Get_B1 (int8u &Info, const char* Name);
+ void Get_B2 (int16u &Info, const char* Name);
+ void Get_B3 (int32u &Info, const char* Name);
+ void Get_B4 (int32u &Info, const char* Name);
+ void Get_B5 (int64u &Info, const char* Name);
+ void Get_B6 (int64u &Info, const char* Name);
+ void Get_B7 (int64u &Info, const char* Name);
+ void Get_B8 (int64u &Info, const char* Name);
+ void Get_B16 (int128u &Info, const char* Name);
+ void Get_BF4 (float32 &Info, const char* Name);
+ void Get_BF8 (float64 &Info, const char* Name);
+ void Get_BF10 (float80 &Info, const char* Name);
+ void Get_BFP4 (size_t Bits, float32 &Info, const char* Name);
+ void Peek_B1 (int8u &Info);
+ void Peek_B2 (int16u &Info);
+ void Peek_B3 (int32u &Info);
+ void Peek_B4 (int32u &Info);
+ void Peek_B5 (int64u &Info);
+ void Peek_B6 (int64u &Info);
+ void Peek_B7 (int64u &Info);
+ void Peek_B8 (int64u &Info);
+ void Peek_B16 (int128u &Info);
+ void Peek_BF4 (float32 &Info);
+ void Peek_BF8 (float64 &Info);
+ void Peek_BF10(float64 &Info);
+ void Peek_BFP4(size_t Bits, float64 &Info);
+ void Skip_B1 ( const char* Name);
+ void Skip_B2 ( const char* Name);
+ void Skip_B3 ( const char* Name);
+ void Skip_B4 ( const char* Name);
+ void Skip_B5 ( const char* Name);
+ void Skip_B6 ( const char* Name);
+ void Skip_B7 ( const char* Name);
+ void Skip_B8 ( const char* Name);
+ void Skip_B16 ( const char* Name);
+ void Skip_BF4 ( const char* Name);
+ void Skip_BF8 ( const char* Name);
+ void Skip_BF10( const char* Name);
+ void Skip_BFP4(size_t Bits, const char* Name);
+ #define Info_B1(_INFO, _NAME) int8u _INFO; Get_B1 (_INFO, _NAME)
+ #define Info_B2(_INFO, _NAME) int16u _INFO; Get_B2 (_INFO, _NAME)
+ #define Info_B3(_INFO, _NAME) int32u _INFO; Get_B3 (_INFO, _NAME)
+ #define Info_B4(_INFO, _NAME) int32u _INFO; Get_B4 (_INFO, _NAME)
+ #define Info_B5(_INFO, _NAME) int64u _INFO; Get_B5 (_INFO, _NAME)
+ #define Info_B6(_INFO, _NAME) int64u _INFO; Get_B6 (_INFO, _NAME)
+ #define Info_B7(_INFO, _NAME) int64u _INFO; Get_B7 (_INFO, _NAME)
+ #define Info_B8(_INFO, _NAME) int64u _INFO; Get_B8 (_INFO, _NAME)
+ #define Info_B16(_INFO, _NAME) int128u _INFO; Get_B16 (_INFO, _NAME)
+ #define Info_BF4(_INFO, _NAME) float32 _INFO; Get_BF4 (_INFO, _NAME)
+ #define Info_BF8(_INFO, _NAME) float64 _INFO; Get_BF8 (_INFO, _NAME)
+ #define Info_BF10(_INFO, _NAME) float80 _INFO; Get_BF10(_INFO, _NAME)
+ #define Info_BFP4(_BITS, _INFO, _NAME) float32 _INFO; Get_BFP4(_BITS, _INFO, _NAME)
+
+ //***************************************************************************
+ // Little Endian
+ //***************************************************************************
+
+ void Get_L1 (int8u &Info, const char* Name);
+ void Get_L2 (int16u &Info, const char* Name);
+ void Get_L3 (int32u &Info, const char* Name);
+ void Get_L4 (int32u &Info, const char* Name);
+ void Get_L5 (int64u &Info, const char* Name);
+ void Get_L6 (int64u &Info, const char* Name);
+ void Get_L7 (int64u &Info, const char* Name);
+ void Get_L8 (int64u &Info, const char* Name);
+ void Get_L16 (int128u &Info, const char* Name);
+ void Get_LF4 (float32 &Info, const char* Name);
+ void Get_LF8 (float64 &Info, const char* Name);
+ void Peek_L1 (int8u &Info);
+ void Peek_L2 (int16u &Info);
+ void Peek_L3 (int32u &Info);
+ void Peek_L4 (int32u &Info);
+ void Peek_L5 (int64u &Info);
+ void Peek_L6 (int64u &Info);
+ void Peek_L7 (int64u &Info);
+ void Peek_L8 (int64u &Info);
+ void Peek_L16(int128u &Info);
+ void Peek_LF4(float32 &Info);
+ void Peek_LF8(float64 &Info);
+ void Skip_L1 ( const char* Name);
+ void Skip_L2 ( const char* Name);
+ void Skip_L3 ( const char* Name);
+ void Skip_L4 ( const char* Name);
+ void Skip_L5 ( const char* Name);
+ void Skip_L6 ( const char* Name);
+ void Skip_L7 ( const char* Name);
+ void Skip_L8 ( const char* Name);
+ void Skip_LF4( const char* Name);
+ void Skip_LF8( const char* Name);
+ void Skip_L16( const char* Name);
+ #define Info_L1(_INFO, _NAME) int8u _INFO; Get_L1 (_INFO, _NAME)
+ #define Info_L2(_INFO, _NAME) int16u _INFO; Get_L2 (_INFO, _NAME)
+ #define Info_L3(_INFO, _NAME) int32u _INFO; Get_L3 (_INFO, _NAME)
+ #define Info_L4(_INFO, _NAME) int32u _INFO; Get_L4 (_INFO, _NAME)
+ #define Info_L5(_INFO, _NAME) int64u _INFO; Get_L5 (_INFO, _NAME)
+ #define Info_L6(_INFO, _NAME) int64u _INFO; Get_L6 (_INFO, _NAME)
+ #define Info_L7(_INFO, _NAME) int64u _INFO; Get_L7 (_INFO, _NAME)
+ #define Info_L8(_INFO, _NAME) int64u _INFO; Get_L8 (_INFO, _NAME)
+ #define Info_L16(_INFO, _NAME) int128u _INFO; Get_L16(_INFO, _NAME)
+ #define Info_LF4(_INFO, _NAME) float32 _INFO; Get_LF4(_INFO, _NAME)
+ #define Info_LF8(_INFO, _NAME) float64 _INFO; Get_LF8(_INFO, _NAME)
+
+ //***************************************************************************
+ // Little and Big Endian together
+ //***************************************************************************
+
+ void Get_D1 (int8u &Info, const char* Name);
+ void Get_D2 (int16u &Info, const char* Name);
+ void Get_D3 (int32u &Info, const char* Name);
+ void Get_D4 (int32u &Info, const char* Name);
+ void Get_D5 (int64u &Info, const char* Name);
+ void Get_D6 (int64u &Info, const char* Name);
+ void Get_D7 (int64u &Info, const char* Name);
+ void Get_D8 (int64u &Info, const char* Name);
+ void Get_D16 (int128u &Info, const char* Name);
+ void Get_DF4 (float32 &Info, const char* Name);
+ void Get_DF8 (float64 &Info, const char* Name);
+ void Peek_D1 (int8u &Info);
+ void Peek_D2 (int16u &Info);
+ void Peek_D3 (int32u &Info);
+ void Peek_D4 (int32u &Info);
+ void Peek_D5 (int64u &Info);
+ void Peek_D6 (int64u &Info);
+ void Peek_D7 (int64u &Info);
+ void Peek_D8 (int64u &Info);
+ void Peek_D16(int128u &Info);
+ void Peek_DF4(float32 &Info);
+ void Peek_DF8(float64 &Info);
+ void Skip_D1 ( const char* Name);
+ void Skip_D2 ( const char* Name);
+ void Skip_D3 ( const char* Name);
+ void Skip_D4 ( const char* Name);
+ void Skip_D5 ( const char* Name);
+ void Skip_D6 ( const char* Name);
+ void Skip_D7 ( const char* Name);
+ void Skip_D8 ( const char* Name);
+ void Skip_DF4( const char* Name);
+ void Skip_DF8( const char* Name);
+ void Skip_D16( const char* Name);
+ #define Info_D1(_INFO, _NAME) int8u _INFO; Get_D1 (_INFO, _NAME)
+ #define Info_D2(_INFO, _NAME) int16u _INFO; Get_D2 (_INFO, _NAME)
+ #define Info_D3(_INFO, _NAME) int32u _INFO; Get_D3 (_INFO, _NAME)
+ #define Info_D4(_INFO, _NAME) int32u _INFO; Get_D4 (_INFO, _NAME)
+ #define Info_D5(_INFO, _NAME) int64u _INFO; Get_D5 (_INFO, _NAME)
+ #define Info_D6(_INFO, _NAME) int64u _INFO; Get_D6 (_INFO, _NAME)
+ #define Info_D7(_INFO, _NAME) int64u _INFO; Get_D7 (_INFO, _NAME)
+ #define Info_D8(_INFO, _NAME) int64u _INFO; Get_D8 (_INFO, _NAME)
+ #define Info_D16(_INFO, _NAME) int128u _INFO; Get_D16(_INFO, _NAME)
+ #define Info_DF4(_INFO, _NAME) float32 _INFO; Get_DF4(_INFO, _NAME)
+ #define Info_DF8(_INFO, _NAME) float64 _INFO; Get_DF8(_INFO, _NAME)
+
+ //***************************************************************************
+ // GUID
+ //***************************************************************************
+
+ void Get_GUID (int128u &Info, const char* Name);
+ void Peek_GUID(int128u &Info);
+ void Skip_GUID( const char* Name);
+ #define Info_GUID(_INFO, _NAME) int128u _INFO; Get_GUID(_INFO, _NAME)
+
+ //***************************************************************************
+ // UUID
+ //***************************************************************************
+
+ void Get_UUID (int128u &Info, const char* Name);
+ void Peek_UUID(int128u &Info);
+ void Skip_UUID( const char* Name);
+ #define Info_UUID(_INFO, _NAME) int128u _INFO; Get_UUID(_INFO, _NAME)
+
+ //***************************************************************************
+ // EBML
+ //***************************************************************************
+
+ void Get_EB (int64u &Info, const char* Name);
+ void Get_ES (int64s &Info, const char* Name);
+ void Skip_EB( const char* Name);
+ void Skip_ES( const char* Name);
+ #define Info_EB(_INFO, _NAME) int64u _INFO; Get_EB(_INFO, _NAME)
+ #define Info_ES(_INFO, _NAME) int64s _INFO; Get_ES(_INFO, _NAME)
+
+ //***************************************************************************
+ // Variable Size Value
+ //***************************************************************************
+
+ void Get_VS (int64u &Info, const char* Name);
+ void Skip_VS( const char* Name);
+ #define Info_VS(_INFO, _NAME) int64u _INFO; Get_VS(_INFO, _NAME)
+
+ //***************************************************************************
+ // Exp-Golomb
+ //***************************************************************************
+
+ void Get_UE (int32u &Info, const char* Name);
+ void Get_SE (int32s &Info, const char* Name);
+ void Skip_UE( const char* Name);
+ void Skip_SE( const char* Name);
+ #define Info_UE(_INFO, _NAME) int32u _INFO; Get_UE(_INFO, _NAME)
+ #define Info_SE(_INFO, _NAME) int32s _INFO; Get_SE(_INFO, _NAME)
+
+ //***************************************************************************
+ // Interleaved Exp-Golomb
+ //***************************************************************************
+
+ void Get_UI (int32u &Info, const char* Name);
+ void Get_SI (int32s &Info, const char* Name);
+ void Skip_UI( const char* Name);
+ void Skip_SI( const char* Name);
+ #define Info_UI(_INFO, _NAME) int32u _INFO; Get_UI(_INFO, _NAME)
+ #define Info_SI(_INFO, _NAME) int32s _INFO; Get_SI(_INFO, _NAME)
+
+ //***************************************************************************
+ // Variable Length Code
+ //***************************************************************************
+
+ struct vlc
+ {
+ int32u value;
+ int8u bit_increment;
+ int8s mapped_to1;
+ int8s mapped_to2;
+ int8s mapped_to3;
+ };
+ struct vlc_fast
+ {
+ int8u* Array;
+ int8u* BitsToSkip;
+ const vlc* Vlc;
+ int8u Size;
+ };
+ #define VLC_END \
+ {(int32u)-1, (int8u)-1, 0, 0, 0}
+ void Get_VL_Prepare(vlc_fast &Vlc);
+ void Get_VL (const vlc Vlc[], size_t &Info, const char* Name);
+ void Get_VL (vlc_fast &Vlc, size_t &Info, const char* Name);
+ void Skip_VL(const vlc Vlc[], const char* Name);
+ void Skip_VL(vlc_fast &Vlc, const char* Name);
+ #define Info_VL(Vlc, Info, Name) size_t Info; Get_VL(Vlc, Info, Name)
+
+ //***************************************************************************
+ // Characters
+ //***************************************************************************
+
+ void Get_C1 (int8u &Info, const char* Name);
+ void Get_C2 (int16u &Info, const char* Name);
+ void Get_C3 (int32u &Info, const char* Name);
+ void Get_C4 (int32u &Info, const char* Name);
+ void Get_C5 (int64u &Info, const char* Name);
+ void Get_C6 (int64u &Info, const char* Name);
+ void Get_C7 (int64u &Info, const char* Name);
+ void Get_C8 (int64u &Info, const char* Name);
+ void Skip_C1( const char* Name);
+ void Skip_C2( const char* Name);
+ void Skip_C3( const char* Name);
+ void Skip_C4( const char* Name);
+ void Skip_C5( const char* Name);
+ void Skip_C6( const char* Name);
+ void Skip_C7( const char* Name);
+ void Skip_C8( const char* Name);
+ #define Info_C1(_INFO, _NAME) int8u _INFO; Get_C1(_INFO, _NAME)
+ #define Info_C2(_INFO, _NAME) int16u _INFO; Get_C2(_INFO, _NAME)
+ #define Info_C3(_INFO, _NAME) int32u _INFO; Get_C3(_INFO, _NAME)
+ #define Info_C4(_INFO, _NAME) int32u _INFO; Get_C4(_INFO, _NAME)
+ #define Info_C5(_INFO, _NAME) int64u _INFO; Get_C5(_INFO, _NAME)
+ #define Info_C6(_INFO, _NAME) int64u _INFO; Get_C6(_INFO, _NAME)
+ #define Info_C7(_INFO, _NAME) int64u _INFO; Get_C7(_INFO, _NAME)
+ #define Info_C8(_INFO, _NAME) int64u _INFO; Get_C8(_INFO, _NAME)
+
+ //***************************************************************************
+ // Text
+ //***************************************************************************
+
+ void Get_Local (int64u Bytes, Ztring &Info, const char* Name);
+ void Get_ISO_8859_1(int64u Bytes, Ztring &Info, const char* Name);
+ void Get_ISO_8859_2(int64u Bytes, Ztring &Info, const char* Name);
+ void Get_String (int64u Bytes, std::string &Info, const char* Name);
+ void Get_UTF8 (int64u Bytes, Ztring &Info, const char* Name);
+ void Get_UTF16 (int64u Bytes, Ztring &Info, const char* Name);
+ void Get_UTF16B (int64u Bytes, Ztring &Info, const char* Name);
+ void Get_UTF16L (int64u Bytes, Ztring &Info, const char* Name);
+ void Peek_Local (int64u Bytes, Ztring &Info);
+ void Peek_String(int64u Bytes, std::string &Info);
+ void Skip_Local (int64u Bytes, const char* Name);
+ void Skip_String(int64u Bytes, const char* Name);
+ void Skip_UTF8 (int64u Bytes, const char* Name);
+ void Skip_UTF16B(int64u Bytes, const char* Name);
+ void Skip_UTF16L(int64u Bytes, const char* Name);
+ #define Info_Local(_BYTES, _INFO, _NAME) Ztring _INFO; Get_Local (_BYTES, _INFO, _NAME)
+ #define Info_UTF8(_BYTES, _INFO, _NAME) Ztring _INFO; Get_UTF8 (_BYTES, _INFO, _NAME)
+ #define Info_UTF16B(_BYTES, _INFO, _NAME) Ztring _INFO; Get_UTF16B(_BYTES, _INFO, _NAME)
+ #define Info_UTF16L(_BYTES, _INFO, _NAME) Ztring _INFO; Get_UTF16L(_BYTES, _INFO, _NAME)
+
+ //***************************************************************************
+ // PAscal strings
+ //***************************************************************************
+
+ void Get_PA (std::string &Info, const char* Name);
+ void Peek_PA(std::string &Info);
+ void Skip_PA( const char* Name);
+ #define Info_PA(_INFO, _NAME) Ztring _INFO; Get_PA (_INFO, _NAME)
+
+ //***************************************************************************
+ // Unknown
+ //***************************************************************************
+
+ void Skip_XX(int64u Bytes, const char* Name);
+
+ //***************************************************************************
+ // Flags
+ //***************************************************************************
+
+ void Get_Flags (int64u Flags, size_t Order, bool &Info, const char* Name);
+ void Get_Flags (int64u ValueToPut, int8u &Info, const char* Name);
+ void Skip_Flags(int64u Flags, size_t Order, const char* Name);
+ void Skip_Flags(int64u ValueToPut, const char* Name);
+ #define Get_FlagsM(_VALUE, _INFO, _NAME) Get_Flags(_VALUE, _INFO, _NAME)
+ #define Skip_FlagsM(_VALUE, _NAME) Skip_Flags(_VALUE, _NAME)
+ #define Info_Flags(_FLAGS, _ORDER, _INFO, _NAME) bool _INFO; Get_Flags (_FLAGS, _ORDER, _INFO, _NAME)
+
+ //***************************************************************************
+ // BitStream
+ //***************************************************************************
+
+ void Get_BS (size_t Bits, int32u &Info, const char* Name);
+ void Get_SB ( bool &Info, const char* Name);
+ bool Get_SB( const char* Name) {bool Temp; Get_SB(Temp, Name); return Temp;}
+ void Get_S1 (size_t Bits, int8u &Info, const char* Name);
+ void Get_S2 (size_t Bits, int16u &Info, const char* Name);
+ void Get_S3 (size_t Bits, int32u &Info, const char* Name);
+ void Get_S4 (size_t Bits, int32u &Info, const char* Name);
+ void Get_S5 (size_t Bits, int64u &Info, const char* Name);
+ void Get_S6 (size_t Bits, int64u &Info, const char* Name);
+ void Get_S7 (size_t Bits, int64u &Info, const char* Name);
+ void Get_S8 (size_t Bits, int64u &Info, const char* Name);
+ void Peek_BS(size_t Bits, int32u &Info);
+ void Peek_SB( bool &Info);
+ bool Peek_SB() {bool Temp; Peek_SB(Temp); return Temp;}
+ void Peek_S1(size_t Bits, int8u &Info);
+ void Peek_S2(size_t Bits, int16u &Info);
+ void Peek_S3(size_t Bits, int32u &Info);
+ void Peek_S4(size_t Bits, int32u &Info);
+ void Peek_S5(size_t Bits, int64u &Info);
+ void Peek_S6(size_t Bits, int64u &Info);
+ void Peek_S7(size_t Bits, int64u &Info);
+ void Peek_S8(size_t Bits, int64u &Info);
+ void Skip_BS(size_t Bits, const char* Name);
+ void Skip_SB( const char* Name);
+ void Skip_S1(size_t Bits, const char* Name);
+ void Skip_S2(size_t Bits, const char* Name);
+ void Skip_S3(size_t Bits, const char* Name);
+ void Skip_S4(size_t Bits, const char* Name);
+ void Skip_S5(size_t Bits, const char* Name);
+ void Skip_S6(size_t Bits, const char* Name);
+ void Skip_S7(size_t Bits, const char* Name);
+ void Skip_S8(size_t Bits, const char* Name);
+ void Mark_0 ();
+ void Mark_0_NoTrustError (); //Use it for providing a warning instead of a non-trusting error
+ void Mark_1 ();
+ void Mark_1_NoTrustError (); //Use it for providing a warning instead of a non-trusting error
+ #define Info_BS(_BITS, _INFO, _NAME) int32u _INFO; Get_BS(_BITS, _INFO, _NAME)
+ #define Info_SB(_INFO, _NAME) bool _INFO; Get_SB( _INFO, _NAME)
+ #define Info_S1(_BITS, _INFO, _NAME) int8u _INFO; Get_S1(_BITS, _INFO, _NAME)
+ #define Info_S2(_BITS, _INFO, _NAME) int16u _INFO; Get_S2(_BITS, _INFO, _NAME)
+ #define Info_S3(_BITS, _INFO, _NAME) int32u _INFO; Get_S4(_BITS, _INFO, _NAME)
+ #define Info_S4(_BITS, _INFO, _NAME) int32u _INFO; Get_S4(_BITS, _INFO, _NAME)
+ #define Info_S5(_BITS, _INFO, _NAME) int64u _INFO; Get_S5(_BITS, _INFO, _NAME)
+ #define Info_S6(_BITS, _INFO, _NAME) int64u _INFO; Get_S6(_BITS, _INFO, _NAME)
+ #define Info_S7(_BITS, _INFO, _NAME) int64u _INFO; Get_S7(_BITS, _INFO, _NAME)
+ #define Info_S8(_BITS, _INFO, _NAME) int64u _INFO; Get_S8(_BITS, _INFO, _NAME)
+
+ #define TEST_SB_GET(_CODE, _NAME) \
+ { \
+ Peek_SB(_CODE); \
+ if (!_CODE) \
+ Skip_SB( _NAME); \
+ else \
+ { \
+ Element_Begin1(_NAME); \
+ Skip_SB( _NAME); \
+
+ #define TEST_SB_SKIP(_NAME) \
+ { \
+ if (!Peek_SB()) \
+ Skip_SB( _NAME); \
+ else \
+ { \
+ Element_Begin1(_NAME); \
+ Skip_SB( _NAME); \
+
+ #define TESTELSE_SB_GET(_CODE, _NAME) \
+ { \
+ Peek_SB(_CODE); \
+ if (_CODE) \
+ { \
+ Element_Begin1(_NAME); \
+ Skip_SB( _NAME); \
+
+ #define TESTELSE_SB_SKIP(_NAME) \
+ { \
+ if (Peek_SB()) \
+ { \
+ Element_Begin1(_NAME); \
+ Skip_SB( _NAME); \
+
+ #define TESTELSE_SB_ELSE(_NAME) \
+ Element_End0(); \
+ } \
+ else \
+ { \
+ Skip_SB( _NAME); \
+
+ #define TESTELSE_SB_END() \
+ } \
+ } \
+
+ #define TEST_SB_END() \
+ Element_End0(); \
+ } \
+ } \
+
+ //***************************************************************************
+ // BitStream (Little Endian)
+ //***************************************************************************
+
+ void Get_BT (size_t Bits, int32u &Info, const char* Name);
+ void Get_TB ( bool &Info, const char* Name);
+ bool Get_TB( const char* Name) {bool Temp; Get_TB(Temp, Name); return Temp;}
+ void Get_T1 (size_t Bits, int8u &Info, const char* Name);
+ void Get_T2 (size_t Bits, int16u &Info, const char* Name);
+ void Get_T3 (size_t Bits, int32u &Info, const char* Name);
+ void Get_T4 (size_t Bits, int32u &Info, const char* Name);
+ void Get_T5 (size_t Bits, int64u &Info, const char* Name);
+ void Get_T6 (size_t Bits, int64u &Info, const char* Name);
+ void Get_T7 (size_t Bits, int64u &Info, const char* Name);
+ void Get_T8 (size_t Bits, int64u &Info, const char* Name);
+ void Peek_BT(size_t Bits, int32u &Info);
+ void Peek_TB( bool &Info);
+ bool Peek_TB() {bool Temp; Peek_TB(Temp); return Temp;}
+ void Peek_T1(size_t Bits, int8u &Info);
+ void Peek_T2(size_t Bits, int16u &Info);
+ void Peek_T3(size_t Bits, int32u &Info);
+ void Peek_T4(size_t Bits, int32u &Info);
+ void Peek_T5(size_t Bits, int64u &Info);
+ void Peek_T6(size_t Bits, int64u &Info);
+ void Peek_T7(size_t Bits, int64u &Info);
+ void Peek_T8(size_t Bits, int64u &Info);
+ void Skip_BT(size_t Bits, const char* Name);
+ void Skip_TB( const char* Name);
+ void Skip_T1(size_t Bits, const char* Name);
+ void Skip_T2(size_t Bits, const char* Name);
+ void Skip_T3(size_t Bits, const char* Name);
+ void Skip_T4(size_t Bits, const char* Name);
+ void Skip_T5(size_t Bits, const char* Name);
+ void Skip_T6(size_t Bits, const char* Name);
+ void Skip_T7(size_t Bits, const char* Name);
+ void Skip_T8(size_t Bits, const char* Name);
+ #define Info_BT(_BITS, _INFO, _NAME) int32u _INFO; Get_BT(_BITS, _INFO, _NAME)
+ #define Info_TB(_INFO, _NAME) bool _INFO; Get_TB( _INFO, _NAME)
+ #define Info_T1(_BITS, _INFO, _NAME) int8u _INFO; Get_T1(_BITS, _INFO, _NAME)
+ #define Info_T2(_BITS, _INFO, _NAME) int16u _INFO; Get_T2(_BITS, _INFO, _NAME)
+ #define Info_T3(_BITS, _INFO, _NAME) int32u _INFO; Get_T4(_BITS, _INFO, _NAME)
+ #define Info_T4(_BITS, _INFO, _NAME) int32u _INFO; Get_T4(_BITS, _INFO, _NAME)
+ #define Info_T5(_BITS, _INFO, _NAME) int64u _INFO; Get_T5(_BITS, _INFO, _NAME)
+ #define Info_T6(_BITS, _INFO, _NAME) int64u _INFO; Get_T6(_BITS, _INFO, _NAME)
+ #define Info_T7(_BITS, _INFO, _NAME) int64u _INFO; Get_T7(_BITS, _INFO, _NAME)
+ #define Info_T8(_BITS, _INFO, _NAME) int64u _INFO; Get_T8(_BITS, _INFO, _NAME)
+
+ #define TEST_TB_GET(_CODE, _NAME) \
+ { \
+ Peek_TB(_CODE); \
+ if (!_CODE) \
+ Skip_TB( _NAME); \
+ else \
+ { \
+ Element_Begin1(_NAME); \
+ Skip_TB( _NAME); \
+
+ #define TEST_TB_SKIP(_NAME) \
+ { \
+ if (!Peek_TB()) \
+ Skip_TB( _NAME); \
+ else \
+ { \
+ Element_Begin1(_NAME); \
+ Skip_TB( _NAME); \
+
+ #define TESTELSE_TB_GET(_CODE, _NAME) \
+ { \
+ Peek_TB(_CODE); \
+ if (_CODE) \
+ { \
+ Element_Begin1(_NAME); \
+ Skip_TB( _NAME); \
+
+ #define TESTELSE_TB_SKIP(_NAME) \
+ { \
+ if (Peek_TB()) \
+ { \
+ Element_Begin1(_NAME); \
+ Skip_TB( _NAME); \
+
+ #define TESTELSE_TB_ELSE(_NAME) \
+ Element_End0(); \
+ } \
+ else \
+ { \
+ Skip_TB( _NAME); \
+
+ #define TESTELSE_TB_END() \
+ } \
+ } \
+
+ #define TEST_TB_END() \
+ Element_End0(); \
+ } \
+ } \
+
+ //***************************************************************************
+ // Next code planning
+ //***************************************************************************
+
+ void NextCode_Add(int64u Code);
+ void NextCode_Clear();
+ bool NextCode_Test();
+
+ //***************************************************************************
+ // Element trusting
+ //***************************************************************************
+
+ void Trusted_IsNot (const char* Reason);
+
+ //***************************************************************************
+ // Stream filling
+ //***************************************************************************
+
+ //Elements - Preparation of element from external app
+ size_t Stream_Prepare (stream_t KindOfStream, size_t StreamPos=(size_t)-1);
+ size_t Stream_Erase (stream_t KindOfStream, size_t StreamPos);
+
+ //Fill with datas (with parameter as a size_t)
+ void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, const Ztring &Value, bool Replace=false);
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, const std::string &Value, bool Utf8=true, bool Replace=false) {if (Utf8) Fill(StreamKind, StreamPos, Parameter, Ztring().From_UTF8(Value.c_str(), Value.size()), Replace); else Fill(StreamKind, StreamPos, Parameter, Ztring().From_Local(Value.c_str(), Value.size()), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, const char* Value, size_t Value_Size=Unlimited, bool Utf8=true, bool Replace=false) {if (Utf8) Fill(StreamKind, StreamPos, Parameter, Ztring().From_UTF8(Value, Value_Size), Replace); else Fill(StreamKind, StreamPos, Parameter, Ztring().From_Local(Value, Value_Size), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, const wchar_t* Value, size_t Value_Size=Unlimited, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring().From_Unicode(Value, Value_Size), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int8u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int8s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int16u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int16s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int32u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int32s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int64u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int64s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, float32 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, float64 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, float80 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ #ifdef SIZE_T_IS_LONG
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, size_t Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ #endif //SIZE_T_IS_LONG
+ //Fill with datas
+ void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, const Ztring &Value, bool Replace=false);
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, const std::string &Value, bool Utf8=true, bool Replace=false) {if (Utf8) Fill(StreamKind, StreamPos, Parameter, Ztring().From_UTF8(Value.c_str(), Value.size())); else Fill(StreamKind, StreamPos, Parameter, Ztring().From_Local(Value.c_str(), Value.size()), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, const char* Value, size_t Value_Size=Unlimited, bool Utf8=true, bool Replace=false) {if (Utf8) Fill(StreamKind, StreamPos, Parameter, Ztring().From_UTF8(Value, Value_Size), Replace); else Fill(StreamKind, StreamPos, Parameter, Ztring().From_Local(Value, Value_Size), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, const wchar_t* Value, size_t Value_Size=Unlimited, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring().From_Unicode(Value, Value_Size), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int8u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int8s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int16u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int16s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int32u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int32s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int64u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int64s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, float32 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, float64 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, float80 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ #ifdef SIZE_T_IS_LONG
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, size_t Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ #endif //SIZE_T_IS_LONG
+ ZtringListList Fill_Temp;
+ void Fill_Flush ();
+ size_t Fill_Parameter(stream_t StreamKind, generic StreamPos);
+
+ const Ztring &Retrieve_Const (stream_t StreamKind, size_t StreamPos, size_t Parameter, info_t KindOfInfo=Info_Text);
+ Ztring Retrieve (stream_t StreamKind, size_t StreamPos, size_t Parameter, info_t KindOfInfo=Info_Text);
+ const Ztring &Retrieve_Const (stream_t StreamKind, size_t StreamPos, const char* Parameter, info_t KindOfInfo=Info_Text);
+ Ztring Retrieve (stream_t StreamKind, size_t StreamPos, const char* Parameter, info_t KindOfInfo=Info_Text);
+
+ void Clear (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void Clear (stream_t StreamKind, size_t StreamPos, const char* Parameter);
+ void Clear (stream_t StreamKind, size_t StreamPos);
+ void Clear (stream_t StreamKind);
+ inline void Clear () {File__Base::Clear();}
+
+ //***************************************************************************
+ // Filling
+ //***************************************************************************
+
+ //Actions
+ void Accept (const char* ParserName=NULL);
+ void Accept (File__Analyze* Parser);
+ void Reject (const char* ParserName=NULL);
+ void Reject (File__Analyze* Parser);
+ void Update (const char* ParserName=NULL);
+ void Update (File__Analyze* Parser);
+ void Fill (const char* ParserName=NULL);
+ void Fill (File__Analyze* Parser);
+ void Finish (const char* ParserName=NULL);
+ void Finish (File__Analyze* Parser);
+ void ForceFinish (const char* ParserName=NULL);
+ void ForceFinish (File__Analyze* Parser);
+ void GoTo (int64u GoTo, const char* ParserName=NULL);
+ void GoToFromEnd (int64u GoToFromEnd, const char* ParserName=NULL);
+ int64u Element_Code_Get (size_t Level);
+ int64u Element_TotalSize_Get (size_t LevelLess=0);
+ bool Element_IsComplete_Get ();
+ void Element_ThisIsAList ();
+ void Element_WaitForMoreData ();
+ void Element_DoNotTrust (const char* Reason);
+ void Element_DoNotShow ();
+ void Element_Show ();
+ bool Element_Show_Get ();
+ void Element_Show_Add (const Ztring &ToShow);
+
+ //Status
+ bool Element_IsOK ();
+ bool Element_IsNotFinished ();
+ bool Element_IsWaitingForMoreData ();
+
+ //Begin
+ #define FILLING_BEGIN() \
+ if (Element_IsOK()) \
+ {
+
+ #define FILLING_BEGIN_PRECISE() \
+ if (Element_Offset!=Element_Size) \
+ Trusted_IsNot("Size error"); \
+ else if (Element_IsOK()) \
+ {
+
+ //Else
+ #define FILLING_ELSE() \
+ } \
+ else \
+ { \
+
+ //End
+ #define FILLING_END() \
+ }
+
+ //***************************************************************************
+ // Merging
+ //***************************************************************************
+
+ //Utils
+public :
+ size_t Merge(MediaInfo_Internal &ToAdd, bool Erase=true); //Merge 2 File_Base
+ size_t Merge(MediaInfo_Internal &ToAdd, stream_t StreamKind, size_t StreamPos_From, size_t StreamPos_To, bool Erase=true); //Merge 2 streams
+ size_t Merge(File__Analyze &ToAdd, bool Erase=true); //Merge 2 File_Base
+ size_t Merge(File__Analyze &ToAdd, stream_t StreamKind, size_t StreamPos_From, size_t StreamPos_To, bool Erase=true); //Merge 2 streams
+
+ //***************************************************************************
+ // Finalize
+ //***************************************************************************
+
+ //End
+ void Streams_Finish_Global();
+
+protected :
+ void Streams_Finish_StreamOnly();
+ void Streams_Finish_StreamOnly(stream_t StreamKid, size_t StreamPos);
+ void Streams_Finish_StreamOnly_General(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Video(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Audio(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Text(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Chapters(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Image(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Menu(size_t StreamPos);
+ void Streams_Finish_InterStreams();
+ void Streams_Finish_Cosmetic();
+ void Streams_Finish_Cosmetic(stream_t StreamKid, size_t StreamPos);
+ void Streams_Finish_Cosmetic_General(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Video(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Audio(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Text(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Chapters(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Image(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Menu(size_t StreamPos);
+
+ void Tags ();
+ void Video_FrameRate_Rounding (size_t Pos, video Parameter);
+ void Video_BitRate_Rounding (size_t Pos, video Parameter);
+ void Audio_BitRate_Rounding (size_t Pos, audio Parameter);
+
+ //Utils - Finalize
+ void Duration_Duration123 (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void FileSize_FileSize123 (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void Kilo_Kilo123 (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void Value_Value123 (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void YesNo_YesNo (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void CodecID_Fill (const Ztring &Value, stream_t StreamKind, size_t StreamPos, infocodecid_format_t Format);
+
+ //***************************************************************************
+ //
+ //***************************************************************************
+
+protected :
+ //Save for speed improvement
+ float Config_Trace_Level;
+ std::bitset<32> Config_Trace_Layers;
+ MediaInfo_Config::trace_Format Config_Trace_Format;
+ float Config_ParseSpeed;
+ int8u Config_Demux;
+ Ztring Config_LineSeparator;
+ bool IsSub;
+ bool IsRawStream;
+
+ //Configuration
+ bool DataMustAlwaysBeComplete; //Data must always be complete, else wait for more data
+ bool MustUseAlternativeParser; //Must use the second parser (example: for Data part)
+
+ //Synchro
+ bool MustParseTheHeaderFile; //There is an header part, must parse it
+ size_t Trusted;
+ size_t Trusted_Multiplier;
+
+ //Elements
+ size_t Element_Level; //Current level
+ bool Element_WantNextLevel; //Want to go to the next leavel instead of the same level
+
+ //Element
+ int64u Element_Code; //Code filled in the file, copy of Element[Element_Level].Code
+ int64u Element_Offset; //Position in the Element (without header)
+ int64u Element_Size; //Size of the Element (without header)
+
+private :
+ //***************************************************************************
+ // Buffer
+ //***************************************************************************
+
+ void Buffer_Clear(); //Clear the buffer
+ bool Open_Buffer_Continue_Loop();
+protected :
+ //Buffer
+ const int8u* Buffer;
+public : //TO CHANGE
+ size_t Buffer_Size;
+ int64u Buffer_TotalBytes;
+ int64u Buffer_TotalBytes_FirstSynched;
+ int64u Buffer_PaddingBytes;
+ float64 Stream_BitRateFromContainer;
+protected :
+ int8u* Buffer_Temp;
+ size_t Buffer_Temp_Size;
+ size_t Buffer_Temp_Size_Max;
+ size_t Buffer_Offset; //Temporary usage in this parser
+ size_t Buffer_Offset_Temp; //Temporary usage in this parser
+ size_t Buffer_MinimumSize;
+ size_t Buffer_MaximumSize;
+ int64u Buffer_TotalBytes_FirstSynched_Max;
+ int64u Buffer_TotalBytes_Fill_Max;
+ friend class File__Tags_Helper;
+
+ //***************************************************************************
+ // Helpers
+ //***************************************************************************
+
+ bool FileHeader_Begin_0x000001();
+ bool FileHeader_Begin_XML(tinyxml2::XMLDocument &Document);
+ bool Synchronize_0x000001();
+public:
+ static void Streams_Accept_TestContinuousFileNames_Static(ZtringList &File_Names, bool IsReferenced);
+protected:
+ void Streams_Accept_TestContinuousFileNames();
+
+private :
+
+ //***************************************************************************
+ // Elements
+ //***************************************************************************
+
+ //Data
+ size_t Data_Level; //Current level for Data ("Top level")
+
+ //Element
+ BitStream_Fast* BS; //For conversion from bytes to bitstream
+ BitStream* BT; //For conversion from bytes to bitstream
+public : //TO CHANGE
+ int64u Header_Size; //Size of the header of the current element
+ const Ztring &Details_Get() {return Element[0].ToShow.Details;} //Direct access to details
+ void Details_Clear();
+protected :
+ bool Trace_DoNotSave;
+ bool Trace_Activated;
+ std::bitset<32> Trace_Layers;
+ void Trace_Layers_Update (size_t Layer=(size_t)-1);
+private :
+
+ //Elements
+ size_t Element_Level_Base; //From other parsers
+
+ struct element_details
+ {
+ struct to_show
+ {
+ int64u Pos; //Position of the element in the file
+ int64u Size; //Size of the element (including header and sub-elements)
+ int64u Header_Size; //Size of the header of the element
+ Ztring Name; //Name planned for this element
+ Ztring Info; //More info about the element
+ Ztring Details; //The main text
+ bool NoShow; //Don't show this element
+ };
+
+ int64u Code; //Code filled in the file
+ int64u Next; //
+ bool WaitForMoreData; //This element is not complete, we need more data
+ bool UnTrusted; //This element has a problem
+ bool IsComplete; //This element is fully buffered, no need of more
+ to_show ToShow;
+ };
+ std::vector<element_details> Element;
+
+ //NextCode
+ std::map<int64u, bool> NextCode;
+
+ //BookMarks
+ size_t BookMark_Element_Level;
+ int64u BookMark_GoTo;
+ std::vector<int64u> BookMark_Code;
+ std::vector<int64u> BookMark_Next;
+
+public :
+ void BookMark_Set(size_t Element_Level_ToGet=(size_t)-1);
+ void BookMark_Get();
+ virtual bool BookMark_Needed() {return false;};
+
+ //Temp
+ std::bitset<32> Status;
+ enum status
+ {
+ IsAccepted,
+ IsFilled,
+ IsUpdated,
+ IsFinished,
+ Reserved_04,
+ Reserved_05,
+ Reserved_06,
+ Reserved_07,
+ Reserved_08,
+ Reserved_09,
+ Reserved_10,
+ Reserved_11,
+ Reserved_12,
+ Reserved_13,
+ Reserved_14,
+ Reserved_15,
+ User_16,
+ User_17,
+ User_18,
+ User_19,
+ User_20,
+ User_21,
+ User_22,
+ User_23,
+ User_24,
+ User_25,
+ User_26,
+ User_27,
+ User_28,
+ User_29,
+ User_30,
+ User_31,
+ };
+ bool ShouldContinueParsing;
+
+ //Configuration
+ bool MustSynchronize;
+
+ //Demux
+ enum contenttype
+ {
+ ContentType_MainStream,
+ ContentType_SubStream,
+ ContentType_Header,
+ ContentType_Synchro
+ };
+ #if MEDIAINFO_DEMUX
+ void Demux (const int8u* Buffer, size_t Buffer_Size, contenttype ContentType);
+ virtual bool Demux_UnpacketizeContainer_Test() {return true;}
+ bool Demux_UnpacketizeContainer_Test_OneFramePerFile();
+ void Demux_UnpacketizeContainer_Demux(bool random_access=true);
+ void Demux_UnpacketizeContainer_Demux_Clear();
+ bool Demux_EventWasSent_Accept_Specific;
+ #else //MEDIAINFO_DEMUX
+ #define Demux(_A, _B, _C)
+ #endif //MEDIAINFO_DEMUX
+
+ //Events data
+ bool PES_FirstByte_IsAvailable;
+ bool PES_FirstByte_Value;
+
+ int64u Unsynch_Frame_Count;
+
+ #if MEDIAINFO_SEEK
+ private:
+ bool Seek_Duration_Detected;
+ #endif //MEDIAINFO_SEEK
+
+ #if MEDIAINFO_IBI
+ public:
+ bool Config_Ibi_Create;
+ int64u Ibi_SynchronizationOffset_Current;
+ int64u Ibi_SynchronizationOffset_BeginOfFrame;
+ ibi::stream* IbiStream;
+ size_t Ibi_Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ void Ibi_Read_Buffer_Unsynched ();
+ void Ibi_Stream_Finish ();
+ void Ibi_Stream_Finish (int64u Numerator, int64u Denominator); //Partial
+ void Ibi_Add ();
+ #else //MEDIAINFO_IBI
+ size_t Ibi_Read_Buffer_Seek (size_t, int64u, int64u) {return (size_t)-1;}
+ void Ibi_Read_Buffer_Unsynched () {}
+ void Ibi_Stream_Finish () {}
+ void Ibi_Stream_Finish (int64u, int64u) {}
+ void Ibi_Add () {}
+ #endif //MEDIAINFO_IBI
+};
+
+//Helpers
+#define DETAILS_INFO(_DATA) _DATA
+
+#endif //MEDIAINFO_TRACE
+
+} //NameSpace
+
+
+
+/*
+#define BS_END() \
+ { \
+ BS.Byte_Align(); \
+ int32u BS_Value=0x00; \
+ while(BS.Remain()>0 && BS_Value==0x00) \
+ BS_Value=BS.Get(8); \
+ if (BS_Value!=0x00) \
+ INTEGRITY_SIZE(BS.Offset_Get()-1, BS.Offset_Get()) \
+ else \
+ INTEGRITY_SIZE(BS.Offset_Get(), BS.Offset_Get()) \
+ } \
+
+#define BS_END_FF() \
+ { \
+ BS.Byte_Align(); \
+ int32u BS_Value=0xFF; \
+ while(BS.Remain()>0 && BS_Value==0x00) \
+ BS_Value=BS.Get(8); \
+ if (BS_Value!=0xFF) \
+ INTEGRITY_SIZE(BS.Offset_Get()-1, BS.Offset_Get()) \
+ else \
+ INTEGRITY_SIZE(BS.Offset_Get(), BS.Offset_Get()) \
+ } \
+
+#define BS_END_CANBEMORE() \
+ { \
+ } \
+*/
+
+#define ATOM_BEGIN \
+ if (Level!=Element_Level) \
+ { \
+ Level++; \
+ switch (Element_Code_Get(Level)) \
+ { \
+
+#define ATOM(_ATOM) \
+ case Elements::_ATOM : \
+ if (Level==Element_Level) \
+ { \
+ if (Element_IsComplete_Get()) \
+ _ATOM(); \
+ else \
+ { \
+ Element_WaitForMoreData(); \
+ return; \
+ } \
+ } \
+ break; \
+
+#define ATOM_PARTIAL(_ATOM) \
+ case Elements::_ATOM : \
+ if (Level==Element_Level) \
+ _ATOM(); \
+ break; \
+
+#define ATOM_DEFAULT(_ATOM) \
+ default : \
+ if (Level==Element_Level) \
+ { \
+ if (Element_IsComplete_Get()) \
+ _ATOM(); \
+ else \
+ { \
+ Element_WaitForMoreData(); \
+ return; \
+ } \
+ } \
+ break; \
+
+#define ATOM_END \
+ default : \
+ Skip_XX(Element_TotalSize_Get(), "Unknown"); \
+ } \
+ } \
+ break; \
+
+#define LIST(_ATOM) \
+ case Elements::_ATOM : \
+ if (Level==Element_Level) \
+ { \
+ Element_ThisIsAList(); \
+ _ATOM(); \
+ } \
+
+#define LIST_DEFAULT(_ATOM) \
+ default : \
+ if (Level==Element_Level) \
+ { \
+ Element_ThisIsAList(); \
+ _ATOM(); \
+ } \
+
+#define ATOM_END_DEFAULT \
+ } \
+ } \
+ break; \
+
+#define ATOM_DEFAULT_ALONE(_ATOM) \
+ if (Level!=Element_Level) \
+ { \
+ Level++; \
+ if (Level==Element_Level) \
+ { \
+ if (Element_IsComplete_Get()) \
+ _ATOM(); \
+ else \
+ { \
+ Element_WaitForMoreData(); \
+ return; \
+ } \
+ } \
+ } \
+ break; \
+
+#define LIST_DEFAULT_ALONE_BEGIN(_ATOM) \
+ if (Level!=Element_Level) \
+ { \
+ Level++; \
+ if (Level==Element_Level) \
+ { \
+ Element_ThisIsAList(); \
+ _ATOM(); \
+ } \
+
+#define LIST_DEFAULT_ALONE_END \
+ } \
+ break; \
+
+#define LIST_SKIP(_ATOM) \
+ case Elements::_ATOM : \
+ if (Level==Element_Level) \
+ { \
+ Element_ThisIsAList(); \
+ _ATOM(); \
+ } \
+ break; \
+
+
+#define DATA_BEGIN \
+ size_t Level=0; \
+ ATOM_BEGIN \
+
+#define DATA_END \
+ default : ; \
+ Skip_XX(Element_TotalSize_Get(), "Unknown"); \
+ }} \
+ \
+
+#define DATA_DEFAULT \
+ default : \
+
+#define DATA_END_DEFAULT \
+ } \
+ } \
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Buffer.cpp b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Buffer.cpp
new file mode 100644
index 000000000..5376877c4
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Buffer.cpp
@@ -0,0 +1,2464 @@
+// File__Analyze - Base for analyze files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+#if MEDIAINFO_TRACE
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "ZenLib/BitStream_LE.h"
+#include <cmath>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//Integrity test
+#define INTEGRITY(TOVALIDATE, ERRORTEXT, OFFSET) \
+ if (!(TOVALIDATE)) \
+ { \
+ Trusted_IsNot(ERRORTEXT); \
+ return; \
+ } \
+
+#define INTEGRITY_INT(TOVALIDATE, ERRORTEXT, OFFSET) \
+ if (!(TOVALIDATE)) \
+ { \
+ Trusted_IsNot(ERRORTEXT); \
+ Info=0; \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE_ATLEAST(_BYTES) \
+ if (Element_Offset+_BYTES>Element_Size) \
+ { \
+ Trusted_IsNot("Size is wrong"); \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE_ATLEAST_STRING(_BYTES) \
+ if (Element_Offset+_BYTES>Element_Size) \
+ { \
+ Trusted_IsNot("Size is wrong"); \
+ Info.clear(); \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE_ATLEAST_INT(_BYTES) \
+ if (Element_Offset+_BYTES>Element_Size) \
+ { \
+ Trusted_IsNot("Size is wrong"); \
+ Info=0; \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE_ATLEAST_BUFFER() \
+ if (BS->Remain()==0) \
+ { \
+ Trusted_IsNot("Size is wrong"); \
+ Info=0; \
+ return; \
+ } \
+
+//***************************************************************************
+// Init
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::BS_Begin()
+{
+ if (Element_Offset>Element_Size)
+ Element_Offset=Element_Size;
+ size_t BS_Size;
+ if (Buffer_Offset+Element_Size<=Buffer_Size)
+ BS_Size=(size_t)(Element_Size-Element_Offset);
+ else
+ BS_Size=Buffer_Size-(Buffer_Offset+(size_t)Element_Offset);
+ BS->Attach(Buffer+Buffer_Offset+(size_t)Element_Offset, BS_Size);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::BS_Begin_LE()
+{
+ if (Element_Offset>Element_Size)
+ Element_Offset=Element_Size;
+ size_t BS_Size;
+ if (Buffer_Offset+Element_Size<=Buffer_Size)
+ BS_Size=(size_t)(Element_Size-Element_Offset);
+ else
+ BS_Size=Buffer_Size-(Buffer_Offset+(size_t)Element_Offset);
+ BT->Attach(Buffer+Buffer_Offset+(size_t)Element_Offset, BS_Size);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::BS_End()
+{
+ BS->Byte_Align();
+ Element_Offset+=BS->Offset_Get();
+ BS->Attach(NULL, 0);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::BS_End_LE()
+{
+ BT->Byte_Align();
+ Element_Offset+=BT->Offset_Get();
+ BT->Attach(NULL, 0);
+}
+
+//***************************************************************************
+// Big Endian
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B1(int8u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ Info=BigEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=1;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B2(int16u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=BigEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B3(int32u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(3);
+ Info=BigEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated)
+ {
+ Ztring Pos1; Pos1.From_Number(Info, 16);
+ Ztring Temp;
+ Temp.resize(6-Pos1.size(), _T('0'));
+ Temp.append(Pos1);
+ Temp.MakeUpperCase();
+ Param(Name, Ztring::ToZtring(Info)+_T(" (0x")+Temp+_T(")"));
+ }
+ Element_Offset+=3;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B4(int32u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated)
+ {
+ Ztring Pos1; Pos1.From_Number(Info, 16);
+ Ztring Temp;
+ Temp.resize(8-Pos1.size(), _T('0'));
+ Temp.append(Pos1);
+ Temp.MakeUpperCase();
+ Param(Name, Ztring::ToZtring(Info)+_T(" (0x")+Temp+_T(")"));
+ }
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B5(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(5);
+ Info=BigEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=5;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B6(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=BigEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B7(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(7);
+ Info=BigEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=7;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B8(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B16(int128u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ //Info=BigEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.hi=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.lo=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset+8);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BF4(float32 &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=BigEndian2float32(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BF8(float64 &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=BigEndian2float64(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BF10(float80 &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(10);
+ Info=BigEndian2float80(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=10;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BFP4(size_t Bits, float32 &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ BS_Begin();
+ int32s Integer=(int32s)BS->Get4(Bits);
+ int32u Fraction=BS->Get4(32-Bits);
+ BS_End();
+ Element_Offset-=4; //Because of BS_End()
+ if (Integer>=(1<<Bits)/2)
+ Integer-=1<<Bits;
+ Info=Integer+((float32)Fraction)/(1<<(32-Bits));
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B1(int8u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ Info=BigEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B2(int16u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=BigEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B3(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(3);
+ Info=BigEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B4(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B5(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(5);
+ Info=BigEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B6(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=BigEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B7(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(7);
+ Info=BigEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B8(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B16(int128u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info=BigEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_B1(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(1);
+ if (Trace_Activated) Param(Name, BigEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=1;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_B2(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(2);
+ if (Trace_Activated) Param(Name, BigEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_B3(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(3);
+ if (Trace_Activated)
+ {
+ int32u Info=BigEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Ztring Pos1; Pos1.From_Number(Info, 16);
+ Ztring Temp;
+ Temp.resize(6-Pos1.size(), _T('0'));
+ Temp.append(Pos1);
+ Temp.MakeUpperCase();
+ Param(Name, Ztring::ToZtring(Info)+_T(" (0x")+Temp+_T(")"));
+ }
+ Element_Offset+=3;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_B4(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(4);
+ if (Trace_Activated)
+ {
+ int32u Info=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Ztring Pos1; Pos1.From_Number(Info, 16);
+ Ztring Temp;
+ Temp.resize(8-Pos1.size(), _T('0'));
+ Temp.append(Pos1);
+ Temp.MakeUpperCase();
+ Param(Name, Ztring::ToZtring(Info)+_T(" (0x")+Temp+_T(")"));
+ }
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_B5(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(5);
+ if (Trace_Activated) Param(Name, BigEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=5;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_B6(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(6);
+ if (Trace_Activated) Param(Name, BigEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_B7(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(7);
+ if (Trace_Activated) Param(Name, BigEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=7;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_B8(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(8);
+ if (Trace_Activated) Param(Name, BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_B16(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(16);
+ if (Trace_Activated) Param(Name, BigEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_BF4(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(4);
+ if (Trace_Activated) Param(Name, BigEndian2float32(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_BFP4(size_t Bits, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(4);
+ BS_Begin();
+ int32u Integer=BS->Get4(Bits);
+ int32u Fraction=BS->Get4(32-Bits);
+ BS_End();
+ Element_Offset-=4; //Because of BS_End()
+ if (Trace_Activated) Param(Name, Integer+((float32)Fraction)/(1<<(32-Bits)));
+ Element_Offset+=4;
+}
+
+//***************************************************************************
+// Little Endian
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L1(int8u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ Info=LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=1;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L2(int16u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L3(int32u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(3);
+ Info=LittleEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=3;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L4(int32u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L5(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(5);
+ Info=LittleEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=5;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L6(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=LittleEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L7(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(7);
+ Info=LittleEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=7;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L8(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L16(int128u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ //Info=LittleEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.hi=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.lo=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset+8);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_LF4(float32 &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=LittleEndian2float32(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_LF8(float64 &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2float64(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L1(int8u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ Info=LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L2(int16u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L3(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(3);
+ Info=LittleEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L4(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L5(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(5);
+ Info=LittleEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L6(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=LittleEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L7(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(7);
+ Info=LittleEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L8(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_L1(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(1);
+ if (Trace_Activated) Param(Name, LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=1;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_L2(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(2);
+ if (Trace_Activated) Param(Name, LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_L3(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(3);
+ if (Trace_Activated)
+ {
+ int32u Info=LittleEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Ztring Pos1; Pos1.From_Number(Info, 16);
+ Ztring Temp;
+ Temp.resize(6-Pos1.size(), _T('0'));
+ Temp.append(Pos1);
+ Temp.MakeUpperCase();
+ Param(Name, Ztring::ToZtring(Info)+_T(" (0x")+Temp+_T(")"));
+ }
+ Element_Offset+=3;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_L4(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(4);
+ if (Trace_Activated)
+ {
+ int32u Info=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Ztring Pos1; Pos1.From_Number(Info, 16);
+ Ztring Temp;
+ Temp.resize(8-Pos1.size(), _T('0'));
+ Temp.append(Pos1);
+ Temp.MakeUpperCase();
+ Param(Name, Ztring::ToZtring(Info)+_T(" (0x")+Temp+_T(")"));
+ }
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_L5(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(5);
+ if (Trace_Activated) Param(Name, LittleEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=5;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_L6(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(6);
+ if (Trace_Activated) Param(Name, LittleEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_L7(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(7);
+ if (Trace_Activated) Param(Name, LittleEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=7;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_L8(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(8);
+ if (Trace_Activated) Param(Name, LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_L16(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(16);
+ if (Trace_Activated) Param(Name, LittleEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=16;
+}
+
+//***************************************************************************
+// Little and Big Endian together
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D1(int8u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D2(int16u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D3(int32u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=LittleEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D4(int32u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D5(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(10);
+ Info=LittleEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=10;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D6(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(12);
+ Info=LittleEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=12;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D7(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(14);
+ Info=LittleEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=14;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D8(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D16(int128u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(32);
+ //Info=LittleEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.hi=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.lo=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset+8);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=32;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_DF4(float32 &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2float32(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_DF8(float64 &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info=LittleEndian2float64(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D1(int8u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D2(int16u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D3(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=LittleEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D4(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D5(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(10);
+ Info=LittleEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D6(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(12);
+ Info=LittleEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D7(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(14);
+ Info=LittleEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D8(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_D1(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(2);
+ if (Trace_Activated) Param(Name, LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_D2(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(4);
+ if (Trace_Activated) Param(Name, LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_D3(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(6);
+ if (Trace_Activated)
+ {
+ int32u Info=LittleEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Ztring Pos1; Pos1.From_Number(Info, 16);
+ Ztring Temp;
+ Temp.resize(6-Pos1.size(), _T('0'));
+ Temp.append(Pos1);
+ Temp.MakeUpperCase();
+ Param(Name, Ztring::ToZtring(Info)+_T(" (0x")+Temp+_T(")"));
+ }
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_D4(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(8);
+ if (Trace_Activated)
+ {
+ int32u Info=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Ztring Pos1; Pos1.From_Number(Info, 16);
+ Ztring Temp;
+ Temp.resize(8-Pos1.size(), _T('0'));
+ Temp.append(Pos1);
+ Temp.MakeUpperCase();
+ Param(Name, Ztring::ToZtring(Info)+_T(" (0x")+Temp+_T(")"));
+ }
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_D5(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(10);
+ if (Trace_Activated) Param(Name, LittleEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=5;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_D6(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(12);
+ if (Trace_Activated) Param(Name, LittleEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=12;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_D7(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(14);
+ if (Trace_Activated) Param(Name, LittleEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=14;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_D8(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(16);
+ if (Trace_Activated) Param(Name, LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_D16(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(32);
+ if (Trace_Activated) Param(Name, LittleEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=32;
+}
+
+//***************************************************************************
+// GUID
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_GUID(int128u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info.hi=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.lo=BigEndian2int64u (Buffer+Buffer_Offset+(size_t)Element_Offset+8);
+ if (Trace_Activated) Param_GUID(Name, Info);
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_GUID(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(16);
+ if (Trace_Activated) Param_GUID(Name, BigEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=16;
+}
+
+//***************************************************************************
+// UUID
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UUID(int128u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info.hi=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.lo=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset+8);
+ if (Trace_Activated) Param_UUID(Name, Info);
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_UUID(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(16);
+ if (Trace_Activated) Param_UUID(Name, BigEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset));
+ Element_Offset+=16;
+}
+
+//***************************************************************************
+// EBML
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_EB(int64u &Info, const char* Name)
+{
+ //Element size
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ if (Buffer[Buffer_Offset+(size_t)Element_Offset]==0xFF)
+ {
+ Info=File_Size-(File_Offset+Buffer_Offset+Element_Offset);
+ if (Trace_Activated) Param(Name, "Unlimited");
+ Element_Offset++;
+ return;
+ }
+ int32u Size=0;
+ int32u Size_Mark=0;
+ BS_Begin();
+ while (Size_Mark==0 && BS->Remain() && Size<=8)
+ {
+ Size++;
+ Peek_BS(Size, Size_Mark);
+ }
+
+ //Integrity
+ if (!BS->Remain() || Size>8)
+ {
+ if (Size>8)
+ {
+ //Element[Element_Level].IsComplete=true; //If it is in a header
+ Trusted_IsNot("EBML integer parsing error");
+ }
+ Info=0;
+ return;
+ }
+ BS_End();
+ if (File_Offset+Buffer_Offset+Element_Offset>=Element[Element_Level].Next)
+ {
+ //Element[Element_Level].IsComplete=true; //If it is in a header
+ Trusted_IsNot("Not enough place to have an EBML");
+ Info=0;
+ return; //Not enough space
+ }
+ INTEGRITY_SIZE_ATLEAST_INT(Size);
+
+ //Element Name
+ switch (Size)
+ {
+ case 1 : {
+ int8u Element_Name;
+ Peek_B1 (Element_Name);
+ Info=Element_Name&0x7F; //Keep out first bit
+ }
+ break;
+ case 2 : {
+ int16u Element_Name;
+ Peek_B2(Element_Name);
+ Info=Element_Name&0x3FFF; //Keep out first bits
+ }
+ break;
+ case 3 : {
+ int32u Element_Name;
+ Peek_B3(Element_Name);
+ Info=Element_Name&0x1FFFFF; //Keep out first bits
+ }
+ break;
+ case 4 : {
+ int32u Element_Name;
+ Peek_B4(Element_Name);
+ Info=Element_Name&0x0FFFFFFF; //Keep out first bits
+ }
+ break;
+ case 5 : {
+ int64u Element_Name;
+ Peek_B5(Element_Name);
+ Info=Element_Name&0x07FFFFFFFFLL; //Keep out first bits
+ }
+ break;
+ case 6 : {
+ int64u Element_Name;
+ Peek_B6(Element_Name);
+ Info=Element_Name&0x03FFFFFFFFFFLL; //Keep out first bits
+ }
+ break;
+ case 7 : {
+ int64u Element_Name;
+ Peek_B7(Element_Name);
+ Info=Element_Name&0x01FFFFFFFFFFFFLL; //Keep out first bits
+ }
+ break;
+ case 8 : {
+ int64u Element_Name;
+ Peek_B8(Element_Name);
+ Info=Element_Name&0x00FFFFFFFFFFFFFFLL; //Keep out first bits
+ }
+ break;
+ }
+
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=Size;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_ES(int64s &Info, const char* Name)
+{
+ //Element size
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ int32u Size=0;
+ int32u Size_Mark=0;
+ BS_Begin();
+ while (Size_Mark==0 && BS->Remain() && Size<=8)
+ {
+ Size++;
+ Peek_BS(Size, Size_Mark);
+ }
+
+ //Integrity
+ if (!BS->Remain() || Size>8)
+ {
+ if (Size>8)
+ {
+ //Element[Element_Level].IsComplete=true; //If it is in a header
+ Trusted_IsNot("EBML integer parsing error");
+ }
+ Info=0;
+ return;
+ }
+ BS_End();
+ if (File_Offset+Buffer_Offset+Element_Offset>=Element[Element_Level].Next)
+ {
+ //Element[Element_Level].IsComplete=true; //If it is in a header
+ Trusted_IsNot("Not enough place to have an EBML");
+ Info=0;
+ return; //Not enough space
+ }
+ INTEGRITY_SIZE_ATLEAST_INT(Size);
+
+ //Element Name
+ switch (Size)
+ {
+ case 1 : {
+ int8u Element_Name;
+ Peek_B1 (Element_Name);
+ Info=(Element_Name&0x7F)-0x3F; //Keep out first bit and sign
+ }
+ break;
+ case 2 : {
+ int16u Element_Name;
+ Peek_B2(Element_Name);
+ Info=(Element_Name&0x3FFF)-0x1FFF; //Keep out first bits and sign
+ }
+ break;
+ case 3 : {
+ int32u Element_Name;
+ Peek_B3(Element_Name);
+ Info=(Element_Name&0x1FFFFF)-0x0FFFFF; //Keep out first bits and sign
+ }
+ break;
+ case 4 : {
+ int32u Element_Name;
+ Peek_B4(Element_Name);
+ Info=(Element_Name&0x0FFFFFFF)-0x07FFFFFF; //Keep out first bits and sign
+ }
+ break;
+ case 5 : {
+ int64u Element_Name;
+ Peek_B5(Element_Name);
+ Info=(Element_Name&0x07FFFFFFFFLL)-0x03FFFFFFFFLL; //Keep out first bits and sign
+ }
+ break;
+ case 6 : {
+ int64u Element_Name;
+ Peek_B6(Element_Name);
+ Info=(Element_Name&0x03FFFFFFFFFFLL)-0x01FFFFFFFFFFLL; //Keep out first bits and sign
+ }
+ break;
+ case 7 : {
+ int64u Element_Name;
+ Peek_B7(Element_Name);
+ Info=(Element_Name&0x01FFFFFFFFFFFFLL)-0x00FFFFFFFFFFFFLL; //Keep out first bits and sign
+ }
+ break;
+ case 8 : {
+ int64u Element_Name;
+ Peek_B8(Element_Name);
+ Info=(Element_Name&0x00FFFFFFFFFFFFFFLL)-0x007FFFFFFFFFFFFFLL; //Keep out first bits and sign
+ }
+ break;
+ }
+
+ if (Trace_Activated) Param(Name, Info);
+ Element_Offset+=Size;
+}
+
+//***************************************************************************
+// Variable Size Value
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_VS(int64u &Info, const char* Name)
+{
+ //Element size
+ Info=0;
+ int8u Size=0;
+ bool more_data;
+ BS_Begin();
+ do
+ {
+ Size++;
+ INTEGRITY_INT(8<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ more_data=BS->GetB();
+ Info=128*Info+BS->Get1(7);
+ }
+ while (more_data && Size<=8 && BS->Remain());
+ BS_End();
+
+ //Integrity
+ if (Size>8)
+ {
+ Trusted_IsNot("Variable Size Value parsing error");
+ Info=0;
+ return;
+ }
+ if (File_Offset+Buffer_Offset+Element_Offset>=Element[Element_Level].Next)
+ {
+ Trusted_IsNot("Not enough place to have a Variable Size Value");
+ Info=0;
+ return; //Not enough space
+ }
+
+ if (Trace_Activated)
+ {
+ Element_Offset-=Size;
+ Param(Name, Info);
+ Element_Offset+=Size;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_VS(const char* Name)
+{
+ //Element size
+ int64u Info=0;
+ int8u Size=0;
+ bool more_data;
+ BS_Begin();
+ do
+ {
+ Size++;
+ INTEGRITY_INT(8<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ more_data=BS->GetB();
+ Info=128*Info+BS->Get1(7);
+ }
+ while (more_data && Size<=8 && BS->Remain());
+ BS_End();
+
+ //Integrity
+ if (Size>8)
+ {
+ Trusted_IsNot("Variable Size Value parsing error");
+ Info=0;
+ return;
+ }
+ if (File_Offset+Buffer_Offset+Element_Offset>=Element[Element_Level].Next)
+ {
+ Trusted_IsNot("Not enough place to have a Variable Size Value");
+ Info=0;
+ return; //Not enough space
+ }
+
+ if (Trace_Activated)
+ {
+ Element_Offset-=Size;
+ Param(Name, Info);
+ Element_Offset+=Size;
+ }
+}
+
+//***************************************************************************
+// Exp-Golomb
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_SE(int32s &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_BUFFER();
+ int8u LeadingZeroBits=0;
+ while(BS->Remain()>0 && !BS->GetB())
+ LeadingZeroBits++;
+ INTEGRITY(LeadingZeroBits<=32, "(Problem)", 0)
+ double InfoD=pow((float)2, (float)LeadingZeroBits)-1+BS->Get4(LeadingZeroBits);
+ INTEGRITY(InfoD<int32u(-1), "(Problem)", 0)
+ Info=(int32s)(pow((double)-1, InfoD+1)*(int32u)ceil(InfoD/2));
+
+ if (Trace_Activated)
+ Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_SE(const char* Name)
+{
+ INTEGRITY(BS->Remain(), "Size is wrong", 0)
+ int8u LeadingZeroBits=0;
+ while(BS->Remain()>0 && !BS->GetB())
+ LeadingZeroBits++;
+ if (Trace_Activated)
+ {
+ INTEGRITY(LeadingZeroBits<=32, "(Problem)", 0)
+ double InfoD=pow((float)2, (float)LeadingZeroBits)-1+BS->Get4(LeadingZeroBits);
+ INTEGRITY(InfoD<int32u(-1), "(Problem)", 0)
+ Param(Name, (int32s)(pow(-1, InfoD+1)*(int32u)ceil(InfoD/2)));
+ }
+ else
+ BS->Skip(LeadingZeroBits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UE(int32u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_BUFFER();
+ int8u LeadingZeroBits=0;
+ while(BS->Remain()>0 && !BS->GetB())
+ LeadingZeroBits++;
+ INTEGRITY(LeadingZeroBits<=32, "(Problem)", 0)
+ double InfoD=pow(2, (float)LeadingZeroBits);
+ Info=(int32u)InfoD-1+BS->Get4(LeadingZeroBits);
+
+ if (Trace_Activated)
+ Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_UE(const char* Name)
+{
+ INTEGRITY(BS->Remain(), "Size is wrong", 0)
+ int8u LeadingZeroBits=0;
+ while(BS->Remain()>0 && !BS->GetB())
+ LeadingZeroBits++;
+ if (Trace_Activated)
+ {
+ INTEGRITY(LeadingZeroBits<=32, "(Problem)", 0)
+ double InfoD=pow(2, (float)LeadingZeroBits);
+ Param(Name, (int32u)InfoD-1+BS->Get4(LeadingZeroBits));
+ }
+ else
+ BS->Skip(LeadingZeroBits);
+}
+
+//***************************************************************************
+// Inverted Exp-Golomb
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_SI(int32s &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_BUFFER();
+
+ Info=1;
+ while(BS->Remain()>0 && BS->GetB()==0)
+ {
+ Info<<=1;
+ if (BS->Remain()==0)
+ {
+ Trusted_IsNot("(Problem)");
+ Info=0;
+ return;
+ }
+ if(BS->GetB()==1)
+ Info++;
+ }
+ Info--;
+
+ if (Info!=0 && BS->Remain()>0 && BS->GetB()==1)
+ Info=-Info;
+
+ if (Trace_Activated)
+ Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_SI(const char* Name)
+{
+ int32s Info;
+ Get_SI(Info, Name);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UI(int32u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_BUFFER();
+ Info=1;
+ while(BS->Remain()>0 && BS->GetB()==0)
+ {
+ Info<<=1;
+ if (BS->Remain()==0)
+ {
+ Trusted_IsNot("(Problem)");
+ Info=0;
+ return;
+ }
+ if(BS->GetB()==1)
+ Info++;
+ }
+ Info--;
+
+ if (Trace_Activated)
+ Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_UI(const char* Name)
+{
+ int32u Info;
+ Get_UI(Info, Name);
+}
+
+//***************************************************************************
+// Variable Length Code
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_VL(const vlc Vlc[], size_t &Info, const char* Name)
+{
+ Info=0;
+ int32u Value=0;
+
+ int8u CountOfBits=0;
+ for(;;)
+ {
+ switch (Vlc[Info].bit_increment)
+ {
+ case 255 :
+ Trusted_IsNot("Variable Length Code error");
+ return;
+ default : ;
+ Value<<=Vlc[Info].bit_increment;
+ Value|=BS->Get1(Vlc[Info].bit_increment);
+ CountOfBits+=Vlc[Info].bit_increment;
+ break;
+ case 1 :
+ Value<<=1;
+ if (BS->GetB())
+ Value++;
+ CountOfBits++;
+ case 0 : ;
+ }
+
+ if (Value==Vlc[Info].value)
+ {
+ if (Trace_Activated)
+ {
+ Ztring ToDisplay=Ztring::ToZtring(Value, 2);
+ ToDisplay.insert(0, CountOfBits-ToDisplay.size(), _T('0'));
+ ToDisplay+=_T(" (")+Ztring::ToZtring(CountOfBits)+_T(" bits)");
+ Param(Name, ToDisplay);
+ }
+ return;
+ }
+ Info++;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_VL_Prepare(vlc_fast &Vlc)
+{
+ Vlc.Array=new int8u[((size_t)1)<<Vlc.Size];
+ Vlc.BitsToSkip=new int8u[((size_t)1)<<Vlc.Size];
+ memset(Vlc.Array, 0xFF, ((size_t)1)<<Vlc.Size);
+ int8u Increment=0;
+ int8u Pos=0;
+ for(; ; Pos++)
+ {
+ if (Vlc.Vlc[Pos].bit_increment==255)
+ break;
+ Increment+=Vlc.Vlc[Pos].bit_increment;
+ size_t Value=Vlc.Vlc[Pos].value<<(Vlc.Size-Increment);
+ size_t ToFill_Size=1<<(Vlc.Size-Increment);
+ for (size_t ToFill_Pos=0; ToFill_Pos<ToFill_Size; ToFill_Pos++)
+ {
+ Vlc.Array[Value+ToFill_Pos]=Pos;
+ Vlc.BitsToSkip[Value+ToFill_Pos]=Increment;
+ }
+ }
+ for (size_t Pos2=0; Pos2<(((size_t)1)<<Vlc.Size); Pos2++)
+ if (Vlc.Array[Pos2]==(int8u)-1)
+ {
+ Vlc.Array[Pos2]=Pos;
+ Vlc.BitsToSkip[Pos2]=(int8u)-1;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_VL(vlc_fast &Vlc, size_t &Info, const char* Name)
+{
+ if (BS->Remain()<Vlc.Size)
+ {
+ Get_VL(Vlc.Vlc, Info, Name);
+ return;
+ }
+
+ int32u Value=BS->Peek4(Vlc.Size);
+ Info=Vlc.Array[Value];
+
+ if (Vlc.BitsToSkip[Value]==(int8u)-1)
+ {
+ Trusted_IsNot("Variable Length Code error");
+ return;
+ }
+
+ if (Trace_Activated)
+ {
+ Ztring ToDisplay=Ztring::ToZtring(Value, 2);
+ ToDisplay.insert(0, Vlc.Size-ToDisplay.size(), _T('0'));
+ ToDisplay.resize(Vlc.BitsToSkip[Value]);
+ ToDisplay+=_T(" (")+Ztring::ToZtring(Vlc.BitsToSkip[Value])+_T(" bits)");
+ Param(Name, ToDisplay);
+ }
+
+ BS->Skip(Vlc.BitsToSkip[Value]);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_VL(const vlc Vlc[], const char* Name)
+{
+ size_t Info;
+ Get_VL(Vlc, Info, Name);
+}
+
+//***************************************************************************
+// Characters
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C1(int8u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ Info=CC1(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 1);
+ Element_Offset+=1;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C2(int16u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=CC2(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 2);
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C3(int32u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(3);
+ Info=CC3(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 3);
+ Element_Offset+=3;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C4(int32u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=CC4(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 4, false);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C5(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(5);
+ Info=CC5(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 5);
+ Element_Offset+=5;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C6(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=CC6(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 6);
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C7(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(7);
+ Info=CC7(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 7);
+ Element_Offset+=7;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C8(int64u &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=CC8(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 8);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_C1(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(1);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 1);
+ Element_Offset+=1;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_C2(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(2);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 2);
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_C3(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(3);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 3);
+ Element_Offset+=3;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_C4(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(4);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 4);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_C5(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(5);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 5);
+ Element_Offset+=5;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_C6(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(6);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 6);
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_C7(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(7);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 7);
+ Element_Offset+=7;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_C8(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(8);
+ if (Trace_Activated) Param(Name, Buffer+Buffer_Offset+(size_t)Element_Offset, 8);
+ Element_Offset+=8;
+}
+
+//***************************************************************************
+// Text
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_Local(int64u Bytes, Ztring &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_Local((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Info);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_ISO_8859_1(int64u Bytes, Ztring &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_ISO_8859_1((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Info);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_ISO_8859_2(int64u Bytes, Ztring &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_ISO_8859_2((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Info);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_String(int64u Bytes, std::string &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.assign((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Info);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_Local(int64u Bytes, Ztring &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_Local((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_String(int64u Bytes, std::string &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.assign((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UTF8(int64u Bytes, Ztring &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_UTF8((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Info);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UTF16(int64u Bytes, Ztring &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_UTF16((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Info);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UTF16B(int64u Bytes, Ztring &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_UTF16BE((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Info);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UTF16L(int64u Bytes, Ztring &Info, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_UTF16LE((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Info);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_Local(int64u Bytes, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Ztring().From_Local((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes));
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_String(int64u Bytes, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Ztring().From_Local((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes));
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_UTF8(int64u Bytes, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Ztring().From_UTF8((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes));
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_UTF16B(int64u Bytes, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Ztring().From_UTF16BE((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes));
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_UTF16L(int64u Bytes, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Ztring().From_UTF16LE((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes));
+ Element_Offset+=Bytes;
+}
+
+//***************************************************************************
+// Text
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_PA(const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(1);
+ int8u Size=Buffer[Buffer_Offset+(size_t)Element_Offset];
+ int8u Pad=(Size%2)?0:1;
+ INTEGRITY_SIZE_ATLEAST(1+Size+Pad);
+ if (Trace_Activated && Size) Param(Name, Ztring().From_Local((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset+1), (size_t)Size));
+ Element_Offset+=1+Size+Pad;
+}
+
+//***************************************************************************
+// Unknown
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_XX(int64u Bytes, const char* Name)
+{
+ INTEGRITY_SIZE_ATLEAST(Bytes);
+ if (Trace_Activated && Bytes) Param(Name, Ztring("(")+Ztring::ToZtring(Bytes)+Ztring(" bytes)"));
+ Element_Offset+=Bytes;
+}
+
+//***************************************************************************
+// Flags
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_Flags (int64u Flags, size_t Order, bool &Info, const char* Name)
+{
+ if (Flags&((int64u)1<<Order))
+ Info=true;
+ else
+ Info=false;
+
+ Element_Begin0();
+ if (Trace_Activated) Param(Name, Info?"Yes":"No");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_Flags (int64u ValueToPut, int8u &Info, const char* Name)
+{
+ Info=(int8u)ValueToPut;
+
+ Element_Begin0();
+ if (Trace_Activated) Param(Name, Info);
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_Flags(int64u Flags, size_t Order, const char* Name)
+{
+ Element_Begin0();
+ if (Trace_Activated) Param(Name, (Flags&((int64u)1<<Order))?"Yes":"No");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_Flags(int64u ValueToPut, const char* Name)
+{
+ Element_Begin0();
+ if (Trace_Activated) Param(Name, ValueToPut);
+ Element_End0();
+}
+
+//***************************************************************************
+// BitStream
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BS(size_t Bits, int32u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Get4(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_SB( bool &Info, const char* Name)
+{
+ INTEGRITY_INT(1<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->GetB();
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S1(size_t Bits, int8u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Get1(Bits);
+ if (Trace_Activated)
+ {
+ Param(Name, Info);
+ Param_Info(_T("(")+Ztring::ToZtring(Bits)+_T(" bits)"));
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S2(size_t Bits, int16u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Get2(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S3(size_t Bits, int32u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Get4(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S4(size_t Bits, int32u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Get4(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S5(size_t Bits, int64u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Get8(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S6(size_t Bits, int64u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Get8(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S7(size_t Bits, int64u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Get8(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S8(size_t Bits, int64u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Get8(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_BS(size_t Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Peek4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_SB( bool &Info)
+{
+ INTEGRITY_INT(1<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->PeekB();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S1(size_t Bits, int8u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Peek1(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S2(size_t Bits, int16u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Peek2(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S3(size_t Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Peek4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S4(size_t Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Peek4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S5(size_t Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S6(size_t Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S7(size_t Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S8(size_t Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ Info=BS->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_BS(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ if (Trace_Activated)
+ {
+ if (Bits<=32) //TODO: in BitStream.h, handle >32 bit gets
+ Param(Name, BS->Get4(Bits));
+ else
+ {
+ Param(Name, "(Data)");
+ BS->Skip(Bits);
+ }
+ }
+ else
+ BS->Skip(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_SB( const char* Name)
+{
+ INTEGRITY(1<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BS->GetB());
+ else
+ BS->Skip(1);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_S1(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ if (Trace_Activated)
+ {
+ Param(Name, BS->Get1(Bits));
+ Param_Info(_T("(")+Ztring::ToZtring(Bits)+_T(" bits)"));
+ }
+ else
+ BS->Skip(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_S2(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BS->Get2(Bits));
+ else
+ BS->Skip(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_S3(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BS->Get4(Bits));
+ else
+ BS->Skip(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_S4(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BS->Get4(Bits));
+ else
+ BS->Skip(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_S5(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BS->Get8(Bits));
+ else
+ BS->Skip(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_S6(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BS->Get8(Bits));
+ else
+ BS->Skip(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_S7(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BS->Get8(Bits));
+ else
+ BS->Skip(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_S8(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BS->Get8(Bits));
+ else
+ BS->Skip(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Mark_0()
+{
+ INTEGRITY(1<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ bool Info=BS->GetB();
+ if (Info)
+ {
+ Param("0", Info);
+ Element_DoNotTrust("Mark bit is wrong");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Mark_0_NoTrustError()
+{
+ INTEGRITY(1<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ bool Info=BS->GetB();
+ if (Info)
+ {
+ Param("0", Info);
+ Param_Info("Warning: should be 0");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Mark_1()
+{
+ INTEGRITY(1<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ bool Info=BS->GetB();
+ if (!Info)
+ {
+ Param("1", Info);
+ Element_DoNotTrust("Mark bit is wrong");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Mark_1_NoTrustError()
+{
+ INTEGRITY(1<=BS->Remain(), "Size is wrong", BS->Offset_Get())
+ bool Info=BS->GetB();
+ if (!Info)
+ {
+ Param("1", Info);
+ Param_Info("Warning: should be 1");
+ }
+}
+
+//***************************************************************************
+// BitStream (Little Endian)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BT(size_t Bits, int32u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Get(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_TB( bool &Info, const char* Name)
+{
+ INTEGRITY_INT(1<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->GetB();
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T1(size_t Bits, int8u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Get1(Bits);
+ if (Trace_Activated)
+ {
+ Param(Name, Info);
+ Param_Info(_T("(")+Ztring::ToZtring(Bits)+_T(" bits)"));
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T2(size_t Bits, int16u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Get2(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T3(size_t Bits, int32u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Get4(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T4(size_t Bits, int32u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Get4(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T5(size_t Bits, int64u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Get8(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T6(size_t Bits, int64u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Get8(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T7(size_t Bits, int64u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Get8(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T8(size_t Bits, int64u &Info, const char* Name)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Get8(Bits);
+ if (Trace_Activated) Param(Name, Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_BT(size_t Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Peek(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_TB( bool &Info)
+{
+ INTEGRITY_INT(1<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->PeekB();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T1(size_t Bits, int8u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Peek1(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T2(size_t Bits, int16u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Peek2(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T3(size_t Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Peek4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T4(size_t Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Peek4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T5(size_t Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T6(size_t Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T7(size_t Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T8(size_t Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ Info=BT->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_BT(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ if (Trace_Activated)
+ {
+ if (Bits<=32) //TODO: in BitStream.h, handle >32 bit gets
+ Param(Name, BT->Get(Bits));
+ else
+ {
+ Param(Name, "(Data)");
+ BT->Skip(Bits);
+ }
+ }
+ else
+ BT->Skip(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_TB( const char* Name)
+{
+ INTEGRITY(1<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BT->GetB());
+ else
+ BT->SkipB();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_T1(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ if (Trace_Activated)
+ {
+ Param(Name, BT->Get1(Bits));
+ Param_Info(_T("(")+Ztring::ToZtring(Bits)+_T(" bits)"));
+ }
+ else
+ BT->Skip1(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_T2(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BT->Get2(Bits));
+ else
+ BT->Skip2(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_T3(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BT->Get4(Bits));
+ else
+ BT->Skip4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_T4(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BT->Get4(Bits));
+ else
+ BT->Skip4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_T5(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BT->Get8(Bits));
+ else
+ BT->Skip8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_T6(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BT->Get8(Bits));
+ else
+ BT->Skip8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_T7(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BT->Get8(Bits));
+ else
+ BT->Skip8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_T8(size_t Bits, const char* Name)
+{
+ INTEGRITY(Bits<=BT->Remain(), "Size is wrong", BT->Offset_Get())
+ if (Trace_Activated)
+ Param(Name, BT->Get8(Bits));
+ else
+ BT->Skip8(Bits);
+}
+
+} //NameSpace
+#endif //MEDIAINFO_TRACE
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Buffer_MinimizeSize.cpp b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Buffer_MinimizeSize.cpp
new file mode 100644
index 000000000..e9ac9e0b1
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Buffer_MinimizeSize.cpp
@@ -0,0 +1,1655 @@
+// File__Analyze - Base for analyze files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+#if !MEDIAINFO_TRACE
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "ZenLib/BitStream_LE.h"
+#include <cmath>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//Integrity test
+#define INTEGRITY(TOVALIDATE) \
+ if (!(TOVALIDATE)) \
+ { \
+ Trusted_IsNot(); \
+ return; \
+ } \
+
+#define INTEGRITY_BOOL(TOVALIDATE) \
+ if (!(TOVALIDATE)) \
+ { \
+ Trusted_IsNot(); \
+ Info=false; \
+ return; \
+ } \
+
+#define INTEGRITY_INT(TOVALIDATE) \
+ if (!(TOVALIDATE)) \
+ { \
+ Trusted_IsNot(); \
+ Info=0; \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE_ATLEAST(_BYTES) \
+ if (Element_Offset+_BYTES>Element_Size) \
+ { \
+ Trusted_IsNot(); \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE_ATLEAST_STRING(_BYTES) \
+ if (Element_Offset+_BYTES>Element_Size) \
+ { \
+ Trusted_IsNot(); \
+ Info.clear(); \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE_ATLEAST_INT(_BYTES) \
+ if (Element_Offset+_BYTES>Element_Size) \
+ { \
+ Trusted_IsNot(); \
+ Info=0; \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE_ATLEAST_BUFFER() \
+ if (BS->Remain()==0) \
+ { \
+ Trusted_IsNot(); \
+ Info=0; \
+ return; \
+ } \
+
+//***************************************************************************
+// Init
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::BS_Begin()
+{
+ if (Element_Offset>Element_Size)
+ return; //There is a problem
+
+ size_t BS_Size;
+ if (Buffer_Offset+Element_Size<=Buffer_Size)
+ BS_Size=(size_t)(Element_Size-Element_Offset);
+ else
+ BS_Size=Buffer_Size-(size_t)(Buffer_Offset+Element_Offset);
+ BS->Attach(Buffer+Buffer_Offset+(size_t)Element_Offset, BS_Size);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::BS_Begin_LE()
+{
+ if (Element_Offset>Element_Size)
+ return; //There is a problem
+
+ size_t BS_Size;
+ if (Buffer_Offset+Element_Size<=Buffer_Size)
+ BS_Size=(size_t)(Element_Size-Element_Offset);
+ else
+ BS_Size=Buffer_Size-(size_t)(Buffer_Offset+Element_Offset);
+ BT->Attach(Buffer+Buffer_Offset+(size_t)Element_Offset, BS_Size);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::BS_End()
+{
+ BS->Byte_Align();
+ Element_Offset+=BS->Offset_Get();
+ BS->Attach(NULL, 0);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::BS_End_LE()
+{
+ BT->Byte_Align();
+ Element_Offset+=BT->Offset_Get();
+ BT->Attach(NULL, 0);
+}
+
+//***************************************************************************
+// Big Endian
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B1_(int8u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ Info=BigEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=1;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B2_(int16u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=BigEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B3_(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(3);
+ Info=BigEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=3;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B4_(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B5_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(5);
+ Info=BigEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=5;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B6_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=BigEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B7_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(7);
+ Info=BigEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=7;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B8_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_B16_(int128u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ //Info=BigEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.hi=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.lo=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset+8);
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BF4_(float32 &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=BigEndian2float32(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BF8_(float64 &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=BigEndian2float64(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BF10_(float80 &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(10);
+ Info=BigEndian2float80(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=10;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BFP4_(int8u Bits, float32 &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ BS_Begin();
+ int32s Integer=(int32s)BS->Get4(Bits);
+ int32u Fraction=BS->Get4(32-Bits);
+ BS_End();
+ if (Integer>=(1<<Bits)/2)
+ Integer-=1<<Bits;
+ Info=Integer+((float32)Fraction)/(1<<(32-Bits));
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B1(int8u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ Info=BigEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B2(int16u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=BigEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B3(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(3);
+ Info=BigEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B4(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B5(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(5);
+ Info=BigEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B6(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=BigEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B7(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(7);
+ Info=BigEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B8(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_B16(int128u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info=BigEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//***************************************************************************
+// Little Endian
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L1_(int8u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ Info=LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=1;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L2_(int16u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L3_(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(3);
+ Info=LittleEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=3;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L4_(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L5_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(5);
+ Info=LittleEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=5;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L6_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=LittleEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L7_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(7);
+ Info=LittleEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=7;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L8_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_L16_(int128u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ //Info=LittleEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.lo=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.hi=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset+8);
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_LF4_(float32 &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=LittleEndian2float32(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_LF8_(float64 &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2float64(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L1(int8u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ Info=LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L2(int16u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L3(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(3);
+ Info=LittleEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L4(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L5(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(5);
+ Info=LittleEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L6(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=LittleEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L7(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(7);
+ Info=LittleEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_L8(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//***************************************************************************
+// Little and Big Endian together
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D1_(int8u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D2_(int16u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D3_(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=LittleEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D4_(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D5_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(10);
+ Info=LittleEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=10;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D6_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(12);
+ Info=LittleEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=12;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D7_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(14);
+ Info=LittleEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=14;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D8_(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_D16_(int128u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(32);
+ //Info=LittleEndian2int128u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.lo=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.hi=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset+8);
+ Element_Offset+=32;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_DF4_(float32 &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2float32(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=8;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_DF8_(float64 &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info=LittleEndian2float64(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=16;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D1(int8u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D2(int16u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D3(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=LittleEndian2int24u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D4(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D5(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(10);
+ Info=LittleEndian2int40u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D6(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(12);
+ Info=LittleEndian2int48u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D7(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(14);
+ Info=LittleEndian2int56u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_D8(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+}
+
+//***************************************************************************
+// GUID
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_GUID(int128u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info.hi=LittleEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.lo=BigEndian2int64u (Buffer+Buffer_Offset+(size_t)Element_Offset+8);
+ Element_Offset+=16;
+}
+
+//***************************************************************************
+// UUID
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UUID(int128u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(16);
+ Info.hi=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Info.lo=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset+8);
+ Element_Offset+=16;
+}
+
+//***************************************************************************
+// EBML
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_EB(int64u &Info)
+{
+ //Element size
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ if (Buffer[Buffer_Offset+Element_Offset]==0xFF)
+ {
+ Info=File_Size-(File_Offset+Buffer_Offset+Element_Offset);
+ Element_Offset++;
+ return;
+ }
+ int8u Size=0;
+ int8u Size_Mark=0;
+ BS_Begin();
+ while (Size_Mark==0 && BS->Remain() && Size<=8)
+ {
+ Size++;
+ Peek_S1(Size, Size_Mark);
+ }
+
+ //Integrity
+ if (!BS->Remain() || Size>8)
+ {
+ if (Size>8)
+ {
+ //Element[Element_Level].IsComplete=true; //If it is in a header
+ Trusted_IsNot("EBML integer parsing error");
+ }
+ Info=0;
+ return;
+ }
+ BS_End();
+ if (File_Offset+Buffer_Offset+Element_Offset>=Element[Element_Level].Next)
+ {
+ //Element[Element_Level].IsComplete=true; //If it is in a header
+ Trusted_IsNot("Not enough place to have an EBML");
+ Info=0;
+ return; //Not enough space
+ }
+ INTEGRITY_SIZE_ATLEAST_INT(Size);
+
+ //Element Name
+ switch (Size)
+ {
+ case 1 : {
+ int8u Element_Name;
+ Peek_B1 (Element_Name);
+ Info=Element_Name&0x7F; //Keep out first bit
+ }
+ break;
+ case 2 : {
+ int16u Element_Name;
+ Peek_B2(Element_Name);
+ Info=Element_Name&0x3FFF; //Keep out first bits
+ }
+ break;
+ case 3 : {
+ int32u Element_Name;
+ Peek_B3(Element_Name);
+ Info=Element_Name&0x1FFFFF; //Keep out first bits
+ }
+ break;
+ case 4 : {
+ int32u Element_Name;
+ Peek_B4(Element_Name);
+ Info=Element_Name&0x0FFFFFFF; //Keep out first bits
+ }
+ break;
+ case 5 : {
+ int64u Element_Name;
+ Peek_B5(Element_Name);
+ Info=Element_Name&0x07FFFFFFFFLL; //Keep out first bits
+ }
+ break;
+ case 6 : {
+ int64u Element_Name;
+ Peek_B6(Element_Name);
+ Info=Element_Name&0x03FFFFFFFFFFLL; //Keep out first bits
+ }
+ break;
+ case 7 : {
+ int64u Element_Name;
+ Peek_B7(Element_Name);
+ Info=Element_Name&0x01FFFFFFFFFFFFLL; //Keep out first bits
+ }
+ break;
+ case 8 : {
+ int64u Element_Name;
+ Peek_B8(Element_Name);
+ Info=Element_Name&0x00FFFFFFFFFFFFFFLL; //Keep out first bits
+ }
+ break;
+ }
+
+ Element_Offset+=Size;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_ES(int64s &Info)
+{
+ //Element size
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ int8u Size=0;
+ int8u Size_Mark=0;
+ BS_Begin();
+ while (Size_Mark==0 && BS->Remain() && Size<=8)
+ {
+ Size++;
+ Peek_S1(Size, Size_Mark);
+ }
+
+ //Integrity
+ if (!BS->Remain() || Size>8)
+ {
+ if (Size>8)
+ {
+ //Element[Element_Level].IsComplete=true; //If it is in a header
+ Trusted_IsNot("EBML integer parsing error");
+ }
+ Info=0;
+ return;
+ }
+ BS_End();
+ if (File_Offset+Buffer_Offset+Element_Offset>=Element[Element_Level].Next)
+ {
+ //Element[Element_Level].IsComplete=true; //If it is in a header
+ Trusted_IsNot("Not enough place to have an EBML");
+ Info=0;
+ return; //Not enough space
+ }
+ INTEGRITY_SIZE_ATLEAST_INT(Size);
+
+ //Element Name
+ switch (Size)
+ {
+ case 1 : {
+ int8u Element_Name;
+ Peek_B1 (Element_Name);
+ Info=(Element_Name&0x7F)-0x3F; //Keep out first bit and sign
+ }
+ break;
+ case 2 : {
+ int16u Element_Name;
+ Peek_B2(Element_Name);
+ Info=(Element_Name&0x3FFF)-0x1FFF; //Keep out first bits and sign
+ }
+ break;
+ case 3 : {
+ int32u Element_Name;
+ Peek_B3(Element_Name);
+ Info=(Element_Name&0x1FFFFF)-0x0FFFFF; //Keep out first bits and sign
+ }
+ break;
+ case 4 : {
+ int32u Element_Name;
+ Peek_B4(Element_Name);
+ Info=(Element_Name&0x0FFFFFFF)-0x07FFFFFF; //Keep out first bits and sign
+ }
+ break;
+ case 5 : {
+ int64u Element_Name;
+ Peek_B5(Element_Name);
+ Info=(Element_Name&0x07FFFFFFFFLL)-0x03FFFFFFFFLL; //Keep out first bits and sign
+ }
+ break;
+ case 6 : {
+ int64u Element_Name;
+ Peek_B6(Element_Name);
+ Info=(Element_Name&0x03FFFFFFFFFFLL)-0x01FFFFFFFFFFLL; //Keep out first bits and sign
+ }
+ break;
+ case 7 : {
+ int64u Element_Name;
+ Peek_B7(Element_Name);
+ Info=(Element_Name&0x01FFFFFFFFFFFFLL)-0x00FFFFFFFFFFFFLL; //Keep out first bits and sign
+ }
+ break;
+ case 8 : {
+ int64u Element_Name;
+ Peek_B8(Element_Name);
+ Info=(Element_Name&0x00FFFFFFFFFFFFFFLL)-0x007FFFFFFFFFFFFFLL; //Keep out first bits and sign
+ }
+ break;
+ }
+
+ Element_Offset+=Size;
+}
+
+//***************************************************************************
+// Variable Length Value
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_VS(int64u &Info)
+{
+ //Element size
+ Info=0;
+ int8u Size=0;
+ bool more_data;
+ BS_Begin();
+ do
+ {
+ Size++;
+ INTEGRITY_INT(8<=BS->Remain())
+ more_data=BS->GetB();
+ Info=128*Info+BS->Get1(7);
+ }
+ while (more_data && Size<=8 && BS->Remain());
+ BS_End();
+
+ //Integrity
+ if (Size>8)
+ {
+ Trusted_IsNot("Variable Length Value parsing error");
+ Info=0;
+ return;
+ }
+ if (File_Offset+Buffer_Offset+Element_Offset>=Element[Element_Level].Next)
+ {
+ Trusted_IsNot("Not enough place to have a Variable Length Value");
+ Info=0;
+ return; //Not enough space
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_VS()
+{
+ //Element size
+ int64u Info=0;
+ int8u Size=0;
+ bool more_data;
+ BS_Begin();
+ do
+ {
+ Size++;
+ INTEGRITY_INT(8<=BS->Remain())
+ more_data=BS->GetB();
+ Info=128*Info+BS->Get1(7);
+ }
+ while (more_data && Size<=8 && BS->Remain());
+ BS_End();
+
+ //Integrity
+ if (Size>8)
+ {
+ Trusted_IsNot("Variable Size Value parsing error");
+ Info=0;
+ return;
+ }
+ if (File_Offset+Buffer_Offset+Element_Offset>=Element[Element_Level].Next)
+ {
+ Trusted_IsNot("Not enough place to have a Variable Size Value");
+ Info=0;
+ return; //Not enough space
+ }
+}
+
+//***************************************************************************
+// Exp-Golomb
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_SE(int32s &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_BUFFER();
+ int8u LeadingZeroBits=0;
+ while(BS->Remain()>0 && !BS->GetB())
+ LeadingZeroBits++;
+ INTEGRITY(LeadingZeroBits<=32)
+ double InfoD=pow((float)2, (float)LeadingZeroBits)-1+BS->Get4(LeadingZeroBits);
+ INTEGRITY(InfoD<int32u(-1))
+ Info=(int32s)(pow((double)-1, InfoD+1)*(int32u)ceil(InfoD/2));
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_SE()
+{
+ INTEGRITY(BS->Remain())
+ int8u LeadingZeroBits=0;
+ while(BS->Remain()>0 && !BS->GetB())
+ LeadingZeroBits++;
+ BS->Skip(LeadingZeroBits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UE(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_BUFFER();
+ int8u LeadingZeroBits=0;
+ while(BS->Remain()>0 && !BS->GetB())
+ LeadingZeroBits++;
+ INTEGRITY(LeadingZeroBits<=32)
+ double InfoD=pow((float)2, (float)LeadingZeroBits);
+ Info=(int32u)InfoD-1+BS->Get4(LeadingZeroBits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_UE()
+{
+ INTEGRITY(BS->Remain())
+ int8u LeadingZeroBits=0;
+ while(BS->Remain()>0 && !BS->GetB())
+ LeadingZeroBits++;
+ BS->Skip(LeadingZeroBits);
+}
+
+//***************************************************************************
+// Inverted Exp-Golomb
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_SI(int32s &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_BUFFER();
+
+ Info=1;
+ while(BS->Remain()>0 && BS->GetB()==0)
+ {
+ Info<<=1;
+ if (BS->Remain()==0)
+ {
+ Trusted_IsNot("(Problem)");
+ Info=0;
+ return;
+ }
+ if(BS->GetB()==1)
+ Info++;
+ }
+ Info--;
+
+ if (Info!=0 && BS->Remain()>0 && BS->GetB()==1)
+ Info=-Info;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_SI()
+{
+ int32s Info;
+ Get_SI(Info);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UI(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_BUFFER();
+ Info=1;
+ while(BS->Remain()>0 && BS->GetB()==0)
+ {
+ Info<<=1;
+ if (BS->Remain()==0)
+ {
+ Trusted_IsNot("(Problem)");
+ Info=0;
+ return;
+ }
+ if(BS->GetB()==1)
+ Info++;
+ }
+ Info--;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_UI()
+{
+ int32u Info;
+ Get_UI(Info);
+}
+
+//***************************************************************************
+// Variable Length Code
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_VL_(const vlc Vlc[], size_t &Info)
+{
+ Info=0;
+ int32u Value=0;
+
+ for(;;)
+ {
+ switch (Vlc[Info].bit_increment)
+ {
+ case 255 :
+ Trusted_IsNot();
+ return;
+ default : ;
+ Value<<=Vlc[Info].bit_increment;
+ Value|=BS->Get1(Vlc[Info].bit_increment);
+ break;
+ case 1 :
+ Value<<=1;
+ if (BS->GetB())
+ Value++;
+ case 0 : ;
+ }
+
+ if (Value==Vlc[Info].value)
+ return;
+ Info++;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_VL_(const vlc Vlc[])
+{
+ size_t Info=0;
+ int32u Value=0;
+
+ for(;;)
+ {
+ switch (Vlc[Info].bit_increment)
+ {
+ case 255 :
+ Trusted_IsNot();
+ return;
+ default : ;
+ Value<<=Vlc[Info].bit_increment;
+ Value|=BS->Get1(Vlc[Info].bit_increment);
+ break;
+ case 1 :
+ Value<<=1;
+ if (BS->GetB())
+ Value++;
+ case 0 : ;
+ }
+
+ if (Value==Vlc[Info].value)
+ return;
+ Info++;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_VL_Prepare(vlc_fast &Vlc)
+{
+ Vlc.Array=new int8u[((size_t)1)<<Vlc.Size];
+ Vlc.BitsToSkip=new int8u[((size_t)1)<<Vlc.Size];
+ memset(Vlc.Array, 0xFF, ((size_t)1)<<Vlc.Size);
+ int8u Increment=0;
+ int8u Pos=0;
+ for(; ; Pos++)
+ {
+ if (Vlc.Vlc[Pos].bit_increment==255)
+ break;
+ Increment+=Vlc.Vlc[Pos].bit_increment;
+ size_t Value=Vlc.Vlc[Pos].value<<(Vlc.Size-Increment);
+ size_t ToFill_Size=1<<(Vlc.Size-Increment);
+ for (size_t ToFill_Pos=0; ToFill_Pos<ToFill_Size; ToFill_Pos++)
+ {
+ Vlc.Array[Value+ToFill_Pos]=Pos;
+ Vlc.BitsToSkip[Value+ToFill_Pos]=Increment;
+ }
+ }
+ for (size_t Pos2=0; Pos2<(((size_t)1)<<Vlc.Size); Pos2++)
+ if (Vlc.Array[Pos2]==(int8u)-1)
+ {
+ Vlc.Array[Pos2]=Pos;
+ Vlc.BitsToSkip[Pos2]=(int8u)-1;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_VL_(const vlc_fast &Vlc, size_t &Info)
+{
+ if (BS->Remain()<Vlc.Size)
+ {
+ Get_VL(Vlc.Vlc, Info, Name);
+ return;
+ }
+
+ int32u Value=BS->Peek4(Vlc.Size);
+ Info=Vlc.Array[Value];
+
+ if (Vlc.BitsToSkip[Value]==(int8u)-1)
+ {
+ Trusted_IsNot();
+ return;
+ }
+
+ BS->Skip(Vlc.BitsToSkip[Value]);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_VL_(const vlc_fast &Vlc)
+{
+ if (BS->Remain()<Vlc.Size)
+ {
+ Skip_VL_(Vlc.Vlc);
+ return;
+ }
+
+ int32u Value=BS->Peek4(Vlc.Size);
+
+ if (Vlc.BitsToSkip[Value]==(int8u)-1)
+ {
+ Trusted_IsNot();
+ return;
+ }
+
+ BS->Skip(Vlc.BitsToSkip[Value]);
+}
+
+//***************************************************************************
+// Characters
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C1(int8u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(1);
+ Info=CC1(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=1;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C2(int16u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(2);
+ Info=CC2(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=2;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C3(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(3);
+ Info=CC3(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=3;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C4(int32u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(4);
+ Info=CC4(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=4;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C5(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(5);
+ Info=CC5(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=5;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C6(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(6);
+ Info=CC6(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=6;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C7(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(7);
+ Info=CC7(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=7;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_C8(int64u &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_INT(8);
+ Info=CC8(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=8;
+}
+
+//***************************************************************************
+// Text
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_Local(int64u Bytes, Ztring &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_Local((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_ISO_8859_1(int64u Bytes, Ztring &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_ISO_8859_1((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_ISO_8859_2(int64u Bytes, Ztring &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_ISO_8859_2((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_String(int64u Bytes, std::string &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.assign((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_Local(int64u Bytes, Ztring &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_Local((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_String(int64u Bytes, std::string &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.assign((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UTF8(int64u Bytes, Ztring &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_UTF8((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UTF16(int64u Bytes, Ztring &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_UTF16((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UTF16B(int64u Bytes, Ztring &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_UTF16BE((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ Element_Offset+=Bytes;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_UTF16L(int64u Bytes, Ztring &Info)
+{
+ INTEGRITY_SIZE_ATLEAST_STRING(Bytes);
+ Info.From_UTF16LE((const char*)(Buffer+Buffer_Offset+(size_t)Element_Offset), (size_t)Bytes);
+ Element_Offset+=Bytes;
+}
+
+//***************************************************************************
+// Text
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Skip_PA()
+{
+ INTEGRITY_SIZE_ATLEAST(1);
+ int8u Size=Buffer[Buffer_Offset+Element_Offset];
+ int8u Pad=(Size%2)?0:1;
+ INTEGRITY_SIZE_ATLEAST(1+Size+Pad);
+ Element_Offset+=(size_t)(1+Size+Pad);
+}
+
+//***************************************************************************
+// Flags
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_Flags_ (int64u Flags, size_t Order, bool &Info)
+{
+ if (Flags&((int64u)1<<Order))
+ Info=true;
+ else
+ Info=false;
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_FlagsM_ (int64u ValueToPut, int8u &Info)
+{
+ Info=(int8u)ValueToPut;
+}
+
+//***************************************************************************
+// BitStream
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BS_(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Get4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_SB_( bool &Info)
+{
+ INTEGRITY_INT(1<=BS->Remain())
+ Info=BS->GetB();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S1_(int8u Bits, int8u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Get1(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S2_(int8u Bits, int16u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Get2(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S3_(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Get4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S4_(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Get4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S5_(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Get8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S6_(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Get8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S7_(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Get8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_S8_(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Get8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_BS(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Peek4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_SB( bool &Info)
+{
+ INTEGRITY_INT(1<=BS->Remain())
+ Info=BS->PeekB();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S1(int8u Bits, int8u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Peek1(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S2(int8u Bits, int16u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Peek2(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S3(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Peek4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S4(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Peek4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S5(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S6(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S7(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_S8(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BS->Remain())
+ Info=BS->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Mark_0()
+{
+ INTEGRITY(1<=BS->Remain())
+ if (BS->GetB())
+ Element_DoNotTrust("Mark bit is wrong");
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Mark_1()
+{
+ INTEGRITY(1<=BS->Remain())
+ if (!BS->GetB())
+ Element_DoNotTrust("Mark bit is wrong");
+}
+
+//***************************************************************************
+// BitStream (Little Endian)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_BT_(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Get(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_TB_( bool &Info)
+{
+ INTEGRITY_INT(1<=BT->Remain())
+ Info=BT->GetB();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T1_(int8u Bits, int8u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Get1(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T2_(int8u Bits, int16u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Get2(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T3_(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Get4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T4_(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Get4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T5_(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Get8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T6_(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Get8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T7_(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Get8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Get_T8_(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Get8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_BT(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Peek(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_TB( bool &Info)
+{
+ INTEGRITY_INT(1<=BT->Remain())
+ Info=BT->PeekB();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T1(int8u Bits, int8u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Peek1(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T2(int8u Bits, int16u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Peek2(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T3(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Peek4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T4(int8u Bits, int32u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Peek4(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T5(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T6(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T7(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Peek8(Bits);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Peek_T8(int8u Bits, int64u &Info)
+{
+ INTEGRITY_INT(Bits<=BT->Remain())
+ Info=BT->Peek8(Bits);
+}
+
+} //NameSpace
+#endif //MEDIAINFO_TRACE
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_MinimizeSize.h b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_MinimizeSize.h
new file mode 100644
index 000000000..a19637c25
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_MinimizeSize.h
@@ -0,0 +1,1339 @@
+// File__Analyze -
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File__AnalyzeMinimizeSizeH
+#define MediaInfo_File__AnalyzeMinimizeSizeH
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Class File__Analyze
+//***************************************************************************
+
+class File__Analyze : public File__Base
+{
+public :
+ //***************************************************************************
+ // Constructor/Destructor
+ //***************************************************************************
+
+ File__Analyze();
+ virtual ~File__Analyze();
+
+ //***************************************************************************
+ // Open
+ //***************************************************************************
+
+ void Open_Buffer_Init ( int64u File_Size);
+ void Open_Buffer_Init (File__Analyze* Sub);
+ void Open_Buffer_Init (File__Analyze* Sub, int64u File_Size);
+ void Open_Buffer_Continue ( const int8u* Buffer, size_t Buffer_Size);
+ void Open_Buffer_Continue (File__Analyze* Sub, const int8u* Buffer, size_t Buffer_Size);
+ void Open_Buffer_Continue (File__Analyze* Sub, size_t Buffer_Size) {Open_Buffer_Continue(Sub, Buffer+Buffer_Offset+(size_t)Element_Offset, Buffer_Size); Element_Offset+=Buffer_Size;}
+ void Open_Buffer_Continue (File__Analyze* Sub) {Open_Buffer_Continue(Sub, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset)); Element_Offset=Element_Size;}
+ void Open_Buffer_Position_Set(int64u File_Offset);
+ #if MEDIAINFO_SEEK
+ size_t Open_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+ void Open_Buffer_Unsynch ();
+ void Open_Buffer_Update ();
+ void Open_Buffer_Update (File__Analyze* Sub);
+ void Open_Buffer_Finalize (bool NoBufferModification=false);
+ void Open_Buffer_Finalize (File__Analyze* Sub);
+
+ //***************************************************************************
+ // In/Out (for parsers)
+ //***************************************************************************
+
+ //In
+ Ztring ParserName;
+ #if MEDIAINFO_EVENTS
+ size_t StreamIDs_Size;
+ int64u StreamIDs[16];
+ int8u StreamIDs_Width[16];
+ int8u ParserIDs[16];
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ int8u Demux_Level; //bit 0=frame, bit 1=container, bit 2=elementary (eg MPEG-TS), default with frame set
+ bool Demux_random_access;
+ bool Demux_UnpacketizeContainer;
+ bool Demux_IntermediateItemFound;
+ size_t Demux_Offset;
+ int64u Demux_TotalBytes;
+ #endif //MEDIAINFO_DEMUX
+ Ztring File_Name_WithoutDemux;
+ bool PTS_DTS_Needed;
+ struct frame_info
+ {
+ int64u Buffer_Offset;
+ int64u PCR; //In nanoseconds
+ int64u PTS; //In nanoseconds
+ int64u DTS; //In nanoseconds
+ int64u DUR; //In nanoseconds
+
+ frame_info()
+ {
+ Buffer_Offset=0;
+ PCR=(int64u)-1;
+ PTS=(int64u)-1;
+ DTS=(int64u)-1;
+ DUR=(int64u)-1;
+ }
+ };
+ frame_info FrameInfo;
+ frame_info FrameInfo_Previous;
+ frame_info FrameInfo_Next;
+
+ //Out
+ int64u PTS_Begin; //In nanoseconds
+ int64u PTS_End; //In nanoseconds
+ int64u DTS_Begin; //In nanoseconds
+ int64u DTS_End; //In nanoseconds
+ int64u Frame_Count;
+ int64u Frame_Count_Previous;
+ int64u Frame_Count_InThisBlock;
+ int64u Field_Count;
+ int64u Field_Count_Previous;
+ int64u Field_Count_InThisBlock;
+ int64u Frame_Count_NotParsedIncluded;
+ bool Synched; //Data is synched
+ bool MustExtendParsingDuration; //Data has some substreams difficult to detect (e.g. captions), must wait a bit before final filling
+
+protected :
+ //***************************************************************************
+ // Streams management
+ //***************************************************************************
+
+ virtual void Streams_Accept() {};
+ virtual void Streams_Fill() {};
+ virtual void Streams_Update() {};
+ virtual void Streams_Finish() {};
+
+ //***************************************************************************
+ // Synchro
+ //***************************************************************************
+
+ virtual bool Synchronize() {Synched=true; return true;}; //Look for the synchro
+ virtual bool Synched_Test() {return true;}; //Test is synchro is OK
+ virtual void Synched_Init() {}; //When synched, we can Init data
+ bool Synchro_Manage();
+ bool Synchro_Manage_Test();
+
+ //***************************************************************************
+ // Buffer
+ //***************************************************************************
+
+ //Buffer
+ virtual void Read_Buffer_Init () {}; //Temp, should be in File__Base caller
+ virtual void Read_Buffer_Continue () {}; //Temp, should be in File__Base caller
+ virtual void Read_Buffer_AfterParsing () {}; //Temp, should be in File__Base caller
+ #if MEDIAINFO_SEEK
+ virtual size_t Read_Buffer_Seek (size_t, int64u, int64u); //Temp, should be in File__Base caller
+ size_t Read_Buffer_Seek_OneFramePerFile (size_t, int64u, int64u);
+ #endif //MEDIAINFO_SEEK
+ virtual void Read_Buffer_Unsynched () {}; //Temp, should be in File__Base caller
+ void Read_Buffer_Unsynched_OneFramePerFile ();
+ virtual void Read_Buffer_Finalize () {}; //Temp, should be in File__Base caller
+ bool Buffer_Parse();
+
+ //***************************************************************************
+ // BitStream init
+ //***************************************************************************
+
+ void BS_Begin();
+ void BS_Begin_LE(); //Little Endian version
+ void BS_End();
+ void BS_End_LE(); //Little Endian version
+
+ //***************************************************************************
+ // File Header
+ //***************************************************************************
+
+ //File Header - Management
+ bool FileHeader_Manage ();
+
+ //File Header - Begin
+ virtual bool FileHeader_Begin () {return true;};
+
+ //File Header - Parse
+ virtual void FileHeader_Parse () {Element_DoNotShow();};
+
+ //***************************************************************************
+ // Header
+ //***************************************************************************
+
+ //Header - Management
+ bool Header_Manage ();
+
+ //Header - Begin
+ virtual bool Header_Begin () {return true;};
+
+ //Header - Parse
+ virtual void Header_Parse ();
+
+ //Header - Info
+ void Header_Fill_Code (int64u Code);
+ inline void Header_Fill_Code (int64u Code, const Ztring &) {Header_Fill_Code(Code);};
+ void Header_Fill_Size (int64u Size);
+
+ //***************************************************************************
+ // Data
+ //***************************************************************************
+
+ //Header - Management
+ bool Data_Manage ();
+
+ //Data - Parse
+ virtual void Data_Parse () {};
+
+ //Data - Info
+ inline void Data_Info (const Ztring &) {};
+ inline void Data_Info_From_Milliseconds (int64u) {}
+
+ //Data - Get info
+ size_t Data_Remain () {return (size_t)(Element_Size-(Element_Offset+BS->Offset_Get()));};
+ size_t Data_BS_Remain () {return (size_t)BS->Remain();};
+
+ //Data - Detect EOF
+ virtual void Detect_EOF () {};
+ bool EOF_AlreadyDetected;
+
+ //Data - Helpers
+ void Data_Accept (const char*) {Accept();}
+ void Data_Accept () {Accept();}
+ void Data_Reject (const char*) {Reject();}
+ void Data_Reject () {Reject();}
+ void Data_Finish (const char*) {ForceFinish();}
+ void Data_Finish () {ForceFinish();}
+ void Data_GoTo (int64u GoTo_, const char*) {GoTo(GoTo_);}
+ void Data_GoTo (int64u GoTo_) {GoTo(GoTo_);}
+ void Data_GoToFromEnd (int64u GoToFromEnd_, const char*) {GoToFromEnd(GoToFromEnd_);}
+ void Data_GoToFromEnd (int64u GoToFromEnd_) {GoToFromEnd(GoToFromEnd_);}
+
+ //***************************************************************************
+ // Elements
+ //***************************************************************************
+
+ //Elements - Begin
+ void Element_Begin ();
+ #define Element_Begin0() Element_Begin()
+ #define Element_Begin1(_NAME) Element_Begin()
+ #define Element_Trace_Begin0()
+ #define Element_Trace_Begin1(_NAME)
+
+ //Elements - Name
+ #define Element_Name(_A)
+
+ //Elements - Info
+ #define Element_Info1(_A)
+ #define Element_Info2(_A,_B)
+ #define Element_Info3(_A,_B,_C)
+ #define Element_Info1C(_CONDITION,_A)
+ #define Element_Info_From_Milliseconds(_A)
+
+ //Elements - End
+ inline void Element_End () {Element_End_Common_Flush();}
+ #define Element_End0() Element_End()
+ #define Element_End1(_NAME) Element_End()
+ #define Element_Trace_End0()
+ #define Element_Trace_End1(_NAME)
+
+ //Elements - Preparation of element from external app
+ void Element_Prepare (int64u Size);
+
+protected :
+ //Element - Common
+ void Element_End_Common_Flush();
+ Ztring Element_End_Common_Flush_Build();
+public :
+
+ //***************************************************************************
+ // Param
+ //***************************************************************************
+
+ //Param - Main
+ #define Param1(_A)
+ #define Param2(_A,_B)
+ #define Param3(_A,_B,_C)
+
+ //Param - Info
+ #define Param_Info1(_A)
+ #define Param_Info2(_A,_B)
+ #define Param_Info3(_A,_B,_C)
+ #define Param_Info1C(_CONDITION,_A)
+ #define Param_Info2C(_CONDITION,_A,_B)
+ #define Param_Info3C(_CONDITION,_A,_B,_C)
+ #define Param_Info_From_Milliseconds(A)
+
+ //***************************************************************************
+ // Information
+ //***************************************************************************
+
+ inline void Info (const Ztring&, size_t =0) {}
+
+ //***************************************************************************
+ // Big Endian (Integer, Float, Fixed-Point)
+ //***************************************************************************
+
+ void Get_B1_ (int8u &Info);
+ void Get_B2_ (int16u &Info);
+ void Get_B3_ (int32u &Info);
+ void Get_B4_ (int32u &Info);
+ void Get_B5_ (int64u &Info);
+ void Get_B6_ (int64u &Info);
+ void Get_B7_ (int64u &Info);
+ void Get_B8_ (int64u &Info);
+ void Get_B16_ (int128u &Info);
+ void Get_BF4_ (float32 &Info);
+ void Get_BF8_ (float64 &Info);
+ void Get_BF10_ (float80 &Info);
+ void Get_BFP4_ (int8u Bits, float32 &Info);
+ #define Get_B1(Info, Name) Get_B1_(Info)
+ #define Get_B2(Info, Name) Get_B2_(Info)
+ #define Get_B3(Info, Name) Get_B3_(Info)
+ #define Get_B4(Info, Name) Get_B4_(Info)
+ #define Get_B5(Info, Name) Get_B5_(Info)
+ #define Get_B6(Info, Name) Get_B6_(Info)
+ #define Get_B7(Info, Name) Get_B7_(Info)
+ #define Get_B8(Info, Name) Get_B8_(Info)
+ #define Get_B16(Info, Name) Get_B16_(Info)
+ #define Get_BF4(Info, Name) Get_BF4_(Info)
+ #define Get_BF8(Info, Name) Get_BF8_(Info)
+ #define Get_BF10(Info, Name) Get_BF10_(Info)
+ #define Get_BFP4(Bits, Info, Name) Get_BFP4_(Bits, Info)
+ void Peek_B1 (int8u &Info);
+ void Peek_B2 (int16u &Info);
+ void Peek_B3 (int32u &Info);
+ void Peek_B4 (int32u &Info);
+ void Peek_B5 (int64u &Info);
+ void Peek_B6 (int64u &Info);
+ void Peek_B7 (int64u &Info);
+ void Peek_B8 (int64u &Info);
+ void Peek_B16 (int128u &Info);
+ void Peek_BF4 (float32 &Info);
+ void Peek_BF8 (float64 &Info);
+ void Peek_BF10(float64 &Info);
+ void Peek_BFP4(int8u Bits, float64 &Info);
+ #define Skip_B1(Name) Element_Offset++
+ #define Skip_B2(Name) Element_Offset+=2
+ #define Skip_B3(Name) Element_Offset+=3
+ #define Skip_B4(Name) Element_Offset+=4
+ #define Skip_B5(Name) Element_Offset+=5
+ #define Skip_B6(Name) Element_Offset+=6
+ #define Skip_B7(Name) Element_Offset+=7
+ #define Skip_B8(Name) Element_Offset+=8
+ #define Skip_BF4(Name) Element_Offset+=4
+ #define Skip_BF8(Name) Element_Offset+=8
+ #define Skip_B16(Name) Element_Offset+=16
+ #define Skip_BFP4(Size, Name) Element_Offset+=4
+ #define Info_B1(_INFO, _NAME) Element_Offset++
+ #define Info_B2(_INFO, _NAME) Element_Offset+=2
+ #define Info_B3(_INFO, _NAME) Element_Offset+=3
+ #define Info_B4(_INFO, _NAME) Element_Offset+=4
+ #define Info_B5(_INFO, _NAME) Element_Offset+=5
+ #define Info_B6(_INFO, _NAME) Element_Offset+=6
+ #define Info_B7(_INFO, _NAME) Element_Offset+=7
+ #define Info_B8(_INFO, _NAME) Element_Offset+=8
+ #define Info_B16(_INFO, _NAME) Element_Offset+=16
+ #define Info_BF4(_INFO, _NAME) Element_Offset+=4
+ #define Info_BF8(_INFO, _NAME) Element_Offset+=8
+ #define Info_BF10(_INFO, _NAME) Element_Offset+=10
+ #define Info_BFP4(_BITS, _INFO, _NAME) Element_Offset+=4
+
+ //***************************************************************************
+ // Little Endian
+ //***************************************************************************
+
+ void Get_L1_ (int8u &Info);
+ void Get_L2_ (int16u &Info);
+ void Get_L3_ (int32u &Info);
+ void Get_L4_ (int32u &Info);
+ void Get_L5_ (int64u &Info);
+ void Get_L6_ (int64u &Info);
+ void Get_L7_ (int64u &Info);
+ void Get_L8_ (int64u &Info);
+ void Get_L16_ (int128u &Info);
+ void Get_LF4_ (float32 &Info);
+ void Get_LF8_ (float64 &Info);
+ void Get_LF10_ (float80 &Info);
+ void Get_LFP4_ (int8u Bits, float32 &Info);
+ #define Get_L1(Info, Name) Get_L1_(Info)
+ #define Get_L2(Info, Name) Get_L2_(Info)
+ #define Get_L3(Info, Name) Get_L3_(Info)
+ #define Get_L4(Info, Name) Get_L4_(Info)
+ #define Get_L5(Info, Name) Get_L5_(Info)
+ #define Get_L6(Info, Name) Get_L6_(Info)
+ #define Get_L7(Info, Name) Get_L7_(Info)
+ #define Get_L8(Info, Name) Get_L8_(Info)
+ #define Get_L16(Info, Name) Get_L16_(Info)
+ #define Get_LF4(Info, Name) Get_LF4_(Info)
+ #define Get_LF8(Info, Name) Get_LF8_(Info)
+ #define Get_LF10(Info, Name) Get_LF10_(Info)
+ #define Get_LFP4(Bits, Info, Name) Get_LFP4_(Bits, Info)
+ void Peek_L1 (int8u &Info);
+ void Peek_L2 (int16u &Info);
+ void Peek_L3 (int32u &Info);
+ void Peek_L4 (int32u &Info);
+ void Peek_L5 (int64u &Info);
+ void Peek_L6 (int64u &Info);
+ void Peek_L7 (int64u &Info);
+ void Peek_L8 (int64u &Info);
+ void Peek_L16 (int128u &Info);
+ void Peek_LF4 (float32 &Info);
+ void Peek_LF8 (float64 &Info);
+ void Peek_LF10(float64 &Info);
+ void Peek_LFP4(int8u Bits, float64 &Info);
+ #define Skip_L1(Name) Element_Offset++
+ #define Skip_L2(Name) Element_Offset+=2
+ #define Skip_L3(Name) Element_Offset+=3
+ #define Skip_L4(Name) Element_Offset+=4
+ #define Skip_L5(Name) Element_Offset+=5
+ #define Skip_L6(Name) Element_Offset+=6
+ #define Skip_L7(Name) Element_Offset+=7
+ #define Skip_L8(Name) Element_Offset+=8
+ #define Skip_LF4(Name) Element_Offset+=4
+ #define Skip_LF8(Name) Element_Offset+=8
+ #define Skip_L16(Name) Element_Offset+=16
+ #define Skip_LFP4(Size, Name) Element_Offset+=4
+ #define Info_L1(_INFO, _NAME) Element_Offset++
+ #define Info_L2(_INFO, _NAME) Element_Offset+=2
+ #define Info_L3(_INFO, _NAME) Element_Offset+=3
+ #define Info_L4(_INFO, _NAME) Element_Offset+=4
+ #define Info_L5(_INFO, _NAME) Element_Offset+=5
+ #define Info_L6(_INFO, _NAME) Element_Offset+=6
+ #define Info_L7(_INFO, _NAME) Element_Offset+=7
+ #define Info_L8(_INFO, _NAME) Element_Offset+=8
+ #define Info_L16(_INFO, _NAME) Element_Offset+=16
+ #define Info_LF4(_INFO, _NAME) Element_Offset+=4
+ #define Info_LF8(_INFO, _NAME) Element_Offset+=8
+ #define Info_LF10(_INFO, _NAME) Element_Offset+=10
+ #define Info_LFP4(_LITS, _INFO, _NAME) Element_Offset+=4
+
+ //***************************************************************************
+ // Little and Big Endian together
+ //***************************************************************************
+
+ void Get_D1_ (int8u &Info);
+ void Get_D2_ (int16u &Info);
+ void Get_D3_ (int32u &Info);
+ void Get_D4_ (int32u &Info);
+ void Get_D5_ (int64u &Info);
+ void Get_D6_ (int64u &Info);
+ void Get_D7_ (int64u &Info);
+ void Get_D8_ (int64u &Info);
+ void Get_D16_ (int128u &Info);
+ void Get_DF4_ (float32 &Info);
+ void Get_DF8_ (float64 &Info);
+ void Get_DF10_ (float80 &Info);
+ void Get_DFP4_ (int8u Bits, float32 &Info);
+ #define Get_D1(Info, Name) Get_D1_(Info)
+ #define Get_D2(Info, Name) Get_D2_(Info)
+ #define Get_D3(Info, Name) Get_D3_(Info)
+ #define Get_D4(Info, Name) Get_D4_(Info)
+ #define Get_D5(Info, Name) Get_D5_(Info)
+ #define Get_D6(Info, Name) Get_D6_(Info)
+ #define Get_D7(Info, Name) Get_D7_(Info)
+ #define Get_D8(Info, Name) Get_D8_(Info)
+ #define Get_D16(Info, Name) Get_D16_(Info)
+ #define Get_DF4(Info, Name) Get_DF4_(Info)
+ #define Get_DF8(Info, Name) Get_DF8_(Info)
+ #define Get_DF10(Info, Name) Get_DF10_(Info)
+ #define Get_DFP4(Bits, Info, Name) Get_DFP4_(Bits, Info)
+ void Peek_D1 (int8u &Info);
+ void Peek_D2 (int16u &Info);
+ void Peek_D3 (int32u &Info);
+ void Peek_D4 (int32u &Info);
+ void Peek_D5 (int64u &Info);
+ void Peek_D6 (int64u &Info);
+ void Peek_D7 (int64u &Info);
+ void Peek_D8 (int64u &Info);
+ void Peek_D16 (int128u &Info);
+ void Peek_DF4 (float32 &Info);
+ void Peek_DF8 (float64 &Info);
+ void Peek_DF10(float64 &Info);
+ void Peek_DFP4(int8u Bits, float64 &Info);
+ #define Skip_D1(Name) Element_Offset++
+ #define Skip_D2(Name) Element_Offset+=2
+ #define Skip_D3(Name) Element_Offset+=3
+ #define Skip_D4(Name) Element_Offset+=4
+ #define Skip_D5(Name) Element_Offset+=5
+ #define Skip_D6(Name) Element_Offset+=6
+ #define Skip_D7(Name) Element_Offset+=7
+ #define Skip_D8(Name) Element_Offset+=8
+ #define Skip_DF4(Name) Element_Offset+=4
+ #define Skip_DF8(Name) Element_Offset+=8
+ #define Skip_D16(Name) Element_Offset+=16
+ #define Skip_DFP4(Size, Name) Element_Offset+=4
+ #define Info_D1(_INFO, _NAME) Element_Offset++
+ #define Info_D2(_INFO, _NAME) Element_Offset+=2
+ #define Info_D3(_INFO, _NAME) Element_Offset+=3
+ #define Info_D4(_INFO, _NAME) Element_Offset+=4
+ #define Info_D5(_INFO, _NAME) Element_Offset+=5
+ #define Info_D6(_INFO, _NAME) Element_Offset+=6
+ #define Info_D7(_INFO, _NAME) Element_Offset+=7
+ #define Info_D8(_INFO, _NAME) Element_Offset+=8
+ #define Info_D16(_INFO, _NAME) Element_Offset+=16
+ #define Info_DF4(_INFO, _NAME) Element_Offset+=4
+ #define Info_DF8(_INFO, _NAME) Element_Offset+=8
+ #define Info_DF10(_INFO, _NAME) Element_Offset+=10
+ #define Info_DFP4(_DITS, _INFO, _NAME) Element_Offset+=4
+
+ //***************************************************************************
+ // GUID
+ //***************************************************************************
+
+ void Get_GUID (int128u &Info);
+ inline void Get_GUID (int128u &Info, const char*) {Get_GUID(Info);}
+ void Peek_GUID(int128u &Info);
+ inline void Skip_GUID( const char*) {if (Element_Offset+16>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=16;}
+ #define Info_GUID(_INFO, _NAME) int128u _INFO; Get_GUID(_INFO, _NAME)
+
+ //***************************************************************************
+ // UUID
+ //***************************************************************************
+
+ void Get_UUID (int128u &Info);
+ inline void Get_UUID (int128u &Info, const char*) {Get_UUID(Info);}
+ void Peek_UUID(int128u &Info);
+ inline void Skip_UUID( const char*) {if (Element_Offset+16>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=16;}
+ #define Info_UUID(_INFO, _NAME) int128u _INFO; Get_UUID(_INFO, _NAME)
+
+ //***************************************************************************
+ // EBML
+ //***************************************************************************
+
+ void Get_EB (int64u &Info);
+ void Get_ES (int64s &Info);
+ inline void Get_EB (int64u &Info, const char*) {Get_EB(Info);}
+ inline void Get_ES (int64s &Info, const char*) {Get_ES(Info);}
+ void Skip_EB();
+ void Skip_ES();
+ inline void Skip_EB( const char*) {Skip_EB();}
+ inline void Skip_ES( const char*) {Skip_ES();}
+ #define Info_EB(_INFO, _NAME) int64u _INFO; Get_EB(_INFO, _NAME)
+ #define Info_ES(_INFO, _NAME) int64s _INFO; Get_ES(_INFO, _NAME)
+
+ //***************************************************************************
+ // Variable Size Value
+ //***************************************************************************
+
+ void Get_VS (int64u &Info);
+ inline void Get_VS (int64u &Info, const char*) {Get_VS(Info);}
+ void Skip_VS();
+ inline void Skip_VS( const char*) {Skip_VS();}
+ #define Info_VS(_INFO, _NAME) int64u _INFO; Get_VS(_INFO, _NAME)
+
+ //***************************************************************************
+ // Exp-Golomb
+ //***************************************************************************
+
+ void Get_UE (int32u &Info);
+ void Get_SE (int32s &Info);
+ inline void Get_UE (int32u &Info, const char*) {Get_UE(Info);}
+ inline void Get_SE (int32s &Info, const char*) {Get_SE(Info);}
+ void Skip_UE();
+ void Skip_SE();
+ inline void Skip_UE( const char*) {Skip_UE();}
+ inline void Skip_SE( const char*) {Skip_SE();}
+ #define Info_UE(_INFO, _NAME) int32u _INFO; Get_UE(_INFO, _NAME)
+ #define Info_SE(_INFO, _NAME) int32s _INFO; Get_SE(_INFO, _NAME)
+
+ //***************************************************************************
+ // Interleaved Exp-Golomb
+ //***************************************************************************
+
+ void Get_UI (int32u &Info);
+ void Get_SI (int32s &Info);
+ inline void Get_UI (int32u &Info, const char*) {Get_UI(Info);}
+ inline void Get_SI (int32s &Info, const char*) {Get_SI(Info);}
+ void Skip_UI();
+ void Skip_SI();
+ inline void Skip_UI( const char*) {Skip_UI();}
+ inline void Skip_SI( const char*) {Skip_SI();}
+ #define Info_UI(_INFO, _NAME) int32u _INFO; Get_UI(_INFO, _NAME)
+ #define Info_SI(_INFO, _NAME) int32s _INFO; Get_SI(_INFO, _NAME)
+
+ //***************************************************************************
+ // Variable Length Code
+ //***************************************************************************
+
+ struct vlc
+ {
+ int32u value;
+ int8u bit_increment;
+ int8s mapped_to1;
+ int8s mapped_to2;
+ int8s mapped_to3;
+ };
+ struct vlc_fast
+ {
+ int8u* Array;
+ int8u* BitsToSkip;
+ const vlc* Vlc;
+ int8u Size;
+ };
+ #define VLC_END \
+ {(int32u)-1, (int8u)-1, 0, 0, 0}
+ void Get_VL_Prepare(vlc_fast &Vlc);
+ void Get_VL_ (const vlc Vlc[], size_t &Info);
+ void Get_VL_ (const vlc_fast &Vlc, size_t &Info);
+ #define Get_VL(Vlc, Info, Name) Get_VL_(Vlc, Info);
+ void Skip_VL_(const vlc Vlc[]);
+ void Skip_VL_(const vlc_fast &Vlc);
+ #define Skip_VL(Vlc, Name) Skip_VL_(Vlc);
+ #define Info_VL(Vlc, Info, Name) Skip_VL_(Vlc)
+
+ //***************************************************************************
+ // Characters
+ //***************************************************************************
+
+ void Get_C1 (int8u &Info);
+ void Get_C2 (int16u &Info);
+ void Get_C3 (int32u &Info);
+ void Get_C4 (int32u &Info);
+ void Get_C5 (int64u &Info);
+ void Get_C6 (int64u &Info);
+ void Get_C7 (int64u &Info);
+ void Get_C8 (int64u &Info);
+ inline void Get_C1 (int8u &Info, const char*) {Get_C1(Info);}
+ inline void Get_C2 (int16u &Info, const char*) {Get_C2(Info);}
+ inline void Get_C3 (int32u &Info, const char*) {Get_C3(Info);}
+ inline void Get_C4 (int32u &Info, const char*) {Get_C4(Info);}
+ inline void Get_C5 (int64u &Info, const char*) {Get_C5(Info);}
+ inline void Get_C6 (int64u &Info, const char*) {Get_C6(Info);}
+ inline void Get_C7 (int64u &Info, const char*) {Get_C7(Info);}
+ inline void Get_C8 (int64u &Info, const char*) {Get_C8(Info);}
+ inline void Skip_C1( const char*) {if (Element_Offset+1>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=1;}
+ inline void Skip_C2( const char*) {if (Element_Offset+2>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=2;}
+ inline void Skip_C3( const char*) {if (Element_Offset+3>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=3;}
+ inline void Skip_C4( const char*) {if (Element_Offset+4>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=4;}
+ inline void Skip_C5( const char*) {if (Element_Offset+5>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=5;}
+ inline void Skip_C6( const char*) {if (Element_Offset+6>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=6;}
+ inline void Skip_C7( const char*) {if (Element_Offset+7>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=7;}
+ inline void Skip_C8( const char*) {if (Element_Offset+8>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=8;}
+ #define Info_C1(_INFO, _NAME) int8u _INFO; Get_C1(_INFO, _NAME)
+ #define Info_C2(_INFO, _NAME) int16u _INFO; Get_C2(_INFO, _NAME)
+ #define Info_C3(_INFO, _NAME) int32u _INFO; Get_C3(_INFO, _NAME)
+ #define Info_C4(_INFO, _NAME) int32u _INFO; Get_C4(_INFO, _NAME)
+ #define Info_C5(_INFO, _NAME) int64u _INFO; Get_C5(_INFO, _NAME)
+ #define Info_C6(_INFO, _NAME) int64u _INFO; Get_C6(_INFO, _NAME)
+ #define Info_C7(_INFO, _NAME) int64u _INFO; Get_C7(_INFO, _NAME)
+ #define Info_C8(_INFO, _NAME) int64u _INFO; Get_C8(_INFO, _NAME)
+
+ //***************************************************************************
+ // Text
+ //***************************************************************************
+
+ void Get_Local (int64u Bytes, Ztring &Info);
+ void Get_ISO_8859_1 (int64u Bytes, Ztring &Info);
+ void Get_ISO_8859_2 (int64u Bytes, Ztring &Info);
+ void Get_String (int64u Bytes, std::string &Info);
+ void Get_UTF8 (int64u Bytes, Ztring &Info);
+ void Get_UTF16 (int64u Bytes, Ztring &Info);
+ void Get_UTF16B (int64u Bytes, Ztring &Info);
+ void Get_UTF16L (int64u Bytes, Ztring &Info);
+ inline void Get_Local (int64u Bytes, Ztring &Info, const char*) {Get_Local(Bytes, Info);}
+ inline void Get_ISO_8859_1 (int64u Bytes, Ztring &Info, const char*) {Get_ISO_8859_1(Bytes, Info);}
+ inline void Get_ISO_8859_2 (int64u Bytes, Ztring &Info, const char*) {Get_ISO_8859_2(Bytes, Info);}
+ inline void Get_String (int64u Bytes, std::string &Info, const char*) {Get_String(Bytes, Info);}
+ inline void Get_UTF8 (int64u Bytes, Ztring &Info, const char*) {Get_UTF8(Bytes, Info);}
+ inline void Get_UTF16 (int64u Bytes, Ztring &Info, const char*) {Get_UTF16(Bytes, Info);}
+ inline void Get_UTF16B (int64u Bytes, Ztring &Info, const char*) {Get_UTF16B(Bytes, Info);}
+ inline void Get_UTF16L (int64u Bytes, Ztring &Info, const char*) {Get_UTF16L(Bytes, Info);}
+ void Peek_Local (int64u Bytes, Ztring &Info);
+ void Peek_String(int64u Bytes, std::string &Info);
+ void Skip_Local (int64u Bytes, const char*) {if (Element_Offset+Bytes>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=(size_t)Bytes;}
+ void Skip_String(int64u Bytes, const char*) {if (Element_Offset+Bytes>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=(size_t)Bytes;}
+ void Skip_UTF8 (int64u Bytes, const char*) {if (Element_Offset+Bytes>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=(size_t)Bytes;}
+ void Skip_UTF16B(int64u Bytes, const char*) {if (Element_Offset+Bytes>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=(size_t)Bytes;}
+ void Skip_UTF16L(int64u Bytes, const char*) {if (Element_Offset+Bytes>Element_Size) {Trusted_IsNot(); return;} Element_Offset+=(size_t)Bytes;}
+ #define Info_Local(_BYTES, _INFO, _NAME) Ztring _INFO; Get_Local (_BYTES, _INFO, _NAME)
+ #define Info_UTF8(_BYTES, _INFO, _NAME) Ztring _INFO; Get_UTF8 (_BYTES, _INFO, _NAME)
+ #define Info_UTF16B(_BYTES, _INFO, _NAME) Ztring _INFO; Get_UTF16B(_BYTES, _INFO, _NAME)
+ #define Info_UTF16L(_BYTES, _INFO, _NAME) Ztring _INFO; Get_UTF16L(_BYTES, _INFO, _NAME)
+
+ //***************************************************************************
+ // Pascal strings
+ //***************************************************************************
+
+ void Get_PA (std::string &Info);
+ inline void Get_PA (std::string &Info, const char*) {Get_PA(Info);}
+ void Peek_PA(std::string &Info);
+ void Skip_PA();
+ inline void Skip_PA( const char*) {Skip_PA();}
+ #define Info_PA(_INFO, _NAME) Ztring _INFO; Get_PA (_INFO, _NAME)
+
+ //***************************************************************************
+ // Unknown
+ //***************************************************************************
+
+ inline void Skip_XX(int64u Bytes, const char*) {if (Element_Offset+Bytes>Element_Size) {Element_Offset=Element_Size; return;} Element_Offset+=Bytes;}
+
+ //***************************************************************************
+ // Flags
+ //***************************************************************************
+
+ void Get_Flags_ (int64u Flags, size_t Order, bool &Info);
+ void Get_FlagsM_ (int64u ValueToPut, int8u &Info); //Multiple
+ #define Get_Flags(_FLAGS, _ORDER, _INFO, _NAME) Get_Flags_(_FLAGS, _ORDER, _INFO)
+ #define Get_FlagsM(_VALUE, _INFO, _NAME) Get_FlagsM_(_VALUE, _INFO)
+ #define Skip_Flags(_FLAGS, _ORDER, _NAME)
+ #define Skip_FlagsM(_VALUE, _NAME)
+ #define Info_Flags(_FLAGS, _ORDER, _INFO, _NAME)
+
+ //***************************************************************************
+ // BitStream
+ //***************************************************************************
+
+ void Get_BS_ (int8u Bits, int32u &Info);
+ void Get_SB_ ( bool &Info);
+ bool Get_SB_ () {return BS->GetB();}
+ void Get_S1_ (int8u Bits, int8u &Info);
+ void Get_S2_ (int8u Bits, int16u &Info);
+ void Get_S3_ (int8u Bits, int32u &Info);
+ void Get_S4_ (int8u Bits, int32u &Info);
+ void Get_S5_ (int8u Bits, int64u &Info);
+ void Get_S6_ (int8u Bits, int64u &Info);
+ void Get_S7_ (int8u Bits, int64u &Info);
+ void Get_S8_ (int8u Bits, int64u &Info);
+ #define Get_BS(Bits, Info, Name) Get_BS_(Bits, Info)
+ #define Get_SB( Info, Name) Get_SB_( Info)
+ #define Get_S1(Bits, Info, Name) Get_S1_(Bits, Info)
+ #define Get_S2(Bits, Info, Name) Get_S2_(Bits, Info)
+ #define Get_S3(Bits, Info, Name) Get_S3_(Bits, Info)
+ #define Get_S4(Bits, Info, Name) Get_S4_(Bits, Info)
+ #define Get_S5(Bits, Info, Name) Get_S5_(Bits, Info)
+ #define Get_S6(Bits, Info, Name) Get_S6_(Bits, Info)
+ #define Get_S7(Bits, Info, Name) Get_S7_(Bits, Info)
+ #define Get_S8(Bits, Info, Name) Get_S8_(Bits, Info)
+ void Peek_BS(int8u Bits, int32u &Info);
+ void Peek_SB( bool &Info);
+ bool Peek_SB() {return BS->PeekB();}
+ void Peek_S1(int8u Bits, int8u &Info);
+ void Peek_S2(int8u Bits, int16u &Info);
+ void Peek_S3(int8u Bits, int32u &Info);
+ void Peek_S4(int8u Bits, int32u &Info);
+ void Peek_S5(int8u Bits, int64u &Info);
+ void Peek_S6(int8u Bits, int64u &Info);
+ void Peek_S7(int8u Bits, int64u &Info);
+ void Peek_S8(int8u Bits, int64u &Info);
+ inline void Skip_BS_(size_t Bits) {BS->Skip(Bits);}
+ inline void Skip_SB_( ) {BS->Skip(1);}
+ inline void Skip_S1_(int8u Bits) {BS->Skip(Bits);}
+ inline void Skip_S2_(int8u Bits) {BS->Skip(Bits);}
+ inline void Skip_S3_(int8u Bits) {BS->Skip(Bits);}
+ inline void Skip_S4_(int8u Bits) {BS->Skip(Bits);}
+ inline void Skip_S5_(int8u Bits) {BS->Skip(Bits);}
+ inline void Skip_S6_(int8u Bits) {BS->Skip(Bits);}
+ inline void Skip_S7_(int8u Bits) {BS->Skip(Bits);}
+ inline void Skip_S8_(int8u Bits) {BS->Skip(Bits);}
+ #define Skip_BS(Bits, Name) Skip_BS_(Bits)
+ #define Skip_SB( Name) Skip_SB_()
+ #define Skip_S1(Bits, Name) Skip_S1_(Bits)
+ #define Skip_S2(Bits, Name) Skip_S2_(Bits)
+ #define Skip_S3(Bits, Name) Skip_S3_(Bits)
+ #define Skip_S4(Bits, Name) Skip_S4_(Bits)
+ #define Skip_S5(Bits, Name) Skip_S5_(Bits)
+ #define Skip_S6(Bits, Name) Skip_S6_(Bits)
+ #define Skip_S7(Bits, Name) Skip_S7_(Bits)
+ #define Skip_S8(Bits, Name) Skip_S8_(Bits)
+ void Mark_0 ();
+ #define Mark_0_NoTrustError() Skip_SB_() //Use it for providing a warning instead of a non-trusting error
+ void Mark_1 ();
+ #define Mark_1_NoTrustError() Skip_SB_() //Use it for providing a warning instead of a non-trusting error
+ #define Info_BS(_BITS, _INFO, _NAME) Skip_BS_(_BITS)
+ #define Info_SB(_INFO, _NAME) Skip_SB_( )
+ #define Info_S1(_BITS, _INFO, _NAME) Skip_S1_(_BITS)
+ #define Info_S2(_BITS, _INFO, _NAME) Skip_S2_(_BITS)
+ #define Info_S3(_BITS, _INFO, _NAME) Skip_S3_(_BITS)
+ #define Info_S4(_BITS, _INFO, _NAME) Skip_S4_(_BITS)
+ #define Info_S5(_BITS, _INFO, _NAME) Skip_S5_(_BITS)
+ #define Info_S6(_BITS, _INFO, _NAME) Skip_S6_(_BITS)
+ #define Info_S7(_BITS, _INFO, _NAME) Skip_S7_(_BITS)
+ #define Info_S8(_BITS, _INFO, _NAME) Skip_S8_(_BITS)
+
+ #define TEST_SB_GET(_CODE, _NAME) \
+ { \
+ Peek_SB(_CODE); \
+ if (!_CODE) \
+ Skip_SB_(); \
+ else \
+ { \
+ Element_Begin0(); \
+ Skip_SB_(); \
+
+ #define TEST_SB_SKIP(_NAME) \
+ { \
+ if (!Peek_SB()) \
+ Skip_SB_(); \
+ else \
+ { \
+ Element_Begin0(); \
+ Skip_SB_(); \
+
+ #define TESTELSE_SB_GET(_CODE, _NAME) \
+ { \
+ Peek_SB(_CODE); \
+ if (_CODE) \
+ { \
+ Element_Begin0(); \
+ Skip_SB_(); \
+
+ #define TESTELSE_SB_SKIP(_NAME) \
+ { \
+ if (Peek_SB()) \
+ { \
+ Element_Begin0(); \
+ Skip_SB_(); \
+
+ #define TESTELSE_SB_ELSE(_NAME) \
+ Element_End0(); \
+ } \
+ else \
+ { \
+ Skip_SB_(); \
+
+ #define TESTELSE_SB_END() \
+ } \
+ } \
+
+ #define TEST_SB_END() \
+ Element_End0(); \
+ } \
+ } \
+
+ //***************************************************************************
+ // BitStream (Little Endian)
+ //***************************************************************************
+
+ void Get_BT_ (int8u Bits, int32u &Info);
+ void Get_TB_ ( bool &Info);
+ bool Get_TB_ () {bool Temp; Get_TB_(Temp); return Temp;}
+ void Get_T1_ (int8u Bits, int8u &Info);
+ void Get_T2_ (int8u Bits, int16u &Info);
+ void Get_T3_ (int8u Bits, int32u &Info);
+ void Get_T4_ (int8u Bits, int32u &Info);
+ void Get_T5_ (int8u Bits, int64u &Info);
+ void Get_T6_ (int8u Bits, int64u &Info);
+ void Get_T7_ (int8u Bits, int64u &Info);
+ void Get_T8_ (int8u Bits, int64u &Info);
+ #define Get_BT(Bits, Info, Name) Get_BT_(Bits, Info)
+ #define Get_TB( Info, Name) Get_TB_( Info)
+ #define Get_T1(Bits, Info, Name) Get_T1_(Bits, Info)
+ #define Get_T2(Bits, Info, Name) Get_T2_(Bits, Info)
+ #define Get_T3(Bits, Info, Name) Get_T3_(Bits, Info)
+ #define Get_T4(Bits, Info, Name) Get_T4_(Bits, Info)
+ #define Get_T5(Bits, Info, Name) Get_T5_(Bits, Info)
+ #define Get_T6(Bits, Info, Name) Get_T6_(Bits, Info)
+ #define Get_T7(Bits, Info, Name) Get_T7_(Bits, Info)
+ #define Get_T8(Bits, Info, Name) Get_T8_(Bits, Info)
+ void Peek_BT(int8u Bits, int32u &Info);
+ void Peek_TB( bool &Info);
+ bool Peek_TB() {bool Temp; Peek_TB(Temp); return Temp;}
+ void Peek_T1(int8u Bits, int8u &Info);
+ void Peek_T2(int8u Bits, int16u &Info);
+ void Peek_T3(int8u Bits, int32u &Info);
+ void Peek_T4(int8u Bits, int32u &Info);
+ void Peek_T5(int8u Bits, int64u &Info);
+ void Peek_T6(int8u Bits, int64u &Info);
+ void Peek_T7(int8u Bits, int64u &Info);
+ void Peek_T8(int8u Bits, int64u &Info);
+ inline void Skip_BT_(size_t Bits) {BT->Skip(Bits);}
+ inline void Skip_TB_( ) {BT->SkipB();}
+ inline void Skip_T1_(int8u Bits) {BT->Skip1(Bits);}
+ inline void Skip_T2_(int8u Bits) {BT->Skip2(Bits);}
+ inline void Skip_T3_(int8u Bits) {BT->Skip4(Bits);}
+ inline void Skip_T4_(int8u Bits) {BT->Skip4(Bits);}
+ inline void Skip_T5_(int8u Bits) {BT->Skip8(Bits);}
+ inline void Skip_T6_(int8u Bits) {BT->Skip8(Bits);}
+ inline void Skip_T7_(int8u Bits) {BT->Skip8(Bits);}
+ inline void Skip_T8_(int8u Bits) {BT->Skip8(Bits);}
+ #define Skip_BT(Bits, Name) Skip_BT_(Bits)
+ #define Skip_TB( Name) Skip_TB_()
+ #define Skip_T1(Bits, Name) Skip_T1_(Bits)
+ #define Skip_T2(Bits, Name) Skip_T2_(Bits)
+ #define Skip_T3(Bits, Name) Skip_T3_(Bits)
+ #define Skip_T4(Bits, Name) Skip_T4_(Bits)
+ #define Skip_T5(Bits, Name) Skip_T5_(Bits)
+ #define Skip_T6(Bits, Name) Skip_T6_(Bits)
+ #define Skip_T7(Bits, Name) Skip_T7_(Bits)
+ #define Skip_T8(Bits, Name) Skip_T8_(Bits)
+ #define Info_BT(_BITS, _INFO, _NAME) Skip_BT_(_BITS)
+ #define Info_TB(_INFO, _NAME) Skip_TB_( )
+ #define Info_T1(_BITS, _INFO, _NAME) Skip_T1_(_BITS)
+ #define Info_T2(_BITS, _INFO, _NAME) Skip_T2_(_BITS)
+ #define Info_T3(_BITS, _INFO, _NAME) Skip_T3_(_BITS)
+ #define Info_T4(_BITS, _INFO, _NAME) Skip_T4_(_BITS)
+ #define Info_T5(_BITS, _INFO, _NAME) Skip_T5_(_BITS)
+ #define Info_T6(_BITS, _INFO, _NAME) Skip_T6_(_BITS)
+ #define Info_T7(_BITS, _INFO, _NAME) Skip_T7_(_BITS)
+ #define Info_T8(_BITS, _INFO, _NAME) Skip_T8_(_BITS)
+
+ #define TEST_TB_GET(_CODE, _NAME) \
+ { \
+ Peek_TB(_CODE); \
+ if (!_CODE) \
+ Skip_TB_(); \
+ else \
+ { \
+ Element_Begin0(); \
+ Skip_TB_(); \
+
+ #define TEST_TB_TKIP(_NAME) \
+ { \
+ if (!Peek_TB()) \
+ Skip_TB_(); \
+ else \
+ { \
+ Element_Begin0(); \
+ Skip_TB_(); \
+
+ #define TESTELSE_TB_GET(_CODE, _NAME) \
+ { \
+ Peek_TB(_CODE); \
+ if (_CODE) \
+ { \
+ Element_Begin0(); \
+ Skip_TB_(); \
+
+ #define TESTELSE_TB_TKIP(_NAME) \
+ { \
+ if (Peek_TB()) \
+ { \
+ Element_Begin0(); \
+ Skip_TB_(); \
+
+ #define TESTELSE_TB_ELSE(_NAME) \
+ Element_End0(); \
+ } \
+ else \
+ { \
+ Skip_TB_(); \
+
+ #define TESTELSE_TB_END() \
+ } \
+ } \
+
+ #define TEST_TB_END() \
+ Element_End0(); \
+ } \
+ } \
+
+ //***************************************************************************
+ // Next code planning
+ //***************************************************************************
+
+ void NextCode_Add(int64u Code);
+ void NextCode_Clear();
+ bool NextCode_Test();
+
+ //***************************************************************************
+ // Element trusting
+ //***************************************************************************
+
+ void Trusted_IsNot (const char*) {Trusted_IsNot();}
+ void Trusted_IsNot ();
+
+ //***************************************************************************
+ // Stream filling
+ //***************************************************************************
+
+ //Elements - Preparation of element from external app
+ size_t Stream_Prepare (stream_t KindOfStream, size_t StreamPos=(size_t)-1);
+ size_t Stream_Erase (stream_t KindOfStream, size_t StreamPos);
+
+ //Fill with datas (with parameter as a size_t)
+ void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, const Ztring &Value, bool Replace=false);
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, const std::string &Value, bool Utf8=true, bool Replace=false) {if (Utf8) Fill(StreamKind, StreamPos, Parameter, Ztring().From_UTF8(Value.c_str(), Value.size()), Replace); else Fill(StreamKind, StreamPos, Parameter, Ztring().From_Local(Value.c_str(), Value.size()), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, const char* Value, size_t Value_Size=Unlimited, bool Utf8=true, bool Replace=false) {if (Utf8) Fill(StreamKind, StreamPos, Parameter, Ztring().From_UTF8(Value, Value_Size), Replace); else Fill(StreamKind, StreamPos, Parameter, Ztring().From_Local(Value, Value_Size), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, const wchar_t* Value, size_t Value_Size=Unlimited, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring().From_Unicode(Value, Value_Size), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int8u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int8s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int16u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int16s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int32u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int32s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int64u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, int64s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, float32 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, float64 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, float80 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ #ifdef SIZE_T_IS_LONG
+ inline void Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, size_t Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ #endif //SIZE_T_IS_LONG
+ //Fill with datas
+ void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, const Ztring &Value, bool Replace=false);
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, const std::string &Value, bool Utf8=true, bool Replace=false) {if (Utf8) Fill(StreamKind, StreamPos, Parameter, Ztring().From_UTF8(Value.c_str(), Value.size())); else Fill(StreamKind, StreamPos, Parameter, Ztring().From_Local(Value.c_str(), Value.size()), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, const char* Value, size_t Value_Size=Unlimited, bool Utf8=true, bool Replace=false) {if (Utf8) Fill(StreamKind, StreamPos, Parameter, Ztring().From_UTF8(Value, Value_Size), Replace); else Fill(StreamKind, StreamPos, Parameter, Ztring().From_Local(Value, Value_Size), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, const wchar_t* Value, size_t Value_Size=Unlimited, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring().From_Unicode(Value, Value_Size), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int8u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int8s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int16u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int16s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int32u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int32s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int64u Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, int64s Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, float32 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, float64 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, float80 Value, int8u AfterComma=3, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, AfterComma), Replace);}
+ #ifdef SIZE_T_IS_LONG
+ inline void Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, size_t Value, int8u Radix=10, bool Replace=false) {Fill(StreamKind, StreamPos, Parameter, Ztring::ToZtring(Value, Radix).MakeUpperCase(), Replace);}
+ #endif //SIZE_T_IS_LONG
+ ZtringListList Fill_Temp;
+ void Fill_Flush ();
+ size_t Fill_Parameter(stream_t StreamKind, generic StreamPos);
+
+ const Ztring &Retrieve_Const (stream_t StreamKind, size_t StreamPos, size_t Parameter, info_t KindOfInfo=Info_Text);
+ Ztring Retrieve (stream_t StreamKind, size_t StreamPos, size_t Parameter, info_t KindOfInfo=Info_Text);
+ const Ztring &Retrieve_Const (stream_t StreamKind, size_t StreamPos, const char* Parameter, info_t KindOfInfo=Info_Text);
+ Ztring Retrieve (stream_t StreamKind, size_t StreamPos, const char* Parameter, info_t KindOfInfo=Info_Text);
+
+ void Clear (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void Clear (stream_t StreamKind, size_t StreamPos, const char* Parameter);
+ void Clear (stream_t StreamKind, size_t StreamPos);
+ void Clear (stream_t StreamKind);
+ inline void Clear () {File__Base::Clear();}
+
+ //***************************************************************************
+ // Filling
+ //***************************************************************************
+
+ //Actions
+ void Accept (const char*) {Accept();}
+ void Accept ();
+ void Accept (File__Analyze* Parser);
+ void Reject (const char*) {Reject();}
+ void Reject ();
+ void Reject (File__Analyze* Parser);
+ void Fill (const char*) {Fill();}
+ void Fill ();
+ void Fill (File__Analyze* Parser);
+ void Update (const char*) {Fill();}
+ void Update ();
+ void Update (File__Analyze* Parser);
+ void Finish (const char*) {Finish();}
+ void Finish ();
+ void Finish (File__Analyze* Parser);
+ void ForceFinish (const char*) {ForceFinish();}
+ void ForceFinish ();
+ void ForceFinish (File__Analyze* Parser);
+ void GoTo (int64u GoTo_, const char*) {GoTo(GoTo_);}
+ void GoTo (int64u GoTo);
+ void GoToFromEnd (int64u GoToFromEnd_, const char*) {GoToFromEnd(GoToFromEnd_);}
+ void GoToFromEnd (int64u GoToFromEnd);
+ int64u Element_Code_Get (size_t Level);
+ int64u Element_TotalSize_Get (size_t LevelLess=0);
+ bool Element_IsComplete_Get ();
+ void Element_ThisIsAList ();
+ void Element_WaitForMoreData ();
+ void Element_DoNotTrust (const char*) {Element_DoNotTrust();}
+ void Element_DoNotTrust ();
+ inline void Element_DoNotShow () {}
+ inline void Element_Show () {}
+ inline bool Element_Show_Get () {return false;}
+ inline void Element_Show_Add (const Ztring &) {}
+
+ //Status
+ bool Element_IsOK ();
+ bool Element_IsNotFinished ();
+ bool Element_IsWaitingForMoreData ();
+
+ //Begin
+ #define FILLING_BEGIN() \
+ if (Element_IsOK()) \
+ {
+
+ #define FILLING_BEGIN_PRECISE() \
+ if (Element_Offset!=Element_Size) \
+ Trusted_IsNot("Size error"); \
+ else if (Element_IsOK()) \
+ {
+
+ //Else
+ #define FILLING_ELSE() \
+ } \
+ else \
+ { \
+
+ //End
+ #define FILLING_END() \
+ }
+
+ //***************************************************************************
+ // Merging
+ //***************************************************************************
+
+ //Utils
+public :
+ size_t Merge(MediaInfo_Internal &ToAdd, bool Erase=true); //Merge 2 File_Base
+ size_t Merge(MediaInfo_Internal &ToAdd, stream_t StreamKind, size_t StreamPos_From, size_t StreamPos_To, bool Erase=true); //Merge 2 streams
+ size_t Merge(File__Analyze &ToAdd, bool Erase=true); //Merge 2 File_Base
+ size_t Merge(File__Analyze &ToAdd, stream_t StreamKind, size_t StreamPos_From, size_t StreamPos_To, bool Erase=true); //Merge 2 streams
+
+ //***************************************************************************
+ // Finalize
+ //***************************************************************************
+
+ //End
+ void Streams_Finish_Global();
+
+protected :
+ void Streams_Finish_StreamOnly();
+ void Streams_Finish_StreamOnly(stream_t StreamKid, size_t StreamPos);
+ void Streams_Finish_StreamOnly_General(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Video(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Audio(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Text(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Chapters(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Image(size_t StreamPos);
+ void Streams_Finish_StreamOnly_Menu(size_t StreamPos);
+ void Streams_Finish_InterStreams();
+ void Streams_Finish_Cosmetic();
+ void Streams_Finish_Cosmetic(stream_t StreamKid, size_t StreamPos);
+ void Streams_Finish_Cosmetic_General(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Video(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Audio(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Text(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Chapters(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Image(size_t StreamPos);
+ void Streams_Finish_Cosmetic_Menu(size_t StreamPos);
+
+ void Tags ();
+ void Video_FrameRate_Rounding (size_t Pos, video Parameter);
+ void Video_BitRate_Rounding (size_t Pos, video Parameter);
+ void Audio_BitRate_Rounding (size_t Pos, audio Parameter);
+
+ //Utils - Finalize
+ void Duration_Duration123 (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void FileSize_FileSize123 (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void Kilo_Kilo123 (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void Value_Value123 (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void YesNo_YesNo (stream_t StreamKind, size_t StreamPos, size_t Parameter);
+ void CodecID_Fill (const Ztring &Value, stream_t StreamKind, size_t StreamPos, infocodecid_format_t Format);
+
+ //***************************************************************************
+ //
+ //***************************************************************************
+
+protected :
+ //Save for speed improvement
+ float Config_ParseSpeed;
+ int8u Config_Demux;
+ Ztring Config_LineSeparator;
+ bool IsSub;
+ bool IsRawStream;
+
+ //Configuration
+ bool DataMustAlwaysBeComplete; //Data must always be complete, else wait for more data
+ bool MustUseAlternativeParser; //Must use the second parser (example: for Data part)
+
+ //Synchro
+ bool MustParseTheHeaderFile; //There is an header part, must parse it
+ size_t Trusted;
+ size_t Trusted_Multiplier;
+
+ //Elements
+ size_t Element_Level; //Current level
+ bool Element_WantNextLevel; //Want to go to the next leavel instead of the same level
+
+ //Element
+ int64u Element_Code; //Code filled in the file, copy of Element[Element_Level].Code
+ int64u Element_Offset; //Position in the Element (without header)
+ int64u Element_Size; //Size of the Element (without header)
+
+private :
+ //***************************************************************************
+ // Buffer
+ //***************************************************************************
+
+ void Buffer_Clear(); //Clear the buffer
+ bool Open_Buffer_Continue_Loop();
+protected :
+ //Buffer
+ const int8u* Buffer;
+public : //TO CHANGE
+ size_t Buffer_Size;
+ int64u Buffer_TotalBytes;
+ int64u Buffer_TotalBytes_FirstSynched;
+ int64u Buffer_PaddingBytes;
+ float64 Stream_BitRateFromContainer;
+protected :
+ int8u* Buffer_Temp;
+ size_t Buffer_Temp_Size;
+ size_t Buffer_Temp_Size_Max;
+ size_t Buffer_Offset; //Temporary usage in this parser
+ size_t Buffer_Offset_Temp; //Temporary usage in this parser
+ size_t Buffer_MinimumSize;
+ size_t Buffer_MaximumSize;
+ int64u Buffer_TotalBytes_FirstSynched_Max;
+ int64u Buffer_TotalBytes_Fill_Max;
+ friend class File__Tags_Helper;
+
+ //***************************************************************************
+ // Helpers
+ //***************************************************************************
+
+ bool FileHeader_Begin_0x000001();
+ bool FileHeader_Begin_XML(tinyxml2::XMLDocument &Document);
+ bool Synchronize_0x000001();
+public:
+ static void Streams_Accept_TestContinuousFileNames_Static(ZtringList &File_Names, bool IsReferenced);
+protected:
+ void Streams_Accept_TestContinuousFileNames();
+
+private :
+
+ //***************************************************************************
+ // Elements
+ //***************************************************************************
+
+ //Element
+ BitStream_Fast* BS; //For conversion from bytes to bitstream
+ BitStream* BT; //For conversion from bytes to bitstream (Little Endian)
+public : //TO CHANGE
+ int64u Header_Size; //Size of the header of the current element
+private :
+
+ //Elements
+ size_t Element_Level_Base; //From other parsers
+
+public : //For very quick access, to not use except if you know what you do
+ struct element_details
+ {
+ int64u Code; //Code filled in the file
+ int64u Next; //
+ bool WaitForMoreData; //This element is not complete, we need more data
+ bool UnTrusted; //This element has a problem
+ bool IsComplete; //This element is fully buffered, no need of more
+ };
+ std::vector<element_details> Element;
+
+private :
+
+ //NextCode
+ std::map<int64u, bool> NextCode;
+
+ //BookMarks
+ size_t BookMark_Element_Level;
+ int64u BookMark_GoTo;
+ std::vector<int64u> BookMark_Code;
+ std::vector<int64u> BookMark_Next;
+
+public :
+ void BookMark_Set(size_t Element_Level_ToGet=(size_t)-1);
+ void BookMark_Get();
+ virtual bool BookMark_Needed() {return false;};
+
+ //Temp
+ std::bitset<32> Status;
+ enum status
+ {
+ IsAccepted,
+ IsFilled,
+ IsUpdated,
+ IsFinished,
+ Reserved_04,
+ Reserved_05,
+ Reserved_06,
+ Reserved_07,
+ Reserved_08,
+ Reserved_09,
+ Reserved_10,
+ Reserved_11,
+ Reserved_12,
+ Reserved_13,
+ Reserved_14,
+ Reserved_15,
+ User_16,
+ User_17,
+ User_18,
+ User_19,
+ User_20,
+ User_21,
+ User_22,
+ User_23,
+ User_24,
+ User_25,
+ User_26,
+ User_27,
+ User_28,
+ User_29,
+ User_30,
+ User_31,
+ };
+ bool ShouldContinueParsing;
+
+ //Configuration
+ bool MustSynchronize;
+
+ //Demux
+ enum contenttype
+ {
+ ContentType_MainStream,
+ ContentType_SubStream,
+ ContentType_Header,
+ ContentType_Synchro
+ };
+ #if MEDIAINFO_DEMUX
+ void Demux (const int8u* Buffer, size_t Buffer_Size, contenttype ContentType);
+ virtual bool Demux_UnpacketizeContainer_Test() {return true;}
+ bool Demux_UnpacketizeContainer_Test_OneFramePerFile();
+ void Demux_UnpacketizeContainer_Demux(bool random_access=true);
+ void Demux_UnpacketizeContainer_Demux_Clear();
+ bool Demux_EventWasSent_Accept_Specific;
+ #else //MEDIAINFO_DEMUX
+ #define Demux(_A, _B, _C)
+ #endif //MEDIAINFO_DEMUX
+
+ //Events data
+ bool PES_FirstByte_IsAvailable;
+ bool PES_FirstByte_Value;
+
+ int64u Unsynch_Frame_Count;
+
+ #if MEDIAINFO_SEEK
+ private:
+ bool Seek_Duration_Detected;
+ #endif //MEDIAINFO_SEEK
+
+ #if MEDIAINFO_IBI
+ public:
+ bool Config_Ibi_Create;
+ int64u Ibi_SynchronizationOffset_Current;
+ int64u Ibi_SynchronizationOffset_BeginOfFrame;
+ ibi::stream* IbiStream;
+ size_t Ibi_Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ void Ibi_Read_Buffer_Unsynched ();
+ void Ibi_Stream_Finish ();
+ void Ibi_Stream_Finish (int64u Numerator, int64u Denominator); //Partial
+ void Ibi_Add ();
+ #else //MEDIAINFO_IBI
+ size_t Ibi_Read_Buffer_Seek (size_t, int64u, int64u) {return (size_t)-1;}
+ void Ibi_Read_Buffer_Unsynched () {}
+ void Ibi_Stream_Finish () {}
+ void Ibi_Stream_Finish (int64u, int64u) {}
+ void Ibi_Add () {}
+ #endif //MEDIAINFO_IBI
+};
+
+//Helpers
+#define DETAILS_INFO(_DATA)
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Streams.cpp b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Streams.cpp
new file mode 100644
index 000000000..e828714be
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Streams.cpp
@@ -0,0 +1,2533 @@
+// File__Analyze - Base for analyze files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "ZenLib/File.h"
+#include "ZenLib/FileName.h"
+#include "ZenLib/BitStream_LE.h"
+#include <cmath>
+#ifdef SS
+ #undef SS //Solaris defines this somewhere
+#endif
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Preparation des streams
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t File__Analyze::Stream_Prepare (stream_t KindOfStream, size_t StreamPos)
+{
+ //Integrity
+ if (!Status[IsAccepted] || KindOfStream>Stream_Max)
+ return Error;
+
+ //Clear
+ if (KindOfStream==Stream_Max)
+ {
+ StreamKind_Last=Stream_Max;
+ StreamPos_Last=(size_t)-1;
+ return 0;
+ }
+
+ if (StreamPos>=Count_Get(KindOfStream))
+ {
+ //Add a stream
+ (*Stream)[KindOfStream].resize((*Stream)[KindOfStream].size()+1);
+ (*Stream_More)[KindOfStream].resize((*Stream_More)[KindOfStream].size()+1);
+ StreamKind_Last=KindOfStream;
+ StreamPos_Last=(*Stream)[KindOfStream].size()-1;
+ }
+ else
+ {
+ //Insert a stream
+ (*Stream)[KindOfStream].insert((*Stream)[KindOfStream].begin()+StreamPos, ZtringList());
+ (*Stream_More)[KindOfStream].insert((*Stream_More)[KindOfStream].begin()+StreamPos, ZtringListList());
+ StreamKind_Last=KindOfStream;
+ StreamPos_Last=StreamPos;
+ }
+
+ //Filling basic info
+ Fill(StreamKind_Last, StreamPos_Last, (size_t)General_Count, Count_Get(StreamKind_Last, StreamPos_Last));
+ Fill(StreamKind_Last, StreamPos_Last, General_StreamKind, MediaInfoLib::Config.Info_Get(StreamKind_Last).Read(General_StreamKind, Info_Text));
+ Fill(StreamKind_Last, StreamPos_Last, General_StreamKind_String, MediaInfoLib::Config.Language_Get(MediaInfoLib::Config.Info_Get(StreamKind_Last).Read(General_StreamKind, Info_Text)), true);
+ for (size_t Pos=0; Pos<Count_Get(KindOfStream); Pos++)
+ {
+ Fill(StreamKind_Last, Pos, General_StreamCount, Count_Get(StreamKind_Last), 10, true);
+ Fill(StreamKind_Last, Pos, General_StreamKindID, Pos, 10, true);
+ if (Count_Get(StreamKind_Last)>1)
+ Fill(StreamKind_Last, Pos, General_StreamKindPos, Pos+1, 10, true);
+ }
+
+ //Filling Lists & Counts
+ if (!IsSub && KindOfStream!=Stream_General)
+ {
+ const Ztring& StreamKind_Text=Get(KindOfStream, 0, General_StreamKind, Info_Text);
+ if (Count_Get(KindOfStream)>1)
+ {
+ ZtringList Temp; Temp.Separator_Set(0, _T(" / "));
+ Temp.Write(Retrieve(Stream_General, 0, Ztring(StreamKind_Text+_T("_Codec_List")).To_Local().c_str()));
+ if (StreamPos<Temp.size())
+ Temp.insert(Temp.begin()+StreamPos, Ztring());
+ else
+ Temp.push_back(Ztring());
+ Fill(Stream_General, 0, Ztring(StreamKind_Text+_T("_Codec_List")).To_Local().c_str(), Temp.Read(), true);
+ Temp.Write(Retrieve(Stream_General, 0, Ztring(StreamKind_Text+_T("_Language_List")).To_Local().c_str()));
+ if (StreamPos<Temp.size())
+ Temp.insert(Temp.begin()+StreamPos, Ztring());
+ else
+ Temp.push_back(Ztring());
+ Fill(Stream_General, 0, Ztring(StreamKind_Text+_T("_Language_List")).To_Local().c_str(), Temp.Read(), true);
+ Temp.Write(Retrieve(Stream_General, 0, Ztring(StreamKind_Text+_T("_Format_List")).To_Local().c_str()));
+ if (StreamPos<Temp.size())
+ Temp.insert(Temp.begin()+StreamPos, Ztring());
+ else
+ Temp.push_back(Ztring());
+ Fill(Stream_General, 0, Ztring(StreamKind_Text+_T("_Format_List")).To_Local().c_str(), Temp.Read(), true);
+ Temp.Write(Retrieve(Stream_General, 0, Ztring(StreamKind_Text+_T("_Format_WithHint_List")).To_Local().c_str()));
+ if (StreamPos<Temp.size())
+ Temp.insert(Temp.begin()+StreamPos, Ztring());
+ else
+ Temp.push_back(Ztring());
+ Fill(Stream_General, 0, Ztring(StreamKind_Text+_T("_Format_WithHint_List")).To_Local().c_str(), Temp.Read(), true);
+ }
+
+ Fill(Stream_General, 0, Ztring(StreamKind_Text+_T("Count")).To_Local().c_str(), Count_Get(KindOfStream), 10, true);
+ }
+
+ //File name and dates
+ if (!IsSub && KindOfStream==Stream_General && File_Name.size()>0)
+ {
+ //File name
+ if (File_Name.find(_T("://"))==string::npos)
+ {
+ Fill (Stream_General, 0, General_CompleteName, File_Name);
+ Fill (Stream_General, 0, General_FolderName, FileName::Path_Get(File_Name));
+ Fill (Stream_General, 0, General_FileName, FileName::Name_Get(File_Name));
+ Fill (Stream_General, 0, General_FileExtension, FileName::Extension_Get(File_Name).MakeLowerCase());
+ }
+ else
+ {
+ Ztring FileName_Modified=File_Name;
+ size_t Begin=FileName_Modified.find(_T(':'), 6);
+ size_t End=FileName_Modified.find(_T('@'));
+ if (Begin!=string::npos && End!=string::npos && Begin<End)
+ FileName_Modified.erase(Begin, End-Begin);
+ Fill (Stream_General, 0, General_CompleteName, FileName_Modified);
+ }
+
+ //File dates
+ File F(File_Name);
+ Fill (Stream_General, 0, General_File_Created_Date, F.Created_Get());
+ Fill (Stream_General, 0, General_File_Created_Date_Local, F.Created_Local_Get());
+ Fill (Stream_General, 0, General_File_Modified_Date, F.Modified_Get());
+ Fill (Stream_General, 0, General_File_Modified_Date_Local, F.Modified_Local_Get());
+ }
+
+ //File size
+ if ((!IsSub || !File_Name.empty()) && KindOfStream==Stream_General && File_Size!=(int64u)-1)
+ Fill (Stream_General, 0, General_FileSize, File_Size);
+
+ //Fill with already ready data
+ for (size_t Pos=0; Pos<Fill_Temp.size(); Pos++)
+ if (Fill_Temp(Pos, 0).IsNumber())
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Temp(Pos, 0).To_int32u(), Fill_Temp(Pos, 1));
+ else
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Temp(Pos, 0).To_UTF8().c_str(), Fill_Temp(Pos, 1));
+ Fill_Temp.clear();
+
+ return StreamPos_Last; //The position in the stream count
+}
+
+size_t File__Analyze::Stream_Erase (stream_t KindOfStream, size_t StreamPos)
+{
+ //Integrity
+ if (!Status[IsAccepted] || KindOfStream>Stream_Max || StreamPos>=Count_Get(KindOfStream))
+ return Error;
+
+ //Insert a stream
+ (*Stream)[KindOfStream].erase((*Stream)[KindOfStream].begin()+StreamPos);
+ (*Stream_More)[KindOfStream].erase((*Stream_More)[KindOfStream].begin()+StreamPos);
+
+ //Filling basic info
+ for (size_t Pos=0; Pos<Count_Get(KindOfStream); Pos++)
+ {
+ Fill(KindOfStream, Pos, General_StreamCount, Count_Get(StreamKind_Last), 10, true);
+ Fill(KindOfStream, Pos, General_StreamKindID, Pos, 10, true);
+ if (Count_Get(KindOfStream)>1)
+ Fill(KindOfStream, Pos, General_StreamKindPos, Pos+1, 10, true);
+ }
+
+ StreamKind_Last=Stream_Max;
+ StreamPos_Last=(size_t)-1;
+
+ return (*Stream)[KindOfStream].size()-1; //The position in the stream count
+}
+
+
+//***************************************************************************
+// Filling
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Fill (stream_t StreamKind, size_t StreamPos, size_t Parameter, const Ztring &Value, bool Replace)
+{
+ //Integrity
+ if (!Status[IsAccepted] || StreamKind>Stream_Max || Parameter==(size_t)-1)
+ return;
+
+ //Handling values with \r\n inside
+ if (Value.find(_T('\r'))!=string::npos || Value.find(_T('\n'))!=string::npos)
+ {
+ Ztring NewValue=Value;
+ NewValue.FindAndReplace(_T("\r\n"), _T(" / "), 0, Ztring_Recursive);
+ NewValue.FindAndReplace(_T("\r"), _T(" / "), 0, Ztring_Recursive);
+ NewValue.FindAndReplace(_T("\n"), _T(" / "), 0, Ztring_Recursive);
+ if (NewValue.size()>=3 && NewValue.rfind(_T(" / "))==NewValue.size()-3)
+ NewValue.resize(NewValue.size()-3);
+ Fill(StreamKind, StreamPos, Parameter, NewValue, Replace);
+ return;
+ }
+
+ //Handle Value before StreamKind
+ if (StreamKind==Stream_Max || StreamPos>=(*Stream)[StreamKind].size())
+ {
+ ZtringList NewList;
+ NewList.push_back(Ztring().From_Number(Parameter));
+ NewList.push_back(Value);
+ Fill_Temp.push_back(NewList);
+ return; //No streams
+ }
+
+ //Some defaults
+ if (Parameter==Fill_Parameter(StreamKind, Generic_Format_Commercial))
+ Replace=true;
+ if (Parameter==Fill_Parameter(StreamKind, Generic_Format_Commercial_IfAny))
+ Replace=true;
+
+ if (!Replace && Value.empty())
+ return;
+ if (Replace && Value.empty())
+ {
+ Clear(StreamKind, StreamPos, Parameter);
+ return;
+ }
+
+ Ztring &Target=(*Stream)[StreamKind][StreamPos](Parameter);
+ if (Target.empty() || Replace)
+ Target=Value; //First value
+ else
+ {
+ Target+=MediaInfoLib::Config.TagSeparator_Get();
+ Target+=Value;
+ }
+ Status[IsUpdated]=true;
+
+ //Deprecated
+ if (Parameter==Fill_Parameter(StreamKind, Generic_BitDepth))
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Resolution), Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_BitDepth)), true);
+ if (StreamKind==Stream_Video && Parameter==Video_Colorimetry)
+ Fill(Stream_Video, StreamPos, Video_ChromaSubsampling, Value, Replace);
+
+ if (StreamKind==Stream_Video && Parameter==Video_DisplayAspectRatio && !Value.empty() && Retrieve(Stream_Video, StreamPos, Video_PixelAspectRatio).empty())
+ {
+ float DAR =Retrieve(Stream_Video, StreamPos, Video_DisplayAspectRatio).To_float32();
+ float Width =Retrieve(Stream_Video, StreamPos, Video_Width ).To_float32();
+ float Height=Retrieve(Stream_Video, StreamPos, Video_Height ).To_float32();
+ if (DAR && Height && Width)
+ {
+ if (Retrieve(Stream_Video, StreamPos, Video_DisplayAspectRatio)==_T("1.778"))
+ DAR=((float)16)/9; //More exact value
+ if (Retrieve(Stream_Video, StreamPos, Video_DisplayAspectRatio)==_T("1.333"))
+ DAR=((float)4)/3; //More exact value
+ Fill(Stream_Video, StreamPos, Video_PixelAspectRatio, DAR/(((float32)Width)/Height));
+ }
+ }
+
+ if (StreamKind==Stream_Video && Parameter==Video_PixelAspectRatio && !Value.empty() && Retrieve(Stream_Video, StreamPos, Video_DisplayAspectRatio).empty())
+ {
+ float32 PAR =Retrieve(Stream_Video, StreamPos, Video_PixelAspectRatio ).To_float32();
+ if (PAR>(float32)12/(float32)11*0.999 && PAR<(float32)12/(float32)11*1.001)
+ PAR=(float32)12/(float32)11;
+ if (PAR>(float32)10/(float32)11*0.999 && PAR<(float32)10/(float32)11*1.001)
+ PAR=(float32)10/(float32)11;
+ if (PAR>(float32)16/(float32)11*0.999 && PAR<(float32)16/(float32)11*1.001)
+ PAR=(float32)16/(float32)11;
+ if (PAR>(float32)40/(float32)33*0.999 && PAR<(float32)40/(float32)33*1.001)
+ PAR=(float32)40/(float32)33;
+ if (PAR>(float32)24/(float32)11*0.999 && PAR<(float32)24/(float32)11*1.001)
+ PAR=(float32)24/(float32)11;
+ if (PAR>(float32)20/(float32)11*0.999 && PAR<(float32)20/(float32)11*1.001)
+ PAR=(float32)20/(float32)11;
+ if (PAR>(float32)32/(float32)11*0.999 && PAR<(float32)32/(float32)11*1.001)
+ PAR=(float32)32/(float32)11;
+ if (PAR>(float32)80/(float32)33*0.999 && PAR<(float32)80/(float32)33*1.001)
+ PAR=(float32)80/(float32)33;
+ if (PAR>(float32)18/(float32)11*0.999 && PAR<(float32)18/(float32)11*1.001)
+ PAR=(float32)18/(float32)11;
+ if (PAR>(float32)15/(float32)11*0.999 && PAR<(float32)15/(float32)11*1.001)
+ PAR=(float32)15/(float32)11;
+ if (PAR>(float32)64/(float32)33*0.999 && PAR<(float32)64/(float32)33*1.001)
+ PAR=(float32)64/(float32)33;
+ if (PAR>(float32)160/(float32)99*0.999 && PAR<(float32)160/(float32)99*1.001)
+ PAR=(float32)160/(float32)99;
+ if (PAR>(float32)4/(float32)3*0.999 && PAR<(float32)4/(float32)3*1.01)
+ PAR=(float32)4/(float32)3;
+ if (PAR>(float32)3/(float32)2*0.999 && PAR<(float32)3/(float32)2*1.001)
+ PAR=(float32)3/(float32)2;
+ if (PAR>(float32)2/(float32)1*0.999 && PAR<(float32)2/(float32)1*1.001)
+ PAR=(float32)2;
+ if (PAR>(float32)59/(float32)54*0.999 && PAR<(float32)59/(float32)54*1.001)
+ PAR=(float32)59/(float32)54;
+ float32 Width =Retrieve(Stream_Video, StreamPos, Video_Width ).To_float32();
+ float32 Height=Retrieve(Stream_Video, StreamPos, Video_Height ).To_float32();
+ if (PAR && Height && Width)
+ Fill(Stream_Video, StreamPos, Video_DisplayAspectRatio, ((float32)Width)/Height*PAR);
+ }
+
+ if (StreamKind==Stream_Image && Parameter==Image_DisplayAspectRatio && !Value.empty() && Retrieve(Stream_Image, StreamPos, Image_PixelAspectRatio).empty())
+ {
+ float DAR =Retrieve(Stream_Image, StreamPos, Image_DisplayAspectRatio).To_float32();
+ float Width =Retrieve(Stream_Image, StreamPos, Image_Width ).To_float32();
+ float Height=Retrieve(Stream_Image, StreamPos, Image_Height ).To_float32();
+ if (DAR && Height && Width)
+ {
+ if (Retrieve(Stream_Image, StreamPos, Image_DisplayAspectRatio)==_T("1.778"))
+ DAR=((float)16)/9; //More exact value
+ if (Retrieve(Stream_Image, StreamPos, Image_DisplayAspectRatio)==_T("1.333"))
+ DAR=((float)4)/3; //More exact value
+ Fill(Stream_Image, StreamPos, Image_PixelAspectRatio, DAR/(((float32)Width)/Height));
+ }
+ }
+
+ if (StreamKind==Stream_Image && Parameter==Image_PixelAspectRatio && !Value.empty() && Retrieve(Stream_Image, StreamPos, Image_DisplayAspectRatio).empty())
+ {
+ float32 PAR =Retrieve(Stream_Image, StreamPos, Image_PixelAspectRatio ).To_float32();
+ if (PAR>(float32)12/(float32)11*0.999 && PAR<(float32)12/(float32)11*1.001)
+ PAR=(float32)12/(float32)11;
+ if (PAR>(float32)10/(float32)11*0.999 && PAR<(float32)10/(float32)11*1.001)
+ PAR=(float32)10/(float32)11;
+ if (PAR>(float32)16/(float32)11*0.999 && PAR<(float32)16/(float32)11*1.001)
+ PAR=(float32)16/(float32)11;
+ if (PAR>(float32)40/(float32)33*0.999 && PAR<(float32)40/(float32)33*1.001)
+ PAR=(float32)40/(float32)33;
+ if (PAR>(float32)24/(float32)11*0.999 && PAR<(float32)24/(float32)11*1.001)
+ PAR=(float32)24/(float32)11;
+ if (PAR>(float32)20/(float32)11*0.999 && PAR<(float32)20/(float32)11*1.001)
+ PAR=(float32)20/(float32)11;
+ if (PAR>(float32)32/(float32)11*0.999 && PAR<(float32)32/(float32)11*1.001)
+ PAR=(float32)32/(float32)11;
+ if (PAR>(float32)80/(float32)33*0.999 && PAR<(float32)80/(float32)33*1.001)
+ PAR=(float32)80/(float32)33;
+ if (PAR>(float32)18/(float32)11*0.999 && PAR<(float32)18/(float32)11*1.001)
+ PAR=(float32)18/(float32)11;
+ if (PAR>(float32)15/(float32)11*0.999 && PAR<(float32)15/(float32)11*1.001)
+ PAR=(float32)15/(float32)11;
+ if (PAR>(float32)64/(float32)33*0.999 && PAR<(float32)64/(float32)33*1.001)
+ PAR=(float32)64/(float32)33;
+ if (PAR>(float32)160/(float32)99*0.999 && PAR<(float32)160/(float32)99*1.001)
+ PAR=(float32)160/(float32)99;
+ if (PAR>(float32)4/(float32)3*0.999 && PAR<(float32)4/(float32)3*1.01)
+ PAR=(float32)4/(float32)3;
+ if (PAR>(float32)3/(float32)2*0.999 && PAR<(float32)3/(float32)2*1.001)
+ PAR=(float32)3/(float32)2;
+ if (PAR>(float32)2/(float32)1*0.999 && PAR<(float32)2/(float32)1*1.001)
+ PAR=(float32)2;
+ if (PAR>(float32)59/(float32)54*0.999 && PAR<(float32)59/(float32)54*1.001)
+ PAR=(float32)59/(float32)54;
+ float32 Width =Retrieve(Stream_Image, StreamPos, Image_Width ).To_float32();
+ float32 Height=Retrieve(Stream_Image, StreamPos, Image_Height ).To_float32();
+ if (PAR && Height && Width)
+ Fill(Stream_Image, StreamPos, Image_DisplayAspectRatio, ((float32)Width)/Height*PAR);
+ }
+
+ //Commercial name
+ if (Parameter==Fill_Parameter(StreamKind, Generic_Format))
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format_Commercial), Value);
+ if (Parameter==Fill_Parameter(StreamKind, Generic_Format_Commercial_IfAny))
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format_Commercial), Value, true);
+
+ if (!IsSub)
+ {
+ Ztring ParameterName=Retrieve(StreamKind, StreamPos, Parameter, Info_Name);
+
+ //Lists
+ if (StreamKind!=Stream_General && (ParameterName==_T("Codec/String")
+ || ParameterName==_T("Language/String")
+ || ParameterName==_T("Format")
+ || ParameterName==_T("CodecID/Hint")))
+ {
+ Ztring Temp1, Temp2;
+ for (size_t StreamPos_Local=0; StreamPos_Local<(*Stream)[StreamKind].size(); StreamPos_Local++)
+ {
+ if (ParameterName==_T("CodecID/Hint"))
+ Temp1+=Retrieve(StreamKind, StreamPos_Local, Fill_Parameter(StreamKind, Generic_Format))+_T(" / ");
+ else
+ Temp1+=Retrieve(StreamKind, StreamPos_Local, Parameter)+_T(" / ");
+ if (ParameterName==_T("Format")
+ || ParameterName==_T("CodecID/Hint"))
+ {
+ Temp2+=Retrieve(StreamKind, StreamPos_Local, Fill_Parameter(StreamKind, Generic_Format));
+ if (!Retrieve(StreamKind, StreamPos_Local, Fill_Parameter(StreamKind, Generic_CodecID_Hint)).empty())
+ {
+ Temp2+=_T(" (");
+ Temp2+=Retrieve(StreamKind, StreamPos_Local, Fill_Parameter(StreamKind, Generic_CodecID_Hint));
+ Temp2+=_T(")");
+ }
+ Temp2+=_T(" / ");
+ }
+ }
+ if (!Temp1.empty())
+ Temp1.resize(Temp1.size()-3); //Delete extra " / "
+ if (!Temp2.empty())
+ Temp2.resize(Temp2.size()-3); //Delete extra " / "
+ Ztring StreamKind_Text=Get(StreamKind, 0, General_StreamKind, Info_Text);
+ if (ParameterName==_T("Codec/String"))
+ Fill(Stream_General, 0, Ztring(StreamKind_Text+_T("_Codec_List")).To_Local().c_str(), Temp1, true);
+ if (ParameterName==_T("Language/String"))
+ Fill(Stream_General, 0, Ztring(StreamKind_Text+_T("_Language_List")).To_Local().c_str(), Temp1, true);
+ if (ParameterName==_T("Format")
+ || ParameterName==_T("CodecID/Hint"))
+ {
+ Fill(Stream_General, 0, Ztring(StreamKind_Text+_T("_Format_List")).To_Local().c_str(), Temp1, true);
+ Fill(Stream_General, 0, Ztring(StreamKind_Text+_T("_Format_WithHint_List")).To_Local().c_str(), Temp2, true);
+ }
+ }
+
+ //Human readable
+ if (MediaInfoLib::Config.ReadByHuman_Get())
+ {
+ //Strings
+ const Ztring &List_Measure_Value=MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter, Info_Measure);
+ if (List_Measure_Value==_T(" byte"))
+ FileSize_FileSize123(StreamKind, StreamPos, Parameter);
+ else if (List_Measure_Value==_T(" bps") || List_Measure_Value==_T(" Hz"))
+ Kilo_Kilo123(StreamKind, StreamPos, Parameter);
+ else if (List_Measure_Value==_T(" ms"))
+ Duration_Duration123(StreamKind, StreamPos, Parameter);
+ else if (List_Measure_Value==_T("Yes"))
+ YesNo_YesNo(StreamKind, StreamPos, Parameter);
+ else
+ Value_Value123(StreamKind, StreamPos, Parameter);
+
+ //BitRate_Mode / OverallBitRate_Mode
+ if (ParameterName==(StreamKind==Stream_General?_T("OverallBitRate_Mode"):_T("BitRate_Mode")) && MediaInfoLib::Config.ReadByHuman_Get())
+ {
+ Clear(StreamKind, StreamPos, StreamKind==Stream_General?"OverallBitRate_Mode/String":"BitRate_Mode/String");
+
+ ZtringList List;
+ List.Separator_Set(0, _T(" / "));
+ List.Write(Retrieve(StreamKind, StreamPos, Parameter));
+
+ //Per value
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ List[Pos]=MediaInfoLib::Config.Language_Get(Ztring(_T("BitRate_Mode_"))+List[Pos]);
+
+ Ztring Translated=List.Read();
+ Fill(StreamKind, StreamPos, StreamKind==Stream_General?"OverallBitRate_Mode/String":"BitRate_Mode/String", Translated.find(_T("BitRate_Mode_"))?Translated:Value);
+ }
+
+ //Encoded_Library
+ if (ParameterName==_T("Encoded_Library")
+ || ParameterName==_T("Encoded_Library/Name")
+ || ParameterName==_T("Encoded_Library/Version")
+ || ParameterName==_T("Encoded_Library/Date"))
+ {
+ Ztring Name=Retrieve(StreamKind, StreamPos, "Encoded_Library/Name");
+ Ztring Version=Retrieve(StreamKind, StreamPos, "Encoded_Library/Version");
+ Ztring Date=Retrieve(StreamKind, StreamPos, "Encoded_Library/Date");
+ if (!Name.empty())
+ {
+ Ztring String=Name;
+ if (!Version.empty())
+ {
+ String+=_T(" ");
+ String+=Version;
+ }
+ if (!Date.empty())
+ {
+ String+=_T(" (");
+ String+=Date;
+ String+=_T(")");
+ }
+ Fill(StreamKind, StreamPos, "Encoded_Library/String", String, true);
+ }
+ else
+ Fill(StreamKind, StreamPos, "Encoded_Library/String", Retrieve(StreamKind, StreamPos, "Encoded_Library"), true);
+ }
+
+ //Format_Settings_Matrix
+ if (StreamKind==Stream_Video && Parameter==Video_Format_Settings_Matrix)
+ {
+ Ztring Translated=MediaInfoLib::Config.Language_Get(Ztring(_T("Format_Settings_Matrix_"))+Value);
+ Fill(Stream_Video, StreamPos, Video_Format_Settings_Matrix_String, Translated.find(_T("Format_Settings_Matrix_"))?Translated:Value, Replace);
+ }
+
+ //Scan type
+ if (StreamKind==Stream_Video && Parameter==Video_ScanType)
+ {
+ Ztring Translated=MediaInfoLib::Config.Language_Get(Ztring(_T("Interlaced_"))+Value);
+ Fill(Stream_Video, StreamPos, Video_ScanType_String, Translated.find(_T("Interlaced_"))?Translated:Value, Replace);
+ }
+
+ //Scan order
+ if (StreamKind==Stream_Video && Parameter==Video_ScanOrder)
+ {
+ Ztring Translated=MediaInfoLib::Config.Language_Get(Ztring(_T("Interlaced_"))+Value);
+ Fill(Stream_Video, StreamPos, Video_ScanOrder_String, Translated.find(_T("Interlaced_"))?Translated:Value, Replace);
+ }
+
+ //Interlacement
+ if (StreamKind==Stream_Video && Parameter==Video_Interlacement)
+ {
+ const Ztring &Z1=Retrieve(Stream_Video, StreamPos, Video_Interlacement);
+ if (Z1.size()==3)
+ Fill(Stream_Video, StreamPos, Video_Interlacement_String, MediaInfoLib::Config.Language_Get(Ztring(_T("Interlaced_"))+Z1), Replace);
+ else
+ Fill(Stream_Video, StreamPos, Video_Interlacement_String, MediaInfoLib::Config.Language_Get(Z1), Replace);
+ if (Retrieve(Stream_Video, StreamPos, Video_Interlacement_String).empty())
+ Fill(Stream_Video, StreamPos, Video_Interlacement_String, Z1, true);
+ }
+
+ //FrameRate_Mode
+ if (StreamKind==Stream_Video && Parameter==Video_FrameRate_Mode)
+ {
+ Ztring Translated=MediaInfoLib::Config.Language_Get(Ztring(_T("FrameRate_Mode_"))+Value);
+ Fill(Stream_Video, StreamPos, Video_FrameRate_Mode_String, Translated.find(_T("FrameRate_Mode_"))?Translated:Value, Replace);
+ }
+
+ //Compression_Mode
+ if (Parameter==Fill_Parameter(StreamKind, Generic_Compression_Mode))
+ {
+ Ztring Translated=MediaInfoLib::Config.Language_Get(Ztring(_T("Compression_Mode_"))+Value);
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Compression_Mode_String), Translated.find(_T("Compression_Mode_"))?Translated:Value, Replace);
+ }
+
+ //Delay_Source
+ if (Parameter==Fill_Parameter(StreamKind, Generic_Delay_Source))
+ {
+ Ztring Translated=MediaInfoLib::Config.Language_Get(Ztring(_T("Delay_Source_"))+Value);
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Delay_Source_String), Translated.find(_T("Delay_Source_"))?Translated:Value, Replace);
+ }
+ }
+
+ //General Format
+ if (Parameter==Fill_Parameter(StreamKind, Generic_Format) && Retrieve(Stream_General, 0, General_Format).empty() && !Value.empty())
+ Fill(Stream_General, 0, General_Format, Value); //If not already filled, we are filling with the stream format
+
+ //ID
+ if (Parameter==General_ID)
+ Fill(StreamKind, StreamPos, General_ID_String, Value, Replace);
+
+ //Format
+ if (Parameter==Fill_Parameter(StreamKind, Generic_Format))
+ {
+ if ((Replace && !MediaInfoLib::Config.Format_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format)), InfoFormat_Info).empty()) || Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format_Info)).empty())
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format_Info), MediaInfoLib::Config.Format_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format)), InfoFormat_Info), true);
+ if ((Replace && !MediaInfoLib::Config.Format_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format)), InfoFormat_Url).empty()) || Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format_Url)).empty())
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format_Url) , MediaInfoLib::Config.Format_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format)), InfoFormat_Url), true);
+ if (StreamKind!=Stream_Menu)
+ {
+ if ((Replace && !MediaInfoLib::Config.Format_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format)), InfoFormat_InternetMediaType).empty()) || Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_InternetMediaType)).empty())
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_InternetMediaType), MediaInfoLib::Config.Format_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format)), InfoFormat_InternetMediaType), true);
+ if ((Replace && !MediaInfoLib::Config.Format_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format)), InfoFormat_Compression_Mode).empty()) || Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Compression_Mode)).empty())
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Compression_Mode), MediaInfoLib::Config.Format_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format)), InfoFormat_Compression_Mode), true);
+ }
+ if (StreamKind==Stream_General)
+ {
+ Fill(Stream_General, 0, General_Format_Extensions, MediaInfoLib::Config.Format_Get(Value, InfoFormat_Extensions), true);
+ Fill(Stream_General, 0, General_Format_String, Value, true);
+ Fill(Stream_General, 0, General_Codec, Value, true);
+ Fill(Stream_General, 0, General_Codec_String, Value, true);
+ }
+ }
+ if (StreamKind==Stream_General && Parameter==General_Format_Info)
+ (*Stream)[Stream_General][0](General_Codec_Info)=Value;
+ if (StreamKind==Stream_General && Parameter==General_Format_Url)
+ (*Stream)[Stream_General][0](General_Codec_Url)=Value;
+ if (StreamKind==Stream_General && Parameter==General_Format_Extensions)
+ (*Stream)[Stream_General][0](General_Codec_Extensions)=Value;
+ if (StreamKind==Stream_General && Parameter==General_Format_Settings)
+ (*Stream)[Stream_General][0](General_Codec_Settings)=Value;
+
+ //Codec
+ if (Parameter==Fill_Parameter(StreamKind, Generic_Codec))
+ {
+ const Ztring &C1=MediaInfoLib::Config.Codec_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Codec)), InfoCodec_Name, (stream_t)StreamKind);
+ if (C1.empty())
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Codec_String), Value, true);
+ else
+ {
+ Ztring D=Retrieve(StreamKind, StreamPos, "Codec/Family");
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Codec_String), C1, true);
+ Fill(StreamKind, StreamPos, "Codec/Family", MediaInfoLib::Config.Codec_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Codec)), InfoCodec_KindofCodec, StreamKind), true);
+ Ztring B=Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Codec));
+ Ztring C=MediaInfoLib::Config.Codec_Get(B, InfoCodec_KindofCodec, StreamKind);
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Codec_Info) , MediaInfoLib::Config.Codec_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Codec)), InfoCodec_Description, StreamKind), true);
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Codec_Url) , MediaInfoLib::Config.Codec_Get(Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Codec)), InfoCodec_Url, StreamKind), true);
+ }
+ }
+
+ //CodecID_Description
+ if (Parameter==Fill_Parameter(StreamKind, Generic_CodecID_Info) && Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_CodecID_Description))==Value)
+ Clear(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_CodecID_Description));
+
+ //BitRate from BitRate_Nominal
+ if (Parameter==Fill_Parameter(StreamKind, Generic_BitRate)
+ || Parameter==Fill_Parameter(StreamKind, Generic_BitRate_Nominal))
+ {
+ float32 BitRate=Retrieve(StreamKind, StreamPos, "BitRate").To_float32();
+ float32 BitRate_Nominal=Retrieve(StreamKind, StreamPos, "BitRate_Nominal").To_float32();
+ if (BitRate_Nominal>BitRate*0.95 && BitRate_Nominal<BitRate*1.05)
+ {
+ Ztring Temp=Retrieve(StreamKind, StreamPos, "BitRate_Nominal");
+ Clear(StreamKind, StreamPos, "BitRate_Nominal");
+ Fill(StreamKind, StreamPos, "BitRate", Temp, true);
+ }
+ }
+
+ //BitRate from BitRate_Maximum
+ if (Parameter==Fill_Parameter(StreamKind, Generic_BitRate)
+ || Parameter==Fill_Parameter(StreamKind, Generic_BitRate_Maximum))
+ {
+ float32 BitRate=Retrieve(StreamKind, StreamPos, "BitRate").To_float32();
+ float32 BitRate_Maximum=Retrieve(StreamKind, StreamPos, "BitRate_Maximum").To_float32();
+ if (BitRate>BitRate_Maximum*0.99 && BitRate<BitRate_Maximum*1.01)
+ {
+ Ztring Temp=Retrieve(StreamKind, StreamPos, "BitRate_Maximum");
+ Clear(StreamKind, StreamPos, "BitRate_Maximum");
+ Fill(StreamKind, StreamPos, "BitRate", Temp, true);
+ }
+ }
+
+ //File size
+ if (StreamKind==Stream_General && Parameter==General_FileSize)
+ {
+ int64u File_Size_Save=File_Size;
+ File_Size=Value.To_int64u();
+ for (size_t Kind=Stream_Video; Kind<Stream_Menu; Kind++)
+ for (size_t Pos=0; Pos<Count_Get((stream_t)Kind); Pos++)
+ FileSize_FileSize123((stream_t)Kind, Pos, Fill_Parameter((stream_t)Kind, Generic_StreamSize));
+ File_Size=File_Size_Save;
+ }
+
+ //Delay/Video
+ if (StreamKind==Stream_Video && StreamPos==0 && Parameter==Video_Delay)
+ {
+ for (size_t Pos=0; Pos<Count_Get(Stream_Audio); Pos++)
+ if (!Retrieve(Stream_Audio, Pos, Audio_Delay).empty())
+ {
+ Fill(Stream_Audio, Pos, Audio_Video_Delay, Retrieve(Stream_Audio, Pos, Audio_Delay).To_int64s()-Value.To_int64s(), 10, true);
+ if (Retrieve(Stream_Audio, Pos, Audio_Video_Delay).To_int64u()==0)
+ for (size_t Param_Pos=Audio_Video_Delay+1; Param_Pos<=Audio_Video_Delay+4; Param_Pos++)
+ if (Param_Pos<(*Stream)[Stream_Audio][Pos].size())
+ (*Stream)[Stream_Audio][Pos][Param_Pos].clear();
+ }
+ for (size_t Pos=0; Pos<Count_Get(Stream_Text); Pos++)
+ if (!Retrieve(Stream_Text, Pos, Text_Delay).empty())
+ {
+ Fill(Stream_Text, Pos, Text_Video_Delay, Retrieve(Stream_Text, Pos, Text_Delay).To_int64s()-Value.To_int64s(), 10, true);
+ if (Retrieve(Stream_Text, Pos, Text_Video_Delay).To_int64u()==0)
+ for (size_t Param_Pos=Text_Video_Delay+1; Param_Pos<=Text_Video_Delay+4; Param_Pos++)
+ if (Param_Pos<(*Stream)[Stream_Text][Pos].size())
+ (*Stream)[Stream_Text][Pos][Param_Pos].clear();
+ }
+ }
+ if (StreamKind==Stream_Audio && Parameter==Audio_Delay && Count_Get(Stream_Video) && !Retrieve(Stream_Audio, StreamPos, Audio_Delay).empty() && !Retrieve(Stream_Video, 0, Video_Delay).empty())
+ {
+ if (Replace)
+ Clear(Stream_Audio, StreamPos, Audio_Video_Delay);
+ ZtringList AudioDelay; AudioDelay.Separator_Set(0, _T(" / ")); AudioDelay.Write(Retrieve(Stream_Audio, StreamPos, Audio_Delay));
+ ZtringList VideoDelay; VideoDelay.Separator_Set(0, _T(" / ")); VideoDelay.Write(Retrieve(Stream_Video, 0, Video_Delay));
+ if (AudioDelay.size()<=VideoDelay.size())
+ {
+ Fill(Stream_Audio, StreamPos, Audio_Video_Delay, AudioDelay(AudioDelay.size()-1).To_int64s()-VideoDelay(AudioDelay.size()-1).To_int64s(), 10);
+ if (VideoDelay.size()==1 && Retrieve(Stream_Audio, StreamPos, Audio_Video_Delay).To_int64u()==0)
+ for (size_t Pos=Audio_Video_Delay+1; Pos<=Audio_Video_Delay+4; Pos++)
+ if (Pos<(*Stream)[Stream_Audio][StreamPos].size())
+ (*Stream)[Stream_Audio][StreamPos][Pos].clear();
+ }
+ }
+ if (StreamKind==Stream_Text && Parameter==Text_Delay && Count_Get(Stream_Video) && !Retrieve(Stream_Text, StreamPos, Text_Delay).empty() && !Retrieve(Stream_Video, 0, Video_Delay).empty())
+ {
+ Fill(Stream_Text, StreamPos, Text_Video_Delay, Value.To_int64s()-Retrieve(Stream_Video, 0, Video_Delay).To_int64s(), 10, true);
+ if (Retrieve(Stream_Text, StreamPos, Text_Video_Delay).To_int64u()==0)
+ for (size_t Pos=Text_Video_Delay+1; Pos<=Text_Video_Delay+4; Pos++)
+ if (Pos<(*Stream)[Stream_Text][StreamPos].size())
+ (*Stream)[Stream_Text][StreamPos][Pos].clear();
+ }
+
+ //Delay/Video0
+ if (StreamKind==Stream_Video && StreamPos==0 && Parameter==Video_Delay)
+ {
+ for (size_t Pos=0; Pos<Count_Get(Stream_Audio); Pos++)
+ if (!Retrieve(Stream_Audio, Pos, Audio_Delay).empty())
+ {
+ Fill(Stream_Audio, Pos, Audio_Video0_Delay, Retrieve(Stream_Audio, Pos, Audio_Delay).To_int64s()-Value.To_int64s(), 10, true);
+ if (Retrieve(Stream_Audio, Pos, Audio_Video0_Delay).To_int64u()==0)
+ for (size_t Param_Pos=Audio_Video0_Delay+1; Param_Pos<=Audio_Video0_Delay+4; Param_Pos++)
+ if (Param_Pos<(*Stream)[Stream_Audio][Pos].size())
+ (*Stream)[Stream_Audio][Pos][Param_Pos].clear();
+ }
+ for (size_t Pos=0; Pos<Count_Get(Stream_Text); Pos++)
+ if (!Retrieve(Stream_Text, Pos, Text_Delay).empty())
+ {
+ Fill(Stream_Text, Pos, Text_Video0_Delay, Retrieve(Stream_Text, Pos, Text_Delay).To_int64s()-Value.To_int64s(), 10, true);
+ if (Retrieve(Stream_Text, Pos, Text_Video0_Delay).To_int64u()==0)
+ for (size_t Param_Pos=Text_Video0_Delay+1; Param_Pos<=Text_Video0_Delay+4; Param_Pos++)
+ if (Param_Pos<(*Stream)[Stream_Text][Pos].size())
+ (*Stream)[Stream_Text][Pos][Param_Pos].clear();
+ }
+ }
+ if (StreamKind==Stream_Audio && Parameter==Audio_Delay && Count_Get(Stream_Video) && !Retrieve(Stream_Audio, StreamPos, Audio_Delay).empty() && !Retrieve(Stream_Video, 0, Video_Delay).empty())
+ {
+ if (Replace)
+ Clear(Stream_Audio, StreamPos, Audio_Video0_Delay);
+ ZtringList AudioDelay; AudioDelay.Separator_Set(0, _T(" / ")); AudioDelay.Write(Retrieve(Stream_Audio, StreamPos, Audio_Delay));
+ ZtringList VideoDelay; VideoDelay.Separator_Set(0, _T(" / ")); VideoDelay.Write(Retrieve(Stream_Video, 0, Video_Delay));
+ if (AudioDelay.size()<=VideoDelay.size())
+ {
+ Fill(Stream_Audio, StreamPos, Audio_Video0_Delay, AudioDelay(AudioDelay.size()-1).To_int64s()-VideoDelay(AudioDelay.size()-1).To_int64s(), 10);
+ if (VideoDelay.size()==1 && Retrieve(Stream_Audio, StreamPos, Audio_Video0_Delay).To_int64u()==0)
+ for (size_t Pos=Audio_Video0_Delay+1; Pos<=Audio_Video0_Delay+4; Pos++)
+ if (Pos<(*Stream)[Stream_Audio][StreamPos].size())
+ (*Stream)[Stream_Audio][StreamPos][Pos].clear();
+ }
+ }
+ if (StreamKind==Stream_Text && Parameter==Text_Delay && Count_Get(Stream_Video) && !Retrieve(Stream_Text, StreamPos, Text_Delay).empty() && !Retrieve(Stream_Video, 0, Video_Delay).empty())
+ {
+ Fill(Stream_Text, StreamPos, Text_Video0_Delay, Value.To_int64s()-Retrieve(Stream_Video, 0, Video_Delay).To_int64s(), 10, true);
+ if (Retrieve(Stream_Text, StreamPos, Text_Video0_Delay).To_int64u()==0)
+ for (size_t Pos=Text_Video0_Delay+1; Pos<=Text_Video0_Delay+4; Pos++)
+ if (Pos<(*Stream)[Stream_Text][StreamPos].size())
+ (*Stream)[Stream_Text][StreamPos][Pos].clear();
+ }
+
+ //Language
+ //-Find 2-digit language
+ if (Parameter==Fill_Parameter(StreamKind, Generic_Language))
+ {
+ //Removing old strings
+ Clear(StreamKind, StreamPos, Parameter+1); //String
+ Clear(StreamKind, StreamPos, Parameter+2); //String1
+ Clear(StreamKind, StreamPos, Parameter+3); //String2
+ Clear(StreamKind, StreamPos, Parameter+4); //String3
+ Clear(StreamKind, StreamPos, Parameter+5); //String4
+
+ ZtringListList Languages;
+ Languages.Separator_Set(0, _T(" / "));
+ Languages.Separator_Set(1, _T("-"));
+ Languages.Write((*Stream)[StreamKind][StreamPos][Parameter]);
+
+ //Canonizing
+ for (size_t Pos=0; Pos<Languages.size(); Pos++)
+ {
+ Ztring Language_Orig;
+
+ //Removing undefined languages
+ if (Languages[Pos].size()>=1)
+ {
+ Language_Orig=Languages[Pos][0];
+ Languages[Pos][0].MakeLowerCase();
+ if ((Languages[Pos][0].size()==3 && (Languages[Pos][0]==_T("mis")
+ || Languages[Pos][0]==_T("und")
+ || Languages[Pos][0]==_T("???")
+ || Languages[Pos][0]==_T(" ")))
+ || (Languages[Pos][0].size()==2 && Languages[Pos][0]==_T(" ")))
+ Languages[Pos].clear();
+ }
+
+ //Finding ISO-639-1 from ISO-639-2 or translated name
+ if (Languages[Pos].size()>=1)
+ {
+ if (Languages[Pos][0].size()==3 && !MediaInfoLib::Config.Iso639_1_Get(Languages[Pos][0]).empty())
+ Languages[Pos][0]=MediaInfoLib::Config.Iso639_1_Get(Languages[Pos][0]);
+ if (Languages[Pos][0].size()>3 && !MediaInfoLib::Config.Iso639_Find(Languages[Pos][0]).empty())
+ Languages[Pos][0]=MediaInfoLib::Config.Iso639_Find(Languages[Pos][0]);
+ if (Languages[Pos][0].size()>3 && !MediaInfoLib::Config.Language_Get(_T("Language_")+Languages[Pos][0].substr(0, 2)).empty())
+ Languages[Pos][0]=Languages[Pos][0].substr(0, 2);
+ if (Languages[Pos][0].size()>3)
+ Languages[Pos][0]=Language_Orig; //We failed to detect language, using the original version
+ }
+
+ //Country name
+ if (Languages[Pos].size()>=2)
+ Languages[Pos][1].MakeLowerCase();
+ }
+
+ if (Languages.Read()!=Retrieve(StreamKind, StreamPos, Parameter))
+ Fill(StreamKind, StreamPos, Parameter, Languages.Read(), true);
+ else
+ {
+ ZtringList Language1; Language1.Separator_Set(0, _T(" / "));
+ ZtringList Language2; Language2.Separator_Set(0, _T(" / "));
+ ZtringList Language3; Language3.Separator_Set(0, _T(" / "));
+ ZtringList Language4; Language4.Separator_Set(0, _T(" / "));
+
+ for (size_t Pos=0; Pos<Languages.size(); Pos++)
+ {
+ if (Languages[Pos].size()>=1)
+ {
+ Ztring Language_Translated=MediaInfoLib::Config.Language_Get(_T("Language_")+Languages[Pos][0]);
+ if (Language_Translated.find(_T("Language_"))==0)
+ Language_Translated=Languages[Pos][0]; //No translation found
+ if (Languages[Pos].size()>=2)
+ {
+ Language_Translated+=_T(" (");
+ Language_Translated+=Ztring(Languages[Pos][1]).MakeUpperCase();
+ Language_Translated+=_T(")");
+ }
+ Language1.push_back(Language_Translated);
+ if (Languages[Pos][0].size()==2)
+ {
+ Language2.push_back(Languages[Pos][0]);
+ Language4.push_back(Languages[Pos].Read());
+ }
+ else
+ {
+ Language2.push_back(Ztring());
+ Language4.push_back(Ztring());
+ }
+ if (Languages[Pos][0].size()==3)
+ Language3.push_back(Languages[Pos][0]);
+ else if (!MediaInfoLib::Config.Iso639_2_Get(Languages[Pos][0]).empty())
+ Language3.push_back(MediaInfoLib::Config.Iso639_2_Get(Languages[Pos][0]));
+ else
+ Language3.push_back(Ztring());
+ }
+ else
+ {
+ Language1.push_back(Ztring());
+ Language2.push_back(Ztring());
+ Language3.push_back(Ztring());
+ Language4.push_back(Ztring());
+ }
+ }
+
+ Fill(StreamKind, StreamPos, Parameter+2, Language1.Read()); //String1
+ Fill(StreamKind, StreamPos, Parameter+3, Language2.Read()); //String2
+ Fill(StreamKind, StreamPos, Parameter+4, Language3.Read()); //String3
+ Fill(StreamKind, StreamPos, Parameter+5, Language4.Read()); //String4
+ Fill(StreamKind, StreamPos, Parameter+1, Retrieve(StreamKind, StreamPos, Parameter+2)); //String
+ }
+ }
+
+ //ServiceName / ServiceProvider
+ if (Parameter==Fill_Parameter(StreamKind, Generic_ServiceName)
+ || Parameter==Fill_Parameter(StreamKind, Generic_ServiceProvider))
+ {
+ if (Retrieve(StreamKind, StreamPos, Parameter).find(_T(" - "))==string::npos && (Retrieve(StreamKind, StreamPos, Parameter).find(_T(":"))==2 || Retrieve(StreamKind, StreamPos, Parameter).find(_T(":"))==3))
+ {
+ Ztring Temp=Retrieve(StreamKind, StreamPos, Parameter);
+ Temp.erase(0, Retrieve(StreamKind, StreamPos, Parameter).find(_T(":"))+1);
+ (*Stream)[StreamKind][StreamPos](Parameter)=Temp;
+ }
+ }
+
+ //FrameRate Nominal
+ if (StreamKind==Stream_Video && (Parameter==Video_FrameRate || Parameter==Video_FrameRate_Nominal))
+ {
+ float32 FrameRate=Retrieve(Stream_Video, StreamPos, Video_FrameRate).To_float32();
+ float32 FrameRate_Nominal=Retrieve(Stream_Video, StreamPos, Video_FrameRate_Nominal).To_float32();
+ if (FrameRate_Nominal>FrameRate*0.995 && FrameRate_Nominal<FrameRate*1.005)
+ {
+ Ztring Temp=Retrieve(StreamKind, StreamPos, Video_FrameRate_Nominal);
+ Clear(StreamKind, StreamPos, Video_FrameRate_Nominal);
+ if (Parameter==Video_FrameRate)
+ Fill(StreamKind, StreamPos, Parameter, Temp, true);
+ }
+ }
+
+ //Well known framerate values
+ if (StreamKind==Stream_Video && (Parameter==Video_FrameRate || Parameter==Video_FrameRate_Nominal || Parameter==Video_FrameRate_Original))
+ {
+ Video_FrameRate_Rounding(StreamPos, (video)Parameter);
+ if (Retrieve(Stream_Video, StreamPos, Video_FrameRate_Nominal)==Retrieve(Stream_Video, StreamPos, Video_FrameRate))
+ Clear(Stream_Video, StreamPos, Video_FrameRate_Nominal);
+ if (Parameter!=Video_FrameRate_Original && Retrieve(Stream_Video, StreamPos, Video_FrameRate_Original)==Retrieve(Stream_Video, StreamPos, Video_FrameRate))
+ Clear(Stream_Video, StreamPos, Video_FrameRate_Original);
+ }
+
+ //Display Aspect Ratio and Pixel Aspect Ratio
+ if (StreamKind==Stream_Video && Parameter==Video_DisplayAspectRatio && !Value.empty())
+ {
+ float F1=Retrieve(Stream_Video, StreamPos, Video_DisplayAspectRatio).To_float32();
+ Ztring C1;
+ if (F1>=(float)1.23 && F1<(float)1.27) C1=_T("5:4");
+ else if (F1>=(float)1.30 && F1<(float)1.37) C1=_T("4:3");
+ else if (F1>=(float)1.45 && F1<(float)1.55) C1=_T("3:2");
+ else if (F1>=(float)1.74 && F1<(float)1.82) C1=_T("16:9");
+ else if (F1>=(float)1.82 && F1<(float)1.88) C1=_T("1.85:1");
+ else if (F1>=(float)2.15 && F1<(float)2.22) C1=_T("2.2:1");
+ else if (F1>=(float)2.23 && F1<(float)2.30) C1=_T("2.25:1");
+ else if (F1>=(float)2.30 && F1<(float)2.37) C1=_T("2.35:1");
+ else if (F1>=(float)2.37 && F1<(float)2.45) C1=_T("2.40:1");
+ else C1.From_Number(F1);
+ C1.FindAndReplace(_T("."), MediaInfoLib::Config.Language_Get(_T(" Config_Text_FloatSeparator")));
+ if (MediaInfoLib::Config.Language_Get(_T(" Language_ISO639"))==_T("fr") && C1.find(_T(":1"))==string::npos)
+ C1.FindAndReplace(_T(":"), _T("/"));
+ Fill(Stream_Video, StreamPos, Video_DisplayAspectRatio_String, C1, true);
+ }
+
+ //Original Display Aspect Ratio and Original Pixel Aspect Ratio
+ if (StreamKind==Stream_Video && Parameter==Video_DisplayAspectRatio_Original)
+ {
+ float F1=Retrieve(Stream_Video, StreamPos, Video_DisplayAspectRatio_Original).To_float32();
+ Ztring C1;
+ if (F1>=(float)1.23 && F1<(float)1.27) C1=_T("5:4");
+ else if (F1>=(float)1.30 && F1<(float)1.37) C1=_T("4:3");
+ else if (F1>=(float)1.45 && F1<(float)1.55) C1=_T("3:2");
+ else if (F1>=(float)1.74 && F1<(float)1.82) C1=_T("16:9");
+ else if (F1>=(float)1.82 && F1<(float)1.88) C1=_T("1.85:1");
+ else if (F1>=(float)2.15 && F1<(float)2.22) C1=_T("2.2:1");
+ else if (F1>=(float)2.23 && F1<(float)2.30) C1=_T("2.25:1");
+ else if (F1>=(float)2.30 && F1<(float)2.37) C1=_T("2.35:1");
+ else if (F1>=(float)2.37 && F1<(float)2.45) C1=_T("2.40:1");
+ else C1.From_Number(F1);
+ C1.FindAndReplace(_T("."), MediaInfoLib::Config.Language_Get(_T(" Config_Text_FloatSeparator")));
+ if (MediaInfoLib::Config.Language_Get(_T(" Language_ISO639"))==_T("fr") && C1.find(_T(":1"))==string::npos)
+ C1.FindAndReplace(_T(":"), _T("/"));
+ Fill(Stream_Video, StreamPos, Video_DisplayAspectRatio_Original_String, C1, true);
+ }
+
+ //Display Aspect Ratio and Pixel Aspect Ratio
+ if (StreamKind==Stream_Image && Parameter==Image_DisplayAspectRatio && !Value.empty())
+ {
+ float F1=Retrieve(Stream_Image, StreamPos, Image_DisplayAspectRatio).To_float32();
+ Ztring C1;
+ if (F1>=(float)1.23 && F1<(float)1.27) C1=_T("5:4");
+ else if (F1>=(float)1.30 && F1<(float)1.37) C1=_T("4:3");
+ else if (F1>=(float)1.45 && F1<(float)1.55) C1=_T("3:2");
+ else if (F1>=(float)1.74 && F1<(float)1.82) C1=_T("16:9");
+ else if (F1>=(float)1.82 && F1<(float)1.88) C1=_T("1.85:1");
+ else if (F1>=(float)2.15 && F1<(float)2.22) C1=_T("2.2:1");
+ else if (F1>=(float)2.23 && F1<(float)2.30) C1=_T("2.25:1");
+ else if (F1>=(float)2.30 && F1<(float)2.37) C1=_T("2.35:1");
+ else if (F1>=(float)2.37 && F1<(float)2.45) C1=_T("2.40:1");
+ else C1.From_Number(F1);
+ C1.FindAndReplace(_T("."), MediaInfoLib::Config.Language_Get(_T(" Config_Text_FloatSeparator")));
+ if (MediaInfoLib::Config.Language_Get(_T(" Language_ISO639"))==_T("fr") && C1.find(_T(":1"))==string::npos)
+ C1.FindAndReplace(_T(":"), _T("/"));
+ Fill(Stream_Image, StreamPos, Image_DisplayAspectRatio_String, C1, true);
+ }
+
+ //Original Display Aspect Ratio and Original Pixel Aspect Ratio
+ if (StreamKind==Stream_Image && Parameter==Image_DisplayAspectRatio_Original)
+ {
+ float F1=Retrieve(Stream_Image, StreamPos, Image_DisplayAspectRatio_Original).To_float32();
+ Ztring C1;
+ if (F1>=(float)1.23 && F1<(float)1.27) C1=_T("5:4");
+ else if (F1>=(float)1.30 && F1<(float)1.37) C1=_T("4:3");
+ else if (F1>=(float)1.45 && F1<(float)1.55) C1=_T("3:2");
+ else if (F1>=(float)1.74 && F1<(float)1.82) C1=_T("16:9");
+ else if (F1>=(float)1.82 && F1<(float)1.88) C1=_T("1.85:1");
+ else if (F1>=(float)2.15 && F1<(float)2.22) C1=_T("2.2:1");
+ else if (F1>=(float)2.23 && F1<(float)2.30) C1=_T("2.25:1");
+ else if (F1>=(float)2.30 && F1<(float)2.37) C1=_T("2.35:1");
+ else if (F1>=(float)2.37 && F1<(float)2.45) C1=_T("2.40:1");
+ else C1.From_Number(F1);
+ C1.FindAndReplace(_T("."), MediaInfoLib::Config.Language_Get(_T(" Config_Text_FloatSeparator")));
+ if (MediaInfoLib::Config.Language_Get(_T(" Language_ISO639"))==_T("fr") && C1.find(_T(":1"))==string::npos)
+ C1.FindAndReplace(_T(":"), _T("/"));
+ Fill(Stream_Image, StreamPos, Image_DisplayAspectRatio_Original_String, C1, true);
+ }
+
+ //Bits/(Pixel*Frame)
+ if (StreamKind==Stream_Video && (Parameter==Video_BitRate || Parameter==Video_BitRate_Nominal || Parameter==Video_Width || Parameter==Video_Height || Parameter==Video_FrameRate))
+ {
+ float32 BitRate=Retrieve(Stream_Video, StreamPos, Video_BitRate).To_float32();
+ if (BitRate==0)
+ BitRate=Retrieve(Stream_Video, StreamPos, Video_BitRate_Nominal).To_float32();
+ float F1=(float)Retrieve(Stream_Video, StreamPos, Video_Width).To_int32s()*(float)Retrieve(Stream_Video, StreamPos, Video_Height).To_int32s()*Retrieve(Stream_Video, StreamPos, Video_FrameRate).To_float32();
+ if (BitRate && F1)
+ Fill(Stream_Video, StreamPos, Video_Bits__Pixel_Frame_, BitRate/F1, 3, true);
+ }
+
+ //Special audio cases
+ if (StreamKind==Stream_Audio && Parameter==Audio_CodecID
+ && Retrieve(Stream_Audio, StreamPos, Audio_Channel_s_).empty()
+ &&(Value==_T("samr")
+ || Value==_T("sawb")
+ || Value==_T("7A21")
+ || Value==_T("7A22"))
+ )
+ Fill(Stream_Audio, StreamPos, Audio_Channel_s_, 1, 10, true); //AMR is always with 1 channel
+
+ //Well known bitrate values
+ if (StreamKind==Stream_Video && (Parameter==Video_BitRate || Parameter==Video_BitRate_Nominal))
+ Video_BitRate_Rounding(StreamPos, (video)Parameter);
+ if (StreamKind==Stream_Audio && (Parameter==Audio_BitRate || Parameter==Audio_BitRate_Nominal))
+ Audio_BitRate_Rounding(StreamPos, (audio)Parameter);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Fill (stream_t StreamKind, size_t StreamPos, const char* Parameter, const Ztring &Value, bool Replace)
+{
+ //Integrity
+ if (!Status[IsAccepted] || StreamKind>Stream_Max || Parameter==NULL || Parameter[0]=='\0')
+ return;
+
+ //Handling values with \r\n inside
+ if (Value.find(_T('\r'))!=string::npos || Value.find(_T('\n'))!=string::npos)
+ {
+ Ztring NewValue=Value;
+ NewValue.FindAndReplace(_T("\r\n"), _T(" / "), 0, Ztring_Recursive);
+ NewValue.FindAndReplace(_T("\r"), _T(" / "), 0, Ztring_Recursive);
+ NewValue.FindAndReplace(_T("\n"), _T(" / "), 0, Ztring_Recursive);
+ if (NewValue.size()>=3 && NewValue.rfind(_T(" / "))==NewValue.size()-3)
+ NewValue.resize(NewValue.size()-3);
+ Fill(StreamKind, StreamPos, Parameter, NewValue, Replace);
+ return;
+ }
+
+ //Handle Value before StreamKind
+ if (StreamKind==Stream_Max || StreamPos>=(*Stream)[StreamKind].size())
+ {
+ Ztring ParameterZ=Ztring().From_UTF8(Parameter);
+ if (Replace)
+ for (size_t Pos=0; Pos<Fill_Temp.size(); Pos++)
+ if (Fill_Temp[Pos](0)==ParameterZ)
+ {
+ Fill_Temp.erase(Fill_Temp.begin()+Pos);
+ Pos--;
+ }
+ ZtringList NewList;
+ NewList.push_back(ParameterZ);
+ NewList.push_back(Value);
+ Fill_Temp.push_back(NewList);
+ return; //No streams
+ }
+
+ //Handling of well known parameters
+ size_t Pos=MediaInfoLib::Config.Info_Get(StreamKind).Find(Ztring().From_Local(Parameter));
+ if (Pos!=Error)
+ {
+ Fill(StreamKind, StreamPos, Pos, Value, Replace);
+ return;
+ }
+
+ //Handling of unknown parameters
+ if (Value.empty())
+ {
+ if (Replace)
+ {
+ size_t Pos_ToReplace=(*Stream_More)[StreamKind][StreamPos].Find(Ztring().From_ISO_8859_1(Parameter), Info_Name);
+ if (Pos_ToReplace!=(size_t)-1)
+ (*Stream_More)[StreamKind][StreamPos].erase((*Stream_More)[StreamKind][StreamPos].begin()+Pos_ToReplace); //Empty value --> remove the line
+ }
+ }
+ else
+ {
+ Ztring &Target=(*Stream_More)[StreamKind][StreamPos](Ztring().From_ISO_8859_1(Parameter), Info_Text);
+ if (Target.empty() || Replace)
+ {
+ Target=Value; //First value
+ (*Stream_More)[StreamKind][StreamPos](Ztring().From_ISO_8859_1(Parameter), Info_Name_Text)=MediaInfoLib::Config.Language_Get(Ztring().From_Local(Parameter));
+ (*Stream_More)[StreamKind][StreamPos](Ztring().From_ISO_8859_1(Parameter), Info_Options)=_T("Y NT");
+ }
+ else
+ {
+ Target+=MediaInfoLib::Config.TagSeparator_Get();
+ Target+=Value;
+ }
+ }
+ Fill(StreamKind, StreamPos, (size_t)General_Count, Count_Get(StreamKind, StreamPos), 10, true);
+}
+
+//---------------------------------------------------------------------------
+const Ztring &File__Analyze::Retrieve_Const (stream_t StreamKind, size_t StreamPos, size_t Parameter, info_t KindOfInfo)
+{
+ //Integrity
+ if (StreamKind>=Stream_Max
+ || StreamPos>=(*Stream)[StreamKind].size()
+ || Parameter>=(*Stream)[StreamKind][StreamPos].size())
+ return MediaInfoLib::Config.EmptyString_Get();
+
+ if (KindOfInfo!=Info_Text)
+ return MediaInfoLib::Config.Info_Get(StreamKind, Parameter, KindOfInfo);
+ return (*Stream)[StreamKind][StreamPos](Parameter);
+}
+
+//---------------------------------------------------------------------------
+Ztring File__Analyze::Retrieve (stream_t StreamKind, size_t StreamPos, size_t Parameter, info_t KindOfInfo)
+{
+ //Integrity
+ if (StreamKind>=Stream_Max
+ || StreamPos>=(*Stream)[StreamKind].size()
+ || Parameter>=(*Stream)[StreamKind][StreamPos].size())
+ return MediaInfoLib::Config.EmptyString_Get();
+
+ if (KindOfInfo!=Info_Text)
+ return MediaInfoLib::Config.Info_Get(StreamKind, Parameter, KindOfInfo);
+ return (*Stream)[StreamKind][StreamPos](Parameter);
+}
+
+//---------------------------------------------------------------------------
+const Ztring &File__Analyze::Retrieve_Const (stream_t StreamKind, size_t StreamPos, const char* Parameter, info_t KindOfInfo)
+{
+ //Integrity
+ if (StreamKind>=Stream_Max
+ || StreamPos>=(*Stream)[StreamKind].size()
+ || Parameter==NULL
+ || Parameter[0]=='\0')
+ return MediaInfoLib::Config.EmptyString_Get();
+
+ if (KindOfInfo!=Info_Text)
+ return MediaInfoLib::Config.Info_Get(StreamKind, Parameter, KindOfInfo);
+ size_t Parameter_Pos=MediaInfoLib::Config.Info_Get(StreamKind).Find(Ztring().From_Local(Parameter));
+ if (Parameter_Pos==Error)
+ {
+ Parameter_Pos=(*Stream_More)[StreamKind][StreamPos].Find(Ztring().From_Local(Parameter));
+ if (Parameter_Pos==Error)
+ return MediaInfoLib::Config.EmptyString_Get();
+ return (*Stream_More)[StreamKind][StreamPos](Parameter_Pos, 1);
+ }
+ return (*Stream)[StreamKind][StreamPos](Parameter_Pos);
+}
+
+//---------------------------------------------------------------------------
+Ztring File__Analyze::Retrieve (stream_t StreamKind, size_t StreamPos, const char* Parameter, info_t KindOfInfo)
+{
+ //Integrity
+ if (StreamKind>=Stream_Max
+ || StreamPos>=(*Stream)[StreamKind].size()
+ || Parameter==NULL
+ || Parameter[0]=='\0')
+ return MediaInfoLib::Config.EmptyString_Get();
+
+ if (KindOfInfo!=Info_Text)
+ return MediaInfoLib::Config.Info_Get(StreamKind, Parameter, KindOfInfo);
+ size_t Parameter_Pos=MediaInfoLib::Config.Info_Get(StreamKind).Find(Ztring().From_Local(Parameter));
+ if (Parameter_Pos==Error)
+ {
+ Parameter_Pos=(*Stream_More)[StreamKind][StreamPos].Find(Ztring().From_Local(Parameter));
+ if (Parameter_Pos==Error)
+ return MediaInfoLib::Config.EmptyString_Get();
+ return (*Stream_More)[StreamKind][StreamPos](Parameter_Pos, 1);
+ }
+ return (*Stream)[StreamKind][StreamPos](Parameter_Pos);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Clear (stream_t StreamKind, size_t StreamPos, const char* Parameter)
+{
+ //Integrity
+ if (StreamKind>=Stream_Max
+ || StreamPos>=(*Stream)[StreamKind].size()
+ || Parameter==NULL
+ || Parameter[0]=='\0')
+ return;
+
+ size_t Parameter_Pos=MediaInfoLib::Config.Info_Get(StreamKind).Find(Ztring().From_Local(Parameter));
+ if (Parameter_Pos==Error)
+ {
+ Parameter_Pos=(*Stream_More)[StreamKind][StreamPos].Find(Ztring().From_Local(Parameter));
+ if (Parameter_Pos==Error)
+ return;
+ (*Stream_More)[StreamKind][StreamPos](Parameter_Pos, 1).clear();
+ return;
+ }
+
+ Clear(StreamKind, StreamPos, Parameter_Pos);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Clear (stream_t StreamKind, size_t StreamPos, size_t Parameter)
+{
+ //Integrity
+ if (StreamKind>=Stream_Max
+ || StreamPos>=(*Stream)[StreamKind].size())
+ return;
+
+ //Normal
+ if (Parameter<MediaInfoLib::Config.Info_Get(StreamKind).size())
+ {
+ //Is something available?
+ if (Parameter>=(*Stream)[StreamKind][StreamPos].size())
+ return; //Was never filled, no nead to clear it
+
+ //Clearing
+ (*Stream)[StreamKind][StreamPos][Parameter].clear();
+
+ //Human readable
+ if (MediaInfoLib::Config.ReadByHuman_Get())
+ {
+ //Strings
+ const Ztring &List_Measure_Value=MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter, Info_Measure);
+ if (List_Measure_Value==_T(" byte"))
+ {
+ const Ztring &Temp=MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter, Info_Name);
+ size_t List_Size=Temp.find(_T("StreamSize"))==string::npos?5:7; //for /String5, with percentage, and proportion
+ for (size_t Pos=Parameter+1; Pos<=Parameter+List_Size; Pos++)
+ if (Pos<(*Stream)[StreamKind][StreamPos].size())
+ (*Stream)[StreamKind][StreamPos][Pos].clear();
+ }
+ else if (List_Measure_Value==_T(" bps") || List_Measure_Value==_T(" Hz"))
+ {
+ if (Parameter+1<(*Stream)[StreamKind][StreamPos].size())
+ (*Stream)[StreamKind][StreamPos][Parameter+1].clear();
+ }
+ else if (List_Measure_Value==_T(" ms"))
+ {
+ for (size_t Pos=Parameter+1; Pos<=Parameter+4; Pos++)
+ if (Pos<(*Stream)[StreamKind][StreamPos].size())
+ (*Stream)[StreamKind][StreamPos][Pos].clear();
+ }
+ else if (List_Measure_Value==_T("Yes"))
+ {
+ if (Parameter+1<(*Stream)[StreamKind][StreamPos].size())
+ (*Stream)[StreamKind][StreamPos][Parameter+1].clear();
+ }
+ else if (!List_Measure_Value.empty())
+ {
+ if (Parameter+1<(*Stream)[StreamKind][StreamPos].size())
+ (*Stream)[StreamKind][StreamPos][Parameter+1].clear();
+ }
+ }
+
+ return;
+ }
+
+ //More
+ Parameter-=(*Stream)[StreamKind][StreamPos].size(); //For having Stream_More position
+ if (Parameter<(*Stream_More)[StreamKind][StreamPos].size())
+ {
+ (*Stream_More)[StreamKind][StreamPos].erase((*Stream_More)[StreamKind][StreamPos].begin()+Parameter);
+ return;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Clear (stream_t StreamKind, size_t StreamPos)
+{
+ //Integrity
+ if (StreamKind>=Stream_Max
+ || StreamPos>=(*Stream)[StreamKind].size())
+ return;
+
+ (*Stream)[StreamKind].erase((*Stream)[StreamKind].begin()+StreamPos);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Clear (stream_t StreamKind)
+{
+ //Integrity
+ if (StreamKind>=Stream_Max)
+ return;
+
+ (*Stream)[StreamKind].clear();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Fill_Flush()
+{
+ Stream_Prepare(Stream_Max); //clear filling
+ Fill_Temp.clear();
+}
+
+//---------------------------------------------------------------------------
+size_t File__Analyze::Merge(MediaInfo_Internal &ToAdd, bool)
+{
+ size_t Count=0;
+ for (size_t StreamKind=(size_t)Stream_General; StreamKind<(size_t)Stream_Max; StreamKind++)
+ {
+ size_t StreamPos_Count=ToAdd.Count_Get((stream_t)StreamKind);
+ for (size_t StreamPos=0; StreamPos<StreamPos_Count; StreamPos++)
+ {
+ //Prepare a new stream
+ if (StreamPos>=Count_Get((stream_t)StreamKind))
+ Stream_Prepare((stream_t)StreamKind);
+
+ //Merge
+ size_t Pos_Count=ToAdd.Count_Get((stream_t)StreamKind, StreamPos);
+ for (size_t Pos=0; Pos<Pos_Count; Pos++)
+ {
+ if (StreamKind!=Stream_General
+ || !(Pos==General_CompleteName
+ || Pos==General_FolderName
+ || Pos==General_FileName
+ || Pos==General_FileExtension
+ || Pos==General_File_Created_Date
+ || Pos==General_Format
+ || Pos==General_Format_String
+ || Pos==General_Format_Extensions
+ || Pos==General_Format_Info
+ || Pos==General_Codec
+ || Pos==General_Codec_String
+ || Pos==General_Codec_Extensions
+ || Pos==General_FileSize
+ || Pos==General_FileSize_String
+ || Pos==General_FileSize_String1
+ || Pos==General_FileSize_String2
+ || Pos==General_FileSize_String3
+ || Pos==General_FileSize_String4
+ || Pos==General_File_Created_Date_Local
+ || Pos==General_File_Modified_Date
+ || Pos==General_File_Modified_Date_Local))
+ Fill((stream_t)StreamKind, StreamPos, Ztring(ToAdd.Get((stream_t)StreamKind, StreamPos, Pos, Info_Name)).To_UTF8().c_str(), ToAdd.Get((stream_t)StreamKind, StreamPos, Pos), true);
+ }
+
+ Count++;
+ }
+ }
+
+ return Count;
+}
+
+//---------------------------------------------------------------------------
+size_t File__Analyze::Merge(MediaInfo_Internal &ToAdd, stream_t StreamKind, size_t StreamPos_From, size_t StreamPos_To, bool)
+{
+ size_t Pos_Count=ToAdd.Count_Get(StreamKind, StreamPos_From);
+ for (size_t Pos=General_Inform; Pos<Pos_Count; Pos++)
+ if (!ToAdd.Get(StreamKind, StreamPos_From, Pos).empty())
+ Fill(StreamKind, StreamPos_To, Ztring(ToAdd.Get((stream_t)StreamKind, StreamPos_From, Pos, Info_Name)).To_UTF8().c_str(), ToAdd.Get(StreamKind, StreamPos_From, Pos), true);
+
+ return 1;
+}
+
+//---------------------------------------------------------------------------
+size_t File__Analyze::Merge(File__Analyze &ToAdd, bool Erase)
+{
+ size_t Count=0;
+ for (size_t StreamKind=(size_t)Stream_General+1; StreamKind<(size_t)Stream_Max; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<(*ToAdd.Stream)[StreamKind].size(); StreamPos++)
+ {
+ //Prepare a new stream
+ Stream_Prepare((stream_t)StreamKind);
+
+ //Merge
+ Merge(ToAdd, (stream_t)StreamKind, StreamPos, StreamPos_Last, Erase);
+
+ Count++;
+ }
+ return Count;
+}
+
+//---------------------------------------------------------------------------
+size_t File__Analyze::Merge(File__Analyze &ToAdd, stream_t StreamKind, size_t StreamPos_From, size_t StreamPos_To, bool Erase)
+{
+ //Integrity
+ if (!Status[IsAccepted] || &ToAdd==NULL || StreamKind>=Stream_Max || !ToAdd.Stream || StreamPos_From>=(*ToAdd.Stream)[StreamKind].size())
+ return 0;
+
+ //Destination
+ while (StreamPos_To>=(*Stream)[StreamKind].size())
+ Stream_Prepare(StreamKind);
+
+ //Specific stuff
+ Ztring Width_Temp, Height_Temp, PixelAspectRatio_Temp, DisplayAspectRatio_Temp, FrameRate_Temp, FrameRate_Mode_Temp, Delay_Temp, Delay_Source_Temp, Delay_Settings_Temp, Source_Temp, Source_Kind_Temp, Source_Info_Temp;
+ if (StreamKind==Stream_Video)
+ {
+ Width_Temp=Retrieve(Stream_Video, StreamPos_To, Video_Width);
+ Height_Temp=Retrieve(Stream_Video, StreamPos_To, Video_Height);
+ PixelAspectRatio_Temp=Retrieve(Stream_Video, StreamPos_To, Video_PixelAspectRatio); //We want to keep the PixelAspectRatio_Temp of the video stream
+ DisplayAspectRatio_Temp=Retrieve(Stream_Video, StreamPos_To, Video_DisplayAspectRatio); //We want to keep the DisplayAspectRatio_Temp of the video stream
+ FrameRate_Temp=Retrieve(Stream_Video, StreamPos_To, Video_FrameRate); //We want to keep the FrameRate of AVI 120 fps
+ FrameRate_Mode_Temp=Retrieve(Stream_Video, StreamPos_To, Video_FrameRate_Mode); //We want to keep the FrameRate_Mode of AVI 120 fps
+ }
+ if (ToAdd.Retrieve(StreamKind, StreamPos_From, Fill_Parameter(StreamKind, Generic_Delay_Source))==_T("Container"))
+ {
+ Fill(StreamKind, StreamPos_To, "Delay_Original", Retrieve(StreamKind, StreamPos_To, "Delay"), true);
+ Clear(StreamKind, StreamPos_To, "Delay");
+ Fill(StreamKind, StreamPos_To, "Delay_Original_Source", Retrieve(StreamKind, StreamPos_To, "Delay_Source"), true);
+ Clear(StreamKind, StreamPos_To, "Delay_Source");
+ if (!ToAdd.Retrieve(StreamKind, StreamPos_To, "Format").empty()) //Exception: MPEG-4 TimeCode, settings are in the MPEG-4 header
+ {
+ Fill(StreamKind, StreamPos_To, "Delay_Original_Settings", Retrieve(StreamKind, StreamPos_To, "Delay_Settings"), true);
+ Clear(StreamKind, StreamPos_To, "Delay_Settings");
+ }
+ }
+ else
+ {
+ Delay_Temp=Retrieve(StreamKind, StreamPos_To, "Delay"); //We want to keep the Delay from the stream
+ Delay_Settings_Temp=Retrieve(StreamKind, StreamPos_To, "Delay_Settings"); //We want to keep the Delay_Settings from the stream
+ Delay_Source_Temp=Retrieve(StreamKind, StreamPos_To, "Delay_Source"); //We want to keep the Delay_Source from the stream
+ }
+ Source_Temp=Retrieve(StreamKind, StreamPos_To, "Source");
+ Source_Kind_Temp=Retrieve(StreamKind, StreamPos_To, "Source_Kind");
+ Source_Info_Temp=Retrieve(StreamKind, StreamPos_To, "Source_Info");
+
+ //Merging
+ size_t Count=0;
+ size_t Size=ToAdd.Count_Get(StreamKind, StreamPos_From);
+ for (size_t Pos=General_Inform; Pos<Size; Pos++)
+ {
+ const Ztring &ToFill_Value=ToAdd.Get(StreamKind, StreamPos_From, Pos);
+ if (!ToFill_Value.empty() && (Erase || Get(StreamKind, StreamPos_To, Pos).empty()))
+ {
+ if (Pos<MediaInfoLib::Config.Info_Get(StreamKind).size())
+ Fill(StreamKind, StreamPos_To, Pos, ToFill_Value, true);
+ else
+ {
+ Fill(StreamKind, StreamPos_To, ToAdd.Get(StreamKind, StreamPos_From, Pos, Info_Name).To_UTF8().c_str(), ToFill_Value, true);
+ (*Stream_More)[StreamKind][StreamPos_To](ToAdd.Get(StreamKind, StreamPos_From, Pos, Info_Name), Info_Options)=ToAdd.Get(StreamKind, StreamPos_From, Pos, Info_Options);
+ }
+ Count++;
+ }
+ }
+
+ //Specific stuff
+ if (StreamKind==Stream_Video)
+ {
+ Ztring PixelAspectRatio_Original=Retrieve(Stream_Video, StreamPos_To, Video_PixelAspectRatio);
+ Ztring DisplayAspectRatio_Original=Retrieve(Stream_Video, StreamPos_To, Video_DisplayAspectRatio);
+
+ if (!Width_Temp.empty() && Width_Temp!=Retrieve(Stream_Video, StreamPos_To, Video_Width))
+ {
+ Fill(Stream_Video, StreamPos_To, Video_Width_Original, (*Stream)[Stream_Video][StreamPos_To][Video_Width], true);
+ Fill(Stream_Video, StreamPos_To, Video_Width, Width_Temp, true);
+ }
+ if (!Height_Temp.empty() && Height_Temp!=Retrieve(Stream_Video, StreamPos_To, Video_Height))
+ {
+ Fill(Stream_Video, StreamPos_To, Video_Height_Original, (*Stream)[Stream_Video][StreamPos_To][Video_Height], true);
+ Fill(Stream_Video, StreamPos_To, Video_Height, Height_Temp, true);
+ }
+ if (!PixelAspectRatio_Temp.empty() && PixelAspectRatio_Temp!=Retrieve(Stream_Video, StreamPos_To, Video_PixelAspectRatio))
+ {
+ Fill(Stream_Video, StreamPos_To, Video_PixelAspectRatio_Original, PixelAspectRatio_Original, true);
+ Fill(Stream_Video, StreamPos_To, Video_PixelAspectRatio, PixelAspectRatio_Temp, true);
+ }
+ if (!DisplayAspectRatio_Temp.empty() && DisplayAspectRatio_Temp!=DisplayAspectRatio_Original)
+ {
+ Fill(Stream_Video, StreamPos_To, Video_DisplayAspectRatio_Original, DisplayAspectRatio_Original, true);
+ Fill(Stream_Video, StreamPos_To, Video_DisplayAspectRatio, DisplayAspectRatio_Temp, true);
+ }
+ if (!FrameRate_Temp.empty() && FrameRate_Temp!=Retrieve(Stream_Video, StreamPos_To, Video_FrameRate))
+ {
+ Fill(Stream_Video, StreamPos_To, Video_FrameRate_Original, (*Stream)[Stream_Video][StreamPos_To][Video_FrameRate], true);
+ Fill(Stream_Video, StreamPos_To, Video_FrameRate, FrameRate_Temp, true);
+ }
+ if (!FrameRate_Mode_Temp.empty() && FrameRate_Mode_Temp!=Retrieve(Stream_Video, StreamPos_To, Video_FrameRate_Mode))
+ {
+ Fill(Stream_Video, StreamPos_To, Video_FrameRate_Mode_Original, (*Stream)[Stream_Video][StreamPos_To][Video_FrameRate_Mode], true);
+ Fill(Stream_Video, StreamPos_To, Video_FrameRate_Mode, FrameRate_Mode_Temp, true);
+ }
+ }
+ if (!Delay_Source_Temp.empty() && Delay_Source_Temp!=Retrieve(StreamKind, StreamPos_To, "Delay_Source"))
+ {
+ Fill(StreamKind, StreamPos_To, "Delay_Original", Retrieve(StreamKind, StreamPos_To, "Delay"), true);
+ Fill(StreamKind, StreamPos_To, "Delay", Delay_Temp, true);
+ Fill(StreamKind, StreamPos_To, "Delay_Original_Settings", Retrieve(StreamKind, StreamPos_To, "Delay_Settings"), true);
+ Fill(StreamKind, StreamPos_To, "Delay_Settings", Delay_Settings_Temp, true);
+ Fill(StreamKind, StreamPos_To, "Delay_Original_Source", Retrieve(StreamKind, StreamPos_To, "Delay_Source"), true);
+ Fill(StreamKind, StreamPos_To, "Delay_Source", Delay_Source_Temp, true);
+ }
+ if (!Source_Temp.empty() && Source_Temp!=Retrieve(StreamKind, StreamPos_To, "Source"))
+ {
+ Fill(StreamKind, StreamPos_To, "Source_Original", Retrieve(StreamKind, StreamPos_To, "Source"), true);
+ Fill(StreamKind, StreamPos_To, "Source", Source_Temp, true);
+ Fill(StreamKind, StreamPos_To, "Source_Original_Kind", Retrieve(StreamKind, StreamPos_To, "Source_Kind"), true);
+ Fill(StreamKind, StreamPos_To, "Source_Kind", Source_Info_Temp, true);
+ Fill(StreamKind, StreamPos_To, "Source_Original_Info", Retrieve(StreamKind, StreamPos_To, "Source_Info"), true);
+ Fill(StreamKind, StreamPos_To, "Source_Info", Source_Info_Temp, true);
+ }
+
+ Fill(StreamKind, StreamPos_To, (size_t)General_Count, Count_Get(StreamKind, StreamPos_To), 10, true);
+ return 1;
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Analyze::Video_FrameRate_Rounding(size_t Pos, video Parameter)
+{
+ float64 FrameRate=Retrieve(Stream_Video, Pos, Parameter).To_float64();
+ float64 FrameRate_Sav=FrameRate;
+
+ if (FrameRate> 9.990 && FrameRate<=10.010) FrameRate=10.000;
+ else if (FrameRate>14.990 && FrameRate<=15.010) FrameRate=15.000;
+ else if (FrameRate>23.964 && FrameRate<=23.988) FrameRate=23.976;
+ else if (FrameRate>23.988 && FrameRate<=24.012) FrameRate=24.000;
+ else if (FrameRate>24.988 && FrameRate<=25.012) FrameRate=25.000;
+ else if (FrameRate>29.955 && FrameRate<=29.985) FrameRate=29.970;
+ else if (FrameRate>29.985 && FrameRate<=30.015) FrameRate=30.000;
+ else if (FrameRate>23.964*2 && FrameRate<=23.988*2) FrameRate=23.976*2;
+ else if (FrameRate>23.988*2 && FrameRate<=24.012*2) FrameRate=24.000*2;
+ else if (FrameRate>24.988*2 && FrameRate<=25.012*2) FrameRate=25.000*2;
+ else if (FrameRate>29.955*2 && FrameRate<=29.985*2) FrameRate=29.970*2;
+ else if (FrameRate>30.985*2 && FrameRate<=30.015*2) FrameRate=30.000*2;
+
+ if (FrameRate!=FrameRate_Sav)
+ Fill(Stream_Video, Pos, Parameter, FrameRate, 3, true);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Video_BitRate_Rounding(size_t Pos, video Parameter)
+{
+ const Ztring& Format=Retrieve(Stream_Video, Pos, Video_Format);
+ int32u BitRate=Retrieve(Stream_Video, Pos, Parameter).To_int32u();
+ int32u BitRate_Sav=BitRate;
+ if (Format==_T("AVC"))
+ {
+ if (BitRate>= 54942720 && BitRate<= 57185280) BitRate= 56064000; //AVC-INTRA50
+ if (BitRate>=111390720 && BitRate<=115937280) BitRate=113664000; //AVC-INTRA100
+ }
+
+ if (BitRate!=BitRate_Sav)
+ Fill(Stream_Video, Pos, Parameter, BitRate, 0, true);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Audio_BitRate_Rounding(size_t Pos, audio Parameter)
+{
+ const Ztring& Format=Retrieve(Stream_Audio, Pos, Audio_Format);
+ const Ztring& Codec=Retrieve(Stream_Audio, Pos, Audio_Codec);
+ int32u BitRate=Retrieve(Stream_Audio, Pos, Parameter).To_int32u();
+ int32u BitRate_Sav=BitRate;
+ if (MediaInfoLib::Config.Codec_Get(Codec, InfoCodec_KindofCodec, Stream_Audio).find(_T("MPEG-"))==0
+ || Retrieve(Stream_Audio, Pos, Audio_Codec_String).find(_T("MPEG-"))==0)
+ {
+ if (BitRate>= 7500 && BitRate<= 8500) BitRate= 8000;
+ if (BitRate>= 15000 && BitRate<= 17000) BitRate= 16000;
+ if (BitRate>= 23000 && BitRate<= 25000) BitRate= 24000;
+ if (BitRate>= 31000 && BitRate<= 33000) BitRate= 32000;
+ if (BitRate>= 38000 && BitRate<= 42000) BitRate= 40000;
+ if (BitRate>= 46000 && BitRate<= 50000) BitRate= 48000;
+ if (BitRate>= 54000 && BitRate<= 58000) BitRate= 56000;
+ if (BitRate>= 62720 && BitRate<= 65280) BitRate= 64000;
+ if (BitRate>= 78400 && BitRate<= 81600) BitRate= 80000;
+ if (BitRate>= 94080 && BitRate<= 97920) BitRate= 96000;
+ if (BitRate>= 109760 && BitRate<= 114240) BitRate= 112000;
+ if (BitRate>= 125440 && BitRate<= 130560) BitRate= 128000;
+ if (BitRate>= 156800 && BitRate<= 163200) BitRate= 160000;
+ if (BitRate>= 156800 && BitRate<= 163200) BitRate= 160000;
+ if (BitRate>= 188160 && BitRate<= 195840) BitRate= 192000;
+ if (BitRate>= 219520 && BitRate<= 228480) BitRate= 224000;
+ if (BitRate>= 219520 && BitRate<= 228480) BitRate= 224000;
+ if (BitRate>= 250880 && BitRate<= 261120) BitRate= 256000;
+ if (BitRate>= 282240 && BitRate<= 293760) BitRate= 288000;
+ if (BitRate>= 313600 && BitRate<= 326400) BitRate= 320000;
+ if (BitRate>= 344960 && BitRate<= 359040) BitRate= 352000;
+ if (BitRate>= 376320 && BitRate<= 391680) BitRate= 384000;
+ if (BitRate>= 407680 && BitRate<= 424320) BitRate= 416000;
+ if (BitRate>= 439040 && BitRate<= 456960) BitRate= 448000;
+ if (Retrieve(Stream_Audio, Pos, "BitRate_Mode")==_T("VBR"))
+ BitRate=BitRate_Sav; //If VBR, we want the exact value
+ }
+
+ else if (MediaInfoLib::Config.Codec_Get(Codec, InfoCodec_Name, Stream_Audio).find(_T("AC3"))==0)
+ {
+ if (BitRate>= 31000 && BitRate<= 33000) BitRate= 32000;
+ if (BitRate>= 39000 && BitRate<= 41000) BitRate= 40000;
+ if (BitRate>= 46000 && BitRate<= 50000) BitRate= 48000;
+ if (BitRate>= 54000 && BitRate<= 58000) BitRate= 56000;
+ if (BitRate>= 62720 && BitRate<= 65280) BitRate= 64000;
+ if (BitRate>= 78400 && BitRate<= 81600) BitRate= 80000;
+ if (BitRate>= 94080 && BitRate<= 97920) BitRate= 96000;
+ if (BitRate>= 109760 && BitRate<= 114240) BitRate= 112000;
+ if (BitRate>= 125440 && BitRate<= 130560) BitRate= 128000;
+ if (BitRate>= 156800 && BitRate<= 163200) BitRate= 160000;
+ if (BitRate>= 188160 && BitRate<= 195840) BitRate= 192000;
+ if (BitRate>= 219520 && BitRate<= 228480) BitRate= 224000;
+ if (BitRate>= 250880 && BitRate<= 261120) BitRate= 256000;
+ if (BitRate>= 313600 && BitRate<= 326400) BitRate= 320000;
+ if (BitRate>= 376320 && BitRate<= 391680) BitRate= 384000;
+ if (BitRate>= 439040 && BitRate<= 456960) BitRate= 448000;
+ if (BitRate>= 501760 && BitRate<= 522240) BitRate= 512000;
+ if (BitRate>= 564480 && BitRate<= 587520) BitRate= 576000;
+ if (BitRate>= 627200 && BitRate<= 652800) BitRate= 640000;
+ }
+
+ else if (MediaInfoLib::Config.Codec_Get(Codec, InfoCodec_Name, Stream_Audio).find(_T("DTS"))==0)
+ {
+ if (BitRate>= 31000 && BitRate<= 33000) BitRate= 32000;
+ if (BitRate>= 54000 && BitRate<= 58000) BitRate= 56000;
+ if (BitRate>= 62720 && BitRate<= 65280) BitRate= 64000;
+ if (BitRate>= 94080 && BitRate<= 97920) BitRate= 96000;
+ if (BitRate>= 109760 && BitRate<= 114240) BitRate= 112000;
+ if (BitRate>= 125440 && BitRate<= 130560) BitRate= 128000;
+ if (BitRate>= 188160 && BitRate<= 195840) BitRate= 192000;
+ if (BitRate>= 219520 && BitRate<= 228480) BitRate= 224000;
+ if (BitRate>= 250880 && BitRate<= 261120) BitRate= 256000;
+ if (BitRate>= 313600 && BitRate<= 326400) BitRate= 320000;
+ if (BitRate>= 376320 && BitRate<= 391680) BitRate= 384000;
+ if (BitRate>= 439040 && BitRate<= 456960) BitRate= 448000;
+ if (BitRate>= 501760 && BitRate<= 522240) BitRate= 512000;
+ if (BitRate>= 564480 && BitRate<= 587520) BitRate= 576000;
+ if (BitRate>= 627200 && BitRate<= 652800) BitRate= 640000;
+ if (BitRate>= 752640 && BitRate<= 783360) BitRate= 768000;
+ if (BitRate>= 940800 && BitRate<= 979200) BitRate= 960000;
+ if (BitRate>=1003520 && BitRate<=1044480) BitRate=1024000;
+ if (BitRate>=1128960 && BitRate<=1175040) BitRate=1152000;
+ if (BitRate>=1254400 && BitRate<=1305600) BitRate=1280000;
+ if (BitRate>=1317120 && BitRate<=1370880) BitRate=1344000;
+ if (BitRate>=1379840 && BitRate<=1436160) BitRate=1408000;
+ if (BitRate>=1382976 && BitRate<=1439424) BitRate=1411200;
+ if (BitRate>=1442560 && BitRate<=1501440) BitRate=1472000;
+ if (BitRate>=1505280 && BitRate<=1566720) BitRate=1536000;
+ if (BitRate>=1881600 && BitRate<=1958400) BitRate=1920000;
+ if (BitRate>=2007040 && BitRate<=2088960) BitRate=2048000;
+ if (BitRate>=3010560 && BitRate<=3133440) BitRate=3072000;
+ if (BitRate>=3763200 && BitRate<=3916800) BitRate=3840000;
+ }
+
+ else if (Codec.find(_T("AAC"))==0 || MediaInfoLib::Config.Codec_Get(Codec, InfoCodec_Name, Stream_Audio).find(_T("AAC"))==0)
+ {
+ if (BitRate>= 46000 && BitRate<= 50000) BitRate= 48000;
+ if (BitRate>= 64827 && BitRate<= 67473) BitRate= 66150;
+ if (BitRate>= 70560 && BitRate<= 73440) BitRate= 72000;
+ if (BitRate>= 94080 && BitRate<= 97920) BitRate= 96000;
+ if (BitRate>= 94080 && BitRate<= 97920) BitRate= 96000;
+ if (BitRate>= 129654 && BitRate<= 134946) BitRate= 132300;
+ if (BitRate>= 141120 && BitRate<= 146880) BitRate= 144000;
+ if (BitRate>= 188160 && BitRate<= 195840) BitRate= 192000;
+ if (BitRate>= 259308 && BitRate<= 269892) BitRate= 264600;
+ if (BitRate>= 282240 && BitRate<= 293760) BitRate= 288000;
+ if (BitRate>= 345744 && BitRate<= 359856) BitRate= 352800;
+ if (BitRate>= 376320 && BitRate<= 391680) BitRate= 384000;
+ if (BitRate>= 518616 && BitRate<= 539784) BitRate= 529200;
+ if (BitRate>= 564480 && BitRate<= 587520) BitRate= 576000;
+ if (BitRate>= 648270 && BitRate<= 674730) BitRate= 661500;
+ }
+
+ else if (Codec==_T("PCM") || Codec==_T("QDM2") || MediaInfoLib::Config.Codec_Get(Codec, InfoCodec_Name, Stream_Audio).find(_T("PCM"))==0)
+ {
+ if (BitRate>= 62720 && BitRate<= 65280) BitRate= 64000;
+ if (BitRate>= 86436 && BitRate<= 89964) BitRate= 88200;
+ if (BitRate>= 125440 && BitRate<= 130560) BitRate= 128000;
+ if (BitRate>= 172872 && BitRate<= 179928) BitRate= 176400;
+ if (BitRate>= 188160 && BitRate<= 195840) BitRate= 192000;
+ if (BitRate>= 250880 && BitRate<= 261120) BitRate= 256000;
+ if (BitRate>= 345744 && BitRate<= 359856) BitRate= 352800;
+ if (BitRate>= 376320 && BitRate<= 391680) BitRate= 384000;
+ if (BitRate>= 501760 && BitRate<= 522240) BitRate= 512000;
+ if (BitRate>= 691488 && BitRate<= 719712) BitRate= 705600;
+ if (BitRate>= 752640 && BitRate<= 783360) BitRate= 768000;
+ if (BitRate>=1003520 && BitRate<=1044480) BitRate=1024000;
+ if (BitRate>=1128960 && BitRate<=1175040) BitRate=1152000;
+ if (BitRate>=1382976 && BitRate<=1439424) BitRate=1411200;
+ if (BitRate>=1505280 && BitRate<=1566720) BitRate=1536000;
+ if (BitRate>=4515840 && BitRate<=4700160) BitRate=4608000;
+ if (BitRate>=6021120 && BitRate<=6266880) BitRate=6144000;
+ }
+
+ else if (MediaInfoLib::Config.Codec_Get(Codec, InfoCodec_Name, Stream_Audio).find(_T("ADPCM"))==0
+ || MediaInfoLib::Config.Codec_Get(Codec, InfoCodec_Name, Stream_Audio).find(_T("U-Law"))==0
+ || MediaInfoLib::Config.Codec_Get(Codec, InfoCodec_KindofCodec, Stream_Audio)==_T("ADPCM")
+ || MediaInfoLib::Config.Codec_Get(Codec, InfoCodec_KindofCodec, Stream_Audio)==_T("U-Law")
+ || Format==_T("ADPCM"))
+ {
+ if (BitRate>= 42000 && BitRate<= 46000) BitRate= 44100;
+ if (BitRate>= 62720 && BitRate<= 65280) BitRate= 64000;
+ if (BitRate>= 86436 && BitRate<= 89964) BitRate= 88200;
+ if (BitRate>= 125440 && BitRate<= 130560) BitRate= 128000;
+ if (BitRate>= 172872 && BitRate<= 179928) BitRate= 176400;
+ if (BitRate>= 188160 && BitRate<= 195840) BitRate= 192000;
+ if (BitRate>= 250880 && BitRate<= 261120) BitRate= 256000;
+ if (BitRate>= 345744 && BitRate<= 359856) BitRate= 352800;
+ if (BitRate>= 376320 && BitRate<= 391680) BitRate= 384000;
+ }
+
+ if (BitRate!=BitRate_Sav)
+ Fill(Stream_Audio, Pos, Parameter, BitRate, 0, true);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Tags()
+{
+ //Integrity
+ if (!Count_Get(Stream_General))
+ return;
+
+ //-Movie/Album
+ if (!Retrieve(Stream_General, 0, General_Title).empty() && Retrieve(Stream_General, 0, General_Movie).empty() && Retrieve(Stream_General, 0, General_Track).empty())
+ {
+ if (Count_Get(Stream_Video))
+ Fill(Stream_General, 0, "Movie", Retrieve(Stream_General, 0, General_Title));
+ else
+ Fill(Stream_General, 0, "Track", Retrieve(Stream_General, 0, General_Title));
+ }
+ if (!Retrieve(Stream_General, 0, General_Title_More).empty() && Retrieve(Stream_General, 0, General_Movie_More).empty() && Retrieve(Stream_General, 0, General_Track_More).empty())
+ {
+ if (Count_Get(Stream_Video))
+ Fill(Stream_General, 0, "Movie/More", Retrieve(Stream_General, 0, General_Title_More));
+ else
+ Fill(Stream_General, 0, "Track/More", Retrieve(Stream_General, 0, General_Title_More));
+ }
+ if (!Retrieve(Stream_General, 0, General_Title_Url).empty() && Retrieve(Stream_General, 0, General_Movie_Url).empty() && Retrieve(Stream_General, 0, General_Track_Url).empty())
+ {
+ if (Count_Get(Stream_Video))
+ Fill(Stream_General, 0, "Movie/Url", Retrieve(Stream_General, 0, General_Title_Url));
+ else
+ Fill(Stream_General, 0, "Track/Url", Retrieve(Stream_General, 0, General_Title_Url));
+ }
+ //-Title
+ if (Retrieve(Stream_General, 0, General_Title).empty() && !Retrieve(Stream_General, 0, General_Movie).empty())
+ Fill(Stream_General, 0, "Title", Retrieve(Stream_General, 0, General_Movie));
+ if (Retrieve(Stream_General, 0, General_Title).empty() && !Retrieve(Stream_General, 0, General_Track).empty())
+ Fill(Stream_General, 0, "Title", Retrieve(Stream_General, 0, General_Track));
+ if (Retrieve(Stream_General, 0, General_Title_More).empty() && !Retrieve(Stream_General, 0, General_Movie_More).empty())
+ Fill(Stream_General, 0, "Title/More", Retrieve(Stream_General, 0, General_Movie_More));
+ if (Retrieve(Stream_General, 0, General_Title_More).empty() && !Retrieve(Stream_General, 0, General_Track_More).empty())
+ Fill(Stream_General, 0, "Title/More", Retrieve(Stream_General, 0, General_Track_More));
+ if (Retrieve(Stream_General, 0, General_Title_Url).empty() && !Retrieve(Stream_General, 0, General_Movie_Url).empty())
+ Fill(Stream_General, 0, "Title/Url", Retrieve(Stream_General, 0, General_Movie_Url));
+ if (Retrieve(Stream_General, 0, General_Title_Url).empty() && !Retrieve(Stream_General, 0, General_Track_Url).empty())
+ Fill(Stream_General, 0, "Title/Url", Retrieve(Stream_General, 0, General_Track_Url));
+
+ //-Genre
+ if (!Retrieve(Stream_General, 0, General_Genre).empty() && Retrieve(Stream_General, 0, General_Genre).size()<4 && Retrieve(Stream_General, 0, General_Genre)[0]>=_T('0') && Retrieve(Stream_General, 0, General_Genre)[0]<=_T('9'))
+ {
+ Ztring Genre;
+ if (Retrieve(Stream_General, 0, General_Genre).size()==1) Genre=Ztring(_T("Genre_00"))+Retrieve(Stream_General, 0, General_Genre);
+ if (Retrieve(Stream_General, 0, General_Genre).size()==2) Genre=Ztring(_T("Genre_0" ))+Retrieve(Stream_General, 0, General_Genre);
+ if (Retrieve(Stream_General, 0, General_Genre).size()==3) Genre=Ztring(_T("Genre_" ))+Retrieve(Stream_General, 0, General_Genre);
+ Fill(Stream_General, 0, "Genre", MediaInfoLib::Config.Language_Get(Genre), true);
+ }
+}
+
+//***************************************************************************
+// Internal Functions
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Duration
+void File__Analyze::Duration_Duration123(stream_t StreamKind, size_t StreamPos, size_t Parameter)
+{
+ if (Retrieve(StreamKind, StreamPos, Parameter).empty())
+ return;
+
+ //Clearing old data
+ Clear(StreamKind, StreamPos, Parameter+1);
+ Clear(StreamKind, StreamPos, Parameter+2);
+ Clear(StreamKind, StreamPos, Parameter+3);
+ Clear(StreamKind, StreamPos, Parameter+4);
+
+ //Retrieving multiple values
+ ZtringList List;
+ List.Separator_Set(0, _T(" / "));
+ List.Write(Retrieve(StreamKind, StreamPos, Parameter));
+
+ //Per value
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ int32s HH, MM, SS, MS;
+ Ztring DurationString1, DurationString2, DurationString3;
+ bool Negative=false;
+ MS=List[Pos].To_int32s(); //in ms
+
+ if (MS<0)
+ {
+ Negative=true;
+ MS=-MS;
+ }
+
+ //Hours
+ HH=MS/1000/60/60; //h
+ if (HH>0)
+ {
+ DurationString1+=Ztring::ToZtring(HH)+MediaInfoLib::Config.Language_Get(_T("h"));
+ DurationString2+=Ztring::ToZtring(HH)+MediaInfoLib::Config.Language_Get(_T("h"));
+ if (HH<10)
+ DurationString3+=Ztring(_T("0"))+Ztring::ToZtring(HH)+_T(":");
+ else
+ DurationString3+=Ztring::ToZtring(HH)+_T(":");
+ MS-=HH*60*60*1000;
+ }
+ else
+ {
+ DurationString3+=_T("00:");
+ }
+
+ //Minutes
+ MM=MS/1000/60; //mn
+ if (MM>0 || HH>0)
+ {
+ if (DurationString1.size()>0)
+ DurationString1+=_T(" ");
+ DurationString1+=Ztring::ToZtring(MM)+MediaInfoLib::Config.Language_Get(_T("mn"));
+ if (DurationString2.size()<5)
+ {
+ if (DurationString2.size()>0)
+ DurationString2+=_T(" ");
+ DurationString2+=Ztring::ToZtring(MM)+MediaInfoLib::Config.Language_Get(_T("mn"));
+ }
+ if (MM<10)
+ DurationString3+=Ztring(_T("0"))+Ztring::ToZtring(MM)+_T(":");
+ else
+ DurationString3+=Ztring::ToZtring(MM)+_T(":");
+ MS-=MM*60*1000;
+ }
+ else
+ {
+ DurationString3+=_T("00:");
+ }
+
+ //Seconds
+ SS=MS/1000; //s
+ if (SS>0 || MM>0 || HH>0)
+ {
+ if (DurationString1.size()>0)
+ DurationString1+=_T(" ");
+ DurationString1+=Ztring::ToZtring(SS)+MediaInfoLib::Config.Language_Get(_T("s"));
+ if (DurationString2.size()<5)
+ {
+ if (DurationString2.size()>0)
+ DurationString2+=_T(" ");
+ DurationString2+=Ztring::ToZtring(SS)+MediaInfoLib::Config.Language_Get(_T("s"));
+ }
+ else if (DurationString2.size()==0)
+ DurationString2+=Ztring::ToZtring(SS)+MediaInfoLib::Config.Language_Get(_T("s"));
+ if (SS<10)
+ DurationString3+=Ztring(_T("0"))+Ztring::ToZtring(SS)+_T(".");
+ else
+ DurationString3+=Ztring::ToZtring(SS)+_T(".");
+ MS-=SS*1000;
+ }
+ else
+ {
+ DurationString3+=_T("00.");
+ }
+
+ //Milliseconds
+ if (MS>0 || SS>0 || MM>0 || HH>0)
+ {
+ if (DurationString1.size()>0)
+ DurationString1+=_T(" ");
+ DurationString1+=Ztring::ToZtring(MS)+MediaInfoLib::Config.Language_Get(_T("ms"));
+ if (DurationString2.size()<5)
+ {
+ if (DurationString2.size()>0)
+ DurationString2+=_T(" ");
+ DurationString2+=Ztring::ToZtring(MS)+MediaInfoLib::Config.Language_Get(_T("ms"));
+ }
+ if (MS<10)
+ DurationString3+=Ztring(_T("00"))+Ztring::ToZtring(MS);
+ else if (MS<100)
+ DurationString3+=Ztring(_T("0"))+Ztring::ToZtring(MS);
+ else
+ DurationString3+=Ztring::ToZtring(MS);
+ }
+ else
+ {
+ DurationString3+=_T("000");
+ }
+
+ if (Negative)
+ {
+ DurationString1=Ztring(_T("-"))+DurationString1;
+ DurationString2=Ztring(_T("-"))+DurationString2;
+ DurationString3=Ztring(_T("-"))+DurationString3;
+ }
+
+ Fill(StreamKind, StreamPos, Parameter+1, DurationString2); // /String
+ Fill(StreamKind, StreamPos, Parameter+2, DurationString1); // /String1
+ Fill(StreamKind, StreamPos, Parameter+3, DurationString2); // /String2
+ Fill(StreamKind, StreamPos, Parameter+4, DurationString3); // /String3
+ }
+}
+
+//---------------------------------------------------------------------------
+//FileSize
+void File__Analyze::FileSize_FileSize123(stream_t StreamKind, size_t StreamPos, size_t Parameter)
+{
+ if (Retrieve(StreamKind, StreamPos, Parameter).empty())
+ return;
+
+ float F1=(float)Retrieve(StreamKind, StreamPos, Parameter).To_int64s(); //Video C++ 6 patch, should be int64u
+
+ //--Bytes, KiB, MiB or GiB...
+ int32u Pow3=0;
+ while(F1>=1024)
+ {
+ F1/=1024;
+ Pow3++;
+ }
+ //--Count of digits
+ int8u I2, I3, I4;
+ if (F1>=100)
+ {
+ I2=0;
+ I3=0;
+ I4=1;
+ }
+ else if (F1>=10)
+ {
+ I2=0;
+ I3=1;
+ I4=2;
+ }
+ else //if (F1>=1)
+ {
+ I2=1;
+ I3=2;
+ I4=3;
+ }
+ Ztring Measure; bool MeasureIsAlwaysSame;
+ switch (Pow3)
+ {
+ case 0 : Measure=_T(" Byte"); MeasureIsAlwaysSame=false; break;
+ case 1 : Measure=_T(" KiB"); MeasureIsAlwaysSame=true; break;
+ case 2 : Measure=_T(" MiB"); MeasureIsAlwaysSame=true; break;
+ case 3 : Measure=_T(" GiB"); MeasureIsAlwaysSame=true; break;
+ default : Measure=_T(" ?iB"); MeasureIsAlwaysSame=true;
+ }
+ Fill(StreamKind, StreamPos, Parameter+2, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, 0), Measure, MeasureIsAlwaysSame), true); // /String1
+ Fill(StreamKind, StreamPos, Parameter+3, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I2), Measure, MeasureIsAlwaysSame), true); // /String2
+ Fill(StreamKind, StreamPos, Parameter+4, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I3), Measure, MeasureIsAlwaysSame), true); // /String3
+ Fill(StreamKind, StreamPos, Parameter+5, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I4), Measure, MeasureIsAlwaysSame), true); // /String4
+ float64 F2=(float)Retrieve(StreamKind, StreamPos, Parameter).To_float64();
+ float64 File_Size_WithReferencedFiles=(float)Retrieve(Stream_General, 0, General_FileSize).To_float64();
+ if (File_Size_WithReferencedFiles>0 && Parameter==Fill_Parameter(StreamKind, Generic_StreamSize) && F2*100/File_Size_WithReferencedFiles<=100)
+ {
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_StreamSize_Proportion), F2/File_Size_WithReferencedFiles, 5, true);
+ Fill(StreamKind, StreamPos, Parameter+6, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I3), Measure, MeasureIsAlwaysSame)+_T(" (")+Ztring::ToZtring(F2*100/File_Size_WithReferencedFiles, 0)+_T("%)"), true); // /String5
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I3), Measure, MeasureIsAlwaysSame)+_T(" (")+Ztring::ToZtring(F2*100/File_Size_WithReferencedFiles, 0)+_T("%)"), true);
+ }
+ else if (File_Size_WithReferencedFiles>0 && Parameter==Fill_Parameter(StreamKind, Generic_StreamSize_Encoded) && F2*100/File_Size_WithReferencedFiles<=100)
+ {
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_StreamSize_Encoded_Proportion), F2/File_Size_WithReferencedFiles, 5, true);
+ Fill(StreamKind, StreamPos, Parameter+6, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I3), Measure, MeasureIsAlwaysSame)+_T(" (")+Ztring::ToZtring(F2*100/File_Size_WithReferencedFiles, 0)+_T("%)"), true); // /String5
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I3), Measure, MeasureIsAlwaysSame)+_T(" (")+Ztring::ToZtring(F2*100/File_Size_WithReferencedFiles, 0)+_T("%)"), true);
+ }
+ else if (File_Size_WithReferencedFiles>0 && Parameter==Fill_Parameter(StreamKind, Generic_Source_StreamSize) && F2*100/File_Size_WithReferencedFiles<=100)
+ {
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Source_StreamSize_Proportion), F2/File_Size_WithReferencedFiles, 5, true);
+ Fill(StreamKind, StreamPos, Parameter+6, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I3), Measure, MeasureIsAlwaysSame)+_T(" (")+Ztring::ToZtring(F2*100/File_Size_WithReferencedFiles, 0)+_T("%)"), true); // /String5
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I3), Measure, MeasureIsAlwaysSame)+_T(" (")+Ztring::ToZtring(F2*100/File_Size_WithReferencedFiles, 0)+_T("%)"), true);
+ }
+ else if (File_Size_WithReferencedFiles>0 && Parameter==Fill_Parameter(StreamKind, Generic_Source_StreamSize_Encoded) && F2*100/File_Size_WithReferencedFiles<=100)
+ {
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Source_StreamSize_Encoded_Proportion), F2/File_Size_WithReferencedFiles, 5, true);
+ Fill(StreamKind, StreamPos, Parameter+6, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I3), Measure, MeasureIsAlwaysSame)+_T(" (")+Ztring::ToZtring(F2*100/File_Size_WithReferencedFiles, 0)+_T("%)"), true); // /String5
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I3), Measure, MeasureIsAlwaysSame)+_T(" (")+Ztring::ToZtring(F2*100/File_Size_WithReferencedFiles, 0)+_T("%)"), true);
+ }
+ else
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(F1, I3), Measure, MeasureIsAlwaysSame), true);
+}
+
+//---------------------------------------------------------------------------
+//FileSize
+void File__Analyze::Kilo_Kilo123(stream_t StreamKind, size_t StreamPos, size_t Parameter)
+{
+ if (Retrieve(StreamKind, StreamPos, Parameter).empty())
+ return;
+
+ //Clearing old data
+ Clear(StreamKind, StreamPos, Parameter+1);
+
+ //Retrieving multiple values
+ ZtringList List;
+ List.Separator_Set(0, _T(" / "));
+ List.Write(Retrieve(StreamKind, StreamPos, Parameter));
+
+ //Per value
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ int32u BitRate=List[Pos].To_int32u();
+
+ //Text
+ if (BitRate==0 && (List[Pos].empty() || List[Pos][0]>_T('9')))
+ {
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(List[Pos]));
+ }
+ else
+ {
+ //Well known values
+ Ztring BitRateS;
+ if (StreamKind==Stream_Audio)
+ {
+ if (Parameter==Audio_BitRate
+ && (Retrieve(Stream_Audio, StreamPos, Audio_Format)==_T("PCM")
+ || Retrieve(Stream_Audio, StreamPos, Audio_Format)==_T("ADPCM")
+ || Retrieve(Stream_Audio, StreamPos, Audio_Format)==_T("U-Law")
+ || Retrieve(Stream_Audio, StreamPos, Audio_Format)==_T("Qdesign 1")
+ || Retrieve(Stream_Audio, StreamPos, Audio_Format)==_T("Qdesign 2")
+ || Retrieve(Stream_Audio, StreamPos, Audio_Format)==_T("DTS")))
+ {
+ if (BitRate== 66150) BitRateS= "66.15";
+ if (BitRate== 132300) BitRateS= "132.3";
+ if (BitRate== 176400) BitRateS= "176.4";
+ if (BitRate== 264600) BitRateS= "264.6";
+ if (BitRate== 352800) BitRateS= "352.8";
+ if (BitRate== 529200) BitRateS= "529.2";
+ if (BitRate== 705600) BitRateS= "705.6";
+ if (BitRate==1411200) BitRateS="1411.2";
+ }
+ if (Parameter==Audio_SamplingRate)
+ {
+ if (BitRate== 11024) BitRateS= "11.024";
+ if (BitRate== 11025) BitRateS= "11.025";
+ if (BitRate== 22050) BitRateS= "22.05";
+ if (BitRate== 44100) BitRateS= "44.1";
+ if (BitRate== 88200) BitRateS= "88.2";
+ if (BitRate== 176400) BitRateS= "176.4";
+ if (BitRate== 352800) BitRateS= "352.8";
+ }
+ }
+ if (!BitRateS.empty())
+ {
+ Ztring Measure=MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter, Info_Measure);
+ Measure.insert(1, _T("K"));
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(BitRateS, Measure, true));
+ }
+ else
+ {
+ //Standard
+ if (BitRate>10000000)
+ {
+ Ztring Measure=MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter, Info_Measure);
+ Measure.insert(1, _T("M"));
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(((float)BitRate)/1000000, BitRate>100000000?0:1), Measure, true));
+ }
+ else if (BitRate>10000)
+ {
+ Ztring Measure=MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter, Info_Measure);
+ Measure.insert(1, _T("K"));
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(((float)BitRate)/1000, BitRate>100000?0:1), Measure, true));
+ }
+ else
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(Ztring::ToZtring(BitRate), MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter, Info_Measure), true));
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+//Value --> Value with measure
+void File__Analyze::Value_Value123(stream_t StreamKind, size_t StreamPos, size_t Parameter)
+{
+ if (Retrieve(StreamKind, StreamPos, Parameter, Info_Measure).empty())
+ return;
+
+ //Clearing old data
+ Clear(StreamKind, StreamPos, Parameter+1);
+
+ //Retrieving multiple values
+ ZtringList List;
+ List.Separator_Set(0, _T(" / "));
+ List.Write(Retrieve(StreamKind, StreamPos, Parameter));
+
+ //Per value
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ //Filling
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(List[Pos], MediaInfoLib::Config.Info_Get(StreamKind).Read(Parameter, Info_Measure)));
+ }
+
+}
+
+//---------------------------------------------------------------------------
+//Value --> Yes or No
+void File__Analyze::YesNo_YesNo(stream_t StreamKind, size_t StreamPos, size_t Parameter)
+{
+ //Filling
+ Fill(StreamKind, StreamPos, Parameter+1, MediaInfoLib::Config.Language_Get(Retrieve(StreamKind, StreamPos, Parameter)), true);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::CodecID_Fill(const Ztring &Value, stream_t StreamKind, size_t StreamPos, infocodecid_format_t Format)
+{
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_CodecID), Value, true);
+ const Ztring &C1=MediaInfoLib::Config.CodecID_Get(StreamKind, Format, Value, InfoCodecID_Format);
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format), C1.empty()?Value:C1, true);
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_CodecID_Info), MediaInfoLib::Config.CodecID_Get(StreamKind, Format, Value, InfoCodecID_Description), true);
+ Fill(StreamKind, StreamPos, "CodecID/Hint", MediaInfoLib::Config.CodecID_Get(StreamKind, Format, Value, InfoCodecID_Hint), true);
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_CodecID_Url), MediaInfoLib::Config.CodecID_Get(StreamKind, Format, Value, InfoCodecID_Url), true);
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format_Version), MediaInfoLib::Config.CodecID_Get(StreamKind, Format, Value, InfoCodecID_Version), true);
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Format_Profile), MediaInfoLib::Config.CodecID_Get(StreamKind, Format, Value, InfoCodecID_Profile), true);
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_ColorSpace), MediaInfoLib::Config.CodecID_Get(StreamKind, Format, Value, InfoCodecID_ColorSpace), true);
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_ChromaSubsampling), MediaInfoLib::Config.CodecID_Get(StreamKind, Format, Value, InfoCodecID_ChromaSubsampling), true);
+ if (Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_BitDepth)).empty())
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_BitDepth), MediaInfoLib::Config.CodecID_Get(StreamKind, Format, Value, InfoCodecID_BitDepth), true);
+ if (Retrieve(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Compression_Mode)).empty())
+ Fill(StreamKind, StreamPos, Fill_Parameter(StreamKind, Generic_Compression_Mode), MediaInfoLib::Config.CodecID_Get(StreamKind, Format, Value, InfoCodecID_Compression_Mode), true);
+
+ //Specific cases
+ if (Value==_T("v210") || Value==_T("V210"))
+ Fill(Stream_Video, StreamPos, Video_BitDepth, 10);
+}
+
+//---------------------------------------------------------------------------
+size_t File__Analyze::Fill_Parameter(stream_t StreamKind, generic StreamPos)
+{
+ switch (StreamKind)
+ {
+ case Stream_General :
+ switch (StreamPos)
+ {
+ case Generic_Format : return General_Format;
+ case Generic_Format_Info : return General_Format_Info;
+ case Generic_Format_Url : return General_Format_Url;
+ case Generic_Format_Version : return General_Format_Version;
+ case Generic_Format_Commercial : return General_Format_Commercial;
+ case Generic_Format_Commercial_IfAny : return General_Format_Commercial_IfAny;
+ case Generic_Format_Profile : return General_Format_Profile;
+ case Generic_Format_Settings : return General_Format_Settings;
+ case Generic_InternetMediaType : return General_InternetMediaType;
+ case Generic_CodecID : return General_CodecID;
+ case Generic_CodecID_Info : return General_CodecID_Info;
+ case Generic_CodecID_Hint : return General_CodecID_Hint;
+ case Generic_CodecID_Url : return General_CodecID_Url;
+ case Generic_CodecID_Description : return General_CodecID_Description;
+ case Generic_Codec : return General_Codec;
+ case Generic_Codec_String : return General_Codec_String;
+ case Generic_Codec_Info : return General_Codec_Info;
+ case Generic_Codec_Url : return General_Codec_Url;
+ case Generic_Duration : return General_Duration;
+ case Generic_Duration_String : return General_Duration_String;
+ case Generic_Duration_String1 : return General_Duration_String1;
+ case Generic_Duration_String2 : return General_Duration_String2;
+ case Generic_Duration_String3 : return General_Duration_String3;
+ case Generic_StreamSize : return General_StreamSize;
+ case Generic_StreamSize_String : return General_StreamSize_String;
+ case Generic_StreamSize_String1 : return General_StreamSize_String1;
+ case Generic_StreamSize_String2 : return General_StreamSize_String2;
+ case Generic_StreamSize_String3 : return General_StreamSize_String3;
+ case Generic_StreamSize_String4 : return General_StreamSize_String4;
+ case Generic_StreamSize_String5 : return General_StreamSize_String5;
+ case Generic_StreamSize_Proportion : return General_StreamSize_Proportion;
+ case Generic_ServiceName : return General_ServiceName;
+ case Generic_ServiceProvider : return General_ServiceProvider;
+ default: return (size_t)-1;
+ }
+ case Stream_Video :
+ switch (StreamPos)
+ {
+ case Generic_Format : return Video_Format;
+ case Generic_Format_Info : return Video_Format_Info;
+ case Generic_Format_Url : return Video_Format_Url;
+ case Generic_Format_Commercial : return Video_Format_Commercial;
+ case Generic_Format_Commercial_IfAny : return Video_Format_Commercial_IfAny;
+ case Generic_Format_Version : return Video_Format_Version;
+ case Generic_Format_Profile : return Video_Format_Profile;
+ case Generic_Format_Settings : return Video_Format_Settings;
+ case Generic_InternetMediaType : return Video_InternetMediaType;
+ case Generic_CodecID : return Video_CodecID;
+ case Generic_CodecID_Info : return Video_CodecID_Info;
+ case Generic_CodecID_Hint : return Video_CodecID_Hint;
+ case Generic_CodecID_Url : return Video_CodecID_Url;
+ case Generic_CodecID_Description : return Video_CodecID_Description;
+ case Generic_Codec : return Video_Codec;
+ case Generic_Codec_String : return Video_Codec_String;
+ case Generic_Codec_Info : return Video_Codec_Info;
+ case Generic_Codec_Url : return Video_Codec_Url;
+ case Generic_Codec_CC : return Video_Codec_CC;
+ case Generic_Duration : return Video_Duration;
+ case Generic_Duration_String : return Video_Duration_String;
+ case Generic_Duration_String1 : return Video_Duration_String1;
+ case Generic_Duration_String2 : return Video_Duration_String2;
+ case Generic_Duration_String3 : return Video_Duration_String3;
+ case Generic_Source_Duration : return Video_Source_Duration;
+ case Generic_Source_Duration_String : return Video_Source_Duration_String;
+ case Generic_Source_Duration_String1 : return Video_Source_Duration_String1;
+ case Generic_Source_Duration_String2 : return Video_Source_Duration_String2;
+ case Generic_Source_Duration_String3 : return Video_Source_Duration_String3;
+ case Generic_BitRate_Mode : return Video_BitRate_Mode;
+ case Generic_BitRate_Mode_String : return Video_BitRate_Mode_String;
+ case Generic_BitRate : return Video_BitRate;
+ case Generic_BitRate_String : return Video_BitRate_String;
+ case Generic_BitRate_Minimum : return Video_BitRate_Minimum;
+ case Generic_BitRate_Minimum_String : return Video_BitRate_Minimum_String;
+ case Generic_BitRate_Nominal : return Video_BitRate_Nominal;
+ case Generic_BitRate_Nominal_String : return Video_BitRate_Nominal_String;
+ case Generic_BitRate_Maximum : return Video_BitRate_Maximum;
+ case Generic_BitRate_Maximum_String : return Video_BitRate_Maximum_String;
+ case Generic_BitRate_Encoded : return Video_BitRate_Encoded;
+ case Generic_BitRate_Encoded_String : return Video_BitRate_Encoded_String;
+ case Generic_FrameCount : return Video_FrameCount;
+ case Generic_Source_FrameCount : return Video_Source_FrameCount;
+ case Generic_ColorSpace : return Video_ColorSpace;
+ case Generic_ChromaSubsampling : return Video_ChromaSubsampling;
+ case Generic_Resolution : return Video_Resolution;
+ case Generic_Resolution_String : return Video_Resolution_String;
+ case Generic_BitDepth : return Video_BitDepth;
+ case Generic_BitDepth_String : return Video_BitDepth_String;
+ case Generic_Compression_Mode : return Video_Compression_Mode;
+ case Generic_Compression_Mode_String : return Video_Compression_Mode_String;
+ case Generic_Compression_Ratio : return Video_Compression_Ratio;
+ case Generic_Delay : return Video_Delay;
+ case Generic_Delay_String : return Video_Delay_String;
+ case Generic_Delay_String1 : return Video_Delay_String1;
+ case Generic_Delay_String2 : return Video_Delay_String2;
+ case Generic_Delay_String3 : return Video_Delay_String3;
+ case Generic_Delay_String4 : return Video_Delay_String4;
+ case Generic_Delay_Settings : return Video_Delay_Settings;
+ case Generic_Delay_Source : return Video_Delay_Source;
+ case Generic_Delay_Source_String : return Video_Delay_Source_String;
+ case Generic_Delay_Original : return Video_Delay_Original;
+ case Generic_Delay_Original_String : return Video_Delay_Original_String;
+ case Generic_Delay_Original_String1 : return Video_Delay_Original_String1;
+ case Generic_Delay_Original_String2 : return Video_Delay_Original_String2;
+ case Generic_Delay_Original_String3 : return Video_Delay_Original_String3;
+ case Generic_Delay_Original_String4 : return Video_Delay_Original_String4;
+ case Generic_Delay_Original_Settings : return Video_Delay_Original_Settings;
+ case Generic_Delay_Original_Source : return Video_Delay_Original_Source;
+ case Generic_StreamSize : return Video_StreamSize;
+ case Generic_StreamSize_String : return Video_StreamSize_String;
+ case Generic_StreamSize_String1 : return Video_StreamSize_String1;
+ case Generic_StreamSize_String2 : return Video_StreamSize_String2;
+ case Generic_StreamSize_String3 : return Video_StreamSize_String3;
+ case Generic_StreamSize_String4 : return Video_StreamSize_String4;
+ case Generic_StreamSize_String5 : return Video_StreamSize_String5;
+ case Generic_StreamSize_Proportion : return Video_StreamSize_Proportion;
+ case Generic_StreamSize_Encoded : return Video_StreamSize_Encoded;
+ case Generic_StreamSize_Encoded_String : return Video_StreamSize_Encoded_String;
+ case Generic_StreamSize_Encoded_String1 : return Video_StreamSize_Encoded_String1;
+ case Generic_StreamSize_Encoded_String2 : return Video_StreamSize_Encoded_String2;
+ case Generic_StreamSize_Encoded_String3 : return Video_StreamSize_Encoded_String3;
+ case Generic_StreamSize_Encoded_String4 : return Video_StreamSize_Encoded_String4;
+ case Generic_StreamSize_Encoded_String5 : return Video_StreamSize_Encoded_String5;
+ case Generic_StreamSize_Encoded_Proportion : return Video_StreamSize_Encoded_Proportion;
+ case Generic_Source_StreamSize : return Video_Source_StreamSize;
+ case Generic_Source_StreamSize_String : return Video_Source_StreamSize_String;
+ case Generic_Source_StreamSize_String1 : return Video_Source_StreamSize_String1;
+ case Generic_Source_StreamSize_String2 : return Video_Source_StreamSize_String2;
+ case Generic_Source_StreamSize_String3 : return Video_Source_StreamSize_String3;
+ case Generic_Source_StreamSize_String4 : return Video_Source_StreamSize_String4;
+ case Generic_Source_StreamSize_String5 : return Video_Source_StreamSize_String5;
+ case Generic_Source_StreamSize_Proportion : return Video_Source_StreamSize_Proportion;
+ case Generic_Source_StreamSize_Encoded : return Video_Source_StreamSize_Encoded;
+ case Generic_Source_StreamSize_Encoded_String : return Video_Source_StreamSize_Encoded_String;
+ case Generic_Source_StreamSize_Encoded_String1 : return Video_Source_StreamSize_Encoded_String1;
+ case Generic_Source_StreamSize_Encoded_String2 : return Video_Source_StreamSize_Encoded_String2;
+ case Generic_Source_StreamSize_Encoded_String3 : return Video_Source_StreamSize_Encoded_String3;
+ case Generic_Source_StreamSize_Encoded_String4 : return Video_Source_StreamSize_Encoded_String4;
+ case Generic_Source_StreamSize_Encoded_String5 : return Video_Source_StreamSize_Encoded_String5;
+ case Generic_Source_StreamSize_Encoded_Proportion : return Video_Source_StreamSize_Encoded_Proportion;
+ case Generic_Language : return Video_Language;
+ default: return (size_t)-1;
+ }
+ case Stream_Audio :
+ switch (StreamPos)
+ {
+ case Generic_Format : return Audio_Format;
+ case Generic_Format_Info : return Audio_Format_Info;
+ case Generic_Format_Url : return Audio_Format_Url;
+ case Generic_Format_Commercial : return Audio_Format_Commercial;
+ case Generic_Format_Commercial_IfAny : return Audio_Format_Commercial_IfAny;
+ case Generic_Format_Version : return Audio_Format_Version;
+ case Generic_Format_Profile : return Audio_Format_Profile;
+ case Generic_Format_Settings : return Audio_Format_Settings;
+ case Generic_InternetMediaType : return Audio_InternetMediaType;
+ case Generic_CodecID : return Audio_CodecID;
+ case Generic_CodecID_Info : return Audio_CodecID_Info;
+ case Generic_CodecID_Hint : return Audio_CodecID_Hint;
+ case Generic_CodecID_Url : return Audio_CodecID_Url;
+ case Generic_CodecID_Description : return Audio_CodecID_Description;
+ case Generic_Codec : return Audio_Codec;
+ case Generic_Codec_String : return Audio_Codec_String;
+ case Generic_Codec_Info : return Audio_Codec_Info;
+ case Generic_Codec_Url : return Audio_Codec_Url;
+ case Generic_Codec_CC : return Audio_Codec_CC;
+ case Generic_Duration : return Audio_Duration;
+ case Generic_Duration_String : return Audio_Duration_String;
+ case Generic_Duration_String1 : return Audio_Duration_String1;
+ case Generic_Duration_String2 : return Audio_Duration_String2;
+ case Generic_Duration_String3 : return Audio_Duration_String3;
+ case Generic_Source_Duration : return Audio_Source_Duration;
+ case Generic_Source_Duration_String : return Audio_Source_Duration_String;
+ case Generic_Source_Duration_String1 : return Audio_Source_Duration_String1;
+ case Generic_Source_Duration_String2 : return Audio_Source_Duration_String2;
+ case Generic_Source_Duration_String3 : return Audio_Source_Duration_String3;
+ case Generic_BitRate_Mode : return Audio_BitRate_Mode;
+ case Generic_BitRate_Mode_String : return Audio_BitRate_Mode_String;
+ case Generic_BitRate : return Audio_BitRate;
+ case Generic_BitRate_String : return Audio_BitRate_String;
+ case Generic_BitRate_Minimum : return Audio_BitRate_Minimum;
+ case Generic_BitRate_Minimum_String : return Audio_BitRate_Minimum_String;
+ case Generic_BitRate_Nominal : return Audio_BitRate_Nominal;
+ case Generic_BitRate_Nominal_String : return Audio_BitRate_Nominal_String;
+ case Generic_BitRate_Maximum : return Audio_BitRate_Maximum;
+ case Generic_BitRate_Maximum_String : return Audio_BitRate_Maximum_String;
+ case Generic_BitRate_Encoded : return Audio_BitRate_Encoded;
+ case Generic_BitRate_Encoded_String : return Audio_BitRate_Encoded_String;
+ case Generic_FrameCount : return Audio_FrameCount;
+ case Generic_Source_FrameCount : return Audio_Source_FrameCount;
+ case Generic_Resolution : return Audio_Resolution;
+ case Generic_Resolution_String : return Audio_Resolution_String;
+ case Generic_BitDepth : return Audio_BitDepth;
+ case Generic_BitDepth_String : return Audio_BitDepth_String;
+ case Generic_Compression_Mode : return Audio_Compression_Mode;
+ case Generic_Compression_Mode_String : return Audio_Compression_Mode_String;
+ case Generic_Compression_Ratio : return Audio_Compression_Ratio;
+ case Generic_Delay : return Audio_Delay;
+ case Generic_Delay_String : return Audio_Delay_String;
+ case Generic_Delay_String1 : return Audio_Delay_String1;
+ case Generic_Delay_String2 : return Audio_Delay_String2;
+ case Generic_Delay_String3 : return Audio_Delay_String3;
+ case Generic_Delay_String4 : return Audio_Delay_String4;
+ case Generic_Delay_Settings : return Audio_Delay_Settings;
+ case Generic_Delay_Source : return Audio_Delay_Source;
+ case Generic_Delay_Source_String : return Audio_Delay_Source_String;
+ case Generic_Delay_Original : return Audio_Delay_Original;
+ case Generic_Delay_Original_String : return Audio_Delay_Original_String;
+ case Generic_Delay_Original_String1 : return Audio_Delay_Original_String1;
+ case Generic_Delay_Original_String2 : return Audio_Delay_Original_String2;
+ case Generic_Delay_Original_String3 : return Audio_Delay_Original_String3;
+ case Generic_Delay_Original_String4 : return Audio_Delay_Original_String4;
+ case Generic_Delay_Original_Settings : return Audio_Delay_Original_Settings;
+ case Generic_Delay_Original_Source : return Audio_Delay_Original_Source;
+ case Generic_Video_Delay : return Audio_Video_Delay;
+ case Generic_Video_Delay_String : return Audio_Video_Delay_String;
+ case Generic_Video_Delay_String1 : return Audio_Video_Delay_String1;
+ case Generic_Video_Delay_String2 : return Audio_Video_Delay_String2;
+ case Generic_Video_Delay_String3 : return Audio_Video_Delay_String3;
+ case Generic_Video_Delay_String4 : return Audio_Video_Delay_String4;
+ case Generic_StreamSize : return Audio_StreamSize;
+ case Generic_StreamSize_String : return Audio_StreamSize_String;
+ case Generic_StreamSize_String1 : return Audio_StreamSize_String1;
+ case Generic_StreamSize_String2 : return Audio_StreamSize_String2;
+ case Generic_StreamSize_String3 : return Audio_StreamSize_String3;
+ case Generic_StreamSize_String4 : return Audio_StreamSize_String4;
+ case Generic_StreamSize_String5 : return Audio_StreamSize_String5;
+ case Generic_StreamSize_Proportion : return Audio_StreamSize_Proportion;
+ case Generic_StreamSize_Encoded : return Audio_StreamSize_Encoded;
+ case Generic_StreamSize_Encoded_String : return Audio_StreamSize_Encoded_String;
+ case Generic_StreamSize_Encoded_String1 : return Audio_StreamSize_Encoded_String1;
+ case Generic_StreamSize_Encoded_String2 : return Audio_StreamSize_Encoded_String2;
+ case Generic_StreamSize_Encoded_String3 : return Audio_StreamSize_Encoded_String3;
+ case Generic_StreamSize_Encoded_String4 : return Audio_StreamSize_Encoded_String4;
+ case Generic_StreamSize_Encoded_String5 : return Audio_StreamSize_Encoded_String5;
+ case Generic_StreamSize_Encoded_Proportion : return Audio_StreamSize_Encoded_Proportion;
+ case Generic_Source_StreamSize : return Audio_Source_StreamSize;
+ case Generic_Source_StreamSize_String : return Audio_Source_StreamSize_String;
+ case Generic_Source_StreamSize_String1 : return Audio_Source_StreamSize_String1;
+ case Generic_Source_StreamSize_String2 : return Audio_Source_StreamSize_String2;
+ case Generic_Source_StreamSize_String3 : return Audio_Source_StreamSize_String3;
+ case Generic_Source_StreamSize_String4 : return Audio_Source_StreamSize_String4;
+ case Generic_Source_StreamSize_String5 : return Audio_Source_StreamSize_String5;
+ case Generic_Source_StreamSize_Proportion : return Audio_Source_StreamSize_Proportion;
+ case Generic_Source_StreamSize_Encoded : return Audio_Source_StreamSize_Encoded;
+ case Generic_Source_StreamSize_Encoded_String : return Audio_Source_StreamSize_Encoded_String;
+ case Generic_Source_StreamSize_Encoded_String1 : return Audio_Source_StreamSize_Encoded_String1;
+ case Generic_Source_StreamSize_Encoded_String2 : return Audio_Source_StreamSize_Encoded_String2;
+ case Generic_Source_StreamSize_Encoded_String3 : return Audio_Source_StreamSize_Encoded_String3;
+ case Generic_Source_StreamSize_Encoded_String4 : return Audio_Source_StreamSize_Encoded_String4;
+ case Generic_Source_StreamSize_Encoded_String5 : return Audio_Source_StreamSize_Encoded_String5;
+ case Generic_Source_StreamSize_Encoded_Proportion : return Audio_Source_StreamSize_Encoded_Proportion;
+ case Generic_Language : return Audio_Language;
+ default: return (size_t)-1;
+ }
+ case Stream_Text :
+ switch (StreamPos)
+ {
+ case Generic_Format : return Text_Format;
+ case Generic_Format_Info : return Text_Format_Info;
+ case Generic_Format_Url : return Text_Format_Url;
+ case Generic_Format_Commercial : return Text_Format_Commercial;
+ case Generic_Format_Commercial_IfAny : return Text_Format_Commercial_IfAny;
+ case Generic_Format_Version : return Text_Format_Version;
+ case Generic_Format_Profile : return Text_Format_Profile;
+ case Generic_Format_Settings : return Text_Format_Settings;
+ case Generic_InternetMediaType : return Text_InternetMediaType;
+ case Generic_CodecID : return Text_CodecID;
+ case Generic_CodecID_Info : return Text_CodecID_Info;
+ case Generic_CodecID_Hint : return Text_CodecID_Hint;
+ case Generic_CodecID_Url : return Text_CodecID_Url;
+ case Generic_CodecID_Description : return Text_CodecID_Description;
+ case Generic_Codec : return Text_Codec;
+ case Generic_Codec_String : return Text_Codec_String;
+ case Generic_Codec_Info : return Text_Codec_Info;
+ case Generic_Codec_Url : return Text_Codec_Url;
+ case Generic_Codec_CC : return Text_Codec_CC;
+ case Generic_Duration : return Text_Duration;
+ case Generic_Duration_String : return Text_Duration_String;
+ case Generic_Duration_String1 : return Text_Duration_String1;
+ case Generic_Duration_String2 : return Text_Duration_String2;
+ case Generic_Duration_String3 : return Text_Duration_String3;
+ case Generic_Source_Duration : return Text_Source_Duration;
+ case Generic_Source_Duration_String : return Text_Source_Duration_String;
+ case Generic_Source_Duration_String1 : return Text_Source_Duration_String1;
+ case Generic_Source_Duration_String2 : return Text_Source_Duration_String2;
+ case Generic_Source_Duration_String3 : return Text_Source_Duration_String3;
+ case Generic_BitRate_Mode : return Text_BitRate_Mode;
+ case Generic_BitRate_Mode_String : return Text_BitRate_Mode_String;
+ case Generic_BitRate : return Text_BitRate;
+ case Generic_BitRate_String : return Text_BitRate_String;
+ case Generic_BitRate_Minimum : return Text_BitRate_Minimum;
+ case Generic_BitRate_Minimum_String : return Text_BitRate_Minimum_String;
+ case Generic_BitRate_Nominal : return Text_BitRate_Nominal;
+ case Generic_BitRate_Nominal_String : return Text_BitRate_Nominal_String;
+ case Generic_BitRate_Maximum : return Text_BitRate_Maximum;
+ case Generic_BitRate_Maximum_String : return Text_BitRate_Maximum_String;
+ case Generic_BitRate_Encoded : return Text_BitRate_Encoded;
+ case Generic_BitRate_Encoded_String : return Text_BitRate_Encoded_String;
+ case Generic_FrameCount : return Text_FrameCount;
+ case Generic_Source_FrameCount : return Text_Source_FrameCount;
+ case Generic_ColorSpace : return Text_ColorSpace;
+ case Generic_ChromaSubsampling : return Text_ChromaSubsampling;
+ case Generic_Resolution : return Text_Resolution;
+ case Generic_Resolution_String : return Text_Resolution_String;
+ case Generic_BitDepth : return Text_BitDepth;
+ case Generic_BitDepth_String : return Text_BitDepth_String;
+ case Generic_Compression_Mode : return Text_Compression_Mode;
+ case Generic_Compression_Mode_String : return Text_Compression_Mode_String;
+ case Generic_Compression_Ratio : return Text_Compression_Ratio;
+ case Generic_Delay : return Text_Delay;
+ case Generic_Delay_String : return Text_Delay_String;
+ case Generic_Delay_String1 : return Text_Delay_String1;
+ case Generic_Delay_String2 : return Text_Delay_String2;
+ case Generic_Delay_String3 : return Text_Delay_String3;
+ case Generic_Delay_String4 : return Text_Delay_String4;
+ case Generic_Delay_Settings : return Text_Delay_Settings;
+ case Generic_Delay_Source : return Text_Delay_Source;
+ case Generic_Delay_Source_String : return Text_Delay_Source_String;
+ case Generic_Delay_Original : return Text_Delay_Original;
+ case Generic_Delay_Original_String : return Text_Delay_Original_String;
+ case Generic_Delay_Original_String1 : return Text_Delay_Original_String1;
+ case Generic_Delay_Original_String2 : return Text_Delay_Original_String2;
+ case Generic_Delay_Original_String3 : return Text_Delay_Original_String3;
+ case Generic_Delay_Original_String4 : return Text_Delay_Original_String4;
+ case Generic_Delay_Original_Settings : return Text_Delay_Original_Settings;
+ case Generic_Delay_Original_Source : return Text_Delay_Original_Source;
+ case Generic_Video_Delay : return Text_Video_Delay;
+ case Generic_Video_Delay_String : return Text_Video_Delay_String;
+ case Generic_Video_Delay_String1 : return Text_Video_Delay_String1;
+ case Generic_Video_Delay_String2 : return Text_Video_Delay_String2;
+ case Generic_Video_Delay_String3 : return Text_Video_Delay_String3;
+ case Generic_Video_Delay_String4 : return Text_Video_Delay_String4;
+ case Generic_StreamSize : return Text_StreamSize;
+ case Generic_StreamSize_String : return Text_StreamSize_String;
+ case Generic_StreamSize_String1 : return Text_StreamSize_String1;
+ case Generic_StreamSize_String2 : return Text_StreamSize_String2;
+ case Generic_StreamSize_String3 : return Text_StreamSize_String3;
+ case Generic_StreamSize_String4 : return Text_StreamSize_String4;
+ case Generic_StreamSize_String5 : return Text_StreamSize_String5;
+ case Generic_StreamSize_Proportion : return Text_StreamSize_Proportion;
+ case Generic_StreamSize_Encoded : return Text_StreamSize_Encoded;
+ case Generic_StreamSize_Encoded_String : return Text_StreamSize_Encoded_String;
+ case Generic_StreamSize_Encoded_String1 : return Text_StreamSize_Encoded_String1;
+ case Generic_StreamSize_Encoded_String2 : return Text_StreamSize_Encoded_String2;
+ case Generic_StreamSize_Encoded_String3 : return Text_StreamSize_Encoded_String3;
+ case Generic_StreamSize_Encoded_String4 : return Text_StreamSize_Encoded_String4;
+ case Generic_StreamSize_Encoded_String5 : return Text_StreamSize_Encoded_String5;
+ case Generic_StreamSize_Encoded_Proportion : return Text_StreamSize_Encoded_Proportion;
+ case Generic_Source_StreamSize : return Text_Source_StreamSize;
+ case Generic_Source_StreamSize_String : return Text_Source_StreamSize_String;
+ case Generic_Source_StreamSize_String1 : return Text_Source_StreamSize_String1;
+ case Generic_Source_StreamSize_String2 : return Text_Source_StreamSize_String2;
+ case Generic_Source_StreamSize_String3 : return Text_Source_StreamSize_String3;
+ case Generic_Source_StreamSize_String4 : return Text_Source_StreamSize_String4;
+ case Generic_Source_StreamSize_String5 : return Text_Source_StreamSize_String5;
+ case Generic_Source_StreamSize_Proportion : return Text_Source_StreamSize_Proportion;
+ case Generic_Source_StreamSize_Encoded : return Text_Source_StreamSize_Encoded;
+ case Generic_Source_StreamSize_Encoded_String : return Text_Source_StreamSize_Encoded_String;
+ case Generic_Source_StreamSize_Encoded_String1 : return Text_Source_StreamSize_Encoded_String1;
+ case Generic_Source_StreamSize_Encoded_String2 : return Text_Source_StreamSize_Encoded_String2;
+ case Generic_Source_StreamSize_Encoded_String3 : return Text_Source_StreamSize_Encoded_String3;
+ case Generic_Source_StreamSize_Encoded_String4 : return Text_Source_StreamSize_Encoded_String4;
+ case Generic_Source_StreamSize_Encoded_String5 : return Text_Source_StreamSize_Encoded_String5;
+ case Generic_Source_StreamSize_Encoded_Proportion : return Text_Source_StreamSize_Encoded_Proportion;
+ case Generic_Language : return Text_Language;
+ default: return (size_t)-1;
+ }
+ case Stream_Image :
+ switch (StreamPos)
+ {
+ case Generic_Format : return Image_Format;
+ case Generic_Format_Info : return Image_Format_Info;
+ case Generic_Format_Url : return Image_Format_Url;
+ case Generic_Format_Commercial : return Image_Format_Commercial;
+ case Generic_Format_Commercial_IfAny : return Image_Format_Commercial_IfAny;
+ case Generic_Format_Version : return Image_Format_Version;
+ case Generic_Format_Profile : return Image_Format_Profile;
+ case Generic_InternetMediaType : return Image_InternetMediaType;
+ case Generic_CodecID : return Image_CodecID;
+ case Generic_CodecID_Info : return Image_CodecID_Info;
+ case Generic_CodecID_Hint : return Image_CodecID_Hint;
+ case Generic_CodecID_Url : return Image_CodecID_Url;
+ case Generic_CodecID_Description : return Image_CodecID_Description;
+ case Generic_Codec : return Image_Codec;
+ case Generic_Codec_String : return Image_Codec_String;
+ case Generic_Codec_Info : return Image_Codec_Info;
+ case Generic_Codec_Url : return Image_Codec_Url;
+ case Generic_ColorSpace : return Image_ColorSpace;
+ case Generic_ChromaSubsampling : return Image_ChromaSubsampling;
+ case Generic_Resolution : return Image_Resolution;
+ case Generic_Resolution_String : return Image_Resolution_String;
+ case Generic_BitDepth : return Image_BitDepth;
+ case Generic_BitDepth_String : return Image_BitDepth_String;
+ case Generic_Compression_Mode : return Image_Compression_Mode;
+ case Generic_Compression_Mode_String : return Image_Compression_Mode_String;
+ case Generic_Compression_Ratio : return Image_Compression_Ratio;
+ case Generic_StreamSize : return Image_StreamSize;
+ case Generic_StreamSize_String : return Image_StreamSize_String;
+ case Generic_StreamSize_String1 : return Image_StreamSize_String1;
+ case Generic_StreamSize_String2 : return Image_StreamSize_String2;
+ case Generic_StreamSize_String3 : return Image_StreamSize_String3;
+ case Generic_StreamSize_String4 : return Image_StreamSize_String4;
+ case Generic_StreamSize_String5 : return Image_StreamSize_String5;
+ case Generic_StreamSize_Proportion : return Image_StreamSize_Proportion;
+ case Generic_Language : return Image_Language;
+ default: return (size_t)-1;
+ }
+ case Stream_Chapters : return (size_t)-1;
+ case Stream_Menu :
+ switch (StreamPos)
+ {
+ case Generic_Format : return Menu_Format;
+ case Generic_Format_Info : return Menu_Format_Info;
+ case Generic_Format_Url : return Menu_Format_Url;
+ case Generic_Format_Commercial : return Menu_Format_Commercial;
+ case Generic_Format_Commercial_IfAny : return Menu_Format_Commercial_IfAny;
+ case Generic_Format_Version : return Menu_Format_Version;
+ case Generic_Format_Profile : return Menu_Format_Profile;
+ case Generic_Format_Settings : return Menu_Format_Settings;
+ case Generic_CodecID : return Menu_CodecID;
+ case Generic_CodecID_Info : return Menu_CodecID_Info;
+ case Generic_CodecID_Hint : return Menu_CodecID_Hint;
+ case Generic_CodecID_Url : return Menu_CodecID_Url;
+ case Generic_CodecID_Description : return Menu_CodecID_Description;
+ case Generic_Codec : return Menu_Codec;
+ case Generic_Codec_String : return Menu_Codec_String;
+ case Generic_Codec_Info : return Menu_Codec_Info;
+ case Generic_Codec_Url : return Menu_Codec_Url;
+ case Generic_Duration : return Menu_Duration;
+ case Generic_Duration_String : return Menu_Duration_String;
+ case Generic_Duration_String1 : return Menu_Duration_String1;
+ case Generic_Duration_String2 : return Menu_Duration_String2;
+ case Generic_Duration_String3 : return Menu_Duration_String3;
+ case Generic_Language : return Menu_Language;
+ case Generic_ServiceName : return Menu_ServiceName;
+ case Generic_ServiceProvider : return Menu_ServiceProvider;
+ default: return (size_t)-1;
+ }
+ default: return (size_t)-1;
+ }
+}
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Streams_Finish.cpp b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Streams_Finish.cpp
new file mode 100644
index 000000000..d9b2d98ae
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Analyze_Streams_Finish.cpp
@@ -0,0 +1,631 @@
+// File__Analyze_Inform - Base for other files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Init and Finalize part
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Utils.h"
+#include "ZenLib/File.h"
+#include "ZenLib/FileName.h"
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#if MEDIAINFO_IBI
+ #include "MediaInfo/Multiple/File_Ibi.h"
+#endif //MEDIAINFO_IBI
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Finish_Global()
+{
+ if (IsSub)
+ return;
+
+ //Video Frame count
+ if (Count_Get(Stream_Video)==1 && Count_Get(Stream_Audio)==0 && Retrieve(Stream_Video, 0, Video_FrameCount).empty())
+ {
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1 && File_Offset+Buffer_Size==File_Size)
+ Fill(Stream_Video, 0, Video_FrameCount, Frame_Count_NotParsedIncluded);
+ else if (Config->File_Names.size()>1)
+ Fill(Stream_Video, 0, Video_FrameCount, Config->File_Names.size());
+ #if MEDIAINFO_IBI
+ else
+ {
+ //External IBI
+ std::string IbiFile=Config->Ibi_Get();
+ if (!IbiFile.empty())
+ {
+ if (IbiStream)
+ IbiStream->Infos.clear(); //TODO: support IBI data from different inputs
+ else
+ IbiStream=new ibi::stream;
+
+ File_Ibi MI;
+ Open_Buffer_Init(&MI, IbiFile.size());
+ MI.Ibi=new ibi;
+ MI.Open_Buffer_Continue((const int8u*)IbiFile.c_str(), IbiFile.size());
+ if (!MI.Ibi->Streams.empty())
+ (*IbiStream)=(*MI.Ibi->Streams.begin()->second);
+ }
+
+ if (IbiStream && !IbiStream->Infos.empty() && IbiStream->Infos[IbiStream->Infos.size()-1].IsContinuous && IbiStream->Infos[IbiStream->Infos.size()-1].FrameNumber!=(int64u)-1)
+ Fill(Stream_Video, 0, Video_FrameCount, IbiStream->Infos[IbiStream->Infos.size()-1].FrameNumber);
+ }
+ #endif //MEDIAINFO_IBI
+ }
+
+ Streams_Finish_StreamOnly();
+ Streams_Finish_StreamOnly();
+ Streams_Finish_InterStreams();
+ Streams_Finish_StreamOnly();
+ Streams_Finish_InterStreams();
+ Streams_Finish_StreamOnly();
+ Streams_Finish_InterStreams();
+ Streams_Finish_StreamOnly();
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Accept_TestContinuousFileNames_Static(ZtringList &File_Names, bool IsReferenced)
+{
+ if (File_Names.size()!=1)
+ return;
+
+ //Trying to detect continuous file names (e.g. video stream as an image or HLS)
+ FileName FileToTest(File_Names.Read(0));
+ Ztring FileToTest_Name=FileToTest.Name_Get();
+ size_t FileNameToTest_Pos=FileToTest_Name.size();
+ while (FileNameToTest_Pos && FileToTest_Name[FileNameToTest_Pos-1]>=_T('0') && FileToTest_Name[FileNameToTest_Pos-1]<=_T('9'))
+ FileNameToTest_Pos--;
+ if (FileNameToTest_Pos!=FileToTest_Name.size())
+ {
+ size_t Numbers_Size=FileToTest_Name.size()-FileNameToTest_Pos;
+ int64u Pos=Ztring(FileToTest_Name.substr(FileNameToTest_Pos)).To_int64u();
+ FileToTest_Name.resize(FileNameToTest_Pos);
+
+ for (;;)
+ {
+ Pos++;
+ Ztring Pos_Ztring; Pos_Ztring.From_Number(Pos);
+ if (Numbers_Size<Pos_Ztring.size())
+ break; //Not enough place for numbers
+ Pos_Ztring.insert(0, Numbers_Size-Pos_Ztring.size(), _T('0'));
+ Ztring Next=FileToTest.Path_Get()+PathSeparator+FileToTest_Name+Pos_Ztring+_T('.')+FileToTest.Extension_Get();
+ if (!File::Exists(Next))
+ break;
+ File_Names.push_back(Next);
+ }
+
+ if (!IsReferenced && File_Names.size()<24)
+ File_Names.resize(1); //Removing files, wrong detection
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Accept_TestContinuousFileNames()
+{
+ if (Config->File_Names.size()!=1)
+ return;
+
+ Streams_Accept_TestContinuousFileNames_Static(Config->File_Names, Config->File_IsReferenced_Get());
+
+ if (Config->File_Names.size()==1)
+ return;
+
+ Config->File_Sizes.clear();
+ Config->File_Size=0;
+ for (size_t Pos=0; Pos<Config->File_Names.size(); Pos++)
+ {
+ int64u Size=File::Size_Get(Config->File_Names[Pos]);
+ Config->File_Sizes.push_back(Size);
+ Config->File_Size+=Size;
+ }
+
+ File_Size=Config->File_Size;
+ Element[0].Next=File_Size;
+ Fill (Stream_General, 0, General_FileSize, File_Size, 10, true);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Finish_StreamOnly()
+{
+ //Generic
+ for (size_t StreamKind=Stream_General; StreamKind<Stream_Max; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Count_Get((stream_t)StreamKind); StreamPos++)
+ Streams_Finish_StreamOnly((stream_t)StreamKind, StreamPos);
+
+ //For each kind of (*Stream)
+ for (size_t Pos=0; Pos<Count_Get(Stream_General); Pos++) Streams_Finish_StreamOnly_General(Pos);
+ for (size_t Pos=0; Pos<Count_Get(Stream_Video); Pos++) Streams_Finish_StreamOnly_Video(Pos);
+ for (size_t Pos=0; Pos<Count_Get(Stream_Audio); Pos++) Streams_Finish_StreamOnly_Audio(Pos);
+ for (size_t Pos=0; Pos<Count_Get(Stream_Text); Pos++) Streams_Finish_StreamOnly_Text(Pos);
+ for (size_t Pos=0; Pos<Count_Get(Stream_Chapters); Pos++) Streams_Finish_StreamOnly_Chapters(Pos);
+ for (size_t Pos=0; Pos<Count_Get(Stream_Image); Pos++) Streams_Finish_StreamOnly_Image(Pos);
+ for (size_t Pos=0; Pos<Count_Get(Stream_Menu); Pos++) Streams_Finish_StreamOnly_Menu(Pos);
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Finish_StreamOnly(stream_t StreamKind, size_t Pos)
+{
+ //BitRate from Duration and StreamSize
+ if (StreamKind!=Stream_General && StreamKind!=Stream_Chapters && StreamKind!=Stream_Menu && Retrieve(StreamKind, Pos, "BitRate").empty() && !Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_StreamSize)).empty() && !Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_Duration)).empty())
+ {
+ float64 Duration=0;
+ if (StreamKind==Stream_Video && !Retrieve(Stream_Video, Pos, Video_FrameCount).empty() && !Retrieve(Stream_Video, Pos, Video_FrameRate).empty())
+ {
+ int64u FrameCount=Retrieve(Stream_Video, Pos, Video_FrameCount).To_int64u();
+ float64 FrameRate=Retrieve(Stream_Video, Pos, Video_FrameRate).To_float64();
+ if (FrameCount && FrameRate)
+ Duration=FrameCount*1000/FrameRate; //More precise (example: 1 frame at 29.97 fps)
+ }
+ if (Duration==0)
+ Duration=Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_Duration)).To_float64();
+ int64u StreamSize=Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_StreamSize)).To_int64u();
+ if (Duration>0 && StreamSize>0)
+ Fill(StreamKind, Pos, "BitRate", StreamSize*8*1000/Duration, 0);
+ }
+
+ //BitRate_Encoded from Duration and StreamSize_Encoded
+ if (StreamKind!=Stream_General && StreamKind!=Stream_Chapters && StreamKind!=Stream_Menu && Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_BitRate_Encoded)).empty() && !Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_StreamSize_Encoded)).empty() && !Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_Duration)).empty())
+ {
+ float64 Duration=0;
+ if (StreamKind==Stream_Video && !Retrieve(Stream_Video, Pos, Video_FrameCount).empty() && !Retrieve(Stream_Video, Pos, Video_FrameRate).empty())
+ {
+ int64u FrameCount=Retrieve(Stream_Video, Pos, Video_FrameCount).To_int64u();
+ float64 FrameRate=Retrieve(Stream_Video, Pos, Video_FrameRate).To_float64();
+ if (FrameCount && FrameRate)
+ Duration=FrameCount*1000/FrameRate; //More precise (example: 1 frame at 29.97 fps)
+ }
+ if (Duration==0)
+ Duration=Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_Duration)).To_float64();
+ int64u StreamSize_Encoded=Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_StreamSize_Encoded)).To_int64u();
+ if (Duration>0 && StreamSize_Encoded>0)
+ Fill(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_BitRate_Encoded), StreamSize_Encoded*8*1000/Duration, 0);
+ }
+
+ //Duration from Bitrate and StreamSize
+ if (StreamKind!=Stream_Chapters && Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_Duration)).empty() && !Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_StreamSize)).empty() && !Retrieve(StreamKind, Pos, "BitRate").empty() && Count_Get(Stream_Video)+Count_Get(Stream_Audio)>1) //If only one stream, duration will be copied later, useful for exact bitrate calculation
+ {
+ int64u BitRate=Retrieve(StreamKind, Pos, "BitRate").To_int64u();
+ int64u StreamSize=Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_StreamSize)).To_int64u();
+ if (BitRate>0 && StreamSize>0)
+ Fill(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_Duration), StreamSize*8*1000/BitRate);
+ }
+
+ //StreamSize from BitRate and Duration
+ if (StreamKind!=Stream_Chapters && Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_StreamSize)).empty() && !Retrieve(StreamKind, Pos, "BitRate").empty() && !Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_Duration)).empty() && Retrieve(StreamKind, Pos, "BitRate").find(_T(" / "))==std::string::npos) //If not done the first time or by other routine
+ {
+ int64u BitRate=Retrieve(StreamKind, Pos, "BitRate").To_int64u();
+ int64u Duration=Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_Duration)).To_int64u();
+ if (BitRate>0 && Duration>0)
+ Fill(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_StreamSize), BitRate*Duration/8/1000);
+ }
+
+ //Bit rate and maximum bit rate
+ if (!Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_BitRate)).empty() && Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_BitRate))==Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_BitRate_Maximum)))
+ {
+ Clear(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_BitRate_Maximum));
+ if (Retrieve(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_BitRate_Mode)).empty())
+ Fill(StreamKind, Pos, Fill_Parameter(StreamKind, Generic_BitRate_Mode), "CBR");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Finish_StreamOnly_General(size_t UNUSED(StreamPos))
+{
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Finish_StreamOnly_Video(size_t Pos)
+{
+ //Frame count
+ if (Retrieve(Stream_Video, Pos, Video_FrameCount).empty() && Frame_Count_NotParsedIncluded!=(int64u)-1 && File_Offset+Buffer_Size==File_Size)
+ {
+ if (Count_Get(Stream_Video)==1 && Count_Get(Stream_Audio)==0)
+ Fill(Stream_Video, 0, Video_FrameCount, Frame_Count_NotParsedIncluded);
+ }
+
+ //FrameCount from Duration and FrameRate
+ if (Retrieve(Stream_Video, Pos, Video_FrameCount).empty())
+ {
+ int64s Duration=Retrieve(Stream_Video, Pos, Video_Duration).To_int64s();
+ if (Duration==0)
+ Duration=Retrieve(Stream_General, 0, General_Duration).To_int64s();
+ float64 FrameRate=Retrieve(Stream_Video, Pos, Video_FrameRate).To_float64();
+ if (Duration && FrameRate)
+ Fill(Stream_Video, Pos, Video_FrameCount, Duration*FrameRate/1000, 0);
+ }
+
+ //Duration from FrameCount and FrameRate
+ if (Retrieve(Stream_Video, Pos, Video_Duration).empty())
+ {
+ int64u FrameCount=Retrieve(Stream_Video, Pos, Video_FrameCount).To_int64u();
+ float64 FrameRate=Retrieve(Stream_Video, Pos, "FrameRate").To_float64();
+ if (FrameCount && FrameRate)
+ Fill(Stream_Video, Pos, Video_Duration, FrameCount/FrameRate*1000, 0);
+ }
+
+ //Pixel Aspect Ratio forced to 1.000 if none
+ if (Retrieve(Stream_Video, Pos, Video_PixelAspectRatio).empty())
+ Fill(Stream_Video, Pos, Video_PixelAspectRatio, 1.000);
+
+ //Standard
+ if (Retrieve(Stream_Video, Pos, Video_Standard).empty() && (Retrieve(Stream_Video, Pos, Video_Width)==_T("720") || Retrieve(Stream_Video, Pos, Video_Width)==_T("704")))
+ {
+ if (Retrieve(Stream_Video, Pos, Video_Height)==_T("576"))
+ Fill(Stream_Video, Pos, Video_Standard, "PAL");
+ else if (Retrieve(Stream_Video, Pos, Video_Height)==_T("486") || Retrieve(Stream_Video, Pos, Video_Height)==_T("480"))
+ Fill(Stream_Video, Pos, Video_Standard, "NTSC");
+ }
+ if (Retrieve(Stream_Video, Pos, Video_Standard).empty() && Retrieve(Stream_Video, Pos, Video_Width)==_T("352"))
+ {
+ if (Retrieve(Stream_Video, Pos, Video_Height)==_T("576") || Retrieve(Stream_Video, Pos, Video_Height)==_T("288"))
+ Fill(Stream_Video, Pos, Video_Standard, "PAL");
+ else if (Retrieve(Stream_Video, Pos, Video_Height)==_T("486") || Retrieve(Stream_Video, Pos, Video_Height)==_T("480") || Retrieve(Stream_Video, Pos, Video_Height)==_T("243") || Retrieve(Stream_Video, Pos, Video_Height)==_T("240"))
+ Fill(Stream_Video, Pos, Video_Standard, "NTSC");
+ }
+
+ //Known ScanTypes
+ if (Retrieve(Stream_Video, Pos, Video_ScanType).empty()
+ && (Retrieve(Stream_Video, Pos, Video_Format)==_T("RED")
+ || Retrieve(Stream_Video, Pos, Video_Format)==_T("CineForm")
+ || Retrieve(Stream_Video, Pos, Video_Format)==_T("DPX")
+ || Retrieve(Stream_Video, Pos, Video_Format)==_T("EXR")))
+ Fill(Stream_Video, Pos, Video_ScanType, "PPF");
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Finish_StreamOnly_Audio(size_t Pos)
+{
+ //SamplingCount
+ if (Retrieve(Stream_Audio, Pos, Audio_SamplingCount).empty())
+ {
+ int64s Duration=Retrieve(Stream_Audio, Pos, Audio_Duration).To_int64s();
+ if (Duration==0)
+ Duration=Retrieve(Stream_General, 0, General_Duration).To_int64s();
+ float SamplingRate=Retrieve(Stream_Audio, Pos, Audio_SamplingRate).To_float32();
+ if (Duration && SamplingRate)
+ Fill(Stream_Audio, Pos, Audio_SamplingCount, ((float64)Duration)/1000*SamplingRate, 0);
+ }
+
+ //Frame count
+ if (Retrieve(Stream_Audio, Pos, Audio_FrameCount).empty() && Frame_Count_NotParsedIncluded!=(int64u)-1 && File_Offset+Buffer_Size==File_Size)
+ {
+ if (Count_Get(Stream_Video)==0 && Count_Get(Stream_Audio)==1)
+ Fill(Stream_Audio, 0, Audio_FrameCount, Frame_Count_NotParsedIncluded);
+ }
+
+ //Duration
+ if (Retrieve(Stream_Audio, Pos, Audio_Duration).empty() && Retrieve(Stream_Audio, Pos, Audio_SamplingRate).To_int64u()!=0)
+ {
+ int64u Duration=Retrieve(Stream_Audio, Pos, Audio_SamplingCount).To_int64u()*1000/Retrieve(Stream_Audio, Pos, Audio_SamplingRate).To_int64u();
+ if (Duration)
+ Fill(Stream_Audio, Pos, Audio_Duration, Duration);
+ }
+
+ //Stream size
+ if (Retrieve(Stream_Audio, Pos, Audio_StreamSize).empty() && !Retrieve(Stream_Audio, Pos, Audio_BitRate).empty() && !Retrieve(Stream_Audio, Pos, Audio_Duration).empty() && Retrieve(Stream_Audio, Pos, Audio_BitRate_Mode)==_T("CBR"))
+ {
+ int64u Duration=Retrieve(Stream_Audio, Pos, Audio_Duration).To_int64u();
+ int64u BitRate=Retrieve(Stream_Audio, Pos, Audio_BitRate).To_int64u();
+ if (Duration && BitRate)
+ Fill(Stream_Audio, Pos, Audio_StreamSize, Duration*BitRate/8/1000);
+ }
+
+ //CBR/VBR
+ if (Retrieve(Stream_Audio, Pos, Audio_BitRate_Mode).empty() && !Retrieve(Stream_Audio, Pos, Audio_Codec).empty())
+ {
+ Ztring Z1=MediaInfoLib::Config.Codec_Get(Retrieve(Stream_Audio, Pos, Audio_Codec), InfoCodec_BitRate_Mode, Stream_Audio);
+ if (!Z1.empty())
+ Fill(Stream_Audio, Pos, Audio_BitRate_Mode, Z1);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Finish_StreamOnly_Text(size_t UNUSED(Pos))
+{
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Finish_StreamOnly_Chapters(size_t UNUSED(StreamPos))
+{
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Finish_StreamOnly_Image(size_t UNUSED(StreamPos))
+{
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Finish_StreamOnly_Menu(size_t UNUSED(StreamPos))
+{
+}
+
+//---------------------------------------------------------------------------
+void File__Analyze::Streams_Finish_InterStreams()
+{
+ //Duration if General not filled
+ if (Retrieve(Stream_General, 0, General_Duration).empty())
+ {
+ int64u Duration=0;
+ //For all streams (Generic)
+ for (size_t StreamKind=Stream_Video; StreamKind<Stream_Max; StreamKind++)
+ for (size_t Pos=0; Pos<Count_Get((stream_t)StreamKind); Pos++)
+ {
+ if (!Retrieve((stream_t)StreamKind, Pos, Fill_Parameter((stream_t)StreamKind, Generic_Duration)).empty())
+ {
+ int64u Duration_Stream=Retrieve((stream_t)StreamKind, Pos, Fill_Parameter((stream_t)StreamKind, Generic_Duration)).To_int64u();
+ if (Duration_Stream>Duration)
+ Duration=Duration_Stream;
+ }
+ }
+
+ //Filling
+ if (Duration>0)
+ Fill(Stream_General, 0, General_Duration, Duration);
+ }
+
+ //(*Stream) size if all stream sizes are OK
+ if (Retrieve(Stream_General, 0, General_StreamSize).empty())
+ {
+ int64u StreamSize_Total=0;
+ bool IsOK=true;
+ //For all streams (Generic)
+ for (size_t StreamKind=Stream_Video; StreamKind<Stream_Max; StreamKind++)
+ {
+ if (StreamKind!=Stream_Chapters && StreamKind!=Stream_Menu) //They have no big size, we never calculate them
+ for (size_t Pos=0; Pos<Count_Get((stream_t)StreamKind); Pos++)
+ {
+ if (!Retrieve((stream_t)StreamKind, Pos, Fill_Parameter((stream_t)StreamKind, Generic_StreamSize_Encoded)).empty())
+ StreamSize_Total+=Retrieve((stream_t)StreamKind, Pos, Fill_Parameter((stream_t)StreamKind, Generic_StreamSize_Encoded)).To_int64u();
+ else if (!Retrieve((stream_t)StreamKind, Pos, Fill_Parameter((stream_t)StreamKind, Generic_StreamSize)).empty())
+ StreamSize_Total+=Retrieve((stream_t)StreamKind, Pos, Fill_Parameter((stream_t)StreamKind, Generic_StreamSize)).To_int64u();
+ else
+ IsOK=false; //StreamSize not available for 1 stream, we can't calculate
+ }
+ }
+
+ //Filling
+ if (IsOK && StreamSize_Total>0 && StreamSize_Total<File_Size)
+ Fill(Stream_General, 0, General_StreamSize, File_Size-StreamSize_Total);
+ }
+
+ //OverallBitRate if we have one Audio stream with bitrate
+ if (Retrieve(Stream_General, 0, General_Duration).empty() && Retrieve(Stream_General, 0, General_OverallBitRate).empty() && Count_Get(Stream_Video)==0 && Count_Get(Stream_Audio)==1 && Retrieve(Stream_Audio, 0, Audio_BitRate).To_int64u()!=0 && (Retrieve(Stream_General, 0, General_Format)==Retrieve(Stream_Audio, 0, Audio_Format) || !Retrieve(Stream_General, 0, General_HeaderSize).empty()))
+ Fill(Stream_General, 0, General_OverallBitRate, Retrieve(Stream_Audio, 0, Audio_BitRate));
+
+ //OverallBitRate if Duration
+ if (Retrieve(Stream_General, 0, General_OverallBitRate).empty() && Retrieve(Stream_General, 0, General_Duration).To_int64u()!=0 && !Retrieve(Stream_General, 0, General_FileSize).empty())
+ {
+ float64 Duration=0;
+ if (Count_Get(Stream_Video)==1 && Retrieve(Stream_General, 0, General_Duration)==Retrieve(Stream_Video, 0, General_Duration) && !Retrieve(Stream_Video, 0, Video_FrameCount).empty() && !Retrieve(Stream_Video, 0, Video_FrameRate).empty())
+ {
+ int64u FrameCount=Retrieve(Stream_Video, 0, Video_FrameCount).To_int64u();
+ float64 FrameRate=Retrieve(Stream_Video, 0, Video_FrameRate).To_float64();
+ if (FrameCount && FrameRate)
+ Duration=FrameCount*1000/FrameRate; //More precise (example: 1 frame at 29.97 fps)
+ }
+ if (Duration==0)
+ Duration=Retrieve(Stream_General, 0, General_Duration).To_float64();
+ Fill(Stream_General, 0, General_OverallBitRate, Retrieve(Stream_General, 0, General_FileSize).To_int64u()*8*1000/Duration, 0);
+ }
+
+ //Duration if OverallBitRate
+ if (Retrieve(Stream_General, 0, General_Duration).empty() && Retrieve(Stream_General, 0, General_OverallBitRate).To_int64u()!=0)
+ Fill(Stream_General, 0, General_Duration, Retrieve(Stream_General, 0, General_FileSize).To_float64()*8*1000/Retrieve(Stream_General, 0, General_OverallBitRate).To_float64(), 0);
+
+ //Video bitrate can be the nominal one if <4s (bitrate estimation is not enough precise
+ if (Count_Get(Stream_Video)==1 && Retrieve(Stream_Video, 0, Video_BitRate).empty() && Retrieve(Stream_General, 0, General_Duration).To_int64u()<4000)
+ {
+ Fill(Stream_Video, 0, Video_BitRate, Retrieve(Stream_Video, 0, Video_BitRate_Nominal));
+ Clear(Stream_Video, 0, Video_BitRate_Nominal);
+ }
+
+ //Video bitrate if we have all audio bitrates and overal bitrate
+ if (Count_Get(Stream_Video)==1 && Retrieve(Stream_General, 0, General_OverallBitRate).size()>4 && Retrieve(Stream_Video, 0, Video_BitRate).empty() && Retrieve(Stream_Video, 0, Video_BitRate_Encoded).empty() && Retrieve(Stream_General, 0, General_Duration).To_int64u()>=1000) //BitRate is > 10 000 and Duration>10s, to avoid strange behavior
+ {
+ double GeneralBitRate_Ratio=0.98; //Default container overhead=2%
+ int32u GeneralBitRate_Minus=5000; //5000 bps because of a "classic" stream overhead
+ double VideoBitRate_Ratio =0.98; //Default container overhead=2%
+ int32u VideoBitRate_Minus =2000; //2000 bps because of a "classic" stream overhead
+ double AudioBitRate_Ratio =0.98; //Default container overhead=2%
+ int32u AudioBitRate_Minus =2000; //2000 bps because of a "classic" stream overhead
+ double TextBitRate_Ratio =0.98; //Default container overhead=2%
+ int32u TextBitRate_Minus =2000; //2000 bps because of a "classic" stream overhead
+ //Specific value depends of Container
+ if (IsRawStream)
+ {
+ GeneralBitRate_Ratio=1;
+ GeneralBitRate_Minus=0;
+ VideoBitRate_Ratio =1;
+ VideoBitRate_Minus =0;
+ AudioBitRate_Ratio =1;
+ AudioBitRate_Minus =0;
+ TextBitRate_Ratio =1;
+ TextBitRate_Minus =0;
+ }
+ if (Get(Stream_General, 0, _T("Format"))==_T("MPEG-TS"))
+ {
+ GeneralBitRate_Ratio=0.98;
+ GeneralBitRate_Minus=0;
+ VideoBitRate_Ratio =0.97;
+ VideoBitRate_Minus =0;
+ AudioBitRate_Ratio =0.96;
+ AudioBitRate_Minus =0;
+ TextBitRate_Ratio =0.96;
+ TextBitRate_Minus =0;
+ }
+ if (Get(Stream_General, 0, _T("Format"))==_T("MPEG-PS"))
+ {
+ GeneralBitRate_Ratio=0.99;
+ GeneralBitRate_Minus=0;
+ VideoBitRate_Ratio =0.99;
+ VideoBitRate_Minus =0;
+ AudioBitRate_Ratio =0.99;
+ AudioBitRate_Minus =0;
+ TextBitRate_Ratio =0.99;
+ TextBitRate_Minus =0;
+ }
+ if (MediaInfoLib::Config.Format_Get(Retrieve(Stream_General, 0, General_Format), InfoFormat_KindofFormat)==_T("MPEG-4"))
+ {
+ GeneralBitRate_Ratio=1;
+ GeneralBitRate_Minus=0;
+ VideoBitRate_Ratio =1;
+ VideoBitRate_Minus =0;
+ AudioBitRate_Ratio =1;
+ AudioBitRate_Minus =0;
+ TextBitRate_Ratio =1;
+ TextBitRate_Minus =0;
+ }
+ if (Get(Stream_General, 0, _T("Format"))==_T("Matroska"))
+ {
+ GeneralBitRate_Ratio=0.99;
+ GeneralBitRate_Minus=0;
+ VideoBitRate_Ratio =0.99;
+ VideoBitRate_Minus =0;
+ AudioBitRate_Ratio =0.99;
+ AudioBitRate_Minus =0;
+ TextBitRate_Ratio =0.99;
+ TextBitRate_Minus =0;
+ }
+
+ //Testing
+ float64 VideoBitRate=Retrieve(Stream_General, 0, General_OverallBitRate).To_float64()*GeneralBitRate_Ratio-GeneralBitRate_Minus;
+ bool VideobitRateIsValid=true;
+ for (size_t Pos=0; Pos<Count_Get(Stream_Audio); Pos++)
+ {
+ float64 AudioBitRate=0;
+ if (!Retrieve(Stream_Audio, Pos, Audio_BitRate).empty() && Retrieve(Stream_Audio, Pos, Audio_BitRate)[0]<=_T('9')) //Note: quick test if it is a number
+ AudioBitRate=Retrieve(Stream_Audio, Pos, Audio_BitRate).To_float64();
+ else if (!Retrieve(Stream_Audio, Pos, Audio_BitRate_Encoded).empty() && Retrieve(Stream_Audio, Pos, Audio_BitRate_Encoded)[0]<=_T('9')) //Note: quick test if it is a number
+ AudioBitRate=Retrieve(Stream_Audio, Pos, Audio_BitRate_Encoded).To_float64();
+ else
+ VideobitRateIsValid=false;
+ if (VideobitRateIsValid && AudioBitRate_Ratio)
+ VideoBitRate-=AudioBitRate/AudioBitRate_Ratio+AudioBitRate_Minus;
+ }
+ for (size_t Pos=0; Pos<Count_Get(Stream_Text); Pos++)
+ {
+ float64 TextBitRate;
+ if (Retrieve(Stream_Text, Pos, Text_BitRate_Encoded).empty())
+ TextBitRate=Retrieve(Stream_Text, Pos, Text_BitRate).To_float64();
+ else
+ TextBitRate=Retrieve(Stream_Text, Pos, Text_BitRate_Encoded).To_float64();
+ if (TextBitRate_Ratio)
+ VideoBitRate-=TextBitRate/TextBitRate_Ratio+TextBitRate_Minus;
+ else
+ VideoBitRate-=1000; //Estimation: Text stream are not often big
+ }
+ if (VideobitRateIsValid && VideoBitRate>=10000) //to avoid strange behavior
+ {
+ VideoBitRate=VideoBitRate*VideoBitRate_Ratio-VideoBitRate_Minus;
+ Fill(Stream_Video, 0, Video_BitRate, VideoBitRate, 0); //Default container overhead=2%
+ if (Retrieve(Stream_Video, 0, Video_StreamSize).empty() && !Retrieve(Stream_Video, 0, Video_Duration).empty())
+ {
+ float64 Duration=0;
+ if (!Retrieve(Stream_Video, 0, Video_FrameCount).empty() && !Retrieve(Stream_Video, 0, Video_FrameRate).empty())
+ {
+ int64u FrameCount=Retrieve(Stream_Video, 0, Video_FrameCount).To_int64u();
+ float64 FrameRate=Retrieve(Stream_Video, 0, Video_FrameRate).To_float64();
+ if (FrameCount && FrameRate)
+ Duration=FrameCount*1000/FrameRate; //More precise (example: 1 frame at 29.97 fps)
+ }
+ if (Duration==0)
+ Duration=Retrieve(Stream_Video, 0, Video_Duration).To_float64();
+ if (Duration)
+ {
+ int64u StreamSize=float64_int64s(VideoBitRate/8*Duration/1000);
+ if (IsRawStream && File_Size!=(int64u)-1 && StreamSize>=File_Size*0.99)
+ StreamSize=File_Size;
+ Fill(Stream_Video, 0, Video_StreamSize, StreamSize);
+ }
+ }
+ }
+ }
+
+ //General stream size if we have all streamsize
+ if (File_Size!=(int64u)-1 && Retrieve(Stream_General, 0, General_StreamSize).empty())
+ {
+ //Testing
+ int64s StreamSize=File_Size;
+ bool StreamSizeIsValid=true;
+ for (size_t StreamKind_Pos=Stream_General+1; StreamKind_Pos<Stream_Menu; StreamKind_Pos++)
+ for (size_t Pos=0; Pos<Count_Get((stream_t)StreamKind_Pos); Pos++)
+ {
+ int64u StreamXX_StreamSize=Retrieve((stream_t)StreamKind_Pos, Pos, Fill_Parameter((stream_t)StreamKind_Pos, Generic_StreamSize)).To_int64u();
+ if (StreamXX_StreamSize>0 || StreamKind_Pos==Stream_Text)
+ StreamSize-=StreamXX_StreamSize;
+ else
+ StreamSizeIsValid=false;
+ }
+ if (StreamSizeIsValid && StreamSize>=0) //to avoid strange behavior
+ Fill(Stream_General, 0, General_StreamSize, StreamSize);
+ }
+
+ //General_OverallBitRate_Mode
+ if (Retrieve(Stream_General, 0, General_OverallBitRate_Mode).empty())
+ {
+ bool IsValid=false;
+ bool IsCBR=true;
+ bool IsVBR=false;
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Menu; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Count_Get((stream_t)StreamKind); StreamPos++)
+ {
+ if (!IsValid)
+ IsValid=true;
+ if (Retrieve((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_BitRate_Mode))!=_T("CBR"))
+ IsCBR=false;
+ if (Retrieve((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_BitRate_Mode))==_T("VBR"))
+ IsVBR=true;
+ }
+ if (IsValid)
+ {
+ if (IsCBR)
+ Fill(Stream_General, 0, General_OverallBitRate_Mode, "CBR");
+ if (IsVBR)
+ Fill(Stream_General, 0, General_OverallBitRate_Mode, "VBR");
+ }
+ }
+
+ //Tags
+ Tags();
+}
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Base.cpp b/src/thirdparty/MediaInfo/MediaInfo/File__Base.cpp
new file mode 100644
index 000000000..ce830520b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Base.cpp
@@ -0,0 +1,229 @@
+// File__Base - Base for other files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Base.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "ZenLib/File.h"
+#include <cstring>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Gestion de la classe
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Constructeurs
+File__Base::File__Base ()
+{
+ //Init pointers
+ #if MEDIAINFO_TRACE
+ Details=NULL;
+ #endif //MEDIAINFO_TRACE
+ Stream=NULL;
+ Stream_More=NULL;
+ Stream_MustBeDeleted=false;
+
+ //File
+ File_Size=(int64u)-1;
+ File_Offset=0;
+ File_Offset_FirstSynched=(int64u)-1;
+ File_GoTo=(int64u)-1;
+
+ //Optimization init
+ StreamKind_Last=Stream_Max;
+ StreamPos_Last=Error;
+
+ //Config
+ Config=NULL;
+}
+
+//---------------------------------------------------------------------------
+//Constructeurs
+File__Base::~File__Base ()
+{
+ if (Stream_MustBeDeleted)
+ {
+ delete Stream; //Stream=NULL;
+ delete Stream_More; //Stream_More=NULL;
+ }
+}
+
+//---------------------------------------------------------------------------
+//Base
+#if MEDIAINFO_TRACE
+void File__Base::Init (MediaInfo_Config_MediaInfo * Config_, Ztring* Details_, std::vector<std::vector<ZtringList> > * Stream_, std::vector<std::vector<ZtringListList> > * Stream_More_)
+#else //MEDIAINFO_TRACE
+void File__Base::Init (MediaInfo_Config_MediaInfo * Config_, std::vector<std::vector<ZtringList> > * Stream_, std::vector<std::vector<ZtringListList> > * Stream_More_)
+#endif //MEDIAINFO_TRACE
+{
+ if (Config)
+ return; //Already done
+
+ if (Stream_)
+ {
+ Stream=Stream_;
+ Stream_More=Stream_More_;
+ Stream_MustBeDeleted=false;
+ }
+ else
+ {
+ Stream=new std::vector<std::vector<ZtringList> >;
+ Stream->resize(Stream_Max);
+ Stream_More=new std::vector<std::vector<ZtringListList> >;
+ Stream_More->resize(Stream_Max);
+ Stream_MustBeDeleted=true;
+ }
+
+ Config=Config_;
+ #if MEDIAINFO_TRACE
+ Details=Details_;
+ #endif //MEDIAINFO_TRACE
+}
+
+//***************************************************************************
+// Fonctions
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t File__Base::Count_Get (stream_t StreamKind, size_t Pos) const
+{
+ //Integrity
+ if (StreamKind>=Stream_Max)
+ return 0;
+
+ //Count of streams
+ if (!Stream)
+ return 0;
+ if (Pos==Error)
+ return (*Stream)[StreamKind].size();
+
+ //Integrity
+ if (Pos>=(*Stream)[StreamKind].size())
+ return 0;
+
+ //Count of piece of information in a stream
+ return MediaInfoLib::Config.Info_Get(StreamKind).size()+(*Stream_More)[StreamKind][Pos].size();
+}
+
+//---------------------------------------------------------------------------
+const Ztring &File__Base::Get (stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t KindOfInfo)
+{
+ //Check integrity
+ if (StreamKind>=Stream_Max || StreamNumber>=(*Stream)[StreamKind].size() || Parameter>=MediaInfoLib::Config.Info_Get(StreamKind).size()+(*Stream_More)[StreamKind][StreamNumber].size() || KindOfInfo>=Info_Max)
+ return MediaInfoLib::Config.EmptyString_Get(); //Parameter is unknown
+
+ else if (Parameter<MediaInfoLib::Config.Info_Get(StreamKind).size())
+ {
+ //Optimization : KindOfInfo>Info_Text is in static lists
+ if (KindOfInfo!=Info_Text)
+ return MediaInfoLib::Config.Info_Get(StreamKind)[Parameter][KindOfInfo]; //look for static information only
+ else if (Parameter<(*Stream)[StreamKind][StreamNumber].size())
+ return (*Stream)[StreamKind][StreamNumber][Parameter];
+ else
+ return MediaInfoLib::Config.EmptyString_Get(); //This parameter is known, but not filled
+ }
+ else
+ {
+ if (((size_t)(Parameter-MediaInfoLib::Config.Info_Get(StreamKind).size()))<(*Stream_More)[StreamKind][StreamNumber].size() && ((size_t)KindOfInfo)<(*Stream_More)[StreamKind][StreamNumber][Parameter-MediaInfoLib::Config.Info_Get(StreamKind).size()].size())
+ return (*Stream_More)[StreamKind][StreamNumber][Parameter-MediaInfoLib::Config.Info_Get(StreamKind).size()][KindOfInfo];
+ else
+ return MediaInfoLib::Config.EmptyString_Get(); //Not filled
+ }
+}
+
+//---------------------------------------------------------------------------
+const Ztring &File__Base::Get (stream_t StreamKind, size_t StreamPos, const Ztring &Parameter, info_t KindOfInfo, info_t KindOfSearch)
+{
+ size_t ParameterI=0;
+
+ //Check integrity
+ if (StreamKind>=Stream_Max || StreamPos>=(*Stream)[StreamKind].size() || KindOfInfo>=Info_Max)
+ return MediaInfoLib::Config.EmptyString_Get();
+ if ((ParameterI=MediaInfoLib::Config.Info_Get(StreamKind).Find(Parameter, KindOfSearch))==Error)
+ {
+ ParameterI=(*Stream_More)[StreamKind][StreamPos].Find(Parameter, KindOfSearch);
+ if (ParameterI==Error)
+ return MediaInfoLib::Config.EmptyString_Get(); //Parameter is unknown
+ return (*Stream_More)[StreamKind][StreamPos][ParameterI](KindOfInfo);
+ }
+
+ return Get(StreamKind, StreamPos, ParameterI, KindOfInfo);
+}
+
+//---------------------------------------------------------------------------
+int File__Base::Set (stream_t StreamKind, size_t StreamNumber, size_t Parameter, const Ztring &ToSet, const Ztring &OldValue)
+{
+ //Integrity
+ if (Count_Get(StreamKind)<=StreamNumber)
+ return 0;
+
+ return Set(StreamKind, StreamNumber, Get(StreamKind, StreamNumber, Parameter, Info_Name), ToSet, OldValue);
+}
+
+//---------------------------------------------------------------------------
+int File__Base::Set (stream_t StreamKind, size_t StreamNumber, const Ztring &Parameter, const Ztring &ToSet, const Ztring &OldValue)
+{
+ //Integrity
+ if (Count_Get(StreamKind)<=StreamNumber)
+ return 0;
+
+ return Write(StreamKind, StreamNumber, Parameter, ToSet, OldValue);
+}
+
+//---------------------------------------------------------------------------
+void File__Base::Language_Set()
+{
+}
+
+//***************************************************************************
+// Divers
+//***************************************************************************
+
+void File__Base::Clear()
+{
+ for (size_t StreamKind=0; StreamKind<Stream_Max; StreamKind++)
+ {
+ (*Stream)[StreamKind].clear();
+ (*Stream_More)[StreamKind].clear();
+ }
+}
+
+} //NameSpace
+
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Base.h b/src/thirdparty/MediaInfo/MediaInfo/File__Base.h
new file mode 100644
index 000000000..25aefc22c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Base.h
@@ -0,0 +1,128 @@
+// File__Base - Base for other files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Give common methods for all file types
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo__BaseH
+#define MediaInfo__BaseH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "ZenLib/ZtringListList.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class MediaInfo_Config_MediaInfo;
+
+//***************************************************************************
+// Class File__Base
+//***************************************************************************
+
+class File__Base
+{
+public :
+ //Constructor/Destructor
+ File__Base();
+ virtual ~File__Base();
+ #if MEDIAINFO_TRACE
+ void Init(MediaInfo_Config_MediaInfo * Config, Ztring* Details, std::vector<std::vector<ZtringList> > * Stream_=NULL, std::vector<std::vector<ZtringListList> > * Stream_More=NULL);
+ #else //MEDIAINFO_TRACE
+ void Init(MediaInfo_Config_MediaInfo * Config, std::vector<std::vector<ZtringList> > * Stream_=NULL, std::vector<std::vector<ZtringListList> > * Stream_More=NULL);
+ #endif //MEDIAINFO_TRACE
+
+ //Save
+ int Save ();
+
+ //Get information
+ const Ztring &Get (stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t KindOfInfo=Info_Text);
+ virtual const Ztring &Get (stream_t StreamKind, size_t StreamNumber, const Ztring &Parameter, info_t KindOfInfo=Info_Text, info_t KindOfSearch=Info_Name);
+
+ //Set information
+ int Set (stream_t StreamKind, size_t StreamNumber, size_t Parameter, const Ztring &ToSet, const Ztring &OldValue=_T(""));
+ int Set (stream_t StreamKind, size_t StreamNumber, const Ztring &Parameter, const Ztring &ToSet, const Ztring &OldValue=_T(""));
+
+ //Output buffer
+ virtual size_t Output_Buffer_Get (const String &) {return 0;};
+ virtual size_t Output_Buffer_Get (size_t) {return 0;};
+
+ //Options
+ size_t Count_Get (stream_t StreamKind, size_t Pos=Error) const;
+ void Language_Set (); //Update language for an existing File__Base
+
+protected :
+ //Read
+ virtual void Read_Buffer_Init () {} //To overload
+ virtual void Read_Buffer_Unsynched() {} //To overload
+ virtual void Read_Buffer_Continue () {} //To overload
+ virtual void Read_Buffer_Finalize () {} //To overload
+
+ //Write
+ virtual int Write (stream_t /*StreamKind*/, size_t /*StreamNumber*/, const Ztring &/*Parameter*/, const Ztring &/*ToSet*/, const Ztring &/*OldValue*/) {return -1;} //Write the value in memory
+ virtual int WriteToDisk () {return -1;} //Write modified tags on disk
+
+ //Arrays
+//private : //TODO:put it as private (DvDif)
+ std::vector<std::vector<ZtringList> > * Stream; //pointer to others listed streams
+ std::vector<std::vector<ZtringListList> > * Stream_More; //pointer to others listed streams
+ bool Stream_MustBeDeleted;
+protected :
+ stream_t StreamKind_Last;
+ size_t StreamPos_Last;
+
+ //Config
+ MediaInfo_Config_MediaInfo* Config;
+
+ //Details
+ #if MEDIAINFO_TRACE
+ Ztring* Details;
+ #endif //MEDIAINFO_TRACE
+
+public :
+ #if MEDIAINFO_TRACE
+ void Details_Add(const char* Parameter);
+ #endif //MEDIAINFO_TRACE
+ virtual void Option_Manage() {};
+
+ //File
+ Ztring File_Name;
+ int64u File_Size;
+ int64u File_Offset;
+ int64u File_Offset_FirstSynched;
+ int64u File_GoTo; //How many byte to skip?
+
+ //Divers
+ void Clear();
+
+public : //A virer
+ friend class File__Analyze;
+ friend class File__MultipleParsing;
+ friend class File__ReferenceFilesHelper;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Duplicate.cpp b/src/thirdparty/MediaInfo/MediaInfo/File__Duplicate.cpp
new file mode 100644
index 000000000..467c85d90
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Duplicate.cpp
@@ -0,0 +1,100 @@
+// File__Duplicate - Duplication of some formats
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Duplication helper for some specific formats
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DUPLICATE
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Duplicate.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "ZenLib/ZtringList.h"
+#include "ZenLib/File.h"
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+File__Duplicate::File__Duplicate ()
+:File__Analyze()
+{
+ //Temp
+ File__Duplicate_HasChanged_=false;
+ File__Duplicate_Needed=false;
+ Config_File_Duplicate_Get_AlwaysNeeded_Count=0;
+}
+
+File__Duplicate::~File__Duplicate ()
+{
+}
+
+//***************************************************************************
+// Get
+//***************************************************************************
+
+bool File__Duplicate::File__Duplicate_Get ()
+{
+ return File__Duplicate_Needed;
+}
+
+bool File__Duplicate::File__Duplicate_HasChanged ()
+{
+ //Retrieving general configuration
+ while (Config->File_Duplicate_Get_AlwaysNeeded(Config_File_Duplicate_Get_AlwaysNeeded_Count))
+ {
+ if (File__Duplicate_Set(Config->File_Duplicate_Get(Config_File_Duplicate_Get_AlwaysNeeded_Count)))
+ File__Duplicate_HasChanged_=true;
+ Config_File_Duplicate_Get_AlwaysNeeded_Count++;
+ }
+
+ bool File__Duplicate_HasChanged_Temp=File__Duplicate_HasChanged_;
+ File__Duplicate_HasChanged_=false;
+ return File__Duplicate_HasChanged_Temp;
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_DUPLICATE
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__Duplicate.h b/src/thirdparty/MediaInfo/MediaInfo/File__Duplicate.h
new file mode 100644
index 000000000..0feb5ecd1
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__Duplicate.h
@@ -0,0 +1,65 @@
+// File__Extract - Extract of some formats
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef File__DuplicateH
+#define File__DuplicateH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Duplicate/File__Duplicate__Writer.h"
+#include "ZenLib/ZtringListList.h"
+#include <map>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File__Duplicate
+//***************************************************************************
+
+class File__Duplicate : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File__Duplicate();
+ virtual ~File__Duplicate();
+
+protected :
+ virtual bool File__Duplicate_Set (const Ztring &Value)=0; //Fill a new File__Duplicate value
+
+ //Get
+ bool File__Duplicate_Get ();
+
+ //Modifications
+ bool File__Duplicate_HasChanged();
+
+private :
+ bool File__Duplicate_HasChanged_;
+ bool File__Duplicate_Needed;
+ size_t Config_File_Duplicate_Get_AlwaysNeeded_Count;
+};
+
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__MultipleParsing.cpp b/src/thirdparty/MediaInfo/MediaInfo/File__MultipleParsing.cpp
new file mode 100644
index 000000000..b344fc99e
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__MultipleParsing.cpp
@@ -0,0 +1,710 @@
+// File__MultipleParsing - Info for MultipleParsing files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__MultipleParsing.h"
+//---------------------------------------------------------------------------
+// Multiple
+#if defined(MEDIAINFO_CDXA_YES)
+ #include "MediaInfo/Multiple/File_Cdxa.h"
+#endif
+#if defined(MEDIAINFO_DCP_YES)
+ #include "MediaInfo/Multiple/File_Dcp.h"
+#endif
+#if defined(MEDIAINFO_DPG_YES)
+ #include "MediaInfo/Multiple/File_Dpg.h"
+#endif
+#if defined(MEDIAINFO_DVDIF_YES)
+ #include "MediaInfo/Multiple/File_DvDif.h"
+#endif
+#if defined(MEDIAINFO_DVDV_YES)
+ #include "MediaInfo/Multiple/File_Dvdv.h"
+#endif
+#if defined(MEDIAINFO_DXW_YES)
+ #include "MediaInfo/Multiple/File_Dxw.h"
+#endif
+#if defined(MEDIAINFO_FLV_YES)
+ #include "MediaInfo/Multiple/File_Flv.h"
+#endif
+#if defined(MEDIAINFO_GXF_YES)
+ #include "MediaInfo/Multiple/File_Gxf.h"
+#endif
+#if defined(MEDIAINFO_HLS_YES)
+ #include "MediaInfo/Multiple/File_Hls.h"
+#endif
+#if defined(MEDIAINFO_ISM_YES)
+ #include "MediaInfo/Multiple/File_Ism.h"
+#endif
+#if defined(MEDIAINFO_IVF_YES)
+ #include "MediaInfo/Multiple/File_Ivf.h"
+#endif
+#if defined(MEDIAINFO_LXF_YES)
+ #include "MediaInfo/Multiple/File_Lxf.h"
+#endif
+#if defined(MEDIAINFO_MK_YES)
+ #include "MediaInfo/Multiple/File_Mk.h"
+#endif
+#if defined(MEDIAINFO_MPEG4_YES)
+ #include "MediaInfo/Multiple/File_Mpeg4.h"
+#endif
+#if defined(MEDIAINFO_MPEGPS_YES)
+ #include "MediaInfo/Multiple/File_MpegPs.h"
+#endif
+#if defined(MEDIAINFO_MPEGTS_YES) || defined(MEDIAINFO_BDAV_YES) || defined(MEDIAINFO_TSP_YES)
+ #include "MediaInfo/Multiple/File_MpegTs.h"
+#endif
+#if defined(MEDIAINFO_MXF_YES)
+ #include "MediaInfo/Multiple/File_Mxf.h"
+#endif
+#if defined(MEDIAINFO_NUT_YES)
+ #include "MediaInfo/Multiple/File_Nut.h"
+#endif
+#if defined(MEDIAINFO_OGG_YES)
+ #include "MediaInfo/Multiple/File_Ogg.h"
+#endif
+#if defined(MEDIAINFO_P2_YES)
+ #include "MediaInfo/Multiple/File_P2_Clip.h"
+#endif
+#if defined(MEDIAINFO_RIFF_YES)
+ #include "MediaInfo/Multiple/File_Riff.h"
+#endif
+#if defined(MEDIAINFO_RM_YES)
+ #include "MediaInfo/Multiple/File_Rm.h"
+#endif
+#if defined(MEDIAINFO_SEQUENCEINFO_YES)
+ #include "MediaInfo/Multiple/File_SequenceInfo.h"
+#endif
+#if defined(MEDIAINFO_SKM_YES)
+ #include "MediaInfo/Multiple/File_Skm.h"
+#endif
+#if defined(MEDIAINFO_SWF_YES)
+ #include "MediaInfo/Multiple/File_Swf.h"
+#endif
+#if defined(MEDIAINFO_WM_YES)
+ #include "MediaInfo/Multiple/File_Wm.h"
+#endif
+#if defined(MEDIAINFO_XDCAM_YES)
+ #include "MediaInfo/Multiple/File_Xdcam_Clip.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Video
+#if defined(MEDIAINFO_AVC_YES)
+ #include "MediaInfo/Video/File_Avc.h"
+#endif
+#if defined(MEDIAINFO_AVSV_YES)
+ #include "MediaInfo/Video/File_AvsV.h"
+#endif
+#if defined(MEDIAINFO_DIRAC_YES)
+ #include "MediaInfo/Video/File_Dirac.h"
+#endif
+#if defined(MEDIAINFO_FLIC_YES)
+ #include "MediaInfo/Video/File_Flic.h"
+#endif
+#if defined(MEDIAINFO_H263_YES)
+ #include "MediaInfo/Video/File_H263.h"
+#endif
+#if defined(MEDIAINFO_MPEG4V_YES)
+ #include "MediaInfo/Video/File_Mpeg4v.h"
+#endif
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_VC1_YES)
+ #include "MediaInfo/Video/File_Vc1.h"
+#endif
+#if defined(MEDIAINFO_VC3_YES)
+ #include "MediaInfo/Video/File_Vc3.h"
+#endif
+#if defined(MEDIAINFO_Y4M_YES)
+ #include "MediaInfo/Video/File_Y4m.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Audio
+#if defined(MEDIAINFO_AAC_YES)
+ #include "MediaInfo/Audio/File_Aac.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_AES3_YES)
+ #include "MediaInfo/Audio/File_Aes3.h"
+#endif
+#if defined(MEDIAINFO_ALS_YES)
+ #include "MediaInfo/Audio/File_Als.h"
+#endif
+#if defined(MEDIAINFO_AMR_YES)
+ #include "MediaInfo/Audio/File_Amr.h"
+#endif
+#if defined(MEDIAINFO_AMV_YES)
+ #include "MediaInfo/Audio/File_Amv.h"
+#endif
+#if defined(MEDIAINFO_APE_YES)
+ #include "MediaInfo/Audio/File_Ape.h"
+#endif
+#if defined(MEDIAINFO_AU_YES)
+ #include "MediaInfo/Audio/File_Au.h"
+#endif
+#if defined(MEDIAINFO_DTS_YES)
+ #include "MediaInfo/Audio/File_Dts.h"
+#endif
+#if defined(MEDIAINFO_XM_YES)
+ #include "MediaInfo/Audio/File_ExtendedModule.h"
+#endif
+#if defined(MEDIAINFO_FLAC_YES)
+ #include "MediaInfo/Audio/File_Flac.h"
+#endif
+#if defined(MEDIAINFO_IT_YES)
+ #include "MediaInfo/Audio/File_ImpulseTracker.h"
+#endif
+#if defined(MEDIAINFO_LA_YES)
+ #include "MediaInfo/Audio/File_La.h"
+#endif
+#if defined(MEDIAINFO_MIDI_YES)
+ #include "MediaInfo/Audio/File_Midi.h"
+#endif
+#if defined(MEDIAINFO_MOD_YES)
+ #include "MediaInfo/Audio/File_Module.h"
+#endif
+#if defined(MEDIAINFO_MPC_YES)
+ #include "MediaInfo/Audio/File_Mpc.h"
+#endif
+#if defined(MEDIAINFO_MPCSV8_YES)
+ #include "MediaInfo/Audio/File_MpcSv8.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if defined(MEDIAINFO_PCM_YES)
+ #include "MediaInfo/Audio/File_Pcm.h"
+#endif
+#if defined(MEDIAINFO_RKAU_YES)
+ #include "MediaInfo/Audio/File_Rkau.h"
+#endif
+#if defined(MEDIAINFO_S3M_YES)
+ #include "MediaInfo/Audio/File_ScreamTracker3.h"
+#endif
+#if defined(MEDIAINFO_TAK_YES)
+ #include "MediaInfo/Audio/File_Tak.h"
+#endif
+#if defined(MEDIAINFO_TTA_YES)
+ #include "MediaInfo/Audio/File_Tta.h"
+#endif
+#if defined(MEDIAINFO_TWINVQ_YES)
+ #include "MediaInfo/Audio/File_TwinVQ.h"
+#endif
+#if defined(MEDIAINFO_WVPK_YES)
+ #include "MediaInfo/Audio/File_Wvpk.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Text
+#if defined(MEDIAINFO_N19_YES)
+ #include "MediaInfo/Text/File_N19.h"
+#endif
+#if defined(MEDIAINFO_OTHERTEXT_YES)
+ #include "MediaInfo/Text/File_OtherText.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Image
+#if defined(MEDIAINFO_BMP_YES)
+ #include "MediaInfo/Image/File_Bmp.h"
+#endif
+#if defined(MEDIAINFO_GIF_YES)
+ #include "MediaInfo/Image/File_Gif.h"
+#endif
+#if defined(MEDIAINFO_ICO_YES)
+ #include "MediaInfo/Image/File_Ico.h"
+#endif
+#if defined(MEDIAINFO_JPEG_YES)
+ #include "MediaInfo/Image/File_Jpeg.h"
+#endif
+#if defined(MEDIAINFO_PNG_YES)
+ #include "MediaInfo/Image/File_Png.h"
+#endif
+#if defined(MEDIAINFO_TIFF_YES)
+ #include "MediaInfo/Image/File_Tiff.h"
+#endif
+#if defined(MEDIAINFO_TIFF_YES)
+ #include "MediaInfo/Image/File_Tga.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Archive
+#if defined(MEDIAINFO_7Z_YES)
+ #include "MediaInfo/Archive/File_7z.h"
+#endif
+#if defined(MEDIAINFO_ACE_YES)
+ #include "MediaInfo/Archive/File_Ace.h"
+#endif
+#if defined(MEDIAINFO_BZIP2_YES)
+ #include "MediaInfo/Archive/File_Bzip2.h"
+#endif
+#if defined(MEDIAINFO_ELF_YES)
+ #include "MediaInfo/Archive/File_Elf.h"
+#endif
+#if defined(MEDIAINFO_GZIP_YES)
+ #include "MediaInfo/Archive/File_Gzip.h"
+#endif
+#if defined(MEDIAINFO_ISO9660_YES)
+ #include "MediaInfo/Archive/File_Iso9660.h"
+#endif
+#if defined(MEDIAINFO_MZ_YES)
+ #include "MediaInfo/Archive/File_Mz.h"
+#endif
+#if defined(MEDIAINFO_RAR_YES)
+ #include "MediaInfo/Archive/File_Rar.h"
+#endif
+#if defined(MEDIAINFO_TAR_YES)
+ #include "MediaInfo/Archive/File_Tar.h"
+#endif
+#if defined(MEDIAINFO_ZIP_YES)
+ #include "MediaInfo/Archive/File_Zip.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Other
+#if !defined(MEDIAINFO_OTHER_NO)
+ #include "MediaInfo/File_Other.h"
+#endif
+#include "MediaInfo/File_Unknown.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Out
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File__Analyze* File__MultipleParsing::Parser_Get()
+{
+ if (Parser.size()!=1)
+ return NULL;
+
+ File__Analyze* ToReturn=Parser[0]; //The first parser
+ Parser.clear();
+ return ToReturn;
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File__MultipleParsing::File__MultipleParsing()
+:File__Analyze()
+{
+ #if MEDIAINFO_TRACE
+ Trace_DoNotSave=true;
+ #endif //MEDIAINFO_TRACE
+
+ File__Analyze* Temp;
+ // Multiple
+ #if defined(MEDIAINFO_BDAV_YES)
+ Temp=new File_MpegTs(); ((File_MpegTs*)Temp)->BDAV_Size=4; Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_CDXA_YES)
+ Temp=new File_Cdxa(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_DCP_YES)
+ Temp=new File_Dcp(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_DPG_YES)
+ Temp=new File_Dpg(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_DVDIF_YES)
+ Temp=new File_DvDif(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_DVDV_YES)
+ Temp=new File_Dvdv(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_DXW_YES)
+ Temp=new File_Dxw(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_FLV_YES)
+ Temp=new File_Flv(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_GXF_YES)
+ Temp=new File_Gxf(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_HLS_YES)
+ Temp=new File_Hls(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_ISM_YES)
+ Temp=new File_Ism(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_IVF_YES)
+ Temp=new File_Ivf(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_LXF_YES)
+ Temp=new File_Lxf(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MK_YES)
+ Temp=new File_Mk(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MPEG4_YES)
+ Temp=new File_Mpeg4(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MPEGPS_YES)
+ Temp=new File_MpegPs(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MPEGTS_YES)
+ Temp=new File_MpegTs(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_TSP_YES)
+ Temp=new File_MpegTs(); ((File_MpegTs*)Temp)->TSP_Size=16; Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MXF_YES)
+ Temp=new File_Mxf(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_NUT_YES)
+ Temp=new File_Nut(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_OGG_YES)
+ Temp=new File_Ogg(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_P2_YES)
+ Temp=new File_P2_Clip(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_RIFF_YES)
+ Temp=new File_Riff(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_RM_YES)
+ Temp=new File_Rm(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_SEQUENCEINFO_YES)
+ Temp=new File_SequenceInfo(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_SKM_YES)
+ Temp=new File_Skm(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_SWF_YES)
+ Temp=new File_Swf(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_WM_YES)
+ Temp=new File_Wm(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_XDCAM_YES)
+ Temp=new File_Xdcam_Clip(); Parser.push_back(Temp);
+ #endif
+
+ // Video
+ #if defined(MEDIAINFO_AVC_YES)
+ Temp=new File_Avc(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_AVSV_YES)
+ Temp=new File_AvsV(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_DIRAC_YES)
+ Temp=new File_Dirac(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_FLIC_YES)
+ Temp=new File_Flic(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_H263_YES)
+ Temp=new File_H263(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ Temp=new File_Mpeg4v(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MPEGV_YES)
+ Temp=new File_Mpegv(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_VC1_YES)
+ Temp=new File_Vc1(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_Y4M_YES)
+ Temp=new File_Y4m(); Parser.push_back(Temp);
+ #endif
+
+ // Audio
+ #if defined(MEDIAINFO_AAC_YES)
+ Temp=new File_Aac(); ((File_Aac*)Temp)->Mode=File_Aac::Mode_ADIF; Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_AAC_YES)
+ Temp=new File_Aac(); ((File_Aac*)Temp)->Mode=File_Aac::Mode_ADTS; Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_AC3_YES)
+ Temp=new File_Ac3(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_AES3_YES)
+ Temp=new File_Aes3(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_ALS_YES)
+ Temp=new File_Als(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_AMR_YES)
+ Temp=new File_Amr(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_AMV_YES)
+ Temp=new File_Amv(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_APE_YES)
+ Temp=new File_Ape(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_AU_YES)
+ Temp=new File_Au(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_DTS_YES)
+ Temp=new File_Dts(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_FLAC_YES)
+ Temp=new File_Flac(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_IT_YES)
+ Temp=new File_ImpulseTracker(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_LA_YES)
+ Temp=new File_La(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MIDI_YES)
+ Temp=new File_Midi(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MOD_YES)
+ Temp=new File_Module(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MPC_YES)
+ Temp=new File_Mpc(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MPCSV8_YES)
+ Temp=new File_MpcSv8(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MPEGA_YES)
+ Temp=new File_Mpega(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_RKAU_YES)
+ Temp=new File_Rkau(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_S3M_YES)
+ Temp=new File_ScreamTracker3(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_TAK_YES)
+ Temp=new File_Tak(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_TTA_YES)
+ Temp=new File_Tta(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_TWINVQ_YES)
+ Temp=new File_TwinVQ(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_WVPK_YES)
+ Temp=new File_Wvpk(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_XM_YES)
+ Temp=new File_ExtendedModule(); Parser.push_back(Temp);
+ #endif
+
+ // Text
+ #if defined(MEDIAINFO_N19_YES)
+ Temp=new File_N19(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_OTHERTEXT_YES)
+ Temp=new File_OtherText(); Parser.push_back(Temp);
+ #endif
+
+ // Image
+ #if defined(MEDIAINFO_BMP_YES)
+ Temp=new File_Bmp(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_GIF_YES)
+ Temp=new File_Gif(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_ICO_YES)
+ Temp=new File_Ico(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_JPEG_YES)
+ Temp=new File_Jpeg(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_PNG_YES)
+ Temp=new File_Png(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_TIFF_YES)
+ Temp=new File_Tiff(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_TGA_YES)
+ Temp=new File_Tga(); Parser.push_back(Temp);
+ #endif
+
+ // Archive
+ #if defined(MEDIAINFO_7Z_YES)
+ Temp=new File_7z(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_ACE_YES)
+ Temp=new File_Ace(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_BZIP2_YES)
+ Temp=new File_Bzip2(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_ELF_YES)
+ Temp=new File_Elf(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_GZIP_YES)
+ Temp=new File_Gzip(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_ISO9660_YES)
+ Temp=new File_Iso9660(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_MZ_YES)
+ Temp=new File_Mz(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_RAR_YES)
+ Temp=new File_Rar(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_TAR_YES)
+ Temp=new File_Tar(); Parser.push_back(Temp);
+ #endif
+ #if defined(MEDIAINFO_ZIP_YES)
+ Temp=new File_Zip(); Parser.push_back(Temp);
+ #endif
+
+ #if defined(MEDIAINFO_OTHER_YES)
+ Temp=new File_Other(); Parser.push_back(Temp);
+ #endif
+}
+
+//---------------------------------------------------------------------------
+File__MultipleParsing::~File__MultipleParsing()
+{
+ for (size_t Pos=0; Pos<Parser.size(); Pos++)
+ delete Parser[Pos]; //Parser[Pos]=NULL
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__MultipleParsing::Streams_Finish()
+{
+ if (Parser.size()!=1)
+ return;
+
+ Parser[0]->Open_Buffer_Finalize();
+ #if MEDIAINFO_TRACE
+ Details=Parser[0]->Details;
+ #endif //MEDIAINFO_TRACE
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__MultipleParsing::Read_Buffer_Init()
+{
+ //Parsing
+ for (size_t Pos=0; Pos<Parser.size(); Pos++)
+ {
+ //Parsing
+ #if MEDIAINFO_TRACE
+ Parser[Pos]->Init(Config, Details, Stream, Stream_More);
+ #else //MEDIAINFO_TRACE
+ Parser[Pos]->Init(Config, Stream, Stream_More);
+ #endif //MEDIAINFO_TRACE
+ Parser[Pos]->File_Name=File_Name;
+ Parser[Pos]->Open_Buffer_Init(File_Size);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__MultipleParsing::Read_Buffer_Unsynched()
+{
+ //Parsing
+ for (size_t Pos=0; Pos<Parser.size(); Pos++)
+ Parser[Pos]->Open_Buffer_Unsynch();
+}
+
+//---------------------------------------------------------------------------
+void File__MultipleParsing::Read_Buffer_Continue()
+{
+ //Parsing
+ for (size_t Pos=0; Pos<Parser.size(); Pos++)
+ {
+ //Parsing
+ Parser[Pos]->Open_Buffer_Continue(Buffer+Buffer_Offset, (size_t)Element_Size);
+ if (File_Offset+Buffer_Size==File_Size)
+ Parser[Pos]->Open_Buffer_Finalize();
+
+ //Testing if the parser failed
+ if (Parser[Pos]->Status[IsFinished] && !Parser[Pos]->Status[IsAccepted])
+ {
+ delete Parser[Pos];
+ Parser.erase(Parser.begin()+Pos);
+ Pos--; //for the next position
+
+ if (Parser.empty())
+ {
+ File__Analyze* Temp=new File_Unknown(); Parser.push_back(Temp);
+ Read_Buffer_Init();
+ }
+ }
+ else
+ {
+ //If Parser is found, erasing all the other parsers
+ if (Parser.size()>1 && Parser[Pos]->Status[IsAccepted])
+ {
+ File__Analyze* Temp=Parser[Pos];
+ for (size_t To_Delete_Pos=0; To_Delete_Pos<Parser.size(); To_Delete_Pos++)
+ if (To_Delete_Pos!=Pos)
+ delete Parser[To_Delete_Pos]; //Parser[Pos]=NULL
+ Parser.clear();
+ Parser.push_back(Temp);
+ Pos=0;
+ }
+
+ if (Parser.size()==1)
+ {
+ //Status
+ if (!Status[IsAccepted] && Parser[Pos]->Status[IsAccepted])
+ Status[IsAccepted]=true;
+ if (!Status[IsFilled] && Parser[Pos]->Status[IsFilled])
+ Status[IsFilled]=true;
+ if (!Status[IsUpdated] && Parser[Pos]->Status[IsUpdated])
+ Status[IsUpdated]=true;
+ if (!Status[IsFinished] && Parser[Pos]->Status[IsFinished])
+ Status[IsFinished]=true;
+
+ //Positionning if requested
+ if (Parser[0]->File_GoTo!=(int64u)-1)
+ File_GoTo=Parser[0]->File_GoTo;
+ }
+ }
+ }
+}
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/File__MultipleParsing.h b/src/thirdparty/MediaInfo/MediaInfo/File__MultipleParsing.h
new file mode 100644
index 000000000..92fefd5ae
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/File__MultipleParsing.h
@@ -0,0 +1,66 @@
+// File_Mpeg - Info for MPEG files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MPEG files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_MpegH
+#define MediaInfo_MpegH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File__MultipleParsing
+//***************************************************************************
+
+class File__MultipleParsing : public File__Analyze
+{
+public :
+ //Out
+ File__Analyze* Parser_Get();
+
+ //Constructor
+ File__MultipleParsing();
+ ~File__MultipleParsing();
+
+private :
+ //Streams management
+ void Streams_Finish();
+
+ //Buffer - Global
+ void Read_Buffer_Init();
+ void Read_Buffer_Unsynched();
+ void Read_Buffer_Continue();
+
+ //Temp
+ std::vector<File__Analyze*> Parser;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Bmp.cpp b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Bmp.cpp
new file mode 100644
index 000000000..1026502fa
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Bmp.cpp
@@ -0,0 +1,223 @@
+// File_Bmp - Info for Bitmap files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// BMP - Format
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// From http://www.onicos.com/staff/iz/formats/bmp.html
+//
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_BMP_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Image/File_Bmp.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Bmp_CompressionMethod(int32u CompressionMethod)
+{
+ switch(CompressionMethod)
+ {
+ case 0 : return "RGB";
+ case 1 : return "RLE";
+ case 2 : return "RLE";
+ case 3 : return "Bit field";
+ case 4 : return "JPEG";
+ case 5 : return "PNG";
+ default: return "";
+ }
+}
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Bmp::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<2)
+ return false; //Must wait for more data
+
+ if (CC2(Buffer)!=0x424D) //"BM"
+ {
+ Reject("BMP");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Bmp::Read_Buffer_Continue()
+{
+ //Parsing
+ int32u Size, DIB_Size, Offset;
+ Element_Begin1("File header");
+ Skip_C2( "Magic");
+ Get_L4 (Size, "Size");
+ Skip_L2( "Reserved");
+ Skip_L2( "Reserved");
+ Get_L4 (Offset, "Offset of data");
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (Size!=File_Size)
+ {
+ Reject("BMP");
+ return;
+ }
+
+ Accept("BMP");
+
+ Fill(Stream_General, 0, General_Format, "Bitmap");
+
+ Stream_Prepare(Stream_Image);
+ FILLING_END();
+
+ Element_Begin1("DIB header");
+ Peek_L4 (DIB_Size);
+ switch (DIB_Size)
+ {
+ case 12 : Skip_XX(DIB_Size-4, "OS/2 v1 header"); break;
+ case 40 : BitmapInfoHeader(); break;
+ case 52 : Skip_XX(DIB_Size-4, "BitmapV2Header"); break;
+ case 56 : Skip_XX(DIB_Size-4, "BitmapV3Header"); break;
+ case 64 : Skip_XX(DIB_Size-4, "OS/2 v2 header"); break;
+ case 108 : BitmapV4Header(); break;
+ case 124 : Skip_XX(DIB_Size-4, "BitmapV5Header"); break;
+ default : Skip_XX(DIB_Size-4, "Unknown header");
+ ;
+ }
+ Element_End0();
+
+ Skip_XX(Offset-Element_Offset, "Color palette");
+ Skip_XX(Element_Size-Offset, "Bitmap data");
+
+ //No need of more
+ Finish("BMP");
+}
+
+//***************************************************************************
+// Buffer - Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Bmp::BitmapInfoHeader()
+{
+ //Parsing
+ Element_Begin1("Bitmap Info header");
+ int32u Width, Height, CompressionMethod;
+ int16u BitsPerPixel;
+ Skip_L4( "Size");
+ Get_L4 (Width, "Width");
+ Get_L4 (Height, "Height");
+ Skip_L2( "Color planes");
+ Get_L2 (BitsPerPixel, "Bits per pixel");
+ Get_L4 (CompressionMethod, "Compression method"); Param_Info1(Bmp_CompressionMethod(CompressionMethod));
+ Skip_L4( "Image size");
+ Skip_L4( "Horizontal resolution");
+ Skip_L4( "Vertical resolution");
+ Skip_L4( "Number of colors in the color palette");
+ Skip_L4( "Number of important colors used");
+ Element_End0();
+
+ FILLING_BEGIN();
+ Fill(Stream_Image, 0, Image_Width, Width);
+ Fill(Stream_Image, 0, Image_Height, Height);
+ Fill(Stream_Image, 0, Image_BitDepth, BitsPerPixel);
+ Fill(Stream_Image, 0, Image_Format, Bmp_CompressionMethod(CompressionMethod));
+ Fill(Stream_Image, 0, Image_Codec, Bmp_CompressionMethod(CompressionMethod));
+ FILLING_END();
+}
+
+
+void File_Bmp::BitmapV4Header()
+{
+ //Parsing
+ Element_Begin1("Bitmap V4 header");
+ int32u Width, Height, CompressionMethod;
+ int16u BitsPerPixel;
+ Skip_L4( "Size");
+ Get_L4 (Width, "Width");
+ Get_L4 (Height, "Height");
+ Skip_L2( "Color planes");
+ Get_L2 (BitsPerPixel, "Bits per pixel");
+ Get_L4 (CompressionMethod, "Compression method"); Param_Info1(Bmp_CompressionMethod(CompressionMethod));
+ Skip_L4( "Image size");
+ Skip_L4( "Horizontal resolution");
+ Skip_L4( "Vertical resolution");
+ Skip_L4( "Number of colors in the color palette");
+ Skip_L4( "Number of important colors used");
+ Skip_L4( "Red Channel bit mask");
+ Skip_L4( "Green Channel bit mask");
+ Skip_L4( "Blue Channel bit mask");
+ Skip_L4( "Alpha Channel bit mask");
+ Skip_L4( "Color Space endpoints");
+ Skip_L4( "Color Space endpoints");
+ Skip_L4( "Color Space endpoints");
+ Skip_L4( "Color Space endpoints");
+ Skip_L4( "Color Space endpoints");
+ Skip_L4( "Color Space endpoints");
+ Skip_L4( "Color Space endpoints");
+ Skip_L4( "Red Gamma");
+ Skip_L4( "Green Gamma");
+ Skip_L4( "Blue Gamma");
+ Element_End0();
+
+ FILLING_BEGIN();
+ Fill(Stream_Image, 0, Image_Width, Width);
+ Fill(Stream_Image, 0, Image_Height, Height);
+ Fill(Stream_Image, 0, Image_BitDepth, BitsPerPixel);
+ Fill(Stream_Image, 0, Image_Format, Bmp_CompressionMethod(CompressionMethod));
+ Fill(Stream_Image, 0, Image_Codec, Bmp_CompressionMethod(CompressionMethod));
+ FILLING_END();
+}
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Bmp.h b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Bmp.h
new file mode 100644
index 000000000..87345cd35
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Bmp.h
@@ -0,0 +1,57 @@
+// File_Bmp - Info for Bitmap files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Bitmap files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_BmpH
+#define MediaInfo_File_BmpH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Bmp
+//***************************************************************************
+
+class File_Bmp : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+
+ //Elements
+ void BitmapInfoHeader();
+ void BitmapV4Header();
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Dpx.cpp b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Dpx.cpp
new file mode 100644
index 000000000..a5dea4ac2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Dpx.cpp
@@ -0,0 +1,848 @@
+// File_Dpx - Info for DPX (SMPTE 268M) files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DPX_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Image/File_Dpx.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* DPX_Orientation[]=
+{
+ "Left to right, Top to bottom",
+ "Right to left, Top to bottom",
+ "Left to right, Bottom to top",
+ "Right to left, Bottom to top",
+ "Top to bottom, Left to right",
+ "Top to bottom, Right to left",
+ "Bottom to top, Left to right",
+ "Bottom to top, Right to left",
+ "Reserved for future use"
+};
+
+//---------------------------------------------------------------------------
+const char* DPX_Descriptors0[]=
+{
+ "User defined (or unspecified single component)",
+ "Red (R)",
+ "Green (G)",
+ "Blue (B)",
+ "Alpha (matte)",
+ "Luma (Y)",
+ "Color Difference (CB, CR, subsampled by two)",
+ "Depth (Z)",
+ "Composite video"
+};
+
+const char* DPX_Descriptors50[]=
+{
+ "R,G,B",
+ "R,G,B, Alpha (A)",
+ "A, B, G, R"
+};
+
+const char* DPX_Descriptors100[]=
+{
+ "CB, Y, CR, Y (4:2:2) ---- based on SMPTE 125M",
+ "CB, Y, A, CR, Y, A (4:2:2:4)",
+ "CB, Y, CR (4:4:4)",
+ "CB, Y, CR, A (4:4:4:4)"
+};
+
+const char* DPX_Descriptors150[]=
+{
+ "User-defined 2-component element",
+ "User-defined 3-component element",
+ "User-defined 4-component element",
+ "User-defined 5-component element",
+ "User-defined 6-component element",
+ "User-defined 7-component element",
+ "User-defined 8-component element"
+};
+
+const char* DPX_Descriptors(int8u i)
+{
+ if(i<10)
+ return DPX_Descriptors0[i];
+ if(i<50)
+ return "Reserved for future single components";
+ if(i<53)
+ return DPX_Descriptors50[i-50];
+ if(i<100)
+ return "Reserved for future RGB ++ formats";
+ if(i<104)
+ return DPX_Descriptors100[i-100];
+ if(i<150)
+ return "Reserved for future CBYCR ++ formats";
+ if(i<157)
+ return "Reserved for future single components";
+ return "Reserved for future formats";
+}
+
+//---------------------------------------------------------------------------
+const char* DPX_TransferCharacteristic[]=
+{
+ "User defined",
+ "Printing density",
+ "Linear",
+ "Logarithmic",
+ "Unspecified video",
+ "SMPTE 274M",
+ "ITU-R 709-4",
+ "ITU-R 601-5 system B or G (625)",
+ "ITU-R 601-5 system M (525)",
+ "Composite video (NTSC); see SMPTE 170M",
+ "Composite video (PAL); see ITU-R 624-4",
+ "Z (depth) - linear",
+ "Z (depth) - homogeneous", //(distance to screen and angle of view must also be specified in user-defined section)
+ "Reserved for future use"
+};
+
+//---------------------------------------------------------------------------
+const char* DPX_ColorimetricSpecification[]=
+{
+ "User defined",
+ "Printing density",
+ "Not applicable",
+ "Not applicable",
+ "Unspecified video",
+ "SMPTE 274M",
+ "ITU-R 709-4",
+ "ITU-R 601-5 system B or G (625)",
+ "ITU-R 601-5 system M (525)",
+ "Composite video (NTSC); see SMPTE 170M",
+ "Composite video (PAL); see ITU-R 624-4",
+ "Not applicable",
+ "Not applicable",
+ "Reserved for future use"
+};
+
+//---------------------------------------------------------------------------
+const char* DPX_ValidBitDephs(int8u i)
+{
+ switch(i)
+ {
+ case 1 :
+ case 8 :
+ case 10 :
+ case 12 :
+ case 16 :
+ return "integer";
+ case 32 :
+ return "IEEE floating point (R32)";
+ case 64 :
+ return "IEEE floating point (R64)";
+ default :
+ return "invalid";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* DPX_ComponentDataPackingMethod[]=
+{
+ "Packed into 32-bit words",
+ "Filled to 32-bit words, method A",
+ "Filled to 32-bit words, method B",
+ "Reserved for future use",
+ "Reserved for future use",
+ "Reserved for future use",
+ "Reserved for future use",
+ "Reserved for future use"
+};
+
+//---------------------------------------------------------------------------
+const char* DPX_ComponentDataEncodingMethod[]=
+{
+ "No encoding applied",
+ "Run-length encoded",
+ "Reserved for future use",
+ "Reserved for future use",
+ "Reserved for future use",
+ "Reserved for future use",
+ "Reserved for future use",
+ "Reserved for future use"
+};
+
+//---------------------------------------------------------------------------
+const char* DPX_VideoSignalStandard0[]=
+{
+ "Undefined",
+ "NTSC",
+ "PAL",
+ "PAL-M",
+ "SECAM"
+};
+
+const char* DPX_VideoSignalStandard50[]=
+{
+ "YCBCR ITU-R 601-5 525-line, 2:1 interlace, 4:3 aspect ratio",
+ "YCBCR ITU-R 601-5 625-line, 2:1 interlace, 4:3 aspect ratio"
+};
+
+const char* DPX_VideoSignalStandard100[]=
+{
+ "YCBCR ITU-R 601-5 525-line, 2:1 interlace, 16:9 aspect ratio",
+ "YCBCR ITU-R 601-5 625-line, 2:1 interlace, 16:9 aspect ratio"
+};
+
+const char* DPX_VideoSignalStandard150[]=
+{
+ "YCBCR 1050-line, 2:1 interlace, 16:9 aspect ratio",
+ "YCBCR 1125-line, 2:1 interlace, 16:9 aspect ratio (SMPTE 274M)",
+ "YCBCR 1250-line, 2:1 interlace, 16:9 aspect ratio",
+ "YCBCR 1125-line, 2:1 interlace, 16:9 aspect ratio (SMPTE 240M)"
+};
+
+const char* DPX_VideoSignalStandard200[]=
+{
+ "YCBCR 525-line, 1:1 progressive, 16:9 aspect ratio",
+ "YCBCR 625-line, 1:1 progressive, 16:9 aspect ratio",
+ "YCBCR 750-line, 1:1 progressive, 16:9 aspect ratio (SMPTE 296M)",
+ "YCBCR 1125-line, 1:1 progressive, 16:9 aspect ratio (SMPTE 274M)"
+};
+
+const char* DPX_VideoSignalStandard(int8u i)
+{
+ if(i<5)
+ return DPX_VideoSignalStandard0[i];
+ if(i<50)
+ return "Reserved for other composite video";
+ if(i<52)
+ return DPX_VideoSignalStandard50[i-50];
+ if(i<100)
+ return "Reserved for future component video";
+ if(i<102)
+ return DPX_VideoSignalStandard100[i-100];
+ if(i<150)
+ return "Reserved for future widescreen";
+ if(i<154)
+ return DPX_VideoSignalStandard150[i-150];
+ if(i<200)
+ return "Reserved for future high-definition interlace";
+ if(i<204)
+ return DPX_VideoSignalStandard200[i-200];
+ return "Reserved for future high-definition progressive";
+}
+
+//***************************************************************************
+// Const
+//***************************************************************************
+
+enum Elements
+{
+ Pos_GenericSection,
+ Pos_IndustrySpecific,
+ Pos_UserDefined,
+ Pos_Padding,
+ Pos_ImageData,
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Dpx::File_Dpx()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("DPX");
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dpx::Streams_Accept()
+{
+ Fill(Stream_General, 0, General_Format, "DPX");
+ Fill(Stream_General, 0, General_Format_Version, Version==1?"Version 1":"Version 2");
+
+ if (!IsSub)
+ {
+ Streams_Accept_TestContinuousFileNames();
+
+ Stream_Prepare((Config->File_Names.size()>1 || Config->File_IsReferenced_Get())?Stream_Video:Stream_Image);
+ Fill(StreamKind_Last, StreamPos_Last, "StreamSize", File_Size);
+ if (StreamKind_Last==Stream_Video)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameCount, Config->File_Names.size());
+ }
+ else
+ Stream_Prepare(Stream_Image);
+
+ //Configuration
+ Buffer_MaximumSize=64*1024*1024;
+ Frame_Count_NotParsedIncluded=0;
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Dpx::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ int32u Magic=CC4(Buffer);
+ switch (Magic)
+ {
+ case 0x802A5FD7 : // (v1 Big)
+ case 0xD75F2A80 : // (v1 Little)
+ case 0x53445058 : //"SPDX" (v2 Big)
+ case 0x58504453 : //"XDPS" (v2 Little)
+ break;
+ default :
+ Reject();
+ return false;
+ }
+
+ //Generic Section size
+ if (Buffer_Size<28)
+ return false; //Must wait for more data
+ Sizes_Pos=Pos_GenericSection;
+ switch (Magic)
+ {
+ case 0x802A5FD7 : // (v1 Big)
+ case 0xD75F2A80 : // (v1 Little)
+ Version=1;
+ break;
+ case 0x58504453 : //"XDPS" (v2 Little)
+ case 0x53445058 : //"SPDX" (v2 Big)
+ Version=2;
+ break;
+ default : ;
+ }
+ switch (Magic)
+ {
+ case 0xD75F2A80 : // (v1 Little)
+ case 0x58504453 : //"XDPS" (v2 Little)
+ LittleEndian=true;
+ break;
+ case 0x802A5FD7 : // (v1 Big)
+ case 0x53445058 : //"SPDX" (v2 Big)
+ LittleEndian=false;
+ break;
+ default : ;
+ }
+
+ //All should be OK...
+ Accept();
+
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dpx::Header_Parse()
+{
+ //Filling
+ Header_Fill_Code(Sizes_Pos); //We use Sizes_Pos as the unique key
+ if (Sizes.empty())
+ {
+ if (Element_Size<28)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ int32u Size=LittleEndian?LittleEndian2int32u(Buffer+Buffer_Offset+24):BigEndian2int32u(Buffer+Buffer_Offset+24);
+ if (Size==(int32u)-1)
+ Size=LittleEndian?LittleEndian2int32u(Buffer+Buffer_Offset+4):BigEndian2int32u(Buffer+Buffer_Offset+4);
+ Header_Fill_Size(Size);
+ }
+ else
+ Header_Fill_Size(Sizes[Sizes_Pos]);
+}
+
+//---------------------------------------------------------------------------
+void File_Dpx::Data_Parse()
+{
+ if (Version==1)
+ {
+ switch (Element_Code)
+ {
+ case Pos_GenericSection : GenericSectionHeader_v1(); break;
+ case Pos_IndustrySpecific : IndustrySpecificHeader_v1(); break;
+ case Pos_UserDefined : UserDefinedHeader_v1(); break;
+ case Pos_Padding : Padding(); break;
+ case Pos_ImageData : ImageData(); break;
+ default : ;
+ }
+ }
+ else
+ {
+ switch (Element_Code)
+ {
+ case Pos_GenericSection : GenericSectionHeader_v2(); break;
+ case Pos_IndustrySpecific : IndustrySpecificHeader_v2(); break;
+ case Pos_UserDefined : UserDefinedHeader_v2(); break;
+ case Pos_Padding : Padding(); break;
+ case Pos_ImageData : ImageData(); break;
+ default : ;
+ }
+ }
+
+ do
+ Sizes_Pos++; //We go automaticly to the next block
+ while (Sizes_Pos<Sizes.size() && Sizes[Sizes_Pos]==0);
+ if (Sizes_Pos==Sizes.size())
+ {
+ Sizes.clear();
+ Sizes_Pos=0;
+
+ if (!Status[IsFilled])
+ Fill();
+ if (Config_ParseSpeed<1.0)
+ Finish();
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dpx::GenericSectionHeader_v1()
+{
+ Element_Name("Generic section header");
+
+ //Parsing
+ Element_Begin1("File information");
+ Ztring CreationDate, CreationTime;
+ int32u Size_Header, Size_Total, Size_Generic, Size_Industry, Size_User;
+ Skip_B4( "Magic number");
+ Get_X4 (Size_Header, "Offset to image data");
+ Get_X4 (Size_Generic, "Generic section header length");
+ Get_X4 (Size_Industry, "Industry specific header length");
+ Get_X4 (Size_User, "User-defined header length");
+ Get_X4 (Size_Total, "Total image file size");
+ Skip_String(8, "Version number of header format");
+ Skip_UTF8 (100, "FileName");
+ Get_UTF8 (12, CreationDate, "Creation Date");
+ Get_UTF8 (12, CreationTime, "Creation Time");
+ Skip_XX(36, "Reserved for future use");
+ Element_End0();
+
+ Element_Begin1("Image information");
+ int8u ImageElements;
+ Info_B1(ImageOrientation, "Image orientation"); Param_Info1(DPX_Orientation[ImageOrientation>8?8:ImageOrientation]);
+ Get_B1 (ImageElements, "Number of image elements");
+ Skip_B2( "Unused");
+ if (ImageElements>8)
+ ImageElements=8;
+ for(int8u ImageElement=0; ImageElement<ImageElements; ImageElement++)
+ GenericSectionHeader_v1_ImageElement();
+ if (ImageElements!=8)
+ Skip_XX((8-ImageElements)*28, "Padding");
+ Skip_BFP4(9, "White point - x");
+ Skip_BFP4(9, "White point - y");
+ Skip_BFP4(9, "Red primary chromaticity - x");
+ Skip_BFP4(9, "Red primary chromaticity - u");
+ Skip_BFP4(9, "Green primary chromaticity - x");
+ Skip_BFP4(9, "Green primary chromaticity - y");
+ Skip_BFP4(9, "Blue primary chromaticity - x");
+ Skip_BFP4(9, "Blue primary chromaticity - y");
+ Skip_UTF8(200, "Label text");
+ Skip_XX(28, "Reserved for future use");
+ Element_End0();
+
+ Element_Begin1("Image Data Format Information");
+ Skip_B1( "Data interleave");
+ Skip_B1( "Packing");
+ Skip_B1( "Data signed or unsigned");
+ Skip_B1( "Image sense");
+ Skip_B4( "End of line padding");
+ Skip_B4( "End of channel padding");
+ Skip_XX(20, "Reserved for future use");
+
+ Element_Begin1("Image Origination Information");
+ Skip_B4( "X offset");
+ Skip_B4( "Y offset");
+ Skip_UTF8 (100, "FileName");
+ Get_UTF8 (12, CreationDate, "Creation Date");
+ Get_UTF8 (12, CreationTime, "Creation Time");
+ Skip_UTF8(64, "Input device");
+ Skip_UTF8(32, "Input device model number");
+ Skip_UTF8(32, "Input device serial number");
+ Skip_BFP4(9, "X input device pitch");
+ Skip_BFP4(9, "Y input device pitch");
+ Skip_BFP4(9, "Image gamma of capture device");
+ Skip_XX(40, "Reserved for future use");
+ Element_End0();
+
+ FILLING_BEGIN();
+ //Coherency tests
+ if (Size_Generic+Size_Industry+Size_User>Size_Header || Size_Header>Size_Total)
+ {
+ Reject();
+ return;
+ }
+
+ //Filling sizes
+ Sizes.push_back(Size_Header);
+ Sizes.push_back(Size_Industry);
+ Sizes.push_back(Size_User);
+ Sizes.push_back(Size_Header-(Size_Generic+Size_Industry+Size_User)); //Size of padding
+ Sizes.push_back(Size_Total-Size_Header); //Size of image
+
+ //Filling meta
+ if (Frame_Count==0)
+ {
+ Fill(Stream_General, 0, General_Encoded_Date, CreationDate+_T(' ')+CreationTime); //ToDo: transform it in UTC
+ Fill(StreamKind_Last, StreamPos_Last, "Encoded_Date", CreationDate+_T(' ')+CreationTime); //ToDo: transform it in UTC
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dpx::GenericSectionHeader_v1_ImageElement()
+{
+ Element_Begin1("image element");
+ int32u Width, Height;
+ Skip_B1( "Designator - Byte 0");
+ Skip_B1( "Designator - Byte 1");
+ Skip_B1( "Bits per pixel");
+ Skip_B1( "Unused");
+ Get_X4 (Width, "Pixels per line");
+ Get_X4 (Height, "Lines per image element");
+ Skip_BFP4(9, "Minimum data value");
+ Skip_BFP4(9, "Minimum quantity represented");
+ Skip_BFP4(9, "Maximum data value");
+ Skip_BFP4(9, "Maximum quantity represented");
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (Frame_Count==0)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, "Format", "DPX");
+ Fill(StreamKind_Last, StreamPos_Last, "Format_Version", "Version 1");
+ Fill(StreamKind_Last, StreamPos_Last, "Width", Width);
+ Fill(StreamKind_Last, StreamPos_Last, "Height", Height);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dpx::GenericSectionHeader_v2()
+{
+ Element_Name("Generic section header");
+
+ //Parsing
+ Element_Begin1("File information");
+ std::string CreationDate, Creator, Project, Copyright;
+ int32u Size_Header, Size_Total, Size_Generic, Size_Industry, Size_User;
+ Skip_String(4, "Magic number");
+ Get_X4 (Size_Header, "Offset to image data");
+ Skip_String(8, "Version number of header format");
+ Get_X4 (Size_Total, "Total image file size");
+ Skip_B4( "Ditto Key");
+ Get_X4 (Size_Generic, "Generic section header length");
+ Get_X4 (Size_Industry, "Industry specific header length");
+ Get_X4 (Size_User, "User-defined header length");
+ Skip_UTF8 (100, "FileName");
+ Get_String (24, CreationDate, "Creation Date");
+ Get_String (100, Creator, "Creator");
+ Get_String (200, Project, "Project");
+ Get_String (200, Copyright, "Right to use or copyright statement");
+ Skip_B4( "Encryption key");
+ Skip_XX(104, "Reserved for future use");
+ Element_End0();
+
+ Element_Begin1("Image information");
+ int32u Width, Height, PAR_H, PAR_V;
+ int16u ImageElements;
+ Info_B2(ImageOrientation, "Image orientation");Param_Info1(DPX_Orientation[ImageOrientation]);
+ Get_X2 (ImageElements, "Number of image elements");
+ if (ImageElements>8)
+ ImageElements=8;
+ Get_X4 (Width, "Pixels per line");
+ Get_X4 (Height, "Lines per image element");
+ for(int16u ImageElement=0; ImageElement<ImageElements; ImageElement++)
+ GenericSectionHeader_v2_ImageElement();
+ if (ImageElements!=8)
+ Skip_XX((8-ImageElements)*72, "Padding");
+ Skip_XX(52, "Reserved for future use");
+ Element_End0();
+
+ Element_Begin1("Image source information");
+ Skip_B4( "X Offset");
+ Skip_B4( "Y Offset");
+ Skip_BFP4(9, "X center");
+ Skip_BFP4(9, "Y center");
+ Skip_B4( "X original size");
+ Skip_B4( "Y original size");
+ Skip_UTF8(100, "Source image filename");
+ Skip_UTF8(24, "Source image date/time");
+ Skip_UTF8(32, "Input device name");
+ Skip_UTF8(32, "Input device serial number");
+ Element_Begin1("Border validity");
+ Skip_B2( "XL border");
+ Skip_B2( "XR border");
+ Skip_B2( "YT border");
+ Skip_B2( "YB border");
+ Element_End0();
+ Get_X4 (PAR_H, "Pixel ratio : horizontal");
+ Get_X4 (PAR_V, "Pixel ratio : vertical");
+
+ Element_Begin1("Additional source image information");
+ Skip_BFP4(9, "X scanned size");
+ Skip_BFP4(9, "Y scanned size");
+ Skip_XX(20, "Reserved for future use");
+ Element_End0();
+
+ FILLING_BEGIN();
+ //Coherency tests
+ if (Size_Generic==(int32u)-1)
+ Size_Generic=Element_Size;
+ if (Size_Industry==(int32u)-1)
+ Size_Industry=0;
+ if (Size_User==(int32u)-1)
+ Size_User=0;
+ if (Size_Generic+Size_Industry+Size_User>Size_Header || Size_Header>Size_Total)
+ {
+ Reject();
+ return;
+ }
+
+ //Filling sizes
+ Sizes.push_back(Size_Header);
+ Sizes.push_back(Size_Industry);
+ Sizes.push_back(Size_User);
+ Sizes.push_back(Size_Header-(Size_Generic+Size_Industry+Size_User)); //Size of padding
+ Sizes.push_back(Size_Total-Size_Header); //Size of image
+
+ //Filling meta
+ if (Frame_Count==0)
+ {
+ Fill(Stream_General, 0, General_Encoded_Date, CreationDate); //ToDo: transform it in UTC
+ Fill(StreamKind_Last, StreamPos_Last, "Encoded_Date", CreationDate); //ToDo: transform it in UTC
+ Fill(Stream_General, 0, General_Encoded_Library, Creator);
+ Fill(StreamKind_Last, StreamPos_Last, "Encoded_Library", Creator);
+ Fill(Stream_General, 0, "Project", Project); //ToDo: map to a MediaInfo field (which one?)
+ Fill(Stream_General, 0, General_Copyright, Copyright);
+
+ Fill(StreamKind_Last, StreamPos_Last, "Width", Width);
+ Fill(StreamKind_Last, StreamPos_Last, "Height", Height);
+ if (PAR_V && PAR_H!=(int32u)-1 && PAR_V!=(int32u)-1)
+ Fill(StreamKind_Last, StreamPos_Last, "PixelAspectRatio", ((float)PAR_H)/PAR_V);
+ else
+ Fill(StreamKind_Last, StreamPos_Last, "PixelAspectRatio", (float)1, 3);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dpx::GenericSectionHeader_v2_ImageElement()
+{
+ Element_Begin1("image element");
+ int8u BitDephs;
+ Info_B4(DataSign, "Data sign");Param_Info1((DataSign==0?"unsigned":"signed"));
+ Skip_B4( "Reference low data code value");
+ Skip_BFP4(9, "Reference low quantity represented");
+ Skip_B4( "Reference high data code value");
+ Skip_BFP4(9, "Reference high quantity represented");
+ Info_B1(Descriptor, "Descriptor");Param_Info1(DPX_Descriptors(Descriptor));
+ Info_B1(TransferCharacteristic, "Transfer characteristic");Param_Info1(DPX_TransferCharacteristic[TransferCharacteristic]);
+ Info_B1(ColorimetricSpecification, "Colorimetric specification");Param_Info1(DPX_ColorimetricSpecification[ColorimetricSpecification]);
+ Get_B1 (BitDephs, "Bit depth");Param_Info1(DPX_ValidBitDephs(BitDephs));
+ Info_B2(ComponentDataPackingMethod, "Packing");Param_Info1((ComponentDataPackingMethod<8?DPX_ComponentDataPackingMethod[ComponentDataPackingMethod]:"invalid"));
+ Info_B2(ComponentDataEncodingMethod, "Encoding");Param_Info1((ComponentDataEncodingMethod<8?DPX_ComponentDataEncodingMethod[ComponentDataEncodingMethod]:"invalid"));
+ Skip_B4( "Offset to data");
+ Skip_B4( "End-of-line padding");
+ Skip_B4( "End-of-image padding");
+ Skip_UTF8(32, "Description of image element");
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (Frame_Count==0)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, "Format", "DPX");
+ Fill(StreamKind_Last, StreamPos_Last, "Format_Version", "Version 2");
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", BitDephs);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dpx::IndustrySpecificHeader_v1()
+{
+ Element_Name("Motion picture industry specific header");
+
+ //Parsing
+ Element_Begin1("Motion-picture film information");
+ Skip_B1( "?");
+ Skip_B1( "?");
+ Skip_B1( "?");
+ Skip_B1( "?");
+ Skip_B4( "?");
+ Skip_B4( "?");
+ Skip_UTF8(32, "?");
+ Skip_B4( "?");
+ Skip_B4( "?");
+ Skip_UTF8(32, "?");
+ Skip_UTF8(200, "?");
+ Skip_XX(740, "Reserved for future use");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Dpx::IndustrySpecificHeader_v2()
+{
+ Element_Name("Industry specific header");
+
+ //Parsing
+ Element_Begin1("Motion-picture film information");
+ Skip_String(2, "Film mfg. ID code");
+ Skip_String(2, "Film type");
+ Skip_String(2, "Offset in perfs");
+ Skip_String(6, "Prefix");
+ Skip_String(4, "Count");
+ Skip_String(32, "Format - e.g. Academy");
+ Skip_B4( "Frame position in sequence");
+ Skip_B4( "Sequence length (frames)");
+ Skip_B4( "Held count (1 = default)");
+ Skip_BFP4(9, "Frame rate of original (frames/s)");
+ Skip_BFP4(9, "Shutter angle of camera in degrees");
+ Skip_UTF8(32, "Frame identification - e.g. keyframe");
+ Skip_UTF8(100, "Slate information");
+ Skip_XX(56, "Reserved for future use");
+ Element_End0();
+
+ Element_Begin1("Television information");
+ Skip_B4( "SMPTE time code");
+ Skip_B4( "SMPTE user bits");
+ Info_B1(Interlace, "Interlace");Param_Info1((Interlace==0?"noninterlaced":"2:1 interlace"));
+ Skip_B1( "Field number");
+ Info_B1(VideoSignalStandard, "Video signal standard");Param_Info1(DPX_VideoSignalStandard(VideoSignalStandard));
+ Skip_B1( "Zero");
+ Skip_BFP4(9, "Horizontal sampling rate (Hz)");
+ Skip_BFP4(9, "Vertical sampling rate (Hz)");
+ Skip_BFP4(9, "Temporal sampling rate or frame rate (Hz)");
+ Skip_BFP4(9, "Time offset from sync to first pixel (ms)");
+ Skip_BFP4(9, "Gamma");
+ Skip_BFP4(9, "Black level code value");
+ Skip_BFP4(9, "Black gain");
+ Skip_BFP4(9, "Breakpoint");
+ Skip_BFP4(9, "Reference white level code value");
+ Skip_BFP4(9, "Integration time (s)");
+ Skip_XX(76, "Reserved for future use");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Dpx::UserDefinedHeader_v1()
+{
+ Element_Name("User defined header");
+
+ //Parsing
+ Skip_XX(Sizes[Pos_UserDefined], "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Dpx::UserDefinedHeader_v2()
+{
+ Element_Name("User defined header");
+
+ //Parsing
+ if (Sizes[Pos_UserDefined]<32)
+ {
+ //Not in spec
+ Skip_XX(Sizes[Pos_UserDefined], "Unknown");
+ return;
+ }
+ Skip_UTF8(32, "User identification");
+ Skip_XX(Sizes[Pos_UserDefined]-32, "User defined");
+}
+
+//---------------------------------------------------------------------------
+void File_Dpx::Padding()
+{
+ Element_Name("Padding");
+
+ //Parsing
+ Skip_XX(Sizes[Pos_Padding], "Padding");
+}
+
+//---------------------------------------------------------------------------
+void File_Dpx::ImageData()
+{
+ Element_Name("Image Data");
+
+ //Parsing
+ Skip_XX(Sizes[Pos_ImageData], "Data");
+
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dpx::Get_X2(int16u &Info, const char* Name)
+{
+ if (LittleEndian)
+ Get_L2 (Info, Name);
+ else
+ Get_B2 (Info, Name);
+}
+
+//---------------------------------------------------------------------------
+void File_Dpx::Get_X4(int32u &Info, const char* Name)
+{
+ if (LittleEndian)
+ Get_L4 (Info, Name);
+ else
+ Get_B4 (Info, Name);
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_DPX_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Dpx.h b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Dpx.h
new file mode 100644
index 000000000..23a865cad
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Dpx.h
@@ -0,0 +1,94 @@
+// File_Dpx - Info for DPX (SMPTE 268M) files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about DPX files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_DpxH
+#define MediaInfo_File_DpxH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Dpx
+//***************************************************************************
+
+class File_Dpx : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Dpx();
+
+private :
+ //Streams management
+ void Streams_Accept();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test() {return Demux_UnpacketizeContainer_Test_OneFramePerFile();}
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched() {Read_Buffer_Unsynched_OneFramePerFile();}
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) {return Read_Buffer_Seek_OneFramePerFile(Method, Value, ID);}
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void GenericSectionHeader_v1();
+ void GenericSectionHeader_v2();
+ void GenericSectionHeader_v1_ImageElement();
+ void GenericSectionHeader_v2_ImageElement();
+ void IndustrySpecificHeader_v1();
+ void IndustrySpecificHeader_v2();
+ void UserDefinedHeader_v1();
+ void UserDefinedHeader_v2();
+ void Padding();
+ void ImageData();
+
+ //Temp
+ std::vector<int32u> Sizes;
+ size_t Sizes_Pos;
+ int8u Version;
+ bool LittleEndian;
+
+ //Helpers
+ void Get_X2 (int16u &Info, const char* Name);
+ void Get_X4 (int32u &Info, const char* Name);
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Exr.cpp b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Exr.cpp
new file mode 100644
index 000000000..2df2b2af2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Exr.cpp
@@ -0,0 +1,350 @@
+// File_Exr - Info for EXR files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_EXR_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Image/File_Exr.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//***************************************************************************
+// Const
+//***************************************************************************
+
+enum Elements
+{
+ Pos_FileInformation,
+ Pos_GenericSection,
+ Pos_IndustrySpecific,
+ Pos_UserDefined,
+ Pos_Padding,
+ Pos_ImageData,
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Exr::File_Exr()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("EXR");
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Exr::Streams_Accept()
+{
+ Fill(Stream_General, 0, General_Format, "EXR");
+
+ if (!IsSub)
+ {
+ Streams_Accept_TestContinuousFileNames();
+
+ Stream_Prepare((Config->File_Names.size()>1 || Config->File_IsReferenced_Get())?Stream_Video:Stream_Image);
+ Fill(StreamKind_Last, StreamPos_Last, "StreamSize", File_Size);
+ if (StreamKind_Last==Stream_Video)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameCount, Config->File_Names.size());
+ }
+ else
+ Stream_Prepare(Stream_Image);
+
+ //Configuration
+ Buffer_MaximumSize=64*1024*1024;
+ Frame_Count_NotParsedIncluded=0;
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Exr::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ if (CC4(Buffer)!=0x762F3101) //"v/1"+1
+ {
+ Reject();
+ return false;
+ }
+
+ //All should be OK...
+ Accept();
+
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Exr::Header_Begin()
+{
+ //Header
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ if (CC4(Buffer+Buffer_Offset)==0x762F3101) //"v/1"+1
+ return Buffer_Offset+12<=Buffer_Size;
+
+ //Name
+ name_End=0;
+ while (Buffer_Offset+name_End<Buffer_Size)
+ {
+ if (Buffer[Buffer_Offset+name_End]=='\0')
+ break;
+ if (name_End==31)
+ break;
+ name_End++;
+ }
+ if (Buffer_Offset+name_End>=Buffer_Size)
+ return false;
+ if (name_End>=31)
+ {
+ Reject();
+ return false;
+ }
+ if (name_End==0)
+ return true;
+
+ //Type
+ type_End=0;
+ while (Buffer_Offset+name_End+1+type_End<Buffer_Size)
+ {
+ if (Buffer[Buffer_Offset+name_End+1+type_End]=='\0')
+ break;
+ if (type_End==31)
+ break;
+ type_End++;
+ }
+
+ if (Buffer_Offset+name_End+1+type_End>=Buffer_Size)
+ return false;
+ if (type_End>=31)
+ {
+ Reject();
+ return false;
+ }
+
+ if (Buffer_Offset+name_End+1+type_End+1+4>=Buffer_Size)
+ return false;
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Exr::Header_Parse()
+{
+ //Header
+ if (CC4(Buffer+Buffer_Offset)==0x762F3101) //"v/1"+1
+ {
+ //Filling
+ Header_Fill_Code(0, "File header");
+ Header_Fill_Size(12);
+ return;
+ }
+
+ //Image data
+ if (name_End==0)
+ {
+ //Filling
+ Header_Fill_Code(0, "Image data");
+ Header_Fill_Size(ImageData_End-(File_Offset+Buffer_Offset));
+ return;
+ }
+
+ int32u size;
+ Get_String(name_End, name, "name");
+ Element_Offset++; //Null byte
+ Get_String(type_End, type, "type");
+ Element_Offset++; //Null byte
+ Get_L4 (size, "size");
+
+ //Filling
+ Header_Fill_Code(0, Ztring().From_Local(name.c_str()));
+ Header_Fill_Size(name_End+1+type_End+1+4+size);
+}
+
+//---------------------------------------------------------------------------
+void File_Exr::Data_Parse()
+{
+
+ if (CC4(Buffer+Buffer_Offset)==0x762F3101) //"v/1"+1 //Header
+ Header();
+ else if (name=="comments" && type=="string")
+ comments();
+ else if (name=="compression" && type=="compression" && Element_Size==1)
+ compression();
+ else if (name=="dataWindow" && type=="box2i" && Element_Size==16)
+ dataWindow();
+ else if (name=="displayWindow" && type=="box2i" && Element_Size==16)
+ displayWindow();
+ else if (name=="pixelAspectRatio" && type=="float" && Element_Size==4)
+ pixelAspectRatio();
+ else
+ Skip_XX(Element_Size, "value");
+}
+
+//---------------------------------------------------------------------------
+void File_Exr::Header()
+{
+ //Parsing
+ int32u Flags;
+ int8u Version;
+ Skip_L4( "Magic number");
+ Get_L1 (Version, "Version field");
+ Get_L3 (Flags, "Flags");
+
+ //Filling
+ if (Frame_Count==0)
+ {
+ Fill(Stream_General, 0, General_Format_Version, _T("Version ")+Ztring::ToZtring(Version));
+ Fill(StreamKind_Last, 0, "Format", "EXR");
+ Fill(StreamKind_Last, 0, "Format_Version", _T("Version ")+Ztring::ToZtring(Version));
+ Fill(StreamKind_Last, 0, "Format_Profile", (Flags&0x02)?"Tile":"Line");
+ }
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ ImageData_End=File_Offset+Buffer_Offset+Config->File_Sizes[Config->File_Names_Pos-1];
+}
+
+//---------------------------------------------------------------------------
+void File_Exr::ImageData()
+{
+ Skip_XX(Element_Size, "data");
+
+ if (!Status[IsFilled])
+ Fill();
+ if (Config_ParseSpeed<1.0)
+ Finish();
+}
+
+//---------------------------------------------------------------------------
+void File_Exr::comments ()
+{
+ //Parsing
+ Ztring value;
+ Get_Local(Element_Size, value, "value");
+
+ //Filling
+ if (Frame_Count==1)
+ Fill(StreamKind_Last, 0, General_Comment, value);
+}
+
+//---------------------------------------------------------------------------
+void File_Exr::compression ()
+{
+ //Parsing
+ int8u value;
+ Get_L1 (value, "value");
+
+ //Filling
+ std::string Compression;
+ switch (value)
+ {
+ case 0x00 : Compression="raw"; break;
+ case 0x01 : Compression="RLZ"; break;
+ case 0x02 : Compression="ZIPS"; break;
+ case 0x03 : Compression="ZIP"; break;
+ case 0x04 : Compression="PIZ"; break;
+ case 0x05 : Compression="PXR24"; break;
+ case 0x06 : Compression="B44"; break;
+ case 0x07 : Compression="B44A"; break;
+ default : ;
+ }
+
+ if (Frame_Count==1)
+ Fill(StreamKind_Last, 0, "Format_Compression", Compression.c_str());
+}
+
+//---------------------------------------------------------------------------
+void File_Exr::dataWindow ()
+{
+ //Parsing
+ int32u xMin, yMin, xMax, yMax;
+ Get_L4 (xMin, "xMin");
+ Get_L4 (yMin, "yMin");
+ Get_L4 (xMax, "xMax");
+ Get_L4 (yMax, "yMax");
+}
+
+//---------------------------------------------------------------------------
+void File_Exr::displayWindow ()
+{
+ //Parsing
+ int32u xMin, yMin, xMax, yMax;
+ Get_L4 (xMin, "xMin");
+ Get_L4 (yMin, "yMin");
+ Get_L4 (xMax, "xMax");
+ Get_L4 (yMax, "yMax");
+
+ //Filling
+ if (Frame_Count==1)
+ {
+ Fill(StreamKind_Last, 0, "Width", xMax-xMin+1);
+ Fill(StreamKind_Last, 0, "Height", yMax-yMin+1);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Exr::pixelAspectRatio ()
+{
+ //Parsing
+ float value;
+ Get_LF4(value, "value");
+
+ //Filling
+ if (Frame_Count==1)
+ Fill(StreamKind_Last, 0, "PixelAspectRatio", value?value:1, 3);
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_EXR_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Exr.h b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Exr.h
new file mode 100644
index 000000000..c2a36dc0a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Exr.h
@@ -0,0 +1,89 @@
+// File_Exr - Info for EXR files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about EXR files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_ExrH
+#define MediaInfo_File_ExrH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Exr
+//***************************************************************************
+
+class File_Exr : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Exr();
+
+private :
+ //Streams management
+ void Streams_Accept();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test() {return Demux_UnpacketizeContainer_Test_OneFramePerFile();}
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched() {Read_Buffer_Unsynched_OneFramePerFile();}
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) {return Read_Buffer_Seek_OneFramePerFile(Method, Value, ID);}
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - Per element
+ bool Header_Begin();
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Header();
+ void ImageData();
+ void comments();
+ void compression();
+ void dataWindow();
+ void displayWindow();
+ void pixelAspectRatio();
+
+ //Temp
+ std::string name;
+ std::string type;
+ size_t name_End;
+ size_t type_End;
+ int64u ImageData_End;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Gif.cpp b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Gif.cpp
new file mode 100644
index 000000000..33d523be8
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Gif.cpp
@@ -0,0 +1,114 @@
+// File_Gif - Info for GIF files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// From http://www.onicos.com/staff/iz/formats/gif.html
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_GIF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Image/File_Gif.h"
+#include <cmath>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Gif::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<3)
+ return false; //Must wait for more data
+
+ if (CC3(Buffer)!=0x474946) //"GIF"
+ {
+ Reject("GIF");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Gif::Read_Buffer_Continue()
+{
+ //Parsing
+ Ztring Version;
+ int16u Width, Height;
+ int8u BackgroundColorIndex, PixelAspectRatio, Resolution, GCT_Size;
+ bool GCT_Flag, Sort;
+ Skip_Local(3, "Header");
+ Get_Local (3, Version, "Version");
+ Get_L2 (Width, "Logical Screen Width");
+ Get_L2 (Height, "Logical Screen Height");
+ BS_Begin();
+ Get_SB ( GCT_Flag, "Global Color Table Flag");
+ Get_S1 (3, Resolution, "Color Resolution");
+ Get_SB ( Sort, "Sort Flag to Global Color Table");
+ Get_S1 (3, GCT_Size, "Size of Global Color Table"); Param_Info1(Ztring::ToZtring((int16u)pow(2.0, 1+GCT_Size)));
+ BS_End();
+ Get_L1 (BackgroundColorIndex, "Background Color Index");
+ Get_L1 (PixelAspectRatio, "Pixel Aspect Ratio");
+ if (GCT_Flag)
+ Skip_XX((int16u)pow(2.0, 1+GCT_Size)*3, "Global Color Table");
+ Element_End0();
+
+ FILLING_BEGIN();
+ Accept("GIF");
+
+ Stream_Prepare(Stream_Image);
+ Fill(Stream_Image, 0, Image_Width, Width);
+ Fill(Stream_Image, 0, Image_Height, Height);
+ Fill(Stream_Image, 0, Image_Format, _T("GIF"));
+ Fill(Stream_Image, 0, Image_Format_Profile, Version);
+ Fill(Stream_Image, 0, Image_Codec, _T("GIF")+Version);
+
+ Finish("GIF");
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Gif.h b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Gif.h
new file mode 100644
index 000000000..3571491d2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Gif.h
@@ -0,0 +1,52 @@
+// File_Gif - Info for GIF files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about GIF files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_GifH
+#define MediaInfo_File_GifH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Gif
+//***************************************************************************
+
+class File_Gif : public File__Analyze
+{
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Ico.cpp b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Ico.cpp
new file mode 100644
index 000000000..5cac04a56
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Ico.cpp
@@ -0,0 +1,162 @@
+// File_Ico - Info for Icon files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_ICO_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Image/File_Ico.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Ico::File_Ico()
+{
+ IcoDataSize=0;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ico::Streams_Fill()
+{
+ Fill(Stream_General, 0, General_Format, Type==1?"ICO":"CUR");
+
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ {
+ Stream_Prepare(Stream_Image);
+ Fill(Stream_Image, StreamPos_Last, Image_Width, Streams[Pos].Width?Streams[Pos].Width:256);
+ Fill(Stream_Image, StreamPos_Last, Image_Height, Streams[Pos].Height?Streams[Pos].Height:256);
+ if (Type==1)
+ Fill(Stream_Image, StreamPos_Last, Image_BitDepth, Streams[Pos].BitsPerPixel);
+ Fill(Stream_Image, StreamPos_Last, Image_StreamSize, Streams[Pos].Size);
+ }
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Ico::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ if (CC2(Buffer) || (LittleEndian2int16u(Buffer+2)!=1 && LittleEndian2int16u(Buffer+2)!=2))
+ {
+ Reject("ICO");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Ico::FileHeader_Parse()
+{
+ //Parsing
+ Skip_L2( "Reserved");
+ Get_L2 (Type, "Type");
+ Get_L2 (Count, "Count");
+}
+
+//***************************************************************************
+
+// Buffer - Per element
+//***************************************************************************
+//---------------------------------------------------------------------------
+void File_Ico::Header_Parse()
+{
+ Header_Fill_Size(16);
+ Header_Fill_Code(0, "Directory");
+}
+
+//---------------------------------------------------------------------------
+void File_Ico::Data_Parse()
+{
+ //Parsing
+ int32u Size, Offset;
+ int16u BitsPerPixel;
+ int8u Width, Height;
+ Get_L1 (Width, "Width");
+ Get_L1 (Height, "Height");
+ Skip_L1( "Colour count");
+ Skip_L1( "Reserved");
+ Skip_L2( Type==1?"Colour planes":"X hotspot");
+ Get_L2 (BitsPerPixel, Type==1?"Bits per pixel":"Y hotspot");
+ Get_L4 (Size, "Size of the bitmap data");
+ Get_L4 (Offset, "Offset of the bitmap data");
+
+ FILLING_BEGIN_PRECISE();
+ stream Stream;
+ Stream.Width=Width;
+ Stream.Height=Height;
+ Stream.BitsPerPixel=BitsPerPixel;
+ Stream.Size=Size;
+ Stream.Offset=Offset;
+ Streams.push_back(Stream);
+
+ IcoDataSize+=Size;
+ if (Offset>File_Size || File_Offset+Buffer_Offset+Element_Size+IcoDataSize>File_Size)
+ Reject("ICO");
+ Count--;
+ if (Count==0)
+ {
+ if (File_Offset+Buffer_Offset+Element_Size+IcoDataSize!=File_Size)
+ Reject("ICO");
+ else
+ {
+ Accept("ICO");
+ Finish("ICO");
+ }
+ }
+ FILLING_END();
+}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Ico.h b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Ico.h
new file mode 100644
index 000000000..9d060a3c7
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Ico.h
@@ -0,0 +1,76 @@
+// File_Ico - Info for Icon files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Icon files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_IcoH
+#define MediaInfo_File_IcoH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Ico
+//***************************************************************************
+
+class File_Ico : public File__Analyze
+{
+public:
+ //Constructor/Destructor
+ File_Ico();
+
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse ();
+
+ //Buffer - Per element
+ void Header_Parse ();
+ void Data_Parse ();
+
+ //Temp
+ int64u IcoDataSize;
+ int16u Type;
+ int16u Count;
+ struct stream
+ {
+ int32u Size;
+ int32u Offset;
+ int16u BitsPerPixel;
+ int8u Width;
+ int8u Height;
+ };
+ std::vector<stream> Streams;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Jpeg.cpp b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Jpeg.cpp
new file mode 100644
index 000000000..94b131e4c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Jpeg.cpp
@@ -0,0 +1,885 @@
+// File_Jpeg - Info for NewFormat files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Links
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// http://www.fileformat.info/format/jpeg/
+// http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
+// http://www.w3.org/Graphics/JPEG/jfif3.pdf
+// http://www.sentex.net/~mwandel/jhead/
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_JPEG_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Image/File_Jpeg.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "ZenLib/Utils.h"
+#include <vector>
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+namespace Elements
+{
+ const int16u TEM =0xFF01;
+ const int16u SOC =0xFF4F; //JPEG 2000
+ const int16u SIZ =0xFF51; //JPEG 2000
+ const int16u COD =0xFF52; //JPEG 2000
+ const int16u COC =0xFF53; //JPEG 2000
+ const int16u TLM =0xFF55; //JPEG 2000
+ const int16u PLM =0xFF57; //JPEG 2000
+ const int16u PLT =0xFF58; //JPEG 2000
+ const int16u QCD =0xFF5C; //JPEG 2000
+ const int16u QCC =0xFF5D; //JPEG 2000
+ const int16u RGN =0xFF5E; //JPEG 2000
+ const int16u PPM =0xFF60; //JPEG 2000
+ const int16u PPT =0xFF61; //JPEG 2000
+ const int16u CME =0xFF64; //JPEG 2000
+ const int16u SOT =0xFF90; //JPEG 2000
+ const int16u SOP =0xFF91; //JPEG 2000
+ const int16u EPH =0xFF92; //JPEG 2000
+ const int16u SOD =0xFF93; //JPEG 2000
+ const int16u S0F0=0xFFC0;
+ const int16u S0F1=0xFFC1;
+ const int16u S0F2=0xFFC2;
+ const int16u S0F3=0xFFC3;
+ const int16u DHT =0xFFC4;
+ const int16u S0F5=0xFFC5;
+ const int16u S0F6=0xFFC6;
+ const int16u S0F7=0xFFC7;
+ const int16u JPG =0xFFC8;
+ const int16u S0F9=0xFFC9;
+ const int16u S0FA=0xFFCA;
+ const int16u S0FB=0xFFCB;
+ const int16u DAC =0xFFCC;
+ const int16u S0FD=0xFFCD;
+ const int16u S0FE=0xFFCE;
+ const int16u S0FF=0xFFCF;
+ const int16u RST0=0xFFD0;
+ const int16u RST1=0xFFD1;
+ const int16u RST2=0xFFD2;
+ const int16u RST3=0xFFD3;
+ const int16u RST4=0xFFD4;
+ const int16u RST5=0xFFD5;
+ const int16u RST6=0xFFD6;
+ const int16u RST7=0xFFD7;
+ const int16u SOI =0xFFD8;
+ const int16u EOI =0xFFD9; //EOC in JPEG 2000
+ const int16u SOS =0xFFDA;
+ const int16u DQT =0xFFDB;
+ const int16u DNL =0xFFDC;
+ const int16u DRI =0xFFDD;
+ const int16u DHP =0xFFDE;
+ const int16u EXP =0xFFDF;
+ const int16u APP0=0xFFE0;
+ const int16u APP1=0xFFE1;
+ const int16u APP2=0xFFE2;
+ const int16u APP3=0xFFE3;
+ const int16u APP4=0xFFE4;
+ const int16u APP5=0xFFE5;
+ const int16u APP6=0xFFE6;
+ const int16u APP7=0xFFE7;
+ const int16u APP8=0xFFE8;
+ const int16u APP9=0xFFE9;
+ const int16u APPA=0xFFEA;
+ const int16u APPB=0xFFEB;
+ const int16u APPC=0xFFEC;
+ const int16u APPD=0xFFED;
+ const int16u APPE=0xFFEE;
+ const int16u APPF=0xFFEF;
+ const int16u JPG0=0xFFF0;
+ const int16u JPG1=0xFFF1;
+ const int16u JPG2=0xFFF2;
+ const int16u JPG3=0xFFF3;
+ const int16u JPG4=0xFFF4;
+ const int16u JPG5=0xFFF5;
+ const int16u JPG6=0xFFF6;
+ const int16u JPG7=0xFFF7;
+ const int16u JPG8=0xFFF8;
+ const int16u JPG9=0xFFF9;
+ const int16u JPGA=0xFFFA;
+ const int16u JPGB=0xFFFB;
+ const int16u JPGC=0xFFFC;
+ const int16u JPGD=0xFFFD;
+ const int16u COM =0xFFFE;
+}
+
+//---------------------------------------------------------------------------
+// Borland C++ does not accept local template
+struct Jpeg_samplingfactor
+{
+ int8u Hi;
+ int8u Vi;
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Jpeg::File_Jpeg()
+{
+ //Config
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(8); //Stream
+ #endif //MEDIAINFO_TRACE
+ MustSynchronize=true;
+ IsRawStream=true;
+
+ //In
+ StreamKind=Stream_Image;
+ Interlaced=false;
+
+ //Temp
+ Height_Multiplier=1;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Jpeg::Streams_Accept()
+{
+ if (!IsSub)
+ {
+ Streams_Accept_TestContinuousFileNames();
+
+ Stream_Prepare(Config->File_Names.size()>1?Stream_Video:StreamKind);
+ Fill(StreamKind_Last, StreamPos_Last, "StreamSize", File_Size);
+ if (StreamKind_Last==Stream_Video)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameCount, Config->File_Names.size());
+ }
+ else
+ Stream_Prepare(StreamKind);
+
+ //Configuration
+ Buffer_MaximumSize=64*1024*1024;
+ Frame_Count_NotParsedIncluded=0;
+}
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Jpeg::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<3)
+ return false; //Must wait for more data
+
+ if (Buffer[2]!=0xFF
+ || (CC2(Buffer)!=Elements::SOI
+ && CC2(Buffer)!=Elements::SOC))
+ {
+ Reject("JPEG");
+ return false;
+ }
+
+ Accept();
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Jpeg::Synchronize()
+{
+ //Synchronizing
+ while(Buffer_Offset+2<=Buffer_Size && (Buffer[Buffer_Offset ]!=0xFF
+ || Buffer[Buffer_Offset+1]==0x00))
+ Buffer_Offset++;
+
+ if (Buffer_Offset+1==Buffer_Size && Buffer[Buffer_Offset ]!=0xFF)
+ Buffer_Offset++;
+
+ if (Buffer_Offset+2>Buffer_Size)
+ return false;
+
+ //Synched is OK
+ Synched=true;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Jpeg::Synched_Test()
+{
+ if (SOS_SOD_Parsed)
+ return true; ///No sync after SOD
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+2>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (Buffer[Buffer_Offset]!=0xFF)
+ {
+ Synched=false;
+ return true;
+ }
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::Synched_Init()
+{
+ SOS_SOD_Parsed=false;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Jpeg::Read_Buffer_Unsynched()
+{
+ SOS_SOD_Parsed=false;
+
+ Read_Buffer_Unsynched_OneFramePerFile();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Jpeg::Header_Parse()
+{
+ if (SOS_SOD_Parsed)
+ {
+ Header_Fill_Code(0, "Data");
+ if (!Header_Parser_Fill_Size())
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ return;
+ }
+
+ //Parsing
+ int16u code, size;
+ Get_B2 (code, "Marker");
+ switch (code)
+ {
+ case Elements::TEM :
+ case Elements::RST0 :
+ case Elements::RST1 :
+ case Elements::RST2 :
+ case Elements::RST3 :
+ case Elements::RST4 :
+ case Elements::RST5 :
+ case Elements::RST6 :
+ case Elements::RST7 :
+ case Elements::SOC :
+ case Elements::SOD :
+ case Elements::SOI :
+ case Elements::EOI :
+ size=0; break;
+ default : Get_B2 (size, "Fl - Frame header length");
+ }
+
+ //Filling
+ Header_Fill_Code(code, Ztring().From_CC2(code));
+ Header_Fill_Size(2+size);
+}
+
+//---------------------------------------------------------------------------
+bool File_Jpeg::Header_Parser_Fill_Size()
+{
+ //Look for next Sync word
+ if (Buffer_Offset_Temp==0) //Buffer_Offset_Temp is not 0 if Header_Parse_Fill_Size() has already parsed first frames
+ Buffer_Offset_Temp=Buffer_Offset;
+ while (Buffer_Offset_Temp+2<=Buffer_Size
+ && CC2(Buffer+Buffer_Offset_Temp)!=Elements::EOI)
+ Buffer_Offset_Temp++;
+
+ //Must wait more data?
+ if (Buffer_Offset_Temp+2>Buffer_Size)
+ {
+ if (/*FrameIsAlwaysComplete ||*/ File_Offset+Buffer_Size>=File_Size)
+ Buffer_Offset_Temp=Buffer_Size; //We are sure that the next bytes are a start
+ else
+ return false;
+ }
+
+ //OK, we continue
+ Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset);
+ Buffer_Offset_Temp=0;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::Data_Parse()
+{
+ #define CASE_INFO(_NAME, _DETAIL) \
+ case Elements::_NAME : Element_Info1(#_NAME); Element_Info1(_DETAIL); _NAME(); break;
+
+ //Parsing
+ if (SOS_SOD_Parsed)
+ {
+ Skip_XX(Element_Size, "Data");
+ SOS_SOD_Parsed=false;
+ return;
+ }
+ switch (Element_Code)
+ {
+ CASE_INFO(TEM , "TEM");
+ CASE_INFO(SOC , "Start of codestream"); //JPEG 2000
+ CASE_INFO(SIZ , "Image and tile size"); //JPEG 2000
+ CASE_INFO(COD , "Coding style default"); //JPEG 2000
+ CASE_INFO(COC , "Coding style component"); //JPEG 2000
+ CASE_INFO(TLM , "Tile-part lengths, main header"); //JPEG 2000
+ CASE_INFO(PLM , "Packet length, main header"); //JPEG 2000
+ CASE_INFO(PLT , "Packet length, tile-part header"); //JPEG 2000
+ CASE_INFO(QCD , "Quantization default"); //JPEG 2000
+ CASE_INFO(QCC , "Quantization component "); //JPEG 2000
+ CASE_INFO(RGN , "Region-of-interest"); //JPEG 2000
+ CASE_INFO(PPM , "Packed packet headers, main header"); //JPEG 2000
+ CASE_INFO(PPT , "Packed packet headers, tile-part header"); //JPEG 2000
+ CASE_INFO(CME , "Comment and extension"); //JPEG 2000
+ CASE_INFO(SOT , "Start of tile-part"); //JPEG 2000
+ CASE_INFO(SOP , "Start of packet"); //JPEG 2000
+ CASE_INFO(EPH , "End of packet header"); //JPEG 2000
+ CASE_INFO(SOD , "Start of data"); //JPEG 2000
+ CASE_INFO(S0F0, "Baseline DCT (Huffman)");
+ CASE_INFO(S0F1, "Extended sequential DCT (Huffman)");
+ CASE_INFO(S0F2, "Progressive DCT (Huffman)");
+ CASE_INFO(S0F3, "Lossless (sequential) (Huffman)");
+ CASE_INFO(DHT , "Define Huffman Tables");
+ CASE_INFO(S0F5, "Differential sequential DCT (Huffman)");
+ CASE_INFO(S0F6, "Differential progressive DCT (Huffman)");
+ CASE_INFO(S0F7, "Differential lossless (sequential) (Huffman)");
+ CASE_INFO(JPG , "Reserved for JPEG extensions");
+ CASE_INFO(S0F9, "Extended sequential DCT (Arithmetic)");
+ CASE_INFO(S0FA, "Progressive DCT (Arithmetic)");
+ CASE_INFO(S0FB, "Lossless (sequential) (Arithmetic)");
+ CASE_INFO(DAC , "Define Arithmetic Coding");
+ CASE_INFO(S0FD, "Differential sequential DCT (Arithmetic)");
+ CASE_INFO(S0FE, "Differential progressive DCT (Arithmetic)");
+ CASE_INFO(S0FF, "Differential lossless (sequential) (Arithmetic)");
+ CASE_INFO(RST0, "Restart Interval Termination 0");
+ CASE_INFO(RST1, "Restart Interval Termination 1");
+ CASE_INFO(RST2, "Restart Interval Termination 2");
+ CASE_INFO(RST3, "Restart Interval Termination 3");
+ CASE_INFO(RST4, "Restart Interval Termination 4");
+ CASE_INFO(RST5, "Restart Interval Termination 5");
+ CASE_INFO(RST6, "Restart Interval Termination 6");
+ CASE_INFO(RST7, "Restart Interval Termination 7");
+ CASE_INFO(SOI , "Start Of Image");
+ CASE_INFO(EOI , "End Of Image"); //Is EOC (End of codestream) in JPEG 2000
+ CASE_INFO(SOS , "Start Of Scan");
+ CASE_INFO(DQT , "Define Quantization Tables");
+ CASE_INFO(DNL , "Define Number of Lines");
+ CASE_INFO(DRI , "Define Restart Interval");
+ CASE_INFO(DHP , "Define Hierarchical Progression");
+ CASE_INFO(EXP , "Expand Reference Components");
+ CASE_INFO(APP0, "Application-specific marker 0");
+ CASE_INFO(APP1, "Application-specific marker 1");
+ CASE_INFO(APP2, "Application-specific marker 2");
+ CASE_INFO(APP3, "Application-specific marker 3");
+ CASE_INFO(APP4, "Application-specific marker 4");
+ CASE_INFO(APP5, "Application-specific marker 5");
+ CASE_INFO(APP6, "Application-specific marker 6");
+ CASE_INFO(APP7, "Application-specific marker 7");
+ CASE_INFO(APP8, "Application-specific marker 8");
+ CASE_INFO(APP9, "Application-specific marker 9");
+ CASE_INFO(APPA, "Application-specific marker 10");
+ CASE_INFO(APPB, "Application-specific marker 11");
+ CASE_INFO(APPC, "Application-specific marker 12");
+ CASE_INFO(APPD, "Application-specific marker 13");
+ CASE_INFO(APPE, "Application-specific marker 14");
+ CASE_INFO(APPF, "Application-specific marker 15");
+ CASE_INFO(JPG0, "JPG");
+ CASE_INFO(JPG1, "JPG");
+ CASE_INFO(JPG2, "JPG");
+ CASE_INFO(JPG3, "JPG");
+ CASE_INFO(JPG4, "JPG");
+ CASE_INFO(JPG5, "JPG");
+ CASE_INFO(JPG6, "JPG");
+ CASE_INFO(JPG7, "JPG");
+ CASE_INFO(JPG8, "JPG");
+ CASE_INFO(JPG9, "JPG");
+ CASE_INFO(JPGA, "JPG");
+ CASE_INFO(JPGB, "JPG");
+ CASE_INFO(JPGC, "JPG");
+ CASE_INFO(JPGD, "JPG");
+ CASE_INFO(COM , "Comment");
+ default : Element_Info1("Reserved");
+ Skip_XX(Element_Size, "Data");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Jpeg::SIZ()
+{
+ //Parsing
+ vector<float> SamplingFactors;
+ vector<int8u> BitDepths;
+ int8u SamplingFactors_Max=0;
+ int32u Xsiz, Ysiz;
+ int16u Count;
+ Skip_B2( "Rsiz - Capability of the codestream");
+ Get_B4 (Xsiz, "Xsiz - Image size X");
+ Get_B4 (Ysiz, "Ysiz - Image size Y");
+ Skip_B4( "XOsiz - Image offset X");
+ Skip_B4( "YOsiz - Image offset Y");
+ Skip_B4( "tileW - Size of tile W");
+ Skip_B4( "tileH - Size of tile H");
+ Skip_B4( "XTOsiz - Upper-left tile offset X");
+ Skip_B4( "YTOsiz - Upper-left tile offset Y");
+ Get_B2 (Count, "Components and initialize related arrays");
+ for (int16u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("Initialize related array");
+ int8u BitDepth, compSubsX, compSubsY;
+ BS_Begin();
+ Skip_SB( "Signed");
+ Get_S1 (7, BitDepth, "BitDepth"); Param_Info1(1+BitDepth); Element_Info1(1+BitDepth);
+ BS_End();
+ Get_B1 ( compSubsX, "compSubsX"); Element_Info1(compSubsX);
+ Get_B1 ( compSubsY, "compSubsY"); Element_Info1(compSubsY);
+ Element_End0();
+
+ //Filling list of HiVi
+ if (compSubsX)
+ {
+ SamplingFactors.push_back(((float)compSubsY)/compSubsX);
+ if (((float)compSubsY)/compSubsX>SamplingFactors_Max)
+ SamplingFactors_Max=(int8u)((float)compSubsY)/compSubsX;
+ }
+
+ if (BitDepths.empty() || BitDepth!=BitDepths[0])
+ BitDepths.push_back(BitDepth);
+ }
+
+ FILLING_BEGIN_PRECISE();
+ if (Frame_Count==0 && Field_Count==0)
+ {
+ Accept("JPEG 2000");
+
+ if (Count_Get(StreamKind_Last)==0)
+ Stream_Prepare(StreamKind_Last);
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Format), "JPEG 2000");
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Codec), "JPEG 2000");
+ if (StreamKind_Last==Stream_Image)
+ Fill(Stream_Image, 0, Image_Codec_String, "JPEG 2000", Unlimited, true, true); //To Avoid automatic filling
+ Fill(StreamKind_Last, 0, StreamKind_Last==Stream_Image?(size_t)Image_Width:(size_t)Video_Width, Xsiz);
+ Fill(StreamKind_Last, 0, StreamKind_Last==Stream_Image?(size_t)Image_Height:(size_t)Video_Height, Ysiz*(Interlaced?2:1)); //If image is from interlaced content, must multiply height by 2
+
+ if (BitDepths.size()==1)
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_BitDepth), 1+BitDepths[0]);
+
+ //Chroma subsampling
+ if (SamplingFactors_Max)
+ while (SamplingFactors_Max<4)
+ {
+ for (size_t Pos=0; Pos<SamplingFactors.size(); Pos++)
+ SamplingFactors[Pos]*=2;
+ SamplingFactors_Max*=2;
+ }
+ while (SamplingFactors.size()<3)
+ SamplingFactors.push_back(0);
+ Ztring ChromaSubsampling;
+ for (size_t Pos=0; Pos<SamplingFactors.size(); Pos++)
+ ChromaSubsampling+=Ztring::ToZtring(SamplingFactors[Pos], 0)+_T(':');
+ if (!ChromaSubsampling.empty())
+ {
+ ChromaSubsampling.resize(ChromaSubsampling.size()-1);
+ Fill(StreamKind_Last, 0, "ChromaSubsampling", ChromaSubsampling);
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::COD()
+{
+ //Parsing
+ int16u Levels;
+ int8u Style, Style2, MultipleComponentTransform;
+ bool PrecinctUsed;
+ Get_B1 (Style, "Scod - Style");
+ Get_Flags (Style, 0, PrecinctUsed, "Precinct used");
+ Skip_Flags(Style, 1, "Use SOP (start of packet)");
+ Skip_Flags(Style, 2, "Use EPH (end of packet header)");
+ Skip_B1( "Number of decomposition levels");
+ Skip_B1( "Progression order");
+ Get_B2 (Levels, "Number of layers");
+ Info_B1(DimX, "Code-blocks dimensions X (2^(n+2))"); Param_Info2(1<<(DimX+2), " pixels");
+ Info_B1(DimY, "Code-blocks dimensions Y (2^(n+2))"); Param_Info2(1<<(DimY+2), " pixels");
+ Get_B1 (Style2, "Style of the code-block coding passes");
+ Skip_Flags(Style, 0, "Selective arithmetic coding bypass");
+ Skip_Flags(Style, 1, "MQ states for all contexts");
+ Skip_Flags(Style, 2, "Regular termination");
+ Skip_Flags(Style, 3, "Vertically stripe-causal context formation");
+ Skip_Flags(Style, 4, "Error resilience info is embedded on MQ termination");
+ Skip_Flags(Style, 5, "Segmentation marker is to be inserted at the end of each normalization coding pass");
+ Skip_B1( "Transform");
+ Get_B1(MultipleComponentTransform, "Multiple component transform");
+ if (PrecinctUsed)
+ {
+ BS_Begin();
+ Skip_S1(4, "LL sub-band width");
+ Skip_S1(4, "LL sub-band height");
+ BS_End();
+ for (int16u Pos=0; Pos<Levels; Pos++)
+ {
+ Element_Begin1("Decomposition level");
+ BS_Begin();
+ Skip_S1(4, "decomposition level width");
+ Skip_S1(4, "decomposition level height");
+ BS_End();
+ Element_End0();
+ }
+ }
+
+ FILLING_BEGIN();
+ if (Frame_Count==0 && Field_Count==0)
+ {
+ switch (MultipleComponentTransform)
+ {
+ case 0x01 : Fill(StreamKind_Last, 0, "Compression_Mode", "Lossless"); break;
+ case 0x02 : Fill(StreamKind_Last, 0, "Compression_Mode", "Lossy"); break;
+ default : ;
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::QCD()
+{
+ //Parsing
+ Skip_B1( "Sqcd - Style");
+ Skip_XX(Element_Size-Element_Offset, "QCD data");
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::SOD()
+{
+ SOS_SOD_Parsed=true;
+ if (Interlaced)
+ Field_Count++;
+ if (!Interlaced && Field_Count%2==0)
+ {
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ }
+ if (Status[IsFilled])
+ Fill();
+ if (Config_ParseSpeed<1.0)
+ Finish("JPEG 2000"); //No need of more
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::SOF_()
+{
+ //Parsing
+ vector<Jpeg_samplingfactor> SamplingFactors;
+ int16u Height, Width;
+ int8u Resolution, Count;
+ Get_B1 (Resolution, "P - Sample precision");
+ Get_B2 (Height, "Y - Number of lines");
+ Get_B2 (Width, "X - Number of samples per line");
+ Get_B1 (Count, "Nf - Number of image components in frame");
+ for (int8u Pos=0; Pos<Count; Pos++)
+ {
+ Jpeg_samplingfactor SamplingFactor;
+ Element_Begin1("Component");
+ Info_B1(Ci, "Ci - Component identifier"); Element_Info1(Ci);
+ BS_Begin();
+ Get_S1 (4, SamplingFactor.Hi, "Hi - Horizontal sampling factor"); Element_Info1(SamplingFactor.Hi);
+ Get_S1 (4, SamplingFactor.Vi, "Vi - Vertical sampling factor"); Element_Info1(SamplingFactor.Vi);
+ BS_End();
+ Skip_B1( "Tqi - Quantization table destination selector");
+ Element_End0();
+
+ //Filling list of HiVi
+ SamplingFactors.push_back(SamplingFactor);
+ }
+
+ FILLING_BEGIN_PRECISE();
+ if (Frame_Count==0 && Field_Count==0)
+ {
+ Accept("JPEG");
+
+ if (Count_Get(StreamKind_Last)==0)
+ Stream_Prepare(StreamKind_Last);
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Format), "JPEG");
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Codec), "JPEG");
+ if (StreamKind_Last==Stream_Image)
+ Fill(Stream_Image, 0, Image_Codec_String, "JPEG", Unlimited, true, true); //To Avoid automatic filling
+ if (StreamKind_Last==Stream_Video)
+ Fill(Stream_Video, 0, Video_InternetMediaType, "video/JPEG", Unlimited, true, true);
+ Fill(StreamKind_Last, 0, "ColorSpace", "YUV");
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_BitDepth), Resolution);
+ Fill(StreamKind_Last, 0, "Height", Height*Height_Multiplier);
+ Fill(StreamKind_Last, 0, "Width", Width);
+
+ //Chroma subsampling
+ if (SamplingFactors.size()==3 && SamplingFactors[1].Hi==1 && SamplingFactors[2].Hi==1 && SamplingFactors[1].Vi==1 && SamplingFactors[2].Vi==1)
+ {
+ string ChromaSubsampling;
+ switch (SamplingFactors[0].Hi)
+ {
+ case 1 :
+ switch (SamplingFactors[0].Vi)
+ {
+ case 1 : ChromaSubsampling="4:4:4"; break;
+ default: ;
+ }
+ break;
+ case 2 :
+ switch (SamplingFactors[0].Vi)
+ {
+ case 1 : ChromaSubsampling="4:2:2"; break;
+ case 2 : ChromaSubsampling="4:2:0"; break;
+ default: ;
+ }
+ break;
+ case 4 :
+ switch (SamplingFactors[0].Vi)
+ {
+ case 1 : ChromaSubsampling="4:1:1"; break;
+ default: ;
+ }
+ break;
+ default: ;
+ }
+ if (!ChromaSubsampling.empty())
+ Fill(StreamKind_Last, 0, "ChromaSubsampling", ChromaSubsampling);
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::SOS()
+{
+ //Parsing
+ int8u Count;
+ Get_B1 (Count, "Number of image components in scan");
+ for (int8u Pos=0; Pos<Count; Pos++)
+ {
+ Skip_B1( "Scan component selector");
+ Skip_B1( "Entropy coding table destination selector");
+ }
+ Skip_B1( "Start of spectral or predictor selection");
+ Skip_B1( "End of spectral selection");
+ Skip_B1( "Successive approximation bit position");
+
+ FILLING_BEGIN_PRECISE();
+ SOS_SOD_Parsed=true;
+ if (Interlaced)
+ Field_Count++;
+ if (!Interlaced && Field_Count%2==0)
+ {
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ }
+ if (Status[IsFilled])
+ Fill();
+ if (Config_ParseSpeed<1.0)
+ Finish("JPEG"); //No need of more
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::APP0()
+{
+ //Parsing
+ int32u Name;
+ Get_C4(Name, "Name");
+ switch (Name)
+ {
+ case 0x41564931 : APP0_AVI1(); break; //"AVI1"
+ case 0x4A464946 : APP0_JFIF(); break; //"JFIF"
+ case 0x4A464646 : APP0_JFFF(); break; //"JFFF"
+ default : Skip_XX(Element_Size, "Data");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::APP0_AVI1()
+{
+ //Parsing
+ int8u FieldOrder=(int8u)-1;
+ Element_Begin1("AVI1");
+ if (Element_Size==16-4)
+ {
+ Get_B1 (FieldOrder, "Field Order");
+ Skip_XX(7, "Zeroes");
+ }
+ if (Element_Size==18-4)
+ {
+ Get_B1 (FieldOrder, "Field Order");
+ Skip_B1( "Zero");
+ Skip_B4( "Size of 1st Field");
+ Skip_B4( "Size of 2nd Field");
+ }
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (Frame_Count==0 && Field_Count==0)
+ {
+ switch (FieldOrder)
+ {
+ case 0x00 : Fill(Stream_Video, 0, Video_Interlacement, "PPF"); Fill(Stream_Video, 0, Video_ScanType, "Progressive"); break;
+ case 0x01 : Fill(Stream_Video, 0, Video_Interlacement, "TFF"); Fill(Stream_Video, 0, Video_ScanType, "Interlaced"); Fill(Stream_Video, 0, Video_ScanOrder, "TFF"); Height_Multiplier=2; break;
+ case 0x02 : Fill(Stream_Video, 0, Video_Interlacement, "BFF"); Fill(Stream_Video, 0, Video_ScanType, "Interlaced"); Fill(Stream_Video, 0, Video_ScanOrder, "BFF"); Height_Multiplier=2; break;
+ default : ;
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::APP0_JFIF()
+{
+ //Parsing
+ Skip_B1( "Zero");
+ Element_Begin1("JFIF");
+ int16u Width, Height;
+ int8u Unit, ThumbailX, ThumbailY;
+ Skip_B2( "Version");
+ Get_B1 (Unit, "Unit"); //0=Pixels, 1=dpi, 2=dpcm
+ Get_B2 (Width, "Xdensity");
+ Get_B2 (Height, "Ydensity");
+ Get_B1 (ThumbailX, "Xthumbail");
+ Get_B1 (ThumbailY, "Ythumbail");
+ Skip_XX(3*ThumbailX*ThumbailY, "RGB Thumbail");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::APP0_JFFF()
+{
+ Skip_B1( "Zero");
+ Element_Begin1("Extension");
+ Skip_B1( "extension_code"); //0x10 Thumbnail coded using JPEG, 0x11 Thumbnail stored using 1 byte/pixel, 0x13 Thumbnail stored using 3 bytes/pixel
+ if (Element_Size>Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "extension_data");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::APP0_JFFF_JPEG()
+{
+ //Parsing
+ Element_Begin1("Thumbail JPEG");
+ if (Element_Size>Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "Data");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::APP0_JFFF_1B()
+{
+ //Parsing
+ Element_Begin1("Thumbail 1 byte per pixel");
+ int8u ThumbailX, ThumbailY;
+ Get_B1 (ThumbailX, "Xthumbail");
+ Get_B1 (ThumbailY, "Ythumbail");
+ Skip_XX(768, "Palette");
+ Skip_XX(ThumbailX*ThumbailY, "Thumbail");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::APP0_JFFF_3B()
+{
+ //Parsing
+ Element_Begin1("Thumbail 3 bytes per pixel");
+ int8u ThumbailX, ThumbailY;
+ Get_B1 (ThumbailX, "Xthumbail");
+ Get_B1 (ThumbailY, "Ythumbail");
+ Skip_XX(3*ThumbailX*ThumbailY, "RGB Thumbail");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::APP1()
+{
+ //Parsing
+ int64u Name;
+ Get_C6(Name, "Name");
+
+ switch (Name)
+ {
+ case 0x457869660000LL : APP1_EXIF(); break; //"Exif\0\0"
+ default : Skip_XX(Element_Size-Element_Offset, "Data");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Jpeg::APP1_EXIF()
+{
+ //Parsing
+ Element_Begin1("Exif");
+ int32u Alignment;
+ Get_C4(Alignment, "Alignment");
+ if (Alignment==0x49492A00)
+ Skip_B4( "First_IFD");
+ if (Alignment==0x4D4D2A00)
+ Skip_L4( "First_IFD");
+ Element_End0();
+}
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Jpeg.h b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Jpeg.h
new file mode 100644
index 000000000..b94a2e070
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Jpeg.h
@@ -0,0 +1,176 @@
+// File_Jpeg - Info for JPEG files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about JPEG files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_JpegH
+#define MediaInfo_File_JpegH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Jpeg
+//***************************************************************************
+
+class File_Jpeg : public File__Analyze
+{
+public :
+ //In
+ stream_t StreamKind;
+ bool Interlaced;
+
+ //Constructor/Destructor
+ File_Jpeg();
+
+private :
+ //Streams management
+ void Streams_Accept();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+ void Synched_Init();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test() {return Demux_UnpacketizeContainer_Test_OneFramePerFile();}
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched();
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) {return Read_Buffer_Seek_OneFramePerFile(Method, Value, ID);}
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - Per element
+ void Header_Parse();
+ bool Header_Parser_Fill_Size();
+ void Data_Parse();
+
+ //Elements
+ void TEM () {};
+ void SOC () {}
+ void SIZ ();
+ void COD ();
+ void COC () {Skip_XX(Element_Size, "Data");}
+ void TLM () {Skip_XX(Element_Size, "Data");}
+ void PLM () {Skip_XX(Element_Size, "Data");}
+ void PLT () {Skip_XX(Element_Size, "Data");}
+ void QCD ();
+ void QCC () {Skip_XX(Element_Size, "Data");}
+ void RGN () {Skip_XX(Element_Size, "Data");}
+ void PPM () {Skip_XX(Element_Size, "Data");}
+ void PPT () {Skip_XX(Element_Size, "Data");}
+ void CME () {Skip_XX(Element_Size, "Data");}
+ void SOT () {Skip_XX(Element_Size, "Data");}
+ void SOP () {Skip_XX(Element_Size, "Data");}
+ void EPH () {Skip_XX(Element_Size, "Data");}
+ void SOD ();
+ void SOF_();
+ void S0F0() {SOF_();};
+ void S0F1() {SOF_();};
+ void S0F2() {SOF_();};
+ void S0F3() {SOF_();}
+ void DHT () {Skip_XX(Element_Size, "Data");}
+ void S0F5() {SOF_();}
+ void S0F6() {SOF_();}
+ void S0F7() {SOF_();}
+ void JPG () {Skip_XX(Element_Size, "Data");}
+ void S0F9() {SOF_();}
+ void S0FA() {SOF_();}
+ void S0FB() {SOF_();}
+ void DAC () {Skip_XX(Element_Size, "Data");}
+ void S0FD() {SOF_();}
+ void S0FE() {SOF_();}
+ void S0FF() {SOF_();}
+ void RST0() {};
+ void RST1() {};
+ void RST2() {};
+ void RST3() {};
+ void RST4() {};
+ void RST5() {};
+ void RST6() {};
+ void RST7() {};
+ void SOI () {};
+ void EOI () {};
+ void SOS ();
+ void DQT () {Skip_XX(Element_Size, "Data");}
+ void DNL () {Skip_XX(Element_Size, "Data");}
+ void DRI () {Skip_XX(Element_Size, "Data");}
+ void DHP () {Skip_XX(Element_Size, "Data");}
+ void EXP () {Skip_XX(Element_Size, "Data");}
+ void APP0();
+ void APP0_AVI1();
+ void APP0_JFIF();
+ void APP0_JFFF();
+ void APP0_JFFF_JPEG();
+ void APP0_JFFF_1B();
+ void APP0_JFFF_3B();
+ void APP1();
+ void APP1_EXIF();
+ void APP2() {Skip_XX(Element_Size, "Data");}
+ void APP3() {Skip_XX(Element_Size, "Data");}
+ void APP4() {Skip_XX(Element_Size, "Data");}
+ void APP5() {Skip_XX(Element_Size, "Data");}
+ void APP6() {Skip_XX(Element_Size, "Data");}
+ void APP7() {Skip_XX(Element_Size, "Data");}
+ void APP8() {Skip_XX(Element_Size, "Data");}
+ void APP9() {Skip_XX(Element_Size, "Data");}
+ void APPA() {Skip_XX(Element_Size, "Data");}
+ void APPB() {Skip_XX(Element_Size, "Data");}
+ void APPC() {Skip_XX(Element_Size, "Data");}
+ void APPD() {Skip_XX(Element_Size, "Data");}
+ void APPE() {Skip_XX(Element_Size, "Data");}
+ void APPF() {Skip_XX(Element_Size, "Data");}
+ void JPG0() {Skip_XX(Element_Size, "Data");}
+ void JPG1() {Skip_XX(Element_Size, "Data");}
+ void JPG2() {Skip_XX(Element_Size, "Data");}
+ void JPG3() {Skip_XX(Element_Size, "Data");}
+ void JPG4() {Skip_XX(Element_Size, "Data");}
+ void JPG5() {Skip_XX(Element_Size, "Data");}
+ void JPG6() {Skip_XX(Element_Size, "Data");}
+ void JPG7() {Skip_XX(Element_Size, "Data");}
+ void JPG8() {Skip_XX(Element_Size, "Data");}
+ void JPG9() {Skip_XX(Element_Size, "Data");}
+ void JPGA() {Skip_XX(Element_Size, "Data");}
+ void JPGB() {Skip_XX(Element_Size, "Data");}
+ void JPGC() {Skip_XX(Element_Size, "Data");}
+ void JPGD() {Skip_XX(Element_Size, "Data");}
+ void COM () {Skip_XX(Element_Size, "Data");}
+
+ //Temp
+ int8u Height_Multiplier;
+ bool SOS_SOD_Parsed;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Png.cpp b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Png.cpp
new file mode 100644
index 000000000..1df902e61
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Png.cpp
@@ -0,0 +1,322 @@
+// File_Png - Info for PNG files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// PNG - Format
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// From http://www.fileformat.info/format/png/
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_PNG_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Image/File_Png.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Png_Colour_type(int8u Colour_type)
+{
+ switch (Colour_type)
+ {
+ case 0 : return "Greyscale";
+ case 2 : return "Truecolour";
+ case 3 : return "Indexed-colour";
+ case 4 : return "Greyscale with alpha";
+ case 6 : return "Truecolour with alpha";
+ default: return "";
+ }
+}
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+namespace Elements
+{
+ const int32u IDAT=0x49444154;
+ const int32u IEND=0x49454E44;
+ const int32u IHDR=0x49484452;
+ const int32u PLTE=0x506C5445;
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Png::File_Png()
+{
+ //Config
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(8); //Stream
+ #endif //MEDIAINFO_TRACE
+ IsRawStream=true;
+
+ //Temp
+ Signature_Parsed=false;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Png::Streams_Accept()
+{
+ if (!IsSub)
+ {
+ Streams_Accept_TestContinuousFileNames();
+
+ Stream_Prepare((Config->File_Names.size()>1 || Config->File_IsReferenced_Get())?Stream_Video:Stream_Image);
+ Fill(StreamKind_Last, StreamPos_Last, "StreamSize", File_Size);
+ if (StreamKind_Last==Stream_Video)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameCount, Config->File_Names.size());
+ }
+ else
+ Stream_Prepare(StreamKind_Last);
+
+ //Configuration
+ Frame_Count_NotParsedIncluded=0;
+}
+
+//***************************************************************************
+// Header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Png::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<8)
+ return false; //Must wait for more data
+
+ if (CC4(Buffer+4)!=0x0D0A1A0A) //Byte order
+ {
+ Reject("PNG");
+ return false;
+ }
+
+ switch (CC4(Buffer)) //Signature
+ {
+ case 0x89504E47 :
+ Accept("PNG");
+
+ Fill(Stream_General, 0, General_Format, "PNG");
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Format), "PNG");
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Codec), "PNG");
+
+ break;
+
+ case 0x8A4E4E47 :
+ Accept("PNG");
+
+ Fill(Stream_General, 0, General_Format, "MNG");
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Format), "MNG");
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Codec), "MNG");
+
+ Finish("PNG");
+ break;
+
+ case 0x8B4A4E47 :
+ Accept("PNG");
+
+ Fill(Stream_General, 0, General_Format, "JNG");
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Format), "JNG");
+ Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Codec), "JNG");
+
+ Finish("PNG");
+ break;
+
+ default:
+ Reject("PNG");
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Png::Read_Buffer_Unsynched()
+{
+ Signature_Parsed=false;
+
+ Read_Buffer_Unsynched_OneFramePerFile();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Png::Header_Parse()
+{
+ if (!Signature_Parsed)
+ {
+ //Filling
+ Header_Fill_Size(8);
+ Header_Fill_Code(0, "File header");
+
+ return;
+ }
+
+ //Parsing
+ int32u Length, Chunk_Type;
+ Get_B4 (Length, "Length");
+ Get_C4 (Chunk_Type, "Chunk Type");
+
+ //Filling
+ Header_Fill_Size(12+Length); //+4 for CRC
+ Header_Fill_Code(Chunk_Type, Ztring().From_CC4(Chunk_Type));
+}
+
+//---------------------------------------------------------------------------
+void File_Png::Data_Parse()
+{
+ if (!Signature_Parsed)
+ {
+ Signature();
+ return;
+ }
+
+ Element_Size-=4; //For CRC
+
+ #define CASE_INFO(_NAME, _DETAIL) \
+ case Elements::_NAME : Element_Info1(_DETAIL); _NAME(); break;
+
+ //Parsing
+ switch (Element_Code)
+ {
+ CASE_INFO(IDAT, "Image data");
+ CASE_INFO(IEND, "Image trailer");
+ CASE_INFO(IHDR, "Image header");
+ CASE_INFO(PLTE, "Palette table");
+ default : Skip_XX(Element_Size, "Unknown");
+ }
+
+ Element_Size+=4; //For CRC
+ Skip_B4( "CRC");
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Png::Signature()
+{
+ //Parsing
+ Skip_B4( "Signature");
+ Skip_B4( "ByteOrder");
+
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ Signature_Parsed=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Png::IEND()
+{
+ Signature_Parsed=false;
+}
+
+//---------------------------------------------------------------------------
+void File_Png::IHDR()
+{
+ //Parsing
+ int32u Width, Height;
+ int8u Bit_depth, Colour_type, Compression_method, Interlace_method;
+ Get_B4 (Width, "Width");
+ Get_B4 (Height, "Height");
+ Get_B1 (Bit_depth, "Bit depth");
+ Get_B1 (Colour_type, "Colour type"); Param_Info1(Png_Colour_type(Colour_type));
+ Get_B1 (Compression_method, "Compression method");
+ Skip_B1( "Filter method");
+ Get_B1 (Interlace_method, "Interlace method");
+
+ FILLING_BEGIN_PRECISE();
+ Fill(StreamKind_Last, 0, "Width", Width);
+ Fill(StreamKind_Last, 0, "Height", Height);
+ int8u Resolution;
+ switch (Colour_type)
+ {
+ case 0 : Resolution=Bit_depth; break;
+ case 2 : Resolution=Bit_depth*3; break;
+ case 3 : Resolution=Bit_depth; break;
+ case 4 : Resolution=Bit_depth*2; break;
+ case 6 : Resolution=Bit_depth*4; break;
+ default: Resolution=0;
+ }
+ if (Resolution)
+ Fill(StreamKind_Last, 0, "BitDepth", Resolution);
+ switch (Compression_method)
+ {
+ case 0 :
+ Fill(StreamKind_Last, 0, "Format_Compression", "LZ77");
+ break;
+ default: ;
+ }
+ switch (Interlace_method)
+ {
+ case 0 :
+ break;
+ case 1 :
+ break;
+ default: ;
+ }
+
+ if (Status[IsFilled])
+ Fill();
+ if (Config_ParseSpeed<1.0)
+ Finish("PNG"); //No need of more
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Png.h b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Png.h
new file mode 100644
index 000000000..a0e73b474
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Png.h
@@ -0,0 +1,81 @@
+// File_Png - Info for PNG files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about PNG files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_PngH
+#define MediaInfo_File_PngH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Png
+//***************************************************************************
+
+class File_Png : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Png();
+
+private :
+ //Streams management
+ void Streams_Accept();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test() {return Demux_UnpacketizeContainer_Test_OneFramePerFile();}
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched();
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID) {return Read_Buffer_Seek_OneFramePerFile(Method, Value, ID);}
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Signature();
+ void IDAT() {Skip_XX(Element_Size, "Data");}
+ void IEND();
+ void IHDR();
+ void PLTE() {Skip_XX(Element_Size, "Data");}
+
+ //Temp
+ bool Signature_Parsed;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Rle.cpp b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Rle.cpp
new file mode 100644
index 000000000..7c4df67f2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Rle.cpp
@@ -0,0 +1,88 @@
+// File_Rle - Info for RLE files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_RLE_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Image/File_Rle.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Rle::File_Rle()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("RLE");
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Rle::Streams_Fill()
+{
+ Stream_Prepare(Stream_General);
+ Fill(Stream_General, 0, General_Format, "RLE");
+
+ Stream_Prepare(Stream_Text); //TODO: This is currenlty only text
+ Fill(Stream_Text, 0, Text_Format, "RLE");
+ Fill(Stream_Text, 0, Text_Codec, "RLE");
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Rle::Read_Buffer_Continue()
+{
+ //Filling
+ Accept();
+ Finish("RLE");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_RLE_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Rle.h b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Rle.h
new file mode 100644
index 000000000..ddc567da7
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Rle.h
@@ -0,0 +1,55 @@
+// File_Rle - Info for RLE files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about RLE files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_RleH
+#define MediaInfo_File_RleH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Rle
+//***************************************************************************
+
+class File_Rle : public File__Analyze
+{
+public :
+ File_Rle();
+
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tga.cpp b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tga.cpp
new file mode 100644
index 000000000..839f3c95a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tga.cpp
@@ -0,0 +1,312 @@
+// File_Tga - Info for TGA files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// TGA - Format
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// From http://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf
+//
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_TGA_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Image/File_Tga.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Tga_Image_Type_Compression(int8u Image_Type)
+{
+ switch (Image_Type)
+ {
+ case 1 : return "Color-mapped";
+ case 2 :
+ case 3 : return "Raw";
+ case 9 : return "Color-mapped + RLE";
+ case 10 :
+ case 11 : return "RLE";
+ case 32 :
+ case 33 : return "Huffman";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Tga_Image_Type_ColorSpace(int8u Image_Type)
+{
+ switch (Image_Type)
+ {
+ case 1 :
+ case 2 :
+ case 9 :
+ case 10 :
+ case 32 :
+ case 33 : return "RGB";
+ case 3 :
+ case 11 : return "Y";
+ default : return "";
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Tga::File_Tga()
+{
+ //Configuration
+ ParserName=_T("TGA");
+ Buffer_MaximumSize=64*1024*1024; //We need to load the complete file for footer check, choosing an high value for an image
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Tga::Streams_Fill()
+{
+ Fill(Stream_General, 0, General_Format, "TGA");
+ Fill(Stream_General, 0, General_Format_Version, _T("Version ")+Ztring::ToZtring(Version));
+ Fill(Stream_General, 0, General_Title, Image_ID);
+
+ Stream_Prepare(Stream_Image);
+ Fill(Stream_Image, 0, Image_Format, Tga_Image_Type_Compression(Image_Type));
+ Fill(Stream_Image, 0, Image_ColorSpace, Tga_Image_Type_ColorSpace(Image_Type));
+ Fill(Stream_Image, 0, Image_CodecID, Image_Type);
+ Fill(Stream_Image, 0, Image_Width, Image_Width_);
+ Fill(Stream_Image, 0, Image_Height, Image_Height_);
+ Fill(Stream_Image, 0, Image_BitDepth, Pixel_Depth);
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Tga::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<File_Size)
+ return false; //Must wait for more data
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Tga::Read_Buffer_Continue()
+{
+ //Parsing
+ Tga_File_Header();
+ Image_Color_Map_Data();
+ Tga_File_Footer();
+
+ FILLING_BEGIN();
+ //Coherency in case of no magic value
+ if (Version==1)
+ {
+ switch (Image_Type)
+ {
+ case 1 : //Color mapped images
+ case 9 : //Color mapped images, RLE
+ if (Color_Map_Type!=1)
+ {
+ Reject();
+ return;
+ }
+ break;
+ case 2 : //True-color images
+ case 10 : //True-color images, RLE
+ if (Color_Map_Type)
+ {
+ Reject();
+ return;
+ }
+ break;
+ case 3 : //Black and White
+ case 11 : //Black and White, RLE
+ if (Color_Map_Type)
+ {
+ Reject();
+ return;
+ }
+ break;
+ default : Reject();
+ return;
+ }
+ switch (Color_Map_Type)
+ {
+ case 0 :
+ if (First_Entry_Index || Color_map_Length || Color_map_Entry_Size)
+ {
+ Reject();
+ return;
+ }
+ break;
+ case 1 :
+ switch (Color_map_Entry_Size)
+ {
+ case 15 :
+ case 16 :
+ case 24 :
+ case 32 :
+ break;
+ default : Reject();
+ return;
+ ;
+ }
+ break;
+ default : Reject();
+ return;
+ }
+ switch (Pixel_Depth)
+ {
+ case 8 :
+ case 16 :
+ case 24 :
+ case 32 :
+ break;
+ default : Reject();
+ return;
+ ;
+ }
+ }
+
+ Accept();
+ Fill();
+ Finish();
+ FILLING_END();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Tga::Tga_File_Header()
+{
+ //Parsing
+ Element_Begin1("Tga File Header");
+ Get_L1 (ID_Length, "ID Length");
+ Get_L1 (Color_Map_Type, "Color Map Type");
+ Get_L1 (Image_Type, "Image Type"); Param_Info1(Tga_Image_Type_Compression(Image_Type));
+ Element_End0();
+ Element_Begin1("Color Map Specification");
+ Get_L2 (First_Entry_Index, "First Entry Index");
+ Get_L2 (Color_map_Length, "Color map Length");
+ Get_L1 (Color_map_Entry_Size, "Color map Entry Size");
+ Element_End0();
+ Element_Begin1("Image Specification");
+ Skip_L2( "X-origin of Image");
+ Skip_L2( "Y-origin of Image");
+ Get_L2 (Image_Width_, "Image Width");
+ Get_L2 (Image_Height_, "Image Height");
+ Get_L1 (Pixel_Depth, "Pixel Depth");
+ Get_L1 (Image_Descriptor, "Image Descriptor");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Tga::Image_Color_Map_Data()
+{
+ Element_Begin1("Image/Color Map Data");
+ Get_Local(ID_Length, Image_ID, "Image ID");
+ if (Color_Map_Type==1)
+ {
+ int64u EntrySizeInBits=8;
+ if (Color_map_Entry_Size<24)
+ EntrySizeInBits=Color_map_Entry_Size/3;
+
+ Skip_XX(Color_map_Length*EntrySizeInBits/8, "Color Map Data");
+
+ }
+ if (Element_Offset+26<Element_Size
+ && Buffer[Buffer_Size- 18]==0x54
+ && Buffer[Buffer_Size- 17]==0x52
+ && Buffer[Buffer_Size- 16]==0x55
+ && Buffer[Buffer_Size- 15]==0x45
+ && Buffer[Buffer_Size- 14]==0x56
+ && Buffer[Buffer_Size- 13]==0x49
+ && Buffer[Buffer_Size- 12]==0x53
+ && Buffer[Buffer_Size- 11]==0x49
+ && Buffer[Buffer_Size- 10]==0x4F
+ && Buffer[Buffer_Size- 9]==0x4E
+ && Buffer[Buffer_Size- 8]==0x2D
+ && Buffer[Buffer_Size- 7]==0x58
+ && Buffer[Buffer_Size- 6]==0x46
+ && Buffer[Buffer_Size- 5]==0x49
+ && Buffer[Buffer_Size- 4]==0x4C
+ && Buffer[Buffer_Size- 3]==0x45
+ && Buffer[Buffer_Size- 2]==0x2E
+ && Buffer[Buffer_Size- 1]==0x00)
+ Version=2;
+ else
+ Version=1;
+ Skip_XX(Element_Size-Element_Offset-(Version==2?26:0), "Image Data");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Tga::Tga_File_Footer()
+{
+ if (Version==1)
+ return; //No footer
+
+ Element_Begin1("Image/color Map Data");
+ Skip_L4( "Extension Area Offset");
+ Skip_L4( "Developer Directory Offset");
+ Skip_Local(16, "Signature");
+ Skip_Local( 1, "Reserved Character");
+ Skip_L1( "Binary Zero String Terminator");
+ Element_End0();
+}
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tga.h b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tga.h
new file mode 100644
index 000000000..07395eb7c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tga.h
@@ -0,0 +1,80 @@
+// File_Tga - Info for TGA files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about TGA files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_TgaH
+#define MediaInfo_File_TgaH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Tga
+//***************************************************************************
+
+class File_Tga : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Tga();
+
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+
+ //Elements
+ void Tga_File_Header();
+ void Image_Color_Map_Data();
+ void Tga_File_Footer();
+
+ //Temp - File Header
+ int16u First_Entry_Index;
+ int16u Color_map_Length;
+ int16u Image_Width_;
+ int16u Image_Height_;
+ int8u ID_Length;
+ int8u Color_Map_Type;
+ int8u Image_Type;
+ int8u Color_map_Entry_Size;
+ int8u Pixel_Depth;
+ int8u Image_Descriptor;
+
+ //Temp - File Footer
+ Ztring Image_ID;
+ int8u Version;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tiff.cpp b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tiff.cpp
new file mode 100644
index 000000000..37374f2a2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tiff.cpp
@@ -0,0 +1,558 @@
+// File_Tiff - Info for TIFF files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// TIFF - Format
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// From
+// http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf
+// http://www.fileformat.info/format/tiff/
+// http://en.wikipedia.org/wiki/Tagged_Image_File_Format
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_TIFF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Image/File_Tiff.h"
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+namespace Tiff_Tag
+{
+ const int16u ImageWidth = 256;
+ const int16u ImageLength = 257;
+ const int16u BitsPerSample = 258;
+ const int16u Compression = 259;
+ const int16u PhotometricInterpretation = 262;
+ const int16u ImageDescription = 270;
+ const int16u SamplesPerPixel = 277;
+ const int16u ExtraSamples = 338;
+}
+
+//---------------------------------------------------------------------------
+const char* Tiff_Tag_Name(int32u Tag)
+{
+ switch (Tag)
+ {
+ case Tiff_Tag::ImageWidth : return "ImageWidth";
+ case Tiff_Tag::ImageLength : return "ImageLength";
+ case Tiff_Tag::BitsPerSample : return "BitsPerSample";
+ case Tiff_Tag::Compression : return "Compression";
+ case Tiff_Tag::PhotometricInterpretation : return "PhotometricInterpretation";
+ case Tiff_Tag::ImageDescription : return "ImageDescription";
+ case Tiff_Tag::SamplesPerPixel : return "SamplesPerPixel";
+ case Tiff_Tag::ExtraSamples : return "ExtraSamples";
+ default : return "Unknown";
+ }
+}
+
+//---------------------------------------------------------------------------
+namespace Tiff_Type
+{
+ const int16u Byte = 1;
+ const int16u Short = 3;
+ const int16u Long = 4;
+}
+
+//---------------------------------------------------------------------------
+const char* Tiff_Type_Name(int32u Type)
+{
+ switch (Type)
+ {
+ case Tiff_Type::Byte : return "Byte";
+ case Tiff_Type::Short : return "Short";
+ case Tiff_Type::Long : return "Long";
+ default : return ""; //Unknown
+ }
+}
+
+//---------------------------------------------------------------------------
+const int8u Tiff_Type_Size(int32u Type)
+{
+ switch (Type)
+ {
+ case Tiff_Type::Byte : return 1;
+ case Tiff_Type::Short : return 2;
+ case Tiff_Type::Long : return 4;
+ default : return 0; //Unknown
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Tiff_Compression(int32u Compression)
+{
+ switch (Compression)
+ {
+ case 1 : return "Raw";
+ case 2 : return "CCITT Group 3";
+ case 3 : return "CCITT T.4";
+ case 5 : return "LZW";
+ case 6 : return "JPEG";
+ case 32773 : return "PackBits";
+ default : return ""; //Unknown
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Tiff_Compression_Mode(int32u Compression)
+{
+ switch (Compression)
+ {
+ case 1 :
+ case 2 :
+ case 3 :
+ case 5 :
+ case 32773 : return "Lossless";
+ default : return ""; //Unknown or depends of the compresser (e.g. JPEG can be lossless or lossy)
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Tiff_PhotometricInterpretation(int32u PhotometricInterpretation)
+{
+ switch (PhotometricInterpretation)
+ {
+ case 0 :
+ case 1 : return "B/W or Grey scale";
+ case 2 : return "RGB";
+ case 3 : return "Palette";
+ case 4 : return "Transparency mask";
+ case 5 : return "CMYK";
+ case 6 : return "YCbCr";
+ case 8 : return "CIELAB";
+ default : return ""; //Unknown
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Tiff_PhotometricInterpretation_ColorSpace (int32u PhotometricInterpretation)
+{
+ switch (PhotometricInterpretation)
+ {
+ case 0 :
+ case 1 : return "Y";
+ case 2 : return "RGB";
+ case 3 : return "RGB"; //Palette
+ case 4 : return "A"; //Transparency mask;
+ case 5 : return "CMYK";
+ case 6 : return "YUV"; //YCbCr
+ case 8 : return "CIELAB"; //What is it?
+ default : return ""; //Unknown
+ }
+}
+
+const char* Tiff_ExtraSamples(int32u ExtraSamples)
+{
+ switch (ExtraSamples)
+ {
+ case 0 :
+ case 1 : return "Associated Alpha";
+ case 2 : return "Unassocieted Alpha";
+ default : return ""; //Unknown
+ }
+}
+
+const char* Tiff_ExtraSamples_ColorSpace(int32u ExtraSamples)
+{
+ switch (ExtraSamples)
+ {
+ case 1 : return "A";
+ default : return ""; //Unknown
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Tiff::File_Tiff()
+{
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Tiff::FileHeader_Begin()
+{
+ //Element_Size
+ /* Minimum header for a tiff file is 8 byte */
+ if (Buffer_Size<8)
+ return false; //Must wait for more data
+ if (CC4(Buffer)==0x49492A00)
+ LittleEndian = true;
+ else if (CC4(Buffer)==0x4D4D002A)
+ LittleEndian = false;
+ else
+ {
+ Reject("TIFF");
+ return false;
+ }
+
+ //All should be OK...
+ Accept("TIFF");
+ Fill(Stream_General, 0, General_Format, "TIFF");
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Tiff::FileHeader_Parse()
+{
+ //The only IFD that is known at forehand is the first one, it's offset is placed byte 4-7 in the file.
+ int32u IFDOffset;
+ Skip_B4( "Magic");
+ Get_X4 (IFDOffset, "IFDOffset");
+
+ FILLING_BEGIN();
+ //Initial IFD
+ GoTo(IFDOffset, "TIFF");
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Tiff::Header_Parse()
+{
+ //Handling remaining IFD data
+ if (!IfdItems.empty())
+ {
+ if (File_Offset+Buffer_Offset!=IfdItems.begin()->first)
+ IfdItems.clear(); //There was a problem during the seek, trashing remaining positions from last IFD
+ else
+ {
+ Header_Fill_Code(IfdItems.begin()->second.Tag, Tiff_Tag_Name(IfdItems.begin()->second.Tag));
+ Header_Fill_Size(Tiff_Type_Size(IfdItems.begin()->second.Type)*IfdItems.begin()->second.Count);
+ return;
+ }
+ }
+
+ /* A tiff images consist in principle of two types of blocks, IFD's and data blocks */
+ /* Each datablock, which could be a image, tiles, transperancy filter is described by one IFD. */
+ /* These IFD's can be placed at any offset in the file and are linked in a chain fashion way. */
+ /* where one IFD points out where the next IFD is placed */
+ /* */
+ /* A creator of a tiff file must describe the "main image" in the first IFD, this means that a */
+ /* reader, such this one, only need to read the first IFD in order to get the bitdepth, resolution etc. */
+ /* of the main image. */
+
+ /* Read one IFD and print out the result */
+
+ /* Scan the tiff file for the IFD's (Image File Directory) */
+ /* As long as the IFD offset to the next IFD in the file is not 0 */
+
+ /* Get number of directories for this IFD */
+ int16u NrOfDirectories;
+ Get_X2 (NrOfDirectories, "NrOfDirectories");
+
+ //Filling
+ Header_Fill_Code(0xFFFFFFFF, "IFD"); //OxFFFFFFFF can not be a Tag, so using it as a magic value
+ Header_Fill_Size(2+12*((int64u)NrOfDirectories)+4); //2 for header + 12 per directory + 4 for next IFD offset
+}
+
+//---------------------------------------------------------------------------
+void File_Tiff::Data_Parse()
+{
+ int32u IFDOffset=0;
+ if (IfdItems.empty())
+ {
+ //Default values
+ Infos.clear();
+ Infos[Tiff_Tag::BitsPerSample]=_T("1");
+
+ //Parsing new IFD
+ while (Element_Offset+4<Element_Size)
+ Read_Directory();
+ Get_X4 (IFDOffset, "IFDOffset");
+ }
+ else
+ {
+ //Handling remaining IFD data from a previous IFD
+ GetValueOffsetu(IfdItems.begin()->second); //Parsing the IFD item
+ IfdItems.erase(IfdItems.begin()->first); //Removing IFD item from the list of IFD items to parse
+ }
+
+ //Some items are not inside the directory, jumping to the offset
+ if (!IfdItems.empty())
+ GoTo(IfdItems.begin()->first, "TIFF");
+ else
+ {
+ //This IFD is finished, filling data then going to next IFD
+ Data_Parse_Fill();
+ if (IFDOffset)
+ GoTo(IFDOffset, "TIFF");
+ else
+ Finish(); //No more IFDs
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Tiff::Data_Parse_Fill()
+{
+ Stream_Prepare(Stream_Image);
+
+ infos::iterator Info;
+
+ //Width
+ Info=Infos.find(Tiff_Tag::ImageWidth);
+ if (Info!=Infos.end())
+ Fill(Stream_Image, StreamPos_Last, Image_Width, Info->second.Read());
+
+ //Height
+ Info=Infos.find(Tiff_Tag::ImageLength);
+ if (Info!=Infos.end())
+ Fill(Stream_Image, StreamPos_Last, Image_Height, Info->second.Read());
+
+ //BitsPerSample
+ Info=Infos.find(Tiff_Tag::BitsPerSample);
+ if (Info!=Infos.end())
+ Fill(Stream_Image, StreamPos_Last, Image_BitDepth, Info->second.Read());
+
+ //Compression
+ Info=Infos.find(Tiff_Tag::Compression);
+ if (Info!=Infos.end())
+ {
+ int32u Value=Info->second.Read().To_int32u();
+ Fill(Stream_Image, StreamPos_Last, Image_Format, Tiff_Compression(Value));
+ Fill(Stream_Image, StreamPos_Last, Image_Codec, Tiff_Compression(Value));
+ Fill(Stream_Image, StreamPos_Last, Image_Compression_Mode, Tiff_Compression_Mode(Value));
+ }
+
+ //PhotometricInterpretation
+ Info=Infos.find(Tiff_Tag::PhotometricInterpretation);
+ if (Info!=Infos.end())
+ {
+ int32u Value=Info->second.Read().To_int32u();
+ Fill(Stream_Image, StreamPos_Last, Image_ColorSpace, Tiff_PhotometricInterpretation_ColorSpace(Value));
+ //Note: should we differeniate between raw RGB and palette (also RGB actually...)
+ }
+
+ //ImageDescription
+ Info=Infos.find(Tiff_Tag::ImageDescription);
+ if (Info!=Infos.end())
+ Fill(Stream_Image, StreamPos_Last, Image_Title, Info->second.Read());
+
+ //ExtraSamples
+ Info=Infos.find(Tiff_Tag::ExtraSamples);
+ if (Info!=Infos.end())
+ {
+ Ztring ColorSpace=Retrieve(Stream_Image, StreamPos_Last, Image_ColorSpace);
+ ColorSpace+=Ztring().From_Local(Tiff_ExtraSamples_ColorSpace(Info->second.Read().To_int32u()));
+ Fill(Stream_Image, StreamPos_Last, Image_ColorSpace, ColorSpace, true);
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Tiff::Read_Directory()
+{
+ /* Each directory consist of 4 fields */
+ /* Get information for this directory */
+ Element_Begin0();
+ ifditem IfdItem;
+ Get_X2 (IfdItem.Tag, "Tag"); Param_Info1(Tiff_Tag_Name(IfdItem.Tag));
+ Get_X2 (IfdItem.Type, "Type"); Param_Info1(Tiff_Type_Name(IfdItem.Type));
+ Get_X4 (IfdItem.Count, "Count");
+ Element_Name(Tiff_Tag_Name(IfdItem.Tag));
+
+ if (Tiff_Type_Size(IfdItem.Type)*IfdItem.Count<=4)
+ {
+ GetValueOffsetu(IfdItem);
+
+ /* Padding up, skip dummy bytes */
+ if (Tiff_Type_Size(IfdItem.Type)*IfdItem.Count<4)
+ Skip_XX(Tiff_Type_Size(IfdItem.Type)*IfdItem.Count, "Padding");
+ }
+ else
+ {
+ int32u IFDOffset;
+ Get_X4 (IFDOffset, "IFDOffset");
+ IfdItems[IFDOffset]=IfdItem;
+ }
+ Element_End0();
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Tiff::Get_X2(int16u &Info, const char* Name)
+{
+ if (LittleEndian)
+ Get_L2 (Info, Name);
+ else
+ Get_B2 (Info, Name);
+}
+
+//---------------------------------------------------------------------------
+void File_Tiff::Get_X4(int32u &Info, const char* Name)
+{
+ if (LittleEndian)
+ Get_L4 (Info, Name);
+ else
+ Get_B4 (Info, Name);
+}
+
+//---------------------------------------------------------------------------
+void File_Tiff::GetValueOffsetu(ifditem &IfdItem)
+{
+ ZtringList &Info=Infos[IfdItem.Tag]; Info.clear(); Info.Separator_Set(0, _T(" / "));
+ const char* Name=Tiff_Tag_Name(IfdItem.Tag);
+
+ if (IfdItem.Count>=10)
+ {
+ //Too many data, we don't currently need it and we skip it
+ Skip_XX(Element_Size, Name);
+ Info.clear();
+ return;
+ }
+
+ switch (IfdItem.Type)
+ {
+ case 1: /* 8-bit unsigned integer. */
+ for (int16u Pos=0; Pos<IfdItem.Count; Pos++)
+ {
+ int8u Ret8;
+ #if MEDIAINFO_TRACE
+ if (LittleEndian)
+ Get_L1 (Ret8, Name);
+ else
+ Get_B1 (Ret8, Name);
+ Element_Info1(Ztring::ToZtring(Ret8));
+ #else //MEDIAINFO_TRACE
+ if (Element_Offset+1>Element_Size)
+ {
+ Trusted_IsNot();
+ break;
+ }
+ if (LittleEndian)
+ Ret8=LittleEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ else
+ Ret8=BigEndian2int8u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset++;
+ #endif //MEDIAINFO_TRACE
+ Info.push_back(Ztring::ToZtring(Ret8));
+ }
+ break;
+
+ case 3: /* 16-bit (2-byte) unsigned integer. */
+ for (int16u Pos=0; Pos<IfdItem.Count; Pos++)
+ {
+ int16u Ret16;
+ #if MEDIAINFO_TRACE
+ if (LittleEndian)
+ Get_L2 (Ret16, Name);
+ else
+ Get_B2 (Ret16, Name);
+ switch (IfdItem.Tag)
+ {
+ case Tiff_Tag::Compression : Element_Info1(Tiff_Compression(Ret16)); break;
+ case Tiff_Tag::PhotometricInterpretation : Element_Info1(Tiff_PhotometricInterpretation(Ret16)); break;
+ default : Element_Info1(Ztring::ToZtring(Ret16));
+ }
+ #else //MEDIAINFO_TRACE
+ if (Element_Offset+2>Element_Size)
+ {
+ Trusted_IsNot();
+ break;
+ }
+ if (LittleEndian)
+ Ret16=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ else
+ Ret16=BigEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=2;
+ #endif //MEDIAINFO_TRACE
+ Info.push_back(Ztring::ToZtring(Ret16));
+ }
+ break;
+
+ case 4: /* 32-bit (4-byte) unsigned integer */
+ for (int16u Pos=0; Pos<IfdItem.Count; Pos++)
+ {
+ int32u Ret32;
+ #if MEDIAINFO_TRACE
+ if (LittleEndian)
+ Get_L4 (Ret32, Name);
+ else
+ Get_B4 (Ret32, Name);
+ Element_Info1(Ztring::ToZtring(Ret32));
+ #else //MEDIAINFO_TRACE
+ if (Element_Offset+4>Element_Size)
+ {
+ Trusted_IsNot();
+ break;
+ }
+ if (LittleEndian)
+ Ret32=LittleEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ else
+ Ret32=BigEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=4;
+ #endif //MEDIAINFO_TRACE
+ Info.push_back(Ztring::ToZtring(Ret32));
+ }
+ break;
+
+ default: //Unknown
+ {
+ if (LittleEndian)
+ Skip_L4( Name);
+ else
+ Skip_B4( Name);
+ Info.clear(); //We actually do not know the type
+ }
+ }
+}
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tiff.h b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tiff.h
new file mode 100644
index 000000000..c1e242086
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Image/File_Tiff.h
@@ -0,0 +1,81 @@
+// File_Tiff - Info for TIFF files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about TIFF files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_TiffH
+#define MediaInfo_File_TiffH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Tiff
+//***************************************************************************
+
+class File_Tiff : public File__Analyze
+{
+public:
+ //Constructor/Destructor
+ File_Tiff();
+
+private :
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+ void Data_Parse_Fill();
+
+ //Elements
+ void Read_Directories();
+ void Read_Directory();
+
+ //Temp
+ struct ifditem
+ {
+ int16u Tag;
+ int16u Type;
+ int32u Count;
+ };
+ typedef std::map<int32u, ifditem> ifditems; //Key is byte offset
+ ifditems IfdItems;
+ typedef std::map<int16u, ZtringList> infos; //Key is Tag value
+ infos Infos;
+ bool LittleEndian;
+
+ //Helpers
+ void Get_X2 (int16u &Info, const char* Name);
+ void Get_X4 (int32u &Info, const char* Name);
+ void GetValueOffsetu(ifditem &IfdItem);
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo.cpp b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo.cpp
new file mode 100644
index 000000000..986f5fb10
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo.cpp
@@ -0,0 +1,247 @@
+// MediaInfo - All info about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+//To clarify the code
+namespace MediaInfo_Debug_MediaInfo
+{
+
+#if defined (MEDIAINFO_DEBUG_CONFIG) || defined (MEDIAINFO_DEBUG_BUFFER) || defined (MEDIAINFO_DEBUG_OUTPUT)
+ #ifdef WINDOWS
+ const Char* MediaInfo_Debug_Name=_T("MediaInfo_Debug");
+ #else
+ const Char* MediaInfo_Debug_Name=_T("/tmp/MediaInfo_Debug");
+ #endif
+#endif
+
+#ifdef MEDIAINFO_DEBUG_CONFIG
+ #define MEDIAINFO_DEBUG_STATIC(_TOAPPEND) \
+ { \
+ File F(Ztring(MediaInfo_Debug_Name)+_T(".Config.static.txt"), File::Access_Write_Append); \
+ Ztring Debug; \
+ _TOAPPEND; \
+ Debug+=_T("\r\n"); \
+ F.Write(Debug); \
+ F.Close(); \
+ }
+#else // MEDIAINFO_DEBUG_CONFIG
+ #define MEDIAINFO_DEBUG_STATIC(_TOAPPEND)
+#endif // MEDIAINFO_DEBUG_CONFIG
+
+}
+using namespace MediaInfo_Debug_MediaInfo;
+
+//***************************************************************************
+// Constructor/destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+MediaInfo::MediaInfo()
+{
+ Internal=new MediaInfo_Internal();
+}
+
+//---------------------------------------------------------------------------
+MediaInfo::~MediaInfo()
+{
+ delete (MediaInfo_Internal*)Internal; //Internal=NULL;
+}
+
+//***************************************************************************
+// Files
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Open(const String &File_Name_)
+{
+ return ((MediaInfo_Internal*)Internal)->Open(File_Name_);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Open (const int8u* Begin, size_t Begin_Size, const int8u* End, size_t End_Size, int64u File_Size)
+{
+ return ((MediaInfo_Internal*)Internal)->Open(Begin, Begin_Size, End, End_Size, (File_Size<Begin_Size+End_Size)?(Begin_Size+End_Size):File_Size);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Open_Buffer_Init (int64u File_Size, int64u File_Offset)
+{
+ return ((MediaInfo_Internal*)Internal)->Open_Buffer_Init(File_Size, File_Offset);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Open_Buffer_Continue (const int8u* ToAdd, size_t ToAdd_Size)
+{
+ return ((MediaInfo_Internal*)Internal)->Open_Buffer_Continue(ToAdd, ToAdd_Size).to_ulong();
+}
+
+//---------------------------------------------------------------------------
+int64u MediaInfo::Open_Buffer_Continue_GoTo_Get ()
+{
+ return ((MediaInfo_Internal*)Internal)->Open_Buffer_Continue_GoTo_Get();
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Open_Buffer_Finalize ()
+{
+ return ((MediaInfo_Internal*)Internal)->Open_Buffer_Finalize();
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Open_NextPacket ()
+{
+ return ((MediaInfo_Internal*)Internal)->Open_NextPacket().to_ulong();;
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Save()
+{
+ return 0; //Not yet implemented
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo::Close()
+{
+ return ((MediaInfo_Internal*)Internal)->Close();
+}
+
+//***************************************************************************
+// Get File info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+String MediaInfo::Inform(size_t)
+{
+ return ((MediaInfo_Internal*)Internal)->Inform();
+}
+
+//---------------------------------------------------------------------------
+String MediaInfo::Get(stream_t StreamKind, size_t StreamPos, size_t Parameter, info_t KindOfInfo)
+{
+ return ((MediaInfo_Internal*)Internal)->Get(StreamKind, StreamPos, Parameter, KindOfInfo);
+}
+
+//---------------------------------------------------------------------------
+String MediaInfo::Get(stream_t StreamKind, size_t StreamPos, const String &Parameter, info_t KindOfInfo, info_t KindOfSearch)
+{
+ return ((MediaInfo_Internal*)Internal)->Get(StreamKind, StreamPos, Parameter, KindOfInfo, KindOfSearch);
+}
+
+//***************************************************************************
+// Set File info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Set(const String &, stream_t, size_t, size_t, const String &)
+{
+ return 0; //Not yet implemented
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Set(const String &, stream_t, size_t, const String &, const String &)
+{
+ return 0; //Not yet implemented
+}
+
+//***************************************************************************
+// Output buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Output_Buffer_Get (const String &Value)
+{
+ return ((MediaInfo_Internal*)Internal)->Output_Buffer_Get(Value);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Output_Buffer_Get (size_t Pos)
+{
+ return ((MediaInfo_Internal*)Internal)->Output_Buffer_Get(Pos);
+}
+
+//***************************************************************************
+// Information
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+String MediaInfo::Option (const String &Option, const String &Value)
+{
+ return ((MediaInfo_Internal*)Internal)->Option(Option, Value);
+}
+
+//---------------------------------------------------------------------------
+String MediaInfo::Option_Static (const String &Option, const String &Value)
+{
+ MEDIAINFO_DEBUG_STATIC(Debug+=_T("Option_Static, Option=");Debug+=Ztring(Option);Debug+=_T(", Value=");Debug+=Ztring(Value);)
+ MediaInfoLib::Config.Init(); //Initialize Configuration
+
+ if (Option==_T("Info_Capacities"))
+ {
+ return _T("Option disactivated for this version, will come back soon!");
+ //MediaInfo_Internal MI;
+ //return MI.Option(Option);
+ }
+ else if (Option==_T("Info_Version"))
+ {
+ Ztring ToReturn=MediaInfoLib::Config.Info_Version_Get();
+ if (MediaInfo_Internal::LibraryIsModified())
+ ToReturn+=_T(" modified");
+ return ToReturn;
+ }
+ else
+ return MediaInfoLib::Config.Option(Option, Value);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::Count_Get (stream_t StreamKind, size_t StreamPos)
+{
+ return ((MediaInfo_Internal*)Internal)->Count_Get(StreamKind, StreamPos);
+
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo::State_Get ()
+{
+ return ((MediaInfo_Internal*)Internal)->State_Get();
+}
+
+} //NameSpace
+
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo.h b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo.h
new file mode 100644
index 000000000..293d9cabf
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo.h
@@ -0,0 +1,257 @@
+// MediaInfo - All information about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Give information about a lot of media files
+// Dispatch the file to be tested by all containers
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfoH
+#define MediaInfoH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo_Const.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#undef MEDIAINFO_EXP
+#if defined(_WIN32) && !defined(__MINGW32__) //MinGW32 does not support _declspec
+ #ifdef MEDIAINFO_DLL_EXPORT
+ #define MEDIAINFO_EXP
+ #else
+ #define MEDIAINFO_EXP
+ #endif
+#else //defined(_WIN32) && !defined(__MINGW32__)
+ #if __GNUC__ >= 4
+ #define MEDIAINFO_EXP __attribute__ ((visibility("default")))
+ #else
+ #define MEDIAINFO_EXP
+ #endif
+#endif //defined(_WIN32) && !defined(__MINGW32__)
+
+#if !defined(__WINDOWS__)
+ #define __stdcall //Supported only on windows
+#endif //!defined(_WIN32)
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class File__Analyze;
+class Internet__Base;
+
+//***************************************************************************
+/// @brief MediaInfo
+/// @version 0.7
+//***************************************************************************
+
+class MEDIAINFO_EXP MediaInfo
+{
+public :
+ //Constructor/Destructor
+ MediaInfo ();
+ ~MediaInfo ();
+ //File
+ /// Open a file and collect information about it (technical information and tags)
+ /// @brief Open a file
+ /// @param File_Name Full name of file to open
+ /// @retval 0 File not opened
+ /// @retval 1 File opened
+ size_t Open (const String &File_Name);
+ /// Open a Buffer (Begin and end of the stream) and collect information about it (technical information and tags)
+ /// @brief Open a buffer
+ /// @param Begin First bytes of the buffer
+ /// @param Begin_Size Size of Begin
+ /// @param End Last bytes of the buffer
+ /// @param End_Size Size of End
+ /// @param File_Size Total size of the file
+ /// @retval 0 File not opened
+ /// @retval 1 File opened
+ size_t Open (const ZenLib::int8u* Begin, size_t Begin_Size, const ZenLib::int8u* End=NULL, size_t End_Size=0, ZenLib::int64u File_Size=0);
+ /// Open a stream and collect information about it (technical information and tags)
+ /// @brief Open a stream (Init)
+ /// @param File_Size Estimated file size
+ /// @param File_Offset Offset of the file (if we don't have the beginning of the file)
+ size_t Open_Buffer_Init (ZenLib::int64u File_Size=(ZenLib::int64u)-1, ZenLib::int64u File_Offset=0);
+ /// Open a stream and collect information about it (technical information and tags)
+ /// @brief Open a stream (Continue)
+ /// @param Buffer pointer to the stream
+ /// @param Buffer_Size Count of bytes to read
+ /// @return a bitfield \n
+ /// bit 0: Is Accepted (format is known)
+ /// bit 1: Is Filled (main data is collected)
+ /// bit 2: Is Updated (some data have beed updated, example: duration for a real time MPEG-TS stream)
+ /// bit 3: Is Finalized (No more data is needed, will not use further data)
+ /// bit 4-15: Reserved
+ /// bit 16-31: User defined
+ size_t Open_Buffer_Continue (const ZenLib::int8u* Buffer, size_t Buffer_Size);
+ /// Open a stream and collect information about it (technical information and tags)
+ /// @brief Open a stream (Get the needed file Offset)
+ /// @return the needed offset of the file \n
+ /// File size if no more bytes are needed
+ ZenLib::int64u Open_Buffer_Continue_GoTo_Get ();
+ /// Open a stream and collect information about it (technical information and tags)
+ /// @brief Open a stream (Finalize)
+ size_t Open_Buffer_Finalize ();
+ /// If Open() is used in "PerPacket" mode, parse only one packet and return
+ /// @brief Read one packet (if "PerPacket" mode is set)
+ /// @return a bitfield \n
+ /// bit 0: A packet was read
+ size_t Open_NextPacket ();
+ /// (NOT IMPLEMENTED YET) Save the file opened before with Open() (modifications of tags)
+ /// @brief (NOT IMPLEMENTED YET) Save the file
+ /// @retval 0 failed
+ /// @retval 1 suceed
+ size_t Save ();
+ /// Close a file opened before with Open() (without saving)
+ /// @brief Close a file
+ /// @warning without have saved before, modifications are lost
+ void Close ();
+
+ //General information
+ /// Get all details about a file in one string
+ /// @brief Get all details about a file
+ /// @pre You can change default presentation with Inform_Set()
+ String Inform (size_t Reserved=0);
+
+ //Get
+ /// Get a piece of information about a file (parameter is an integer)
+ /// @brief Get a piece of information about a file (parameter is an integer)
+ /// @param StreamKind Kind of stream (general, video, audio...)
+ /// @param StreamNumber Stream number in Kind of stream (first, second...)
+ /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...)
+ /// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...)
+ /// @return a string about information you search \n
+ /// an empty string if there is a problem
+ String Get (stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind=Info_Text);
+ /// Get a piece of information about a file (parameter is a string)
+ /// @brief Get a piece of information about a file (parameter is a string)
+ /// @param StreamKind Kind of stream (general, video, audio...)
+ /// @param StreamNumber Stream number in Kind of stream (first, second...)
+ /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n
+ /// See MediaInfo::Option("Info_Parameters") to have the full list
+ /// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...)
+ /// @param SearchKind Where to look for the parameter
+ /// @return a string about information you search \n
+ /// an empty string if there is a problem
+ String Get (stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind=Info_Text, info_t SearchKind=Info_Name);
+
+ //Set
+ /// (NOT IMPLEMENTED YET) Set a piece of information about a file (parameter is an integer)
+ /// @brief (NOT IMPLEMENTED YET) Set a piece of information about a file (parameter is an int)
+ /// @warning Not yet implemented, do not use it
+ /// @param ToSet Piece of information
+ /// @param StreamKind Kind of stream (general, video, audio...)
+ /// @param StreamNumber Stream number in Kind of stream (first, second...)
+ /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...)
+ /// @param OldValue The old value of the parameter \n if OldValue is empty and ToSet is filled: tag is added \n if OldValue is filled and ToSet is filled: tag is replaced \n if OldValue is filled and ToSet is empty: tag is deleted
+ /// @retval >0 succeed
+ /// @retval 0 failed
+ size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=String());
+ /// (NOT IMPLEMENTED YET) Set a piece of information about a file (parameter is a string)
+ /// @warning Not yet implemented, do not use it
+ /// @brief (NOT IMPLEMENTED YET) Set information about a file (parameter is a string)
+ /// @param ToSet Piece of information
+ /// @param StreamKind Kind of stream (general, video, audio...)
+ /// @param StreamNumber Stream number in Kind of stream (first, second...)
+ /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format
+ /// @param OldValue The old value of the parameter \n if OldValue is empty and ToSet is filled: tag is added \n if OldValue is filled and ToSet is filled: tag is replaced \n if OldValue is filled and ToSet is empty: tag is deleted
+ /// @retval >0 succeed
+ /// @retval 0 failed
+ size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=String());
+
+ //Output_Buffered
+ /// Output the written size when "File_Duplicate" option is used.
+ /// @brief Output the written size when "File_Duplicate" option is used.
+ /// @param Value The unique name of the duplicated stream (begin with "memory://")
+ /// @return The size of the used buffer
+ size_t Output_Buffer_Get (const String &Value);
+ /// Output the written size when "File_Duplicate" option is used.
+ /// @brief Output the written size when "File_Duplicate" option is used.
+ /// @param Value The order of calling
+ /// @return The size of the used buffer
+ size_t Output_Buffer_Get (size_t Pos);
+
+ //Info
+ /// Configure or get information about MediaInfoLib
+ /// @param Option The name of option
+ /// @param Value The value of option
+ /// @return Depend of the option: by default "" (nothing) means No, other means Yes
+ /// @post Known options are: \n
+ /// * (NOT IMPLEMENTED YET) "BlockMethod": Configure when Open Method must return (default or not command not understood: "1") \n
+ /// "0": Immediatly \n
+ /// "1": After geting local information \n
+ /// "2": When user interaction is needed, or whan Internet information is get
+ /// * "Complete": For debug, configure if MediaInfoLib::Inform() show all information (doesn't care of InfoOption_NoShow tag): shows all information if true, shows only useful for user information if false (No by default)\n
+ /// * "Complete_Get": return the state of "Complete" \n
+ /// * "Language": Configure language (default language, and this object); Value is Description of language (format: "Column1;Colum2\n...) \n
+ /// Column 1: Unique name ("Bytes", "Title") \n
+ /// Column 2: translation ("Octets", "Titre") \n
+ /// * "Language_Get": Get the language file in memory
+ /// * "Language_Update": Configure language of this object only (for optimisation); Value is Description of language (format: "Column1;Colum2\n...) \n
+ /// Column 1: Unique name ("Bytes", "Title") \n
+ /// Column 2: translation ("Octets", "Titre") \n
+ /// * "Inform": Configure custom text, See MediaInfoLib::Inform() function; Description of views (format: "Column1;Colum2...) \n
+ /// Column 1: code (11 lines: "General", "Video", "Audio", "Text", "Chapters", "Begin", "End", "Page_Begin", "Page_Middle", "Page_End") \n
+ /// Column 2: The text to show (exemple: "Audio: %FileName% is at %BitRate/String%") \n
+ /// * "ParseUnknownExtensions": Configure if MediaInfo parse files with unknown extension\n
+ /// * "ParseUnknownExtensions_Get": Get if MediaInfo parse files with unknown extension\n
+ /// * "ShowFiles": Configure if MediaInfo keep in memory files with specific kind of streams (or no streams); Value is Description of components (format: "Column1;Colum2\n...) \n\n
+ /// Column 1: code (available: "Nothing" for unknown format, "VideoAudio" for at least 1 video and 1 audio, "VideoOnly" for video streams only, "AudioOnly", "TextOnly") \n
+ /// Column 2: "" (nothing) not keeping, other for keeping
+ /// * (NOT IMPLEMENTED YET) "TagSeparator": Configure the separator if there are multiple same tags (" | " by default)\n
+ /// * (NOT IMPLEMENTED YET) "TagSeparator_Get": return the state of "TagSeparator" \n
+ /// * (NOT IMPLEMENTED YET) "Internet": Authorize Internet connection (Yes by default)
+ /// * (NOT IMPLEMENTED YET) "Internet_Title_Get": When State=5000, give all possible titles for this file (one per line) \n
+ /// Form: Author TagSeparator Title TagSeparator Year\n...
+ /// * (NOT IMPLEMENTED YET) "Internet_Title_Set": Set the Good title (same as given by Internet_Title_Get) \n
+ /// Form: Author TagSeparator Title TagSeparator Year
+ /// * "Info_Parameters": Information about what are known unique names for parameters \n
+ /// * "Info_Parameters_CSV": Information about what are known unique names for parameters, in CSV format \n
+ /// * "Info_Codecs": Information about which codec is known \n
+ /// * "Info_Version": Information about the version of MediaInfoLib
+ /// * "Info_Url": Information about where to find the last version
+ String Option (const String &Option, const String &Value=String());
+ /// Configure or get information about MediaInfoLib
+ /// @param Option The name of option
+ /// @param Value The value of option
+ /// @return Depend of the option: by default "" (nothing) means No, other means Yes
+ /// @post Known options are: See MediaInfo::Option()
+ static String Option_Static (const String &Option, const String &Value=String());
+ /// @brief (NOT IMPLEMENTED YET) Get the state of the library
+ /// @retval <1000 No information is available for the file yet
+ /// @retval >=1000_<5000 Only local (into the file) information is available, getting Internet information (titles only) is no finished yet
+ /// @retval 5000 (only if Internet connection is accepted) User interaction is needed (use Option() with "Internet_Title_Get") \n
+ /// Warning: even there is only one possible, user interaction (or the software) is needed
+ /// @retval >5000<=10000 Only local (into the file) information is available, getting Internet information (all) is no finished yet
+ /// @retval <10000 Done
+ size_t State_Get ();
+ /// @brief Count of streams of a stream kind (StreamNumber not filled), or count of piece of information in this stream
+ /// @param StreamKind Kind of stream (general, video, audio...)
+ /// @param StreamNumber Stream number in this kind of stream (first, second...)
+ size_t Count_Get (stream_t StreamKind, size_t StreamNumber=(size_t)-1);
+
+private :
+ void* Internal;
+};
+
+} //NameSpace
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList.cpp b/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList.cpp
new file mode 100644
index 000000000..53b0ce38f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList.cpp
@@ -0,0 +1,260 @@
+// MediaInfoList - A list of MediaInfo
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// For user: you can disable or enable it
+//#define MEDIAINFO_DEBUG
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(__BORLANDC__) && defined (_DEBUG)
+ //Why? in Debug mode with release Wx Libs, wxAssert is not defined?
+ void wxAssert (int, const wchar_t*, int, const wchar_t*, const wchar_t*){return;}
+ void wxAssert (int, const char*, int, const char*, const char*){return;}
+#endif
+#include "MediaInfoList.h"
+#include "MediaInfoList_Internal.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+//To clarify the code
+namespace MediaInfoList_Debug
+{
+#ifdef MEDIAINFO_DEBUG
+ #include <stdio.h>
+ FILE* F;
+ std::string Debug;
+
+ #undef MEDIAINFO_DEBUG
+ #define MEDIAINFO_DEBUG(_TOAPPEND) \
+ F=fopen("MediaInfoList_Debug.txt", "a+t"); \
+ Debug.clear(); \
+ _TOAPPEND; \
+ Debug+="\r\n"; \
+ fwrite(Debug.c_str(), Debug.size(), 1, F); \
+ fclose(F);
+#else // MEDIAINFO_DEBUG
+ #define MEDIAINFO_DEBUG(_TOAPPEND)
+#endif // MEDIAINFO_DEBUG
+
+#ifdef MEDIAINFO_DEBUG
+#define EXECUTE_VOID(_METHOD,_DEBUGB) \
+ ((MediaInfo_Internal*)Internal)->_METHOD;
+#else //MEDIAINFO_DEBUG
+#define EXECUTE_VOID(_METHOD,_DEBUGB) \
+ ((MediaInfo_Internal*)Internal)->_METHOD; \
+ MEDIAINFO_DEBUG(_DEBUGB)
+#endif //MEDIAINFO_DEBUG
+
+#ifdef MEDIAINFO_DEBUG
+#define EXECUTE_INT(_METHOD,_DEBUGB) \
+ return ((MediaInfo_Internal*)Internal)->_METHOD;
+#else //MEDIAINFO_DEBUG
+#define EXECUTE_INT(_METHOD, _DEBUGB) \
+ int64u ToReturn=((MediaInfo_Internal*)Internal)->_METHOD; \
+ MEDIAINFO_DEBUG(_DEBUGB) \
+ return ToReturn;
+#endif //MEDIAINFO_DEBUG
+
+#ifdef MEDIAINFO_DEBUG
+#define EXECUTE_STRING(_METHOD,_DEBUGB) \
+ return ((MediaInfo_Internal*)Internal)->_METHOD;
+#else //MEDIAINFO_DEBUG
+#define EXECUTE_STRING(_METHOD,_DEBUGB) \
+ Ztring ToReturn=((MediaInfo_Internal*)Internal)->_METHOD; \
+ MEDIAINFO_DEBUG(_DEBUGB) \
+ return ToReturn;
+#endif //MEDIAINFO_DEBUG
+}
+using namespace MediaInfoList_Debug;
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Gestion de la classe
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Constructeurs
+MediaInfoList::MediaInfoList(size_t Count_Init)
+{
+ MEDIAINFO_DEBUG(Debug+="Construction";)
+ Internal=new MediaInfoList_Internal(Count_Init);
+}
+
+//---------------------------------------------------------------------------
+//Destructeur
+MediaInfoList::~MediaInfoList()
+{
+ MEDIAINFO_DEBUG(Debug+="Destruction";)
+ delete (MediaInfoList_Internal*)Internal; //Internal=NULL;
+}
+
+//***************************************************************************
+// Files
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList::Open(const String &File, const fileoptions_t Options)
+{
+ MEDIAINFO_DEBUG(Debug+="Open, File=";Debug+=Ztring(File).To_Local().c_str();)
+ return ((MediaInfoList_Internal*)Internal)->Open(File, Options);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList::Open_Buffer_Init (int64u File_Size_, int64u File_Offset_)
+{
+ return ((MediaInfoList_Internal*)Internal)->Open_Buffer_Init(File_Size_, File_Offset_);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList::Open_Buffer_Continue (size_t FilePos, const int8u* ToAdd, size_t ToAdd_Size)
+{
+ return ((MediaInfoList_Internal*)Internal)->Open_Buffer_Continue(FilePos, ToAdd, ToAdd_Size);
+}
+
+//---------------------------------------------------------------------------
+int64u MediaInfoList::Open_Buffer_Continue_GoTo_Get (size_t FilePos)
+{
+ return ((MediaInfoList_Internal*)Internal)->Open_Buffer_Continue_GoTo_Get(FilePos);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList::Open_Buffer_Finalize (size_t FilePos)
+{
+ return ((MediaInfoList_Internal*)Internal)->Open_Buffer_Finalize(FilePos);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList::Save(size_t)
+{
+ return 0; //Not yet implemented
+}
+
+//---------------------------------------------------------------------------
+void MediaInfoList::Close(size_t FilePos)
+{
+ ((MediaInfoList_Internal*)Internal)->Close(FilePos);
+}
+
+//***************************************************************************
+// Get File info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+String MediaInfoList::Inform(size_t FilePos, size_t)
+{
+ return ((MediaInfoList_Internal*)Internal)->Inform(FilePos);
+}
+
+//---------------------------------------------------------------------------
+String MediaInfoList::Get(size_t FilePos, stream_t KindOfStream, size_t StreamNumber, size_t Parameter, info_t KindOfInfo)
+{
+ return ((MediaInfoList_Internal*)Internal)->Get(FilePos, KindOfStream, StreamNumber, Parameter, KindOfInfo);
+}
+
+//---------------------------------------------------------------------------
+String MediaInfoList::Get(size_t FilePos, stream_t KindOfStream, size_t StreamNumber, const String &Parameter, info_t KindOfInfo, info_t KindOfSearch)
+{
+ //TRACE(Trace+=_T("Get(L), CompleteName=");Trace+=Info[FilePos].Get(Stream_General, 0, _T("CompleteName")).c_str();)
+ //TRACE(Trace+=_T("Get(L), StreamKind=");Trace+=ZenLib::Ztring::ToZtring((int8u)KindOfStream);Trace+=_T(", StreamNumber=");Trace+=ZenLib::Ztring::ToZtring((int8u)StreamNumber);Trace+=_T(", Parameter=");Trace+=ZenLib::Ztring(Parameter);Trace+=_T(", KindOfInfo=");Trace+=ZenLib::Ztring::ToZtring((int8u)KindOfInfo);Trace+=_T(", KindOfSearch=");Trace+=ZenLib::Ztring::ToZtring((int8u)KindOfSearch);)
+ //TRACE(Trace+=_T("Get(L), will return ");Trace+=Info[FilePos].Get(KindOfStream, StreamNumber, Parameter, KindOfInfo, KindOfSearch).c_str();)
+
+ return ((MediaInfoList_Internal*)Internal)->Get(FilePos, KindOfStream, StreamNumber, Parameter, KindOfInfo, KindOfSearch);
+}
+
+//***************************************************************************
+// Set File info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList::Set(const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue)
+{
+ return ((MediaInfoList_Internal*)Internal)->Set(ToSet, FilePos, StreamKind, StreamNumber, Parameter, OldValue);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList::Set(const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue)
+{
+ return ((MediaInfoList_Internal*)Internal)->Set(ToSet, FilePos, StreamKind, StreamNumber, Parameter, OldValue);
+}
+
+//***************************************************************************
+// Output buffer
+//***************************************************************************
+
+/*
+//---------------------------------------------------------------------------
+char* MediaInfoList::Output_Buffer_Get (size_t FilePos, size_t &Output_Buffer_Size)
+{
+ return ((MediaInfoList_Internal*)Internal)->Output_Buffer_Get(FilePos, Output_Buffer_Size);
+}
+*/
+
+//***************************************************************************
+// Information
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+String MediaInfoList::Option (const String &Option, const String &Value)
+{
+ return ((MediaInfoList_Internal*)Internal)->Option(Option, Value);
+
+}
+
+//---------------------------------------------------------------------------
+String MediaInfoList::Option_Static (const String &Option, const String &Value)
+{
+ return MediaInfo::Option_Static(Option, Value);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList::State_Get()
+{
+ return ((MediaInfoList_Internal*)Internal)->State_Get();
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList::Count_Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber)
+{
+ return ((MediaInfoList_Internal*)Internal)->Count_Get(FilePos, StreamKind, StreamNumber);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList::Count_Get()
+{
+ return ((MediaInfoList_Internal*)Internal)->Count_Get();
+}
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList.h b/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList.h
new file mode 100644
index 000000000..3b7891768
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList.h
@@ -0,0 +1,225 @@
+// MediaInfoList - A list of MediaInfo
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// MediaInfoList
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Give information about a lot of media files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfoListH
+#define MediaInfoListH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#undef MEDIAINFO_EXP
+#if defined(_WIN32) && !defined(__MINGW32__) //MinGW32 does not support _declspec
+ #ifdef MEDIAINFO_DLL_EXPORT
+ #define MEDIAINFO_EXP
+ #else
+ #define MEDIAINFO_EXP
+ #endif
+#else //defined(_WIN32) && !defined(__MINGW32__)
+ #if __GNUC__ >= 4
+ #define MEDIAINFO_EXP __attribute__ ((visibility("default")))
+ #else
+ #define MEDIAINFO_EXP
+ #endif
+#endif //defined(_WIN32) && !defined(__MINGW32__)
+
+#if !defined(__WINDOWS__)
+ #define __stdcall //Supported only on windows
+#endif //!defined(_WIN32)
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+/// @brief MediaInfoList
+/// @version 0.7
+//***************************************************************************
+
+class MEDIAINFO_EXP MediaInfoList
+{
+public :
+ //Class
+ /// @brief Constructor
+ /// @param Count_Init optimization information: How many files do you plan to handle?
+ MediaInfoList (size_t Count_Init=64);
+ ~MediaInfoList ();
+
+ //Files
+ /// Open one or more files and collect information about them (technical information and tags)
+ /// @brief Open files
+ /// @param File Full name of file(s) to open \n
+ /// or Full name of folder(s) to open \n
+ /// (if multiple names, names must be separated by "|")
+ /// @param Options: FileOption_Recursive = Recursive mode for folders \n
+ /// FileOption_Close = Close all already opened files before
+ /// @retval Number of files successfuly added
+ size_t Open (const String &File, const fileoptions_t Options=FileOption_Nothing);
+ /// Open a stream and collect information about it (technical information and tags)
+ /// @brief Open a stream (Init)
+ /// @param File_Size Estimated file size
+ /// @param File_Offset Offset of the file (if we don't have the beginning of the file)
+ size_t Open_Buffer_Init (ZenLib::int64u File_Size=(ZenLib::int64u)-1, ZenLib::int64u File_Offset=0);
+ /// Open a stream and collect information about it (technical information and tags)
+ /// @brief Open a stream (Continue)
+ /// @param FilePos File position
+ /// @param Buffer pointer to the stream
+ /// @param Buffer_Size Count of bytes to read
+ size_t Open_Buffer_Continue (size_t FilePos, const ZenLib::int8u* Buffer, size_t Buffer_Size);
+ /// Open a stream and collect information about it (technical information and tags)
+ /// @brief Open a stream (Get the needed file Offset)
+ /// @param FilePos File position
+ /// @return the needed offset of the file \n
+ /// File size if no more bytes are needed
+ ZenLib::int64u Open_Buffer_Continue_GoTo_Get (size_t FilePos);
+ /// Open a stream and collect information about it (technical information and tags)
+ /// @brief Open a stream (Finalize)
+ /// @param FilePos File position
+ size_t Open_Buffer_Finalize (size_t FilePos);
+ /// Save the file opened before with Open() (modifications of tags)
+ /// @brief Save the file
+ /// @param FilePos File position \n
+ /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") )
+ /// @retval 0 failed
+ /// @retval 1 suceed
+ size_t Save (size_t FilePos);
+ /// (NOT IMPLEMENTED YET) Save all files opened before with Open() (modifications of tags)
+ /// @brief (NOT IMPLEMENTED YET) Save all files
+ /// @param FilePos File position \n
+ /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") )
+ /// @retval Count of files saved
+ void Close (size_t FilePos=(size_t)-1);
+
+ /// Get all details about a file in one string
+ /// @brief Get all details about a file
+ /// @param FilePos File position \n
+ /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") )
+ /// @param Reserved Deprecated, do not use it anymore
+ /// @pre You can change default presentation with Inform_Set()
+ String Inform (size_t FilePos=(size_t)-1, size_t Reserved=0);
+
+ //Get
+ /// Get a piece of information about a file (parameter is an integer)
+ /// @brief Get a piece of information about a file (parameter is an integer)
+ /// @param FilePos File position \n
+ /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") )
+ /// @param StreamKind Kind of stream (general, video, audio...)
+ /// @param StreamNumber Stream number in Kind of stream (first, second...)
+ /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...)
+ /// @param KindOfInfo Kind of information you want about the parameter (the text, the measure, the help...)
+ /// @return a string about information you search \n
+ /// an empty string if there is a problem
+ String Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t KindOfInfo=Info_Text); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name, text, measure, options, name (language), measure (language), info, how to
+ /// Get a piece of information about a file (parameter is a string)
+ /// @brief Get a piece of information about a file (parameter is a string)
+ /// @param FilePos File position \n
+ /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") )
+ /// @param StreamKind Kind of stream (general, video, audio...)
+ /// @param StreamNumber Stream number in Kind of stream (first, second...)
+ /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n
+ /// See MediaInfo::Option("Info_Parameters") to have the full list
+ /// @param KindOfInfo Kind of information you want about the parameter (the text, the measure, the help...)
+ /// @param KindOfSearch Where to look for the parameter
+ /// @return a string about information you search \n
+ /// an empty string if there is a problem
+ String Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t KindOfInfo=Info_Text, info_t KindOfSearch=Info_Name); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name text measure options name(language) measure(language) information how to, KindOfSearch=which Kind Of information Parameter must be searched?
+
+ //Set
+ /// (NOT IMPLEMENTED YET) Set a piece of information about a file (parameter is an int)
+ /// @brief (NOT IMPLEMENTED YET) Set a piece of information about a file (parameter is an int)
+ /// @warning Not yet implemented, do not use it
+ /// @param ToSet Piece of information
+ /// @param FilePos File position \n
+ /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") )
+ /// @param StreamKind Kind of stream (general, video, audio...)
+ /// @param StreamNumber Stream number in Kind of stream (first, second...)
+ /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...)
+ /// @param OldValue The old value of the parameter \n if OldValue is empty and ToSet is filled: tag is added \n if OldValue is filled and ToSet is filled: tag is replaced \n if OldValue is filled and ToSet is empty: tag is deleted
+ /// @retval >0 succeed
+ /// @retval 0 failed
+ size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=String()); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name, text, measure, options name(language) measure(language) information how to
+ /// @brief (NOT IMPLEMENTED YET) Get information about a file (parameter is a string)
+ /// @warning Not yet implemented, do not use it
+ /// @param ToSet Piece of information
+ /// @param FilePos File position \n
+ /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") )
+ /// @param StreamKind Kind of stream (general, video, audio...)
+ /// @param StreamNumber Stream number in Kind of stream (first, second...)
+ /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n
+ /// See Option("Info_Parameters") to have the full list
+ /// @param OldValue The old value of the parameter \n if OldValue is empty and ToSet is filled: tag is added \n if OldValue is filled and ToSet is filled: tag is replaced \n if OldValue is filled and ToSet is empty: tag is deleted
+ /// @retval >0 succeed
+ /// @retval 0 failed
+ size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=String()); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name text measure options name (language) measure (language) information how to, KindOfSearch=which Kind Of information Parameter must be searched?
+
+ //Output_Buffered
+ /// Output buffer retrieving, used for File_Duplicate option.
+ /// @brief Output buffer retrieving
+ /// @param FilePos File position
+ /// @param Output_Buffer_Size A pointer to the variable that receives the size of the buffer \n
+ /// Note: you must use all the size of the buffer before the next call to this procedure
+ /// @return A pointer on the output buffer, NULL if there is nothing in the buffer
+ char* Output_Buffer_Get (size_t FilePos, size_t &Output_Buffer_Size);
+
+ //Info
+ /// Configure or get information about MediaInfoLib
+ /// @param Option The name of option
+ /// @param Value The value of option
+ /// @return Depend of the option: by default "" (nothing) means No, other means Yes
+ /// @post Known options are: See MediaInfo::Option()
+ String Option (const String &Option, const String &Value=String());
+ /// Configure or get information about MediaInfoLib (static version)
+ /// @param Option The name of option
+ /// @param Value The value of option
+ /// @return Depend of the option: by default "" (nothing) means No, other means Yes
+ /// @post Known options are: See MediaInfo::Option()
+ static String Option_Static (const String &Option, const String &Value=String());
+ /// @brief (NOT IMPLEMENTED YET) Get the state of the library
+ /// @retval <1000 No information is available for the file yet
+ /// @retval >=1000_<5000 Only local (into the file) information is available, getting Internet information (titles only) is no finished yet
+ /// @retval 5000 (only if Internet connection is accepted) User interaction is needed (use Option() with "Internet_Title_Get") \n
+ /// Warning: even there is only one possible, user interaction (or the software) is needed
+ /// @retval >5000<=10000 Only local (into the file) information is available, getting Internet information (all) is no finished yet
+ /// @retval <10000 Done
+ size_t State_Get ();
+ /// @brief Count of streams, or count of piece of information in this stream
+ /// @param FilePos File position \n
+ /// (you can know the position in searching the filename with MediaInfoList::Get(FilePos, 0, 0, "CompleteName") )
+ /// @param StreamKind Kind of stream (general, video, audio...)
+ /// @param StreamNumber Stream number in this kind of stream (first, second...)
+ size_t Count_Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber=(size_t)-1);
+ /// @brief Get the count of opened files
+ /// @return Count of files opened
+ size_t Count_Get ();
+
+private :
+ void* Internal;
+};
+
+} //NameSpace
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList_Internal.cpp b/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList_Internal.cpp
new file mode 100644
index 000000000..bcf03051f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList_Internal.cpp
@@ -0,0 +1,454 @@
+// MediaInfoList_Internal - A list of MediaInfo
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfoList_Internal.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "ZenLib/ZtringListList.h"
+#include "ZenLib/File.h"
+#include "ZenLib/Dir.h"
+#include "MediaInfo/Reader/Reader_Directory.h"
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Gestion de la classe
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Constructeurs
+MediaInfoList_Internal::MediaInfoList_Internal(size_t Count_Init)
+: Thread()
+{
+ CriticalSectionLocker CSL(CS);
+
+ //Initialisation
+ Info.reserve(Count_Init);
+ for (size_t Pos=0; Pos<Info.size(); Pos++)
+ Info[Pos]=NULL;
+ ToParse_AlreadyDone=0;
+ ToParse_Total=0;
+
+ //Threading
+ BlockMethod=0;
+ State=0;
+ IsInThread=false;
+}
+
+//---------------------------------------------------------------------------
+//Destructeur
+MediaInfoList_Internal::~MediaInfoList_Internal()
+{
+ Close();
+}
+
+//***************************************************************************
+// Fichiers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList_Internal::Open(const String &File_Name, const fileoptions_t Options)
+{
+ //Option FileOption_Close
+ if (Options & FileOption_CloseAll)
+ Close(All);
+
+ //Option Recursive
+ //TODO
+
+ //Get all filenames
+ ZtringList List;
+ size_t Pos=File_Name.find(_T(':'));
+ if (Pos!=string::npos && Pos!=1)
+ List.push_back(File_Name);
+ else if (File::Exists(File_Name))
+ List.push_back(File_Name);
+ else
+ List=Dir::GetAllFileNames(File_Name, (Options&FileOption_NoRecursive)?Dir::Nothing:Dir::Parse_SubDirs);
+
+ #if defined(MEDIAINFO_DIRECTORY_YES)
+ Reader_Directory().Directory_Cleanup(List);
+ #endif //defined(MEDIAINFO_DIRECTORY_YES)
+
+ //Registering files
+ CS.Enter();
+ if (ToParse.empty())
+ CountValid=0;
+ for (ZtringList::iterator L=List.begin(); L!=List.end(); L++)
+ ToParse.push(*L);
+ ToParse_Total+=List.size();
+ if (ToParse_Total)
+ State=ToParse_AlreadyDone*10000/ToParse_Total;
+ else
+ State=10000;
+ CS.Leave();
+
+ //Parsing
+ if (BlockMethod==1)
+ {
+ CS.Enter();
+ if (!IsRunning()) //If already created, the routine will read the new files
+ {
+ RunAgain();
+ IsInThread=true;
+ }
+ CS.Leave();
+ return 0;
+ }
+ else
+ {
+ Entry(); //Normal parsing
+ return Count_Get();
+ }
+}
+
+void MediaInfoList_Internal::Entry()
+{
+ if (ToParse_Total==0)
+ return;
+
+ for (;;)
+ {
+ CS.Enter();
+ if (!ToParse.empty())
+ {
+ MediaInfo_Internal* MI=new MediaInfo_Internal();
+ for (std::map<String, String>::iterator Config_MediaInfo_Item=Config_MediaInfo_Items.begin(); Config_MediaInfo_Item!=Config_MediaInfo_Items.end(); Config_MediaInfo_Item++)
+ MI->Option(Config_MediaInfo_Item->first, Config_MediaInfo_Item->second);
+ if (BlockMethod==1)
+ MI->Option(_T("Thread"), _T("1"));
+ MI->Open(ToParse.front());
+ if (BlockMethod==1)
+ {
+ CS.Leave();
+ while (MI->State_Get()<10000)
+ {
+ size_t A=MI->State_Get();
+ CS.Enter();
+ State=(ToParse_AlreadyDone*10000+A)/ToParse_Total;
+ CS.Leave();
+ if (IsTerminating())
+ {
+ break;
+ }
+ Yield();
+ }
+ CS.Enter();
+ }
+ Info.push_back(MI);
+ ToParse.pop();
+ ToParse_AlreadyDone++;
+ State=ToParse_AlreadyDone*10000/ToParse_Total;
+ }
+ if (IsTerminating() || State==10000)
+ {
+ CS.Leave();
+ break;
+ }
+ CS.Leave();
+ Yield();
+ }
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList_Internal::Open_Buffer_Init (int64u File_Size_, int64u File_Offset_)
+{
+ MediaInfo_Internal* MI=new MediaInfo_Internal();
+ MI->Open_Buffer_Init(File_Size_, File_Offset_);
+
+ CriticalSectionLocker CSL(CS);
+ size_t Pos=Info.size();
+ Info.push_back(MI);
+ return Pos;
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList_Internal::Open_Buffer_Continue (size_t FilePos, const int8u* ToAdd, size_t ToAdd_Size)
+{
+ CriticalSectionLocker CSL(CS);
+ if (FilePos>=Info.size() || Info[FilePos]==NULL)
+ return 0;
+
+ return Info[FilePos]->Open_Buffer_Continue(ToAdd, ToAdd_Size).to_ulong();
+}
+
+//---------------------------------------------------------------------------
+int64u MediaInfoList_Internal::Open_Buffer_Continue_GoTo_Get (size_t FilePos)
+{
+ CriticalSectionLocker CSL(CS);
+ if (FilePos>=Info.size() || Info[FilePos]==NULL)
+ return (int64u)-1;
+
+ return Info[FilePos]->Open_Buffer_Continue_GoTo_Get();
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList_Internal::Open_Buffer_Finalize (size_t FilePos)
+{
+ CriticalSectionLocker CSL(CS);
+ if (FilePos>=Info.size() || Info[FilePos]==NULL)
+ return 0;
+
+ return Info[FilePos]->Open_Buffer_Finalize();
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList_Internal::Save(size_t)
+{
+ CriticalSectionLocker CSL(CS);
+ return 0; //Not yet implemented
+}
+
+//---------------------------------------------------------------------------
+void MediaInfoList_Internal::Close(size_t FilePos)
+{
+ if (IsRunning())
+ {
+ RequestTerminate();
+ while(IsExited())
+ Yield();
+ }
+
+ CriticalSectionLocker CSL(CS);
+ if (FilePos==Unlimited)
+ {
+ for (size_t Pos=0; Pos<Info.size(); Pos++)
+ {
+ delete Info[Pos]; Info[Pos]=NULL;
+ }
+ Info.clear();
+ }
+ else if (FilePos<Info.size())
+ {
+ delete Info[FilePos]; Info[FilePos]=NULL;
+ Info.erase(Info.begin()+FilePos);
+ }
+
+ ToParse_AlreadyDone=0;
+ ToParse_Total=0;
+}
+
+//***************************************************************************
+// Get File info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+String MediaInfoList_Internal::Inform(size_t FilePos, size_t)
+{
+ if (FilePos==Error)
+ {
+ Ztring Retour;
+ FilePos=0;
+ ZtringListList MediaInfo_Custom_View; MediaInfo_Custom_View.Write(Option(_T("Inform_Get")));
+ bool XML=false;
+ if (MediaInfoLib::Config.Inform_Get()==_T("XML"))
+ XML=true;
+ if (XML) Retour+=_T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")+MediaInfoLib::Config.LineSeparator_Get()+_T("<Mediainfo version=\"")+MediaInfoLib::Config.Info_Version_Get().SubString(_T(" v"), Ztring())+_T("\">")+MediaInfoLib::Config.LineSeparator_Get();
+ else
+ Retour+=MediaInfo_Custom_View("Page_Begin");
+ while (FilePos<Info.size())
+ {
+ Retour+=Inform(FilePos);
+ if (FilePos<Info.size()-1)
+ {
+ Retour+=MediaInfo_Custom_View("Page_Middle");
+ }
+ FilePos++;
+ }
+ if (XML) Retour+=_T("</Mediainfo>")+MediaInfoLib::Config.LineSeparator_Get();
+ else Retour+=MediaInfo_Custom_View("Page_End");//
+ return Retour.c_str();
+ }
+
+ CriticalSectionLocker CSL(CS);
+
+ if (FilePos>=Info.size() || Info[FilePos]==NULL || Info[FilePos]->Count_Get(Stream_General)==0)
+ return MediaInfoLib::Config.EmptyString_Get();
+
+ Info[FilePos]->IsFirst=FilePos==0;
+ Info[FilePos]->IsLast=(FilePos+1)==Info.size();
+ return Info[FilePos]->Inform();
+}
+
+//---------------------------------------------------------------------------
+String MediaInfoList_Internal::Get(size_t FilePos, stream_t KindOfStream, size_t StreamNumber, size_t Parameter, info_t KindOfInfo)
+{
+ CriticalSectionLocker CSL(CS);
+ if (FilePos==Error || FilePos>=Info.size() || Info[FilePos]==NULL || Info[FilePos]->Count_Get(Stream_General)==0)
+ return MediaInfoLib::Config.EmptyString_Get();
+
+ return Info[FilePos]->Get(KindOfStream, StreamNumber, Parameter, KindOfInfo);
+}
+
+//---------------------------------------------------------------------------
+String MediaInfoList_Internal::Get(size_t FilePos, stream_t KindOfStream, size_t StreamNumber, const String &Parameter, info_t KindOfInfo, info_t KindOfSearch)
+{
+ CriticalSectionLocker CSL(CS);
+ if (FilePos==Error || FilePos>=Info.size() || Info[FilePos]==NULL || Info[FilePos]->Count_Get(Stream_General)==0)
+ return MediaInfoLib::Config.EmptyString_Get();
+
+ return Info[FilePos]->Get(KindOfStream, StreamNumber, Parameter, KindOfInfo, KindOfSearch);
+}
+
+//***************************************************************************
+// Set File info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList_Internal::Set(const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue)
+{
+ CriticalSectionLocker CSL(CS);
+ if (FilePos==(size_t)-1)
+ FilePos=0; //TODO : average
+
+ if (FilePos>=Info.size() || Info[FilePos]==NULL || Info[FilePos]->Count_Get(Stream_General)==0)
+ return 0;
+
+ return Info[FilePos]->Set(ToSet, StreamKind, StreamNumber, Parameter, OldValue);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList_Internal::Set(const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue)
+{
+ CriticalSectionLocker CSL(CS);
+ if (FilePos==(size_t)-1)
+ FilePos=0; //TODO : average
+
+ if (FilePos>=Info.size() || Info[FilePos]==NULL || Info[FilePos]->Count_Get(Stream_General)==0)
+ return 0;
+
+ return Info[FilePos]->Set(ToSet, StreamKind, StreamNumber, Parameter, OldValue);
+}
+
+//***************************************************************************
+// Output buffer
+//***************************************************************************
+
+/*
+//---------------------------------------------------------------------------
+char* MediaInfoList_Internal::Output_Buffer_Get (size_t FilePos, size_t &Output_Buffer_Size)
+{
+ if (FilePos==(size_t)-1)
+ FilePos=0; //TODO : average
+
+ if (FilePos>=Info.size() || Info[FilePos]==NULL || Info[FilePos]->Count_Get(Stream_General)==0)
+ return 0;
+
+ return Info[FilePos]->Output_Buffer_Get(Output_Buffer_Size);
+}
+*/
+
+//***************************************************************************
+// Information
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+String MediaInfoList_Internal::Option (const String &Option, const String &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ztring OptionLower=Option; OptionLower.MakeLowerCase();
+ if (Option==_T(""))
+ return _T("");
+ else if (OptionLower==_T("manguage_update"))
+ {
+ //Special case : Language_Update must update all MediaInfo classes
+ for (unsigned int Pos=0; Pos<Info.size(); Pos++)
+ if (Info[Pos])
+ Info[Pos]->Option(_T("language_update"), Value);
+
+ return _T("");
+ }
+ else if (OptionLower==_T("create_dummy"))
+ {
+ Info.resize(Info.size()+1);
+ Info[Info.size()-1]=new MediaInfo_Internal();
+ Info[Info.size()-1]->Option(Option, Value);
+ return _T("");
+ }
+ else if (OptionLower==_T("thread"))
+ {
+ BlockMethod=1;
+ return _T("");
+ }
+ else if (OptionLower.find(_T("file_"))==0)
+ {
+ Config_MediaInfo_Items[Option]=Value;
+ return _T("");
+ }
+ else
+ return MediaInfo::Option_Static(Option, Value);
+}
+
+//---------------------------------------------------------------------------
+String MediaInfoList_Internal::Option_Static (const String &Option, const String &Value)
+{
+ return MediaInfo::Option_Static(Option, Value);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList_Internal::State_Get()
+{
+ CriticalSectionLocker CSL(CS);
+ if (State==10000)
+ {
+ //Pause();
+ IsInThread=false;
+ }
+ return State;
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList_Internal::Count_Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber)
+{
+ CriticalSectionLocker CSL(CS);
+ if (FilePos>=Info.size() || Info[FilePos]==NULL)
+ return 0;
+
+ return Info[FilePos]->Count_Get(StreamKind, StreamNumber);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfoList_Internal::Count_Get()
+{
+ CriticalSectionLocker CSL(CS);
+ return Info.size();
+}
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList_Internal.h b/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList_Internal.h
new file mode 100644
index 000000000..029cdf480
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfoList_Internal.h
@@ -0,0 +1,97 @@
+// MediaInfoList_Internal - A list of MediaInfo
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// MediaInfoList_Internal
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Give information about a lot of media files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfoList_InternalH
+#define MediaInfoList_InternalH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "ZenLib/Thread.h"
+#include "ZenLib/CriticalSection.h"
+#include <vector>
+#include <queue>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class MediaInfoList_Internal : public ZenLib::Thread
+{
+public :
+ //Class
+ MediaInfoList_Internal (size_t Count_Init=64);
+ virtual ~MediaInfoList_Internal ();
+
+ //Files
+ size_t Open (const String &File, const fileoptions_t Options=FileOption_Nothing);
+ size_t Open_Buffer_Init (ZenLib::int64u File_Size=(ZenLib::int64u)-1, ZenLib::int64u File_Offset=0);
+ size_t Open_Buffer_Continue (size_t FilePos, const ZenLib::int8u* Buffer, size_t Buffer_Size);
+ ZenLib::int64u Open_Buffer_Continue_GoTo_Get (size_t FilePos);
+ size_t Open_Buffer_Finalize (size_t FilePos);
+ size_t Save (size_t FilePos);
+ void Close (size_t FilePos=(size_t)-1);
+ String Inform (size_t FilePos=(size_t)-1, size_t Reserved=0);
+
+ //Get
+ String Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t KindOfInfo=Info_Text); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name, text, measure, options, name (language), measure (language), info, how to
+ String Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t KindOfInfo=Info_Text, info_t KindOfSearch=Info_Name); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name text measure options name(language) measure(language) information how to, KindOfSearch=which Kind Of information Parameter must be searched?
+
+ //Set
+ size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=_T("")); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name, text, measure, options name(language) measure(language) information how to
+ size_t Set (const String &ToSet, size_t FilePos, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=_T("")); //Get info, FilePos=File position, StreamKind=General video audio text chapter, StreamNumber=stream number, PosInStream=parameter you want, KindOfInfo=name text measure options name (language) measure (language) information how to, KindOfSearch=which Kind Of information Parameter must be searched?
+
+ //Output_Buffered
+ char* Output_Buffer_Get (size_t File_Pos, size_t &Output_Buffer_Size);
+
+ //Info
+ String Option (const String &Option, const String &Value=String(_T("")));
+ static String Option_Static (const String &Option, const String &Value=String(_T("")));
+ size_t State_Get ();
+ size_t Count_Get (size_t FilePos, stream_t StreamKind, size_t StreamNumber=(size_t)-1);
+ size_t Count_Get ();
+
+private :
+ std::vector<MediaInfo_Internal*> Info;
+ std::queue<String> ToParse;
+ std::map<String, String> Config_MediaInfo_Items; //Config per file
+ size_t ToParse_AlreadyDone;
+ size_t ToParse_Total;
+ size_t CountValid;
+ MediaInfo_Config_MediaInfo Config;
+
+ //Threading
+ size_t BlockMethod; //Open() return: 0=immedialtly, 1=after local info, 2=when user interaction is needed
+ size_t State;
+ bool IsInThread;
+ void Entry();
+ ZenLib::CriticalSection CS;
+};
+
+} //NameSpace
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config.cpp b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config.cpp
new file mode 100644
index 000000000..403e5cce2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config.cpp
@@ -0,0 +1,2075 @@
+// MediaInfo_Config - Configuration class
+// Copyright (C) 2005-2012 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Global configuration of MediaInfo
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo_Config.h"
+#include "ZenLib/ZtringListListF.h"
+#include "ZenLib/File.h"
+#include <algorithm>
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+const Char* MediaInfo_Version=_T("MediaInfoLib - v0.7.58");
+const Char* MediaInfo_Url=_T("http://mediainfo.sourceforge.net");
+ Ztring EmptyZtring; //Use it when we can't return a reference to a true Ztring
+const Ztring EmptyZtring_Const; //Use it when we can't return a reference to a true Ztring, const version
+const ZtringListList EmptyZtringListList_Const; //Use it when we can't return a reference to a true ZtringListList, const version
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_General_Mpeg4 (InfoMap &Info);
+void MediaInfo_Config_CodecID_Video_Matroska (InfoMap &Info);
+void MediaInfo_Config_CodecID_Video_Mpeg4 (InfoMap &Info);
+void MediaInfo_Config_CodecID_Video_Ogg (InfoMap &Info);
+void MediaInfo_Config_CodecID_Video_Real (InfoMap &Info);
+void MediaInfo_Config_CodecID_Video_Riff (InfoMap &Info);
+void MediaInfo_Config_CodecID_Audio_Matroska (InfoMap &Info);
+void MediaInfo_Config_CodecID_Audio_Mpeg4 (InfoMap &Info);
+void MediaInfo_Config_CodecID_Audio_Ogg (InfoMap &Info);
+void MediaInfo_Config_CodecID_Audio_Real (InfoMap &Info);
+void MediaInfo_Config_CodecID_Audio_Riff (InfoMap &Info);
+void MediaInfo_Config_CodecID_Text_Matroska (InfoMap &Info);
+void MediaInfo_Config_CodecID_Text_Mpeg4 (InfoMap &Info);
+void MediaInfo_Config_CodecID_Text_Riff (InfoMap &Info);
+void MediaInfo_Config_Codec (InfoMap &Info);
+void MediaInfo_Config_DefaultLanguage (Translation &Info);
+void MediaInfo_Config_Iso639_1 (InfoMap &Info);
+void MediaInfo_Config_Iso639_2 (InfoMap &Info);
+void MediaInfo_Config_General (ZtringListList &Info);
+void MediaInfo_Config_Video (ZtringListList &Info);
+void MediaInfo_Config_Audio (ZtringListList &Info);
+void MediaInfo_Config_Text (ZtringListList &Info);
+void MediaInfo_Config_Chapters (ZtringListList &Info);
+void MediaInfo_Config_Image (ZtringListList &Info);
+void MediaInfo_Config_Menu (ZtringListList &Info);
+void MediaInfo_Config_Summary (ZtringListList &Info);
+void MediaInfo_Config_Format (InfoMap &Info);
+void MediaInfo_Config_Library_DivX (InfoMap &Info);
+void MediaInfo_Config_Library_XviD (InfoMap &Info);
+void MediaInfo_Config_Library_MainConcept_Avc (InfoMap &Info);
+void MediaInfo_Config_Library_VorbisCom (InfoMap &Info);
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+void MediaInfo_Config::Init()
+{
+ CS.Enter();
+ //We use Init() instead of COnstructor because for some backends (like WxWidgets...) does NOT like constructor of static object with Unicode conversion
+
+ //Test
+ if (!LineSeparator.empty())
+ {
+ CS.Leave();
+ return; //Already done
+ }
+
+ //Filling
+ FormatDetection_MaximumOffset=0;
+ MpegTs_MaximumOffset=32*1024*1024;
+ MpegTs_MaximumScanDuration=16000000000LL;
+ MpegTs_ForceStreamDisplay=false;
+ Complete=0;
+ BlockMethod=0;
+ Internet=0;
+ MultipleValues=0;
+ ParseUnknownExtensions=1;
+ ShowFiles_Nothing=1;
+ ShowFiles_VideoAudio=1;
+ ShowFiles_VideoOnly=1;
+ ShowFiles_AudioOnly=1;
+ ShowFiles_TextOnly=1;
+ ParseSpeed=(float32)0.5;
+ Verbosity=(float32)0.5;
+ Trace_Level=(float32)0.0;
+ Trace_TimeSection_OnlyFirstOccurrence=false;
+ Trace_Format=Trace_Format_Tree;
+ Language_Raw=false;
+ ReadByHuman=true;
+ LegacyStreamDisplay=true;
+ Demux=0;
+ LineSeparator=EOL;
+ ColumnSeparator=_T(";");
+ TagSeparator=_T(" / ");
+ Quote=_T("\"");
+ DecimalPoint=_T(".");
+ ThousandsPoint=Ztring();
+ #if MEDIAINFO_EVENTS
+ Event_CallBackFunction=NULL;
+ Event_UserHandler=NULL;
+ #endif //MEDIAINFO_EVENTS
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssh_IgnoreSecurity=false;
+ Ssl_IgnoreSecurity=false;
+ #endif //defined(MEDIAINFO_LIBCURL_YES)
+
+ CS.Leave();
+
+ ZtringListList ZLL1; Language_Set(ZLL1);
+}
+
+//***************************************************************************
+// Info
+//***************************************************************************
+
+Ztring MediaInfo_Config::Option (const String &Option, const String &Value_Raw)
+{
+ SubFile_Config(Option)=Value_Raw;
+
+ String Option_Lower(Option);
+ size_t Egal_Pos=Option_Lower.find(_T('='));
+ if (Egal_Pos==string::npos)
+ Egal_Pos=Option_Lower.size();
+ transform(Option_Lower.begin(), Option_Lower.begin()+Egal_Pos, Option_Lower.begin(), (int(*)(int))tolower); //(int(*)(int)) is a patch for unix
+
+ //Parsing pointer to a file
+ Ztring Value;
+ if (Value_Raw.find(_T("file://"))==0)
+ {
+ //Open
+ Ztring FileName(Value_Raw, 7, Ztring::npos);
+ File F(FileName.c_str());
+
+ //Read
+ int64u Size=F.Size_Get();
+ if (Size>=0xFFFFFFFF)
+ Size=1024*1024;
+ int8u* Buffer=new int8u[(size_t)Size+1];
+ size_t Pos=F.Read(Buffer, (size_t)Size);
+ F.Close();
+ Buffer[Pos]='\0';
+ Ztring FromFile; FromFile.From_UTF8((char*)Buffer);
+ if (FromFile.empty())
+ FromFile.From_Local((char*)Buffer);
+ delete[] Buffer; //Buffer=NULL;
+
+ //Merge
+ Value=FromFile;
+ }
+ else
+ Value=Value_Raw;
+
+ if (Option_Lower.empty())
+ {
+ return Ztring();
+ }
+ else if (Option_Lower==_T("charset_config"))
+ {
+ return Ztring(); //Only used in DLL, no Library action
+ }
+ else if (Option_Lower==_T("charset_output"))
+ {
+ return Ztring(); //Only used in DLL, no Library action
+ }
+ else if (Option_Lower==_T("complete"))
+ {
+ Complete_Set(Value.To_int8u()?true:false);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("complete_get"))
+ {
+ if (Complete_Get())
+ return _T("1");
+ else
+ return Ztring();
+ }
+ else if (Option_Lower==_T("blockmethod"))
+ {
+ if (Value.empty())
+ BlockMethod_Set(0);
+ else
+ BlockMethod_Set(1);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("blockmethod_get"))
+ {
+ if (BlockMethod_Get())
+ return _T("1");
+ else
+ return Ztring();
+ }
+ else if (Option_Lower==_T("internet"))
+ {
+ if (Value.empty())
+ Internet_Set(0);
+ else
+ Internet_Set(1);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("internet_get"))
+ {
+ if (Internet_Get())
+ return _T("1");
+ else
+ return Ztring();
+ }
+ else if (Option_Lower==_T("demux"))
+ {
+ String Value_Lower(Value);
+ transform(Value_Lower.begin(), Value_Lower.end(), Value_Lower.begin(), (int(*)(int))tolower); //(int(*)(int)) is a patch for unix
+
+ if (Value_Lower==_T("all"))
+ Demux_Set(7);
+ else if (Value_Lower==_T("frame"))
+ Demux_Set(1);
+ else if (Value_Lower==_T("container"))
+ Demux_Set(2);
+ else if (Value_Lower==_T("elementary"))
+ Demux_Set(4);
+ else
+ Demux_Set(0);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("demux_get"))
+ {
+ switch (Demux_Get())
+ {
+ case 7 : return _T("All");
+ case 1 : return _T("Frame");
+ case 2 : return _T("Container");
+ case 4 : return _T("Elementary");
+ default: return Ztring();
+ }
+ }
+ else if (Option_Lower==_T("multiplevalues"))
+ {
+ if (Value.empty())
+ MultipleValues_Set(0);
+ else
+ MultipleValues_Set(1);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("multiplevalues_get"))
+ {
+ if (MultipleValues_Get())
+ return _T("1");
+ else
+ return Ztring();
+ }
+ else if (Option_Lower==_T("parseunknownextensions"))
+ {
+ if (Value.empty())
+ ParseUnknownExtensions_Set(0);
+ else
+ ParseUnknownExtensions_Set(1);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("parseunknownextensions_get"))
+ {
+ if (ParseUnknownExtensions_Get())
+ return _T("1");
+ else
+ return Ztring();
+ }
+ else if (Option_Lower==_T("showfiles_set"))
+ {
+ ShowFiles_Set(Value.c_str());
+ return Ztring();
+ }
+ else if (Option_Lower==_T("readbyhuman"))
+ {
+ ReadByHuman_Set(Value.To_int8u()?true:false);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("readbyhuman_get"))
+ {
+ return ReadByHuman_Get()?_T("1"):_T("0");
+ }
+ else if (Option_Lower==_T("legacystreamdisplay"))
+ {
+ LegacyStreamDisplay_Set(Value.To_int8u()?true:false);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("legacystreamdisplay_get"))
+ {
+ return LegacyStreamDisplay_Get()?_T("1"):_T("0");
+ }
+ else if (Option_Lower==_T("parsespeed"))
+ {
+ ParseSpeed_Set(Value.To_float32());
+ return Ztring();
+ }
+ else if (Option_Lower==_T("parsespeed_get"))
+ {
+ return Ztring::ToZtring(ParseSpeed_Get(), 3);
+ }
+ else if (Option_Lower==_T("verbosity"))
+ {
+ Verbosity_Set(Value.To_float32());
+ return Ztring();
+ }
+ else if (Option_Lower==_T("verbosity_get"))
+ {
+ return Ztring::ToZtring(Verbosity_Get(), 3);
+ }
+ else if (Option_Lower==_T("lineseparator"))
+ {
+ LineSeparator_Set(Value);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("lineseparator_get"))
+ {
+ return LineSeparator_Get();
+ }
+ else if (Option_Lower==_T("version"))
+ {
+ Version_Set(Value);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("version_get"))
+ {
+ return Version_Get();
+ }
+ else if (Option_Lower==_T("columnseparator"))
+ {
+ ColumnSeparator_Set(Value);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("columnseparator_get"))
+ {
+ return ColumnSeparator_Get();
+ }
+ else if (Option_Lower==_T("tagseparator"))
+ {
+ TagSeparator_Set(Value);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("tagseparator_get"))
+ {
+ return TagSeparator_Get();
+ }
+ else if (Option_Lower==_T("quote"))
+ {
+ Quote_Set(Value);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("quote_get"))
+ {
+ return Quote_Get();
+ }
+ else if (Option_Lower==_T("decimalpoint"))
+ {
+ DecimalPoint_Set(Value);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("decimalpoint_get"))
+ {
+ return DecimalPoint_Get();
+ }
+ else if (Option_Lower==_T("thousandspoint"))
+ {
+ ThousandsPoint_Set(Value);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("thousandspoint_get"))
+ {
+ return ThousandsPoint_Get();
+ }
+ else if (Option_Lower==_T("streammax"))
+ {
+ ZtringListList StreamMax=Value.c_str();
+ StreamMax_Set(StreamMax);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("streammax_get"))
+ {
+ return StreamMax_Get();
+ }
+ else if (Option_Lower==_T("language"))
+ {
+ ZtringListList Language=Value.c_str();
+ Language_Set(Language);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("language_get"))
+ {
+ return Language_Get();
+ }
+ else if (Option_Lower==_T("inform"))
+ {
+ Inform_Set(Value.c_str());
+ return Ztring();
+ }
+ else if (Option_Lower==_T("output"))
+ {
+ Inform_Set(Value.c_str());
+ return Ztring();
+ }
+ else if (Option_Lower==_T("inform_get"))
+ {
+ return Inform_Get();
+ }
+ else if (Option_Lower==_T("output_get"))
+ {
+ return Inform_Get();
+ }
+ else if (Option_Lower==_T("inform_replace"))
+ {
+ Inform_Replace_Set(Value.c_str());
+ return Ztring();
+ }
+ else if (Option_Lower==_T("inform_replace_get"))
+ {
+ return Inform_Replace_Get();
+ }
+ else if (Option_Lower==_T("details")) //Legacy for trace_level
+ {
+ return MediaInfo_Config::Option(_T("Trace_Level"), Value);
+ }
+ else if (Option_Lower==_T("details_get")) //Legacy for trace_level
+ {
+ return MediaInfo_Config::Option(_T("Trace_Level_Get"), Value);
+ }
+ else if (Option_Lower==_T("detailslevel")) //Legacy for trace_level
+ {
+ return MediaInfo_Config::Option(_T("Trace_Level"), Value);
+ }
+ else if (Option_Lower==_T("detailslevel_get")) //Legacy for trace_level
+ {
+ return MediaInfo_Config::Option(_T("Trace_Level_Get"), Value);
+ }
+ else if (Option_Lower==_T("trace_level"))
+ {
+ Trace_Level_Set(Value);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("trace_level_get"))
+ {
+ return Ztring::ToZtring(Trace_Level_Get());
+ }
+ else if (Option_Lower==_T("trace_timesection_onlyfirstoccurrence"))
+ {
+ Trace_TimeSection_OnlyFirstOccurrence_Set(Value.To_int64u()?true:false);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("trace_timesection_onlyfirstoccurrence_get"))
+ {
+ return Trace_TimeSection_OnlyFirstOccurrence_Get()?_T("1"):_T("0");
+ }
+ else if (Option_Lower==_T("detailsformat")) //Legacy for trace_format
+ {
+ return MediaInfo_Config::Option(_T("Trace_Format"), Value);
+ }
+ else if (Option_Lower==_T("detailsformat_get")) //Legacy for trace_format
+ {
+ return MediaInfo_Config::Option(_T("Trace_Format_Get"), Value);
+ }
+ else if (Option_Lower==_T("trace_format"))
+ {
+ String NewValue_Lower(Value);
+ transform(NewValue_Lower.begin(), NewValue_Lower.end(), NewValue_Lower.begin(), (int(*)(int))tolower); //(int(*)(int)) is a patch for unix
+
+ CriticalSectionLocker CSL(CS);
+ if (NewValue_Lower==_T("csv"))
+ Trace_Format_Set(Trace_Format_CSV);
+ else
+ Trace_Format_Set(Trace_Format_Tree);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("trace_format_get"))
+ {
+ switch (Trace_Format_Get())
+ {
+ case Trace_Format_CSV : return _T("CSV");
+ default : return _T("Tree");
+ }
+ }
+ else if (Option_Lower==_T("detailsmodificator"))
+ {
+ Trace_Modificator_Set(Value);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("detailsmodificator_get"))
+ {
+ return Trace_Modificator_Get(Value);
+ }
+ else if (Option_Lower==_T("info_parameters"))
+ {
+ ZtringListList ToReturn=Info_Parameters_Get();
+
+ //Adapt first column
+ for (size_t Pos=0; Pos<ToReturn.size(); Pos++)
+ {
+ Ztring &C1=ToReturn(Pos, 0);
+ if (!ToReturn(Pos, 1).empty())
+ {
+ C1.resize(25, ' ');
+ ToReturn(Pos, 0)=C1 + _T(" :");
+ }
+ }
+
+ ToReturn.Separator_Set(0, LineSeparator_Get());
+ ToReturn.Separator_Set(1, _T(" "));
+ ToReturn.Quote_Set(Ztring());
+ return ToReturn.Read();
+ }
+ else if (Option_Lower==_T("info_parameters_csv"))
+ {
+ return Info_Parameters_Get();
+ }
+ else if (Option_Lower==_T("info_codecs"))
+ {
+ return Info_Codecs_Get();
+ }
+ else if (Option_Lower==_T("info_version"))
+ {
+ return Info_Version_Get();
+ }
+ else if (Option_Lower==_T("info_url"))
+ {
+ return Info_Url_Get();
+ }
+ else if (Option_Lower==_T("formatdetection_maximumoffset"))
+ {
+ FormatDetection_MaximumOffset_Set(Value==_T("-1")?(int64u)-1:((Ztring*)&Value)->To_int64u());
+ return Ztring();
+ }
+ else if (Option_Lower==_T("formatdetection_maximumoffset_get"))
+ {
+ return FormatDetection_MaximumOffset_Get()==(int64u)-1?Ztring(_T("-1")):Ztring::ToZtring(FormatDetection_MaximumOffset_Get());
+ }
+ else if (Option_Lower==_T("mpegts_maximumoffset"))
+ {
+ MpegTs_MaximumOffset_Set(Value==_T("-1")?(int64u)-1:((Ztring*)&Value)->To_int64u());
+ return Ztring();
+ }
+ else if (Option_Lower==_T("mpegts_maximumoffset_get"))
+ {
+ return MpegTs_MaximumOffset_Get()==(int64u)-1?Ztring(_T("-1")):Ztring::ToZtring(MpegTs_MaximumOffset_Get());
+ }
+ else if (Option_Lower==_T("mpegts_maximumscanduration"))
+ {
+ MpegTs_MaximumScanDuration_Set(float64_int64s((((Ztring*)&Value)->To_float64())*1000000000));
+ return Ztring();
+ }
+ else if (Option_Lower==_T("mpegts_maximumscanduration_get"))
+ {
+ return MpegTs_MaximumScanDuration_Get()==(int64u)-1?Ztring(_T("-1")):Ztring::ToZtring(MpegTs_MaximumOffset_Get());
+ }
+ else if (Option_Lower==_T("mpegts_forcestreamdisplay"))
+ {
+ MpegTs_ForceStreamDisplay_Set(Value.To_int8u()?true:false);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("mpegts_forcestreamdisplay_get"))
+ {
+ return MpegTs_ForceStreamDisplay_Get()?_T("1"):_T("0");
+ }
+ else if (Option_Lower==_T("custommapping"))
+ {
+ CustomMapping_Set(Value);
+ return Ztring();
+ }
+ else if (Option_Lower==_T("event_callbackfunction"))
+ {
+ #if MEDIAINFO_EVENTS
+ return Event_CallBackFunction_Set(Value);
+ #else //MEDIAINFO_EVENTS
+ return _T("Event manager is disabled due to compilation options");
+ #endif //MEDIAINFO_EVENTS
+ }
+ else if (Option_Lower==_T("ssh_knownhostsfilename"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssh_KnownHostsFileName_Set(Value);
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("ssh_publickeyfilename"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssh_PublicKeyFileName_Set(Value);
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("ssh_privatekeyfilename"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssh_PrivateKeyFileName_Set(Value);
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("ssh_ignoresecurity"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssh_IgnoreSecurity_Set(Value.empty() || Value.To_float32());
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("ssl_certificatefilename"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssl_CertificateFileName_Set(Value);
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("ssl_certificateFormat"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssl_CertificateFormat_Set(Value);
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("ssl_privatekeyfilename"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssl_PrivateKeyFileName_Set(Value);
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("ssl_privatekeyformat"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssl_PrivateKeyFormat_Set(Value);
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("ssl_certificateauthorityfilename"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssl_CertificateAuthorityFileName_Set(Value);
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("ssl_certificateauthoritypath"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssl_CertificateAuthorityPath_Set(Value);
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("ssl_certificaterevocationlistfilename"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssl_CertificateRevocationListFileName_Set(Value);
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("ssl_ignoresecurity"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ssl_IgnoreSecurity_Set(Value.empty() || Value.To_float32());
+ return Ztring();
+ #else // defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif // defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else
+ return _T("Option not known");
+}
+
+//***************************************************************************
+// Info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Complete_Set (size_t NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Complete=NewValue;
+}
+
+size_t MediaInfo_Config::Complete_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Complete;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::BlockMethod_Set (size_t NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ BlockMethod=NewValue;
+}
+
+size_t MediaInfo_Config::BlockMethod_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return BlockMethod;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Internet_Set (size_t NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Internet=NewValue;
+}
+
+size_t MediaInfo_Config::Internet_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Internet;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::MultipleValues_Set (size_t NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ MultipleValues=NewValue;
+}
+
+size_t MediaInfo_Config::MultipleValues_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return MultipleValues;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::ParseUnknownExtensions_Set (size_t NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ ParseUnknownExtensions=NewValue;
+}
+
+size_t MediaInfo_Config::ParseUnknownExtensions_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return ParseUnknownExtensions;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::ShowFiles_Set (const ZtringListList &NewShowFiles)
+{
+ CriticalSectionLocker CSL(CS);
+ for (size_t Pos=0; Pos<NewShowFiles.size(); Pos++)
+ {
+ const Ztring& Object=NewShowFiles.Read(Pos, 0);
+ if (Object==_T("Nothing"))
+ ShowFiles_Nothing=NewShowFiles.Read(Pos, 1).empty()?1:0;
+ else if (Object==_T("VideoAudio"))
+ ShowFiles_VideoAudio=NewShowFiles.Read(Pos, 1).empty()?1:0;
+ else if (Object==_T("VideoOnly"))
+ ShowFiles_VideoOnly=NewShowFiles.Read(Pos, 1).empty()?1:0;
+ else if (Object==_T("AudioOnly"))
+ ShowFiles_AudioOnly=NewShowFiles.Read(Pos, 1).empty()?1:0;
+ else if (Object==_T("TextOnly"))
+ ShowFiles_TextOnly=NewShowFiles.Read(Pos, 1).empty()?1:0;
+ }
+}
+
+size_t MediaInfo_Config::ShowFiles_Nothing_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return ShowFiles_Nothing;
+}
+
+size_t MediaInfo_Config::ShowFiles_VideoAudio_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return ShowFiles_VideoAudio;
+}
+
+size_t MediaInfo_Config::ShowFiles_VideoOnly_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return ShowFiles_VideoOnly;
+}
+
+size_t MediaInfo_Config::ShowFiles_AudioOnly_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return ShowFiles_AudioOnly;
+}
+
+size_t MediaInfo_Config::ShowFiles_TextOnly_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return ShowFiles_TextOnly;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::ParseSpeed_Set (float32 NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ ParseSpeed=NewValue;
+}
+
+float32 MediaInfo_Config::ParseSpeed_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return ParseSpeed;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Verbosity_Set (float32 NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Verbosity=NewValue;
+}
+
+float32 MediaInfo_Config::Verbosity_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Verbosity;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::ReadByHuman_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ ReadByHuman=NewValue;
+}
+
+bool MediaInfo_Config::ReadByHuman_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return ReadByHuman;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::LegacyStreamDisplay_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ LegacyStreamDisplay=NewValue;
+}
+
+bool MediaInfo_Config::LegacyStreamDisplay_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return LegacyStreamDisplay;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Trace_Level_Set (const ZtringListList &NewTrace_Level)
+{
+ CriticalSectionLocker CSL(CS);
+
+ //Global
+ if (NewTrace_Level.size()==1 && NewTrace_Level[0].size()==1)
+ {
+ Trace_Level=NewTrace_Level[0][0].To_float32();
+ if (Trace_Layers.to_ulong()==0) //if not set to a specific layer
+ Trace_Layers.set();
+ return;
+ }
+
+ //Per item
+ else
+ {
+ Trace_Layers.reset();
+ for (size_t Pos=0; Pos<NewTrace_Level.size(); Pos++)
+ {
+ if (NewTrace_Level[Pos].size()==2)
+ {
+ if (NewTrace_Level[Pos][0]==_T("Container1"))
+ Trace_Layers.set(0, NewTrace_Level[Pos][1].To_int64u()?true:false);
+ }
+ }
+ }
+}
+
+float32 MediaInfo_Config::Trace_Level_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Trace_Level;
+}
+
+std::bitset<32> MediaInfo_Config::Trace_Layers_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Trace_Layers;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Trace_TimeSection_OnlyFirstOccurrence_Set (bool Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Trace_TimeSection_OnlyFirstOccurrence=Value;
+}
+
+bool MediaInfo_Config::Trace_TimeSection_OnlyFirstOccurrence_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Trace_TimeSection_OnlyFirstOccurrence;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Trace_Format_Set (trace_Format NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Trace_Format=NewValue;
+}
+
+MediaInfo_Config::trace_Format MediaInfo_Config::Trace_Format_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Trace_Format;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Trace_Modificator_Set (const ZtringList &NewValue)
+{
+ ZtringList List(NewValue);
+ if (List.size()!=2)
+ return;
+ transform(List[0].begin(), List[0].end(), List[0].begin(), (int(*)(int))tolower); //(int(*)(int)) is a patch for unix
+
+ CriticalSectionLocker CSL(CS);
+ Trace_Modificators[List[0]]=List[1]==_T("1");
+}
+
+Ztring MediaInfo_Config::Trace_Modificator_Get (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ std::map<Ztring, bool>::iterator ToReturn=Trace_Modificators.find(Value);
+ if (ToReturn!=Trace_Modificators.end())
+ return ToReturn->second?_T("1"):_T("0");
+ else
+ return Ztring();
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Demux_Set (int8u NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Demux=NewValue;
+}
+
+int8u MediaInfo_Config::Demux_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Demux;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::LineSeparator_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ LineSeparator=NewValue;
+}
+
+Ztring MediaInfo_Config::LineSeparator_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return LineSeparator;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Version_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Version=ZtringListList(NewValue).Read(0); //Only the 1st value
+}
+
+Ztring MediaInfo_Config::Version_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Version;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::ColumnSeparator_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ ColumnSeparator=NewValue;
+}
+
+Ztring MediaInfo_Config::ColumnSeparator_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return ColumnSeparator;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::TagSeparator_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ TagSeparator=NewValue;
+}
+
+Ztring MediaInfo_Config::TagSeparator_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return TagSeparator;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Quote_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Quote=NewValue;
+}
+
+Ztring MediaInfo_Config::Quote_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Quote;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::DecimalPoint_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ DecimalPoint=NewValue;
+}
+
+Ztring MediaInfo_Config::DecimalPoint_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return DecimalPoint;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::ThousandsPoint_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ ThousandsPoint=NewValue;
+}
+
+Ztring MediaInfo_Config::ThousandsPoint_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return ThousandsPoint;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::StreamMax_Set (const ZtringListList &)
+{
+ CriticalSectionLocker CSL(CS);
+ //TODO : implementation
+}
+
+Ztring MediaInfo_Config::StreamMax_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ ZtringListList StreamMax;
+ //TODO : implementation
+ return StreamMax.Read();
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Language_Set (const ZtringListList &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+
+ //Which language to choose?
+ //-Raw
+ if (NewValue.size()==1 && NewValue[0].size()==1 && NewValue[0][0]==_T("raw"))
+ {
+ Language_Raw=true;
+ Language.clear();
+ //Exceptions
+ Language.Write(_T(" Config_Text_ColumnSize"), _T("32"));
+ Language.Write(_T(" Config_Text_Separator"), _T(" : "));
+ Language.Write(_T(" Config_Text_NumberTag"), _T(" #"));
+ Language.Write(_T(" Config_Text_FloatSeparator"), _T("."));
+ Language.Write(_T(" Config_Text_ThousandsSeparator"), Ztring());
+ }
+ //-Add custom language to English language
+ else
+ {
+ Language_Raw=false;
+ //Fill base words (with English translation)
+ MediaInfo_Config_DefaultLanguage(Language);
+ //Add custom language to English language
+ for (size_t Pos=0; Pos<NewValue.size(); Pos++)
+ if (NewValue[Pos].size()>=2)
+ Language.Write(NewValue[Pos][0], NewValue[Pos][1]);
+ else if (NewValue[Pos].size()==1)
+ Language.Write(NewValue[Pos][0], Ztring());
+ }
+
+ //Fill Info
+ for (size_t StreamKind=0; StreamKind<Stream_Max; StreamKind++)
+ if (!Info[StreamKind].empty())
+ Language_Set((stream_t)StreamKind);
+}
+
+void MediaInfo_Config::Language_Set (stream_t StreamKind)
+{
+ //CriticalSectionLocker CSL(CS); //No, only used internaly
+
+ //Fill Info
+ for (size_t Pos=0; Pos<Info[StreamKind].size(); Pos++)
+ {
+ //Strings - Info_Name_Text
+ Ztring ToReplace=Info[StreamKind](Pos, Info_Name);
+ if (!Language_Raw && ToReplace.find(_T("/String"))!=Error)
+ {
+ ToReplace.FindAndReplace(_T("/String1"), Ztring());
+ ToReplace.FindAndReplace(_T("/String2"), Ztring());
+ ToReplace.FindAndReplace(_T("/String3"), Ztring());
+ ToReplace.FindAndReplace(_T("/String4"), Ztring());
+ ToReplace.FindAndReplace(_T("/String5"), Ztring());
+ ToReplace.FindAndReplace(_T("/String6"), Ztring());
+ ToReplace.FindAndReplace(_T("/String7"), Ztring());
+ ToReplace.FindAndReplace(_T("/String8"), Ztring());
+ ToReplace.FindAndReplace(_T("/String9"), Ztring());
+ ToReplace.FindAndReplace(_T("/String"), Ztring());
+ }
+ if (!Language_Raw && ToReplace.find(_T("/"))!=Error) //Complex values, like XXX/YYY --> We translate both XXX and YYY
+ {
+ Ztring ToReplace1=ToReplace.SubString(Ztring(), _T("/"));
+ Ztring ToReplace2=ToReplace.SubString(_T("/"), Ztring());
+ Info[StreamKind](Pos, Info_Name_Text)=Language.Get(ToReplace1);
+ Info[StreamKind](Pos, Info_Name_Text)+=_T("/");
+ Info[StreamKind](Pos, Info_Name_Text)+=Language.Get(ToReplace2);
+ }
+ else
+ Info[StreamKind](Pos, Info_Name_Text)=Language.Get(ToReplace);
+ //Strings - Info_Measure_Text
+ Info[StreamKind](Pos, Info_Measure_Text).clear(); //I don(t know why, but if I don't do this Delphi/C# debugger make crashing the calling program
+ Info[StreamKind](Pos, Info_Measure_Text)=Language.Get(Info[StreamKind](Pos, Info_Measure));
+ //Slashes
+
+ }
+}
+
+Ztring MediaInfo_Config::Language_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ Ztring ToReturn;//TODO =Language.Read();
+ return ToReturn;
+}
+
+Ztring MediaInfo_Config::Language_Get (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+
+ if (Value.find(_T(" / "))==string::npos)
+ return Language.Get(Value);
+
+ ZtringList List;
+ List.Separator_Set(0, _T(" / "));
+ List.Write(Value);
+
+ //Per value
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ List[Pos]=Language.Get(List[Pos]);
+
+ return List.Read();
+}
+
+//---------------------------------------------------------------------------
+Ztring MediaInfo_Config::Language_Get (const Ztring &Count, const Ztring &Value, bool ValueIsAlwaysSame)
+{
+ //Integrity
+ if (Count.empty())
+ return EmptyString_Get();
+
+ //Different Plurals are available or not?
+ if (Language_Get(Value+_T("1")).empty())
+ {
+ //if (Count==_T("0") || Count==_T("1"))
+ return Count+Language_Get(Value);
+ //else
+ //return Count+Language_Get(Value+_T("s"));
+ }
+
+ //Detecting plural form for multiple plurals
+ int8u Form=(int8u)-1;
+
+ if (!ValueIsAlwaysSame)
+ {
+ //Polish has 2 plurial, Algorithm of Polish
+ size_t CountI=Count.To_int32u();
+ size_t Pos3=CountI/100;
+ int8u Pos2=(int8u)((CountI-Pos3*100)/10);
+ int8u Pos1=(int8u)(CountI-Pos3*100-Pos2*10);
+ if (Pos3==0)
+ {
+ if (Pos2==0)
+ {
+ if (Pos1==0 && Count.size()==1) //Only "0", not "0.xxx"
+ Form=0; //000 to 000 kanal?
+ else if (Pos1<=1)
+ Form=1; //001 to 001 kanal
+ else if (Pos1<=4)
+ Form=2; //002 to 004 kanaly
+ else //if (Pos1>=5)
+ Form=3; //005 to 009 kanalow
+ }
+ else if (Pos2==1)
+ Form=3; //010 to 019 kanalow
+ else //if (Pos2>=2)
+ {
+ if (Pos1<=1)
+ Form=3; //020 to 021, 090 to 091 kanalow
+ else if (Pos1<=4)
+ Form=2; //022 to 024, 092 to 094 kanali
+ else //if (Pos1>=5)
+ Form=3; //025 to 029, 095 to 099 kanalow
+ }
+ }
+ else //if (Pos3>=1)
+ {
+ if (Pos2==0)
+ {
+ if (Pos1<=1)
+ Form=3; //100 to 101 kanalow
+ else if (Pos1<=4)
+ Form=2; //102 to 104 kanaly
+ else //if (Pos1>=5)
+ Form=3; //105 to 109 kanalow
+ }
+ else if (Pos2==1)
+ Form=3; //110 to 119 kanalow
+ else //if (Pos2>=2)
+ {
+ if (Pos1<=1)
+ Form=3; //120 to 121, 990 to 991 kanalow
+ else if (Pos1<=4)
+ Form=2; //122 to 124, 992 to 994 kanali
+ else //if (Pos1>=5)
+ Form=3; //125 to 129, 995 to 999 kanalow
+ }
+ }
+ }
+
+ //Replace dot and thousand separator
+ Ztring ToReturn=Count;
+ Ztring DecimalPoint=Ztring().From_Number(0.0, 1).substr(1, 1); //Getting Decimal point
+ size_t DotPos=ToReturn.find(DecimalPoint);
+ if (DotPos!=string::npos)
+ ToReturn.FindAndReplace(DecimalPoint, Language_Get(_T(" Config_Text_FloatSeparator")), DotPos);
+ else
+ DotPos=ToReturn.size();
+ if (DotPos>3)
+ ToReturn.insert(DotPos-3, Language_Get(_T(" Config_Text_ThousandsSeparator")));
+
+ //Selecting the form
+ if (Form==0)
+ ToReturn =Language_Get(Value+_T("0")); //Only the translation
+ else if (Form==1)
+ ToReturn+=Language_Get(Value+_T("1"));
+ else if (Form==2)
+ ToReturn+=Language_Get(Value+_T("2"));
+ else if (Form==3)
+ ToReturn+=Language_Get(Value+_T("3"));
+ else
+ ToReturn+=Language_Get(Value);
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Inform_Set (const ZtringListList &NewValue)
+{
+ if (NewValue.Read(0, 0)==_T("Details"))
+ Trace_Level_Set(NewValue.Read(0, 1));
+ else
+ {
+ Trace_Level_Set(_T("0"));
+
+ CriticalSectionLocker CSL(CS);
+
+ //Inform
+ if (NewValue==_T("Summary"))
+ MediaInfo_Config_Summary(Custom_View);
+ else
+ Custom_View=NewValue;
+ }
+
+ CriticalSectionLocker CSL(CS);
+
+ //Parsing pointers to files in streams
+ for (size_t Pos=0; Pos<Custom_View.size(); Pos++)
+ {
+ if (Custom_View[Pos].size()>1 && Custom_View(Pos, 1).find(_T("file://"))==0)
+ {
+ //Open
+ Ztring FileName(Custom_View(Pos, 1), 7, Ztring::npos);
+ File F(FileName.c_str());
+
+ //Read
+ int64u Size=F.Size_Get();
+ if (Size>=0xFFFFFFFF)
+ Size=1024*1024;
+ int8u* Buffer=new int8u[(size_t)Size+1];
+ size_t F_Offset=F.Read(Buffer, (size_t)Size);
+ F.Close();
+ Buffer[F_Offset]='\0';
+ Ztring FromFile; FromFile.From_Local((char*)Buffer);
+ delete[] Buffer; //Buffer=NULL;
+
+ //Merge
+ FromFile.FindAndReplace(_T("\r\n"), _T("\\r\\n"), 0, Ztring_Recursive);
+ FromFile.FindAndReplace(_T("\n"), _T("\\r\\n"), 0, Ztring_Recursive);
+ Custom_View(Pos, 1)=FromFile;
+ }
+ }
+}
+
+Ztring MediaInfo_Config::Inform_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Custom_View.Read();
+}
+
+Ztring MediaInfo_Config::Inform_Get (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ size_t Pos=Custom_View.Find(Value);
+ if (Pos==Error || 1>=Custom_View[Pos].size())
+ return EmptyString_Get();
+ return Custom_View[Pos][1];
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config::Inform_Replace_Set (const ZtringListList &NewValue_Replace)
+{
+ CriticalSectionLocker CSL(CS);
+
+ //Parsing
+ for (size_t Pos=0; Pos<NewValue_Replace.size(); Pos++)
+ {
+ if (NewValue_Replace[Pos].size()==2)
+ Custom_View_Replace(NewValue_Replace[Pos][0])=NewValue_Replace[Pos][1];
+ }
+}
+
+Ztring MediaInfo_Config::Inform_Replace_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Custom_View.Read();
+}
+
+ZtringListList MediaInfo_Config::Inform_Replace_Get_All ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Custom_View_Replace;
+}
+
+//---------------------------------------------------------------------------
+const Ztring &MediaInfo_Config::Format_Get (const Ztring &Value, infoformat_t KindOfFormatInfo)
+{
+ //Loading codec table if not yet done
+ CS.Enter();
+ if (Format.empty())
+ MediaInfo_Config_Format(Format);
+ CS.Leave();
+
+ return Format.Get(Value, KindOfFormatInfo);
+}
+
+//---------------------------------------------------------------------------
+InfoMap &MediaInfo_Config::Format_Get ()
+{
+ //Loading codec table if not yet done
+ CS.Enter();
+ if (Format.empty())
+ MediaInfo_Config_Format(Format);
+ CS.Leave();
+
+ return Format;
+}
+
+//---------------------------------------------------------------------------
+const Ztring &MediaInfo_Config::Codec_Get (const Ztring &Value, infocodec_t KindOfCodecInfo)
+{
+ //Loading codec table if not yet done
+ CS.Enter();
+ if (Codec.empty())
+ MediaInfo_Config_Codec(Codec);
+ CS.Leave();
+
+ return Codec.Get(Value, KindOfCodecInfo);
+}
+
+//---------------------------------------------------------------------------
+const Ztring &MediaInfo_Config::Codec_Get (const Ztring &Value, infocodec_t KindOfCodecInfo, stream_t KindOfStream)
+{
+ //Loading codec table if not yet done
+ CS.Enter();
+ if (Codec.empty())
+ MediaInfo_Config_Codec(Codec);
+ CS.Leave();
+
+ //Transform to text
+ Ztring KindOfStreamS;
+ switch (KindOfStream)
+ {
+ case Stream_General : KindOfStreamS=_T("G"); break;
+ case Stream_Video : KindOfStreamS=_T("V"); break;
+ case Stream_Audio : KindOfStreamS=_T("A"); break;
+ case Stream_Text : KindOfStreamS=_T("T"); break;
+ case Stream_Image : KindOfStreamS=_T("I"); break;
+ case Stream_Chapters : KindOfStreamS=_T("C"); break;
+ case Stream_Menu : KindOfStreamS=_T("M"); break;
+ case Stream_Max : KindOfStreamS=_T(" "); break;
+ }
+
+ return Codec.Get(Value, KindOfCodecInfo, KindOfStreamS, InfoCodec_KindOfStream);
+}
+
+//---------------------------------------------------------------------------
+const Ztring &MediaInfo_Config::CodecID_Get (stream_t KindOfStream, infocodecid_format_t Format, const Ztring &Value, infocodecid_t KindOfCodecIDInfo)
+{
+ if (Format>=InfoCodecID_Format_Max || KindOfStream>=Stream_Max)
+ return EmptyString_Get();
+
+ CS.Enter();
+ if (CodecID[Format][KindOfStream].empty())
+ {
+ switch (KindOfStream)
+ {
+ case Stream_General :
+ switch (Format)
+ {
+ case InfoCodecID_Format_Mpeg4 : MediaInfo_Config_CodecID_General_Mpeg4(CodecID[Format][KindOfStream]); break;
+ default: ;
+ }
+ break;
+ case Stream_Video :
+ switch (Format)
+ {
+ case InfoCodecID_Format_Matroska : MediaInfo_Config_CodecID_Video_Matroska(CodecID[Format][KindOfStream]); break;
+ case InfoCodecID_Format_Mpeg4 : MediaInfo_Config_CodecID_Video_Mpeg4(CodecID[Format][KindOfStream]); break;
+ case InfoCodecID_Format_Real : MediaInfo_Config_CodecID_Video_Real(CodecID[Format][KindOfStream]); break;
+ case InfoCodecID_Format_Riff : MediaInfo_Config_CodecID_Video_Riff(CodecID[Format][KindOfStream]); break;
+ default: ;
+ }
+ break;
+ case Stream_Audio :
+ switch (Format)
+ {
+ case InfoCodecID_Format_Matroska : MediaInfo_Config_CodecID_Audio_Matroska(CodecID[Format][KindOfStream]); break;
+ case InfoCodecID_Format_Mpeg4 : MediaInfo_Config_CodecID_Audio_Mpeg4(CodecID[Format][KindOfStream]); break;
+ case InfoCodecID_Format_Real : MediaInfo_Config_CodecID_Audio_Real(CodecID[Format][KindOfStream]); break;
+ case InfoCodecID_Format_Riff : MediaInfo_Config_CodecID_Audio_Riff(CodecID[Format][KindOfStream]); break;
+ default: ;
+ }
+ break;
+ case Stream_Text :
+ switch (Format)
+ {
+ case InfoCodecID_Format_Matroska : MediaInfo_Config_CodecID_Text_Matroska(CodecID[Format][KindOfStream]); break;
+ case InfoCodecID_Format_Mpeg4 : MediaInfo_Config_CodecID_Text_Mpeg4(CodecID[Format][KindOfStream]); break;
+ case InfoCodecID_Format_Riff : MediaInfo_Config_CodecID_Text_Riff(CodecID[Format][KindOfStream]); break;
+ default: ;
+ }
+ break;
+ default: ;
+ }
+ }
+ CS.Leave();
+ return CodecID[Format][KindOfStream].Get(Value, KindOfCodecIDInfo);
+}
+
+//---------------------------------------------------------------------------
+const Ztring &MediaInfo_Config::Library_Get (infolibrary_format_t Format, const Ztring &Value, infolibrary_t KindOfLibraryInfo)
+{
+ if (Format>=InfoLibrary_Format_Max)
+ return EmptyString_Get();
+
+ CS.Enter();
+ if (Library[Format].empty())
+ {
+ switch (Format)
+ {
+ case InfoLibrary_Format_DivX : MediaInfo_Config_Library_DivX(Library[Format]); break;
+ case InfoLibrary_Format_XviD : MediaInfo_Config_Library_XviD(Library[Format]); break;
+ case InfoLibrary_Format_MainConcept_Avc : MediaInfo_Config_Library_MainConcept_Avc(Library[Format]); break;
+ case InfoLibrary_Format_VorbisCom : MediaInfo_Config_Library_VorbisCom(Library[Format]); break;
+ default: ;
+ }
+ }
+ CS.Leave();
+ return Library[Format].Get(Value, KindOfLibraryInfo);
+}
+
+//---------------------------------------------------------------------------
+const Ztring &MediaInfo_Config::Iso639_1_Get (const Ztring &Value)
+{
+ //Loading codec table if not yet done
+ CS.Enter();
+ if (Iso639_1.empty())
+ MediaInfo_Config_Iso639_1(Iso639_1);
+ CS.Leave();
+
+ return Iso639_1.Get(Ztring(Value).MakeLowerCase(), 1);
+}
+
+//---------------------------------------------------------------------------
+const Ztring &MediaInfo_Config::Iso639_2_Get (const Ztring &Value)
+{
+ //Loading codec table if not yet done
+ CS.Enter();
+ if (Iso639_2.empty())
+ MediaInfo_Config_Iso639_2(Iso639_2);
+ CS.Leave();
+
+ return Iso639_2.Get(Ztring(Value).MakeLowerCase(), 1);
+}
+
+//---------------------------------------------------------------------------
+const Ztring MediaInfo_Config::Iso639_Find (const Ztring &Value)
+{
+ Translation Info;
+ MediaInfo_Config_DefaultLanguage (Info);
+ Ztring Value_Lower(Value);
+ Value_Lower.MakeLowerCase();
+
+ for (Translation::iterator Trans=Info.begin(); Trans!=Info.end(); Trans++)
+ {
+ Trans->second.MakeLowerCase();
+ if (Trans->second==Value_Lower && Trans->first.find(_T("Language_"))==0)
+ return Trans->first.substr(9, string::npos);
+ }
+ return Ztring();
+}
+
+//---------------------------------------------------------------------------
+const Ztring &MediaInfo_Config::Info_Get (stream_t KindOfStream, const Ztring &Value, info_t KindOfInfo)
+{
+ //Loading codec table if not yet done
+ CS.Enter();
+ if (Info[KindOfStream].empty())
+ switch (KindOfStream)
+ {
+ case Stream_General : MediaInfo_Config_General(Info[Stream_General]); Language_Set(Stream_General); break;
+ case Stream_Video : MediaInfo_Config_Video(Info[Stream_Video]); Language_Set(Stream_Video); break;
+ case Stream_Audio : MediaInfo_Config_Audio(Info[Stream_Audio]); Language_Set(Stream_Audio); break;
+ case Stream_Text : MediaInfo_Config_Text(Info[Stream_Text]); Language_Set(Stream_Text); break;
+ case Stream_Chapters : MediaInfo_Config_Chapters(Info[Stream_Chapters]); Language_Set(Stream_Chapters); break;
+ case Stream_Image : MediaInfo_Config_Image(Info[Stream_Image]); Language_Set(Stream_Image); break;
+ case Stream_Menu : MediaInfo_Config_Menu(Info[Stream_Menu]); Language_Set(Stream_Menu); break;
+ default:;
+ }
+ CS.Leave();
+
+ if (KindOfStream>=Stream_Max)
+ return EmptyString_Get();
+ size_t Pos=Info[KindOfStream].Find(Value);
+ if (Pos==Error || (size_t)KindOfInfo>=Info[KindOfStream][Pos].size())
+ return EmptyString_Get();
+ return Info[KindOfStream][Pos][KindOfInfo];
+}
+
+const Ztring &MediaInfo_Config::Info_Get (stream_t KindOfStream, size_t Pos, info_t KindOfInfo)
+{
+ //Loading codec table if not yet done
+ CS.Enter();
+ if (Info[KindOfStream].empty())
+ switch (KindOfStream)
+ {
+ case Stream_General : MediaInfo_Config_General(Info[Stream_General]); Language_Set(Stream_General); break;
+ case Stream_Video : MediaInfo_Config_Video(Info[Stream_Video]); Language_Set(Stream_Video); break;
+ case Stream_Audio : MediaInfo_Config_Audio(Info[Stream_Audio]); Language_Set(Stream_Audio); break;
+ case Stream_Text : MediaInfo_Config_Text(Info[Stream_Text]); Language_Set(Stream_Text); break;
+ case Stream_Chapters : MediaInfo_Config_Chapters(Info[Stream_Chapters]); Language_Set(Stream_Chapters); break;
+ case Stream_Image : MediaInfo_Config_Image(Info[Stream_Image]); Language_Set(Stream_Image); break;
+ case Stream_Menu : MediaInfo_Config_Menu(Info[Stream_Menu]); Language_Set(Stream_Menu); break;
+ default:;
+ }
+ CS.Leave();
+
+ if (KindOfStream>=Stream_Max)
+ return EmptyString_Get();
+ if (Pos>=Info[KindOfStream].size() || (size_t)KindOfInfo>=Info[KindOfStream][Pos].size())
+ return EmptyString_Get();
+ return Info[KindOfStream][Pos][KindOfInfo];
+}
+
+const ZtringListList &MediaInfo_Config::Info_Get(stream_t KindOfStream)
+{
+ if (KindOfStream>=Stream_Max)
+ return EmptyStringListList_Get();
+
+ //Loading codec table if not yet done
+ CS.Enter();
+ if (Info[KindOfStream].empty())
+ switch (KindOfStream)
+ {
+ case Stream_General : MediaInfo_Config_General(Info[Stream_General]); Language_Set(Stream_General); break;
+ case Stream_Video : MediaInfo_Config_Video(Info[Stream_Video]); Language_Set(Stream_Video); break;
+ case Stream_Audio : MediaInfo_Config_Audio(Info[Stream_Audio]); Language_Set(Stream_Audio); break;
+ case Stream_Text : MediaInfo_Config_Text(Info[Stream_Text]); Language_Set(Stream_Text); break;
+ case Stream_Chapters : MediaInfo_Config_Chapters(Info[Stream_Chapters]); Language_Set(Stream_Chapters); break;
+ case Stream_Image : MediaInfo_Config_Image(Info[Stream_Image]); Language_Set(Stream_Image); break;
+ case Stream_Menu : MediaInfo_Config_Menu(Info[Stream_Menu]); Language_Set(Stream_Menu); break;
+ default:;
+ }
+ CS.Leave();
+
+ return Info[KindOfStream];
+}
+
+//---------------------------------------------------------------------------
+Ztring MediaInfo_Config::Info_Parameters_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ //Loading all
+ MediaInfo_Config_General(Info[Stream_General]);
+ MediaInfo_Config_Video(Info[Stream_Video]);
+ MediaInfo_Config_Audio(Info[Stream_Audio]);
+ MediaInfo_Config_Text(Info[Stream_Text]);
+ MediaInfo_Config_Chapters(Info[Stream_Chapters]);
+ MediaInfo_Config_Image(Info[Stream_Image]);
+ MediaInfo_Config_Menu(Info[Stream_Menu]);
+
+ //Building
+ ZtringListList ToReturn;
+ size_t ToReturn_Pos=0;
+
+ for (size_t StreamKind=0; StreamKind<Stream_Max; StreamKind++)
+ {
+ ToReturn(ToReturn_Pos, 0)=Info[StreamKind].Read(_T("StreamKind"), Info_Text);
+ ToReturn_Pos++;
+ for (size_t Pos=0; Pos<Info[StreamKind].size(); Pos++)
+ if (!Info[StreamKind].Read(Pos, Info_Name).empty())
+ {
+ ToReturn(ToReturn_Pos, 0)=Info[StreamKind].Read(Pos, Info_Name);
+ ToReturn(ToReturn_Pos, 1)=Info[StreamKind].Read(Pos, Info_Info);
+ ToReturn_Pos++;
+ }
+ ToReturn_Pos++;
+ }
+ return ToReturn.Read();
+}
+
+//---------------------------------------------------------------------------
+Ztring MediaInfo_Config::Info_Tags_Get () const
+{
+ return Ztring();
+}
+
+Ztring MediaInfo_Config::Info_Codecs_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ //Loading
+ MediaInfo_Config_Codec(Codec);
+
+ //Building
+ Ztring ToReturn;
+ InfoMap::iterator Temp=Codec.begin();
+ while (Temp!=Codec.end())
+ {
+ ToReturn+=Temp->second.Read();
+ ToReturn+=EOL;
+ Temp++;
+ }
+
+ return ToReturn;
+}
+
+Ztring MediaInfo_Config::Info_Version_Get () const
+{
+ return MediaInfo_Version;
+}
+
+Ztring MediaInfo_Config::Info_Url_Get () const
+{
+ return MediaInfo_Url;
+}
+
+const Ztring &MediaInfo_Config::EmptyString_Get () const
+{
+ return EmptyZtring_Const;
+}
+
+const ZtringListList &MediaInfo_Config::EmptyStringListList_Get () const
+{
+ return EmptyZtringListList_Const;
+}
+
+void MediaInfo_Config::FormatDetection_MaximumOffset_Set (int64u Value)
+{
+ CriticalSectionLocker CSL(CS);
+ FormatDetection_MaximumOffset=Value;
+}
+
+int64u MediaInfo_Config::FormatDetection_MaximumOffset_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return FormatDetection_MaximumOffset;
+}
+
+void MediaInfo_Config::MpegTs_MaximumOffset_Set (int64u Value)
+{
+ CriticalSectionLocker CSL(CS);
+ MpegTs_MaximumOffset=Value;
+}
+
+int64u MediaInfo_Config::MpegTs_MaximumOffset_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return MpegTs_MaximumOffset;
+}
+
+void MediaInfo_Config::MpegTs_MaximumScanDuration_Set (int64u Value)
+{
+ CriticalSectionLocker CSL(CS);
+ MpegTs_MaximumScanDuration=Value;
+}
+
+int64u MediaInfo_Config::MpegTs_MaximumScanDuration_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return MpegTs_MaximumScanDuration;
+}
+
+void MediaInfo_Config::MpegTs_ForceStreamDisplay_Set (bool Value)
+{
+ CriticalSectionLocker CSL(CS);
+ MpegTs_ForceStreamDisplay=Value;
+}
+
+bool MediaInfo_Config::MpegTs_ForceStreamDisplay_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return MpegTs_ForceStreamDisplay;
+}
+
+//***************************************************************************
+// SubFile
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+ZtringListList MediaInfo_Config::SubFile_Config_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ return SubFile_Config;
+}
+
+//***************************************************************************
+// Custom mapping
+//***************************************************************************
+
+void MediaInfo_Config::CustomMapping_Set (const Ztring &Value)
+{
+ ZtringList List; List.Separator_Set(0, _T(","));
+ List.Write(Value);
+ if (List.size()==3)
+ {
+ CriticalSectionLocker CSL(CS);
+ CustomMapping[List[0]][List[1]]=List[2];
+ }
+}
+
+Ztring MediaInfo_Config::CustomMapping_Get (const Ztring &Format, const Ztring &Field)
+{
+ CriticalSectionLocker CSL(CS);
+ return CustomMapping[Format][Field];
+}
+
+bool MediaInfo_Config::CustomMapping_IsPresent(const Ztring &Format, const Ztring &Field)
+{
+ CriticalSectionLocker CSL(CS);
+ std::map<Ztring, std::map<Ztring, Ztring> >::iterator PerFormat=CustomMapping.find(Format);
+ if (PerFormat==CustomMapping.end())
+ return false;
+ std::map<Ztring, Ztring>::iterator PerField=PerFormat->second.find(Field);
+ if (PerField==PerFormat->second.end())
+ return false;
+ return true;
+}
+
+//***************************************************************************
+// Event
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+bool MediaInfo_Config::Event_CallBackFunction_IsSet ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ return Event_CallBackFunction?true:false;
+}
+#endif //MEDIAINFO_EVENTS
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+Ztring MediaInfo_Config::Event_CallBackFunction_Set (const Ztring &Value)
+{
+ ZtringList List=Value;
+
+ CriticalSectionLocker CSL(CS);
+
+ if (List.empty())
+ {
+ Event_CallBackFunction=(MediaInfo_Event_CallBackFunction*)NULL;
+ Event_UserHandler=NULL;
+ }
+ else
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ if (List[Pos].find(_T("CallBack=memory://"))==0)
+ Event_CallBackFunction=(MediaInfo_Event_CallBackFunction*)Ztring(List[Pos].substr(18, std::string::npos)).To_int64u();
+ else if (List[Pos].find(_T("UserHandle=memory://"))==0)
+ Event_UserHandler=(void*)Ztring(List[Pos].substr(20, std::string::npos)).To_int64u();
+ else if (List[Pos].find(_T("UserHandler=memory://"))==0)
+ Event_UserHandler=(void*)Ztring(List[Pos].substr(21, std::string::npos)).To_int64u();
+ else
+ return("Problem during Event_CallBackFunction value parsing");
+ }
+
+ return Ztring();
+}
+#endif //MEDIAINFO_EVENTS
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+Ztring MediaInfo_Config::Event_CallBackFunction_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ return _T("CallBack=memory://")+Ztring::ToZtring((size_t)Event_CallBackFunction)+_T(";UserHandler=memory://")+Ztring::ToZtring((size_t)Event_UserHandler);
+}
+#endif //MEDIAINFO_EVENTS
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+void MediaInfo_Config::Event_Send (const int8u* Data_Content, size_t Data_Size)
+{
+ CriticalSectionLocker CSL(CS);
+
+ if (Event_CallBackFunction)
+ Event_CallBackFunction ((unsigned char*)Data_Content, Data_Size, Event_UserHandler);
+}
+#endif //MEDIAINFO_EVENTS
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+void MediaInfo_Config::Event_Send (const int8u* Data_Content, size_t Data_Size, const Ztring &File_Name)
+{
+ CriticalSectionLocker CSL(CS);
+
+ if (Event_CallBackFunction)
+ Event_CallBackFunction ((unsigned char*)Data_Content, Data_Size, Event_UserHandler);
+}
+#endif //MEDIAINFO_EVENTS
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+void MediaInfo_Config::Log_Send (int8u Type, int8u Severity, int32u MessageCode, const Ztring &Message)
+{
+ struct MediaInfo_Event_Log_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_Log, 0);
+ Event.Type=Type;
+ Event.Severity=Severity;
+ Event.Reserved2=(int8u)-1;
+ Event.Reserved3=(int8u)-1;
+ Event.MessageCode=MessageCode;
+ Event.Reserved4=(int32u)-1;
+ wstring MessageU=Message.To_Unicode();
+ string MessageA=Message.To_Local();
+ Event.MessageStringU=MessageU.c_str();
+ Event.MessageStringA=MessageA.c_str();
+ Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_Log_0));
+}
+#endif //MEDIAINFO_EVENTS
+
+//***************************************************************************
+// Curl
+//***************************************************************************
+
+#if defined(MEDIAINFO_LIBCURL_YES)
+void MediaInfo_Config::Ssh_PublicKeyFileName_Set (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ssh_PublicKeyFileName=Value;
+}
+
+Ztring MediaInfo_Config::Ssh_PublicKeyFileName_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssh_PublicKeyFileName;
+}
+
+void MediaInfo_Config::Ssh_PrivateKeyFileName_Set (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ssh_PrivateKeyFileName=Value;
+}
+
+Ztring MediaInfo_Config::Ssh_PrivateKeyFileName_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssh_PrivateKeyFileName;
+}
+
+void MediaInfo_Config::Ssh_KnownHostsFileName_Set (const Ztring &Value)
+{
+ if (Value.empty())
+ return; //empty value means "disable security" for libcurl, not acceptable
+
+ CriticalSectionLocker CSL(CS);
+ Ssh_KnownHostsFileName=Value;
+}
+
+Ztring MediaInfo_Config::Ssh_KnownHostsFileName_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssh_KnownHostsFileName;
+}
+
+void MediaInfo_Config::Ssh_IgnoreSecurity_Set (bool Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ssh_IgnoreSecurity=Value;
+}
+
+bool MediaInfo_Config::Ssh_IgnoreSecurity_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssh_IgnoreSecurity;
+}
+
+void MediaInfo_Config::Ssl_CertificateFileName_Set (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ssl_CertificateFileName=Value;
+}
+
+Ztring MediaInfo_Config::Ssl_CertificateFileName_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssl_CertificateFileName;
+}
+
+void MediaInfo_Config::Ssl_CertificateFormat_Set (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ssl_CertificateFormat=Value;
+}
+
+Ztring MediaInfo_Config::Ssl_CertificateFormat_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssl_CertificateFormat;
+}
+
+void MediaInfo_Config::Ssl_PrivateKeyFileName_Set (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ssl_PrivateKeyFileName=Value;
+}
+
+Ztring MediaInfo_Config::Ssl_PrivateKeyFileName_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssl_PrivateKeyFileName;
+}
+
+void MediaInfo_Config::Ssl_PrivateKeyFormat_Set (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ssl_PrivateKeyFormat=Value;
+}
+
+Ztring MediaInfo_Config::Ssl_PrivateKeyFormat_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssl_PrivateKeyFormat;
+}
+
+void MediaInfo_Config::Ssl_CertificateAuthorityFileName_Set (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ssl_CertificateAuthorityFileName=Value;
+}
+
+Ztring MediaInfo_Config::Ssl_CertificateAuthorityFileName_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssl_CertificateAuthorityFileName;
+}
+
+void MediaInfo_Config::Ssl_CertificateAuthorityPath_Set (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ssl_CertificateAuthorityPath=Value;
+}
+
+Ztring MediaInfo_Config::Ssl_CertificateAuthorityPath_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssl_CertificateAuthorityPath;
+}
+
+void MediaInfo_Config::Ssl_CertificateRevocationListFileName_Set (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ssl_CertificateRevocationListFileName=Value;
+}
+
+Ztring MediaInfo_Config::Ssl_CertificateRevocationListFileName_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssl_CertificateRevocationListFileName;
+}
+
+void MediaInfo_Config::Ssl_IgnoreSecurity_Set (bool Value)
+{
+ CriticalSectionLocker CSL(CS);
+ Ssl_IgnoreSecurity=Value;
+}
+
+bool MediaInfo_Config::Ssl_IgnoreSecurity_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ssl_IgnoreSecurity;
+}
+
+#endif //defined(MEDIAINFO_LIBCURL_YES)
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config.h b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config.h
new file mode 100644
index 000000000..6e026bd53
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config.h
@@ -0,0 +1,317 @@
+// MediaInfo_Config - Configuration class
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Global configuration of MediaInfo
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_ConfigH
+#define MediaInfo_ConfigH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo_Internal_Const.h"
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#include "ZenLib/CriticalSection.h"
+#include "ZenLib/ZtringListList.h"
+#include "ZenLib/Translation.h"
+#include "ZenLib/InfoMap.h"
+#include <map>
+#include <vector>
+#include <bitset>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class MediaInfo_Config
+//***************************************************************************
+
+class MediaInfo_Config
+{
+public :
+ //Constructor/Destructor
+ void Init(); //Must be called instead of constructor
+
+ //General
+ Ztring Option (const String &Option, const String &Value=Ztring());
+
+ //Info
+ void Complete_Set (size_t NewValue);
+ size_t Complete_Get ();
+
+ void BlockMethod_Set (size_t NewValue);
+ size_t BlockMethod_Get ();
+
+ void Internet_Set (size_t NewValue);
+ size_t Internet_Get ();
+
+ void MultipleValues_Set (size_t NewValue);
+ size_t MultipleValues_Get ();
+
+ void ParseUnknownExtensions_Set (size_t NewValue);
+ size_t ParseUnknownExtensions_Get ();
+
+ void ShowFiles_Set (const ZtringListList &NewShowFiles);
+ size_t ShowFiles_Nothing_Get ();
+ size_t ShowFiles_VideoAudio_Get ();
+ size_t ShowFiles_VideoOnly_Get ();
+ size_t ShowFiles_AudioOnly_Get ();
+ size_t ShowFiles_TextOnly_Get ();
+
+ void ReadByHuman_Set (bool NewValue);
+ bool ReadByHuman_Get ();
+
+ void LegacyStreamDisplay_Set (bool Value);
+ bool LegacyStreamDisplay_Get ();
+
+ void ParseSpeed_Set (float32 NewValue);
+ float32 ParseSpeed_Get ();
+
+ void Verbosity_Set (float32 NewValue);
+ float32 Verbosity_Get ();
+
+ void Trace_Level_Set (const ZtringListList &NewDetailsLevel);
+ float32 Trace_Level_Get ();
+ std::bitset<32> Trace_Layers_Get ();
+
+ void Trace_TimeSection_OnlyFirstOccurrence_Set (bool Value);
+ bool Trace_TimeSection_OnlyFirstOccurrence_Get ();
+
+ enum trace_Format
+ {
+ Trace_Format_Tree,
+ Trace_Format_CSV,
+ };
+ void Trace_Format_Set (trace_Format NewValue);
+ trace_Format Trace_Format_Get ();
+
+ void Trace_Modificator_Set (const ZtringList &NewModifcator); //Not implemented
+ Ztring Trace_Modificator_Get (const Ztring &Modificator); //Not implemented
+
+ void Demux_Set (int8u NewValue);
+ int8u Demux_Get ();
+
+ void LineSeparator_Set (const Ztring &NewValue);
+ Ztring LineSeparator_Get ();
+
+ void Version_Set (const Ztring &NewValue);
+ Ztring Version_Get ();
+
+ void ColumnSeparator_Set (const Ztring &NewValue);
+ Ztring ColumnSeparator_Get ();
+
+ void TagSeparator_Set (const Ztring &NewValue);
+ Ztring TagSeparator_Get ();
+
+ void Quote_Set (const Ztring &NewValue);
+ Ztring Quote_Get ();
+
+ void DecimalPoint_Set (const Ztring &NewValue);
+ Ztring DecimalPoint_Get ();
+
+ void ThousandsPoint_Set (const Ztring &NewValue);
+ Ztring ThousandsPoint_Get ();
+
+ void StreamMax_Set (const ZtringListList &NewValue);
+ Ztring StreamMax_Get ();
+
+ void Language_Set (const ZtringListList &NewLanguage);
+ Ztring Language_Get ();
+ Ztring Language_Get (const Ztring &Value);
+ Ztring Language_Get (const Ztring &Count, const Ztring &Value, bool ValueIsAlwaysSame=false);
+
+ void Inform_Set (const ZtringListList &NewInform);
+ Ztring Inform_Get ();
+ Ztring Inform_Get (const Ztring &Value);
+
+ void Inform_Replace_Set (const ZtringListList &NewInform_Replace);
+ Ztring Inform_Replace_Get ();
+ ZtringListList Inform_Replace_Get_All ();
+
+ const Ztring &Format_Get (const Ztring &Value, infoformat_t KindOfFormatInfo=InfoFormat_Name);
+ InfoMap &Format_Get(); //Should not be, but too difficult to hide it
+
+ const Ztring &Codec_Get (const Ztring &Value, infocodec_t KindOfCodecInfo=InfoCodec_Name);
+ const Ztring &Codec_Get (const Ztring &Value, infocodec_t KindOfCodecInfo, stream_t KindOfStream);
+
+ const Ztring &CodecID_Get (stream_t KindOfStream, infocodecid_format_t Format, const Ztring &Value, infocodecid_t KindOfCodecIDInfo=InfoCodecID_Format);
+
+ const Ztring &Library_Get (infolibrary_format_t Format, const Ztring &Value, infolibrary_t KindOfLibraryInfo=InfoLibrary_Version);
+
+ const Ztring &Iso639_1_Get (const Ztring &Value);
+ const Ztring &Iso639_2_Get (const Ztring &Value);
+ const Ztring Iso639_Find (const Ztring &Value);
+
+ const Ztring &Info_Get (stream_t KindOfStream, const Ztring &Value, info_t KindOfInfo=Info_Text);
+ const Ztring &Info_Get (stream_t KindOfStream, size_t Pos, info_t KindOfInfo=Info_Text);
+ const ZtringListList &Info_Get(stream_t KindOfStream); //Should not be, but too difficult to hide it
+
+ Ztring Info_Parameters_Get ();
+ Ztring Info_Tags_Get () const;
+ Ztring Info_CodecsID_Get ();
+ Ztring Info_Codecs_Get ();
+ Ztring Info_Version_Get () const;
+ Ztring Info_Url_Get () const;
+
+ const Ztring &EmptyString_Get() const; //Use it when we can't return a reference to a true string
+ const ZtringListList &EmptyStringListList_Get() const; //Use it when we can't return a reference to a true string list list
+
+ void FormatDetection_MaximumOffset_Set (int64u Value);
+ int64u FormatDetection_MaximumOffset_Get ();
+
+ void MpegTs_MaximumOffset_Set (int64u Value);
+ int64u MpegTs_MaximumOffset_Get ();
+ void MpegTs_MaximumScanDuration_Set (int64u Value);
+ int64u MpegTs_MaximumScanDuration_Get ();
+ void MpegTs_ForceStreamDisplay_Set (bool Value);
+ bool MpegTs_ForceStreamDisplay_Get ();
+
+ ZtringListList SubFile_Config_Get ();
+
+ void CustomMapping_Set (const Ztring &Value);
+ Ztring CustomMapping_Get (const Ztring &Format, const Ztring &Field);
+ bool CustomMapping_IsPresent (const Ztring &Format, const Ztring &Field);
+
+ void ErrorLog_Callback_Set(const Ztring &Value);
+ void ErrorLog(const Ztring &Value);
+
+ #if MEDIAINFO_EVENTS
+ bool Event_CallBackFunction_IsSet ();
+ Ztring Event_CallBackFunction_Set (const Ztring &Value);
+ Ztring Event_CallBackFunction_Get ();
+ void Event_Send(const int8u* Data_Content, size_t Data_Size);
+ void Event_Send(const int8u* Data_Content, size_t Data_Size, const Ztring &File_Name);
+ void Log_Send(int8u Type, int8u Severity, int32u MessageCode, const Ztring &Message);
+ void Log_Send(int8u Type, int8u Severity, int32u MessageCode, const char* Message) {return Log_Send(Type, Severity, MessageCode, Ztring().From_Local(Message));}
+ #endif //MEDIAINFO_EVENTS
+
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ void Ssh_PublicKeyFileName_Set (const Ztring &NewValue);
+ Ztring Ssh_PublicKeyFileName_Get ();
+ void Ssh_PrivateKeyFileName_Set (const Ztring &NewValue);
+ Ztring Ssh_PrivateKeyFileName_Get ();
+ void Ssh_IgnoreSecurity_Set (bool NewValue);
+ void Ssh_KnownHostsFileName_Set (const Ztring &NewValue);
+ Ztring Ssh_KnownHostsFileName_Get ();
+ bool Ssh_IgnoreSecurity_Get ();
+ void Ssl_CertificateFileName_Set (const Ztring &NewValue);
+ Ztring Ssl_CertificateFileName_Get ();
+ void Ssl_CertificateFormat_Set (const Ztring &NewValue);
+ Ztring Ssl_CertificateFormat_Get ();
+ void Ssl_PrivateKeyFileName_Set (const Ztring &NewValue);
+ Ztring Ssl_PrivateKeyFileName_Get ();
+ void Ssl_PrivateKeyFormat_Set (const Ztring &NewValue);
+ Ztring Ssl_PrivateKeyFormat_Get ();
+ void Ssl_CertificateAuthorityFileName_Set (const Ztring &NewValue);
+ Ztring Ssl_CertificateAuthorityFileName_Get ();
+ void Ssl_CertificateAuthorityPath_Set (const Ztring &NewValue);
+ Ztring Ssl_CertificateAuthorityPath_Get ();
+ void Ssl_CertificateRevocationListFileName_Set (const Ztring &NewValue);
+ Ztring Ssl_CertificateRevocationListFileName_Get ();
+ void Ssl_IgnoreSecurity_Set (bool NewValue);
+ bool Ssl_IgnoreSecurity_Get ();
+ #endif //defined(MEDIAINFO_LIBCURL_YES)
+
+private :
+ int64u MpegTs_MaximumScanDuration;
+ int64u FormatDetection_MaximumOffset;
+ int64u MpegTs_MaximumOffset;
+ bool MpegTs_ForceStreamDisplay;
+ size_t Complete;
+ size_t BlockMethod;
+ size_t Internet;
+ size_t MultipleValues;
+ size_t ParseUnknownExtensions;
+ size_t ShowFiles_Nothing;
+ size_t ShowFiles_VideoAudio;
+ size_t ShowFiles_VideoOnly;
+ size_t ShowFiles_AudioOnly;
+ size_t ShowFiles_TextOnly;
+ float32 ParseSpeed;
+ float32 Verbosity;
+ float32 Trace_Level;
+ bool Trace_TimeSection_OnlyFirstOccurrence;
+ std::bitset<32> Trace_Layers; //0-7: Container, 8: Stream
+ std::map<Ztring, bool> Trace_Modificators; //If we want to add/remove some details
+ bool Language_Raw;
+ bool ReadByHuman;
+ bool LegacyStreamDisplay;
+ int8u Demux;
+ Ztring Version;
+ Ztring ColumnSeparator;
+ Ztring LineSeparator;
+ Ztring TagSeparator;
+ Ztring Quote;
+ Ztring DecimalPoint;
+ Ztring ThousandsPoint;
+ Translation Language; //ex. : "KB;Ko"
+ ZtringListList Custom_View; //Definition of "General", "Video", "Audio", "Text", "Chapters", "Image"
+ ZtringListList Custom_View_Replace; //ToReplace;ReplaceBy
+ trace_Format Trace_Format;
+
+ InfoMap Container;
+ InfoMap CodecID[InfoCodecID_Format_Max][Stream_Max];
+ InfoMap Format;
+ InfoMap Codec;
+ InfoMap Library[InfoLibrary_Format_Max];
+ InfoMap Iso639_1;
+ InfoMap Iso639_2;
+ ZtringListList Info[Stream_Max]; //General info
+
+ ZtringListList SubFile_Config;
+
+ std::map<Ztring, std::map<Ztring, Ztring> > CustomMapping;
+
+ ZenLib::CriticalSection CS;
+
+ void Language_Set (stream_t StreamKind);
+
+ //Event
+ #if MEDIAINFO_EVENTS
+ MediaInfo_Event_CallBackFunction* Event_CallBackFunction; //void Event_Handler(unsigned char* Data_Content, size_t Data_Size, void* UserHandler)
+ void* Event_UserHandler;
+ #endif //MEDIAINFO_EVENTS
+
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ Ztring Ssh_PublicKeyFileName;
+ Ztring Ssh_PrivateKeyFileName;
+ Ztring Ssh_KnownHostsFileName;
+ bool Ssh_IgnoreSecurity;
+ Ztring Ssl_CertificateFileName;
+ Ztring Ssl_CertificateFormat;
+ Ztring Ssl_PrivateKeyFileName;
+ Ztring Ssl_PrivateKeyFormat;
+ Ztring Ssl_CertificateAuthorityFileName;
+ Ztring Ssl_CertificateAuthorityPath;
+ Ztring Ssl_CertificateRevocationListFileName;
+ bool Ssl_IgnoreSecurity;
+ #endif //defined(MEDIAINFO_LIBCURL_YES)
+};
+
+extern MediaInfo_Config Config;
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_Automatic.cpp b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_Automatic.cpp
new file mode 100644
index 000000000..7518dd291
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_Automatic.cpp
@@ -0,0 +1,5611 @@
+// Helpers - Automaticly generated methods for MediaInfo
+// Copyright (C) 2005-2007 Jerome Martinez, Zen@MediaArea.net
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Automaticly generated methods for MediaInfo
+// Don't modify, this will be deleted at the next automatic update
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/PreComp.h"
+#include "ZenLib/ZtringListList.h"
+#include "ZenLib/InfoMap.h"
+#include "ZenLib/Translation.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_DefaultLanguage (Translation &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ " Language_ISO639;en\n"
+ " Author_Email;Zen@mediaarea.net\n"
+ " Author_Name;Zen\n"
+ " Author_OldNames;Initial translator\n"
+ " Language_Name;English\n"
+ " Config_Text_ColumnSize;40\n"
+ " Config_Text_Separator; : \n"
+ " Config_Text_NumberTag; #\n"
+ " Config_Text_FloatSeparator;.\n"
+ " Config_Text_ThousandsSeparator; \n"
+ " audio stream1; audio stream\n"
+ " audio stream2; audio streams\n"
+ " audio stream3; audio streams\n"
+ " bit1; bit\n"
+ " bit2; bits\n"
+ " bit3; bits\n"
+ " bps; bps\n"
+ " Bps; Bps\n"
+ " Byte1; Byte\n"
+ " Byte2; Bytes\n"
+ " Byte3; Bytes\n"
+ " channel1; channel\n"
+ " channel2; channels\n"
+ " channel3; channels\n"
+ " chapter1; chapter\n"
+ " chapter2; chapters\n"
+ " chapter3; chapters\n"
+ " chapters stream1; chapters stream\n"
+ " chapters stream2; chapters streams\n"
+ " chapters stream3; chapters streams\n"
+ " day1; day\n"
+ " day2; days\n"
+ " day3; days\n"
+ " dB1; dB\n"
+ " dB2; dB\n"
+ " dB3; dB\n"
+ " file1; file\n"
+ " file2; files\n"
+ " file3; files\n"
+ " frame1; frame\n"
+ " frame2; frames\n"
+ " frame3; frames\n"
+ " fps1; fps\n"
+ " fps2; fps\n"
+ " fps3; fps\n"
+ " GB; GB\n"
+ " Gb; Gb\n"
+ " Gbps; Gbps\n"
+ " GBps; GBps\n"
+ " GHz; GHz\n"
+ " GiB; GiB\n"
+ " GibiByte1; GibiBytes\n"
+ " GibiByte2; GibiBytes\n"
+ " GibiByte3; GibiBytes\n"
+ " GiBps; GiBps\n"
+ " GigaBit1; GigaBit\n"
+ " GigaBit2; GigaBits\n"
+ " GigaBit3; GigaBits\n"
+ " GigaByte1; GigaByte\n"
+ " GigaByte2; GigaBytes\n"
+ " GigaByte3; GigaBytes\n"
+ " hour1; hour\n"
+ " hour2; hours\n"
+ " hour3; hours\n"
+ " Hz; Hz\n"
+ " image stream1; image stream\n"
+ " image stream2; image streams\n"
+ " image stream3; image streams\n"
+ " KB; KB\n"
+ " Kb; Kb\n"
+ " KBps; KBps\n"
+ " Kbps; Kbps\n"
+ " KHz; KHz\n"
+ " KiB; KiB\n"
+ " KibiBit1; KibiBit\n"
+ " KibiBit2; KibiBits\n"
+ " KibiBit3; KibiBits\n"
+ " KibiByte1; KibiByte\n"
+ " KibiByte2; KibiBytes\n"
+ " KibiByte3; KibiBytes\n"
+ " KiBps; KiBps\n"
+ " KiloBit1; KiloBit\n"
+ " KiloBit2; KiloBits\n"
+ " KiloBit3; KiloBits\n"
+ " KiloByte1; KiloByte\n"
+ " KiloByte2; KiloBytes\n"
+ " KiloByte3; KiloBytes\n"
+ " MB; MB\n"
+ " Mb; Mb\n"
+ " Mbps; Mbps\n"
+ " MBps; MebiBytes\n"
+ " MebiBit1; MebiBit\n"
+ " MebiBit2; MebiBits\n"
+ " MebiBit3; MebiBits\n"
+ " MebiByte1; MebiByte\n"
+ " MebiByte2; MebiBytes\n"
+ " MebiByte3; MebiBytes\n"
+ " MegaBit1; MegaBit\n"
+ " MegaBit2; MegaBits\n"
+ " MegaBit3; MegaBits\n"
+ " MegaByte1; MegaByte\n"
+ " MegaByte2; MegaBytes\n"
+ " MegaByte3; MegaBytes\n"
+ " MHz; MHz\n"
+ " MiB; MiB\n"
+ " Mib; Mib\n"
+ " MiBps; MiBps\n"
+ " millisecond1; millisecond\n"
+ " millisecond2; milliseconds\n"
+ " millisecond3; milliseconds\n"
+ " minute1; minute\n"
+ " minute2; minutes\n"
+ " minute3; minutes\n"
+ " month1; month\n"
+ " month2; months\n"
+ " month3; months\n"
+ " pixel1; pixel\n"
+ " pixel2; pixels\n"
+ " pixel3; pixels\n"
+ " second1; second\n"
+ " second2; seconds\n"
+ " second3; seconds\n"
+ " text stream1; text stream\n"
+ " text stream2; text streams\n"
+ " text stream3; text streams\n"
+ " video frames1; video frame\n"
+ " video frames2; video frames\n"
+ " video frames3; video frames\n"
+ " video stream1; video stream\n"
+ " video stream2; video streams\n"
+ " video stream3; video streams\n"
+ " warppoint0;No warppoints\n"
+ " warppoint1; warppoint\n"
+ " warppoint2; warppoints\n"
+ " warppoint3; warppoints\n"
+ " week1; week\n"
+ " week2; weeks\n"
+ " week3; weeks\n"
+ " year1; year\n"
+ " year2; years\n"
+ " year3; years\n"
+ ", ;, \n"
+ ": ;: \n"
+ "About;About\n"
+ "About_Hint;How to contact me and find last version\n"
+ "Accompaniment;Accompaniment\n"
+ "ActiveFormatDescription;Active Format Description\n"
+ "ActiveFormatDescription_MuxingMode;Active Format Description, Muxing mode\n"
+ "Actor;Actor\n"
+ "Actor_Character;Character played\n"
+ "Added_Date;Added date\n"
+ "Address;Address\n"
+ "Advanced;Advanced\n"
+ "Advanced mode;Advanced mode\n"
+ "Album;Album\n"
+ "Album_ReplayGain_Gain;Album replay gain\n"
+ "Album_ReplayGain_Peak;Album replay gain peak\n"
+ "Alignment;Alignment\n"
+ "Alignment_Aligned;Aligned on interleaves\n"
+ "Alignment_Split;Split accross interleaves\n"
+ "All;All\n"
+ "Archival_Location;Archival location\n"
+ "Arranger;Arranger\n"
+ "ArtDirector;ArtDirector\n"
+ "AspectRatio;Aspect ratio\n"
+ "AssistantDirector;AssistantDirector\n"
+ "at;at\n"
+ "At least one file;(You must at least open one file)\n"
+ "Audio;Audio\n"
+ "Audio stream(s);Audio streams\n"
+ "Audio_Codec_List;Audio codecs\n"
+ "Audio_No;No audio\n"
+ "Audio1;First audio stream\n"
+ "Audio2;Second audio stream\n"
+ "AudioCount;Count of audio streams\n"
+ "Author;Author\n"
+ "BarCode;BarCode\n"
+ "Basic;Basic\n"
+ "Basic_Note;Note : for more information about this file, you must select a different view (Sheet, Tree...)\n"
+ "BitDepth;Bit depth\n"
+ "BitRate;Bit rate\n"
+ "BitRate_Maximum;Maximum bit rate\n"
+ "BitRate_Minimum;Minimum bit rate\n"
+ "BitRate_Mode;Bit rate mode\n"
+ "BitRate_Mode_CBR;Constant\n"
+ "BitRate_Mode_VBR;Variable\n"
+ "BitRate_Nominal;Nominal bit rate\n"
+ "BitRate_Encoded;Encoded bit rate\n"
+ "Bits-(Pixel*Frame);Bits/(Pixel*Frame)\n"
+ "BufferSize;Buffer size\n"
+ "Cancel;Cancel\n"
+ "Channel(s);Channel(s)\n"
+ "ChannelPositions;Channel positions\n"
+ "Chapter(s);Chapter(s)\n"
+ "Chapters;Chapters\n"
+ "Chapters stream(s);Chapters stream(s)\n"
+ "Chapters_Codec_List;Chapters Codecs\n"
+ "Chapters_No;No chapters\n"
+ "ChaptersCount;Count of chapter streams\n"
+ "CheckNewVersion;Check for new version\n"
+ "Choose custom;Choose custom\n"
+ "Choose custom sheet;Choose your desired custom sheet\n"
+ "Choose custom text;Choose your desired custom text\n"
+ "Choose export format;Choose your desired export format\n"
+ "Choose file(s);Choose the files to open\n"
+ "Choose filename;Choose your desired filename\n"
+ "Choose language;Choose your desired language\n"
+ "Choregrapher;Choregrapher\n"
+ "Chroma;Chroma\n"
+ "ChromaSubsampling;Chroma subsampling\n"
+ "Close;Close\n"
+ "Close all before open;Close all before open\n"
+ "Codec;Codec\n"
+ "Codec_Description;Codec description\n"
+ "Codec_Info;Details for codec\n"
+ "Codec_Settings;Codec settings\n"
+ "Codec_Settings_PacketBitStream;Codec settings, Packet bitstream\n"
+ "Codec_Settings_BVOP;Codec settings, BVOP\n"
+ "Codec_Settings_QPel;Codec settings, QPel\n"
+ "Codec_Settings_GMC;Codec settings, GMC\n"
+ "Codec_Settings_Matrix;Codec settings, Matrix\n"
+ "Codec_Settings_Floor;Codec settings, Floor\n"
+ "Codec_Settings_CABAC;Codec settings, CABAC\n"
+ "Codec_Settings_Firm;Codec settings, Firm\n"
+ "Codec_Settings_Endianness;Codec settings, Endianness\n"
+ "Codec_Settings_Sign;Codec settings, Sign\n"
+ "Codec_Settings_Law;Codec settings, Law\n"
+ "Codec_Settings_ITU;Codec settings, ITU\n"
+ "Codec_Profile;Codec profile\n"
+ "Codec_Url;Weblink for codec\n"
+ "CodecID;Codec ID\n"
+ "CodecID_Description;Description of the codec\n"
+ "Collection;Collection\n"
+ "Colorimetry;Colorimetry\n"
+ "ColorSpace;Color space\n"
+ "colour_primaries;Color primaries\n"
+ "Comment;Comment\n"
+ "CommissionedBy;Commissioned by\n"
+ "Compilation;Compilation\n"
+ "CompleteName;Complete name\n"
+ "Composer;Composer\n"
+ "Compression_Mode;Compression mode\n"
+ "Compression_Mode_Lossless;Lossless\n"
+ "Compression_Mode_Lossy;Lossy\n"
+ "Compression_Ratio;Compression ratio\n"
+ "Conductor;Conductor\n"
+ "Container and general information;Container and general information\n"
+ "ContentType;ContentType\n"
+ "CoProducer;Coproducer\n"
+ "Copyright;Copyright\n"
+ "CostumeDesigner;Costume designer\n"
+ "Count;Count\n"
+ "Country;Country\n"
+ "Cover;Cover\n"
+ "Cover_Datas;Cover datas\n"
+ "Cover_Description;Cover description\n"
+ "Cover_Mime;Cover MIME\n"
+ "Cover_Type;Cover type\n"
+ "Cropped;Crop dimensions\n"
+ "Custom;Custom\n"
+ "Customize;Customize\n"
+ "Date;Date\n"
+ "Debug;Debug\n"
+ "Decimal point;Decimal point\n"
+ "Delay;Delay\n"
+ "Delay_Source;Delay, origin\n"
+ "Delay_Source_Container;Container\n"
+ "Delay_Source_Stream;Raw stream\n"
+ "Delete;Delete\n"
+ "Description;Description\n"
+ "Digitized_Date;Digitized date\n"
+ "Dimensions;Dimensions\n"
+ "Director;Director\n"
+ "DirectorOfPhotography;Director of photography\n"
+ "DisplayAspectRatio;Display aspect ratio\n"
+ "DisplayAspectRatio_Original;Original display aspect ratio\n"
+ "DistributedBy;Distributed by\n"
+ "Donate;Donate\n"
+ "DotsPerInch;Dots per inch\n"
+ "Duration;Duration\n"
+ "Duration_End;End time\n"
+ "Duration_Start;Start time\n"
+ "Edit;Edit\n"
+ "EditedBy;Edited by\n"
+ "EMail;E-Mail\n"
+ "Encoded_Application;Writing application\n"
+ "Encoded_Date;Encoded date\n"
+ "Encoded_Library;Writing library\n"
+ "Encoded_Library_Settings;Encoding settings\n"
+ "Encoded_Original;Original support\n"
+ "EncodedBy;Encoded by\n"
+ "EPG_Positions;EPG positions (internal)\n"
+ "Error_File;Error while reading file\n"
+ "ExecutiveProducer;Executive producer\n"
+ "Exit;Exit\n"
+ "Exit_Hint;Quit the program\n"
+ "Export;Export\n"
+ "Export_Hint;Export in a customized format\n"
+ "Extensions;Extensions usually used\n"
+ "Family;Family\n"
+ "Fax;Fax\n"
+ "File;File\n"
+ "File size;File size\n"
+ "File_Append;Append to the existing file (Warning : be careful to have the same parameters)\n"
+ "File_Created_Date;File creation date\n"
+ "File_Created_Date_Local;File creation date (local)\n"
+ "File_Hint;Select a multimedia file to examine\n"
+ "File_Modified_Date;File last modification date\n"
+ "File_Modified_Date_Local;File last modification date (local)\n"
+ "FileExtension;File extension\n"
+ "FileName;File name\n"
+ "FileSize;File size\n"
+ "Folder;Folder\n"
+ "Folder (R);Folder (R)\n"
+ "Folder (R)_Hint;Select a folder to examine (with all folders recursively)\n"
+ "Folder (Recursively);Folder (Recursively)\n"
+ "Folder_Hint;Select a folder to examine\n"
+ "FolderName;Folder name\n"
+ "Format;Format\n"
+ "Format_Commercial;Commercial name\n"
+ "Format_Commercial_IfAny;Commercial name\n"
+ "Format_Description;Format description\n"
+ "Format_Info;Details for format\n"
+ "Format_Profile;Format profile\n"
+ "Format_Settings;Format settings\n"
+ "Format_Settings_PacketBitStream;Format settings, Packet bitstream\n"
+ "Format_Settings_BVOP;Format settings, BVOP\n"
+ "Format_Settings_QPel;Format settings, QPel\n"
+ "Format_Settings_GMC;Format settings, GMC\n"
+ "Format_Settings_Matrix;Format settings, Matrix\n"
+ "Format_Settings_Matrix_Custom;Custom\n"
+ "Format_Settings_Matrix_Default;Default\n"
+ "Format_Settings_Floor;Format settings, Floor\n"
+ "Format_Settings_CABAC;Format settings, CABAC\n"
+ "Format_Settings_Firm;Format settings, Firm\n"
+ "Format_Settings_Endianness;Format settings, Endianness\n"
+ "Format_Settings_RefFrames;Format settings, ReFrames\n"
+ "Format_Settings_Sign;Format settings, Sign\n"
+ "Format_Settings_Law;Format settings, Law\n"
+ "Format_Settings_ITU;Format settings, ITU\n"
+ "Format_Settings_SBR;Format settings, SBR\n"
+ "Format_Settings_PS;Format settings, PS\n"
+ "Format_Settings_Pulldown;Format settings, Pulldown\n"
+ "Format_Settings_Mode;Mode\n"
+ "Format_Settings_FrameMode;Frame mode\n"
+ "Format_Settings_Emphasis;Emphasis\n"
+ "Format_Settings_ModeExtension;Mode extension\n"
+ "Format_Settings_GOP;Format settings, GOP\n"
+ "Format_Version;Format version\n"
+ "Format_Url;Weblink for format\n"
+ "FrameCount;Frame count\n"
+ "FrameRate;Frame rate\n"
+ "FrameRate_Mode;Frame rate mode\n"
+ "FrameRate_Mode_CFR;Constant\n"
+ "FrameRate_Mode_VFR;Variable\n"
+ "FrameRate_Minimum;Minimum frame rate\n"
+ "FrameRate_Nominal;Nominal frame rate\n"
+ "FrameRate_Maximum;Maximum frame rate\n"
+ "FrameRate_Original;Original frame rate\n"
+ "General;General\n"
+ "Genre;Genre\n"
+ "Genre_000;Blues\n"
+ "Genre_001;Classic Rock\n"
+ "Genre_002;Country\n"
+ "Genre_003;Dance\n"
+ "Genre_004;Disco\n"
+ "Genre_005;Funk\n"
+ "Genre_006;Grunge\n"
+ "Genre_007;Hip-Hop\n"
+ "Genre_008;Jazz\n"
+ "Genre_009;Metal\n"
+ "Genre_010;New Age\n"
+ "Genre_011;Oldies\n"
+ "Genre_012;Other\n"
+ "Genre_013;Pop\n"
+ "Genre_014;R&B\n"
+ "Genre_015;Rap\n"
+ "Genre_016;Reggae\n"
+ "Genre_017;Rock\n"
+ "Genre_018;Techno\n"
+ "Genre_019;Industrial\n"
+ "Genre_020;Alternative\n"
+ "Genre_021;Ska\n"
+ "Genre_022;Death Metal\n"
+ "Genre_023;Pranks\n"
+ "Genre_024;Soundtrack\n"
+ "Genre_025;Euro-Techno\n"
+ "Genre_026;Ambient\n"
+ "Genre_027;Trip-Hop\n"
+ "Genre_028;Vocal\n"
+ "Genre_029;Jazz+Funk\n"
+ "Genre_030;Fusion\n"
+ "Genre_031;Trance\n"
+ "Genre_032;Classical\n"
+ "Genre_033;Instrumental\n"
+ "Genre_034;Acid\n"
+ "Genre_035;House\n"
+ "Genre_036;Game\n"
+ "Genre_037;Sound Clip\n"
+ "Genre_038;Gospel\n"
+ "Genre_039;Noise\n"
+ "Genre_040;AlternRock\n"
+ "Genre_041;Bass\n"
+ "Genre_042;Soul\n"
+ "Genre_043;Punk\n"
+ "Genre_044;Space\n"
+ "Genre_045;Meditative\n"
+ "Genre_046;Instrumental Pop\n"
+ "Genre_047;Instrumental Rock\n"
+ "Genre_048;Ethnic\n"
+ "Genre_049;Gothic\n"
+ "Genre_050;Darkwave\n"
+ "Genre_051;Techno-Industrial\n"
+ "Genre_052;Electronic\n"
+ "Genre_053;Pop-Folk\n"
+ "Genre_054;Eurodance\n"
+ "Genre_055;Dream\n"
+ "Genre_056;Southern Rock\n"
+ "Genre_057;Comedy\n"
+ "Genre_058;Cult\n"
+ "Genre_059;Gangsta\n"
+ "Genre_060;Top 40\n"
+ "Genre_061;Christian Rap\n"
+ "Genre_062;Pop/Funk\n"
+ "Genre_063;Jungle\n"
+ "Genre_064;Native American\n"
+ "Genre_065;Cabaret\n"
+ "Genre_066;New Wave\n"
+ "Genre_067;Psychadelic\n"
+ "Genre_068;Rave\n"
+ "Genre_069;Showtunes\n"
+ "Genre_070;Trailer\n"
+ "Genre_071;Lo-Fi\n"
+ "Genre_072;Tribal\n"
+ "Genre_073;Acid Punk\n"
+ "Genre_074;Acid Jazz\n"
+ "Genre_075;Polka\n"
+ "Genre_076;Retro\n"
+ "Genre_077;Musical\n"
+ "Genre_078;Rock & Roll\n"
+ "Genre_079;Hard Rock\n"
+ "Genre_080;Folk\n"
+ "Genre_081;Folk-Rock\n"
+ "Genre_082;National Folk\n"
+ "Genre_083;Swing\n"
+ "Genre_084;Fast Fusion\n"
+ "Genre_085;Bebob\n"
+ "Genre_086;Latin\n"
+ "Genre_087;Revival\n"
+ "Genre_088;Celtic\n"
+ "Genre_089;Bluegrass\n"
+ "Genre_090;Avantgarde\n"
+ "Genre_091;Gothic Rock\n"
+ "Genre_092;Progressive Rock\n"
+ "Genre_093;Psychedelic Rock\n"
+ "Genre_094;Symphonic Rock\n"
+ "Genre_095;Slow Rock\n"
+ "Genre_096;Big Band\n"
+ "Genre_097;Chorus\n"
+ "Genre_098;Easy Listening\n"
+ "Genre_099;Acoustic\n"
+ "Genre_100;Humour\n"
+ "Genre_101;Speech\n"
+ "Genre_102;Chanson\n"
+ "Genre_103;Opera\n"
+ "Genre_104;Chamber Music\n"
+ "Genre_105;Sonata\n"
+ "Genre_106;Symphony\n"
+ "Genre_107;Booty Bass\n"
+ "Genre_108;Primus\n"
+ "Genre_109;Porn Groove\n"
+ "Genre_110;Satire\n"
+ "Genre_111;Slow Jam\n"
+ "Genre_112;Club\n"
+ "Genre_113;Tango\n"
+ "Genre_114;Samba\n"
+ "Genre_115;Folklore\n"
+ "Genre_116;Ballad\n"
+ "Genre_117;Power Ballad\n"
+ "Genre_118;Rhythmic Soul\n"
+ "Genre_119;Freestyle\n"
+ "Genre_120;Duet\n"
+ "Genre_121;Punk Rock\n"
+ "Genre_122;Drum Solo\n"
+ "Genre_123;A capella\n"
+ "Genre_124;Euro-House\n"
+ "Genre_125;Dance Hall\n"
+ "Genre_126;Goa\n"
+ "Genre_127;Drum & Bass\n"
+ "Genre_128;Club-House\n"
+ "Genre_129;Hardcore\n"
+ "Genre_130;Terror\n"
+ "Genre_131;Indie\n"
+ "Genre_132;Britpop\n"
+ "Genre_133;Negerpunk\n"
+ "Genre_134;Polsk Punk\n"
+ "Genre_135;Beat\n"
+ "Genre_136;Christian Gangsta Rap\n"
+ "Genre_137;Heavy Metal\n"
+ "Genre_138;Black Metal\n"
+ "Genre_139;Crossover\n"
+ "Genre_140;Contemporary Christian\n"
+ "Genre_141;Christian Rock \n"
+ "Genre_142;Merengue\n"
+ "Genre_143;Salsa\n"
+ "Genre_144;Trash Metal\n"
+ "Genre_145;Anime\n"
+ "Genre_146;JPop\n"
+ "Genre_147;Synthpop\n"
+ "Go to WebSite;Go to website\n"
+ "Grouping;Grouping\n"
+ "h;h\n"
+ "Header file;Create a header file\n"
+ "Height;Height\n"
+ "Height_Original;Original height\n"
+ "Help;Help\n"
+ "Hint;Hint\n"
+ "How many audio streams?;How many audio streams?\n"
+ "How many chapters streams?;How many chapters streams?\n"
+ "How many text streams?;How many text streams?\n"
+ "How many video streams?;How many video streams?\n"
+ "HTML;HTML\n"
+ "ID;ID\n"
+ "Image;Image\n"
+ "Image stream(s);Image streams\n"
+ "Image_Codec_List;Codecs Image\n"
+ "ImageCount;Count of image streams\n"
+ "Info;Info\n"
+ "Instruments;Instruments\n"
+ "Interlacement;Interlacement\n"
+ "Interlaced_Interlaced;Interlaced\n"
+ "Interlaced_TFF;Top Field First\n"
+ "Interlaced_BFF;Bottom Field First\n"
+ "Interlaced_PPF;Progressive\n"
+ "Interlaced_Progressive;Progressive\n"
+ "Interleaved;Interleaved\n"
+ "Interleave_Duration;Interleave, duration\n"
+ "Interleave_Preload;Interleave, preload duration\n"
+ "Interleave_VideoFrames;Interleave, duration\n"
+ "InternetMediaType;Internet media type\n"
+ "IRCA;IRCA\n"
+ "ISBN;ISBN\n"
+ "ISRC;ISRC\n"
+ "Keywords;Keywords\n"
+ "Known codecs;Known codecs\n"
+ "Known formats;Known formats\n"
+ "Known parameters;Known parameters\n"
+ "Label;Label\n"
+ "Language;Language\n"
+ "Language_More;Language, more info\n"
+ "Language_aa;Afar\n"
+ "Language_ab;Abkhazian\n"
+ "Language_ae;Avestan\n"
+ "Language_af;Afrikaans\n"
+ "Language_ak;Akan\n"
+ "Language_am;Amharic\n"
+ "Language_an;Aragonese\n"
+ "Language_ar;Arabic\n"
+ "Language_as;Assamese\n"
+ "Language_av;Avaric\n"
+ "Language_ay;Aymara\n"
+ "Language_az;Azerbaijani\n"
+ "Language_ba;Bashkir\n"
+ "Language_be;Belarusian\n"
+ "Language_bg;Bulgarian\n"
+ "Language_bh;Bihari\n"
+ "Language_bi;Bislama\n"
+ "Language_bm;Bambara\n"
+ "Language_bn;Bengali\n"
+ "Language_bo;Tibetan\n"
+ "Language_br;Breton\n"
+ "Language_bs;Bosnian\n"
+ "Language_ca;Catalan\n"
+ "Language_ce;Chechen\n"
+ "Language_ch;Chamorro\n"
+ "Language_co;Corsican\n"
+ "Language_cr;Cree\n"
+ "Language_cs;Czech\n"
+ "Language_cu;Slave\n"
+ "Language_cv;Chuvash\n"
+ "Language_cy;Welsh\n"
+ "Language_da;Danish\n"
+ "Language_de;German\n"
+ "Language_dv;Divehi\n"
+ "Language_dz;Dzongkha\n"
+ "Language_ee;Ewe\n"
+ "Language_el;Greek\n"
+ "Language_en;English\n"
+ "Language_en-gb;English (Great Britain)\n"
+ "Language_en-us;English (United States)\n"
+ "Language_eo;Esperanto\n"
+ "Language_es;Spanish\n"
+ "Language_et;Estonian\n"
+ "Language_eu;Basque\n"
+ "Language_fa;Persian\n"
+ "Language_ff;Fulah\n"
+ "Language_fi;Finnish\n"
+ "Language_fj;Fijian\n"
+ "Language_fo;Faroese\n"
+ "Language_fr;French\n"
+ "Language_fy;Frisian\n"
+ "Language_ga;Irish\n"
+ "Language_gd;Gaelic\n"
+ "Language_gl;Galician\n"
+ "Language_gn;Guarani\n"
+ "Language_gu;Gujarati\n"
+ "Language_gv;Manx\n"
+ "Language_ha;Hausa\n"
+ "Language_he;Hebrew\n"
+ "Language_hi;Hindi\n"
+ "Language_ho;Hiri Motu\n"
+ "Language_hr;Croatian\n"
+ "Language_ht;Haitian\n"
+ "Language_hu;Hungarian\n"
+ "Language_hy;Armenian\n"
+ "Language_hz;Herero\n"
+ "Language_ia;Auxiliary Language Association\n"
+ "Language_id;Indonesian\n"
+ "Language_ie;Interlingue\n"
+ "Language_ig;Igbo\n"
+ "Language_ii;Sichuan Yi\n"
+ "Language_ik;Inupiaq\n"
+ "Language_Info;Language info\n"
+ "Language_io;Ido\n"
+ "Language_is;Icelandic\n"
+ "Language_it;Italian\n"
+ "Language_iu;Inuktitut\n"
+ "Language_ja;Japanese\n"
+ "Language_jv;Javanese\n"
+ "Language_ka;Georgian\n"
+ "Language_kg;Kongo\n"
+ "Language_ki;Kikuyu\n"
+ "Language_kj;Kuanyama\n"
+ "Language_kk;Kazakh\n"
+ "Language_kl;Kalaallisut\n"
+ "Language_km;Khmer\n"
+ "Language_kn;Kannada\n"
+ "Language_ko;Korean\n"
+ "Language_kr;Kanuri\n"
+ "Language_ks;Kashmiri\n"
+ "Language_ku;Kurdish\n"
+ "Language_kv;Komi\n"
+ "Language_kw;Cornish\n"
+ "Language_ky;Kirghiz\n"
+ "Language_la;Latin\n"
+ "Language_lb;Luxembourgish\n"
+ "Language_lg;Ganda\n"
+ "Language_li;Limburgish\n"
+ "Language_ln;Lingala\n"
+ "Language_lo;Lao\n"
+ "Language_lt;Lithuanian\n"
+ "Language_lu;Luba-Katanga\n"
+ "Language_lv;Latvian\n"
+ "Language_mg;Malagasy\n"
+ "Language_mh;Marshallese\n"
+ "Language_mi;Maori\n"
+ "Language_mk;Macedonian\n"
+ "Language_ml;Malayalam\n"
+ "Language_mn;Mongolian\n"
+ "Language_mo;Moldavian\n"
+ "Language_mr;Marathi\n"
+ "Language_ms;Malay\n"
+ "Language_mt;Maltese\n"
+ "Language_mul;Multiple languages\n"
+ "Language_my;Burmese\n"
+ "Language_na;Nauru\n"
+ "Language_nb;Norwegian Bokmal\n"
+ "Language_nd;Ndebele\n"
+ "Language_ne;Nepali\n"
+ "Language_ng;Ndonga\n"
+ "Language_nl;Dutch\n"
+ "Language_nn;Norwegian Nynorsk\n"
+ "Language_no;Norwegian\n"
+ "Language_nr;Ndebele\n"
+ "Language_nv;Navaho\n"
+ "Language_ny;Nyanja\n"
+ "Language_oc;Occitan\n"
+ "Language_oj;Ojibwa\n"
+ "Language_om;Oromo\n"
+ "Language_or;Oriya\n"
+ "Language_os;Ossetic\n"
+ "Language_pa;Panjabi\n"
+ "Language_pi;Pali\n"
+ "Language_pl;Polish\n"
+ "Language_ps;Pushto\n"
+ "Language_pt;Portuguese\n"
+ "Language_pt-br;Portuguese (Brazil)\n"
+ "Language_qu;Quechua\n"
+ "Language_rm;Raeto-Romance\n"
+ "Language_rn;Rundi\n"
+ "Language_ro;Romanian\n"
+ "Language_ru;Russian\n"
+ "Language_rw;Kinyarwanda\n"
+ "Language_sa;Sanskrit\n"
+ "Language_sc;Sardinian\n"
+ "Language_sd;Sindhi\n"
+ "Language_se;Northern Sami\n"
+ "Language_sg;Sango\n"
+ "Language_si;Sinhala\n"
+ "Language_sk;Slovak\n"
+ "Language_sl;Slovenian\n"
+ "Language_sm;Samoan\n"
+ "Language_sn;Shona\n"
+ "Language_so;Somali\n"
+ "Language_sq;Albanian\n"
+ "Language_sr;Serbian\n"
+ "Language_ss;Swati\n"
+ "Language_st;Sotho\n"
+ "Language_su;Sundanese\n"
+ "Language_sv;Swedish\n"
+ "Language_sw;Swahili\n"
+ "Language_ta;Tamil\n"
+ "Language_te;Telugu\n"
+ "Language_tg;Tajik\n"
+ "Language_th;Thai\n"
+ "Language_ti;Tigrinya\n"
+ "Language_tk;Turkmen\n"
+ "Language_tl;Tagalog\n"
+ "Language_tn;Tswana\n"
+ "Language_to;Tonga\n"
+ "Language_tr;Turkish\n"
+ "Language_ts;Tsonga\n"
+ "Language_tt;Tatar\n"
+ "Language_tw;Twi\n"
+ "Language_ty;Tahitian\n"
+ "Language_ug;Uighur\n"
+ "Language_uk;Ukrainian\n"
+ "Language_ur;Urdu\n"
+ "Language_uz;Uzbek\n"
+ "Language_ve;Venda\n"
+ "Language_vi;Vietnamese\n"
+ "Language_vo;Volapuk\n"
+ "Language_wa;Walloon\n"
+ "Language_wo;Wolof\n"
+ "Language_xh;Xhosa\n"
+ "Language_yi;Yiddish\n"
+ "Language_yo;Yoruba\n"
+ "Language_za;Zhuang\n"
+ "Language_zh;Chinese\n"
+ "Language_zh-cn;Chinese (China)\n"
+ "Language_zh-tw;Chinese (Taiwan)\n"
+ "Language_zu;Zulu\n"
+ "LawRating;Law rating\n"
+ "LCCN;LCCN\n"
+ "Library;Muxing library\n"
+ "Lightness;Lightness\n"
+ "List;List\n"
+ "Lyrics;Lyrics\n"
+ "Lyricist;Lyricist\n"
+ "Mastered_Date;Mastered date\n"
+ "MasteredBy;Mastered by\n"
+ "matrix_coefficients;Matrix coefficients\n"
+ "MediaInfo_About;Supply very detailled information\r\nabout a multimedia file:\r\nMatroska, OGG (including OGM)\r\nMPEG1 (including VCD)\r\nMPEG2 (including DVD and SVCD)\r\nMPEG4 (including Itunes M4A)\r\nQuicktime\r\nRealMedia\r\nWindowsMedia (including WMV, WMA)\r\nMicrosoft RIFF (including AVI, WAV)\r\nSound-only formats (AC3, DTS, AAC, AU, AIFF...)\n"
+ "Menu;Menu\n"
+ "Menu stream(s);Menu streams\n"
+ "Menu_Codec_List;Menu codecs\n"
+ "Menu_No;No menu\n"
+ "MenuCount;Count of menu streams\n"
+ "Menu_Hint;More possibilities\n"
+ "MenuID;Menu ID\n"
+ "mn;mn\n"
+ "Mood;Mood\n"
+ "More;More\n"
+ "Movie;Movie name\n"
+ "ms;ms\n"
+ "MSDI;MSDI\n"
+ "MusicBy;Music by\n"
+ "MuxingMode;Muxing mode\n"
+ "MuxingMode_MoreInfo;Muxing mode, more info\n"
+ "MuxingMode_PackedBitstream;Packed bitstream\n"
+ "Name;Name\n"
+ "Nationality;Nationality\n"
+ "NetworkName;Network name\n"
+ "New;New\n"
+ "Newest version;Check for new versions (requires Internet connection)\n"
+ "NewVersion_Menu;A new version is available\n"
+ "NewVersion_Question_Title;A new version was released!\n"
+ "NewVersion_Question_Content;A new version (v%Version%) is available, would you like to download it?\n"
+ "No;No\n"
+ "Not yet;Not yet\n"
+ "NumColors;Number of colors\n"
+ "OK;OK\n"
+ "One output file per input file;One output file per input file\n"
+ "Open;Open\n"
+ "OpenCandy_01;Downloading ________\n"
+ "OpenCandy_02;__% Complete\n"
+ "OpenCandy_03;Internet connection interrupted\n"
+ "OpenCandy_04;________ download complete\n"
+ "OpenCandy_05;Click to install ________\n"
+ "OpenCandy_06;Are you sure you wish to cancel the install?\r\nIf you wish to postpone the install until later, select 'No'.\r\nNote: You may select Exit from the menu to defer installation until after the next time you reboot.\n"
+ "OpenCandy_07;Download of ________ has been paused.\r\nClick on the tray icon to resume downloading.\n"
+ "OpenCandy_08;A critical error has occurred. Installation of _________ will be aborted.\n"
+ "OpenCandy_09;Pause download\n"
+ "OpenCandy_10;Cancel install\n"
+ "OpenCandy_11;Resume download\n"
+ "OpenCandy_12;Exit Installer\n"
+ "OpenCandy_13;___________ - Recommended by ____________\n"
+ "OpenCandy_14;Downloading _________\n"
+ "OpenCandy_15;___________, the software recommended to you by ___________, is now downloading at your requestWe will let you know when it is ready to be installed.\n"
+ "OpenCandy_16;___________ is ready for installation\n"
+ "OpenCandy_17;___________ is now fully downloaded. Please click on 'Install' to proceed.\n"
+ "OpenCandy_18;___________ of ___________ downloaded\n"
+ "OpenCandy_19;Powered by OpenCandy\n"
+ "OpenCandy_20;Learn more at OpenCandy.com\n"
+ "OpenCandy_21;Install\n"
+ "OpenCandy_22;Installation of ___________\n"
+ "OpenCandy_23;This will cancel the installation of ___________\r\nAre you sure you wish to exit?\n"
+ "OpenCandy_24;Pause\n"
+ "OpenCandy_25;Your download has been paused. Click 'Resume' when you are ready to continue.\n"
+ "OpenCandy_26;Resume\n"
+ "OpenCandy_27;Install Now\n"
+ "OpenCandy_28;Pause Download\n"
+ "OpenCandy_29;Resume Download\n"
+ "OpenCandy_30;Cancel Install\n"
+ "OpenCandy_31;Please choose an installation option\n"
+ "OpenCandy_32;Install ___________\n"
+ "OpenCandy_33;Don't Install\n"
+ "OpenCandy_34;Please select an install option\n"
+ "OpenCandy_35;______ recommends this software\n"
+ "OpenCandy_36;Your current installation will not be interrupted\n"
+ "Options;Options\n"
+ "Options_Hint;Preferences\n"
+ "Original;Original\n"
+ "OriginalNetworkName;Original network name\n"
+ "OriginalSourceForm;Original source form\n"
+ "OriginalSourceMedium;Original source medium\n"
+ "Other;Other\n"
+ "Output;Output\n"
+ "Output format;Output format\n"
+ "OverallBitRate;Overall bit rate\n"
+ "OverallBitRate_Maximum;Maximum Overall bit rate\n"
+ "OverallBitRate_Minimum;Minimum Overall bit rate\n"
+ "OverallBitRate_Mode;Overall bit rate mode\n"
+ "OverallBitRate_Nominal;Nominal Overall bit rate\n"
+ "Part;Part\n"
+ "Part_Count;Total count\n"
+ "Performer;Performer\n"
+ "Period;Period\n"
+ "Phone;Phone\n"
+ "PixelAspectRatio;Pixel aspect ratio\n"
+ "PixelAspectRatio_Original;Original pixel aspect ratio\n"
+ "PlayCounter;PlayCounter\n"
+ "Played_Count;Times played\n"
+ "Played_First_Date;First played\n"
+ "Played_Last_Date;Last played\n"
+ "PlayTime;PlayTime\n"
+ "Position;Position\n"
+ "Position_Total;Total\n"
+ "Preferences;Preferences\n"
+ "Producer;Producer\n"
+ "ProductionDesigner;Production designer\n"
+ "ProductionStudio;Production studio\n"
+ "Publisher;Publisher\n"
+ "Purchased_Date;purchased date\n"
+ "Quote character;Quote character\n"
+ "RadioStation;Radio station\n"
+ "Rating;Rating\n"
+ "Recorded_Date;Recorded date\n"
+ "Recorded_Location;Recorded location\n"
+ "Released_Date;Released date\n"
+ "RemixedBy;Remixed by\n"
+ "ReplayGain_Gain;Replay gain\n"
+ "ReplayGain_Peak;Replay gain peak\n"
+ "Resolution;Resolution\n"
+ "s;s\n"
+ "SamplingRate;Sampling rate\n"
+ "Save;Save\n"
+ "ScanType;Scan type\n"
+ "ScanOrder;Scan order\n"
+ "ScreenplayBy;Screenplay by\n"
+ "Season;Season\n"
+ "see below;see below\n"
+ "Send HeaderFile;Please send me the Header file here : http://sourceforge.net/projects/mediainfo/ (Bug section)\n"
+ "Separator_Columns;columns separator\n"
+ "Separator_Lines;lines separator\n"
+ "ServiceChannel;Service channel number\n"
+ "ServiceName;Service name\n"
+ "ServiceProvider;Service provider\n"
+ "ServiceType;Service type\n"
+ "Set;Set\n"
+ "Set_Count;Set count\n"
+ "Setup;Setup\n"
+ "Sharpness;Sharpness\n"
+ "Sheet;Sheet\n"
+ "Sheet (Complete);Sheet (Complete)\n"
+ "Shell extension;Explorer extension (in Windows Explorer, right click on a file, there will be a MediaInfo option)\n"
+ "Shell extension, folder;For folders too\n"
+ "Shell InfoTip;Explorer Tooltip (in Windows Explorer, move the mouse over the file, info will be displayed)\n"
+ "Show menu;Show menu\n"
+ "Show toolbar;Show toolbar\n"
+ "Sort;Sorted by\n"
+ "SamplingCount;Samples count\n"
+ "SoundEngineer;Sound engineer\n"
+ "Source;Source\n"
+ "Source_Duration;Source duration\n"
+ "Source_FrameCount;Source frame count\n"
+ "Source_SamplingCount;Source sample count\n"
+ "Source_StreamSize;Source stream size\n"
+ "Source_StreamSize_Encoded;Source encoded stream size\n"
+ "Standard;Standard\n"
+ "Stream;Stream\n"
+ "Stream_MoreInfo;More information about the stream\n"
+ "StreamCount;Count of stream of this kind\n"
+ "StreamID;Stream ID\n"
+ "StreamKind;Kind of stream\n"
+ "StreamKindID;Stream identifier\n"
+ "StreamKindPos;Stream identifier\n"
+ "StreamSize;Stream size\n"
+ "StreamSize_Encoded;Encoded stream size\n"
+ "StreamSize_Proportion;Proportion of this stream\n"
+ "Subject;Subject\n"
+ "SubTrack;SubTrack\n"
+ "Summary;Summary\n"
+ "Supported formats;Supported formats\n"
+ "Supported?;Supported?\n"
+ "Synopsis;Synopsis\n"
+ "SystemId;Id\n"
+ "Tagged_Application;Tagging application\n"
+ "Tagged_Date;Tagged date\n"
+ "Technician;Technician\n"
+ "TermsOfUse;Terms of use\n"
+ "Text;Text\n"
+ "Text - Custom;Text - Custom\n"
+ "Text (HTML);Text (HTML)\n"
+ "Text stream(s);Text streams\n"
+ "Text streams;Text streams\n"
+ "Text_Codec_List;Text codecs\n"
+ "Text_No;No text\n"
+ "Text1;First text stream\n"
+ "Text2;Second text stream\n"
+ "Text3;Third text stream\n"
+ "TextCount;Count of text streams\n"
+ "ThanksTo;Thanks to\n"
+ "Thousands separator;Thousands separator\n"
+ "Title;Title\n"
+ "Title_More;Title, more info\n"
+ "TimeZone;Timezone\n"
+ "Total;Total\n"
+ "Track;Track name\n"
+ "Track_Count;Track count\n"
+ "transfer_characteristics;Transfer characteristics\n"
+ "Translator;Translator\n"
+ "Tree;Tree\n"
+ "Tree & Text;Tree & Text\n"
+ "UniqueID;Unique ID\n"
+ "Unknown;Unknown\n"
+ "Url;Url\n"
+ "Video;Video\n"
+ "Video stream(s);Video stream(s)\n"
+ "Video_Codec_List;Codecs Video\n"
+ "Video_Delay;Delay relative to video\n"
+ "Video_No;No video\n"
+ "Video0_Delay;Video0 delay\n"
+ "Video1;First video stream\n"
+ "VideoCount;Count of video streams\n"
+ "View;View\n"
+ "View_Hint;Change the means of viewing information\n"
+ "Warning : more streams in the files;Warning : there are more streams in the files\n"
+ "Web;Web\n"
+ "WebSite_Audio;Go to the web site of this audio codec\n"
+ "WebSite_Audio_More;Go to the web site (%Url%) to find this audio codec\n"
+ "WebSite_General;Go to the web site of a player for this file\n"
+ "WebSite_General_More;Go to the web site of a player for this file\n"
+ "WebSite_Text;Go to the web site of this text codec\n"
+ "WebSite_Text_More;Go to the web site (%Url%) to find this text codec\n"
+ "WebSite_Url;http://mediainfo.sourceforge.net\n"
+ "WebSite_Video;Go to the web site of this video codec\n"
+ "WebSite_Video_More;Go to the web site (%Url%) to find this video codec\n"
+ "Width;Width\n"
+ "Width_Original;Original width\n"
+ "WriteMe;Write mail to author\n"
+ "WriteToTranslator;Write to translator\n"
+ "Written_Date;Written date\n"
+ "Written_Location;Written location\n"
+ "WrittenBy;Written by\n"
+ "Yes;Yes\n"
+ "Your system;Your system\n"
+ "ZZ_Automatic_Percent;100\n"
+ "ZZ_AutomaticLanguage_Percent;100\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Format (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "AIFF;;;M;Riff;Apple/SGI;aiff aifc aif;audio/x-aiff;\n"
+ "AMV;;;M;Riff;Chinese hack of AVI;amv;;http://en.wikipedia.org/wiki/AMV_video_format\n"
+ "AVI;;;M;Riff;Audio Video Interleave;avi;video/vnd.avi;\n"
+ "BDAV;;;M;Bdav;Blu-ray Video;m2ts;;\n"
+ "Blu-ray Clip info;;;M;Bdmv;;clpi;;\n"
+ "Blu-ray Index;;;M;Bdmv;;bdmv;;\n"
+ "Blu-ray Movie object;;;M;Bdmv;;bdmv;;\n"
+ "Blu-ray Playlist;;;M;Bdmv;;mpls;;\n"
+ "CDDA;;;M;Riff;;cda;;\n"
+ "CDXA;;;M;Cdxa;;dat;;\n"
+ "DV;;;M;DvdDif;;dv dif;video/DV;;Lossy\n"
+ "DivX;;;M;Riff;Hack of AVI;divx;video/vnd.avi;http://www.divx.com\n"
+ "DPG;;;M;Dpg;Nintendo DS;dpg;;\n"
+ "DVD Video;;;M;Dvdv;;ifo;;\n"
+ "Flash Video;;;M;Flv;;flv;application/x-shockwave-flash;http://www.macromedia.com/go/getflashplayer\n"
+ "GXF;;;M;Gxf;SMPTE 360M;gxf;;\n"
+ "HLS;;;M;Hls;;m3u8;;\n"
+ "Google Video;;;M;Riff;Hack of AVI;gvi;;http://video.google.com/playerdownload.html\n"
+ "ISM;Internet Streaming Media;;M;Ism;;ism;;\n"
+ "IVF;;;M;Ivf;;ivf;;\n"
+ "LXF;;;M;Lxf;;lxf;video/lxf;\n"
+ "Matroska;;;M;Mk;;mkv mk3d mka mks;;http://packs.matroska.org/\n"
+ "MPEG-PS;;;M;MpegPs;;mpeg mpg m2p vob pss;video/MP2P;\n"
+ "MPEG-TS;;;M;MpegTs;;ts m2t m2s m4t m4s ts tp trp;video/MP2T;\n"
+ "MPEG-4;;;M;Mpeg4;;mp4 m4v m4a m4b m4p 3gpp 3gp 3gpp2 3g2 k3g jpm jpx mqv ismv isma f4v;video/mp4;\n"
+ "MTV;;;M;Other;Chinese hack of MPEG-1 layer 3;mtv;;http://en.wikipedia.org/wiki/Chinese_MP4/MTV_Player\n"
+ "MXF;;;M;Mxf;;mxf;application/mxf;\n"
+ "NSV;;;M;Nsv;Nullsoft Streaming Video;nsv;;http://winamp.com\n"
+ "Ogg;;;M;Ogg;;ogg ogm;video/ogg;http://www.free-codecs.com/Ogg_DirectShow_Filters_download.htm\n"
+ "QuickTime;;;M;Mpeg4;Original Apple specifications;mov qt;video/quicktime;http://www.apple.com/quicktime/download/standalone.html\n"
+ "RealMedia;;;M;Rm;;rm rmvb ra;application/vnd.rn-realmedia;\n"
+ "RIFF-MMP;;;M;Riff;RIFF Multimedia Movie;;;\n"
+ "ShockWave;;;M;Swf;;swf;application/x-shockwave;http://www.macromedia.com/go/getflashplayer\n"
+ "SKM;;;M;Skm;Sky Korean Mobilephone;skm;;http://www.isky.co.kr/html/cs/download.jsp\n"
+ "Windows Media;;;M;Wm;;asf wmv wma;video/x-ms-wmv;\n"
+ "WebM;;;M;Mkv;;webm;video/webm;http://www.webmproject.org/\n"
+ "AVC;;;V;Avc;Advanced Video Codec;avc h264;video/H264;http://developers.videolan.org/x264.html\n"
+ "AVS Video;;;V;AvsV;Audio Video Standart, Video part;;;http://www.avs.org.cn/;Lossy\n"
+ "Dirac;;;V;Dirac;;drc;;http://diracvideo.org/;Lossy\n"
+ "FFV1;;;V;;;;;;Lossless\n"
+ "FFV2;;;V;;;;;;Lossless\n"
+ "FLC;;;V;Flic;;fli flc;;http://www.chem.nott.ac.uk/flc.html;Lossy\n"
+ "FLI;;;V;Flic;;fli flc;;http://www.chem.nott.ac.uk/flc.html;Lossy\n"
+ "FLIC;;;V;Flic;;fli flc;;http://www.chem.nott.ac.uk/flc.html;Lossy\n"
+ "H.261;;;V;;;h261;video/H261;;Lossy\n"
+ "H.263;;;V;;;h263;video/H263;;Lossy\n"
+ "MPEG Video;;;V;Mpegv;;mpgv mpv mp1v m1v mp2v m2v;video/MPV;;Lossy\n"
+ "MPEG-4 Visual;;;V;Mpeg4;;m4v mp4v;video/MP4V-ES;;Lossy\n"
+ "Theora;;;V;;;;;http://www.theora.org/;Lossy\n"
+ "VC-1;;;V;Vc1;;vc1;video/vc1;;Lossy\n"
+ "YUV4MPEG2;;;V;Y4m;;y4m;;;Lossless\n"
+ "VP8;;;V;;;;;http://www.webmproject.org/;Lossy\n"
+ "YUV;;;V;;;;;;Lossless\n"
+ "AAC;;;A;;Advanced Audio Codec;aac;;;Lossy\n"
+ "AC-3;;;A;Ac3;Audio Coding 3;ac3;;;Lossy\n"
+ "ADIF;;;A;Adif;Audio Data Interchange Format;aac;;\n"
+ "ADTS;;;A;Adts;Audio Data Transport Stream;aac;;\n"
+ "ALS;;;A;Als;MPEG-4 Audio Lossless Coding;als;;http://www.nue.tu-berlin.de/forschung/projekte/lossless/mp4als.html#downloads;Lossless\n"
+ "AMR;;;A;Amr;Adaptive Multi-Rate;amr;audio/AMR;http://www.apple.com/quicktime/download/standalone.html\n"
+ "Atrac;;;A;;;;audio/ATRAC;;Lossy\n"
+ "Atrac3;;;A;;;;audio/ATRAC3;;Lossy\n"
+ "AU;;;A;Au;uLaw/AU Audio File;au;audio/basic;\n"
+ "DolbyE;;;A;Aes3;;dde\n"
+ "DTS;;;A;Dts;Digital Theater Systems;dts;;;Lossy\n"
+ "DTS-HD;;;A;Dts;Digital Theater Systems;dts;;;Lossy\n"
+ "E-AC-3;;;A;Ac3;Audio Coding 3;dd+ ec3;audio/eac3;;Lossy\n"
+ "Extended Module;;;A;ExtendedModule;;xm;;\n"
+ "FLAC;;;A;Flac;Free Lossless Audio Codec;flac;;http://flac.sourceforge.net/\n"
+ "G.719;;;A;;;;audio/G719;;Lossy\n"
+ "G.722;;;A;;;;audio/G722;;Lossy\n"
+ "G.722.1;;;A;;;;audio/G7221;;Lossy\n"
+ "G.723;;;A;;;;audio/G723;;Lossy\n"
+ "G.729;;;A;;;;audio/G729;;Lossy\n"
+ "G.729.1;;;A;;;;audio/G7291;;Lossy\n"
+ "Impulse Tracker;;;A;ImpulseTracker;;it;;\n"
+ "LA;;;A;La;Lossless Audio Codec;la;;http://www.lossless-audio.com/;Lossless\n"
+ "MIDI;;;A;Riff;RIFF Musical Instrument Digital Interface;midi mid kar;audio/midi;\n"
+ "Module;;;A;Module;;mod;;\n"
+ "Monkey's Audio;;;A;Ape;;ape mac;;http://www.monkeysaudio.com/;Lossless\n"
+ "MPEG Audio;;;A;Mpega;;m1a mpa1 mp1 m2a mpa2 mp2 mp3;audio/mpeg;;Lossy\n"
+ "Musepack SV7;;;A;Mpc;;mpc;;http://www.musepack.net;Lossy\n"
+ "Musepack SV8;;;A;Mpc;;mp+;;http://www.musepack.net;Lossy\n"
+ "QCELP;;;A;;;;audio/QCELP;\n"
+ "RIFF-MIDI;;;A;Riff;RIFF Musical Instrument Digital Interface;;;\n"
+ "RKAU;RK Audio;;A;Rkau;;rka;;http://www.msoftware.co.nz\n"
+ "Scream Tracker 3;;;A;S3m;;s3m;;\n"
+ "Shorten;;;A;;;shn;;http://etree.org/shnutils/shorten/;Lossless\n"
+ "SLS;;;A;;MPEG-4 Scalable Lossless Coding;sls;;http://www.chiariglione.org/mpeg/technologies/mp04-sls/index.htm;Lossless\n"
+ "Speex;;;A;;;;audio/speex;http://www.speex.org/;Lossy\n"
+ "TAK;;;A;;;tak;;http://thbeck.de/Tak/Tak.html;Lossless\n"
+ "TrueHD;;;A;Ac3;;dts;;;Lossless\n"
+ "TwinVQ;;;A;TwinVQ;Transform domain Weighted INterleave Vector Quantization;vqf;;http://www.twinvq.org/english/index_en.html\n"
+ "Vorbis;;;A;;;;audio/vorbis;http://www.vorbis.com/;Lossy\n"
+ "Wave;;;A;Riff;;wav;audio/vnd.wave;\n"
+ "Wave64;;;A;Riff;;w64;;\n"
+ "WavPack;;;A;Wvpk;;wv wvc;;http://www.wavpack.com\n"
+ "Bitmap;;;I;Bmp;;bmp;image/bmp;;Lossless\n"
+ "DPX;;;I;Dpx;;dpx cin;;;Lossless\n"
+ "EXR;;;I;Exr;;exr;;;Lossless\n"
+ "DIB;;;I;Riff;RIFF Device Independent Bitmap;;;;Lossless\n"
+ "GIF;;;I;Gif;Graphics Interchange Format;gif;image/gif;;Lossless\n"
+ "ICO;;;I;Ico;;ico;image/vnd.microsoft.icon;;Lossless\n"
+ "JNG;;;I;Jng;JPEG Network Graphic;jng;;;Lossy\n"
+ "JPEG;;;I;Jpeg;;jpeg jpg jpe;image/jpeg;;Lossy\n"
+ "JPEG 2000;;;I;Jpeg;;jp2;image/jp2;http://www.morgan-multimedia.com/JPEG 2000/\n"
+ "LZ77;;;I;;;;;\n"
+ "MNG;;;I;Mng;Multiple-Image Network Graphic;mng;;;Lossless\n"
+ "PNG;;;I;Png;Portable Network Graphic;png;image/png;;Lossless\n"
+ "RIFF Palette;;;I;Riff;RIFF Palette;;;\n"
+ "RLE;;;I;;Run-length encoding;rle;;\n"
+ "TIFF;;;I;Tiff;;tiff tif;image/tiff;\n"
+ "TGA;;;I;Tga;;tga;image/tga;\n"
+ "7-Zip;;;C;7z;;7z;;http://7-zip.org\n"
+ "ACE;;;C;Ace;;ace;;http://winace.com\n"
+ "ELF;;;C;Elf;;so;;\n"
+ "ISO 9660;;;C;Iso9660;;iso;;\n"
+ "MZ;;;C;Mz;;exe dll;;\n"
+ "RAR;;;C;Rar;From Rarlabs;rar;application/x-rar-compressed;http://rarlabs.com\n"
+ "ZIP;;;C;Zip;;zip;application/zip;http://winzip.com\n"
+ "Adobe encore DVD;;;T;Other;;txt;;http://www.adobe.fr/products/encore/;Lossless\n"
+ "AQTitle;;;T;Other;;aqt;;http://www.volny.cz/aberka/czech/aqt.html;Lossless\n"
+ "ASS;;;T;Other;;ssa;;http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow;Lossless\n"
+ "Captions 32;;;T;Other;;txt;;;Lossless\n"
+ "Captions Inc;;;T;Other;;txt;;;Lossless\n"
+ "CPC Captioning;;;T;Other;;txt;;http://www.cpcweb.com/Captioning/cap_software.htm;Lossless\n"
+ "Cheeta;;;T;Other;;asc;;;Lossless\n"
+ "SSA;;;T;Other;;ssa;;http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow;Lossless\n"
+ "SubRip;;;T;Other;;srt;;http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow;Lossless\n"
+ "Blender;;;O;Other;;blenders;;http://www.blender3d.com\n"
+ "AutoCAD;;;O;Other;;;;http://www.autodesk.com\n"
+ "N19;;;T;N19;;stl;;;Lossless\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_General_Mpeg4 (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "M4V ;MPEG-4;;;\n"
+ "isom;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Base Media\n"
+ "iso2;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Base Media\n"
+ "mp41;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Base Media / Version 1\n"
+ "mp42;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Base Media / Version 2\n"
+ "avc1;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;JVT\n"
+ "3gp1;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 1\n"
+ "3gp2;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 2\n"
+ "3gp3;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 3\n"
+ "3gp4;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 4\n"
+ "3gp5;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 5\n"
+ "3gp6;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 6 Basic\n"
+ "3gp6;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 6 Progressive Download\n"
+ "3gp6;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 6 Streaming Servers\n"
+ "3gp7;MPEG-4;;;http://www.3gpp.org/;3GPP Media Release 7 Streaming Servers\n"
+ "3g2a;MPEG-4;;;http://www.3gpp2.org/;3GPP2 Media\n"
+ "3ge6;MPEG-4;;;http://www.3gpp.org/;3GPP Release 6 MBMS Extended Presentation\n"
+ "3ge7;MPEG-4;;;http://www.3gpp.org/;3GPP Release 7 MBMS Extended Presentation\n"
+ "3gg6;MPEG-4;;;http://www.3gpp.org/;3GPP Release 6 General\n"
+ "3gp8;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "3gp9;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "CAQV;MPEG-4;;;http://world.casio.com/;Casio\n"
+ "FACE;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Facebook\n"
+ "isml;MPEG-4;IIS Smooth Streaming file format;;http://www.apple.com/quicktime/download/standalone.html;ISML\n"
+ "JP20;MPEG-4;;;http://gpac.sourceforge.net/;JPEG 2000\n"
+ "JPM ;MPEG-4;;;http://www.iso.org/;JPEG 2000 Compound Image\n"
+ "JPX ;MPEG-4;;;http://www.iso.org/;JPEG 2000 w/ extensions\n"
+ "KDDI;MPEG-4;;;http://www.3gpp2.org/;3GPP2 EZMovie for KDDI 3G Cellphones\n"
+ "MJ2S;MPEG-4;;;http://www.iso.org/;Motion JPEG 2000 Simple Profile\n"
+ "MJP2;MPEG-4;;;http://www.iso.org/;Motion JPEG 2000 General Profile\n"
+ "MQT ;MPEG-4;;;http://www.sony.com/;Sony/Mobile QuickTime\n"
+ "MSNV;MPEG-4;;;http://www.sony.com/;Sony PSP\n"
+ "ndas;MPEG-4;;;http://www.nerodigital.com;Nero Digital AAC Audio\n"
+ "ndsc;MPEG-4;;;http://www.nerodigital.com;Nero Digital Cinema Profile\n"
+ "ndsh;MPEG-4;;;http://www.nerodigital.com;Nero Digital HDTV Profile\n"
+ "ndsm;MPEG-4;;;http://www.nerodigital.com;Nero Digital Mobile Profile\n"
+ "ndsp;MPEG-4;;;http://www.nerodigital.com;Nero Digital Portable Profile\n"
+ "ndss;MPEG-4;;;http://www.nerodigital.com;Nero Digital Standard Profile\n"
+ "ndxc;MPEG-4;;;http://www.nerodigital.com;Nero Digital AVC Cinema Profile\n"
+ "ndxh;MPEG-4;;;http://www.nerodigital.com;Nero Digital AVC HDTV Profile\n"
+ "ndxm;MPEG-4;;;http://www.nerodigital.com;Nero Digital AVC Mobile Profile\n"
+ "ndxp;MPEG-4;;;http://www.nerodigital.com;Nero Digital AVC Portable Profile\n"
+ "ndxs;MPEG-4;;;http://www.nerodigital.com;Nero Digital AVC Standard Profile\n"
+ "mmp4;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Mobile version\n"
+ "mp71;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;ISO 14496-12 MPEG-7 meta data\n"
+ "mp7b;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;ISO 14496-12 MPEG-7 meta data\n"
+ "piff;MPEG-4;Protected Interoperable File Format;;http://www.apple.com/quicktime/download/standalone.html;PIFF\n"
+ "qt ;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;QuickTime\n"
+ "SDV ;MPEG-4;;;http://www.sdcard.org/;SD Memory Card Video\n"
+ "M4A ;MPEG-4;;;http://www.apple.com/itunes/;Apple audio with iTunes info\n"
+ "M4B ;MPEG-4;;;http://www.apple.com/itunes/;Apple audio with iTunes position\n"
+ "M4P ;MPEG-4;;;http://www.apple.com/itunes/;AES encrypted audio\n"
+ "M4VP;MPEG-4;;;http://www.apple.com/iphone/;Apple iPhone\n"
+ "iphE;MPEG-4;;;http://www.apple.com/iphone/;Apple iPhone (Cellular)\n"
+ "M4VH;MPEG-4;;;http://www.apple.com/appletv/;Apple TV\n"
+ "QTCA;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Quicktime compressed archive\n"
+ "CAQV;MPEG-4;;;;Casio Digital Camera\n"
+ "QTI ;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;QuickTime Image\n"
+ "f4v ;MPEG-4;;;http://www.apple.com/quicktime/download/standalone.html;Adobe Flash\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_Video_Matroska (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "V_UNCOMPRESSED;RGB;;Raw uncompressed video frames\n"
+ "V_DIRAC;Dirac;;;http://diracvideo.org/\n"
+ "V_MPEG4/IS0/SP;MPEG-4 Visual;;There is a zero instead of a O, may be a problem;http://www.divx.com\n"
+ "V_MPEG4/IS0/ASP;MPEG-4 Visual;;There is a zero instead of a O, may be a problem;http://www.xvid.org/Downloads.15.0.html\n"
+ "V_MPEG4/IS0/AP;MPEG-4 Visual;;There is a zero instead of a O, may be a problem;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG4/IS0/AVC;AVC;;There is a zero instead of a O, may be a problem;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG4/ISO/SP;MPEG-4 Visual;;Simple Profile;http://www.divx.com\n"
+ "V_MPEG4/ISO/ASP;MPEG-4 Visual;;Advanced Simple Profile;http://www.xvid.org/Downloads.15.0.html\n"
+ "V_MPEG4/ISO/AP;MPEG-4 Visual;;Advanced Profile;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG4/ISO/AVC;AVC;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG4/MS/V2;MPEG-4 Visual;MS MPEG-4 v2;MS MPEG-4 v2;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG4/MS/V3;MPEG-4 Visual;MS MPEG-4 v3;MS MPEG-4 v3;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG1;MPEG Video;;MPEG 1 or 2 Video;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG2;MPEG Video;;MPEG 1 or 2 Video;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_PRORES;ProRes;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "V_REAL/RV10;RealVideo 1;;RealVideo 1.0 aka RealVideo 5;http://www.real.com\n"
+ "V_REAL/RV20;RealVideo 2;;RealVideo 2.0 aka G2 and RealVideo G2+SVT;http://www.real.com\n"
+ "V_REAL/RV30;RealVideo 3;;RealVideo 3.0 aka RealVideo 8;http://www.real.com\n"
+ "V_REAL/RV40;RealVideo 4;;RealVideo 4.0 aka RealVideo 9;http://www.real.com\n"
+ "V_THEORA;Theora;;;http://www.theora.org\n"
+ "V_VP8;VP8;;;http://www.webmproject.org/\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_Video_Mpeg4 (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "2vuy;YUV;;;;;;YUV;4:2:2\n"
+ "2Vuy;YUV;;;;;;YUV;4:2:2\n"
+ "8BPS;RGB;;;;;;RGB;8:8:8\n"
+ "ac16;YUV;;;;;;YUV;4:2:2\n"
+ "ac32;YUV;;;;;;YUV;4:2:2\n"
+ "acBG;YUV;;;;;;YUV;4:2:2\n"
+ "apch;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;High;;YUV;4:2:2\n"
+ "apcn;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "apcs;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;LT;;YUV;4:2:2\n"
+ "apco;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;Proxy;;YUV;4:2:2\n"
+ "ap4c;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:4:4\n"
+ "ap4h;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:4:4\n"
+ "ai12;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;;\n"
+ "ai15;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;;\n"
+ "ai1q;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;;\n"
+ "ai5q;AVC;;Advanced Video Coding;http://ffdshow-tryout.sourceforge.net;;;\n"
+ "avc1;AVC;;Advanced Video Coding;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "avcp;AVC;;Advanced Video Coding Parameters;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "AVdv;DV;;Avid;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "AVdn;VC-3;DNxHD;Avid;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "AVmp;MPEG Video;Avid IMX;;;;Version 2;;\n"
+ "avr ;JPEG;;;;;;\n"
+ "b16g;Gray;;;;;;Y;16\n"
+ "b32a;Gray/Alpha;;;;;;YA;16:16\n"
+ "b48r;RGB;;;;;;RGB;16:16:16\n"
+ "b64a;RGBA;;;;;;RGBA;16:16:16:16\n"
+ "base;RGBA;;;;;;RGBA;16:16:16:16\n"
+ "blit;RGBA;;;;;;RGBA;16:16:16:16\n"
+ "blnd;Alpha Compositor;;;;;;\n"
+ "blur;Blur;;;;;;CMYK\n"
+ "CFHD;CineForm;;CineForm High-Definition (HD) wavelet codec;http://www.cineform.com/;;;\n"
+ "cmyk;CMYK;;;;;;\n"
+ "cvid;Cinepack;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "drac;Dirac;;Dirac Video Coder;http://www.bbc.co.uk/rd/projects/dirac/index.shtml;;;\n"
+ "dslv;Cross Fade;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "DV10;Digital Voodoo;;Digital Voodoo 10 bit Uncompressed 4:2:2 codec;http://www.digitalvoodoo.net/;;;\n"
+ "dv5n;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "dv5p;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "dvc ;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "dvcp;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "dvh1;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "dvh2;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "dvh3;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "dvh4;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "dvh5;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "dvh6;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "dvhp;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "dvhq;DV;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "DVOO;Digital Voodoo;;Digital Voodoo 8 bit Uncompressed 4:2:2 codec;http://www.digitalvoodoo.net/;;;\n"
+ "DVOR;Digital Voodoo;;Digital Voodoo intermediate raw;http://www.digitalvoodoo.net/;;;\n"
+ "dvpp;DV;DVCPRO;;http://www.apple.com/quicktime/download/standalone.html;;;YUV;4:2:2\n"
+ "DVTV;Digital Voodoo;;Digital Voodoo intermediate 2vuy;http://www.digitalvoodoo.net/;;;\n"
+ "DVVT;Digital Voodoo;;Digital Voodoo intermediate v210;http://www.digitalvoodoo.net/;;;\n"
+ "encv;(Encrypted);;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "gif ;M-GIF;;;;;;\n"
+ "h261;H.261;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "h263;H.263;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "H263;H.263;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "h264;H.264;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "hcpa;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;High;;YUV;4:2:2\n"
+ "HD10;Digital Voodoo;;Digital Voodoo 10 bit Uncompressed 4:2:2 HD codec;http://www.digitalvoodoo.net/;;;\n"
+ "hdv1;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdv2;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdv3;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdv4;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdv5;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdv6;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdv7;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdv8;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdv9;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdva;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdvb;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdvc;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdvd;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdve;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "hdvf;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "icod;Intermediate Codec;Apple;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "j420;YUV;;;;;;YUV;4:2:0\n"
+ "jpeg;JPEG;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "kpcd;Photo CD;;;;;;\n"
+ "LMP2;MPEG Video;;;;;;YUV\n"
+ "M105;Matrox;;;http://www.matrox.com/;;;\n"
+ "MMES;MPEG Video;;;;;;YUV\n"
+ "mmes;MPEG Video;;;;;;YUV\n"
+ "mjp2;JPEG 2000;;;;;;\n"
+ "mjpa;JPEG;;;;;;\n"
+ "mjpb;JPEG;;;;;;\n"
+ "mp4v;MPEG-4 Visual;;;;;;\n"
+ "mpeg;MPEG Video;;;;;;\n"
+ "mx3n;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "mx3p;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "mx4n;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "mx4p;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "mx5n;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "mx5p;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "myuv;YUV;;;;;;YUV;4:2:0\n"
+ "ncpa;ProRes;;;http://www.apple.com/quicktime/download/standalone.html;Normal;;YUV;4:2:2\n"
+ "ovc1;VC-1;;Smooth Streaming Media Video;http://alexzambelli.com/blog/2009/02/10/smooth-streaming-architecture/;;;\n"
+ "png ;PNG;;;;;;\n"
+ "PIM1;MPEG Video;;;;;;YUV\n"
+ "PIM2;MPEG Video;;;;;;YUV\n"
+ "PNTG;MacPaint;;Apple MacPaint image format;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "rle ;RLE;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "rpza;Road Pizza;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "s263;H.263;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "Shr0;SheerVideo;;Generic SheerVideo codec;http://www.bitjazz.com/;;;\n"
+ "Shr1;SheerVideo;;SheerVideo RGB;http://www.bitjazz.com/;;;\n"
+ "Shr2;SheerVideo;;SheerVideo Y'CbCr[A] 4:4:4;http://www.bitjazz.com/;;;\n"
+ "Shr3;SheerVideo;;SheerVideo Y'CbCr 4:2:2;http://www.bitjazz.com/;;;\n"
+ "Shr4;SheerVideo;;SheerVideo Y'CbCr 4:2:2;http://www.bitjazz.com/;;;\n"
+ "SV10;Sorenson;;Sorenson Media Video R1;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "SVQ1;Sorenson 1;;Sorenson Media Video 1 (Apple QuickTime 3);http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "SVQ2;Sorenson 2;;Sorenson Media Video 2 (Apple QuickTime 4);http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "SVQ3;Sorenson 3;;Sorenson Media Video 3 (Apple QuickTime 5);http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "v210;YUV;AJA Video Systems Xena;;;;;YUV;4:2:2\n"
+ "vc-1;VC-1;;SMPTE VC-1;http://www.smpte.org/;;;YUV\n"
+ "WMV3;VC-1;WMV3;Windows Media Video 9;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx;;;\n"
+ "WRLE;Bitmap;;Windows BMP image format;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd50;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd51;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd52;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd53;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd54;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd55;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd56;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd57;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd58;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd59;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd5a;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd5b;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd5c;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd5d;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd5e;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xd5f;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdhd;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdh2;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdv0;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdv1;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdv2;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdv3;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdv4;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdv5;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdv6;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdv7;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdv8;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdv9;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdva;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdvb;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdvc;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdvd;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdve;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "xdvf;MPEG Video;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "yuv2;YUV;;;;;;YUV;4:2:2\n"
+ "yuvs;YUV;;;;;;YUV;4:2:2\n"
+ "yuvu;YUV;;;;;;YUV;4:2:2\n"
+ "yuvx;YUV;;;;;;YUV;4:2:2\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_Video_Real (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "RV10;RealVideo 1;;Based on H.263, Real Player 5;http://www.real.com\n"
+ "RV13;RealVideo 1.3;;Based on H.263, Real Player 5;http://www.real.com\n"
+ "RV20;RealVideo 2;;Based on H.263, Real Player 6;http://www.real.com\n"
+ "RV30;RealVideo 3;;Between H.263 and AVC (H.264), Real Player 8;http://www.real.com\n"
+ "RV40;RealVideo 4;;Based on AVC (H.264), Real Player 9;http://www.real.com\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_Video_Riff (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "0x00000000;RGB;;Basic Windows bitmap format. 1, 4 and 8 bpp versions are palettised. 16, 24 and 32bpp contain raw RGB samples;http://www.fourcc.org/indexrgb.htm;;;;\n"
+ "0x00000001;RLE;;Run length encoded 8bpp RGB image;http://www.fourcc.org/indexrgb.htm;;;;\n"
+ "0x00000002;RLE;;Run length encoded 4bpp RGB image;http://www.fourcc.org/indexrgb.htm;;;;\n"
+ "0x00000003;RGB;;Raw RGB with arbitrary sample packing within a pixel. Packing and precision of R, G and B components is determined by bit masks for each;http://www.fourcc.org/indexrgb.htm;;;;\n"
+ "1978;RGB;A.M.Paredes predictor;;http://www.pegasusimaging.com/cgi-bin/download2.cgi?LVIDB;;;RGB;\n"
+ " BIT;RGB;;;;;;RGB;\n"
+ " JPG;JPEG;;;;;;YUV\n"
+ " PNG;PNG;;;;;;RGB;\n"
+ " RAW;RGB;;;http://www.fourcc.org/indexrgb.htm;;;RGB;\n"
+ " raw;RGB;;;http://www.fourcc.org/indexrgb.htm;;;RGB;\n"
+ " RGB;RGB;;;http://www.fourcc.org/indexrgb.htm;;;RGB;\n"
+ " RL4;RLE;;;http://www.fourcc.org/indexrgb.htm;;;RGB;;4\n"
+ " RL8;RLE;;;http://www.fourcc.org/indexrgb.htm;;;RGB;;8\n"
+ "2VUY;YUV;Optibase VideoPump;;;;;YUV;4:2:2\n"
+ "3IV0;MPEG-4 Visual;3ivX;3ivX pre-1.0;http://www.3ivx.com/download/;;;YUV;4:2:0\n"
+ "3IV1;MPEG-4 Visual;3ivX;3ivX 1.0-3.5;http://www.3ivx.com/download/;;;YUV;4:2:0\n"
+ "3IV2;MPEG-4 Visual;3ivX;3ivX 4.0;http://www.3ivx.com/download/;;;YUV;4:2:0\n"
+ "3IVD;MPEG-4 Visual;3ivX;;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "3IVX;MPEG-4 Visual;3ivX;;http://www.3ivx.com/download/;;;YUV;4:2:0\n"
+ "3VID;MPEG-4 Visual;3ivX;;http://www.3ivx.com/download/;;;YUV;4:2:0\n"
+ "8BPS;RGB;Apple;;http://ffdshow-tryout.sourceforge.net/;;;RGBA\n"
+ "AAS4;RLE;Autodesk;;http://mirror01.iptelecom.net.ua/~video/codecs/Autodesk.Animator.v1.11.Codec.exe;;;RGB\n"
+ "AASC;RLE;Autodesk;;http://mirror01.iptelecom.net.ua/~video/codecs/Autodesk.Animator.v1.11.Codec.exe;;;RGB\n"
+ "ABYR;Kensigton low;Kensington;Low resolution, low frame rate (6fps) for digital cameras;;;;\n"
+ "ACTL;ACT-L2;Streambox;;http://www.streambox.com/products/act-L2_codec.htm;;;\n"
+ "ADV1;WaveCodec;Loronix;;http://www.loronix.com/products/video_clips/wavecodec.asp;;;\n"
+ "ADVJ;JPEG;Avid;;;;;YUV\n"
+ "AEIK;Indeo 3.2;;Vector Quantization;;;;\n"
+ "AEMI;MPEG Video;VideoONE;MPEG-1-I Capture;http://www.array.com;;;YUV;4:2:0\n"
+ "AFLC;FLC;Autodesk;;http://mirror01.iptelecom.net.ua/~video/codecs/Autodesk.Animator.v1.11.Codec.exe;;;\n"
+ "AFLI;FLI;Autodesk;;http://mirror01.iptelecom.net.ua/~video/codecs/Autodesk.Animator.v1.11.Codec.exe;;;\n"
+ "AHDV;CineForm;CineForm HD;;http://www.cineform.com/products/ConnectHD.htm;;;\n"
+ "AJPG;JPEG;;22fps for digital cameras;;;;YUV\n"
+ "ALPH;Ziracom;;Ziracom Digital Communications Inc.;;;;\n"
+ "AMM2;AMV2 MT;AMV2 MT Video Codec Version 2;;http://amamaman.hp.infoseek.co.jp/english/amv2_e.html;;;\n"
+ "AMPG;MPEG-1;VideoONE;;http://www.array.com;;;YUV;4:2:0\n"
+ "AMR ;AMR;;Speech codec;;;;\n"
+ "AMV3;AMV3;AMV3 Video Codec Version 3;;http://amamaman.hp.infoseek.co.jp/english/amv2_e.html;;;YUV;4:2:0\n"
+ "ANIM;RDX;Intel;;;;;\n"
+ "AP41;MPEG-4 Visual;AngelPotion;Hack of MS MPEG-4 v3;http://www.divxity.com/download/ap4v1-702.exe;;;YUV;4:2:0\n"
+ "AP42;MPEG-4 Visual;AngelPotion;Hack of MS MPEG-4 v3;http://www.divxity.com/download/ap4v1-702.exe;;;YUV;4:2:0\n"
+ "ASLC;AlparySoft Lossless;;;http://www.free-codecs.com/download/Alparysoft_Lossless_Video_Codec.htm;;;\n"
+ "ASV1;Asus 1;;;ftp://ftp.asuscom.de/pub/asuscom/treiber/vga/ASUS_VGA_TOOLS/asv2dec.zip;;;\n"
+ "ASV2;Asus 2;;;ftp://ftp.asuscom.de/pub/asuscom/treiber/vga/ASUS_VGA_TOOLS/asv2dec.zip;;;\n"
+ "ASVX;Asus X;;;ftp://ftp.asuscom.de/pub/asuscom/treiber/vga/ASUS_VGA_TOOLS/asv2dec.zip;;;\n"
+ "ATM4;MPEG-4 Visual;Nero;;http://www.nero.com;;;YUV;4:2:0\n"
+ "AUR2;YUV;;Auravision Aura 2;;;;YUV;4:2:2\n"
+ "AURA;YUV;;Auravision Aura 1;;;;YUV;4:1:1\n"
+ "AUVX;AUVX;;USH GmbH;;;;\n"
+ "AV1X;Avid 1:1;;;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe;;;\n"
+ "AVC1;AVC;;;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "avc1;AVC;;;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "AVD1;DV;Avid;;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe;;;YUV;\n"
+ "AVDJ;JPEG;Avid;;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe;;;YUV\n"
+ "AVDN;Avid HD;;;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe;;;;\n"
+ "AVDV;DV;Avid;;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe;;;YUV;\n"
+ "AVI1;JPEG;MainConcept;;;;;YUV\n"
+ "AVI2;JPEG;MainConcept;;;;;YUV\n"
+ "AVID;JPEG;Avid;;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe;;;YUV\n"
+ "AVIS;AviSynth;;Wrapper for AviSynth (Dummy);http://ffdshow-tryout.sourceforge.net/;;;;\n"
+ "AVMP;Avid IMX;;;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe;;;;\n"
+ "AVR ;JPEG;Avid NuVista;Avid ABVB/NuVista JPEG with Alpha-channel;;;;YUV\n"
+ "AVRn;JPEG;Avid JPEG;;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe;;;YUV\n"
+ "AVRN;JPEG;Avid JPEG;;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe;;;YUV\n"
+ "AVUI;Avid;;Avid Meridien Uncompressed with Alpha-channel;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe;;;;\n"
+ "AVUP;Avid;;Avid 10bit Packed (Quick Time);http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe;;;;\n"
+ "AYUV;YUV;YUV;;;;;YUVA;4:4:4;8\n"
+ "AZPR;QuickTime;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "AZRP;QuickTime;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "BGR ;RGB;RGB;;;;;RGB\n"
+ "BHIV;BeHere iVideo;;;;;;\n"
+ "BINK;Bink;;;;;;\n"
+ "BIT ;RGB;RGB;;;;;RGB\n"
+ "BITM;H.261;Microsoft;;;;;YUV\n"
+ "BLOX;MPEG Video;Blox;;http://www.ii.uj.edu.pl/~jezabek/blox/blox-0.1.0b.zip;;;YUV;4:2:0\n"
+ "BLZ0;MPEG-4 Visual;DivX;DivX for Blizzard Decoder Filter;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "BT20;MediaStream;;Conexant ProSummer MediaStream;;;;\n"
+ "BTCV;Composite;;Conexant Composite Video;;;;\n"
+ "BTVC;Composite;;Conexant Composite Video;;;;\n"
+ "BW00;Wavelet;BergWave;;;;;\n"
+ "BW10;MPEG-1;Broadway;Data Translation Broadway MPEG Capture/Compression;;;;YUV\n"
+ "BXBG;RGB;Boxx;;;;;RGB\n"
+ "BXRG;RGB;Boxx;;;;;RGB\n"
+ "BXY2;YUV;Boxx;10-bit;;;;YUV\n"
+ "BXYV;YUV;Boxx;;;;;YUV\n"
+ "CC12;YUV;Intel;;;;;YUV\n"
+ "CDV5;DV;Canopus;Canopus SD50/DVHD;http://www.cineform.com/products/ConnectHD.htm;;;YUV\n"
+ "CDVC;DV;Canopus;Canopus DV (DV);http://www.cineform.com/products/ConnectHD.htm;;;YUV\n"
+ "CDVH;DV;Canopus;Canopus SD50/DVHD;http://www.cineform.com/products/ConnectHD.htm;;;YUV\n"
+ "CFCC;JPEG;DPS Perception;Dummy format - only AVI header;;;;YUV\n"
+ "CFHD;CineForm;;CineForm 10-bit Visually Perfect HD (Wavelet);;;;\n"
+ "CGDI;Camcorder;;Camcorder Video (MS Office 97);;;;\n"
+ "CHAM;Champagne;;Winnov Caviara Champagne;;;;\n"
+ "CJPG;JPEG;Creative;Creative Video Blaster Webcam Go JPEG;;;;YUV\n"
+ "CLJR;YUV;Cirrus Logic;Less than 8 bits per Y, U and V sample.;http://www.fourcc.org/indexyuv.htm;;;YUV;4:1:1\n"
+ "CLLC;Canopus;;Canopus LossLess;;;;\n"
+ "CLPL;YUV;;Format similar to YV12 but including a level of indirection.;;;;YUV\n"
+ "CM10;MediaShow;;CyberLink Corporation;http://www.cyberlink.com;;;\n"
+ "CMYK;CMYK;;Common Data Format in Printing;;;;\n"
+ "COL0;MPEG-4 Visual;;Hacked MS MPEG-4 v3;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "COL1;MPEG-4 Visual;;Hacked MS MPEG-4 v3;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "CPLA;YUV;Weitek;;;;;YUV;4:2:0\n"
+ "CRAM;MS Video;;Microsoft Video 1;;;;\n"
+ "CSCD;CamStudio;;RenderSoft CamStudio lossless (LZO & GZIP compression);;;;\n"
+ "CT10;TalkingShow;;CyberLink Corporation;http://www.cyberlink.com;;;\n"
+ "CTRX;Citrix;;Citrix Scalable Video;;;;\n"
+ "CUVC;Canopus HQ;;Canopus HQ;;;;\n"
+ "CVID;Cinepack;;;http://www.cinepak.com/text.html;;;\n"
+ "cvid;Cinepack;;;http://www.cinepak.com/text.html;;;\n"
+ "CWLT;WLT;;Microsoft Color WLT DIB;;;;\n"
+ "CYUV;YUV;Creative Labs;;http://www.fourcc.org/indexyuv.htm;;;YUV;4:2:2\n"
+ "cyuv;YUV;;;http://www.fourcc.org/indexyuv.htm;;;YUV;4:2:2\n"
+ "CYUY;YUV;ATI;;http://www.fourcc.org/indexyuv.htm;;;YUV;4:2:2\n"
+ "D261;H.261;DEC;;;;;\n"
+ "D263;H.263;DEC;;;;;\n"
+ "DAVC;AVC;Dicas;;;;;YUV;4:2:0\n"
+ "DC25;DV;MainConcept;;;;;YUV\n"
+ "DCAP;DV;Pinnacle;;;;;YUV\n"
+ "DCL1;Data Connextion;;Conferencing;;;;\n"
+ "DCT0;WniWni;;;;;;\n"
+ "DFSC;VFW;;DebugMode FrameServer VFW;;;;\n"
+ "DIB ;RGB;;;;;;RGB\n"
+ "DIV1;MPEG-4 Visual;FFMpeg;Hacked MS MPEG-4 V1;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "DIV2;MPEG-4 Visual;MS MPEG-4 1/2;;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "DIV3;MPEG-4 Visual;DivX 3 Low;;http://www.divx.com;;;YUV;4:2:0\n"
+ "DIV4;MPEG-4 Visual;DivX 3 Fast;;http://www.divx.com;;;YUV;4:2:0\n"
+ "DIV5;MPEG-4 Visual;DivX 5;;http://www.divx.com;;;YUV;4:2:0\n"
+ "DIV6;MPEG-4 Visual;MS MPEG-4 v3;;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "DIVX;MPEG-4 Visual;DivX 4;Project Mayo;http://mediaarea.net/DIVX;;;YUV;4:2:0\n"
+ "divx;MPEG-4 Visual;DivX;Mainly used by Google;http://www.divx.com;;;YUV;4:2:0\n"
+ "DJPG;JPEG;Broadway 101;Data Translation, Inc.;;;;YUV\n"
+ "DM4V;MPEG-4 Visual;Dicas;;;;;YUV;4:2:0\n"
+ "DMB1;JPEG;Rainbow;Matrox Rainbow Runner hardware compression;http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.MJPG.v2.10.27.codec.exe;;;YUV\n"
+ "DMB2;JPEG;Paradigm;;;;;YUV\n"
+ "DMK2;V36 PDA;;ViewSonic V36 PDA Video;;;;\n"
+ "DP02;MPEG-4 Visual;DynaPel;;;;;YUV;4:2:0\n"
+ "DP16;YUV;Matsushita;With DPCM 6-bit compression;;;;YUV;4:1:1\n"
+ "DP18;YUV;Matsushita;With DPCM 8-bit compression;;;;YUV;4:1:1\n"
+ "DP26;YUV;Matsushita;With DPCM 6-bit compression;;;;YUV;4:2:2\n"
+ "DP28;YUV;Matsushita;With DPCM 8-bit compression;;;;YUV;4:2:2\n"
+ "DP96;YUV;Matsushita;With DPCM 6-bit compression;;;;YUV\n"
+ "DP98;YUV;Matsushita;With DPCM 8-bit compression;;;;YUV\n"
+ "DP9L;YUV;Matsushita;With DPCM 6-bit compression;;;;YUV\n"
+ "DPS0;JPEG;DPS Reality;Dummy format - only AVI header;;;;YUV\n"
+ "DPSC;JPEG;DPS PAR;Dummy format - only AVI header;;;;YUV\n"
+ "DRWX;DV;Pinnacle;;;;;YUV\n"
+ "DSVD;DV;Microsoft;;;;;YUV\n"
+ "DTMT;Media-100;;;;;\n"
+ "DTNT;Media-100;;;;;\n"
+ "DUCK;TrueMotion S;Duck Corporation;;;;\n"
+ "DV10;RGB;BlueFish;BlueFish444 (lossless RGBA, YUV 10-bit);;;;RGB\n"
+ "DV25;DV;DVCPro;;;;;YUV\n"
+ "dv25;DV;DVCPro;;;;;YUV\n"
+ "DV50;DV;DVCPro5;;;;;YUV\n"
+ "dv50;DV;DVCPro5;;;;;YUV\n"
+ "DVAN;DV;Pinnacle DV300;;;;;YUV\n"
+ "DVC ;DV;Apple;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "DVCP;DV;Apple;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "DVCS;DV;MainConcept;;;;;YUV\n"
+ "DVE2;DV;Insoft DVE-2;InSoft DVE-2 Videoconferencing;;;;YUV\n"
+ "DVH1;DV;Pinnacle;;;;;YUV\n"
+ "dvhd;DV;HD;;;;;YUV\n"
+ "DVIS;DV;DualMoon;;;;;YUV\n"
+ "DVL ;DV;Radius;;;;;YUV\n"
+ "DVLP;DV;Radius;;;;;YUV\n"
+ "DVMA;DV;Darim;;;;;YUV\n"
+ "DVNM;DVNM;;Matsushita Electric Industrial Co., Ltd.;;;;\n"
+ "DVOR;RGB;BlueFish;BlueFish444 (lossless RGBA, YUV 10-bit);;;;RGB\n"
+ "DVPN;DV;Apple;;;;;YUV\n"
+ "DVPP;DV;Apple;;;;;YUV\n"
+ "DVR ;MPEG Video;ASF;;;;;YUV;4:2:0\n"
+ "DVR1;Targa2000;;;;;;\n"
+ "DVRS;DV;DualMoon;;;;;YUV\n"
+ "dvsd;DV;Sony;;;;;YUV\n"
+ "dvsl;DV;Sony;;;;;YUV\n"
+ "DVSL;DV;;;;;;YUV\n"
+ "DVX1;DVX 1 SP;;Lucent DVX1000SP Video Decoder;;;;\n"
+ "DVX2;DVX 2 S;;Lucent DVX2000S Video Decoder;;;;\n"
+ "DVX3;DVX 3 S;;Lucent DVX3000S Video Decoder;;;;\n"
+ "DX50;MPEG-4 Visual;DivX 5;;http://mediaarea.net/DX50;;;YUV;4:2:0\n"
+ "DXGM;EA GameVideo;;;;;;\n"
+ "DXT1;DirectX TC;;DirectX Compressed Texture (1bit alpha channel)\n"
+ "DXT2;DirectX TC;;DirectX Compressed Texture\n"
+ "DXT3;DirectX TC;;DirectX Compressed Texture (4bit alpha channel)\n"
+ "DXT4;DirectX TC;;DirectX Compressed Texture\n"
+ "DXT5;DirectX TC;;DirectX Compressed Texture (3bit alpha channel with interpolation)\n"
+ "DXTC;DirectX TC;;DirectX Texture Compression\n"
+ "DXTn;DirectX TC;;Microsoft Compressed Texture\n"
+ "DXTN;DirectX TC;;Microsoft DirectX Compressed Texture (DXTn)\n"
+ "EKQ0;Elsa KQ;;Elsa graphics card quick\n"
+ "ELK0;Elsa LK;;Elsa graphics card\n"
+ "EM2V;Elymonyx MPEG-2;;Etymonix MPEG-2 I-frame\n"
+ "EQK0;Elsa;;Elsa graphics card quick\n"
+ "ESCP;Escape;;Eidos Escape\n"
+ "ETV1;eTreppid 1;;eTreppid Video 1\n"
+ "ETV2;eTreppid 2;;eTreppid Video 2\n"
+ "ETVC;eTreppid C;;eTreppid Video C\n"
+ "FFDS;FFDS;;;http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "FFV1;FFV1;;;http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "FFV2;FFV2;;;http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "FFVH;FFVH;;;http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "FLIC;FLI/FLC;Autodesk;;;;;\n"
+ "FLJP;DField JPEG;;D-Vision Field Encoded JPEG with LSI (or Targa emulation);;;;\n"
+ "FLV1;Sorenson Spark;;;http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "FLV4;VP6;On2;;http://ftp.pub.cri74.org/pub/win9x/video/codecs/VP6/vp6_vfw_codec.exe;Heightened Sharpness;;\n"
+ "FMJP;JPEG;D-Vision;;;;;YUV\n"
+ "FMP4;MPEG-4 Visual;;;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "FPS1;Fraps;;;http://www.fraps.com/;;;\n"
+ "FRLE;JPEG;SoftLab-Nsk;SoftLab-NSK Y16 + Alpha RLE;;;;YUV\n"
+ "FRWA;JPEG;SoftLab-Nsk;SoftLab-NSK Vision Forward JPEG with Alpha-channel;;;;YUV\n"
+ "FRWD;JPEG;SoftLab-Nsk;SoftLab-NSK Vision Forward JPEG;;;;YUV\n"
+ "FRWT;JPEG;SoftLab-Nsk;SoftLab-NSK Vision Forward JPEG with Alpha-channel;;;;YUV\n"
+ "FRWU;JPEG;SoftLab-Nsk;SoftLab-NSK Vision Forward Uncompressed;;;;YUV\n"
+ "FVF1;Itered Fractal;;;;;;\n"
+ "FVFW;FVFW;;;http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "FXT1;3DFX;;;;;;\n"
+ "G2M2;GoToMeeting2;;Citrix Systems, Inc.;http://www.gotomeeting.com/;;;\n"
+ "G2M3;GoToMeeting3;;Citrix Systems, Inc.;http://www.gotomeeting.com/;;;\n"
+ "GEPJ;JPEG;White Pine;;;;;YUV\n"
+ "GJPG;Grand Tech GT891x;;;;;;\n"
+ "GLCC;GigaLink;;;;;;\n"
+ "GLZW;LZW;Gabest;;http://sourceforge.net/project/showfiles.php?group_id=82303&package_id=84358;;;\n"
+ "GMP4;GeoVision Advanced MPEG-4;;;http://www.geovision.com.tw/;;;\n"
+ "GM40;GeoVision Advanced MPEG-4;;;http://www.geovision.com.tw/;;;\n"
+ "GPEG;JPEG;Gabest;;http://sourceforge.net/project/showfiles.php?group_id=82303&package_id=84358;;;YUV\n"
+ "GPJM;JPEG;Pinnacle;;;;;YUV\n"
+ "GREY;YUV;;Simple grayscale video;http://www.fourcc.org/indexyuv.htm;;;YUV\n"
+ "GWLT;MS GWLT;;Microsoft Greyscale WLT DIB;;;;\n"
+ "GXVE;ViVD V2;SoftMedia;;;;;\n"
+ "H260;H.260;;;;;;\n"
+ "H261;H.261;;;;;;\n"
+ "H262;MPEG Video;;;;;;YUV;4:2:0\n"
+ "H263;H.263;;;;;;\n"
+ "h263;H.263;;;http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "H264;AVC;;;;;;YUV;4:2:0\n"
+ "h264;AVC;;;;;;YUV;4:2:0\n"
+ "H265;H.265;;;;;;\n"
+ "H266;H.266;;;;;;\n"
+ "H267;H.267;;;;;;\n"
+ "H268;H.268;;;;;;\n"
+ "H269;H.263;;;;;;\n"
+ "HD10;RGB;BlueFish;BlueFish444 (lossless RGBA, YUV 10-bit);;;;RGB\n"
+ "HDX4;Jomigo HDX4;;;;;;\n"
+ "HFYU;Huffman;;;;;;\n"
+ "HMCR;Rendition;;Rendition Motion Compensation Format;;;;\n"
+ "HMRR;Rendition;;Rendition Motion Compensation Format;;;;\n"
+ "i263;H.263;;;;;;\n"
+ "I420;YUV;;8 bit Y plane followed by 8 bit 2x2 subsampled U and V planes.;;;;\n"
+ "IAN ;Indeo 4;;;;;;\n"
+ "ICLB;CellB;;InSoft CellB Videoconferencing;;;;\n"
+ "IDM0;Wavelets 2;;IDM Motion Wavelets 2.0;;;;\n"
+ "IF09;H.261;Microsoft;;;;;\n"
+ "IFO9;YUV;Intel;;;;;YUV\n"
+ "IGOR;PowerDVD;;;;;;\n"
+ "IJPG;JPEG;Intergraph;;;;;YUV\n"
+ "ILVC;Layered Video;Intel;;;;;\n"
+ "ILVR;H.263+;;;;;;\n"
+ "IMAC;MotionComp;;Intel hardware motion compensation.;;;;\n"
+ "IMC1;YUV;;As YV12, except the U and V planes each have the same stride as the Y plane;;;;YUV\n"
+ "IMC2;YUV;;Similar to IMC1, except that the U and V lines are interleaved at half stride boundaries;;;;YUV\n"
+ "IMC3;YUV;;As IMC1, except that U and V are swapped;;;;YUV\n"
+ "IMC4;YUV;;As IMC2, except that U and V are swapped;;;;YUV\n"
+ "IMG ;YUV;;;;;;YUV\n"
+ "IMJG;Accom JPEG;;Accom SphereOUS JPEG with Alpha-channel;;;;\n"
+ "IPDV;I-O DV;;I-O Data Device Giga AVI DV;;;\n"
+ "IPJ2;JPEG 2000;;Image Power JPEG 2000;;;\n"
+ "IR21;Indeo 2.1;;;;;\n"
+ "IRAW;YUV;;;http://www.fourcc.org/indexyuv.htm;;;YUV\n"
+ "ISME;ISME;;Intel;;;\n"
+ "IUYV;YUV;;Lead 16bpp. Interlaced version of UYVY (line order 0, 2, 4,....,1, 3, 5....);;;;YUV\n"
+ "IV30;Indeo 3;;Intel Indeo Video 3;;;\n"
+ "IV31;Indeo 3;;Intel Indeo Video 3.1;;;\n"
+ "IV32;Indeo 3;;Intel Indeo Video 3.2;;;\n"
+ "IV33;Indeo 3;;Intel Indeo Video 3.3;;;\n"
+ "IV34;Indeo 3;;Intel Indeo Video 3.4;;;\n"
+ "IV35;Indeo 3;;Intel Indeo Video 3.5;;;\n"
+ "IV36;Indeo 3;;Intel Indeo Video 3.6;;;\n"
+ "IV37;Indeo 3;;Intel Indeo Video 3.7;;;\n"
+ "IV38;Indeo 3;;Intel Indeo Video 3.8;;;\n"
+ "IV39;Indeo 3;;Intel Indeo Video 3.9;;;\n"
+ "IV40;Indeo 4;;Intel Indeo Video 4.0;;;\n"
+ "IV41;Indeo 4;;Intel Indeo Video 4.1;;;\n"
+ "IV42;Indeo 4;;Intel Indeo Video 4.2;;;\n"
+ "IV43;Indeo 4;;Intel Indeo Video 4.3;;;\n"
+ "IV44;Indeo 4;;Intel Indeo Video 4.4;;;\n"
+ "IV45;Indeo 4;;Intel Indeo Video 4.5;;;\n"
+ "IV46;Indeo 4;;Intel Indeo Video 4.6;;;\n"
+ "IV47;Indeo 4;;Intel Indeo Video 4.7;;;\n"
+ "IV48;Indeo 4;;Intel Indeo Video 4.8;;;\n"
+ "IV49;Indeo 4;;Intel Indeo Video 4.9;;;\n"
+ "IV50;Indeo 4;;Intel Indeo Video 5.0 Wavelet;http://www.fourcc.org/indexyuv.htm;;\n"
+ "IY41;YUV;;Lead 16bpp. Interlaced version of Y41P (line order 0, 2, 4,....,1, 3, 5....);http://www.fourcc.org/indexyuv.htm;;;YUV\n"
+ "IYU1;YUV;;IEEE1394 12bpp. 12 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec;http://www.fourcc.org/indexyuv.htm;;;YUV\n"
+ "IYU2;YUV;;IEEE1394 24bpp. 24 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec;;;;YUV\n"
+ "IYUV;YUV;;Intel Indeo iYUV 4:2:0;;;;YUV\n"
+ "JBYR;Kensington;;Kensington Video;http://ffdshow-tryout.sourceforge.net/;;\n"
+ "JFIF;JPEG;;;;;;YUV\n"
+ "JPEG;JPEG;;;http://www.apple.com/quicktime/download/standalone.html;;;YUV\n"
+ "JPG;JPEG;;;http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.Lossless.JPEG.codec.v2.10.27.exe;;;YUV\n"
+ "JPGL;JPEG;Pegasus;DIVIO JPEG Light for WebCams (Pegasus Lossless JPEG);;;;YUV\n"
+ "KMVC;Karl;;Karl Morton's Video (presumably);http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "kpcd;Photo CD;;Kodak Photo CD;;;;\n"
+ "L261;H.261;Lead Technologies;;;;;\n"
+ "L263;H.263+;Lead Technologies;;;;;\n"
+ "LAGS;Lagarith;;;;;;\n"
+ "LBYR;Creative WebCam;;;;;;\n"
+ "LCMW;Lead CMW;;Lead Technologies Motion CMW;;;;\n"
+ "LCW2;Lead MCMW;;LEADTools MCMW 9Motion Wavelet;http://mirror01.iptelecom.net.ua/~video/codecs/LEAD.MCMP-JPEG.v1.016.codec.exe;;;\n"
+ "LEAD;Lead Video;;;;;;\n"
+ "LGRY;Lead GrayScale;;;;;;\n"
+ "LIA1;Liafail;;Liafail, Inc.;;;;\n"
+ "LJ2K;JPEG 2000;Lead;;http://mirror01.iptelecom.net.ua/~video/codecs/LEAD.MCMP-JPEG.v1.016.codec.exe;;;\n"
+ "LJPG;JPEG;Lead;;http://mirror01.iptelecom.net.ua/~video/codecs/LEAD.MCMP-JPEG.v1.016.codec.exe;;;YUV\n"
+ "Ljpg;JPEG;Lead;;;;;YUV\n"
+ "LMP2;MPEG-PS;Lead;;;;;\n"
+ "LOCO;LOCO;;Lossless;;;;\n"
+ "LSCR;Lead Screen capture;;;;;;\n"
+ "LSV0;LSV0;;Infinop Inc.;;;;\n"
+ "LSVC;Vmail;;Vianet Lighting Strike Vmail (Streaming);;;;\n"
+ "LSVM;Vmail;;Vianet Lighting Strike Vmail (Streaming);;;;\n"
+ "LSVW;Infinop;;Infinop Lightning Strike multiple bit rate video codec.;;;;\n"
+ "LSVX;Vmail;;Vianet Lightning Strike Video Codec;;;;\n"
+ "LZO1;LZO;;LZO compressed (lossless);;;;\n"
+ "M101;YUV;Matrox;;;;;YUV\n"
+ "M261;H.261;Microsoft;;;;;\n"
+ "M263;H.263;Microsoft;;;;;\n"
+ "M4CC;MPEG-4 Visual;ESS Divo;;;;;YUV;4:2:0\n"
+ "M4S2;MPEG-4 Visual;Microsoft;;;;;YUV;4:2:0\n"
+ "MC12;ATI Motion;;ATI Motion Compensation Format;;;;\n"
+ "MC24;JPEG;MainConcept;;;;;YUV\n"
+ "MCAM;ATI Motion;;ATI Motion Compensation Format;;;;\n"
+ "MCZM;RGB;;Theory MicroCosm Lossless 64bit RGB with Alpha-channel;;;;RGB\n"
+ "MDVD;MicroDVD;;Alex MicroDVD Video (hacked MS MPEG-4);;;;\n"
+ "MDVF;DV;Pinnacle;Pinnacle DV/DV50/DVHD100;;;;YUV\n"
+ "MHFY;YUV;;A.M.Paredes mhuffyYUV (LossLess);http://mirror01.iptelecom.net.ua/~video/codecs/Pinnacle.ReelTime.v2.5.software.only.codec.exe;;;YUV\n"
+ "MJ2C;JPEG 2000;;Morgan Multimedia JPEG 2000 Compression;http://mirror01.iptelecom.net.ua/~video/codecs/Pinnacle.ReelTime.v2.5.software.only.codec.exe;;;\n"
+ "MJPA;JPEG;Pinacle;Pinnacle ReelTime MJPG hardware;http://mediaxw.sourceforge.net;;;YUV\n"
+ "MJPB;JPEG;Pinacle B;;;;;YUV\n"
+ "MJPG;JPEG;;;;;;YUV\n"
+ "mJPG;JPEG;IBM;Including Huffman Tables;;;;YUV\n"
+ "MJPX;JPEG;Pegasus;Pegasus PICVideo JPEG;;;;YUV\n"
+ "ML20;Webcam;;Mimic MSN Messenger Webcam;;;;\n"
+ "MLCY;MLC;;MLC Lossless Codec;http://www.linek.sk/mlc/;;;;;;Lossless\n"
+ "MMES;MPEG Video;Matrox;I-frame;;;;YUV;4:2:0\n"
+ "MMIF;MPEG Video;Matrox;I-frame;;;;YUV;4:2:0\n"
+ "MNVD;MindVid;;MindBend MindVid LossLess;;;;\n"
+ "MP2V;MPEG Video;;Media Excel MPEG-2 Video;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "MP2v;MPEG Video;;MPEG-2 Video;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "MP41;MPEG-4 Visual;Microsoft;Microsoft MPEG-4 v1 (pre-standard);http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "MP42;MPEG-4 Visual;Microsoft;Microsoft MPEG-4 v2 (pre-standard);http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "MP43;MPEG-4 Visual;Microsoft;Microsoft MPEG-4 v3 (pre-standard);;;;\n"
+ "MP4S;MPEG-4 Visual;MS MPEG-4 v3;Microsoft MPEG-4 (Windows Media 7.0);;;;YUV;4:2:0\n"
+ "MP4V;MPEG-4 Visual;;Apple QuickTime MPEG-4 native;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "MPEG;MPEG Video;;Chromatic MPEG 1 Video I Frame;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "mpeg;MPEG Video;;MPEG-1 Video;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "MPG1;MPEG Video;Ffmpeg;(MPEG-1/2) FFmpeg;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "mpg1;MPEG Video;Ffmpeg;(MPEG-1/2) FFmpeg;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "MPG2;MPEG Video;Ffmpeg;(MPEG-1/2) FFmpeg;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "mpg2;MPEG Video;Ffmpeg;(MPEG-1/2) FFmpeg;http://ffdshow-tryout.sourceforge.net/;;;YUV;4:2:0\n"
+ "MPG3;MPEG-4 Visual;FFmpeg DivX 3;(MPEG-4) MS MPEG-4 v3;;;;YUV;4:2:0\n"
+ "MPG4;MPEG-4 Visual;MS MPEG-4 v1;Microsoft MPEG-4 v1;;;;YUV;4:2:0\n"
+ "MPGI;MPEG Video;Sigma;Sigma Design MPEG-1 I-frame;;;;YUV;4:2:0\n"
+ "MPNG;PNG;;Motion PNG;;;;\n"
+ "MRCA;Mrcodec;;FAST Multimedia;;;;\n"
+ "MRLE;RLE;;Microsoft RLE;;;;RGB\n"
+ "MSS1;Screen Video;Windows;Windows Screen Video;;;;\n"
+ "MSS2;Windows Media;;Windows Media 9;;;;\n"
+ "MSUC;MSU;;MSU LossLess;;;;\n"
+ "MSUD;MSU;;MSU LossLess;;;;\n"
+ "MSV1;Microsoft Video 1;;Microsoft Video 1;;;;\n"
+ "MSVC;Microsoft Video 1;;Microsoft Video 1;;;;\n"
+ "MSZH;AVImszh;;Lossless (ZIP compression);;;;\n"
+ "MTGA;TGA;;Motion TGA images (24, 32 bpp);;;;\n"
+ "MTX1;JPEG;Matrox;;;;;YUV\n"
+ "MTX2;JPEG;Matrox;;;;;YUV\n"
+ "MTX3;JPEG;Matrox;;;;;YUV\n"
+ "MTX4;JPEG;Matrox;;;;;YUV\n"
+ "MTX5;JPEG;Matrox;;;;;YUV\n"
+ "MTX6;JPEG;Matrox;;;;;YUV\n"
+ "MTX7;JPEG;Matrox;;;;;YUV\n"
+ "MTX8;JPEG;Matrox;;;;;YUV\n"
+ "MTX9;JPEG;Matrox;;;;;YUV\n"
+ "MV10;Nokia;;Nokia Mobile Phones;;;;\n"
+ "MV11;Nokia;;Nokia Mobile Phones;;;;\n"
+ "MV12;MVI;;Motion Pixels (old);;;;\n"
+ "MV99;Nokia;;Nokia Mobile Phones;;;;\n"
+ "MVC1;Nokia;;Nokia Mobile Phones;;;;\n"
+ "MVC2;Nokia;;Nokia Mobile Phones;;;;\n"
+ "MVC9;Nokia;;Nokia Mobile Phones;;;;\n"
+ "MVI1;MVI;;Motion Pixels MVI;;;;\n"
+ "MVI2;MVI;;Motion Pixels MVI;;;;\n"
+ "MWV1;Aware Motion Wavelets;;Aware Motion Wavelets;;;;\n"
+ "MYUV;RGB;;Media-100 844/X Uncompressed;;;;RGB\n"
+ "NAVI;MPEG-4 Visual;;nAVI video (hacked MS MPEG-4);;;;YUV;4:2:0\n"
+ "NDIG;MPEG-4 Visual;Ahead;Ahead Nero Digital MPEG-4;;;;YUV;4:2:0\n"
+ "NHVU;Nvidia Texture;;Nvidia Texture Format (GEForce 3);;;;\n"
+ "NO16;RGB;;Theory None16 64bit uncompressed Uncompressed;;;;RGB\n"
+ "NT00;YUV;LightWave;NewTek LightWave HDTV YUV with Alpha-channel;;;;YUV\n"
+ "NTN1;NogaTech Video 1;;Nogatech Video Compression 1;;;;\n"
+ "NTN2;NogaTech Video 2;;Nogatech Video Compression 2 (GrabBee hardware coder);;;;\n"
+ "NUV1;Nuppel;;NuppelVideo;;;;\n"
+ "NV12;YUV;;8-bit Y plane followed by an interleaved U/V plane with 2x2 subsampling;;;;YUV\n"
+ "NV21;YUV;;As NV12 with U and V reversed in the interleaved plane;;;;YUV\n"
+ "NVDS;Nvidia Texture;;Nvidia Texture Format;;;;\n"
+ "NVHS;Nvidia Texture;;Nvidia Texture Format (GeForce 3);;;;\n"
+ "NVHU;Nvidia Texture;;Nvidia Texture Format;;;;\n"
+ "NVS0;Nvidia Texture;;Nvidia Texture Compression Format;;;;\n"
+ "NVS1;Nvidia Texture;;Nvidia Texture Compression Format;;;;\n"
+ "NVS2;Nvidia Texture;;Nvidia Texture Compression Format;;;;\n"
+ "NVS3;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVS4;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVS5;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVS6;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVS7;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVS8;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVS9;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVT0;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVT1;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVT2;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVT3;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVT4;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVT5;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVT6;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVT7;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVT8;Nvidia Texture;;Nvidia Texture Compression Format\n"
+ "NVT9;Nvidia Texture;;Nvidia Texture Compression Format;;;;\n"
+ "NY12;YUV;Nogatech;;;;;YUV\n"
+ "NYUV;YUV;Nogatech;;;;;YUV\n"
+ "ONYX;VP7;On2;;http://www.on2.com/vp7.php3;;;\n"
+ "PCLE;Studio400;Pinnacle;;;;;\n"
+ "PDVC;DV;Panasonic;;;;;YUV\n"
+ "PGVV;Radius Video Vision;;;;;;\n"
+ "PHMO;Photomotion;IBM;;;;;\n"
+ "PIM1;JPEG;Pegasus;Pinnacle DC1000 hardware (MPEG compression);http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.Lossless.JPEG.codec.v2.10.27.exe;;;YUV\n"
+ "PIM2;JPEG;Pegasus;Pegasus Imaging;http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.Lossless.JPEG.codec.v2.10.27.exe;;;YUV\n"
+ "PIMJ;JPEG;Pegasus;Pegasus Imaging PICvideo Lossless JPEG;http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.Lossless.JPEG.codec.v2.10.27.exe;;;YUV\n"
+ "PIXL;JPEG;Miro;MiroVideo XL (JPEG);;;;YUV\n"
+ "PNG;PNG;;;;;;\n"
+ "PNG1;PNG;;Corecodec.org CorePNG;;;;\n"
+ "PVEZ;PowerEZ;;Horizons Technology PowerEZ;;;;\n"
+ "PVMM;MPEG-4 Visual;Pegasus;PacketVideo Corporation MPEG-4;;;;YUV;4:2:0\n"
+ "PVW2;Wavelet;Pegasus;Pegasus Imaging Wavelet 2000;;;;\n"
+ "PVWV;Wavelet;Pegasus;Pegasus Imaging Wavelet 2000;;;;\n"
+ "PXLT;Pixlet;;Apple Pixlet (Wavelet);;;;\n"
+ "Q1.0;QPEG 1.0;;Q-Team QPEG 1.0;http://www.q-team.de;;;\n"
+ "Q1.1;QPEG 1.1;;Q-Team QPEG 1.1;http://www.q-team.de;;;\n"
+ "QDGX;Apple GX;;Apple QuickDUncompressed GX;;;;\n"
+ "QDRW;Palettized Video;;Apple;;;;\n"
+ "QPEG;QPEG 1.1;;Q-Team QPEG 1.1;;;;\n"
+ "QPEQ;QPEG 1.1;;Q-Team QPEG 1.1;;;;\n"
+ "R210;YUV;;BlackMagic YUV (Quick Time);;;;YUV\n"
+ "R411;DV;Radius;Radius DV NTSC YUV;;;;YUV\n"
+ "R420;DV;Radius;Radius DV PAL YUV;;;;YUV\n"
+ "RAV_;MPEG-1;GroupTron;GroupTRON ReferenceAVI (dummy for MPEG compressor);;;;YUV;4:2:0\n"
+ "RAVI;MPEG-1;GroupTron;GroupTRON ReferenceAVI (dummy for MPEG compressor);;;;YUV;4:2:0\n"
+ "RAW ;RGB;;Full Frames (Uncompressed);;;;RGB\n"
+ "raw ;RGB;;Full Frames (Uncompressed);http://www.apple.com/quicktime/download/standalone.html;;;RGB\n"
+ "RGB ;RGB;;;;;;RGB;8:8:8\n"
+ "RGB1;RGB;;;;;;RGB 3:3:2;3:3:2\n"
+ "RGB2;RGB;;;;;;RGB 3:3:2;3:3:2\n"
+ "RGBA;RGB;;;http://www.fourcc.org/indexrgb.htm;;;RGB\n"
+ "RGBO;RGB;;Little Endian;;;;RGB 5:5:5;5:5:5\n"
+ "RGBP;RGB;;Little Endian;;;;RGB 5:6:5;5:6:5\n"
+ "RGBQ;RGB;;Big Endian;;;;RGB 5:5:5;5:5:5\n"
+ "RGBR;RGB;;Big Endian;;;;RGB 5:6:5;5:6:5\n"
+ "RGBT;RGBA;;;http://www.fourcc.org/indexrgb.htm;;;RGBA\n"
+ "RIVA;Swizzled texture;;Nvidia;;;;\n"
+ "RL4;RLE;;RLE 4bpp RGB;;;;RGB\n"
+ "RL8;RLE;;RLE 8bpp RGB;;;;RGB\n"
+ "RLE ;RLE;;RLE RGB with arbitrary sample packing within a pixel;http://www.fourcc.org/indexrgb.htm;;;RGB\n"
+ "RLE4;RLE;;RLE 4bpp RGB;http://www.fourcc.org/indexrgb.htm;;;RGB\n"
+ "RLE8;RLE;;RLE 8bpp RGB;http://www.fourcc.org/indexrgb.htm;;;RGB\n"
+ "RLND;Roland;;Roland Corporation;;;;\n"
+ "RMP4;MPEG-4 Visual;RealMagic;REALmagic MPEG-4 Video (Sigma Design, built on XviD);;;;YUV;4:2:0\n"
+ "ROQV;Id RoQ;;Id RoQ File Video Decoder;;;;\n"
+ "RT21;Intel Video 2.1;;Intel Real Time Video 2.1;;;;\n"
+ "RTV0;NewTek VideoToaster;;NewTek VideoToaster (dummy format - only AVI header);;;;\n"
+ "RUD0;Rududu;;Rududu video;;;;\n"
+ "RV10;RealVideo 1;;H263, RealVideo 5;http://www.real.com;;;\n"
+ "RV13;RealVideo 1;;H263, RealVideo 5;http://www.real.com;;;\n"
+ "RV20;RealVideo 2;;H263, RealVideo 6;http://www.real.com;;;\n"
+ "RV30;RealVideo 3;;Between H263 and H264, RealVideo 8;http://www.real.com;;;\n"
+ "RV40;RealVideo 4;;H264, RealVideo 9;http://www.real.com;;;\n"
+ "RVX ;RDX;;Intel RDX;;;;\n"
+ "S263;H.263;;;http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "S422;YUV;VideoCap C210;VideoCap C210;;;;YUV\n"
+ "SAN3;MPEG-4 Visual;;Direct copy of DivX 3.11;;;;YUV;4:2:0\n"
+ "SANM;Smush v2;;LucasArts;http://www.lucasarts.com/;;;\n"
+ "SCCD;SoftCam;;;;;;\n"
+ "SDCC;DV;Sun;Sun Digital Camera;;;;YUV;4:1:1\n"
+ "SEDG;MPEG-4 Visual;Samsung;Samsung MPEG-4;;;;YUV;4:2:0\n"
+ "SEG4;Cinepak;;;http://www.sega.com/;;;\n"
+ "SEGA;Cinepak;;;http://www.sega.com/;;;\n"
+ "SFMC;CrystalNet;;CrystalNet Surface Fitting Method;;;;\n"
+ "SHR0;BitJazz SheerVideo;;BitJazz SheerVideo (realtime lossless);;;;\n"
+ "SHR1;BitJazz SheerVideo;;BitJazz SheerVideo (realtime lossless);;;;\n"
+ "SHR2;BitJazz SheerVideo;;BitJazz SheerVideo (realtime lossless);;;;\n"
+ "SHR3;BitJazz SheerVideo;;BitJazz SheerVideo (realtime lossless);;;;\n"
+ "SHR4;BitJazz SheerVideo;;BitJazz SheerVideo (realtime lossless);;;;\n"
+ "SHR5;BitJazz SheerVideo;;BitJazz SheerVideo (realtime lossless);;;;\n"
+ "SHR6;BitJazz SheerVideo;;BitJazz SheerVideo (realtime lossless);;;;\n"
+ "SHR7;BitJazz SheerVideo;;BitJazz SheerVideo (realtime lossless);;;;\n"
+ "SIF1;SIF1;;;http://mysif.ru/SIF1_dd_Eng.htm;;;\n"
+ "SJPG;JPEG;CuSeeMe;CuSeeMe;http://mirror01.iptelecom.net.ua/~video/codecs/CUseeMe.JPEG.CODEC.v1.17.exe;;;YUV\n"
+ "SL25;DV;SoftLab DVCPro;SoftLab-NSK DVCPRO;;;;YUV;4:1:1\n"
+ "SL50;DV;SoftLab DVCPro5;SoftLab-NSK ;;;;YUV;4:1:1\n"
+ "SLDV;DV;SoftLab;SoftLab-NSK Forward DV Draw;;;;YUV;4:1:1\n"
+ "SLIF;MPEG Video;SoftLab;SoftLab-NSK MPEG-2 I-frames;;;;YUV;4:2:0\n"
+ "SLMJ;JPEG;SoftLab;SoftLab-NSK Forward JPEG;;;;YUV\n"
+ "smc ;SMC;;Apple Graphics (SMC);http://www.apple.com/quicktime/download/standalone.html;;;\n"
+ "SMSC;Radius;;;;;;\n"
+ "SMSD;Radius;;;;;;\n"
+ "SMSV;Wavelet Video;;WorldConnect Wavelet Streaming Video;;;;\n"
+ "SNOW;Snow;;;http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "SP40;YUV;SunPlus;SunPlus YUV;;;;YUV\n"
+ "SP44;MegaCam;;SunPlus Aiptek MegaCam;;;;\n"
+ "SP53;MegaCam;;SunPlus Aiptek MegaCam;;;;\n"
+ "SP54;MegaCam;;SunPlus Aiptek MegaCam;;;;\n"
+ "SP55;MegaCam;;SunPlus Aiptek MegaCam;;;;\n"
+ "SP56;MegaCam;;SunPlus Aiptek MegaCam;;;;\n"
+ "SP57;MegaCam;;SunPlus Aiptek MegaCam;;;;\n"
+ "SP58;MegaCam;;SunPlus Aiptek MegaCam;;;;\n"
+ "SP61;MegaCam;;SunPlus Aiptek MegaCam;;;;\n"
+ "SPIG;Spigot;;Radius Spigot;;;;\n"
+ "SPLC;ACM audio;;Splash Studios ACM Audio;;;;\n"
+ "SPRK;Spark;;;;;;\n"
+ "SQZ2;VXTreme 2;;Microsoft VXTreme Video V2;;;;\n"
+ "STVA;ST Imager;;ST Microelectronics CMOS Imager Data (Bayer);;;;\n"
+ "STVB;ST Imager;;ST Microelectronics CMOS Imager Data (Nudged Bayer);;;;\n"
+ "STVC;ST Imager;;ST Microelectronics CMOS Imager Data (Bunched);;;;\n"
+ "STVX;ST Imager;;ST Microelectronics CMOS Imager Data (Extended Data Format);;;;\n"
+ "STVY;ST Imager;;ST Microelectronics CMOS Imager Data (Extended Data Format with Correction Data);;;;\n"
+ "SV10;Sorenson;;Sorenson Media Video R1;;;;\n"
+ "SVQ1;AVC;Sorenson 1;Sorenson Media Video 1 (Apple QuickTime 3);;;;\n"
+ "SVQ2;AVC;Sorenson 2;Sorenson Media Video 2 (Apple QuickTime 4);;;;\n"
+ "SVQ3;AVC;Sorenson 3;Sorenson Media Video 3 (Apple QuickTime 5);;;;\n"
+ "SWC1;JPEG;MainConcept;MainConcept JPEG;;;;YUV\n"
+ "T420;YUV;Toshiba;Toshiba YUV 4:2:0;;;;YUV\n"
+ "TGA ;TGA;Apple;Apple TGA (with Alpha-channel)\n"
+ "THEO;Theora;;FFVFW Supported\n"
+ "TIFF;Apple TIFF;;Apple TIFF (with Alpha-channel)\n"
+ "TIM2;Pinnacle DVI;;Pinnacle RAL DVI\n"
+ "TLMS;TeraLogic;;TeraLogic Motion Intraframe\n"
+ "TLST;TeraLogic;;TeraLogic Motion Intraframe\n"
+ "TM10;Duck;;Duck TrueMotion\n"
+ "TM20;Duck 2;;Duck TrueMotion 2.0\n"
+ "TM2A;Duck Archiver 2;;Duck TrueMotion Archiver 2.0\n"
+ "TM2X;Duck 2;;Duck TrueMotion 2X\n"
+ "TMIC;TeraLogic;;TeraLogic Motion Intraframe\n"
+ "TMOT;Horizons TM S;;Horizons Technology TrueMotion Video\n"
+ "TR20;Duck TM RT2;;Duck TrueMotion RT 2.0\n"
+ "TRLE;Akula;;Akula Alpha Pro Custom AVI (LossLess)\n"
+ "TSCC;TechSmith;;TechSmith Screen Capture\n"
+ "tscc;TechSmith;;TechSmith Screen Capture\n"
+ "TV10;Tecomac;;Tecomac Low-Bit Rate;;;;\n"
+ "TVJP;Pinnacle/Truevision;;TrueVision Field Encoded JPEG (Targa emulation);;;;\n"
+ "TVMJ;Pinnacle/Truevision;;Truevision TARGA JPEG Hardware (or Targa emulation);;;;\n"
+ "TY0N;Trident;;Trident Decompression Driver;;;;\n"
+ "TY2C;Trident;;Trident Decompression Driver;;;;\n"
+ "TY2N;Trident;;Trident Decompression Driver;;;;\n"
+ "U<Y ;YUV;Discreet;Discreet UC YUV 4:2:2:4 10 bit;;;;YUV\n"
+ "U<YA;YUV;Discreet;Discreet UC YUV 4:2:2:4 10 bit (with Alpha-channel);;;;YUV\n"
+ "U263;H.263;UB;UB Video H.263/H.263+/H.263++ Decoder;http://eMajix.com;;;\n"
+ "UCOD;ClearVideo;;ClearVideo (fractal compression-based);;;;\n"
+ "ULRA;RGBA;Ut Video;Ut Video Lossless Codec;http://umezawa.dyndns.info/archive/utvideo;;;RGBA;4:4:4:4\n"
+ "ULRG;RGB;Ut Video;Ut Video Lossless Codec;http://umezawa.dyndns.info/archive/utvideo;;;RGB;4:4:4\n"
+ "ULTI;Ultimotion;;IBM Ultimotion;;;;\n"
+ "ULY0;YUV;Ut Video;Ut Video Lossless Codec;http://umezawa.dyndns.info/archive/utvideo;;;YUV;4:2:0\n"
+ "ULY2;YUV;Ut Video;Ut Video Lossless Codec;http://umezawa.dyndns.info/archive/utvideo;;;YUV;4:2:2\n"
+ "UMP4;MPEG-4 Visual;UB;UB Video MPEG 4;http://www.fourcc.org/indexyuv.htm;;;YUV;4:2:0\n"
+ "UYNV;YUV;;Nvidia 16bpp. A direct copy of UYVY registered by Nvidia to work around problems in some olds which did not like hardware which offered more than 2 UYVY surfaces.;http://www.fourcc.org/indexyuv.htm;;;YUV\n"
+ "UYVP;YUV;;Evans & Sutherland 24bpp. YUV 4:2:2 extended precision 10-bits per component in U0Y0V0Y1 order;;;;YUV\n"
+ "UYVU;YUV;SoftLab;SoftLab-NSK Forward YUV;http://www.fourcc.org/indexyuv.htm;;;YUV\n"
+ "UYVY;YUV;;Uncompressed 16bpp. YUV 4:2:2 (Y sample at every pixel, U and V sampled at every second pixel horizontally on each line). A macropixel contains 2 pixels in 1 u_int32.;;;;YUV;4:2:2\n"
+ "V210;YUV;;Optibase VideoPump 10-bit 4:2:2 Component YUV;;;;\n"
+ "v210;YUV;AJA Video Systems Xena;;;;;YUV;4:2:2\n"
+ "V261;VX3000S;;Lucent VX3000S;;;;\n"
+ "V422;YUV;Vitec;;;;;YUV;4:2:2\n"
+ "V655;YUV;Vitec;Vitec Multimedia 16 bit YUV 4:2:2 (6:5:5) format;;;;YUV\n"
+ "VBLE;MarcFD VBLE;;MarcFD VBLE Lossless;;;;\n"
+ "VCR1;ATI Video 1;;ATI VCR 1.0;;;;\n"
+ "VCR2;ATI Video 2;;ATI VCR 2.0 (MPEG YV12);;;;\n"
+ "VCR3;ATI Video 3;;ATI VCR 3.0;;;;\n"
+ "VCR4;ATI Video 4;;ATI VCR 4.0;;;;\n"
+ "VCR5;ATI Video 5;;ATI VCR 5.0;;;;\n"
+ "VCR6;ATI Video 6;;ATI VCR 6.0;;;;\n"
+ "VCR7;ATI Video 7;;ATI VCR 7.0;;;;\n"
+ "VCR8;ATI Video 8;;ATI VCR 8.0;;;;\n"
+ "VCR9;ATI Video 9;;ATI VCR 9.0;;;;\n"
+ "VCWV;Wavelet;;VideoCon;;;;\n"
+ "VDCT;RGB;VideoMaker;Video Maker Pro DIB;;;;RGB\n"
+ "VDOM;VDOWave;;VDONet Wave;;;;\n"
+ "VDOW;VDOLive;;VDONet Live (H,263);;;;\n"
+ "VDST;VirtualDub;;VirtualDub remote frameclient ICM driver;;;;\n"
+ "VDTZ;YUV;;VideoTizer / Darim Vision YUV;;;;YUV;4:2:2\n"
+ "VGPX;VGP;;Alaris VideoGramPixel;;;;\n"
+ "VIDM;MPEG-4 Visual;DivX 5 Pro;DivX 5.0 Pro Supported;;;;YUV;4:2:0\n"
+ "VIDS;Vitec;;Vitec Multimedia YUV 4:2:2;www.yks.ne.jp/~hori/;;;\n"
+ "VIFP;VFAPI;;Virtual Frame API (VFAPI dummy format);;;;\n"
+ "VIV1;H.263;Vivo;;;;;\n"
+ "VIV2;H.263;Vivo;;;;;\n"
+ "VIVO;H.263;Vivo;;;;;\n"
+ "VIXL;JPEG;Miro XL;Miro Video XL;http://mirror01.iptelecom.net.ua/~video/codecs/miroVIDEO-XL.codec.v2.2.exe;;;YUV\n"
+ "VJPG;JPEG;;;;;;YUV\n"
+ "VLV1;Videologic;;;;;;\n"
+ "VMNC;Vmware;;;http://www.vmware.com/;;;\n"
+ "VP30;VP3;On2;;;;;\n"
+ "VP31;VP3;On2;;;;;\n"
+ "VP32;VP3;On2;;;;;\n"
+ "VP40;VP4;On2;;;;;\n"
+ "VP50;VP5;On2;;;;;\n"
+ "VP60;VP6;On2;;http://ftp.pub.cri74.org/pub/win9x/video/codecs/VP6/vp6_vfw_codec.exe;Simple;;\n"
+ "VP61;VP6;On2;;http://ftp.pub.cri74.org/pub/win9x/video/codecs/VP6/vp6_vfw_codec.exe;Advanced;;\n"
+ "VP62;VP6;On2;;http://ftp.pub.cri74.org/pub/win9x/video/codecs/VP6/vp6_vfw_codec.exe;Heightened Sharpness;;\n"
+ "VP6A;VP6;On2;;http://ftp.pub.cri74.org/pub/win9x/video/codecs/VP6/vp6_vfw_codec.exe;Alpha;;\n"
+ "VP6F;VP6;On2;;http://ftp.pub.cri74.org/pub/win9x/video/codecs/VP6/vp6_vfw_codec.exe;Heightened Sharpness;;\n"
+ "VP70;VP7;On2;;;General;;\n"
+ "VP71;VP7;On2;;;Error Resilient;;\n"
+ "VP72;VP7;On2;;;;;\n"
+ "VP80;VP8;;;http://www.webmproject.org;;;YUV;4:2:0\n"
+ "VQC1;Vector 1;;Vector-quantised 1 (high compression) http://eprints.ecs.soton.ac.uk/archive/00001310/01/VTC97-js.pdf;;;;\n"
+ "VQC2;Vector 2;;Vector-quantised 2 (high robustness against channel errors) http://eprints.ecs.soton.ac.uk/archive/00001310/01/VTC97-js.pdf;;;;\n"
+ "VQJP;VQ630;;Dual-mode digital camera;;;;\n"
+ "VQS4;VQ110;;DV camera;;;;\n"
+ "VR21;YUV;BlckMagic;BlackMagic YUV (Quick Time);;;;YUV\n"
+ "VSSH;AVC;Vanguard VSS;;;;;YUV;4:2:0\n"
+ "VSSV;Vanguard Video;Vanguard VSS;;;;;\n"
+ "VSSW;AVC;Vanguard VSS;;;;;YUV;4:2:0\n"
+ "VTLP;GGP;;Alaris VideoGramPixel;;;;\n"
+ "VX1K;DVX 1 S;;Lucent VX1000S Video;;;;\n"
+ "VX2K;DVX 2 S;;Lucent VX2000S Video;;;;\n"
+ "VXSP;DVX 1 SP;;Lucent VX1000SP Video;;;;\n"
+ "VYU9;YUV;ATI;;;;;YUV\n"
+ "VYUY;YUV;ATI;;;;;YUV\n"
+ "WBVC;W9960;;Winbond Electronics W9960;;;;\n"
+ "WHAM;Microsoft Video 1;;;;;;\n"
+ "WINX;Winnov;;;;;;\n"
+ "WJPG;JPEG;Winbond ;Winbond JPEG (AverMedia USB devices);;;;YUV\n"
+ "WMV1;WMV1;;Windows Media Video 7;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx;;;\n"
+ "WMV2;WMV2;;Windows Media Video 8;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx;;;\n"
+ "WMV3;VC-1;WMV3;Windows Media Video 9;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx;;;\n"
+ "WMVA;VC-1;WMV;Windows Media Video;http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "WMVP;WMV3;;Windows Media Video V9;;;;\n"
+ "WNIX;WniWni;;WniWni;;;;\n"
+ "WNV1;WinNov;;WinNov Videum Hardware Compression;http://www.winnov.com/;;;\n"
+ "WNVA;WinNov;;WinNov Videum Hardware Compression;http://www.winnov.com/;;;\n"
+ "WRLE;RGB;Apple;Apple QuickTime BMP;;;;RGB\n"
+ "WRPR;AVideoTools;;VideoTools VideoServer Client (wrapper for AviSynth);;;;\n"
+ "WV1F;;;;http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "WVC1;VC-1;Microsoft;;;;;\n"
+ "WVLT;IllusionHope Wavelet 9/7;;IllusionHope Wavelet 9/7;;;;\n"
+ "WVP2;;;;http://ffdshow-tryout.sourceforge.net/;;;\n"
+ "WZCD;iScan;;CORE Co. Ltd.;;;;\n"
+ "WZDC;iSnap;;CORE Co. Ltd.;;;;\n"
+ "X263;H.263;Xirlink;;;;;\n"
+ "X264;AVC;;XiWave GNU GPL x264 MPEG-4;;;;\n"
+ "XJPG;JPEG;Xirlink;;;;;YUV\n"
+ "XLV0;NetXL Video;;NetXL Inc. XL Video Decoder;;;;\n"
+ "XMPG;MPEG Video;Xing;XING MPEG (I frame only);;;;YUV;4:2:0\n"
+ "XVID;MPEG-4 Visual;XviD;;http://mediaarea.net/XVID;;;YUV;4:2:0\n"
+ "XVIX;MPEG-4 Visual;XviD;Based on XviD MPEG-4;http://www.xvid.org/Downloads.15.0.html;;;YUV;4:2:0\n"
+ "XWV0;XiWave Video;;;;;;\n"
+ "XWV1;XiWave Video;;;;;;\n"
+ "XWV2;XiWave Video;;;;;;\n"
+ "XWV3;XiWave Video;;;;;;\n"
+ "XWV4;XiWave Video;;;;;;\n"
+ "XWV5;XiWave Video;;;;;;\n"
+ "XWV6;XiWave Video;;;;;;\n"
+ "XWV7;XiWave Video;;;;;;\n"
+ "XWV8;XiWave Video;;;;;;\n"
+ "XWV9;XiWave Video;;;;;;\n"
+ "XXAN;Origin VideoGame;;Used in Wing Commander 3 and 4;;;;\n"
+ "XYZP;YUV;;Extended PAL format XYZ palette;;;;YUV\n"
+ "Y211;YUV;;Packed YUV format with Y sampled at every second pixel across each line and U and V sampled at every fourth pixel;;;;YUV\n"
+ "Y216;YUV;Targa;Pinnacle TARGA CineWave YUV (Quick Time);;;;YUV\n"
+ "Y411;YUV;;YUV 4:1:1 Packed;;;;YUV;4:1:1\n"
+ "Y41B;YUV;;YUV 4:1:1 Planar;;;;YUV;4:1:1\n"
+ "Y41P;YUV;;Conexant (ex Brooktree) YUV 4:1:1 Raw;http://www.fourcc.org/indexyuv.htm;;;YUV;4:1:1\n"
+ "Y41T;YUV;;Format as for Y41P, but the lsb of each Y component is used to signal pixel transparency;;;;YUVA;4:1:1\n"
+ "Y422;YUV;;Direct copy of UYVY as used by ADS Technologies Pyro WebCam firewire camera;;;;YUV;4:2:2\n"
+ "Y42B;YUV;;YUV 4:2:2 Planar;;;;YUV;4:2:2\n"
+ "Y42T;YUV;;Format as for UYVY, but the lsb of each Y component is used to signal pixel transparency;;;;YUVA;4:2:2\n"
+ "Y444;YUV;;IYU2 (iRez Stealth Fire camera);;;;YUV\n"
+ "Y8 ;GrayScale;;Simple grayscale video;;;;Y\n"
+ "Y800;GrayScale;;Simple grayscale video;;;;Y\n"
+ "YC12;YUV;;Intel YUV12;http://www.fourcc.org/indexyuv.htm;;;YUV\n"
+ "YCCK;YUV;;;;;;YUV\n"
+ "YMPG;MPEG-PS;;YMPEG Alpha (dummy for MPEG-2 compressor);;;;\n"
+ "YU12;YUV;;ATI YV12 4:2:0 Planar;;;;YUV;4:2:0\n"
+ "YU92;YUV;;Intel - YUV;;;;YUV\n"
+ "YUNV;YUV;;A direct copy of YUY2 registered by Nvidia to work around problems in some olds which did not like hardware that offered more than 2 YUY2 surfaces;;;;YUV\n"
+ "YUV2;YUV;;Apple Component Video (YUV 4:2:2);http://www.apple.com/quicktime/download/standalone.html;;;YUV;\n"
+ "YUV8;YUV;;Winnov Caviar YUV8 ;http://www.fourcc.org/indexyuv.htm;;;YUV;\n"
+ "YUV9;YUV;;Intel YUV9;;;;YUV;\n"
+ "YUVP;YUV;;YUV 4:2:2 extended precision 10-bits per component in Y0U0Y1V0 order;;;;YUV;4:2:2;10\n"
+ "YUY2;YUV;;YUV 4:2:2 as for UYVY but with different component ordering within the u_int32 macropixel;http://www.fourcc.org/indexyuv.htm;;;YUV;4:2:2\n"
+ "YUYP;YUV;;Evans & Sutherland;;;;YUV;\n"
+ "YUYV;YUV;;Canopus YUV format;http://www.fourcc.org/indexyuv.htm;;;YUV;\n"
+ "YV12;YUV;;ATI YVU12 4:2:0 Planar;http://www.fourcc.org/indexyuv.htm;;;YUV;4:2:0\n"
+ "YV16;YUV;;Elecard YUV 4:2:2 Planar;;;;YUV;4:2:2\n"
+ "YV92;YUV;;Intel Smart Video Recorder YVU9;;;;YUV;\n"
+ "YVU9;YUV;;Brooktree YVU9 Raw (YVU9 Planar);http://www.fourcc.org/indexyuv.htm;;;YUV;\n"
+ "YVYU;YUV;;YUV 4:2:2 as for UYVY but with different component ordering within the u_int32 macropixel;;;;YUV;4:2:2\n"
+ "ZLIB;AVIzlib;;Lossless (ZIP compression);;;;;\n"
+ "ZMBV;Zip;;Zip Motion Blocks Video;;;;;\n"
+ "ZPEG;Video Zipper;;Metheus Video Zipper;;;;;\n"
+ "ZYGO;ZyGo;;ZyGo Video;;;;;\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_Audio_Matroska (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "A_MPEG/L1;MPEG Audio;MP1;;http://www.iis.fraunhofer.de/amm/index.html\n"
+ "A_MPEG/L2;MPEG Audio;MP2;;http://www.iis.fraunhofer.de/amm/index.html\n"
+ "A_MPEG/L3;MPEG Audio;MP3;;http://www.iis.fraunhofer.de/amm/index.html\n"
+ "A_PCM/INT/BIG;PCM;;\n"
+ "A_PCM/INT/LIT;PCM;;\n"
+ "A_PCM/FLOAT/IEEE;PCM;;\n"
+ "A_AC3;AC-3;;\n"
+ "A_AC3/BSID9;AC-3;;\n"
+ "A_AC3/BSID10;AC-3;;\n"
+ "A_DTS;DTS;;\n"
+ "A_EAC3;E-AC-3;;\n"
+ "A_FLAC;Flac;;;http://flac.sourceforge.net\n"
+ "A_TTA1;TTA;;The True Audio Lossless Codec;http://true-audio.com\n"
+ "A_VORBIS;Vorbis;;;http://www.vorbis.com\n"
+ "A_WAVPACK4;WavPack;;;http://www.wavpack.com\n"
+ "A_REAL/14_4;VSELP;;Real Audio 1 (14.4);http://www.real.com\n"
+ "A_REAL/28_8;G.728;;Real Audio 2 (28.8);http://www.real.com\n"
+ "A_REAL/COOK;Cooker;;Real Audio Cook Codec (codename: Gecko);http://www.real.com\n"
+ "A_REAL/SIPR;G.729;;Real & Sipro Voice Codec;http://www.real.com\n"
+ "A_REAL/RALF;RealAudio Lossless;;Real Audio Lossless Format;http://www.real.com\n"
+ "A_REAL/ATRC;Atrac;;Real & Sony Atrac3 Codec;http://www.real.com\n"
+ "A_TRUEHD;TrueHD;;;http://www.dolby.com/consumer/technology/trueHD.html\n"
+ "A_MLP;MLP;;Meridian Lossless Packing;http://www.meridian-audio.com\n"
+ "A_AAC;AAC;;\n"
+ "A_AAC/MPEG2/MAIN;AAC;;\n"
+ "A_AAC/MPEG2/LC;AAC;;\n"
+ "A_AAC/MPEG2/LC/SBR;AAC;;\n"
+ "A_AAC/MPEG2/SSR;AAC;;\n"
+ "A_AAC/MPEG4/MAIN;AAC;;\n"
+ "A_AAC/MPEG4/LC;AAC;;\n"
+ "A_AAC/MPEG4/LC/SBR;AAC;;\n"
+ "A_AAC/MPEG4/LC/SBR/PS;AAC;;\n"
+ "A_AAC/MPEG4/SSR;AAC\n"
+ "A_AAC/MPEG4/LTP;AAC\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_Audio_Mpeg4 (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ ".mp3;MPEG Audio;;;\n"
+ "A104;AMR;;;http://www.apple.com/quicktime/download/standalone.html;Wide band\n"
+ "ac-3;AC-3;;;\n"
+ "alac;ALAC;;Apple Lossless Format;http://www.apple.com/quicktime/download/standalone.html\n"
+ "alaw;ADPCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "dtsc;DTS;;Digital Theater Systems;http://www.dts.com\n"
+ "dtsh;DTS;HRA;Digital Theater Systems High Res;http://www.dts.com\n"
+ "dtsl;DTS;MA;Digital Theater Systems Master Audio;http://www.dts.com\n"
+ "dtse;DTS;Express;;Digital Theater Systems Low Bitrate;http://www.dts.com\n"
+ "dvca;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "ec-3;E-AC-3;;;\n"
+ "enca;(Encrypted);;;\n"
+ "fl32;PCM ; ;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "fl64;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "ima4;ADPCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "in24;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "in32;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "lpcm;PCM;;;\n"
+ "MAC3;MACE 3;;;\n"
+ "MAC6;MACE 6;;;\n"
+ "nmos;Nellymoser;;;http://www.nellymoser.com/\n"
+ "NONE;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "owma;WMA Pro;;Smooth Streaming Media Audio;http://alexzambelli.com/blog/2009/02/10/smooth-streaming-architecture/\n"
+ "Qclp;QCELP;;Qualcomm PureVoice;\n"
+ "QDM1;QDesign 1;;QDesign Music 1;http://www.apple.com/quicktime/download/standalone.html\n"
+ "QDM2;Qdesign 2;;QDesign Music 2;http://www.apple.com/quicktime/download/standalone.html\n"
+ "QDMC;Qdesign 2;(Old);QDesign Music 2 (old version, rare);http://www.apple.com/quicktime/download/standalone.html\n"
+ "raw ;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "sac3;AC-3;;Made by Nero;http://www.nerodigital.com\n"
+ "samr;AMR;;;http://www.apple.com/quicktime/download/standalone.html;Narrow band\n"
+ "sawb;AMR;;;http://www.apple.com/quicktime/download/standalone.html;Wide band\n"
+ "sevc;EVRC;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "sowt;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "twos;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "ulaw;ADPCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "vdva;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "WMA2;WMA;;Windows Media Audio;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx;;Version 2\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_Audio_Real (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "14.4;VSELP;;Real Player 1;http://www.real.com\n"
+ "14_4;VSELP;;Real Player 1;http://www.real.com\n"
+ "28.8;G.728;;Real Player 2;http://www.real.com\n"
+ "28_8;G.728;;Real Player 2;http://www.real.com\n"
+ "atrc;Atrac;;Real Player 8;http://www.real.com\n"
+ "audio/X-MP3-draft-00;MPEG Audio;;\n"
+ "audio/x-ralf-mpeg4;RealAudio Lossless;;Real Audio Lossless Format, Real Player 10;http://www.real.com;;;;;;Lossless\n"
+ "audio/x-ralf-mpeg4-generic;RealAudio Lossless;;Real Audio Lossless Format, Real Player 10;http://www.real.com;;;;;;Lossless\n"
+ "cook;Cooker;;Based on G.722.1, Real Player 6;http://www.real.com\n"
+ "dnet;AC-3;;Real Player 3;http://www.real.com\n"
+ "lpcJ;VSELP;;Real Player 1;http://www.real.com\n"
+ "raac;AAC;;Real Player 9;http://www.real.com;LC\n"
+ "racp;AAC;;Real Player 10;http://www.real.com;HE-AAC\n"
+ "rtrc;RealAudio 8;;;http://www.real.com\n"
+ "sipr;ACELP;;Real Player 4;http://www.real.com\n"
+ "whrl;RealAudio Multi-Channel;;Real Audio Multi-Channel;http://www.real.com\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_Audio_Riff (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "0;;;;\n"
+ "1;PCM;;;http://www.microsoft.com/windows/\n"
+ "2;ADPCM;;;http://www.microsoft.com/windows/\n"
+ "3;PCM;IEEE ;;http://www.microsoft.com/windows/;Float\n"
+ "4;VSELP;Compaq;;\n"
+ "5;CVSD;IBM;;\n"
+ "6;ADPCM;CCITT;;http://www.microsoft.com/windows/;A-Law\n"
+ "7;ADPCM;CCITT;;http://www.microsoft.com/windows/;U-Law\n"
+ "8;DTS;;Digital Theater Systems;\n"
+ "9;DRM;Microsoft;;\n"
+ "A;WMA;;Windows Media Audio;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx;Voice\n"
+ "C;MPEG Audio;;;;MPEG-2 5.1\n"
+ "10;ADPCM;OKI;;\n"
+ "11;ADPCM;Intel;;\n"
+ "12;ADPCM;Mediaspace;;\n"
+ "13;ADPCM;Sierra;;\n"
+ "14;ADPCM;Antex;G.723\n"
+ "15;STD;DSP solutions;\n"
+ "16;FIX;DSP solutions;\n"
+ "17;ADPCM;Dialogic-OKI;;http://www.microsoft.com/windows/\n"
+ "18;ADPCM;;\n"
+ "19;CU;HP;\n"
+ "1A;Dynamic Voice;HP;\n"
+ "20;ADPCM;Yamaha;\n"
+ "21;SONARC;Speech Compression;\n"
+ "22;Truespeech;DSP Group;;http://www.microsoft.com/windows/\n"
+ "23;SC1;Echo Speech;\n"
+ "24;AudioFile 36;Virtual Music ;\n"
+ "25;APTX;;Audio Processing Technology X\n"
+ "26;AudioFile 10;Virtual Music;\n"
+ "27;Prosody 1612;Aculab plc;\n"
+ "28;LRC;Merging Technologies;\n"
+ "30;AC-2;Dolby Laboratories;\n"
+ "31;GSM 6.10;Microsoft;;http://www.microsoft.com/windows/\n"
+ "32;Microsoft Audio;;\n"
+ "33;ADPCM;Antex;\n"
+ "34;VQLPC;Control Resources;\n"
+ "35;REAL;DSP Solutions;\n"
+ "36;ADPCM;DSP Solutions;\n"
+ "37;CR10;;Control Resources 10\n"
+ "38;ADPCM;Natural MicroSystems VBX;\n"
+ "39;ADPCM;Crystal Semiconductor IMA;\n"
+ "3A;SC3;Echo Speech;\n"
+ "3B;ADPCM;Rockwell;\n"
+ "3C;DigiTalk;Rockwell DigiTalk;\n"
+ "3D;Xebec;;Xebec Multimedia Solutions\n"
+ "40;ADPCM;Antex Electronics;G.721\n"
+ "41;CELP;Antex Electronics;G.728\n"
+ "42;G.723.1;Microsoft;;http://www.microsoft.com/windows/;\n"
+ "42;ADPCM;;IBM;;\n"
+ "42;G.729;Microsoft;;;\n"
+ "45;ADPCM;Microsoft;G.726;http://www.microsoft.com/windows/;\n"
+ "50;MPEG Audio;;;http://www.iis.fraunhofer.de/amm/index.html;;Version 1\n"
+ "51;MPEG Audio;;;http://www.iis.fraunhofer.de/amm/index.html;;Version 2\n"
+ "52;RT24;InSoft, Inc.;;;\n"
+ "53;PAC;InSoft, Inc.;;;\n"
+ "55;MPEG Audio;MP3;;http://www.iis.fraunhofer.de/amm/index.html;\n"
+ "59;G.723;Lucent;G.723;;\n"
+ "60;Cirrus;;Cirrus Logic;;\n"
+ "61;PCM;ESS Technology;;;\n"
+ "62;Voxware;;;;\n"
+ "63;Atrac;Canopus;;;\n"
+ "64;ADPCM;APICOM;G.726;;\n"
+ "65;ADPCM;APICOM;G.722;;\n"
+ "66;DSAT;Microsoft;\n"
+ "67;DSAT Display;Microsoft;\n"
+ "69;BYTE_ALIGNED;Voxware;;http://www.voxware.com/\n"
+ "70;AC8;Voxware;;http://www.voxware.com/\n"
+ "71;AC10;Voxware;;http://www.voxware.com/\n"
+ "72;AC16;Voxware;;http://www.voxware.com/\n"
+ "73;AC20;Voxware;;http://www.voxware.com/\n"
+ "74;RT24;Voxware;MetaVoice;http://www.voxware.com/\n"
+ "75;RT29;Voxware;MetaSound;http://www.voxware.com/\n"
+ "76;RT29HW;Voxware;;http://www.voxware.com/\n"
+ "77;VR12;Voxware;;http://www.voxware.com/\n"
+ "78;VR18;Voxware;;http://www.voxware.com/\n"
+ "79;TQ40;Voxware;;http://www.voxware.com/\n"
+ "7A;SC3;Voxware;\n"
+ "7B;SC3;Voxware;\n"
+ "80;Softsound;;\n"
+ "81;TQ60;Voxware;;http://www.voxware.com/\n"
+ "82;MSRT24;Microsoft;\n"
+ "83;G.729a;AT&T;\n"
+ "84;MVI_MVI2;Motion Pixels;\n"
+ "85;ADPCM;DataFusion Systems;G.726\n"
+ "86;GSM 6.10;DataFusion Systems;\n"
+ "88;ISI AUDIO;;Iterated Systems AUDIO\n"
+ "89;Onlive;;OnLive! Technologies\n"
+ "8A;SX20;Multitude;\n"
+ "8B;ADPCM;Infocom ITS A/S;\n"
+ "8C;G.729;Convedia Corporation;\n"
+ "91;SBC24;;Siemens Business Communications Sys 24\n"
+ "92;AC-3;Sonic Foundry;\n"
+ "93;G.723;MediaSonic;\n"
+ "94;Prosody 8KBPS;Aculab plc;\n"
+ "97;ADPCM;ZyXEL Communications;\n"
+ "98;LPCBB;Philips Speech Processing;;\n"
+ "99;Packed;;Studer Professional Audio AG Packed;\n"
+ "A0;PHONYTALK;Malden Electronics;;\n"
+ "A1;GSM;Racal Recorders;;\n"
+ "A2;G.720a;Racal Recorders;;\n"
+ "A3;G.723.1;Racal Recorders;;\n"
+ "A4;ACELP;Racal Recorders;;\n"
+ "B0;AAC;NEC Corporation;;\n"
+ "FF;AAC;;;\n"
+ "100;ADPCM;;;\n"
+ "101;IRAT;BeCubed;;\n"
+ "102;ADPCM;IBM;;;A-law\n"
+ "103;ADPCM;IBM AVC;;\n"
+ "111;G.723;Vivo;;\n"
+ "112;SIREN;Vivo;;\n"
+ "120;CELP;Philips Speech Processing;;\n"
+ "121;Grundig;Philips Speech Processing;;\n"
+ "123;G.723;Digital Equipment Corporation;;\n"
+ "125;ADPCM;;;\n"
+ "130;ACELP;Sipro;;http://dividix.host.sk;.net\n"
+ "131;ACELP;Sipro;;;4800\n"
+ "132;ACELP;Sipro;;;8V3\n"
+ "133;G.729;Sipro;;\n"
+ "134;G.729a;Sipro;;\n"
+ "135;KELVIN;Sipro;;\n"
+ "135;AMR;VoiceAge Corporation;;\n"
+ "140;ADPCM;Dictaphone Corporation;G.726;\n"
+ "140;CELP68;Dictaphone Corporation;;\n"
+ "140;CELP54;Dictaphone Corporation;;\n"
+ "150;PureVoice;Qualcomm;;\n"
+ "151;HalfRate;Qualcomm;;\n"
+ "155;TUBGSM;Ring Zero Systems;;\n"
+ "160;WMA;;Windows Media Audio;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx;;Version 1\n"
+ "161;WMA;;Windows Media Audio;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx;;Version 2\n"
+ "162;WMA;;Windows Media Audio;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx;Pro\n"
+ "163;WMA;;Windows Media Audio;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx;Lossless\n"
+ "170;ADPCM;Unisys Nap;;;\n"
+ "171;ADPCM;Unisys Nap;;;U-law\n"
+ "172;ADPCM;Unisys Nap;;;A-law\n"
+ "173;16K;Unisys Nap;;;\n"
+ "174;G.700;SyCom Technologies;;;\n"
+ "175;ADPCM;SyCom Technologies;;;\n"
+ "176;CELP54;SyCom Technologies;;;\n"
+ "177;CELP68;SyCom Technologies;;;\n"
+ "178;ADPCM;Knowledge Adventure, Inc.;;;\n"
+ "180;AAC;Fraunhofer IIS;;;\n"
+ "190;DTS;;Digital Theater Systems;;\n"
+ "200;ADPCM;Creative Labs;;;\n"
+ "202;Fast Speech 8;Creative Labs\n"
+ "203;Fast Speech 10;Creative Labs\n"
+ "210;ADPCM;UHER informatic GmbH\n"
+ "215;ACM;Ulead\n"
+ "216;ACM;Ulead\n"
+ "220;QuaterDeck;\n"
+ "230;VC;;I-link VC\n"
+ "240;RAW_SPORT;;Aureal\n"
+ "241;AC-3;ESST\n"
+ "250;HSX;Interactive Products, Inc.\n"
+ "251;RPELP;Interactive Products, Inc.\n"
+ "260;CS2;Consistent Software\n"
+ "270;Atrac3;Sony\n"
+ "271;SCY;Sony\n"
+ "272;Atrac3;Sony\n"
+ "273;SPC;Sony\n"
+ "280;Telum;;\n"
+ "281;TelumIA;;\n"
+ "285;ADPCM;Norcom Voice Systems;\n"
+ "300;FM_TOWNS_SND;Fujitsu;\n"
+ "350;Dev;Micronas Semiconductors, Inc.;\n"
+ "351;CELP833;Micronas Semiconductors, Inc.;\n"
+ "400;DIGITAL;Brooktree;\n"
+ "401;Music Coder;Intel;;http://www.intel.com/\n"
+ "402;IAC2;Ligos;;http://www.ligos.com\n"
+ "450;Qdesign;;QDesign Music\n"
+ "500;VP7;;On2\n"
+ "501;VP6;;On2\n"
+ "680;VM;;AT&T VME_VMPCM\n"
+ "681;TPC;;AT&T TPC\n"
+ "700;YMPEG;;YMPEG Alpha\n"
+ "8AE;LiteWave;;ClearJump LiteWave\n"
+ "AAC;AAC;;;\n"
+ "1000;GSM;Ing C. Olivetti & C., S.p.A.;;\n"
+ "1001;ADPCM;Ing C. Olivetti & C., S.p.A.;;\n"
+ "1002;CELP;Ing C. Olivetti & C., S.p.A.;;\n"
+ "1003;SBC;Ing C. Olivetti & C., S.p.A.;;\n"
+ "1004;OPR;Ing C. Olivetti & C., S.p.A.;;\n"
+ "1100;LH_CODEC;Lernout & Hauspie; Codec;\n"
+ "1101;CELP;Lernout & Hauspie;;http://www.microsoft.com/windows/;4.8 kb/s\n"
+ "1102;SBC;Lernout & Hauspie;;http://www.microsoft.com/windows/;8 kb/s\n"
+ "1103;SBC;Lernout & Hauspie;;http://www.microsoft.com/windows/;12 kb/s\n"
+ "1104;SBC;Lernout & Hauspie;;http://www.microsoft.com/windows/;16 kb/s\n"
+ "1400;Norris;;Norris Communications, Inc.;\n"
+ "1401;ISIAudio;;;\n"
+ "1500;MUSICOMPRESS;;Soundspace Music Compression;\n"
+ "181C;RT24;VoxWare;;\n"
+ "181E;AX24000P;Lucent elemedia;;\n"
+ "1971;SonicFoundry;;Lossless\n"
+ "1C03;ADPCM;Lucent;G.723\n"
+ "1C07;SX8300P;Lucent\n"
+ "1C0C;ADPCM;Lucent;G.723\n"
+ "1F03;DigiTalk;;CUseeMe (ex-Rocwell)\n"
+ "1FC4;ALF2CD;NCT Soft\n"
+ "2000;AC-3;\n"
+ "2001;DTS;;Digital Theater Systems\n"
+ "2002;VSELP;;RealAudio 1/2 14.4\n"
+ "2003;VSELP;;RealAudio 1/2 28.8\n"
+ "2004;Cooker;;RealAudio G2/8 Cook (low bitrate)\n"
+ "2005;DNET;;RealAudio 3/4/5 Music (DNET)\n"
+ "2006;AAC;;RealAudio 10 AAC (RAAC)\n"
+ "2007;AAC;;RealAudio 10 AAC+ (RACP)\n"
+ "2048;Sonic;\n"
+ "3313;AviSynth;;makeAVIS (fake AVI sound from AviSynth scripts)\n"
+ "4143;AAC;;Divio MPEG-4 AAC audio;;\n"
+ "4201;Nokia;;;;\n"
+ "4243;ADPCM;;G.726;;\n"
+ "43AC;Speex;;;;\n"
+ "564C;Vorbis;;;;\n"
+ "566F;Vorbis;;;http://www.vorbis.com;\n"
+ "5756;WavPack;;;http://www.wavpack.com/;\n"
+ "674F;Vorbis;;;http://www.vorbis.com;;Mode 1\n"
+ "6750;Vorbis;;;http://www.vorbis.com;;Mode 2\n"
+ "6751;Vorbis;;;http://www.vorbis.com;;Mode 3\n"
+ "676F;Vorbis;;;http://www.vorbis.com;;Mode 1+\n"
+ "6770;Vorbis;;;http://www.vorbis.com;;Mode 2+\n"
+ "6771;Vorbis;;;http://www.vorbis.com;;Mode 3+\n"
+ "8180;AAC\n"
+ "7A21;AMR;;GSM-AMR (CBR, no SID);http://www.microsoft.com;\n"
+ "7A22;AMR;;GSM-AMR (VBR, including SID);http://www.microsoft.com;\n"
+ "A100;G.723.1;;;;\n"
+ "A101;AVQSBC;;\n"
+ "A102;ODSBC;;\n"
+ "A103;G729A;;\n"
+ "A104;AMR;;\n"
+ "A105;ADPCM;;G.726\n"
+ "A106;AAC;;\n"
+ "A107;ADPCM;;G.726\n"
+ "A109;Speex;;;http://www.speex.org/\n"
+ "DFAC;FrameServer;;DebugMode SonicFoundry Vegas FrameServer ACM Codec\n"
+ "F1AC;FLAC;;Free Lossless Audio Codec\n"
+ "FFFE;Extensible;;\n"
+ "FFFF;In Development;;\n"
+ "58CB7144-23E9-BFAA-A119-FFFA01E4CE62;Atrac3;;\n"
+ "AD98D184-AAC3-11D0-A41C-00A0C9223196;VC;;\n"
+ "05589F81-C356-11CE-BF01-00AA0055595A;WaveFormatEx;;\n"
+ "518590A2-A184-11D0-8522-00C04FD9BAF3;DSound;;\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_Text_Matroska (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "S_ASS;ASS;;Advanced Sub Station Alpha\n"
+ "S_IMAGE/BMP;Bitmap;;Basic image based subtitle format\n"
+ "S_SSA;SSA;;Sub Station Alpha\n"
+ "S_TEXT/ASS;ASS;;Advanced Sub Station Alpha\n"
+ "S_TEXT/SSA;SSA;;Sub Station Alpha\n"
+ "S_TEXT/USF;USF;;Universal Subtitle Format\n"
+ "S_TEXT/UTF8;UTF-8;;UTF-8 Plain Text\n"
+ "S_USF;USF;;Universal Subtitle Format\n"
+ "S_UTF8;UTF-8;;UTF-8 Plain Text\n"
+ "S_VOBSUB;VobSub;;The same subtitle format used on DVDs\n"
+ "S_HDMV/PGS;PGS;;The same subtitle format used on BDs/HD-DVDs\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_Text_Mpeg4 (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "c608;EIA-608\n"
+ "c708;EIA-708\n"
+ "subp;VobSub;;The same subtitle format used on DVDs\n"
+ "text;Apple text;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "sbtl;Apple text;(iPhone);;http://www.apple.com/quicktime/download/standalone.html\n"
+ "tx3g;Timed text;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "enct;(Encrypted);;\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_CodecID_Text_Riff (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "DXSB;DivX Subtitle;;Subtitle in AVI from DivX networks;http://www.divx.com\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Codec (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ " BIT;RGB;4CC;V;RGB;;Uncompressed\n"
+ " JPG;JPEG;4CC;V;JPEG;;\n"
+ " PNG;PNG;4CC;V;RGB;;\n"
+ " RAW;RGB;4CC;V;RGB;;Uncompressed;http://www.fourcc.org/indexrgb.htm\n"
+ " RGB;RGB;4CC;V;RGB;;Uncompressed. Basic Windows bitmap format. 1, 4 and 8 bpp versions are palettised. 16, 24 and 32bpp contain Uncompressed RGB samples.;http://www.fourcc.org/indexrgb.htm\n"
+ " RL4;RGB;4CC;V;RGB;;RLE 4bpp;http://www.fourcc.org/indexrgb.htm\n"
+ " RL8;RGB;4CC;V;RGB;;RLE 8bpp;http://www.fourcc.org/indexrgb.htm\n"
+ "1978;RGB;4CC;V;JPEG;;A.M.Paredes predictor;http://www.pegasusimaging.com/cgi-bin/download2.cgi?LVIDB\n"
+ "2VUY;YUV;4CC;V;YUV;;Optibase VideoPump 8-bit 4:2:2 Component YCbCr\n"
+ "3IV0;3ivX;4CC;V;MPEG-4V;;3ivX pre-1.0;http://www.3ivx.com/download/\n"
+ "3IV1;3ivX;4CC;V;MPEG-4V;;3ivX 1.0-3.5;http://www.3ivx.com/download/\n"
+ "3IV2;3ivX;4CC;V;MPEG-4V;;3ivX 4.0;http://www.3ivx.com/download/\n"
+ "3IVD;3ivX;4CC;V;MPEG-4V;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "3IVX;3ivX;4CC;V;MPEG-4V;;;http://www.3ivx.com/download/\n"
+ "3VID;3ivX;4CC;V;MPEG-4V;;;http://www.3ivx.com/download/\n"
+ "8BPS;QuickTime 8bps;4CC;V;RGB;;Apple QuickTime Planar RGB with Alpha-channel;http://ffdshow-tryout.sourceforge.net/\n"
+ "AAS4;Autodesk;4CC;V;RGB;;Autodesk Animator Studio RLE (warning: this is a discoutinued product);http://mirror01.iptelecom.net.ua/~video/codecs/Autodesk.Animator.v1.11.Codec.exe\n"
+ "AASC;Autodesk;4CC;V;RGB;;Autodesk Animator Studio RLE (warning: this is a discoutinued product);http://mirror01.iptelecom.net.ua/~video/codecs/Autodesk.Animator.v1.11.Codec.exe\n"
+ "ABYR;Kensigton low;4CC;V;;;Kensington (low resolution, low frame rate (6fps) for digital cameras)\n"
+ "ACTL;ACT-L2;4CC;V;;;Streambox ACT-L2;http://www.streambox.com/products/act-L2_codec.htm\n"
+ "ADV1;WaveCodec;4CC;V;Wavelet;;Loronix WaveCodec;http://www.loronix.com/products/video_clips/wavecodec.asp\n"
+ "ADVJ;Avid;4CC;V;JPEG;;Avid JPEG. Aka AVRn\n"
+ "AEIK;Indeo 3.2;4CC;V;;;Intel Indeo Video 3.2 (Vector Quantization)\n"
+ "AEMI;VideoONE;4CC;V;MPEG-V;;Array VideoONE MPEG-1-I Capture. Array's used for I frame only MPEG-1 AVI files;http://www.array.com\n"
+ "AFLC;Autodesk;4CC;V;;;Autodesk Animator Studio FLI (256 color) (warning: this is a discoutinued product);http://mirror01.iptelecom.net.ua/~video/codecs/Autodesk.Animator.v1.11.Codec.exe\n"
+ "AFLI;Autodesk;4CC;V;;;Autodesk Animator Studio FLI (256 color) (warning: this is a discoutinued product);http://mirror01.iptelecom.net.ua/~video/codecs/Autodesk.Animator.v1.11.Codec.exe\n"
+ "AHDV;CineForm;4CC;V;Wavelet;;CineForm 10-bit Visually Perfect HD (Wavelet);http://www.cineform.com/products/ConnectHD.htm\n"
+ "AJPG;JPEG;4CC;V;JPEG;;22fps JPEG-based for digital cameras\n"
+ "ALPH;Ziracom;4CC;V;;;Ziracom Digital Communications Inc.\n"
+ "AMPG;VideoONE;4CC;V;MPEG-1;;Array VideoONE MPEG;http://www.array.com\n"
+ "AMR ;AMR;4CC;V;;;Speech codec\n"
+ "ANIM;RDX;4CC;V;;;Intel RDX\n"
+ "AP41;AngelPotion;4CC;V;MPEG-4V;;AngelPotion Definitive 1 (hack of MS MPEG-4 v3);http://www.divxity.com/download/ap4v1-702.exe\n"
+ "AP42;AngelPotion;4CC;V;MPEG-4V;;AngelPotion Definitive 2 (hack of MS MPEG-4 v3);http://www.divxity.com/download/ap4v1-702.exe\n"
+ "ASLC;AlparySoft Lossless;4CC;V;;;AlparySoft Lossless;http://www.free-codecs.com/download/Alparysoft_Lossless_Video_Codec.htm\n"
+ "ASV1;Asus 1;4CC;V;;;Asus Video 1;ftp://ftp.asuscom.de/pub/asuscom/treiber/vga/ASUS_VGA_TOOLS/asv2dec.zip\n"
+ "ASV2;Asus 2;4CC;V;;;Asus Video 2;ftp://ftp.asuscom.de/pub/asuscom/treiber/vga/ASUS_VGA_TOOLS/asv2dec.zip\n"
+ "ASVX;Asus X;4CC;V;;;Asus Video X;ftp://ftp.asuscom.de/pub/asuscom/treiber/vga/ASUS_VGA_TOOLS/asv2dec.zip\n"
+ "ATM4;Nero MPEG-4;4CC;V;MPEG-4V;;Ahead Nero Digital MPEG-4;http://www.nero.com\n"
+ "AUR2;YUV;4CC;V;YUV;;Auravision Aura 2 - YUV 422\n"
+ "AURA;YUV;4CC;V;YUV;;Auravision Aura 1 - YUV 411\n"
+ "AUVX;AUVX;4CC;V;;;USH GmbH\n"
+ "AV1X;Avid 1:1;4CC;V;;;Avid 1:1x (Quick Time);http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe\n"
+ "AVC1;AVC;4CC;V;AVC;;Advanced Video Codec;http://ffdshow-tryout.sourceforge.net/\n"
+ "AVD1;Avid DV;4CC;V;DV;;Avid DV (Quick Time);http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe\n"
+ "AVDJ;Avid JFIF;4CC;V;JPEG;;Avid Meridien JFIF with Alpha-channel;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe\n"
+ "AVDN;Avid HD;4CC;V;;;Avid DNxHD (Quick Time);http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe\n"
+ "AVDV;Avid DV;4CC;V;DV;;Avid DV;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe\n"
+ "AVI1;MainConcept;4CC;V;JPEG;;MainConcept JPEG\n"
+ "AVI2;MainConcept;4CC;V;JPEG;;MainConcept JPEG\n"
+ "AVID;Avid JPEG;4CC;V;JPEG;;Avid JPEG;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe\n"
+ "AVIS;AviSynth;4CC;V;;;Wrapper for AviSynth (Dummy);http://ffdshow-tryout.sourceforge.net/\n"
+ "AVMP;Avid IMX;4CC;V;;;Avid IMX (Quick Time);http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe\n"
+ "AVR ;Avid NuVista;4CC;V;JPEG;;Avid ABVB/NuVista JPEG with Alpha-channel\n"
+ "AVRn;Avid JPEG;4CC;V;JPEG;;Avid JPEG;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe\n"
+ "AVRN;Avid JPEG;4CC;V;JPEG;;Avid JPEG;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe\n"
+ "AVUI;Avid;4CC;V;;;Avid Meridien Uncompressed with Alpha-channel;http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe\n"
+ "AVUP;Avid;4CC;V;;;Avid 10bit Packed (Quick Time);http://mirror01.iptelecom.net.ua/~video/codecs/Avid.VfW.codec.v2.0d2.exe\n"
+ "AYUV;YUV;4CC;V;YUV;;4:4:4 YUV (AYUV)\n"
+ "AZPR;QuickTime;4CC;V;;;Quicktime Apple Video;http://www.apple.com/quicktime/download/standalone.html\n"
+ "AZRP;QuickTime;4CC;V;;;Quicktime Apple Video;http://www.apple.com/quicktime/download/standalone.html\n"
+ "BGR ;RGB;4CC;V;RGB;;Uncompressed RGB32\n"
+ "BHIV;BeHere iVideo;4CC;V;;;BeHere iVideo\n"
+ "BINK;Bink;4CC;V;;;RAD Game Tools Bink Video\n"
+ "BIT ;RGB;4CC;V;RGB;;Uncompressed. BI_BITFIELDS\n"
+ "BITM;H.261;4CC;V;;;Microsoft H.261\n"
+ "BLOX;Blox;4CC;V;;;Jan Jezabek BLOX MPEG;http://www.ii.uj.edu.pl/~jezabek/blox/blox-0.1.0b.zip\n"
+ "BLZ0;DivX;4CC;V;MPEG-4V;;DivX for Blizzard Decoder Filter;http://ffdshow-tryout.sourceforge.net/\n"
+ "BT20;MediaStream;4CC;V;;;Conexant ProSummer MediaStream\n"
+ "BTCV;Composite;4CC;V;;;Conexant Composite Video\n"
+ "BTVC;Composite;4CC;V;;;Conexant Composite Video\n"
+ "BW00;BergWave;4CC;V;Wavelet;;BergWave (Wavelet)\n"
+ "BW10;Broadway;4CC;V;MPEG-1;;Data Translation Broadway MPEG Capture/Compression\n"
+ "BXBG;Boxx RGB;4CC;V;;;BOXX BGR\n"
+ "BXRG;Boxx RGB;4CC;V;;;BOXX RGB\n"
+ "BXY2;Boxx YUV;4CC;V;;;BOXX 10-bit YUV\n"
+ "BXYV;Boxx YUV;4CC;V;;;BOXX YUV\n"
+ "CC12;Intel YUV;4CC;V;YUV;;Intel YUV12\n"
+ "CDV5;Canopus DV;4CC;V;DV;;Canopus SD50/DVHD;http://www.cineform.com/products/ConnectHD.htm\n"
+ "CDVC;Canopus DV;4CC;V;DV;;Canopus DV (DV);http://www.cineform.com/products/ConnectHD.htm\n"
+ "CDVH;Canopus DV;4CC;V;DV;;Canopus SD50/DVHD;http://www.cineform.com/products/ConnectHD.htm\n"
+ "CFCC;Perception;4CC;V;;;DPS Perception JPEG (dummy format - only AVI header)\n"
+ "CFHD;CineForm;4CC;V;;;CineForm 10-bit Visually Perfect HD (Wavelet)\n"
+ "CGDI;Camcorder;4CC;V;;;Camcorder Video (MS Office 97)\n"
+ "CHAM;Champagne;4CC;V;;;Winnov Caviara Champagne\n"
+ "CJPG;Creative JPEG;4CC;V;JPEG;;Creative Video Blaster Webcam Go JPEG\n"
+ "CLJR;YUV;4CC;V;YUV;;Cirrus Logic YUV 4:1:1;http://www.fourcc.org/indexyuv.htm\n"
+ "CLLC;Canopus;4CC;V;;;Canopus LossLess\n"
+ "CLPL;YUV;4CC;V;YUV;;Format similar to YV12 but including a level of indirection.\n"
+ "CM10;MediaShow;4CC;V;;;CyberLink Corporation;http://www.cyberlink.com\n"
+ "CMYK;CMYK;4CC;V;;;Common Data Format in Printing\n"
+ "COL0;MS MPEG-4 v3;4CC;V;MPEG-4V;;Hacked MS MPEG-4 v3;http://ffdshow-tryout.sourceforge.net/\n"
+ "COL1;MS MPEG-4 v3;4CC;V;MPEG-4V;;Hacked MS MPEG-4 v3;http://ffdshow-tryout.sourceforge.net/\n"
+ "CPLA;YUV;4CC;V;YUV;;Weitek YUV 4:2:0 Planar\n"
+ "CRAM;MS Video;4CC;V;;;Microsoft Video 1\n"
+ "CSCD;CamStudio;4CC;V;;;RenderSoft CamStudio lossless (LZO & GZIP compression)\n"
+ "CT10;TalkingShow;4CC;V;;;CyberLink Corporation;http://www.cyberlink.com\n"
+ "CTRX;Citrix;4CC;V;;;Citrix Scalable Video\n"
+ "CUVC;Canopus HQ;4CC;V;;;Canopus HQ\n"
+ "CVID;Cinepack;4CC;V;;;Cinepak by CTi (ex. Radius) Vector Quantization;http://www.cinepak.com/text.html\n"
+ "cvid;Cinepack;4CC;V;;;Cinepak by CTi (ex. Radius) Vector Quantization;http://www.apple.com/quicktime/download/standalone.html\n"
+ "CWLT;WLT;4CC;V;;;Microsoft Color WLT DIB\n"
+ "CYUV;YUV;4CC;V;YUV;;Creative Labs YUV 4:2:2;http://www.fourcc.org/indexyuv.htm\n"
+ "CYUY;YUV;4CC;V;YUV;;ATI Technologies YUV;http://www.fourcc.org/indexyuv.htm\n"
+ "D261;H.261;4CC;V;;;DEC H.261\n"
+ "D263;H.263;4CC;V;;;DEC H.263\n"
+ "DAVC;AVC;4CC;V;AVC;;Dicas MPEGable H.264/MPEG-4 AVC base profile\n"
+ "DC25;MainConcept DV;4CC;V;DV;;MainConcept ProDV\n"
+ "DCAP;Pinnacle DV25;4CC;V;DV;;Pinnacle DV25\n"
+ "DCL1;Data Connextion;4CC;V;;;Data Connection Conferencing\n"
+ "DCT0;WniWni;4CC;V;;;WniWni\n"
+ "DFSC;VFW;4CC;V;;;DebugMode FrameServer VFW\n"
+ "DIB ;RGB;4CC;V;RGB;;Device Independent Bitmap\n"
+ "DIV1;FFMpeg;4CC;V;MPEG-4V;;FFmpeg-4 V1 (hacked MS MPEG-4 V1);http://ffdshow-tryout.sourceforge.net/\n"
+ "DIV2;MS MPEG-4 1/2;4CC;V;MPEG-4V;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "DIV3;DivX 3 Low;4CC;V;MPEG-4V;;;http://www.divx.com\n"
+ "DIV4;DivX 3 Fast;4CC;V;MPEG-4V;;;http://www.divx.com\n"
+ "DIV5;DivX 5;4CC;V;MPEG-4V;;;http://www.divx.com\n"
+ "DIV6;MS MPEG-4 v3;4CC;V;MPEG-4V;;MS MPEG-4 v3;http://ffdshow-tryout.sourceforge.net/\n"
+ "DIVX;DivX 4;4CC;V;MPEG-4V;;Project Mayo DivX 4;http://www.divx.com\n"
+ "divx;DivX;4CC;V;MPEG-4V;;Mainly used by Google;http://www.divx.com\n"
+ "DJPG;Broadway 101;4CC;V;JPEG;;Data Translation, Inc.\n"
+ "DM4V;Dicas;4CC;V;MPEG-4V;;Dicas MPEGable MPEG-4\n"
+ "DMB1;Rainbow;4CC;V;JPEG;;Matrox Rainbow Runner hardware compression;http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.MJPG.v2.10.27.codec.exe\n"
+ "DMB2;Paradigm JPEG;4CC;V;JPEG;;JPEG used by Paradigm\n"
+ "DMK2;V36 PDA;4CC;V;;;ViewSonic V36 PDA Video\n"
+ "DP02;DynaPel;4CC;V;MPEG-4V;;DynaPel MPEG-4\n"
+ "DP16;YUV411;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 6-bit compression)\n"
+ "DP18;YUV411;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 8-bit compression)\n"
+ "DP26;YUV422;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 6-bit compression)\n"
+ "DP28;YUV422;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 8-bit compression)\n"
+ "DP96;YVU9;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 6-bit compression)\n"
+ "DP98;YVU9;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 8-bit compression)\n"
+ "DP9L;YVU9;4CC;V;YUV;;Matsushita Electric Industrial Co., Ltd. (With DPCM 6-bit compression)\n"
+ "DPS0;DPS Reality;4CC;V;JPEG;;DPS Reality JPEG (dummy format - only AVI header)\n"
+ "DPSC;DPS PAR;4CC;V;JPEG;;DPS PAR JPEG (dummy format - only AVI header)\n"
+ "DRWX;Pinnacle DV25;4CC;V;DV;;Pinnacle DV25\n"
+ "DSVD;DV;4CC;V;DV;;Microsoft DirectShow DV\n"
+ "DTMT;Media-100;4CC;V;;;Media-100\n"
+ "DTNT;Media-100;4CC;V;;;Media-100\n"
+ "DUCK;TrueMotion S;4CC;V;;;Duck Corporation True Motion S\n"
+ "DV10;BlueFish;4CC;V;;;BlueFish444 (lossless RGBA, YUV 10-bit)\n"
+ "DV25;DVCPro;4CC;V;DV;;Matrox DVCPRO\n"
+ "DV50;DVCPro5;4CC;V;DV;;Matrox \n"
+ "DVAN;Pinnacle DV300;4CC;V;DV;;Pinnacle miroVideo DV300 SW only\n"
+ "DVC ;Apple DV NTSC;4CC;V;DV;;Apple QuickTime DV (DVCPRO NTSC);http://www.apple.com/quicktime/download/standalone.html\n"
+ "dvc ;Apple DV NTSC;4CC;V;DV;;Apple QuickTime DV (DVCPRO NTSC);http://www.apple.com/quicktime/download/standalone.html\n"
+ "DVCP;Apple DV PAL;4CC;V;DV;;Apple QuickTime DV (DVCPRO PAL);http://www.apple.com/quicktime/download/standalone.html\n"
+ "dvcp;Apple DV PAL;4CC;V;DV;;Apple QuickTime DV (DVCPRO PAL);http://www.apple.com/quicktime/download/standalone.html\n"
+ "DVCS;MainConcept DV;4CC;V;DV;;MainConcept DV\n"
+ "DVE2;Insoft DVE-2;4CC;V;DV;;InSoft DVE-2 Videoconferencing\n"
+ "DVH1;Pinnacle DV;4CC;V;DV;;Pinnacle DVHD100\n"
+ "dvhd;DV HD;4CC;V;DV;;DV 1125 lines at 30.00 Hz or 1250 lines at 25.00 Hz\n"
+ "dvhd;DV HD;4CC;A;DV;;Sony DV (DV), audio part\n"
+ "DVIS;DualMoon DV;4CC;V;DV;;VSYNC DualMoon Iris DV\n"
+ "DVL ;Radius DV NTSC;4CC;V;DV;;Radius SoftDV 16:9 NTSC\n"
+ "DVLP;Radius DV PAL;4CC;V;DV;;Radius SoftDV 16:9 PAL\n"
+ "DVMA;Darim DV;4CC;V;DV;;Darim Vision DVMPEG (dummy for MPEG compressor)\n"
+ "DVNM;DVNM;4CC;V;;;Matsushita Electric Industrial Co., Ltd.\n"
+ "DVOR;BlueFish;4CC;V;;;BlueFish444 (lossless RGBA, YUV 10-bit)\n"
+ "DVPN;Apple DV NTSC;4CC;V;DV;;Apple QuickTime DV (DV NTSC)\n"
+ "DVPP;Apple DV PAL;4CC;V;DV;;Apple QuickTime DV (DV PAL)\n"
+ "DVR ;MPEG-2 Video;4CC;V;MPEG-2;;MPEG-2 Video in a ASF container\n"
+ "DVR1;Targa2000;4CC;V;;;TARGA2000\n"
+ "DVRS;DualMoon DV;4CC;V;DV;;VSYNC DualMoon Iris DV\n"
+ "DVSD;DV;4CC;V;DV;;IEC 61834 and SMPTE 314M\n"
+ "dvsd;Sony DV;4CC;V;DV;;Sony DV (DV) 525 lines at 29.97 Hz or 625 lines at 25.00 Hz\n"
+ "dvsd;Sony DV;4CC;A;DV;;Sony DV (DV), audio part\n"
+ "dvsl;Sony DV;4CC;V;DV;;Sony DV (DV) 525 lines at 29.97 Hz or 625 lines at 25.00 Hz\n"
+ "dvsl;Sony DV;4CC;A;DV;;Sony DV (DV), audio part\n"
+ "DVSL;DSL DV;4CC;V;DV;;DV compressed in SD (SDL)\n"
+ "DVX1;DVX 1 SP;4CC;V;;;Lucent DVX1000SP Video Decoder\n"
+ "DVX2;DVX 2 S;4CC;V;;;Lucent DVX2000S Video Decoder\n"
+ "DVX3;DVX 3 S;4CC;V;;;Lucent DVX3000S Video Decoder\n"
+ "DX50;DivX 5;4CC;V;MPEG-4V;;;http://www.divx.com\n"
+ "DXGM;EA GameVideo;4CC;V;;;Electronic Arts Game Video\n"
+ "DXSB;DivX.com Subtitle;4CC;T;;;Subtitle in AVI from DivX networks;http://www.divx.com\n"
+ "DXT1;DirectX TC;4CC;V;;;DirectX Compressed Texture (1bit alpha channel)\n"
+ "DXT2;DirectX TC;4CC;V;;;DirectX Compressed Texture\n"
+ "DXT3;DirectX TC;4CC;V;;;DirectX Compressed Texture (4bit alpha channel)\n"
+ "DXT4;DirectX TC;4CC;V;;;DirectX Compressed Texture\n"
+ "DXT5;DirectX TC;4CC;V;;;DirectX Compressed Texture (3bit alpha channel with interpolation)\n"
+ "DXTC;DirectX TC;4CC;V;;;DirectX Texture Compression\n"
+ "DXTn;DirectX TC;4CC;V;;;Microsoft Compressed Texture\n"
+ "DXTN;DirectX TC;4CC;V;;;Microsoft DirectX Compressed Texture (DXTn)\n"
+ "EKQ0;Elsa KQ;4CC;V;;;Elsa graphics card quick\n"
+ "ELK0;Elsa LK;4CC;V;;;Elsa graphics card\n"
+ "EM2V;Elymonyx MPEG-2;4CC;V;;;Etymonix MPEG-2 I-frame\n"
+ "EMWC;WMA;;A;;;EverAd, Inc.\n"
+ "EQK0;Elsa;4CC;V;;;Elsa graphics card quick\n"
+ "ESCP;Escape;4CC;V;;;Eidos Escape\n"
+ "ETV1;eTreppid 1;4CC;V;;;eTreppid Video 1\n"
+ "ETV2;eTreppid 2;4CC;V;;;eTreppid Video 2\n"
+ "ETVC;eTreppid C;4CC;V;;;eTreppid Video C\n"
+ "FFDS;FFDS;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "FFV1;FFV1;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "FFVH;FFVH;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "FLIC;FLI/FLC;4CC;V;;;Autodesk FLI/FLC Animation\n"
+ "FLJP;DField JPEG;4CC;V;;;D-Vision Field Encoded JPEG with LSI (or Targa emulation)\n"
+ "FLV1;H.263;;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "FLV4;VP6;4CC;V;;;Flash, On2 Technologies;http://www.on2.com\n"
+ "FMJP;D-Vision JPEG;4CC;V;;;D-Vision fieldbased ISO JPEG\n"
+ "FMP4;MPEG-4 Visual;4CC;V;MPEG-4V;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "FPS1;FRAPS;4CC;V;;;;http://www.fraps.com/\n"
+ "FRLE;SoftLab-Nsk JPEG;4CC;V;;;SoftLab-NSK Y16 + Alpha RLE\n"
+ "FRWA;SoftLab-Nsk JPEG (w Alpha);4CC;V;;;SoftLab-NSK Vision Forward JPEG with Alpha-channel\n"
+ "FRWD;SoftLab-Nsk JPEG;4CC;V;;;SoftLab-NSK Vision Forward JPEG\n"
+ "FRWT;SoftLab-Nsk JPEG;4CC;V;;;SoftLab-NSK Vision Forward JPEG with Alpha-channel\n"
+ "FRWU;SoftLab-Nsk JPEG;4CC;V;;;SoftLab-NSK Vision Forward Uncompressed\n"
+ "FVF1;Itered Fractal;4CC;V;;;Iterated Systems Fractal Video Frame\n"
+ "FVFW;FVFW;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "FXT1;3DFX;4CC;V;;;3dfx Interactive, Inc.\n"
+ "G2M2;GoToMeeting2;4CC;V;;;Citrix Systems, Inc.;http://www.gotomeeting.com/\n"
+ "G2M3;GoToMeeting3;4CC;V;;;Citrix Systems, Inc.;http://www.gotomeeting.com/\n"
+ "GEPJ;White Pine JPEG;4CC;V;;;White Pine JPEG\n"
+ "GJPG;Grand Tech GT891x;4CC;V;;;Grand Tech GT891x\n"
+ "GLCC;GigaLink;4CC;V;;;GigaLink AV Capture\n"
+ "GLZW;Gabest;4CC;V;;;Motion LZW by Gabest;http://sourceforge.net/project/showfiles.php?group_id=82303&package_id=84358\n"
+ "GPEG;Gabest;4CC;V;JPEG;;JPEG by Gabest (with floating point);http://sourceforge.net/project/showfiles.php?group_id=82303&package_id=84358\n"
+ "GPJM;Pinnacle JPEG;4CC;V;JPEG;;Pinnacle ReelTime JPEG\n"
+ "GREY;YUV;4CC;V;YUV;;Simple grayscale video;http://www.fourcc.org/indexyuv.htm\n"
+ "GWLT;MS GWLT;4CC;V;;;Microsoft Greyscale WLT DIB\n"
+ "GXVE;ViVD V2;4CC;V;;;SoftMedia\n"
+ "H260;Intel H.260;4CC;V;;;Intel H.260\n"
+ "H261;Intel H.261;4CC;V;;;Intel H.261\n"
+ "H262;Intel H.262;4CC;V;;;Intel H.262\n"
+ "H263;Intel H.263;4CC;V;;;Intel H.263\n"
+ "H264;AVC;4CC;V;AVC;;Intel H.264\n"
+ "h264;AVC;4CC;V;AVC;;Intel H.264\n"
+ "H265;Intel H.265;4CC;V;;;Intel H.265\n"
+ "H266;Intel H.266;4CC;V;;;Intel H.266\n"
+ "H267;Intel H.267;4CC;V;;;Intel H.267\n"
+ "H268;Intel H.268;4CC;V;;;Intel H.268\n"
+ "H269;Intel H.263;4CC;V;;;Intel H.263 for POTS-based videoconferencing\n"
+ "HD10;BlueFish;4CC;V;;;BlueFish444 (lossless RGBA, YUV 10-bit)\n"
+ "HDX4;Jomigo;4CC;V;;;Jomigo HDX4\n"
+ "HFYU;Huffman;4CC;V;;;Huffman Lossless YUV and RGB formats (with Alpha-channel)\n"
+ "HMCR;Rendition;4CC;V;;;Rendition Motion Compensation Format\n"
+ "HMRR;Rendition;4CC;V;;;Rendition Motion Compensation Format\n"
+ "i263;Intel H.263;4CC;V;;;Intel H.263\n"
+ "I420;YUV;4CC;V;;\n"
+ "IAN ;Indeo 4;4CC;V;;;Intel Indeo 4\n"
+ "ICLB;CellB;4CC;V;;;InSoft CellB Videoconferencing\n"
+ "IDM0;Wavelets 2;4CC;V;;;IDM Motion Wavelets 2.0\n"
+ "IF09;H.261;4CC;V;;;Microsoft H.261\n"
+ "IFO9;YUV9;4CC;V;YUV;;Intel\n"
+ "IGOR;PowerDVD;4CC;V;;;Power DVD\n"
+ "IJPG;Intergraph JPEG;4CC;V;JPEG;;Intergraph\n"
+ "ILVC;Layered Video;4CC;V;;;Intel Layered Video\n"
+ "ILVR;H.263+;4CC;V;;;Intel H.263+\n"
+ "IMAC;MotionComp;4CC;V;;;Intel hardware motion compensation.\n"
+ "IMC1;YUV;4CC;V;YUV;;As YV12, except the U and V planes each have the same stride as the Y plane\n"
+ "IMC2;YUV;4CC;V;YUV;;Similar to IMC1, except that the U and V lines are interleaved at half stride boundaries\n"
+ "IMC3;YUV;4CC;V;YUV;;As IMC1, except that U and V are swapped\n"
+ "IMC4;YUV;4CC;V;YUV;;As IMC2, except that U and V are swapped\n"
+ "IMG ;YUV;4CC;V;YUV;\n"
+ "IMJG;Accom JPEG;4CC;V;;;Accom SphereOUS JPEG with Alpha-channel\n"
+ "IPDV;I-O DV;4CC;V;;;I-O Data Device Giga AVI DV\n"
+ "IPJ2;JPEG 2000;4CC;V;;;Image Power JPEG 2000\n"
+ "IR21;Indeo 2.1;4CC;V;;;Intel Indeo 2.1\n"
+ "IRAW;YUV;4CC;V;YUV;;Intel YUV Uncompressed;http://www.fourcc.org/indexyuv.htm\n"
+ "ISME;ISME;4CC;V;;;Intel\n"
+ "IUYV;YUV;4CC;V;YUV;;Lead 16bpp. Interlaced version of UYVY (line order 0, 2, 4,....,1, 3, 5....)\n"
+ "IV30;Indeo 3;4CC;V;;;Intel Indeo Video 3\n"
+ "IV31;Indeo 3;4CC;V;;;Intel Indeo Video 3.1\n"
+ "IV32;Indeo 3;4CC;V;;;Intel Indeo Video 3.2\n"
+ "IV33;Indeo 3;4CC;V;;;Intel Indeo Video 3.3\n"
+ "IV34;Indeo 3;4CC;V;;;Intel Indeo Video 3.4\n"
+ "IV35;Indeo 3;4CC;V;;;Intel Indeo Video 3.5\n"
+ "IV36;Indeo 3;4CC;V;;;Intel Indeo Video 3.6\n"
+ "IV37;Indeo 3;4CC;V;;;Intel Indeo Video 3.7\n"
+ "IV38;Indeo 3;4CC;V;;;Intel Indeo Video 3.8\n"
+ "IV39;Indeo 3;4CC;V;;;Intel Indeo Video 3.9\n"
+ "IV40;Indeo 4;4CC;V;;;Intel Indeo Video 4.0\n"
+ "IV41;Indeo 4;4CC;V;;;Intel Indeo Video 4.1\n"
+ "IV42;Indeo 4;4CC;V;;;Intel Indeo Video 4.2\n"
+ "IV43;Indeo 4;4CC;V;;;Intel Indeo Video 4.3\n"
+ "IV44;Indeo 4;4CC;V;;;Intel Indeo Video 4.4\n"
+ "IV45;Indeo 4;4CC;V;;;Intel Indeo Video 4.5\n"
+ "IV46;Indeo 4;4CC;V;;;Intel Indeo Video 4.6\n"
+ "IV47;Indeo 4;4CC;V;;;Intel Indeo Video 4.7\n"
+ "IV48;Indeo 4;4CC;V;;;Intel Indeo Video 4.8\n"
+ "IV49;Indeo 4;4CC;V;;;Intel Indeo Video 4.9\n"
+ "IV50;Indeo 4;4CC;V;;;Intel Indeo Video 5.0 Wavelet;http://www.fourcc.org/indexyuv.htm\n"
+ "IY41;YUV;4CC;V;YUV;;Lead 16bpp. Interlaced version of Y41P (line order 0, 2, 4,....,1, 3, 5....);http://www.fourcc.org/indexyuv.htm\n"
+ "IYU1;YUV;4CC;V;YUV;;IEEE1394 12bpp. 12 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec;http://www.fourcc.org/indexyuv.htm\n"
+ "IYU2;YUV;4CC;V;YUV;;IEEE1394 24bpp. 24 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec\n"
+ "IYUV;YUV;4CC;V;YUV;;Intel Indeo iYUV 4:2:0\n"
+ "JBYR;Kensington;4CC;V;;;Kensington Video;http://ffdshow-tryout.sourceforge.net/\n"
+ "JFIF;JPEG;4CC;V;JPEG;;\n"
+ "JPEG;JPEG;4CC;V;JPEG;;JPEG compressed;http://www.apple.com/quicktime/download/standalone.html\n"
+ "jpeg;JPEG;4CC;V;JPEG;;JPEG compressed\n"
+ "JPG;JPEG;4CC;V;JPEG;;JPEG compressed;http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.Lossless.JPEG.codec.v2.10.27.exe\n"
+ "JPGL;Pegasus JPEG;4CC;V;;;DIVIO JPEG Light for WebCams (Pegasus Lossless JPEG)\n"
+ "KMVC;Karl;4CC;V;;;Karl Morton's Video (presumably);http://www.apple.com/quicktime/download/standalone.html\n"
+ "kpcd;Photo CD;4CC;V;;;Kodak Photo CD\n"
+ "L261;H.261;4CC;V;;;Lead Technologies H.261\n"
+ "L263;H.263+;4CC;V;;;Lead Technologies H.263\n"
+ "LAGS;Lagarith;4CC;V;;;Lagarith LossLess\n"
+ "LBYR;Creative WebCam;4CC;V;;;Creative WebCam\n"
+ "LCMW;Lead CMW;4CC;V;;;Lead Technologies Motion CMW\n"
+ "LCW2;Lead MCMW;4CC;V;;;LEADTools MCMW 9Motion Wavelet;http://mirror01.iptelecom.net.ua/~video/codecs/LEAD.MCMP-JPEG.v1.016.codec.exe\n"
+ "LEAD;Lead Video;4CC;V;;;LEAD Video\n"
+ "LGRY;Lead GrayScale;4CC;V;;;Lead Technologies Grayscale Image\n"
+ "LIA1;Liafail;4CC;V;;;Liafail, Inc.\n"
+ "LJ2K;Lead JPEG 2000;4CC;V;;;LEADTools JPEG 2000;http://mirror01.iptelecom.net.ua/~video/codecs/LEAD.MCMP-JPEG.v1.016.codec.exe\n"
+ "LJPG;Lead JPEG;4CC;V;JPEG;;LEAD JPEG;http://mirror01.iptelecom.net.ua/~video/codecs/LEAD.MCMP-JPEG.v1.016.codec.exe\n"
+ "Ljpg;Lead JPEG;4CC;V;JPEG;;LEAD JPEG\n"
+ "LMP2;Lead MPEG-2;4CC;V;;;LEADTools MPEG-2\n"
+ "LOCO;LOCO;4CC;V;;;LOCO Lossless\n"
+ "LSCR;Lead Screen capture;4CC;V;;;LEAD Screen Capture\n"
+ "LSV0;LSV0;4CC;V;;;Infinop Inc.\n"
+ "LSVC;Vmail;4CC;V;;;Vianet Lighting Strike Vmail (Streaming)\n"
+ "LSVM;Vmail;4CC;V;;;Vianet Lighting Strike Vmail (Streaming)\n"
+ "LSVW;Infinop;4CC;V;;;Infinop Lightning Strike multiple bit rate video codec.\n"
+ "LSVX;Vmail;4CC;V;;;Vianet Lightning Strike Video Codec\n"
+ "LZO1;LZO;4CC;V;;;LZO compressed (lossless)\n"
+ "M101;YUV;4CC;V;YUV;;Matrox\n"
+ "M261;H.261;4CC;V;;;Microsoft H.261\n"
+ "M263;H.263;4CC;V;;;Microsoft H.263\n"
+ "M4CC;ESS Divo;4CC;V;MPEG-4V;;ESS MPEG-4 Divio\n"
+ "M4S2;FFmpeg MPEG-4;4CC;V;;;Microsoft MPEG-4 (hacked MS MPEG-4)\n"
+ "MC12;ATI Motion;4CC;V;;;ATI Motion Compensation Format\n"
+ "MC24;MainConcept JPEG;4CC;V;JPEG;;MainConcept JPEG\n"
+ "MCAM;ATI Motion;4CC;V;;;ATI Motion Compensation Format\n"
+ "MCZM;RGB;4CC;V;RGB;;Theory MicroCosm Lossless 64bit RGB with Alpha-channel\n"
+ "MDVD;MicroDVD;4CC;V;;;Alex MicroDVD Video (hacked MS MPEG-4)\n"
+ "MDVF;Pinnacle DV;4CC;V;DV;;Pinnacle DV/DV50/DVHD100\n"
+ "MHFY;YUB;4CC;V;YUV;;A.M.Paredes mhuffyYUV (LossLess);http://mirror01.iptelecom.net.ua/~video/codecs/Pinnacle.ReelTime.v2.5.software.only.codec.exe\n"
+ "MJ2C;JPEG 2000;4CC;V;;;Morgan Multimedia JPEG 2000 Compression;http://mirror01.iptelecom.net.ua/~video/codecs/Pinnacle.ReelTime.v2.5.software.only.codec.exe\n"
+ "MJPA;Pinacle JPEG A;4CC;V;;;Pinnacle ReelTime MJPG hardware;http://mediaxw.sourceforge.net\n"
+ "MJPB;Pinacle JPEG B;4CC;V;JPEG;;JPEG\n"
+ "MJPG;JPEG;4CC;V;JPEG;;JPEG including Huffman Tables\n"
+ "mJPG;IBM JPEG (w Huffman);4CC;V;JPEG;;IBM JPEG including Huffman Tables\n"
+ "MJPX;Pegasus JPEG;4CC;V;;;Pegasus PICVideo JPEG\n"
+ "ML20;Webcam;4CC;V;;;Mimic MSN Messenger Webcam\n"
+ "MMES;Matrox MPEG-2;4CC;V;MPEG-V;;Matrox MPEG-2 I-frame\n"
+ "MMIF;Matrox MPEG-2;4CC;V;MPEG-V;;Matrox MPEG-2 I-frame\n"
+ "MNVD;MindVid;4CC;V;;;MindBend MindVid LossLess\n"
+ "MP2A;MPEG-2 Audio;4CC;A;MPEG-A;;Media Excel MPEG-2 Audio\n"
+ "MP2T;MPEG-2 TS;4CC;M;MPEG-TS;;Media Excel MPEG-2 Transport Stream\n"
+ "MP2V;MPEG-2 Video;4CC;V;MPEG-V;;Media Excel MPEG-2 Video;http://ffdshow-tryout.sourceforge.net/\n"
+ "MP2v;MPEG-2 Video;4CC;V;MPEG-V;;MPEG-2 Video;http://ffdshow-tryout.sourceforge.net/\n"
+ "MP41;S-Mpeg 4 v1;4CC;V;;;Microsoft MPEG-4 V1 (enhansed H263);http://ffdshow-tryout.sourceforge.net/\n"
+ "MP42;S-Mpeg 4 v2;4CC;V;;;Microsoft MPEG-4 V2;http://www.apple.com/quicktime/download/standalone.html\n"
+ "MP43;S-Mpeg 4 v3;4CC;V;;;Microsoft MPEG-4 V3\n"
+ "mp4a;AAC;4CC;A;AAC;;AAC;http://ffdshow-tryout.sourceforge.net/\n"
+ "MP4A;MPEG-4 Audio;4CC;A;AAC;;Media Excel MPEG-4 Audio;http://www.apple.com/quicktime/download/standalone.html\n"
+ "MP4S;MS MPEG-4 v3;4CC;V;MPEG-4V;;Microsoft MPEG-4 (Windows Media 7.0)\n"
+ "mp4s;MPEG-4 TS;4CC;M;MPEG-TS;;(MPEG-4) Apple MPEG-4 Transport Stream;http://ffdshow-tryout.sourceforge.net/\n"
+ "MP4T;MPEG-4 TS;4CC;M;MPEG-TS;;Media Excel MPEG-4 Transport Stream;http://www.apple.com/quicktime/download/standalone.html\n"
+ "MP4V;MPEG-4 Video;4CC;V;MPEG-4V;;Apple QuickTime MPEG-4 native;http://ffdshow-tryout.sourceforge.net/\n"
+ "mp4v;MPEG-4 Video;4CC;V;MPEG-4V;;(MPEG-4) Apple MPEG-4 Video;http://www.apple.com/quicktime/download/standalone.html\n"
+ "MPEG;MPEG;4CC;V;MPEG-V;;Chromatic MPEG 1 Video I Frame;http://ffdshow-tryout.sourceforge.net/\n"
+ "mpeg;MPEG;4CC;V;MPEG-V;;MPEG-1 Video;http://ffdshow-tryout.sourceforge.net/\n"
+ "MPG1;FFmpeg MPEG 1/2;4CC;V;MPEG-V;;(MPEG-1/2) FFmpeg;http://ffdshow-tryout.sourceforge.net/\n"
+ "MPG2;FFmpeg MPEG 1/2;4CC;V;MPEG-V;;(MPEG-1/2) FFmpeg;http://ffdshow-tryout.sourceforge.net/\n"
+ "MPG3;FFmpeg DivX 3;4CC;V;MPEG-4V;;(MPEG-4) MS MPEG-4 v3\n"
+ "MPG4;MS MPEG-4 v1;4CC;V;MPEG-4V;;Microsoft MPEG-4 v1\n"
+ "MPGI;Sigma MPEG;4CC;V;MPEG-V;;Sigma Design MPEG-1 I-frame\n"
+ "MPNG;PNG;4CC;V;RGB;;Motion PNG\n"
+ "MRCA;Mrcodec;4CC;V;;;FAST Multimedia\n"
+ "MRLE;RLE;4CC;V;RGB;;Microsoft RLE\n"
+ "MSS1;Windows Screen Video;4CC;V;;;Windows Screen Video\n"
+ "MSS2;Windows Media;4CC;V;;;Windows Media 9\n"
+ "MSUC;MSU;4CC;V;;;MSU LossLess\n"
+ "MSUD;MSU;4CC;V;;;MSU LossLess\n"
+ "MSV1;Microsoft Video 1;4CC;V;;;Microsoft Video 1\n"
+ "MSVC;Microsoft Video 1;4CC;V;;;Microsoft Video 1\n"
+ "MSZH;AVImszh;4CC;V;;;Lossless (ZIP compression)\n"
+ "MTGA;TGA;4CC;V;RGB;;Motion TGA images (24, 32 bpp)\n"
+ "MTX1;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG\n"
+ "MTX2;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG\n"
+ "MTX3;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG\n"
+ "MTX4;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG\n"
+ "MTX5;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG\n"
+ "MTX6;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG\n"
+ "MTX7;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG\n"
+ "MTX8;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG\n"
+ "MTX9;Matrox JPEG;4CC;V;JPEG;;Matrox JPEG\n"
+ "MV10;Nokia;4CC;V;;;Nokia Mobile Phones\n"
+ "MV11;Nokia;4CC;V;;;Nokia Mobile Phones\n"
+ "MV12;MVI;4CC;V;;;Motion Pixels (old)\n"
+ "MV99;Nokia;4CC;V;;;Nokia Mobile Phones\n"
+ "MVC1;Nokia;4CC;V;;;Nokia Mobile Phones\n"
+ "MVC2;Nokia;4CC;V;;;Nokia Mobile Phones\n"
+ "MVC9;Nokia;4CC;V;;;Nokia Mobile Phones\n"
+ "MVI1;MVI;4CC;V;;;Motion Pixels MVI\n"
+ "MVI2;MVI;4CC;V;;;Motion Pixels MVI\n"
+ "MWV1;Aware Motion Wavelets;4CC;V;;;Aware Motion Wavelets\n"
+ "MYUV;RGB;4CC;V;RGB;;Media-100 844/X Uncompressed\n"
+ "NAVI;MS MPEG-4;4CC;V;MPEG-4V;;nAVI video (hacked MS MPEG-4)\n"
+ "NDIG;Ahead MPEG-4;4CC;V;MPEG-4V;;Ahead Nero Digital MPEG-4\n"
+ "NHVU;Nvidia Texture;4CC;V;;;Nvidia Texture Format (GEForce 3)\n"
+ "NO16;RGB;4CC;V;RGB;;Theory None16 64bit uncompressed Uncompressed\n"
+ "NT00;LightWave;4CC;V;YUV;;NewTek LightWave HDTV YUV with Alpha-channel\n"
+ "NTN1;NogaTech Video 1;4CC;V;;;Nogatech Video Compression 1\n"
+ "NTN2;NogaTech Video 2;4CC;V;;;Nogatech Video Compression 2 (GrabBee hardware coder)\n"
+ "NUV1;Nuppel;4CC;V;;;NuppelVideo\n"
+ "NV12;YUV;4CC;V;YUV;;8-bit Y plane followed by an interleaved U/V plane with 2x2 subsampling\n"
+ "NV21;YUV;4CC;V;YUV;;As NV12 with U and V reversed in the interleaved plane\n"
+ "NVDS;Nvidia Texture;4CC;V;;;Nvidia Texture Format\n"
+ "NVHS;Nvidia Texture;4CC;V;;;Nvidia Texture Format (GeForce 3)\n"
+ "NVHU;Nvidia Texture;4CC;V;;;Nvidia Texture Format\n"
+ "NVS0;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVS1;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVS2;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVS3;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVS4;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVS5;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVS6;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVS7;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVS8;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVS9;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVT0;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVT1;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVT2;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVT3;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVT4;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVT5;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVT6;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVT7;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVT8;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NVT9;Nvidia Texture;4CC;V;;;Nvidia Texture Compression Format\n"
+ "NY12;YUV;4CC;V;YUV;;Nogatech Ltd.\n"
+ "NYUV;YUV;4CC;V;YUV;;Nogatech Ltd.\n"
+ "ONYX;VP7;4CC;V;;;On2 VP7;http://www.on2.com/vp7.php3\n"
+ "PCLE;Studio400;4CC;V;;;Pinnacle Systems, Inc.\n"
+ "PDVC;Panasonic DV;4CC;V;DV;;Panasonic DV\n"
+ "PGVV;Radius Video Vision;4CC;V;;;Radius Video Vision Telecast (adaptive JPEG)\n"
+ "PHMO;Photomotion;4CC;V;;;IBM Photomotion\n"
+ "PIM1;Pegasus JPEG;4CC;V;JPEG;;Pinnacle DC1000 hardware (MPEG compression);http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.Lossless.JPEG.codec.v2.10.27.exe\n"
+ "PIM2;Pegasus JPEG;4CC;V;JPEG;;Pegasus Imaging;http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.Lossless.JPEG.codec.v2.10.27.exe\n"
+ "PIMJ;Pegasus JPEG;4CC;V;JPEG;;Pegasus Imaging PICvideo Lossless JPEG;http://mirror01.iptelecom.net.ua/~video/codecs/PICVideo.Lossless.JPEG.codec.v2.10.27.exe\n"
+ "PIXL;Miro JPEG;4CC;V;JPEG;;MiroVideo XL (JPEG)\n"
+ "PNG;PNG;4CC;V;RGB;;\n"
+ "PNG1;PNG;4CC;V;RGB;;Corecodec.org CorePNG\n"
+ "PVEZ;PowerEZ;4CC;V;;;Horizons Technology PowerEZ\n"
+ "PVMM;Pegasus MPEG-4;4CC;V;MPEG-4V;;PacketVideo Corporation MPEG-4\n"
+ "PVW2;Pegasus Wavelet;4CC;V;;;Pegasus Imaging Wavelet 2000\n"
+ "PVWV;Pegasus Wavelet;4CC;V;;;Pegasus Imaging Wavelet 2000\n"
+ "PXLT;Pixlet;4CC;V;;;Apple Pixlet (Wavelet)\n"
+ "Q1.0;QPEG 1.0;4CC;V;;;Q-Team QPEG 1.0;http://www.q-team.de\n"
+ "Q1.1;QPEG 1.1;4CC;V;;;Q-Team QPEG 1.1;http://www.q-team.de\n"
+ "Qclp;QCLP;4CC;A;;;\n"
+ "QDGX;Apple GX;4CC;V;;;Apple QuickDUncompressed GX\n"
+ "QDM1;QDesign 1;4CC;A;;;QDesign Music 1\n"
+ "QDM2;Qdesign 2;4CC;A;;;QDesign Music 2\n"
+ "QDRW;Palettized Video;4CC;V;;;Apple\n"
+ "QPEG;QPEG 1.1;4CC;V;;;Q-Team QPEG 1.1\n"
+ "QPEQ;QPEG 1.1;4CC;V;;;Q-Team QPEG 1.1\n"
+ "R210;YUV;4CC;V;YUV;;BlackMagic YUV (Quick Time)\n"
+ "R411;Radius DV;4CC;V;DV;;Radius DV NTSC YUV\n"
+ "R420;Radius DV;4CC;V;DV;;Radius DV PAL YUV\n"
+ "RAV_;GroupTron;4CC;V;MPEG-1;;GroupTRON ReferenceAVI (dummy for MPEG compressor)\n"
+ "RAVI;GroupTron;4CC;V;MPEG-1;;GroupTRON ReferenceAVI (dummy for MPEG compressor)\n"
+ "RAW ;RGB;4CC;V;RGB;;Full Frames (Uncompressed)\n"
+ "raw ;RGB;4CC;V;RGB;;Full Frames (Uncompressed);http://www.apple.com/quicktime/download/standalone.html\n"
+ "RGB ;RGB;4CC;V;RGB;;Uncompressed RGB32\n"
+ "RGB1;RGB;4CC;V;RGB;;Uncompressed RGB332 3:3:2\n"
+ "RGBA;RGB;4CC;V;RGB;;Uncompressed w/ Alpha. Uncompressed RGB with alpha. Sample precision and packing is arbitrary and determined using bit masks for each component, as for BI_BITFIELDS.;http://www.fourcc.org/indexrgb.htm\n"
+ "RGBO;RGB;4CC;V;RGB;;Uncompressed RGB555 5:5:5\n"
+ "RGBP;RGB;4CC;V;RGB;;Uncompressed RGB565 5:6:5\n"
+ "RGBQ;RGB;4CC;V;RGB;;Uncompressed RGB555X 5:5:5 BE\n"
+ "RGBR;RGB;4CC;V;RGB;;Uncompressed RGB565X 5:6:5 BE\n"
+ "RGBT;RGB;4CC;V;RGB;;Uncompressed RGB with transparency;http://www.fourcc.org/indexrgb.htm\n"
+ "RIVA;Swizzled texture;4CC;V;;;Nvidia\n"
+ "RL4;RLE;4CC;V;RGB;;RLE 4bpp RGB\n"
+ "RL8;RLE;4CC;V;RGB;;RLE 8bpp RGB\n"
+ "RLE ;RLE;4CC;V;RGB;;RLE RGB with arbitrary sample packing within a pixel;http://www.fourcc.org/indexrgb.htm\n"
+ "rle ;Animation;4CC;V;RGB;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "RLE4;RLE;4CC;V;RGB;;RLE 4bpp RGB;http://www.fourcc.org/indexrgb.htm\n"
+ "RLE8;RLE;4CC;V;RGB;;RLE 8bpp RGB;http://www.fourcc.org/indexrgb.htm\n"
+ "RLND;Roland;4CC;V;;;Roland Corporation\n"
+ "RMP4;RealMagic MPEG-4;4CC;V;MPEG-4V;;REALmagic MPEG-4 Video (Sigma Design, built on XviD)\n"
+ "ROQV;Id RoQ;4CC;V;;;Id RoQ File Video Decoder\n"
+ "rpza;Road Pizza;4CC;V;;;Apple Video 16 bit road pizza;http://www.apple.com/quicktime/download/standalone.html\n"
+ "RT21;Intel Video 2.1;4CC;V;;;Intel Real Time Video 2.1\n"
+ "RTV0;NewTek VideoToaster;4CC;V;;;NewTek VideoToaster (dummy format - only AVI header)\n"
+ "RUD0;Rududu;4CC;V;;;Rududu video\n"
+ "RV10;RealVideo 1;4CC;V;;;H263, RealVideo 5;http://www.real.com\n"
+ "rv10;RealVideo 1;Real;V;;;H263, RealVideo 5;http://www.real.com\n"
+ "RV13;RealVideo 1;4CC;V;;;H263, RealVideo 5;http://www.real.com\n"
+ "rv20;RealVideo 2;Real;V;;;H263, RealVideo 6;http://www.real.com\n"
+ "RV20;RealVideo 2;4CC;V;;;H263, RealVideo 6;http://www.real.com\n"
+ "rv30;RealVideo 3;Real;V;;;Between H263 and H264, RealVideo 8;http://www.real.com\n"
+ "RV30;RealVideo 3;4CC;V;;;Between H263 and H264, RealVideo 8;http://www.real.com\n"
+ "rv40;RealVideo 4;Real;V;;;H264, RealVideo 9;http://www.real.com\n"
+ "RV40;RealVideo 4;4CC;V;;;H264, RealVideo 9;http://www.real.com\n"
+ "RVX ;RDX;4CC;V;;;Intel RDX\n"
+ "S263;S263;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "S422;VideoCap C210;4CC;V;YUV;;VideoCap C210\n"
+ "s422;VideoCap C210;4CC;V;YUV;;VideoCap C210\n"
+ "SAMR;AMR;4CC;A;;;\n"
+ "SAN3;SAN3;4CC;V;MPEG-4V;;Direct copy of DivX 3.11\n"
+ "SANM;Smush v2;4CC;V;;;LucasArts;http://www.lucasarts.com/\n"
+ "SCCD;SoftCam;4CC;V;;;\n"
+ "SDCC;Sun DV;4CC;V;DV;;Sun Digital Camera\n"
+ "SEDG;Samsung MPEG-4;4CC;V;MPEG-4V;;Samsung MPEG-4\n"
+ "SEG4;Cinepak;4CC;V;;;;http://www.sega.com/\n"
+ "SEGA;Cinepak;4CC;V;;;;http://www.sega.com/\n"
+ "SFMC;CrystalNet;4CC;V;;;CrystalNet Surface Fitting Method\n"
+ "SHR0;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless)\n"
+ "SHR1;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless)\n"
+ "SHR2;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless)\n"
+ "SHR3;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless)\n"
+ "SHR4;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless)\n"
+ "SHR5;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless)\n"
+ "SHR6;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless)\n"
+ "SHR7;BitJazz SheerVideo;4CC;V;;;BitJazz SheerVideo (realtime lossless)\n"
+ "SJPG;CuSeeMe;4CC;V;JPEG;;CuSeeMe;http://mirror01.iptelecom.net.ua/~video/codecs/CUseeMe.JPEG.CODEC.v1.17.exe\n"
+ "SL25;SoftLab DVCPro;4CC;V;;;SoftLab-NSK DVCPRO\n"
+ "SL50;SoftLab DVCPro5;4CC;V;;;SoftLab-NSK \n"
+ "SLDV;SoftLab DV;4CC;V;;;SoftLab-NSK Forward DV Draw\n"
+ "SLIF;SoftLab MPEG-2;4CC;V;MPEG-V;;SoftLab-NSK MPEG-2 I-frames\n"
+ "SLMJ;SoftLab JPEG;4CC;V;JPEG;;SoftLab-NSK Forward JPEG\n"
+ "smc ;SMC;4CC;V;;;Apple Graphics (SMC);http://www.apple.com/quicktime/download/standalone.html\n"
+ "SMSC;Radius;4CC;V;;;\n"
+ "SMSD;Radius;4CC;V;;;\n"
+ "SMSV;Wavelet Video;4CC;V;;;WorldConnect Wavelet Streaming Video\n"
+ "smsv;Wavelet Video;4CC;V;;;WorldConnect Wavelet Video\n"
+ "SNOW;Snow;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "SP40;SunPlus YUV;4CC;V;YUV;;SunPlus YUV\n"
+ "SP44;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam\n"
+ "SP53;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam\n"
+ "SP54;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam\n"
+ "SP55;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam\n"
+ "SP56;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam\n"
+ "SP57;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam\n"
+ "SP58;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam\n"
+ "SP61;MegaCam;4CC;V;;;SunPlus Aiptek MegaCam\n"
+ "SPIG;Spigot;4CC;V;;;Radius Spigot\n"
+ "SPLC;ACM audio;4CC;V;;;Splash Studios ACM Audio\n"
+ "SPRK;Spark;4CC;V;;\n"
+ "SQZ2;VXTreme 2;4CC;V;;;Microsoft VXTreme Video V2\n"
+ "STVA;ST Imager;4CC;V;;;ST Microelectronics CMOS Imager Data (Bayer)\n"
+ "STVB;ST Imager;4CC;V;;;ST Microelectronics CMOS Imager Data (Nudged Bayer)\n"
+ "STVC;ST Imager;4CC;V;;;ST Microelectronics CMOS Imager Data (Bunched)\n"
+ "STVX;ST Imager;4CC;V;;;ST Microelectronics CMOS Imager Data (Extended Data Format)\n"
+ "STVY;ST Imager;4CC;V;;;ST Microelectronics CMOS Imager Data (Extended Data Format with Correction Data)\n"
+ "subp;VobSub;4CC;T;;;The same subtitle format used on DVDs\n"
+ "SV10;Sorenson;4CC;V;;;Sorenson Media Video R1\n"
+ "SVQ1;Sorenson 1;4CC;V;;;Sorenson Media Video 1 (Apple QuickTime 3)\n"
+ "SVQ2;Sorenson 2;4CC;V;;;Sorenson Media Video 2 (Apple QuickTime 4)\n"
+ "SVQ3;Sorenson 3;4CC;V;;;Sorenson Media Video 3 (Apple QuickTime 5)\n"
+ "SWC1;MainConcept JPEG;4CC;V;JPEG;;MainConcept JPEG\n"
+ "T420;Toshiba YUV;4CC;V;YUV;;Toshiba YUV 4:2:0\n"
+ "TGA ;Apple TGA;4CC;V;;;Apple TGA (with Alpha-channel)\n"
+ "THEO;Theora;4CC;V;;;FFVFW Supported\n"
+ "TIFF;Apple TIFF;4CC;V;;;Apple TIFF (with Alpha-channel)\n"
+ "TIM2;Pinnacle DVI;4CC;V;;;Pinnacle RAL DVI\n"
+ "TLMS;TeraLogic;4CC;V;;;TeraLogic Motion Intraframe\n"
+ "TLST;TeraLogic;4CC;V;;;TeraLogic Motion Intraframe\n"
+ "TM10;Duck;4CC;V;;;Duck TrueMotion\n"
+ "TM20;Duck 2;4CC;V;;;Duck TrueMotion 2.0\n"
+ "TM2A;Duck Archiver 2;4CC;V;;;Duck TrueMotion Archiver 2.0\n"
+ "TM2X;Duck 2;4CC;V;;;Duck TrueMotion 2X\n"
+ "TMIC;TeraLogic;4CC;V;;;TeraLogic Motion Intraframe\n"
+ "TMOT;Horizons TM S;4CC;V;;;Horizons Technology TrueMotion Video\n"
+ "TR20;Duck TM RT2;4CC;V;;;Duck TrueMotion RT 2.0\n"
+ "TRLE;Akula;4CC;V;;;Akula Alpha Pro Custom AVI (LossLess)\n"
+ "TSCC;TechSmith;4CC;V;;;TechSmith Screen Capture\n"
+ "TV10;Tecomac;4CC;V;;;Tecomac Low-Bit Rate\n"
+ "TVJP;Pinnacle/Truevision;4CC;V;;;TrueVision Field Encoded JPEG (Targa emulation)\n"
+ "TVMJ;Pinnacle/Truevision;4CC;V;;;Truevision TARGA JPEG Hardware (or Targa emulation)\n"
+ "TY0N;Trident;4CC;V;;;Trident Decompression Driver\n"
+ "TY2C;Trident;4CC;V;;;Trident Decompression Driver\n"
+ "TY2N;Trident;4CC;V;;;Trident Decompression Driver\n"
+ "U<Y ;Discreet YUV;4CC;V;YUV;;Discreet UC YUV 4:2:2:4 10 bit\n"
+ "U<YA;Discreet YUV;4CC;V;;;Discreet UC YUV 4:2:2:4 10 bit (with Alpha-channel)\n"
+ "U263;UB H.263;4CC;V;;;UB Video H.263/H.263+/H.263++ Decoder;http://eMajix.com\n"
+ "UCOD;ClearVideo;4CC;V;;;ClearVideo (fractal compression-based)\n"
+ "ULRA;RGBA;Ut Video;Ut Video Lossless Codec;http://umezawa.dyndns.info/archive/utvideo;;;RGBA;4:4:4:4\n"
+ "ULRG;RGB;Ut Video;Ut Video Lossless Codec;http://umezawa.dyndns.info/archive/utvideo;;;RGB;4:4:4 \n"
+ "ULTI;Ultimotion;4CC;V;;;IBM Ultimotion\n"
+ "ULY0;YUV;Ut Video;Ut Video Lossless Codec;http://umezawa.dyndns.info/archive/utvideo;;;YUV;4:2:2\n"
+ "ULY2;YUV;Ut Video;Ut Video Lossless Codec;http://umezawa.dyndns.info/archive/utvideo;;;YUV;4:2:0 \n"
+ "UMP4;UB MPEG-4;4CC;V;MPEG-4V;;UB Video MPEG 4;http://www.fourcc.org/indexyuv.htm\n"
+ "UYNV;YUV;4CC;V;YUV;;Nvidia 16bpp. A direct copy of UYVY registered by Nvidia to work around problems in some olds which did not like hardware which offered more than 2 UYVY surfaces.;http://www.fourcc.org/indexyuv.htm\n"
+ "UYVP;YUV;4CC;V;YUV;;Evans & Sutherland 24bpp. YCbCr 4:2:2 extended precision 10-bits per component in U0Y0V0Y1 order\n"
+ "UYVU;SoftLab YUV;4CC;V;YUV;;SoftLab-NSK Forward YUV;http://www.fourcc.org/indexyuv.htm\n"
+ "UYVY;YUV;4CC;V;YUV;;Uncompressed 16bpp. YUV 4:2:2 (Y sample at every pixel, U and V sampled at every second pixel horizontally on each line). A macropixel contains 2 pixels in 1 u_int32.\n"
+ "V210;Optibase;4CC;V;;;Optibase VideoPump 10-bit 4:2:2 Component YCbCr\n"
+ "V261;VX3000S;4CC;V;;;Lucent VX3000S\n"
+ "V422;Vitec YUV;4CC;V;YUV;;Vitec Multimedia YUV 4:2:2 as for UYVY, but with different component ordering within the u_int32 macropixel\n"
+ "V655;Vitec YUV;4CC;V;YUV;;Vitec Multimedia 16 bit YUV 4:2:2 (6:5:5) format\n"
+ "VBLE;MarcFD VBLE;4CC;V;;;MarcFD VBLE Lossless\n"
+ "VCR1;ATI Video 1;4CC;V;;;ATI VCR 1.0\n"
+ "VCR2;ATI Video 2;4CC;V;;;ATI VCR 2.0 (MPEG YV12)\n"
+ "VCR3;ATI Video 3;4CC;V;;;ATI VCR 3.0\n"
+ "VCR4;ATI Video 4;4CC;V;;;ATI VCR 4.0\n"
+ "VCR5;ATI Video 5;4CC;V;;;ATI VCR 5.0\n"
+ "VCR6;ATI Video 6;4CC;V;;;ATI VCR 6.0\n"
+ "VCR7;ATI Video 7;4CC;V;;;ATI VCR 7.0\n"
+ "VCR8;ATI Video 8;4CC;V;;;ATI VCR 8.0\n"
+ "VCR9;ATI Video 9;4CC;V;;;ATI VCR 9.0\n"
+ "VCWV;Wavelet;4CC;V;;;VideoCon\n"
+ "VDCT;VideoMaker RGB;4CC;V;RGB;;Video Maker Pro DIB\n"
+ "VDOM;VDOWave;4CC;V;;;VDONet Wave\n"
+ "VDOW;VDOLive;4CC;V;;;VDONet Live (H,263)\n"
+ "VDST;VirtualDub;4CC;V;;;VirtualDub remote frameclient ICM driver\n"
+ "VDTZ;YUV;4CC;V;YUV;;VideoTizer / Darim Vision YUV\n"
+ "VGPX;VGP;4CC;V;;;Alaris VideoGramPixel\n"
+ "VIDM;DivX 5 pro;4CC;V;MPEG-4V;;DivX 5.0 Pro Supported\n"
+ "VIDS;Vitec;4CC;V;;;Vitec Multimedia YUV 4:2:2;www.yks.ne.jp/~hori/\n"
+ "VIFP;VFAPI;4CC;V;;;Virtual Frame API (VFAPI dummy format)\n"
+ "VIV1;H.263;4CC;V;;;Vivo H.263\n"
+ "VIV2;H.263;4CC;V;;;Vivo H.263\n"
+ "VIVO;H.263;4CC;V;;;Vivo H.263\n"
+ "VIXL;Miro XL;4CC;V;JPEG;;Miro Video XL;http://mirror01.iptelecom.net.ua/~video/codecs/miroVIDEO-XL.codec.v2.2.exe\n"
+ "VJPG;JPEG;4CC;V;JPEG;;\n"
+ "VLV1;Videologic;4CC;V;;;\n"
+ "VMNC;Vmware;4CC;V;;;;http://www.vmware.com/\n"
+ "VP30;VP3;4CC;V;;;On2 VP3\n"
+ "VP31;VP3;4CC;V;;;On2 VP3\n"
+ "VP32;VP3;4CC;V;;;On2 VP3\n"
+ "VP40;VP4;4CC;V;;;On2 TrueCast VP4\n"
+ "VP50;VP5;4CC;V;;;On2 TrueCast VP5\n"
+ "VP60;VP6;4CC;V;;;On2 TrueCast VP6\n"
+ "VP61;VP6;4CC;V;;;On2 TrueCast VP6.1\n"
+ "VP62;VP6;4CC;V;;;On2 TrueCast VP6.2;http://ftp.pub.cri74.org/pub/win9x/video/codecs/VP6/vp6_vfw_codec.exe\n"
+ "VP6A;VP6;4CC;V;;;On2 TrueCast VP6.2;http://ftp.pub.cri74.org/pub/win9x/video/codecs/VP6/vp6_vfw_codec.exe\n"
+ "VP6F;VP6;4CC;V;;;On2 TrueCast VP6.2;http://ftp.pub.cri74.org/pub/win9x/video/codecs/VP6/vp6_vfw_codec.exe\n"
+ "VP70;VP7;4CC;V;;;On2 TrueMotion VP7\n"
+ "VP71;VP7;4CC;V;;;On2 TrueMotion VP7\n"
+ "VP72;VP7;4CC;V;;;On2 TrueMotion VP7\n"
+ "VQC1;Vector 1;4CC;V;;;Vector-quantised 1 (high compression) http://eprints.ecs.soton.ac.uk/archive/00001310/01/VTC97-js.pdf\n"
+ "VQC2;Vector 2;4CC;V;;;Vector-quantised 2 (high robustness against channel errors) http://eprints.ecs.soton.ac.uk/archive/00001310/01/VTC97-js.pdf\n"
+ "VQJP;VQ630;4CC;V;;;Dual-mode digital camera\n"
+ "VQS4;VQ110;4CC;V;;;DV camera\n"
+ "VR21;BlckMagic YUV;4CC;V;YUV;;BlackMagic YUV (Quick Time)\n"
+ "VSSH;AVC;4CC;V;AVC;;Vanguard VSS H.264\n"
+ "VSSV;Vanguard Video;4CC;V;;;Vanguard Software Solutions Video\n"
+ "VSSW;AVC;4CC;V;AVC;;Vanguard VSS H.264\n"
+ "VTLP;GGP;4CC;V;;;Alaris VideoGramPixel\n"
+ "VX1K;DVX 1 S;4CC;V;;;Lucent VX1000S Video\n"
+ "VX2K;DVX 2 S;4CC;V;;;Lucent VX2000S Video\n"
+ "VXSP;DVX 1 SP;4CC;V;;;Lucent VX1000SP Video\n"
+ "VYU9;YUV;4CC;V;YUV;;ATI YUV\n"
+ "VYUY;YUV;4CC;V;YUV;;ATI Packed YUV Data\n"
+ "WBVC;W9960;4CC;V;;;Winbond Electronics W9960\n"
+ "WHAM;Microsoft Video 1;4CC;V;;;\n"
+ "WINX;Winnov;4CC;V;;;\n"
+ "WJPG;Winbond JPEG;4CC;V;JPEG;;Winbond JPEG (AverMedia USB devices)\n"
+ "WMV1;WMV1;4CC;V;;;Windows Media Video 7;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx\n"
+ "WMV2;WMV2;4CC;V;;;Windows Media Video 8;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx\n"
+ "WMV3;WMV3;4CC;V;VC-1;;Windows Media Video 9;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx\n"
+ "WMVA;WMV;4CC;V;VC-1;;Windows Media Video;http://ffdshow-tryout.sourceforge.net/\n"
+ "WMVP;WMV3;4CC;V;;;Windows Media Video V9\n"
+ "WNIX;WniWni;4CC;V;;;WniWni\n"
+ "WNV1;WinNov;4CC;V;;;WinNov Videum Hardware Compression;http://www.winnov.com/\n"
+ "WNVA;WinNov;4CC;V;;;WinNov Videum Hardware Compression;http://www.winnov.com/\n"
+ "WRLE;Apple BMP;4CC;V;RGB;;Apple QuickTime BMP\n"
+ "WRPR;AVideoTools;4CC;V;;;VideoTools VideoServer Client (wrapper for AviSynth)\n"
+ "WV1F;WV1F;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "WVC1;VC-1;4CC;V;VC-1;;Microsoft\n"
+ "WVLT;IllusionHope Wavelet 9/7;4CC;V;;;IllusionHope Wavelet 9/7\n"
+ "WVP2;WVP2;4CC;V;;;;http://ffdshow-tryout.sourceforge.net/\n"
+ "WZCD;iScan;4CC;V;;;CORE Co. Ltd.\n"
+ "WZDC;iSnap;4CC;V;;;CORE Co. Ltd.\n"
+ "X263;H.263;4CC;V;;;Xirlink H.263\n"
+ "x263;Xirlink;4CC;V;;;\n"
+ "X264;AVC;4CC;V;AVC;;XiWave GNU GPL x264 MPEG-4\n"
+ "x264;AVC;4CC;V;AVC;;XiWave GNU GPL x264 MPEG-4\n"
+ "XJPG;Xirlink;4CC;V;JPEG;;Xirlink, Inc.\n"
+ "XLV0;NetXL Video;4CC;V;;;NetXL Inc. XL Video Decoder\n"
+ "XMPG;Xing MPEG;4CC;V;MPEG-V;;XING MPEG (I frame only)\n"
+ "XVID;XviD;4CC;V;MPEG-4V;;XviD project;http://www.xvid.org/Downloads.15.0.html\n"
+ "XVIX;XviD;4CC;V;MPEG-4V;;Based on XviD MPEG-4;http://www.xvid.org/Downloads.15.0.html\n"
+ "XWV0;XiWave Video;4CC;V;;;XiWave Video\n"
+ "XWV1;XiWave Video;4CC;V;;;XiWave Video\n"
+ "XWV2;XiWave Video;4CC;V;;;XiWave Video\n"
+ "XWV3;XiWave Video;4CC;V;;;XiWave Video (Xi-3 Video)\n"
+ "XWV4;XiWave Video;4CC;V;;;XiWave Video\n"
+ "XWV5;XiWave Video;4CC;V;;;XiWave Video\n"
+ "XWV6;XiWave Video;4CC;V;;;XiWave Video\n"
+ "XWV7;XiWave Video;4CC;V;;;XiWave Video\n"
+ "XWV8;XiWave Video;4CC;V;;;XiWave Video\n"
+ "XWV9;XiWave Video;4CC;V;;;XiWave Video\n"
+ "XXAN;Origin VideoGame;4CC;V;;;Origin Video (used in Wing Commander 3 and 4)\n"
+ "XYZP;PAL;4CC;V;;;Extended PAL format XYZ palette\n"
+ "Y211;YUV;4CC;V;YUV;;Packed YUV format with Y sampled at every second pixel across each line and U and V sampled at every fourth pixel\n"
+ "Y216;Targa YUV;4CC;V;YUV;;Pinnacle TARGA CineWave YUV (Quick Time)\n"
+ "Y411;YUV;4CC;V;YUV;;YUV 4:1:1 Packed\n"
+ "Y41B;YUV;4CC;V;YUV;;YUV 4:1:1 Planar\n"
+ "Y41P;YUV;4CC;V;YUV;;Conexant (ex Brooktree) YUV 4:1:1 Raw;http://www.fourcc.org/indexyuv.htm\n"
+ "Y41T;YUV;4CC;V;YUV;;Format as for Y41P, but the lsb of each Y component is used to signal pixel transparency\n"
+ "Y422;YUV;4CC;V;YUV;;Direct copy of UYVY as used by ADS Technologies Pyro WebCam firewire camera\n"
+ "Y42B;YUV;4CC;V;YUV;;YUV 4:2:2 Planar\n"
+ "Y42T;YUV;4CC;V;YUV;;Format as for UYVY, but the lsb of each Y component is used to signal pixel transparency\n"
+ "Y444;YUV;4CC;V;YUV;;IYU2 (iRez Stealth Fire camera)\n"
+ "Y8 ;GrayScale;4CC;V;;;Simple grayscale video\n"
+ "Y800;GrayScale;4CC;V;;;Simple grayscale video\n"
+ "YC12;YUV;4CC;V;YUV;;Intel YUV12;http://www.fourcc.org/indexyuv.htm\n"
+ "YCCK;YUV;4CC;V;YUV;;\n"
+ "YMPG;MPEG-2;4CC;V;MPEG-2;;YMPEG Alpha (dummy for MPEG-2 compressor)\n"
+ "YU12;YUV;4CC;V;YUV;;ATI YV12 4:2:0 Planar\n"
+ "YU92;YUV;4CC;V;YUV;;Intel - YUV\n"
+ "YUNV;YUV;4CC;V;YUV;;A direct copy of YUY2 registered by Nvidia to work around problems in some olds which did not like hardware that offered more than 2 YUY2 surfaces\n"
+ "YUV2;YUV;4CC;V;YUV;;Apple Component Video (YUV 4:2:2);http://www.apple.com/quicktime/download/standalone.html\n"
+ "YUV8;YUV;4CC;V;YUV;;Winnov Caviar YUV8 ;http://www.fourcc.org/indexyuv.htm\n"
+ "YUV9;YUV;4CC;V;YUV;;Intel YUV9\n"
+ "YUVP;YUV;4CC;V;YUV;;YCbCr 4:2:2 extended precision 10-bits per component in Y0U0Y1V0 order\n"
+ "YUY2;YUV;4CC;V;YUV;;YUV 4:2:2 as for UYVY but with different component ordering within the u_int32 macropixel;http://www.fourcc.org/indexyuv.htm\n"
+ "YUYP;YUV;4CC;V;YUV;;Evans & Sutherland\n"
+ "YUYV;YUV;4CC;V;YUV;;Canopus YUV format;http://www.fourcc.org/indexyuv.htm\n"
+ "YV12;YUV;4CC;V;YUV;;ATI YVU12 4:2:0 Planar;http://www.fourcc.org/indexyuv.htm\n"
+ "YV16;YUV;4CC;V;YUV;;Elecard YUV 4:2:2 Planar\n"
+ "YV92;YUV;4CC;V;YUV;;Intel Smart Video Recorder YVU9\n"
+ "YVU9;YUV;4CC;V;YUV;;Brooktree YVU9 Raw (YVU9 Planar);http://www.fourcc.org/indexyuv.htm\n"
+ "YVYU;YUV;4CC;V;YUV;;YUV 4:2:2 as for UYVY but with different component ordering within the u_int32 macropixel\n"
+ "ZLIB;AVIzlib;4CC;V;RGB;;Lossless (ZIP compression)\n"
+ "ZMBV;Zip;4CC;V;;;Zip Motion Blocks Video\n"
+ "ZPEG;Video Zipper;4CC;V;RGB;;Metheus Video Zipper\n"
+ "ZYGO;ZyGo;4CC;V;;;ZyGo Video\n"
+ "V_UNCOMPRESSED;Raw;Mk;V;;;Raw uncompressed video frames\n"
+ "V_DIRAC;Dirac;Mk;V;;;;http://diracvideo.org/\n"
+ "V_MPEG4/ISO/SP;MPEG-4 Visual SP;Mk;V;MPEG-4V;;Simple Profile;http://www.divx.com\n"
+ "V_MPEG4/ISO/ASP;MPEG-4 Visual ASP;Mk;V;MPEG-4V;;Advanced Simple Profile;http://www.xvid.org/Downloads.15.0.html\n"
+ "V_MPEG4/ISO/AP;MPEG-4 Visual AP;Mk;V;MPEG-4V;;Advanced Profile;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG4/ISO/AVC;AVC;Mk;V;AVC;;Advanced Video Codec;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG4/MS/V2;MS MPEG-4 v2;Mk;V;MPEG-4V;;MS MPEG-4 v2;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG4/MS/V3;MS MPEG-4 v3;Mk;V;MPEG-4V;;MS MPEG-4 v3;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG1;MPEG-1 Video;Mk;V;MPEG-V;;MPEG 1 or 2 Video;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_MPEG2;MPEG-2 Video;Mk;V;MPEG-V;;MPEG 1 or 2 Video;http://ffdshow-tryout.sourceforge.net/\n"
+ "V_REAL/RV10;Real 1;Mk;V;;;RealVideo 1.0 aka RealVideo 5;http://www.real.com\n"
+ "V_REAL/RV20;Real 2;Mk;V;;;RealVideo 2.0 aka G2 and RealVideo G2+SVT;http://www.real.com\n"
+ "V_REAL/RV30;Real 3;Mk;V;;;RealVideo 3.0 aka RealVideo 8;http://www.real.com\n"
+ "V_REAL/RV40;Real 4;Mk;V;;;RealVideo 4.0 aka RealVideo 9;http://www.real.com\n"
+ "V_THEORA;Theora;Mk;V;;;;http://www.theora.org\n"
+ "A_MPEG/L1;MPEG1/2 L1;Mk;A;MPEG-A;;MPEG1 or 2 Audio layer 1;http://www.iis.fraunhofer.de/amm/index.html\n"
+ "A_MPEG/L2;MPEG1/2 L2;Mk;A;MPEG-A;;MPEG1 or 2 Audio layer 2;http://www.iis.fraunhofer.de/amm/index.html\n"
+ "A_MPEG/L3;MPEG1/2 L3;Mk;A;MPEG-A;;MPEG1 or 2 Audio Layer 3;http://www.iis.fraunhofer.de/amm/index.html\n"
+ "A_PCM/INT/BIG;PCM;Mk;A;PCM;;Linear PCM (Big Endian)\n"
+ "A_PCM/INT/LIT;PCM;Mk;A;PCM;;Linear PCM (Little Endian)\n"
+ "A_PCM/FLOAT/IEEE;PCM;Mk;A;PCM;;Microsoft Linear PCM, Float;http://www.microsoft.com/windows/\n"
+ "A_AC3;AC3;Mk;A;AC3;;Dolby AC3\n"
+ "A_AC3/BSID9;AC3;Mk;A;AC3;;Dolby AC3\n"
+ "A_AC3/BSID10;AC3;Mk;A;AC3;;Dolby AC3\n"
+ "A_DTS;DTS;Mk;A;DTS;;\n"
+ "A_EAC3;EAC3;Mk;A;EAC3;;Dolby Enhanced AC3\n"
+ "A_FLAC;Flac;Mk;A;Flac;;;http://flac.sourceforge.net\n"
+ "A_TTA1;TTA;Mk;A;TTA;;The True Audio Lossless Codec;http://true-audio.com\n"
+ "A_VORBIS;Vorbis;Mk;A;Vorbis;VBR;;http://www.vorbis.com\n"
+ "A_WAVPACK4;WavPack;Mk;A;Real;VBR;;http://www.wavpack.com\n"
+ "A_REAL/14_4;RealAudio 1;Mk;A;Real;;Real Audio 1 (14.4);http://www.real.com\n"
+ "A_REAL/28_8;RealAudio 2;Mk;A;Real;;Real Audio 2 (28.8);http://www.real.com\n"
+ "A_REAL/COOK;RealAudio 7;Mk;A;Real;;Real Audio Cook Codec (codename: Gecko);http://www.real.com\n"
+ "A_REAL/SIPR;RealAudio 4;Mk;A;Real;;Real & Sipro Voice Codec;http://www.real.com\n"
+ "A_REAL/RALF;RealAudio Lossless;Mk;A;Real;;Real Audio Lossless Format;http://www.real.com\n"
+ "A_REAL/ATRC;RealAudio Atrac3;Mk;A;Real;;Real & Sony Atrac3 Codec;http://www.real.com\n"
+ "A_AAC;AAC;Mk;A;AAC;;\n"
+ "A_AAC/MPEG2/MAIN;AAC Main;Mk;A;AAC;;AAC Main\n"
+ "A_AAC/MPEG2/LC;AAC LC;Mk;A;AAC;;AAC Low Complexity\n"
+ "A_AAC/MPEG2/LC/SBR;AAC LC-SBR;Mk;A;AAC;;AAC Low Complexity with Spectral Band Replication\n"
+ "A_AAC/MPEG2/SSR;AAC SSR;Mk;A;AAC;;AAC Scalable Sampling Rate\n"
+ "A_AAC/MPEG4/MAIN;AAC Main;Mk;A;AAC;;AAC Low Complexity\n"
+ "A_AAC/MPEG4/MAIN/SBR;AAC Main;Mk;A;AAC;;AAC Low Complexity with Spectral Band Replication\n"
+ "A_AAC/MPEG4/MAIN/SBR/PS;AAC Main;Mk;A;AAC;;AAC Low Complexity with Spectral Band Replication and Parametric Stereo\n"
+ "A_AAC/MPEG4/MAIN/PS;AAC Main;Mk;A;AAC;;AAC Low Complexity with Parametric Stereo\n"
+ "A_AAC/MPEG4/LC;AAC LC;Mk;A;AAC;;AAC Low Complexity\n"
+ "A_AAC/MPEG4/LC/SBR;AAC LC-SBR;Mk;A;AAC;;AAC Low Complexity with Spectral Band Replication\n"
+ "A_AAC/MPEG4/LC/SBR/PS;AAC LC-SBR-PS;Mk;A;AAC;;AAC Low Complexity with Spectral Band Replication and Parametric Stereo\n"
+ "A_AAC/MPEG4/LC/PS;AAC LC-PS;Mk;A;AAC;;AAC Low Complexity with Parametric Stereo\n"
+ "A_AAC/MPEG4/SSR;AAC SSR;Mk;A;AAC;;AAC Scalable Sampling Rate\n"
+ "A_AAC/MPEG4/LTP;AAC LTP;Mk;A;AAC;;AAC Long Term Prediction\n"
+ "14_4;VSELP;Real;A;;;EIA/TIA IS-54 VSELP, Real Audio 1 (for streaming 14.4 Kbps);http://www.real.com\n"
+ "14.4;VSELP;Real;A;;;EIA/TIA IS-54 VSELP, Real Audio 1 (for streaming 14.4 Kbps);http://www.real.com\n"
+ "lpcJ;VSELP;Real;A;;;EIA/TIA IS-54 VSELP, Real Audio 1 (for streaming 14.4 Kbps);http://www.real.com\n"
+ "28_8;G.728;Real;A;;;ITU-T G.728, Real Audio 2 (for streaming 28.8 Kbps);http://www.real.com\n"
+ "28.8;G.728;Real;A;;;ITU-T G.728, Real Audio 2 (for streaming 28.8 Kbps);http://www.real.com\n"
+ "cook;Cooker;Real;A;;;Real Audio G2/7 Cook (low bitrate);http://www.real.com\n"
+ "dnet;AC3;Real;A;AC3;;A52/AC3, Real Audio 2;http://www.real.com\n"
+ "sipr;G.729;Real;A;;;G.729, Real Audio 2;http://www.real.com\n"
+ "rtrc;RealAudio 8;Real;A;;;Real Audio 8 (RTRC);http://www.real.com\n"
+ "ralf;Lossless;Real;A;;;Real Audio Lossless Format;http://www.real.com\n"
+ "whrl;Multi-Channel;Real;A;;;Real Audio Multi-Channel;http://www.real.com\n"
+ "atrc;Atrac;Real;A;;;Real & Sony Atrac3;http://www.real.com\n"
+ "raac;AAC-LC;Real;A;AAC;;Real Audio 10 AAC LC;http://www.real.com\n"
+ "racp;AAC-HE;Real;A;AAC;;Real Audio 10 AAC-HE;http://www.real.com\n"
+ "Vorbis;Vorbis;Ogg;A;Vorbis;;;http://www.vorbis.com\n"
+ "Theora;Theora;Ogg;V;Theora;;;http://www.theora.com\n"
+ "mp4a;AAC;4CC;A;AAC;;AAC (3GPP);http://www.apple.com/quicktime/download/standalone.html\n"
+ "mp4v;MPEG-4;4CC;V;MPEG-4V;;MPEG-4 Video (3GPP);http://www.apple.com/quicktime/download/standalone.html\n"
+ "avc1;AVC;4CC;V;AVC;;Advanced Video Codec;http://www.apple.com/quicktime/download/standalone.html\n"
+ "h263;H.263;4CC;V;;;H.263 (3GPP);http://www.apple.com/quicktime/download/standalone.html\n"
+ "s263;H.263;4CC;V;;;H.263 (3GPP);http://www.apple.com/quicktime/download/standalone.html\n"
+ "samr;AMR-NB;4CC;A;;;AMR narrow band (3GPP);http://www.apple.com/quicktime/download/standalone.html\n"
+ "sawb;AMR-WB;4CC;A;;;AMR wide band (3GPP);http://www.apple.com/quicktime/download/standalone.html\n"
+ "sevc;EVRC;4CC;A;;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "tx3g;Timed;4CC;T;;;Timed text (3GPP);http://www.apple.com/quicktime/download/standalone.html\n"
+ "encv;Encrypted;4CC;V;;;Encrypted Video (3GPP);http://www.apple.com/quicktime/download/standalone.html\n"
+ "enca;Encrypted;4CC;A;;;Encrypted Audio (3GPP);http://www.apple.com/quicktime/download/standalone.html\n"
+ "enct;Encrypted;4CC;T;;;Encrypted Text (3GPP);http://www.apple.com/quicktime/download/standalone.html\n"
+ "ima4;ADPCM;4CC;A;ADPCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "raw ;PCM;4CC;A;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "twos;PCM;4CC;A;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "sowt;PCM;4CC;A;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "alac;Lossless;4CC;A;;;Apple Lossless Format (similar to FLAC);http://www.apple.com/quicktime/download/standalone.html\n"
+ "sac3;AC3;4CC;A;AC3;;AC3 in MP4 (made in Nero);http://www.nerodigital.com\n"
+ "in24;PCM;4CC;A;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "in32;PCM;4CC;A;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "fl32;PCM ;4CC;A;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "fl64;PCM;4CC;A;PCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "alaw;A-Law;4CC;A;ADPCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ "ulaw;U-Law;4CC;A;ADPCM;;;http://www.apple.com/quicktime/download/standalone.html\n"
+ ".mp3;MPEG-1/2 L3;2CC;A;MPEG-A;;MPEG-1 or 2 layer 3;http://www.iis.fraunhofer.de/amm/index.html\n"
+ "MPEG-4 AAC main;AAC Main;Mp4v2;A;AAC;;\n"
+ "MPEG-4 AAC LC;AAC LC;Mp4v2;A;AAC;;\n"
+ "MPEG-4 AAC SSR;AAC SSR;Mp4v2;A;AAC;;\n"
+ "MPEG-4 AAC LTP;AAC LTP;Mp4v2;A;AAC;;\n"
+ "AVC;AVC;MediaInfo;V;AVC;;Advanced Video Codec;http://developers.videolan.org/x264.html\n"
+ "MPEG-1V;MPEG-1 Video;MediaInfo;V;MPEG-V;;\n"
+ "MPEG-2V;MPEG-2 Video;MediaInfo;V;MPEG-V;;\n"
+ "MPEG-4V;MPEG-4 Visual;MediaInfo;V;MPEG-4V;;\n"
+ "MPEG-1A;MPEG-1 Audio;MediaInfo;A;MPEG-A;;\n"
+ "MPEG-1A L1;MPEG-1 Audio Layer 1;MediaInfo;A;MPEG-A;;\n"
+ "MPEG-1A L2;MPEG-1 Audio Layer 2;MediaInfo;A;MPEG-A;;\n"
+ "MPEG-1A L3;MPEG-1 Audio Layer 3;MediaInfo;A;MPEG-A;;\n"
+ "MPEG-2A;MPEG-2 Audio;MediaInfo;A;MPEG-A;;\n"
+ "MPEG-2A L1;MPEG-2 Audio Layer 1;MediaInfo;A;MPEG-A;;\n"
+ "MPEG-2A L2;MPEG-2 Audio Layer 2;MediaInfo;A;MPEG-A;;\n"
+ "MPEG-2A L3;MPEG-2 Audio Layer 3;MediaInfo;A;MPEG-A;;\n"
+ "MPEG-2.5A;MPEG-2.5 Audio;MediaInfo;A;MPEG-A;;;\n"
+ "MPEG-2.5A L1;MPEG-2.5 Audio Layer 1;MediaInfo;A;MPEG-A;;;\n"
+ "MPEG-2.5A L2;MPEG-2.5 Audio Layer 2;MediaInfo;A;MPEG-A;;;\n"
+ "MPEG-2.5A L3;MPEG-2.5 Audio Layer 3;MediaInfo;A;MPEG-A;;;\n"
+ "APE;Monkey's Audio;MediaInfo;A;;;;http://www.monkeysaudio.com/\n"
+ "ALS;ALS;MediaInfo;A;;;MPEG-4 Audio Lossless Coding;http://www.nue.tu-berlin.de/forschung/projekte/lossless/mp4als.html#downloads\n"
+ "Vodei;Vodei MP;MediaInfo;V;;;Video On Demand Exploration Interface;http://www.vodei.com\n"
+ "SWF ADPCM;ADPCM;MediaInfo;A;ADPCM;;ADPCM found in SWF/FLV files;http://www.adobe.com\n"
+ "AC3+;AC3+;MediaInfo;A;AC3;;Dolby Ehanced AC3;\n"
+ "TrueHD;TrueHD;MediaInfo;A;AC3;;Dolby TrueHD (AC3 based);\n"
+ "VC-1;VC-1;MediaInfo;V;VC-1;;;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx\n"
+ "LA;LA;MediaInfo;A;;;Lossless Audio Codec;la;http://www.lossless-audio.com/\n"
+ "0;Unknown;2CC;A;;;;\n"
+ "1;PCM;2CC;A;PCM;;Microsoft PCM;http://www.microsoft.com/windows/\n"
+ "2;ADPCM;2CC;A;ADPCM;;Microsoft ADPCM;http://www.microsoft.com/windows/\n"
+ "3;PCM;2CC;A;PCM;;IEEE FLOAT;http://www.microsoft.com/windows/\n"
+ "4;VSELP;2CC;A;;;Compaq VSELP\n"
+ "5;CVSD;2CC;A;;;IBM CVSD\n"
+ "6;A-Law;2CC;A;ADPCM;;CCITT A-Law;http://www.microsoft.com/windows/\n"
+ "7;U-Law;2CC;A;ADPCM;;CCITT U-Law;http://www.microsoft.com/windows/\n"
+ "8;DTS;2CC;A;DTS;;\n"
+ "9;DRM;2CC;A;;;Microsoft\n"
+ "A;WMSpeech;2CC;A;;;\n"
+ "C;MPEG2 5.1;2CC;A;;;MPEG2 5.1\n"
+ "10;ADPCM;2CC;A;ADPCM;;OKI ADPCM\n"
+ "11;ADPCM;2CC;A;ADPCM;;Intel ADPCM\n"
+ "12;ADPCM;2CC;A;ADPCM;;Mediaspace (Videologic) ADPCM\n"
+ "13;ADPCM;2CC;A;ADPCM;;Sierra ADPCM\n"
+ "14;ADPCM;2CC;A;ADPCM;;Antex G723 ADPCM\n"
+ "15;STD;2CC;A;;;DSP solutions Digi-STD\n"
+ "16;FIX;2CC;A;;;DSP solutions Digi-FIX\n"
+ "17;ADPCM;2CC;A;ADPCM;;Dialogic-OKI ADPCM;http://www.microsoft.com/windows/\n"
+ "18;ADPCM;2CC;A;ADPCM;;\n"
+ "19;CU;2CC;A;;;HP CU_CODEC\n"
+ "1A;Dynamic Voice;2CC;A;;;HP\n"
+ "20;ADPCM;2CC;A;ADPCM;;Yamaha ADPCM\n"
+ "21;SONARC;2CC;A;;;Speech Compression SONARC\n"
+ "22;Truespeech;2CC;A;;;DSP Group TrueSpeech;http://www.microsoft.com/windows/\n"
+ "23;SC1;2CC;A;;;Echo Speech SC1\n"
+ "24;AF36;2CC;A;;;Virtual Music AudioFile 36\n"
+ "25;APTX;2CC;A;;;Audio Processing Technology X\n"
+ "26;AF10;2CC;A;;;Virtual Music AudioFile 10\n"
+ "27;Prosody 1612;2CC;A;;;Aculab plc Prosody 1612\n"
+ "28;LRC;2CC;A;;;Merging Technologies LRC\n"
+ "30;AC2;2CC;A;;;Dolby Laboratories AC2\n"
+ "31;GSM 6.10;2CC;A;;;Microsoft GSM 6.10;http://www.microsoft.com/windows/\n"
+ "32;MSAUDIO;2CC;A;;;Microsoft Audio\n"
+ "33;ADPCM;2CC;A;ADPCM;;Antex ADPCM\n"
+ "34;VQLPC;2CC;A;;;Control Resources VQLPC\n"
+ "35;REAL;2CC;A;;;DSP Solutions Digi-REAL\n"
+ "36;ADPCM;2CC;A;ADPCM;;DSP Solutions Digi-ADPCM\n"
+ "37;CR10;2CC;A;;;Control Resources 10\n"
+ "38;ADPCM;2CC;A;ADPCM;;Natural MicroSystems VBX ADPCM\n"
+ "39;ADPCM;2CC;A;ADPCM;;Crystal Semiconductor IMA ADPCM\n"
+ "3A;SC3;2CC;A;;;Echo Speech SC3\n"
+ "3B;ADPCM;2CC;A;;;Rockwell ADPCM\n"
+ "3C;DigiTalk;2CC;A;;;Rockwell DigiTalk\n"
+ "3D;Xebec;2CC;A;;;Xebec Multimedia Solutions\n"
+ "40;ADPCM;2CC;A;ADPCM;;Antex Electronics G721 ADPCM\n"
+ "41;CELP;2CC;A;;;Antex Electronics G728 CELP\n"
+ "42;G.723.1;2CC;A;;;Microsoft G.723.1;http://www.microsoft.com/windows/\n"
+ "42;ADPCM;2CC;A;;;IBM\n"
+ "42;MSG729;2CC;A;;;Microsoft\n"
+ "45;ADPCM;2CC;A;ADPCM;;Microsoft G.726;http://www.microsoft.com/windows/\n"
+ "50;MPEG-1/2 L1;2CC;A;MPEG-1;;;http://www.iis.fraunhofer.de/amm/index.html\n"
+ "51;MPEG-1/2 L2;2CC;A;MPEG-1;;;http://www.iis.fraunhofer.de/amm/index.html\n"
+ "52;RT24;2CC;A;;;InSoft, Inc.\n"
+ "53;PAC;2CC;A;;;InSoft, Inc.\n"
+ "55;MPEG-1/2 L3;2CC;A;MPEG-1;;MPEG-1 or 2 layer 3;http://www.iis.fraunhofer.de/amm/index.html\n"
+ "59;G723;2CC;A;;;Lucent G723\n"
+ "60;Cirrus;2CC;A;;;Cirrus Logic\n"
+ "61;PCM;2CC;A;;;ESS Technology PCM\n"
+ "62;Voxware;2CC;A;;;\n"
+ "63;ATRAC;2CC;A;;;Canopus ATRAC\n"
+ "64;ADPCM;2CC;A;ADPCM;;APICOM G726 ADPCM\n"
+ "65;ADPCM;2CC;A;ADPCM;;APICOM G722 ADPCM\n"
+ "66;DSAT;2CC;A;;;Microsoft DSAT\n"
+ "67;DSAT Display;2CC;A;;;Microsoft DSAT DISPLAY\n"
+ "69;BYTE_ALIGNED;2CC;A;;;Voxware BYTE_ALIGNED;http://www.voxware.com/\n"
+ "70;AC8;2CC;A;;;Voxware AC8;http://www.voxware.com/\n"
+ "71;AC10;2CC;A;;;Voxware AC10;http://www.voxware.com/\n"
+ "72;AC16;2CC;A;;;Voxware AC16;http://www.voxware.com/\n"
+ "73;AC20;2CC;A;;;Voxware AC20;http://www.voxware.com/\n"
+ "74;RT24;2CC;A;;;Voxware RT24 (MetaVoice);http://www.voxware.com/\n"
+ "75;RT29;2CC;A;;;Voxware RT29 (MetaSound);http://www.voxware.com/\n"
+ "76;RT29HW;2CC;A;;;Voxware RT29HW;http://www.voxware.com/\n"
+ "77;VR12;2CC;A;;;Voxware VR12;http://www.voxware.com/\n"
+ "78;VR18;2CC;A;;;Voxware VR18;http://www.voxware.com/\n"
+ "79;TQ40;2CC;A;;;Voxware TQ40;http://www.voxware.com/\n"
+ "7A;SC3;2CC;A;;;Voxware\n"
+ "7B;SC3;2CC;A;;;Voxware\n"
+ "80;Softsound;2CC;A;;;\n"
+ "81;TQ60;2CC;A;;;Voxware TQ60;http://www.voxware.com/\n"
+ "82;MSRT24;2CC;A;;;Microsoft MSRT24\n"
+ "83;G729A;2CC;A;;;AT&T G729A\n"
+ "84;MVI_MVI2;2CC;A;;;Motion Pixels MVI_MVI2\n"
+ "85;ADPCM;2CC;A;ADPCM;;DataFusion Systems (Pty) G726\n"
+ "86;GSM6.10;2CC;A;;;DataFusion Systems (Pty) GSM6.10\n"
+ "88;ISI AUDIO;2CC;A;;;Iterated Systems AUDIO\n"
+ "89;Onlive;2CC;A;;;OnLive! Technologies\n"
+ "8A;SX20;2CC;A;;;Multitude\n"
+ "8B;ADPCM;2CC;A;ADPCM;;Infocom ITS A/S\n"
+ "8C;G.729;2CC;A;;;Convedia Corporation\n"
+ "91;SBC24;2CC;A;;;Siemens Business Communications Sys 24\n"
+ "92;AC3 SPDIF;2CC;A;;;Sonic Foundry AC3 SPDIF\n"
+ "93;G723;2CC;A;;;MediaSonic G723\n"
+ "94;Prosody 8KBPS;2CC;A;;;Aculab plc Prosody 8KBPS\n"
+ "97;ADPCM;2CC;A;ADPCM;;ZyXEL Communications ADPCM\n"
+ "98;LPCBB;2CC;A;;;Philips Speech Processing LPCBB\n"
+ "99;Packed;2CC;A;;;Studer Professional Audio AG Packed\n"
+ "A0;PHONYTALK;2CC;A;;;Malden Electronics PHONYTALK\n"
+ "A1;GSM;2CC;A;;;Racal Recorders\n"
+ "A2;G.720a;2CC;A;;;Racal Recorders\n"
+ "A3;G.723.1;2CC;A;;;Racal Recorders\n"
+ "A4;ACELP;2CC;A;;;Racal Recorders\n"
+ "B0;AAC;2CC;A;AAC;;NEC Corporation\n"
+ "FF;AAC;2CC;A;AAC;;\n"
+ "100;ADPCM;2CC;A;ADPCM;;\n"
+ "101;IRAT;2CC;A;;;BeCubed IRAT\n"
+ "102;;2CC;A;;;IBM A-law\n"
+ "103;;2CC;A;;;IBM AVC ADPCM\n"
+ "111;G723;2CC;A;;;Vivo G723\n"
+ "112;SIREN;2CC;A;;;Vivo SIREN\n"
+ "120;CELP;2CC;A;;;Philips Speech Processing\n"
+ "121;Grundig;2CC;A;;;Philips Speech Processing\n"
+ "123;G723;2CC;A;;;Digital Equipment Corporation (DEC) G723\n"
+ "125;ADPCM;2CC;A;ADPCM;;\n"
+ "130;ACEPL;2CC;A;;;Sipro ACEPL.net;http://dividix.host.sk\n"
+ "131;ACELP4800;2CC;A;;;Sipro ACELP4800\n"
+ "132;ACELP8V3;2CC;A;;;Sipro ACELP8V3\n"
+ "133;G729;2CC;A;;;Sipro G729\n"
+ "134;G729;2CC;A;;;Sipro G729A\n"
+ "135;KELVIN;2CC;A;;;Sipro KELVIN\n"
+ "135;AMR;2CC;A;;;VoiceAge Corporation\n"
+ "140;ADPCM;2CC;A;ADPCM;;Dictaphone Corporation G726 ADPCM\n"
+ "140;CELP68;2CC;A;;;Dictaphone Corporation\n"
+ "140;CELP54;2CC;A;;;Dictaphone Corporation\n"
+ "150;PureVoice;2CC;A;;;Qualcomm PUREVOICE\n"
+ "151;HalfRate;2CC;A;;;Qualcomm HALFRATE\n"
+ "155;TUBGSM;2CC;A;;;Ring Zero Systems TUBGSM\n"
+ "160;WMA1;2CC;A;;;Windows Media Audio 1;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx\n"
+ "161;WMA2;2CC;A;;;Windows Media Audio 2;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx\n"
+ "162;WMA3;2CC;A;;;Windows Media Audio 3;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx\n"
+ "163;WMA Lossless;2CC;A;;;Windows Media Audio 3;http://www.microsoft.com/windows/windowsmedia/format/codecdownload.aspx\n"
+ "163;WMA Pro;2CC;A;;;WMA Pro over S/PDIF\n"
+ "170;ADPCM;2CC;A;ADPCM;;Unisys Nap ADPCM\n"
+ "171;U-Law;2CC;A;ADPCM;;Unisys Nap U-law\n"
+ "172;A-Law;2CC;A;ADPCM;;Unisys Nap A-law\n"
+ "173;16K;2CC;A;;;Unisys Nap 16K\n"
+ "174;G.700;2CC;A;;;SyCom Technologies\n"
+ "175;ADPCM;2CC;A;ADPCM;;SyCom Technologies\n"
+ "176;CELP54;2CC;A;;;SyCom Technologies\n"
+ "177;CELP68;2CC;A;;;SyCom Technologies\n"
+ "178;ADPCM;2CC;A;ADPCM;;Knowledge Adventure, Inc.\n"
+ "180;AAC;2CC;A;;;Fraunhofer IIS\n"
+ "190;DTS;2CC;A;;\n"
+ "200;ADPCM;2CC;A;ADPCM;;Creative Labs ADPCM\n"
+ "202;FastSpeech8;2CC;A;;;Creative Labs Fast Speech 8\n"
+ "203;FastSpeech10;2CC;A;;;Creative Labs Fast Speech 10\n"
+ "210;ADPCM;2CC;A;ADPCM;;UHER informatic GmbH ADPCM\n"
+ "215;;2CC;A;;;Ulead DV ACM\n"
+ "216;;2CC;A;;;Ulead DV ACM\n"
+ "220;QuaterDeck;2CC;A;;;Quarterdeck\n"
+ "230;VC;2CC;A;;;I-link VC\n"
+ "240;RAW_SPORT;2CC;A;;;Aureal RAW_SPORT\n"
+ "241;AC3;2CC;A;;;ESST AC3\n"
+ "250;HSX;2CC;A;;;Interactive Products, Inc. (IPI) HSX\n"
+ "251;RPELP;2CC;A;;;Interactive Products, Inc. (IPI) RPELP\n"
+ "260;CS2;2CC;A;;;Consistent Software CS2\n"
+ "270;SCX;2CC;A;;;Sony\n"
+ "271;SCY;2CC;A;;;Sony\n"
+ "272;Atrac3;2CC;A;;;Sony\n"
+ "273;SPC;2CC;A;;;Sony\n"
+ "280;Telum;2CC;A;;\n"
+ "281;TelumIA;2CC;A;;\n"
+ "285;ADPCM;2CC;A;ADPCM;;Norcom Voice Systems\n"
+ "300;FM_TOWNS_SND;2CC;A;;;Fujitsu FM_TOWNS_SND\n"
+ "350;Dev;2CC;A;;;Micronas Semiconductors, Inc.\n"
+ "351;CELP833;2CC;A;;;Micronas Semiconductors, Inc.\n"
+ "400;BTV_DIGITAL;2CC;A;;;Brooktree (BTV) DIGITAL\n"
+ "401;Music Coder;2CC;A;;;Intel Music Coder;http://www.intel.com/\n"
+ "402;IAC2;2CC;A;;;Ligos IAC2;http://www.ligos.com\n"
+ "450;Qdesign;2CC;A;;;QDesign Music\n"
+ "500;VP7;2CC;A;;;On2\n"
+ "501;VP6;2CC;A;;;On2\n"
+ "680;VMPCM;2CC;A;;;AT&T VME_VMPCM\n"
+ "681;TPC;2CC;A;;;AT&T TPC\n"
+ "700;YMPEG;2CC;A;;;YMPEG Alpha\n"
+ "8AE;LiteWave;2CC;A;;;ClearJump LiteWave\n"
+ "AAC;AAC;2CC;A;AAC;;\n"
+ "1000;GSM;2CC;A;;;Ing C. Olivetti & C., S.p.A. GSM\n"
+ "1001;ADPCM;2CC;A;ADPCM;;Ing C. Olivetti & C., S.p.A. ADPCM\n"
+ "1002;CELP;2CC;A;;;Ing C. Olivetti & C., S.p.A. CELP\n"
+ "1003;SBC;2CC;A;;;Ing C. Olivetti & C., S.p.A. SBC\n"
+ "1004;OPR;2CC;A;;;Ing C. Olivetti & C., S.p.A. OPR\n"
+ "1100;LH_CODEC;2CC;A;;;Lernout & Hauspie Codec\n"
+ "1101;CELP;2CC;A;;;Lernout & Hauspie CELP 4.8 kb/s;http://www.microsoft.com/windows/\n"
+ "1102;SBC;2CC;A;;;Lernout & Hauspie SBC 8 kb/s;http://www.microsoft.com/windows/\n"
+ "1103;SBC;2CC;A;;;Lernout & Hauspie SBC 12 kb/s;http://www.microsoft.com/windows/\n"
+ "1104;SBC;2CC;A;;;Lernout & Hauspie SBC 16 kb/s;http://www.microsoft.com/windows/\n"
+ "1400;NORRIS;2CC;A;;;Norris Communications, Inc.\n"
+ "1401;ISIAUDIO;2CC;A;;;ISIAudio\n"
+ "1500;MUSICOMPRESS;2CC;A;;;Soundspace Music Compression\n"
+ "181C;RT24;2CC;A;;;VoxWare RT24 speech codec\n"
+ "181E;AX24000P;2CC;A;;;Lucent elemedia AX24000P Music codec\n"
+ "1971;SonicFoundry;2CC;A;;;Lossless\n"
+ "1C03;ADPCM;2CC;A;ADPCM;;Lucent SX5363S G.723 compliant codec\n"
+ "1C07;SX8300P;2CC;A;;;Lucent SX8300P speech codec\n"
+ "1C0C;ADPCM;2CC;A;ADPCM;;Lucent SX5363S G.723 compliant codec\n"
+ "1F03;DigiTalk;2CC;A;;;CUseeMe DigiTalk (ex-Rocwell)\n"
+ "1FC4;ALF2CD;2CC;A;;;NCT Soft ALF2CD ACM\n"
+ "2000;AC3;2CC;A;AC3;CBR;Dolby AC3\n"
+ "2001;DTS;2CC;A;DTS;;Digital Theater Systems\n"
+ "2002;Real Audio 1;2CC;A;;;RealAudio 1/2 14.4\n"
+ "2003;Real Audio 1;2CC;A;;;RealAudio 1/2 28.8\n"
+ "2004;Real Audio 2;2CC;A;;;RealAudio G2/8 Cook (low bitrate)\n"
+ "2005;Real Audio 3;2CC;A;;;RealAudio 3/4/5 Music (DNET)\n"
+ "2006;AAC;2CC;A;AAC;;RealAudio 10 AAC (RAAC)\n"
+ "2007;AAC+;2CC;A;AAC;;RealAudio 10 AAC+ (RACP)\n"
+ "3313;AviSynth;2CC;A;;;makeAVIS (fake AVI sound from AviSynth scripts)\n"
+ "4143;AAC;2CC;A;AAC;;Divio MPEG-4 AAC audio\n"
+ "4201;Nokia;2CC;A;;\n"
+ "4243;ADPCM;2CC;A;ADPCM;;G726\n"
+ "43AC;Lead Speech;2CC;A;;\n"
+ "564C;Lead Vorbis;2CC;A;;;\n"
+ "566F;Vorbis;2CC;A;Vorbis;;;http://www.vorbis.com\n"
+ "5756;WavPack;2CC;A;;;;http://www.wavpack.com/\n"
+ "674F;Vorbis;2CC;A;Vorbis;;Mode 1;http://www.vorbis.com\n"
+ "6750;Vorbis;2CC;A;Vorbis;;Mode 2;http://www.vorbis.com\n"
+ "6751;Vorbis;2CC;A;Vorbis;;Mode 3;http://www.vorbis.com\n"
+ "676F;Vorbis;2CC;A;Vorbis;;Mode 1+;http://www.vorbis.com\n"
+ "6770;Vorbis;2CC;A;Vorbis;;Mode 2+;http://www.vorbis.com\n"
+ "6771;Vorbis;2CC;A;Vorbis;;Mode 2+;http://www.vorbis.com\n"
+ "7A21;AMR;2CC;A;;CBR;GSM-AMR (CBR, no SID);http://www.microsoft.com\n"
+ "7A22;AMR;2CC;A;;VBR;GSM-AMR (VBR, including SID);http://www.microsoft.com\n"
+ "A100;G723.1;2CC;A;;;\n"
+ "A101;AVQSBC;2CC;A;;;\n"
+ "A102;ODSBC;2CC;A;;;\n"
+ "A103;G729A;2CC;A;;;\n"
+ "A104;AMR-WB;2CC;A;;;\n"
+ "A105;ADPCM;2CC;A;ADPCM;;G726\n"
+ "A106;AAC;2CC;A;;;\n"
+ "A107;ADPCM;2CC;A;ADPCM;;G726\n"
+ "A109;Speex;2CC;A;;;;http://www.speex.org/\n"
+ "DFAC;FrameServer;2CC;A;;;DebugMode SonicFoundry Vegas FrameServer ACM Codec\n"
+ "F1AC;FLAC;2CC;A;;;Free Lossless Audio Codec FLAC\n"
+ "FFFE;PCM;2CC;A;PCM;;Extensible wave format\n"
+ "FFFF;In Development;2CC;A;;;In Development / Unregistered\n"
+ "S_TEXT/UTF8;UTF-8;Mk;T;;;UTF-8 Plain Text\n"
+ "S_TEXT/SSA;SSA;Mk;T;;;Sub Station Alpha\n"
+ "S_TEXT/ASS;ASS;Mk;T;;;Advanced Sub Station Alpha\n"
+ "S_TEXT/USF;USF;Mk;T;;;Universal Subtitle Format\n"
+ "S_IMAGE/BMP;Bitmap;Mk;T;;;Basic image based subtitle format\n"
+ "S_VOBSUB;VobSub;Mk;T;;;The same subtitle format used on DVDs\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Generic (ZtringListList &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "Format\n"
+ "Format/Info\n"
+ "Format/Url\n"
+ "Format_Commercial\n"
+ "Format_Commercial_IfAny\n"
+ "Format_Version\n"
+ "Format_Profile\n"
+ "Format_Compression\n"
+ "Format_Settings\n"
+ "InternetMediaType\n"
+ "CodecID\n"
+ "CodecID/Info\n"
+ "CodecID/Hint\n"
+ "CodecID/Url\n"
+ "CodecID_Description\n"
+ "Codec\n"
+ "Codec/String\n"
+ "Codec/Info\n"
+ "Codec/Url\n"
+ "Codec/CC\n"
+ "Duration\n"
+ "Duration/String\n"
+ "Duration/String1\n"
+ "Duration/String2\n"
+ "Duration/String3\n"
+ "Source_Duration\n"
+ "Source_Duration/String\n"
+ "Source_Duration/String1\n"
+ "Source_Duration/String2\n"
+ "Source_Duration/String3\n"
+ "BitRate_Mode\n"
+ "BitRate_Mode/String\n"
+ "BitRate\n"
+ "BitRate/String\n"
+ "BitRate_Minimum\n"
+ "BitRate_Minimum/String\n"
+ "BitRate_Nominal\n"
+ "BitRate_Nominal/String\n"
+ "BitRate_Maximum\n"
+ "BitRate_Maximum/String\n"
+ "BitRate_Encoded\n"
+ "BitRate_Encoded/String\n"
+ "FrameCount\n"
+ "Source_FrameCount\n"
+ "ColorSpace\n"
+ "ChromaSubsampling\n"
+ "Resolution\n"
+ "Resolution/String\n"
+ "BitDepth\n"
+ "BitDepth/String\n"
+ "Compression_Mode\n"
+ "Compression_Mode/String\n"
+ "Compression_Ratio\n"
+ "Delay\n"
+ "Delay/String\n"
+ "Delay/String1\n"
+ "Delay/String2\n"
+ "Delay/String3\n"
+ "Delay/String4\n"
+ "Delay_Settings\n"
+ "Delay_Source\n"
+ "Delay_Source/String\n"
+ "Delay_Original\n"
+ "Delay_Original/String\n"
+ "Delay_Original/String1\n"
+ "Delay_Original/String2\n"
+ "Delay_Original/String3\n"
+ "Delay_Original/String4\n"
+ "Delay_Original_Settings\n"
+ "Delay_Original_Source\n"
+ "Video_Delay\n"
+ "Video_Delay/String\n"
+ "Video_Delay/String1\n"
+ "Video_Delay/String2\n"
+ "Video_Delay/String3\n"
+ "Video_Delay/String4\n"
+ "StreamSize\n"
+ "StreamSize/String\n"
+ "StreamSize/String1\n"
+ "StreamSize/String2\n"
+ "StreamSize/String3\n"
+ "StreamSize/String4\n"
+ "StreamSize/String5\n"
+ "StreamSize_Proportion\n"
+ "Source_StreamSize\n"
+ "Source_StreamSize/String\n"
+ "Source_StreamSize/String1\n"
+ "Source_StreamSize/String2\n"
+ "Source_StreamSize/String3\n"
+ "Source_StreamSize/String4\n"
+ "Source_StreamSize/String5\n"
+ "Source_StreamSize_Proportion\n"
+ "StreamSize_Encoded\n"
+ "StreamSize_Encoded/String\n"
+ "StreamSize_Encoded/String1\n"
+ "StreamSize_Encoded/String2\n"
+ "StreamSize_Encoded/String3\n"
+ "StreamSize_Encoded/String4\n"
+ "StreamSize_Encoded/String5\n"
+ "StreamSize_Encoded_Proportion\n"
+ "Source_StreamSize_Encoded\n"
+ "Source_StreamSize_Encoded/String\n"
+ "Source_StreamSize_Encoded/String1\n"
+ "Source_StreamSize_Encoded/String2\n"
+ "Source_StreamSize_Encoded/String3\n"
+ "Source_StreamSize_Encoded/String4\n"
+ "Source_StreamSize_Encoded/String5\n"
+ "Source_StreamSize_Encoded_Proportion\n"
+ "Language\n"
+ "ServiceName\n"
+ "ServiceProvider\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_General (ZtringListList &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "Count;;;N NI;;;Number of objects available in this stream\n"
+ "Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished)\n"
+ "StreamCount;;;N NI;;;Number of streams of this kind available\n"
+ "StreamKind;General;;N NI;;;Stream type name\n"
+ "StreamKind/String;;;N NI;;;Stream type name\n"
+ "StreamKindID;;;N NI;;;Number of the stream (base=0)\n"
+ "StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1)\n"
+ "StreamOrder;;;N NI;;;Stream order in the file, whatever is the kind of stream (base=0)\n"
+ "Inform;;;N NT;;;Last **Inform** call\n"
+ "ID;;;N YI;;;The ID for this stream in this file\n"
+ "ID/String;;;Y NT;;;The ID for this stream in this file\n"
+ "UniqueID;;;N YI;;;The unique ID for this stream, should be copied with stream copy\n"
+ "UniqueID/String;;;Y NT;;;A unique ID for this stream, should be copied with stream copy\n"
+ "MenuID;;;N YI;;;The menu ID for this stream in this file\n"
+ "MenuID/String;;;Y NT;;;The menu ID for this stream in this file\n"
+ "GeneralCount;1;;N NI;;;Number of general streams\n"
+ "VideoCount;;;N NI;;;Number of video streams\n"
+ "AudioCount;;;N NI;;;Number of audio streams\n"
+ "TextCount;;;N NI;;;Number of text streams\n"
+ "ChaptersCount;;;N NI;;;Number of chapters streams\n"
+ "ImageCount;;;N NI;;;Number of image streams\n"
+ "MenuCount;;;N NI;;;Number of menu streams\n"
+ "Video_Format_List;;;N NT;;;Video Codecs in this file, separated by /\n"
+ "Video_Format_WithHint_List;;;N NT;;;Video Codecs in this file with popular name (hint), separated by /\n"
+ "Video_Codec_List;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Video_Language_List;;;N NT;;;Video languagesin this file, full names, separated by /\n"
+ "Audio_Format_List;;;N NT;;;Audio Codecs in this file,separated by /\n"
+ "Audio_Format_WithHint_List;;;N NT;;;Audio Codecs in this file with popular name (hint), separated by /\n"
+ "Audio_Codec_List;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Audio_Language_List;;;N NT;;;Audio languages in this file separated by /\n"
+ "Text_Format_List;;;N NT;;;Text Codecs in this file, separated by /\n"
+ "Text_Format_WithHint_List;;;N NT;;;Text Codecs in this file with popular name (hint),separated by /\n"
+ "Text_Codec_List;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Text_Language_List;;;N NT;;;Text languages in this file, separated by /\n"
+ "Chapters_Format_List;;;N NT;;;Chapters Codecs in this file, separated by /\n"
+ "Chapters_Format_WithHint_List;;;N NT;;;Chapters Codecs in this file with popular name (hint), separated by /\n"
+ "Chapters_Codec_List;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Chapters_Language_List;;;N NT;;;Chapters languages in this file, separated by /\n"
+ "Image_Format_List;;;N NT;;;Image Codecs in this file, separated by /\n"
+ "Image_Format_WithHint_List;;;N NT;;;Image Codecs in this file with popular name (hint), separated by /\n"
+ "Image_Codec_List;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Image_Language_List;;;N NT;;;Image languages in this file, separated by /\n"
+ "Menu_Format_List;;;N NT;;;Menu Codecsin this file, separated by /\n"
+ "Menu_Format_WithHint_List;;;N NT;;;Menu Codecs in this file with popular name (hint),separated by /\n"
+ "Menu_Codec_List;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Menu_Language_List;;;N NT;;;Menu languages in this file, separated by /\n"
+ "CompleteName;;;Y NT;;;Complete name (Folder+Name+Extension)\n"
+ "FolderName;;;N NT;;;Folder name only\n"
+ "FileName;;;N NT;;;File name only\n"
+ "FileExtension;;;N NT;;;File extension only\n"
+ "Format;;;Y YT;;;Format used\n"
+ "Format/String;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Format/Info;;;Y NT;;;Info about this Format\n"
+ "Format/Url;;;N NT;;;Link to a description of this format\n"
+ "Format/Extensions;;;N NT;;;Known extensions of this format\n"
+ "Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference\n"
+ "Format_Commercial_IfAny;;;Y NT;;;Commercial name used by vendor for theses setings if there is one\n"
+ "Format_Version;;;Y NT;;;Version of this format\n"
+ "Format_Profile;;;Y NT;;;Profile of the Format\n"
+ "Format_Compression;;;Y NT;;;Compression method used;\n"
+ "Format_Settings;;;Y NT;;;Settings needed for decoder used\n"
+ "InternetMediaType;;;N YT;;;Internet Media Type (aka MIME Type, Content-Type)\n"
+ "CodecID;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/String;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/Info;;;Y NT;;;Info about this codec\n"
+ "CodecID/Hint;;;Y NT;;;A hint/popular name for this codec\n"
+ "CodecID/Url;;;N NT;;;A link to more details about this codec ID\n"
+ "CodecID_Description;;;Y NT;;;Manual description given by the container\n"
+ "Interleaved;;;N NT;;;If Audio and video are muxed\n"
+ "Codec;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/String;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/Info;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/Url;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/Extensions;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings_Automatic;;;N NT;;;Deprecated, do not use in new projects\n"
+ "FileSize;; byte;N NT;;;File size in bytes\n"
+ "FileSize/String;;;Y NT;;;File size (with measure)\n"
+ "FileSize/String1;;;N NT;;;File size (with measure, 1 digit mini)\n"
+ "FileSize/String2;;;N NT;;;File size (with measure, 2 digit mini)\n"
+ "FileSize/String3;;;N NT;;;File size (with measure, 3 digit mini)\n"
+ "FileSize/String4;;;N NT;;;File size (with measure, 4 digit mini)\n"
+ "Duration;; ms;N YI;;;Play time of the stream in ms\n"
+ "Duration/String;;;Y NT;;;Play time in format : XXx YYy only, YYy omited if zero\n"
+ "Duration/String1;;;N NT;;;Play time in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Duration/String2;;;N NT;;;Play time in format : XXx YYy only, YYy omited if zero\n"
+ "Duration/String3;;;N NT;;;Play time in format : HH:MM:SS.MMM\n"
+ "Duration_Start;;;Y YT;;\n"
+ "Duration_End;;;Y YT;;\n"
+ "OverallBitRate_Mode;;;N YT;;;Bit rate mode of all streams (VBR, CBR)\n"
+ "OverallBitRate_Mode/String;;;Y NT;;;Bit rate mode of all streams (Variable, Constant)\n"
+ "OverallBitRate;; bps;N YF;;;Bit rate of all streams in bps\n"
+ "OverallBitRate/String;;;Y NT;;;Bit rate of all streams (with measure)\n"
+ "OverallBitRate_Minimum;; bps;N YF;;;Minimum Bit rate in bps\n"
+ "OverallBitRate_Minimum/String;;;Y NT;;;Minimum Bit rate (with measurement)\n"
+ "OverallBitRate_Nominal;; bps;N YF;;;Nominal Bit rate in bps\n"
+ "OverallBitRate_Nominal/String;;;Y NT;;;Nominal Bit rate (with measurement)\n"
+ "OverallBitRate_Maximum;; bps;N YF;;;Maximum Bit rate in bps\n"
+ "OverallBitRate_Maximum/String;;;Y NT;;;Maximum Bit rate (with measurement)\n"
+ "Delay;; ms;N NI;;;Delay fixed in the stream (relative) IN MS\n"
+ "Delay/String;;;N NT;;;Delay with measurement\n"
+ "Delay/String1;;;N NT;;;Delay with measurement\n"
+ "Delay/String2;;;N NT;;;Delay with measurement\n"
+ "Delay/String3;;;N NT;;;format : HH:MM:SS.MMM\n"
+ "StreamSize;; byte;N YI;;;Stream size in bytes\n"
+ "StreamSize/String;;;N NT;;\n"
+ "StreamSize/String1;;;N NT;;\n"
+ "StreamSize/String2;;;N NT;;\n"
+ "StreamSize/String3;;;N NT;;\n"
+ "StreamSize/String4;;;N NT;;\n"
+ "StreamSize/String5;;;N NT;;;With proportion\n"
+ "StreamSize_Proportion;;;N NT;;;Stream size divided by file size\n"
+ "HeaderSize;;;N NI;;\n"
+ "DataSize;;;N NI;;\n"
+ "FooterSize;;;N NI;;\n"
+ "IsStreamable;;;N NT;;\n"
+ "Album_ReplayGain_Gain;; dB;N YT;;;The gain to apply to reach 89dB SPL on playback\n"
+ "Album_ReplayGain_Gain/String;;;Y YT;;\n"
+ "Album_ReplayGain_Peak;;;Y YT;;;The maximum absolute peak value of the item;\n"
+ "Encryption;;;Y YT;;;;\n"
+ "Title;;;N NT;;;(Generic)Title of file;;Title\n"
+ "Title/More;;;N NT;;;(Generic)More info about the title of file;;Title\n"
+ "Title/Url;;;N NT;;;(Generic)Url;;Title\n"
+ "Domain;;;Y YT;;;Univers movies belong to, e.g. Starwars, Stargate, Buffy, Dragonballs;;Title\n"
+ "Collection;;;Y YT;;;Name of the series, e.g. Starwars movies, Stargate SG-1, Stargate Atlantis, Buffy, Angel;;Title\n"
+ "Season;;;Y YT;;;Name of the season, e.g. Strawars first Trilogy, Season 1;;Title\n"
+ "Season_Position;;;Y YI;;;Number of the Season;;Title\n"
+ "Season_Position_Total;;;Y YI;;;Place of the season e.g. 2 of 7;;Title\n"
+ "Movie;;;Y YT;;;Name of the movie. Eg : Starwars, a new hope;;Title\n"
+ "Movie/More;;;Y YT;;;More infos about the movie;;Title\n"
+ "Movie/Country;;;Y YT;;;Country, where the movie was procuced;;Title\n"
+ "Movie/Url;;;Y YT;;;Homepage for the movie;;Title\n"
+ "Album;;;Y YT;;;Name of an audio-album. Eg : The joshua tree;;Title\n"
+ "Album/More;;;Y YT;;;More infos about the album;;Title\n"
+ "Album/Sort;;;Y YT;;;;;Title\n"
+ "Album/Performer;;;Y YT;;;Album performer/artist of this file;;Entity\n"
+ "Album/Performer/Sort;;;Y YT;;;;;Entity\n"
+ "Album/Performer/Url;;;Y YT;;;Homepage of the album performer/artist;;Entity\n"
+ "Comic;;;Y YT;;;Name of the comic.;;Title\n"
+ "Comic/More;;;Y YT;;;;;Title\n"
+ "Comic/Position_Total;;;Y YI;;;;;Title\n"
+ "Part;;;Y YT;;;Name of the part. e.g. CD1, CD2;;Title\n"
+ "Part/Position;;;Y YI;;;Number of the part;;Title\n"
+ "Part/Position_Total;;;Y YI;;;Place of the part e.g. 2 of 3;;Title\n"
+ "Track;;;Y YT;;;Name of the track. e.g. track1, track 2;;Title\n"
+ "Track/More;;;Y YT;;;More infos about the track;;Title\n"
+ "Track/Url;;;Y YT;;;Link to a site about this track;;Title\n"
+ "Track/Sort;;;Y YT;;;;;Title\n"
+ "Track/Position;;;Y YI;;;Number of this track;;Title\n"
+ "Track/Position_Total;;;Y YI;;;Place of this track, e.g. 3 of 15;;Title\n"
+ "Grouping;;;Y YT;;;iTunes grouping;;Title\n"
+ "Chapter;;;Y YT;;;Name of the chapter.;;Title\n"
+ "SubTrack;;;Y YT;;;Name of the subtrack.;;Title\n"
+ "Original/Album;;;Y YT;;;Original name of album, serie...;;Title\n"
+ "Original/Movie;;;Y YT;;;Original name of the movie;;Title\n"
+ "Original/Part;;;Y YT;;;Original name of the part in the original support;;Title\n"
+ "Original/Track;;;Y YT;;;Original name of the track in the original support;;Title\n"
+ "Compilation;;;Y YT;;;iTunes compilation;;Title\n"
+ "Compilation/String;;Yes;Y YT;;;iTunes compilation;;Title\n"
+ "Performer;;;Y YT;;;Main performer/artist of this file;;Entity\n"
+ "Performer/Sort;;;Y YT;;;;;Entity\n"
+ "Performer/Url;;;Y YT;;;Homepage of the performer/artist;;Entity\n"
+ "Original/Performer;;;Y YT;;;Original artist(s)/performer(s).;;Entity\n"
+ "Accompaniment;;;Y YT;;;Band/orchestra/accompaniment/musician.;;Entity\n"
+ "Composer;;;Y YT;;;Name of the original composer.;;Entity\n"
+ "Composer/Nationality;;;Y YT;;;Nationality of the main composer of the item, mostly for classical music.;;Entity\n"
+ "Arranger;;;Y YT;;;The person who arranged the piece. e.g. Ravel.;;Entity\n"
+ "Lyricist;;;Y YT;;;The person who wrote the lyrics for a musical item.;;Entity\n"
+ "Original/Lyricist;;;Y YT;;;Original lyricist(s)/text writer(s).;;Entity\n"
+ "Conductor;;;Y YT;;;The artist(s) who performed the work. In classical music this would be the conductor, orchestra, soloists.;;Entity\n"
+ "Director;;;Y YT;;;Name of the director.;;Entity\n"
+ "AssistantDirector;;;Y YT;;;Name of the assistant director.;;Entity\n"
+ "DirectorOfPhotography;;;Y YT;;;The name of the director of photography, also known as cinematographer.;;Entity\n"
+ "SoundEngineer;;;Y YT;;;The name of the sound engineer or sound recordist.;;Entity\n"
+ "ArtDirector;;;Y YT;;;The person who oversees the artists and craftspeople who build the sets.;;Entity\n"
+ "ProductionDesigner;;;Y YT;;;The person responsible for designing the Overall visual appearance of a movie.;;Entity\n"
+ "Choregrapher;;;Y YT;;;The name of the choregrapher.;;Entity\n"
+ "CostumeDesigner;;;Y YT;;;The name of the costume designer.;;Entity\n"
+ "Actor;;;Y YT;;;Real name of an actor or actress playing a role in the movie.;;Entity\n"
+ "Actor_Character;;;Y YT;;;Name of the character an actor or actress plays in this movie.;;Entity\n"
+ "WrittenBy;;;Y YT;;;The author of the story or script.;;Entity\n"
+ "ScreenplayBy;;;Y YT;;;The author of the screenplay or scenario (used for movies and TV shows).;;Entity\n"
+ "EditedBy;;;Y YT;;;Editors name;;Entity\n"
+ "CommissionedBy;;;Y YT;;;name of the person or organization that commissioned the subject of the file;;Entity\n"
+ "Producer;;;Y YT;;;Name of the producer of the movie.;;Entity\n"
+ "CoProducer;;;Y YT;;;The name of a co-producer.;;Entity\n"
+ "ExecutiveProducer;;;Y YT;;;The name of an executive producer.;;Entity\n"
+ "MusicBy;;;Y YT;;;Main music-artist for a movie;;Entity\n"
+ "DistributedBy;;;Y YT;;;Company the item is mainly distributed by ;;Entity\n"
+ "OriginalSourceForm/DistributedBy;;;Y YT;;;Name of the person or organization who supplied the original subject;;Entity\n"
+ "MasteredBy;;;Y YT;;;The engineer who mastered the content for a physical medium or for digital distribution.;;Entity\n"
+ "EncodedBy;;;Y YT;;;Name of the person or organisation that encoded/ripped the audio file.;;Entity\n"
+ "RemixedBy;;;Y YT;;;Name of the artist(s), that interpreted, remixed, or otherwise modified the item.;;Entity\n"
+ "ProductionStudio;;;Y YT;;;Main production studio ;;Entity\n"
+ "ThanksTo;;;Y YT;;;A very general tag for everyone else that wants to be listed.;;Entity\n"
+ "Publisher;;;Y YT;;;Name of the organization publishing the album (i.e. the 'record label') or movie.;;Entity\n"
+ "Publisher/URL;;;Y YT;;;Publishers official webpage.;;Entity\n"
+ "Label;;;Y YT;;;Brand or trademark associated with the marketing of music recordings and music videos.;;Entity\n"
+ "Genre;;;Y YT;;;The main genre of the audio or video. e.g. classical, ambient-house, synthpop, sci-fi, drama, etc.;;Classification\n"
+ "Mood;;;Y YT;;;Intended to reflect the mood of the item with a few keywords, e.g. Romantic, Sad, Uplifting, etc.;;Classification\n"
+ "ContentType;;;Y YT;;;The type of the item. e.g. Documentary, Feature Film, Cartoon, Music Video, Music, Sound FX, etc.;;Classification\n"
+ "Subject;;;Y YT;;;Describes the topic of the file, such as Aerial view of Seattle..;;Classification\n"
+ "Description;;;Y YT;;;A short description of the contents, such as Two birds flying.;;Classification\n"
+ "Keywords;;;Y YT;;;Keywords to the item separated by a comma, used for searching.;;Classification\n"
+ "Summary;;;Y YT;;;A plot outline or a summary of the story.;;Classification\n"
+ "Synopsis;;;Y YT;;;A description of the story line of the item.;;Classification\n"
+ "Period;;;Y YT;;;Describes the period that the piece is from or about. e.g. Renaissance.;;Classification\n"
+ "LawRating;;;Y YT;;;Depending on the country it's the format of the rating of a movie (P, R, X in the USA, an age in other countries or a URI defining a logo).;;Classification\n"
+ "LawRating_Reason;;;Y YT;;;Reason for the law rating;;Classification\n"
+ "ICRA;;;Y YT;;;The ICRA rating. (Previously RSACi);;Classification\n"
+ "Released_Date;;;Y YT;;;The date/year that the item was released.;;Temporal\n"
+ "Original/Released_Date;;;Y YT;;;The date/year that the item was originaly released.;;Temporal\n"
+ "Recorded_Date;;;Y YT;;;The time/date/year that the recording began.;;Temporal\n"
+ "Encoded_Date;;;Y YT;;;The time/date/year that the encoding of this item was completed began.;;Temporal\n"
+ "Tagged_Date;;;Y YT;;;The time/date/year that the tags were done for this item.;;Temporal\n"
+ "Written_Date;;;Y YT;;;The time/date/year that the composition of the music/script began.;;Temporal\n"
+ "Mastered_Date;;;Y YT;;;The time/date/year that the item was tranfered to a digitalmedium.;;Temporal\n"
+ "File_Created_Date;;;N NT;;;The time that the file was created on the file system;;Temporal\n"
+ "File_Created_Date_Local;;;N NT;;;The time that the file was created on the file system (Warning: this field depends of local configuration, do not use it in an international database);;Temporal\n"
+ "File_Modified_Date;;;N NT;;;The time that the file was modified on the file system;;Temporal\n"
+ "File_Modified_Date_Local;;;N NT;;;The time that the file was modified on the file system (Warning: this field depends of local configuration, do not use it in an international database);;Temporal\n"
+ "Recorded_Location;;;Y YT;;;Location where track was recorded. (See COMPOSITION_LOCATION for format);;Spatial\n"
+ "Written_Location;;;Y YT;;;Location that the item was originaly designed/written. Information should be stored in the following format: country code, state/province, city where the coutry code is the same 2 octets as in Internet domains, or possibly ISO-3166. e.g. US, Texas, Austin or US, , Austin.;;Spatial\n"
+ "Archival_Location;;;Y YT;;;Location, where an item is archived, e.eg. Louvre,Paris,France;;Spatial\n"
+ "Encoded_Application;;;Y YT;;;Name of the software package used to create the file, such as Microsoft WaveEdit.;;Technical\n"
+ "Encoded_Application/Url;;;N YT;;;Name of the software package used to create the file, such as Microsoft WaveEdit.;;Technical\n"
+ "Encoded_Library;;;N YT;;;Software used to create the file;;Technical\n"
+ "Encoded_Library/String;;;Y NT;;;Software used to create the file;;Technical\n"
+ "Encoded_Library/Name;;;N NT;;;Name of the the encoding-software;;Technical\n"
+ "Encoded_Library/Version;;;N NT;;;Version of encoding-software;;Technical\n"
+ "Encoded_Library/Date;;;N NT;;;Release date of software;;Technical\n"
+ "Encoded_Library_Settings;;;Y YT;;;Parameters used by the software;;Technical\n"
+ "Cropped;;;Y YT;;;Describes whether an image has been cropped and, if so, how it was cropped.;;Technical\n"
+ "Dimensions;;;Y YT;;;Specifies the size of the original subject of the file. eg 8.5 in h, 11 in w;;Technical\n"
+ "DotsPerInch;;;Y YT;;;Stores dots per inch setting of the digitizer used to produce the file;;Technical\n"
+ "Lightness;;;Y YT;;;Describes the changes in lightness settings on the digitizer required to produce the file;;Technical\n"
+ "OriginalSourceMedium;;;Y YT;;;Original medium of the material, e.g. vinyl, Audio-CD, Super8 or BetaMax;;Technical\n"
+ "OriginalSourceForm;;;Y YT;;;Original form of the material, e.g. slide, paper, map;;Technical\n"
+ "OriginalSourceForm/NumColors;;;Y YT;;;Number of colors requested when digitizing, e.g. 256 for images or 32 bit RGB for video;;Technical\n"
+ "OriginalSourceForm/Name;;;Y YT;;;Name of the product the file was originally intended for;;Technical\n"
+ "OriginalSourceForm/Cropped;;;Y YT;;;Describes whether an image has been cropped and, if so, how it was cropped. e.g. 16:9 to 4:3, top and bottom;;Technical\n"
+ "OriginalSourceForm/Sharpness;;;Y YT;;;Identifies the changes in sharpness for the digitizer requiered to produce the file;;Technical\n"
+ "Tagged_Application;;;Y YT;;;Software used to tag this file;;Technical\n"
+ "BPM;;;Y YT;;;Average number of beats per minute;;Technical\n"
+ "ISRC;;;Y YT;;;International Standard Recording Code, excluding the ISRC prefix and including hyphens.;;Identifier\n"
+ "ISBN;;;Y YT;;;International Standard Book Number.;;Identifier\n"
+ "BarCode;;;Y YT;;;EAN-13 (13-digit European Article Numbering) or UPC-A (12-digit Universal Product Code) bar code identifier.;;Identifier\n"
+ "LCCN;;;Y YT;;;Library of Congress Control Number.;;Identifier\n"
+ "CatalogNumber;;;Y YT;;;A label-specific catalogue number used to identify the release. e.g. TIC 01.;;Identifier\n"
+ "LabelCode;;;Y YT;;;A 4-digit or 5-digit number to identify the record label, typically printed as (LC) xxxx or (LC) 0xxxx on CDs medias or covers, with only the number being stored.;;Identifier\n"
+ "Owner;;;Y YT;;;Owner of the file;;Legal\n"
+ "Copyright;;;Y YT;;;Copyright attribution.;;Legal\n"
+ "Copyright/Url;;;Y YT;;;Link to a site with copyright/legal information.;;Legal\n"
+ "Producer_Copyright;;;Y YT;;;The copyright information as per the productioncopyright holder.;;Legal\n"
+ "TermsOfUse;;;Y YT;;;License information, e.g., All Rights Reserved,Any Use Permitted.;;Legal\n"
+ "ServiceName;;;Y YT;;;;;Legal\n"
+ "ServiceChannel;;;Y YT;;;;;Legal\n"
+ "Service/Url;;;Y YT;;;;;Legal\n"
+ "ServiceProvider;;;Y YT;;;;;Legal\n"
+ "ServiceProviderr/Url;;;Y YT;;;;;Legal\n"
+ "ServiceType;;;Y YT;;;;;Legal\n"
+ "NetworkName;;;Y YT;;;;;Legal\n"
+ "OriginalNetworkName;;;Y YT;;;;;Legal\n"
+ "Country;;;Y YT;;;;;Legal\n"
+ "TimeZone;;;Y YT;;;;;Legal\n"
+ "Cover;;;Y YT;;;Is there a cover;;Info\n"
+ "Cover_Description;;;Y YT;;;short descriptio, e.g. Earth in space;;Info\n"
+ "Cover_Type;;;Y YT;;;;;Info\n"
+ "Cover_Mime;;;Y YT;;;;;Info\n"
+ "Cover_Data;;;N YT;;;Cover, in binary format encoded BASE64;;Info\n"
+ "Lyrics;;;Y YT;;;Text of a song;;Info\n"
+ "Comment;;;Y YT;;;Any comment related to the content.;;Personal\n"
+ "Rating;;;Y YT;;;A numeric value defining how much a person likes the song/movie. The number is between 0 and 5 with decimal values possible (e.g. 2.7), 5(.0) being the highest possible rating.;;Personal\n"
+ "Added_Date;;;Y YT;;;Date/year the item was added to the owners collection;;Personal\n"
+ "Played_First_Date;;;Y YT;;;The date, the owner first played an item;;Personal\n"
+ "Played_Last_Date;;;Y YT;;;The date, the owner last played an item;;Personal\n"
+ "Played_Count;;;Y YI;;;Number of times an item was played;;Personal\n"
+ "EPG_Positions_Begin;;;N NI;;;;\n"
+ "EPG_Positions_End;;;N NI;;;;\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Video (ZtringListList &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "Count;;;N NI;;;Number of objects available in this stream\n"
+ "Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished)\n"
+ "StreamCount;;;N NI;;;Number of streams of this kind available\n"
+ "StreamKind;Video;;N NI;;;Stream type name\n"
+ "StreamKind/String;;;N NI;;;Stream type name\n"
+ "StreamKindID;;;N NI;;;Number of the stream (base=0)\n"
+ "StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1)\n"
+ "StreamOrder;;;N NI;;;Stream order in the file, whatever is the kind of stream (base=0)\n"
+ "Inform;;;N NT;;;Last **Inform** call\n"
+ "ID;;;N YI;;;The ID for this stream in this file\n"
+ "ID/String;;;Y NT;;;The ID for this stream in this file\n"
+ "UniqueID;;;N YI;;;The unique ID for this stream, should be copied with stream copy\n"
+ "UniqueID/String;;;Y NT;;;A unique ID for this stream, should be copied with stream copy\n"
+ "MenuID;;;N YI;;;The menu ID for this stream in this file\n"
+ "MenuID/String;;;Y NT;;;The menu ID for this stream in this file\n"
+ "Format;;;Y YT;;;Format used\n"
+ "Format/Info;;;Y NT;;;Info about Format\n"
+ "Format/Url;;;N NT;;;Link\n"
+ "Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference\n"
+ "Format_Commercial_IfAny;;;Y NT;;;Commercial name used by vendor for theses setings if there is one\n"
+ "Format_Version;;;Y NT;;;Version of this format\n"
+ "Format_Profile;;;Y NT;;;Profile of the Format\n"
+ "Format_Compression;;;Y NT;;;Compression method used;\n"
+ "MultiView_BaseProfile;;;Y NT;;;Multiview, profile of the base stream\n"
+ "MultiView_Count;;;Y NT;;;Multiview, count of views\n"
+ "MultiView_Layout;;;Y NT;;;Multiview, how views are muxed in the container in case of it is not muxing in the stream\n"
+ "Format_Settings;;;N NT;;;Settings needed for decoder used, summary\n"
+ "Format_Settings_BVOP;;Yes;N YT;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_BVOP/String;;;Y NT;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_QPel;;Yes;N YT;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_QPel/String;;;Y NT;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_GMC;; warppoint;N YI;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_GMC/String;;;Y NT;;\n"
+ "Format_Settings_Matrix;;;N YT;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_Matrix/String;;;Y NT;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_Matrix_Data;;;N NT;;;Matrix, in binary format encoded BASE64. Order = intra, non-intra, gray intra, gray non-intra\n"
+ "Format_Settings_CABAC;;Yes;N YT;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_CABAC/String;;;Y NT;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_RefFrames;; frame;N YI;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_RefFrames/String;;;Y NT;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_Pulldown;;;Y YT;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_FrameMode;;;Y YT;;;Settings needed for decoder used, detailled\n"
+ "Format_Settings_GOP;;;Y YT;;;Settings needed for decoder used, detailled (M=x N=y)\n"
+ "Format_Settings_FrameStructures;;;Y YT;;;Settings needed for decoder used, detailled (Type of frame, and field/frame info)\n"
+ "Format_Settings_Wrapping;;;Y YT;;;Wrapping mode (Frame wrapped or Clip wrapped)\n"
+ "InternetMediaType;;;N YT;;;Internet Media Type (aka MIME Type, Content-Type)\n"
+ "MuxingMode;;;Y NT;;;How this file is muxed in the container\n"
+ "CodecID;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/String;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/Info;;;Y NT;;;Info on the codec\n"
+ "CodecID/Hint;;;Y NT;;;Hint/popular name for this codec\n"
+ "CodecID/Url;;;N NT;;;Homepage for more details about this codec\n"
+ "CodecID_Description;;;Y NT;;;Manual description given by the container\n"
+ "Codec;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/String;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/Family;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/Info;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/Url;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/CC;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Profile;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Description;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings_PacketBitStream;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings_BVOP;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings_QPel;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings_GMC;; warppoint;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings_GMC/String;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings_Matrix;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings_Matrix_Data;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings_CABAC;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec_Settings_RefFrames;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Duration;; ms;N YI;;;Play time of the stream in ms\n"
+ "Duration/String;;;Y NT;;;Play time in format : XXx YYy only, YYy omited if zero\n"
+ "Duration/String1;;;N NT;;;Play time in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Duration/String2;;;N NT;;;Play time in format : XXx YYy only, YYy omited if zero\n"
+ "Duration/String3;;;N NT;;;Play time in format : HH:MM:SS.MMM\n"
+ "Duration/String4;;;N NT;;;Play time in format : HH:MM:SS:FF (HH:MM:SS;FF for drop frame, if available)\n"
+ "Duration_FirstFrame;; ms;N YI;;;Duration of the first frame if it is longer than others, in ms\n"
+ "Duration_FirstFrame/String;;;Y NT;;;Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_FirstFrame/String1;;;N NT;;;Duration of the first frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Duration_FirstFrame/String2;;;N NT;;;Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_FirstFrame/String3;;;N NT;;;Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "Duration_LastFrame;; ms;N YI;;;Duration of the last frame if it is longer than others, in ms\n"
+ "Duration_LastFrame/String;;;Y NT;;;Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_LastFrame/String1;;;N NT;;;Duration of the last frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Duration_LastFrame/String2;;;N NT;;;Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_LastFrame/String3;;;N NT;;;Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "Source_Duration;; ms;N YI;;;Source Play time of the stream;\n"
+ "Source_Duration/String;;;Y NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;\n"
+ "Source_Duration/String1;;;N NT;;;Source Play time in format : HHh MMmn SSs MMMms, XX omited if zero;\n"
+ "Source_Duration/String2;;;N NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;\n"
+ "Source_Duration/String3;;;N NT;;;Source Play time in format : HH:MM:SS.MMM;\n"
+ "Source_Duration_FirstFrame;; ms;N YI;;;Source Duration of the first frame if it is longer than others, in ms\n"
+ "Source_Duration_FirstFrame/String;;;Y NT;;;Source Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_FirstFrame/String1;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Source_Duration_FirstFrame/String2;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_FirstFrame/String3;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "Source_Duration_LastFrame;; ms;N YI;;;Source Duration of the last frame if it is longer than others, in ms\n"
+ "Source_Duration_LastFrame/String;;;Y NT;;;Source Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_LastFrame/String1;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Source_Duration_LastFrame/String2;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_LastFrame/String3;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "BitRate_Mode;;;N YT;;;Bit rate mode (VBR, CBR)\n"
+ "BitRate_Mode/String;;;Y NT;;;Bit rate mode (Variable, Cconstant)\n"
+ "BitRate;; bps;N YF;;;Bit rate in bps\n"
+ "BitRate/String;;;Y NT;;;Bit rate (with measurement)\n"
+ "BitRate_Minimum;; bps;N YF;;;Minimum Bit rate in bps\n"
+ "BitRate_Minimum/String;;;Y NT;;;Minimum Bit rate (with measurement)\n"
+ "BitRate_Nominal;; bps;N YF;;;Nominal Bit rate in bps\n"
+ "BitRate_Nominal/String;;;Y NT;;;Nominal Bit rate (with measurement)\n"
+ "BitRate_Maximum;; bps;N YF;;;Maximum Bit rate in bps\n"
+ "BitRate_Maximum/String;;;Y NT;;;Maximum Bit rate (with measurement)\n"
+ "BitRate_Encoded;; bps;N YF;;;Encoded (with forced padding) bit rate in bps, if some container padding is present\n"
+ "BitRate_Encoded/String;;;Y NT;;;Encoded (with forced padding) bit rate (with measurement), if some container padding is present\n"
+ "Width;; pixel;N YI;;;Width (aperture size if present) in pixel\n"
+ "Width/String;;;Y NT;;;Width (aperture size if present) with measurement (pixel)\n"
+ "Width_Offset;; pixel;N YI;;;Offset between original width and displayed width (aperture size) in pixel\n"
+ "Width_Offset/String;;;N NT;;;Offset between original width and displayed width (aperture size) in pixel\n"
+ "Width_Original;; pixel;N YI;;;Original (in the raw stream) width in pixel\n"
+ "Width_Original/String;;;Y NT;;;Original (in the raw stream) width with measurement (pixel)\n"
+ "Height;; pixel;N YI;;;Height (aperture size if present) in pixel\n"
+ "Height/String;;;Y NT;;;Height (aperture size if present) with measurement (pixel)\n"
+ "Height_Offset;; pixel;N YI;;;Offset between original height and displayed height (aperture size) in pixel\n"
+ "Height_Offset/String;;;N NT;;;Offset between original height and displayed height (aperture size) in pixel\n"
+ "Height_Original;; pixel;N YI;;;Original (in the raw stream) height in pixel\n"
+ "Height_Original/String;;;Y NT;;;Original (in the raw stream) height with measurement (pixel)\n"
+ "PixelAspectRatio;;;N YF;;;Pixel Aspect ratio\n"
+ "PixelAspectRatio/String;;;N NT;;;Pixel Aspect ratio\n"
+ "PixelAspectRatio_Original;;;N YF;;;Original (in the raw stream) Pixel Aspect ratio\n"
+ "PixelAspectRatio_Original/String;;;N NT;;;Original (in the raw stream) Pixel Aspect ratio\n"
+ "DisplayAspectRatio;;;N YF;;;Display Aspect ratio\n"
+ "DisplayAspectRatio/String;;;Y NT;;;Display Aspect ratio\n"
+ "DisplayAspectRatio_Original;;;N YF;;;Original (in the raw stream) Display Aspect ratio\n"
+ "DisplayAspectRatio_Original/String;;;Y NT;;;Original (in the raw stream) Display Aspect ratio\n"
+ "ActiveFormatDescription;;;N YN;;;Active Format Description (AFD value)\n"
+ "ActiveFormatDescription/String;;;Y NT;;;Active Format Description (text)\n"
+ "ActiveFormatDescription_MuxingMode;;;N YT;;;Active Format Description (AFD value) muxing mode (Ancillary or Raw stream)\n"
+ "Rotation;;;N YT;;;Rotation\n"
+ "Rotation/String;;;Y NT;;;Rotation (if not horizontal)\n"
+ "FrameRate_Mode;;;N YT;;;Frame rate mode (CFR, VFR)\n"
+ "FrameRate_Mode/String;;;Y NT;;;Frame rate mode (Constant, Variable)\n"
+ "FrameRate_Mode_Original;;;N YT;;;Original frame rate mode (CFR, VFR)\n"
+ "FrameRate_Mode_Original/String;;;Y NT;;;Original frame rate mode (Constant, Variable)\n"
+ "FrameRate;; fps;N YF;;;Frames per second\n"
+ "FrameRate/String;;;Y NT;;;Frames per second (with measurement)\n"
+ "FrameRate_Original;; fps;N YF;;;Original (in the raw stream) frames per second\n"
+ "FrameRate_Original/String;;;Y NT;;;Original (in the raw stream) frames per second (with measurement)\n"
+ "FrameRate_Minimum;; fps;N YF;;;Minimum Frames per second\n"
+ "FrameRate_Minimum/String;;;Y NT;;;Minimum Frames per second (with measurement)\n"
+ "FrameRate_Nominal;; fps;N YF;;;Nominal Frames per second\n"
+ "FrameRate_Nominal/String;;;Y NT;;;Nominal Frames per second (with measurement)\n"
+ "FrameRate_Maximum;; fps;N YF;;;Maximum Frames per second\n"
+ "FrameRate_Maximum/String;;;Y NT;;;Maximum Frames per second (with measurement)\n"
+ "FrameCount;;;N NI;;;Number of frames\n"
+ "Source_FrameCount;;;N NI;;;Source Number of frames\n"
+ "Standard;;;Y NT;;;NTSC or PAL\n"
+ "Resolution;; bit;N NI;;;Deprecated, do not use in new projects\n"
+ "Resolution/String;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Colorimetry;;;N NT;;;Deprecated, do not use in new projects\n"
+ "ColorSpace;;;Y YT;;\n"
+ "ChromaSubsampling;;;Y YT;;\n"
+ "BitDepth;; bit;N YI;;;16/24/32 \n"
+ "BitDepth/String;;;Y NT;;;16/24/32 bits\n"
+ "ScanType;;;N YT;;\n"
+ "ScanType/String;;;Y NT;;\n"
+ "ScanOrder;;;N YT;;;\n"
+ "ScanOrder/String;;;Y NT;;;\n"
+ "Interlacement;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Interlacement/String;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Compression_Mode;;;N YT;;;Compression mode (Lossy or Lossless)\n"
+ "Compression_Mode/String;;;Y NT;;;Compression mode (Lossy or Lossless)\n"
+ "Compression_Ratio;;;Y YF;;;Current stream size divided by uncompressed stream size;\n"
+ "Bits-(Pixel*Frame);;;Y YF;;;bits/(Pixel*Frame) (like Gordian Knot)\n"
+ "Delay;; ms;N NI;;;Delay fixed in the stream (relative) IN MS\n"
+ "Delay/String;;;N NT;;;Delay with measurement\n"
+ "Delay/String1;;;N NT;;;Delay with measurement\n"
+ "Delay/String2;;;N NT;;;Delay with measurement\n"
+ "Delay/String3;;;N NT;;;Delay in format : HH:MM:SS.MMM\n"
+ "Delay/String4;;;N NT;;;Delay in format : HH:MM:SS:FF (HH:MM:SS;FF for drop frame, if available)\n"
+ "Delay_Settings;;;N NT;;;Delay settings (in case of timecode for example)\n"
+ "Delay_Source;;;N NT;;;Delay source (Container or Stream or empty)\n"
+ "Delay_Source/String;;;N NT;;;Delay source (Container or Stream or empty)\n"
+ "Delay_Original;; ms;N NI;;;Delay fixed in the raw stream (relative) IN MS\n"
+ "Delay_Original/String;;;N NT;;;Delay with measurement\n"
+ "Delay_Original/String1;;;N NT;;;Delay with measurement\n"
+ "Delay_Original/String2;;;N NT;;;Delay with measurement\n"
+ "Delay_Original/String3;;;N NT;;;Delay in format: HH:MM:SS.MMM;\n"
+ "Delay_Original/String4;;;N NT;;;Delay in format: HH:MM:SS:FF (HH:MM:SS;FF for drop frame, if available)\n"
+ "Delay_Original_Settings;;;N NT;;;Delay settings (in case of timecode for example);\n"
+ "Delay_Original_Source;;;N NT;;;Delay source (Stream or empty)\n"
+ "StreamSize;; byte;N YI;;;Streamsize in bytes;\n"
+ "StreamSize/String;;;Y NT;;;Streamsize in with percentage value;\n"
+ "StreamSize/String1;;;N NT;;;;\n"
+ "StreamSize/String2;;;N NT;;;;\n"
+ "StreamSize/String3;;;N NT;;;;\n"
+ "StreamSize/String4;;;N NT;;;;\n"
+ "StreamSize/String5;;;N NT;;;Streamsize in with percentage value;\n"
+ "StreamSize_Proportion;;;N NT;;;Stream size divided by file size;\n"
+ "Source_StreamSize;; byte;N YI;;;Source Streamsize in bytes;\n"
+ "Source_StreamSize/String;;;Y NT;;;Source Streamsize in with percentage value;\n"
+ "Source_StreamSize/String1;;;N NT;;;;\n"
+ "Source_StreamSize/String2;;;N NT;;;;\n"
+ "Source_StreamSize/String3;;;N NT;;;;\n"
+ "Source_StreamSize/String4;;;N NT;;;;\n"
+ "Source_StreamSize/String5;;;N NT;;;Source Streamsize in with percentage value;\n"
+ "Source_StreamSize_Proportion;;;N NT;;;Source Stream size divided by file size;\n"
+ "StreamSize_Encoded;; byte;N YI;;;Encoded Streamsize in bytes;\n"
+ "StreamSize_Encoded/String;;;Y NT;;;Encoded Streamsize in with percentage value;\n"
+ "StreamSize_Encoded/String1;;;N NT;;;;\n"
+ "StreamSize_Encoded/String2;;;N NT;;;;\n"
+ "StreamSize_Encoded/String3;;;N NT;;;;\n"
+ "StreamSize_Encoded/String4;;;N NT;;;;\n"
+ "StreamSize_Encoded/String5;;;N NT;;;Encoded Streamsize in with percentage value;\n"
+ "StreamSize_Encoded_Proportion;;;N NT;;;Encoded Stream size divided by file size;\n"
+ "Source_StreamSize_Encoded;; byte;N YI;;;Source Encoded Streamsize in bytes;\n"
+ "Source_StreamSize_Encoded/String;;;Y NT;;;Source Encoded Streamsize in with percentage value;\n"
+ "Source_StreamSize_Encoded/String1;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String2;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String3;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String4;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String5;;;N NT;;;Source Encoded Streamsize in with percentage value;\n"
+ "Source_StreamSize_Encoded_Proportion;;;N NT;;;Source Encoded Stream size divided by file size;\n"
+ "Alignment;;;Y NT;;;How this stream file is aligned in the container;\n"
+ "Alignment/String;;;N YT;;;;\n"
+ "Title;;;Y YI;;;Name of the track;\n"
+ "Encoded_Application;;;Y YT;;;Software. Identifies the name of the software package used to create the file, such as Microsoft WaveEdit.;;Technical\n"
+ "Encoded_Application/Url;;;N YT;;;Software. Identifies the name of the software package used to create the file, such as Microsoft WaveEdit.;;Technical\n"
+ "Encoded_Library;;;N YT;;;Software used to create the file;\n"
+ "Encoded_Library/String;;;Y NT;;;Software used to create the file;\n"
+ "Encoded_Library/Name;;;N NT;;;Info from the software;\n"
+ "Encoded_Library/Version;;;N NT;;;Version of software;\n"
+ "Encoded_Library/Date;;;N NT;;;Release date of software;\n"
+ "Encoded_Library_Settings;;;Y YT;;;Parameters used by the software;\n"
+ "Language;;;N YT;;;Language (2-letter ISO 639-1 if exists, else 3-letter ISO 639-2, and with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn);\n"
+ "Language/String;;;Y NT;;;Language (full);\n"
+ "Language/String1;;;N NT;;;Language (full);\n"
+ "Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty);\n"
+ "Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);\n"
+ "Language/String4;;;N NT;;;Language (2-letter ISO 639-1 if exists with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn, else empty);\n"
+ "Language_More;;;Y YT;;;More info about Language (e.g. Director's Comment);\n"
+ "Default;;Yes;N YT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Default/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Forced;;Yes;N YT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Forced/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Encoded_Date;;;Y YT;;;UTC time that the encoding of this item was completed began.;;Temporal\n"
+ "Tagged_Date;;;Y YT;;;UTC time that the tags were done for this item.;;Temporal\n"
+ "Encryption;;;Y YT;;;;\n"
+ "BufferSize;;;N YT;;;Defines the size of the buffer needed to decode the sequence.\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Audio (ZtringListList &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "Count;;;N NI;;;Number of objects available in this stream;\n"
+ "Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished)\n"
+ "StreamCount;;;N NI;;;Number of streams of this kind available;\n"
+ "StreamKind;Audio;;N NI;;;Stream type name;\n"
+ "StreamKind/String;;;N NI;;;Stream type name;\n"
+ "StreamKindID;;;N NI;;;Number of the stream (base=0);\n"
+ "StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1);\n"
+ "StreamOrder;;;N NI;;;Stream order in the file, whatever is the kind of stream (base=0);\n"
+ "Inform;;;N NT;;;Last **Inform** call;\n"
+ "ID;;;N YI;;;The ID of this stream in this file;\n"
+ "ID/String;;;Y NT;;;The ID of this stream in this file;\n"
+ "UniqueID;;;N YI;;;A unique ID for this stream, should be copied with stream copy;\n"
+ "UniqueID/String;;;Y NT;;;A unique ID for this stream, should be copied with stream copy\n"
+ "MenuID;;;N YI;;;The menu ID for this stream in this file;\n"
+ "MenuID/String;;;Y NT;;;The menu ID for this stream in this file;\n"
+ "Format;;;Y YT;;;Format used;\n"
+ "Format/Info;;;Y NT;;;Info about the format;\n"
+ "Format/Url;;;N NT;;;Homepage of this format;\n"
+ "Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference;\n"
+ "Format_Commercial_IfAny;;;Y NT;;;Commercial name used by vendor for theses setings if there is one;\n"
+ "Format_Version;;;Y NT;;;Version of this format;\n"
+ "Format_Profile;;;Y NT;;;Profile of this Format;\n"
+ "Format_Compression;;;Y NT;;;Compression method used;\n"
+ "Format_Settings;;;N NT;;;Settings needed for decoder used, summary;\n"
+ "Format_Settings_SBR;;Yes;N YT;;;;\n"
+ "Format_Settings_SBR/String;;;N NT;;;;\n"
+ "Format_Settings_PS;;Yes;N YT;;;;\n"
+ "Format_Settings_PS/String;;;N NT;;;;\n"
+ "Format_Settings_Mode;;;Y YT;;;;\n"
+ "Format_Settings_ModeExtension;;;Y YT;;;;\n"
+ "Format_Settings_Emphasis;;;Y YT;;;;\n"
+ "Format_Settings_Floor;;;Y YT;;;;\n"
+ "Format_Settings_Firm;;;Y YT;;;;\n"
+ "Format_Settings_Endianness;;;Y YT;;;;\n"
+ "Format_Settings_Sign;;;Y YT;;;;\n"
+ "Format_Settings_Law;;;Y YT;;;;\n"
+ "Format_Settings_ITU;;;Y YT;;;;\n"
+ "Format_Settings_Wrapping;;;Y YT;;;Wrapping mode (Frame wrapped or Clip wrapped)\n"
+ "InternetMediaType;;;N YT;;;Internet Media Type (aka MIME Type, Content-Type);\n"
+ "MuxingMode;;;Y NT;;;How this stream is muxed in the container;\n"
+ "MuxingMode_MoreInfo;;;Y NT;;;More info (text) about the muxing mode;\n"
+ "CodecID;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/String;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/Info;;;Y NT;;;Info about codec ID;\n"
+ "CodecID/Hint;;;Y NT;;;Hint/popular name for this codec ID;\n"
+ "CodecID/Url;;;N NT;;;Homepage for more details about this codec ID;\n"
+ "CodecID_Description;;;Y NT;;;Manual description given by the container;\n"
+ "Codec;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec/String;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec/Family;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec/Info;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec/Url;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec/CC;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec_Description;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec_Profile;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec_Settings;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec_Settings_Automatic;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec_Settings_Floor;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec_Settings_Firm;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec_Settings_Endianness;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec_Settings_Sign;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec_Settings_Law;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Codec_Settings_ITU;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "Duration;; ms;N YI;;;Play time of the stream;\n"
+ "Duration/String;;;Y NT;;;Play time in format : XXx YYy only, YYy omited if zero;\n"
+ "Duration/String1;;;N NT;;;Play time in format : HHh MMmn SSs MMMms, XX omited if zero;\n"
+ "Duration/String2;;;N NT;;;Play time in format : XXx YYy only, YYy omited if zero;\n"
+ "Duration/String3;;;N NT;;;Play time in format : HH:MM:SS.MMM;\n"
+ "Duration_FirstFrame;; ms;N YI;;;Duration of the first frame if it is longer than others, in ms\n"
+ "Duration_FirstFrame/String;;;Y NT;;;Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_FirstFrame/String1;;;N NT;;;Duration of the first frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Duration_FirstFrame/String2;;;N NT;;;Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_FirstFrame/String3;;;N NT;;;Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "Duration_LastFrame;; ms;N YI;;;Duration of the last frame if it is longer than others, in ms\n"
+ "Duration_LastFrame/String;;;Y NT;;;Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_LastFrame/String1;;;N NT;;;Duration of the last frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Duration_LastFrame/String2;;;N NT;;;Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_LastFrame/String3;;;N NT;;;Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "Source_Duration;; ms;N YI;;;Source Play time of the stream;\n"
+ "Source_Duration/String;;;Y NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;\n"
+ "Source_Duration/String1;;;N NT;;;Source Play time in format : HHh MMmn SSs MMMms, XX omited if zero;\n"
+ "Source_Duration/String2;;;N NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;\n"
+ "Source_Duration/String3;;;N NT;;;Source Play time in format : HH:MM:SS.MMM;\n"
+ "Source_Duration_FirstFrame;; ms;N YI;;;Source Duration of the first frame if it is longer than others, in ms\n"
+ "Source_Duration_FirstFrame/String;;;Y NT;;;Source Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_FirstFrame/String1;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Source_Duration_FirstFrame/String2;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_FirstFrame/String3;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "Source_Duration_LastFrame;; ms;N YI;;;Source Duration of the last frame if it is longer than others, in ms\n"
+ "Source_Duration_LastFrame/String;;;Y NT;;;Source Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_LastFrame/String1;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Source_Duration_LastFrame/String2;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_LastFrame/String3;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "BitRate_Mode;;;N YT;;;Bit rate mode (VBR, CBR);\n"
+ "BitRate_Mode/String;;;Y NT;;;Bit rate mode (Constant, Variable);\n"
+ "BitRate;; bps;N YF;;;Bit rate in bps;\n"
+ "BitRate/String;;;Y NT;;;Bit rate (with measurement);\n"
+ "BitRate_Minimum;; bps;N YF;;;Minimum Bit rate in bps;\n"
+ "BitRate_Minimum/String;;;Y NT;;;Minimum Bit rate (with measurement);\n"
+ "BitRate_Nominal;; bps;N YF;;;Nominal Bit rate in bps;\n"
+ "BitRate_Nominal/String;;;Y NT;;;Nominal Bit rate (with measurement);\n"
+ "BitRate_Maximum;; bps;N YF;;;Maximum Bit rate in bps;\n"
+ "BitRate_Maximum/String;;;Y NT;;;Maximum Bit rate (with measurement);\n"
+ "BitRate_Encoded;; bps;N YF;;;Encoded (with forced padding) bit rate in bps, if some container padding is present\n"
+ "BitRate_Encoded/String;;;Y NT;;;Encoded (with forced padding) bit rate (with measurement), if some container padding is present\n"
+ "Channel(s);; channel;N YF;;;Number of channels;\n"
+ "Channel(s)/String;;;Y NT;;;Number of channels (with measurement);\n"
+ "ChannelPositions;;;Y YT;;;Position of channels;\n"
+ "ChannelPositions/String2;;;N NT;;;Position of channels (x/y.z format);\n"
+ "ChannelLayout;;;N YT;;;Layout of channels (in the stream);\n"
+ "SamplingRate;; Hz;N YF;;;Sampling rate;\n"
+ "SamplingRate/String;;;Y NT;;;in KHz;\n"
+ "SamplingCount;;;N NI;;;Sample count (based on sampling rate);\n"
+ "Source_SamplingCount;;;N NI;;;Source Sample count (based on sampling rate);\n"
+ "FrameRate;; fps;N YF;;;Frames per second\n"
+ "FrameRate/String;;;N NT;;;Frames per second (with measurement)\n"
+ "FrameCount;;;N NI;;;Frame count (a frame contains a count of samples depends of the format);\n"
+ "Source_FrameCount;;;N NI;;;Source Frame count (a frame contains a count of samples depends of the format);\n"
+ "Resolution;; bit;N NI;;;Deprecated, do not use in new projects;\n"
+ "Resolution/String;;;N NT;;;Deprecated, do not use in new projects;\n"
+ "BitDepth;; bit;N YI;;;Resolution in bits (8, 16, 20, 24);\n"
+ "BitDepth/String;;;Y NT;;;Resolution in bits (8, 16, 20, 24);\n"
+ "Compression_Mode;;;N YT;;;Compression mode (Lossy or Lossless)\n"
+ "Compression_Mode/String;;;Y NT;;;Compression mode (Lossy or Lossless)\n"
+ "Compression_Ratio;;;Y YF;;;Current stream size divided by uncompressed stream size;\n"
+ "Delay;; ms;N NI;;;Delay fixed in the stream (relative) IN MS\n"
+ "Delay/String;;;N NT;;;Delay with measurement\n"
+ "Delay/String1;;;N NT;;;Delay with measurement\n"
+ "Delay/String2;;;N NT;;;Delay with measurement\n"
+ "Delay/String3;;;N NT;;;Delay in format : HH:MM:SS.MMM\n"
+ "Delay/String4;;;N NT;;;Delay in format : HH:MM:SS:FF (HH:MM:SS;FF for drop frame, if available)\n"
+ "Delay_Settings;;;N NT;;;Delay settings (in case of timecode for example)\n"
+ "Delay_Source;;;N NT;;;Delay source (Container or Stream or empty)\n"
+ "Delay_Source/String;;;N NT;;;Delay source (Container or Stream or empty)\n"
+ "Delay_Original;; ms;N NI;;;Delay fixed in the raw stream (relative) IN MS\n"
+ "Delay_Original/String;;;N NT;;;Delay with measurement\n"
+ "Delay_Original/String1;;;N NT;;;Delay with measurement\n"
+ "Delay_Original/String2;;;N NT;;;Delay with measurement\n"
+ "Delay_Original/String3;;;N NT;;;Delay in format: HH:MM:SS.MMM;\n"
+ "Delay_Original/String4;;;N NT;;;Delay in format: HH:MM:SS:FF (HH:MM:SS;FF for drop frame, if available)\n"
+ "Delay_Original_Settings;;;N NT;;;Delay settings (in case of timecode for example);\n"
+ "Delay_Original_Source;;;N NT;;;Delay source (Stream or empty)\n"
+ "Video_Delay;; ms;N NI;;;Delay fixed in the stream (absolute / video)\n"
+ "Video_Delay/String;;;Y NT;;\n"
+ "Video_Delay/String1;;;N NT;;\n"
+ "Video_Delay/String2;;;N NT;;\n"
+ "Video_Delay/String3;;;N NT;;\n"
+ "Video_Delay/String4;;;N NT;;\n"
+ "Video0_Delay;; ms;N NI;;;Deprecated, do not use in new projects\n"
+ "Video0_Delay/String;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Video0_Delay/String1;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Video0_Delay/String2;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Video0_Delay/String3;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Video0_Delay/String4;;;N NT;;;Deprecated, do not use in new projects\n"
+ "ReplayGain_Gain;; dB;N YT;;;The gain to apply to reach 89dB SPL on playback;\n"
+ "ReplayGain_Gain/String;;;Y YT;;;;\n"
+ "ReplayGain_Peak;;;Y YT;;;The maximum absolute peak value of the item;\n"
+ "StreamSize;; byte;N YI;;;Streamsize in bytes;\n"
+ "StreamSize/String;;;Y NT;;;Streamsize in with percentage value;\n"
+ "StreamSize/String1;;;N NT;;;;\n"
+ "StreamSize/String2;;;N NT;;;;\n"
+ "StreamSize/String3;;;N NT;;;;\n"
+ "StreamSize/String4;;;N NT;;;;\n"
+ "StreamSize/String5;;;N NT;;;Streamsize in with percentage value;\n"
+ "StreamSize_Proportion;;;N NT;;;Stream size divided by file size;\n"
+ "Source_StreamSize;; byte;N YI;;;Source Streamsize in bytes;\n"
+ "Source_StreamSize/String;;;Y NT;;;Source Streamsize in with percentage value;\n"
+ "Source_StreamSize/String1;;;N NT;;;;\n"
+ "Source_StreamSize/String2;;;N NT;;;;\n"
+ "Source_StreamSize/String3;;;N NT;;;;\n"
+ "Source_StreamSize/String4;;;N NT;;;;\n"
+ "Source_StreamSize/String5;;;N NT;;;Source Streamsize in with percentage value;\n"
+ "Source_StreamSize_Proportion;;;N NT;;;Source Stream size divided by file size;\n"
+ "StreamSize_Encoded;; byte;N YI;;;Encoded Streamsize in bytes;\n"
+ "StreamSize_Encoded/String;;;Y NT;;;Encoded Streamsize in with percentage value;\n"
+ "StreamSize_Encoded/String1;;;N NT;;;;\n"
+ "StreamSize_Encoded/String2;;;N NT;;;;\n"
+ "StreamSize_Encoded/String3;;;N NT;;;;\n"
+ "StreamSize_Encoded/String4;;;N NT;;;;\n"
+ "StreamSize_Encoded/String5;;;N NT;;;Encoded Streamsize in with percentage value;\n"
+ "StreamSize_Encoded_Proportion;;;N NT;;;Encoded Stream size divided by file size;\n"
+ "Source_StreamSize_Encoded;; byte;N YI;;;Source Encoded Streamsize in bytes;\n"
+ "Source_StreamSize_Encoded/String;;;Y NT;;;Source Encoded Streamsize in with percentage value;\n"
+ "Source_StreamSize_Encoded/String1;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String2;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String3;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String4;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String5;;;N NT;;;Source Encoded Streamsize in with percentage value;\n"
+ "Source_StreamSize_Encoded_Proportion;;;N NT;;;Source Encoded Stream size divided by file size;\n"
+ "Alignment;;;N YT;;;How this stream file is aligned in the container;\n"
+ "Alignment/String;;;Y NT;;;Where this stream file is aligned in the container;\n"
+ "Interleave_VideoFrames;;;N YF;;;Between how many video frames the stream is inserted;\n"
+ "Interleave_Duration;;;N YI;;;Between how much time (ms) the stream is inserted;\n"
+ "Interleave_Duration/String;;;Y NT;;;Between how much time and video frames the stream is inserted (with measurement);\n"
+ "Interleave_Preload;;;N YI;;;How much time is buffered before the first video frame;\n"
+ "Interleave_Preload/String;;;Y NT;;;How much time is buffered before the first video frame (with measurement);\n"
+ "Title;;;Y YI;;;Name of the track;\n"
+ "Encoded_Library;;;N YT;;;Software used to create the file;\n"
+ "Encoded_Library/String;;;Y NT;;;Software used to create the file;\n"
+ "Encoded_Library/Name;;;N NT;;;Info from the software;\n"
+ "Encoded_Library/Version;;;N NT;;;Version of software;\n"
+ "Encoded_Library/Date;;;N NT;;;Release date of software;\n"
+ "Encoded_Library_Settings;;;Y YT;;;Parameters used by the software;\n"
+ "Language;;;N YT;;;Language (2-letter ISO 639-1 if exists, else 3-letter ISO 639-2, and with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn);\n"
+ "Language/String;;;Y NT;;;Language (full);\n"
+ "Language/String1;;;N NT;;;Language (full);\n"
+ "Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty);\n"
+ "Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);\n"
+ "Language/String4;;;N NT;;;Language (2-letter ISO 639-1 if exists with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn, else empty);\n"
+ "Language_More;;;Y YT;;;More info about Language (e.g. Director's Comment);\n"
+ "Default;;Yes;N YT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Default/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Forced;;Yes;N YT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Forced/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Encoded_Date;;;Y YT;;;UTC time that the encoding of this item was completed began.;;Temporal\n"
+ "Tagged_Date;;;Y YT;;;UTC time that the tags were done for this item.;;Temporal\n"
+ "Encryption;;;Y YT;;;;\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Text (ZtringListList &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "Count;;;N NI;;;Count of objects available in this stream\n"
+ "Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished)\n"
+ "StreamCount;;;N NI;;;Count of streams of that kind available\n"
+ "StreamKind;Text;;N NI;;;Stream type name\n"
+ "StreamKind/String;;;N NI;;;Stream type name\n"
+ "StreamKindID;;;N NI;;;Number of the stream (base=0)\n"
+ "StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1)\n"
+ "StreamOrder;;;N NI;;;Stream order in the file, whatever is the kind of stream (base=0)\n"
+ "Inform;;;N NT;;;Last **Inform** call\n"
+ "ID;;;N YI;;;A ID for this stream in this file\n"
+ "ID/String;;;Y NT;;;A ID for this stream in this file\n"
+ "UniqueID;;;N YI;;;A unique ID for this stream, should be copied with stream copy\n"
+ "UniqueID/String;;;Y NT;;;A unique ID for this stream, should be copied with stream copy\n"
+ "MenuID;;;N YI;;;A menu ID for this stream in this file\n"
+ "MenuID/String;;;Y NT;;;A menu ID for this stream in this file\n"
+ "Format;;;Y YT;;;Format used\n"
+ "Format/Info;;;Y NT;;;Info about Format\n"
+ "Format/Url;;;N NT;;;Link\n"
+ "Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference\n"
+ "Format_Commercial_IfAny;;;Y NT;;;Commercial name used by vendor for theses setings if there is one\n"
+ "Format_Version;;;Y NT;;;Version of this format\n"
+ "Format_Profile;;;Y NT;;;Profile of the Format\n"
+ "Format_Compression;;;Y NT;;;Compression method used;\n"
+ "Format_Settings;;;Y NT;;;Settings needed for decoder used\n"
+ "Format_Settings_Wrapping;;;Y YT;;;Wrapping mode (Frame wrapped or Clip wrapped)\n"
+ "InternetMediaType;;;N YT;;;Internet Media Type (aka MIME Type, Content-Type)\n"
+ "MuxingMode;;;Y NT;;;How this stream is muxed in the container\n"
+ "MuxingMode_MoreInfo;;;Y NT;;;More info (text) about the muxing mode\n"
+ "CodecID;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/String;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/Info;;;Y NT;;;Info about codec ID\n"
+ "CodecID/Hint;;;Y NT;;;A hint for this codec ID\n"
+ "CodecID/Url;;;N NT;;;A link for more details about this codec ID\n"
+ "CodecID_Description;;;Y NT;;;Manual description given by the container\n"
+ "Codec;;;N YT;;;Deprecated\n"
+ "Codec/String;;;N NT;;;Deprecated\n"
+ "Codec/Info;;;N NT;;;Deprecated\n"
+ "Codec/Url;;;N NT;;;Deprecated\n"
+ "Codec/CC;;;N NT;;;Deprecated\n"
+ "Duration;; ms;N YI;;;Play time of the stream\n"
+ "Duration/String;;;Y NT;;;Play time (formated)\n"
+ "Duration/String1;;;N NT;;;Play time in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Duration/String2;;;N NT;;;Play time in format : XXx YYy only, YYy omited if zero\n"
+ "Duration/String3;;;N NT;;;Play time in format : HH:MM:SS.MMM\n"
+ "Duration/String4;;;N NT;;;Play time in format : HH:MM:SS:FF (HH:MM:SS;FF for drop frame, if available)\n"
+ "Duration_FirstFrame;; ms;N YI;;;Duration of the first frame if it is longer than others, in ms\n"
+ "Duration_FirstFrame/String;;;Y NT;;;Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_FirstFrame/String1;;;N NT;;;Duration of the first frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Duration_FirstFrame/String2;;;N NT;;;Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_FirstFrame/String3;;;N NT;;;Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "Duration_LastFrame;; ms;N YI;;;Duration of the last frame if it is longer than others, in ms\n"
+ "Duration_LastFrame/String;;;Y NT;;;Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_LastFrame/String1;;;N NT;;;Duration of the last frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Duration_LastFrame/String2;;;N NT;;;Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Duration_LastFrame/String3;;;N NT;;;Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "Source_Duration;; ms;N YI;;;Source Play time of the stream;\n"
+ "Source_Duration/String;;;Y NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;\n"
+ "Source_Duration/String1;;;N NT;;;Source Play time in format : HHh MMmn SSs MMMms, XX omited if zero;\n"
+ "Source_Duration/String2;;;N NT;;;Source Play time in format : XXx YYy only, YYy omited if zero;\n"
+ "Source_Duration/String3;;;N NT;;;Source Play time in format : HH:MM:SS.MMM;\n"
+ "Source_Duration_FirstFrame;; ms;N YI;;;Source Duration of the first frame if it is longer than others, in ms\n"
+ "Source_Duration_FirstFrame/String;;;Y NT;;;Source Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_FirstFrame/String1;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Source_Duration_FirstFrame/String2;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_FirstFrame/String3;;;N NT;;;Source Duration of the first frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "Source_Duration_LastFrame;; ms;N YI;;;Source Duration of the last frame if it is longer than others, in ms\n"
+ "Source_Duration_LastFrame/String;;;Y NT;;;Source Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_LastFrame/String1;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Source_Duration_LastFrame/String2;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : XXx YYy only, YYy omited if zero\n"
+ "Source_Duration_LastFrame/String3;;;N NT;;;Source Duration of the last frame if it is longer than others, in format : HH:MM:SS.MMM\n"
+ "BitRate_Mode;;;N YT;;;Bit rate mode (VBR, CBR)\n"
+ "BitRate_Mode/String;;;Y NT;;;Bit rate mode (Constant, Variable)\n"
+ "BitRate;; bps;N YF;;;Bit rate in bps\n"
+ "BitRate/String;;;Y NT;;;Bit rate (with measurement)\n"
+ "BitRate_Minimum;; bps;N YF;;;Minimum Bit rate in bps\n"
+ "BitRate_Minimum/String;;;Y NT;;;Minimum Bit rate (with measurement)\n"
+ "BitRate_Nominal;; bps;N YF;;;Nominal Bit rate in bps\n"
+ "BitRate_Nominal/String;;;Y NT;;;Nominal Bit rate (with measurement)\n"
+ "BitRate_Maximum;; bps;N YF;;;Maximum Bit rate in bps\n"
+ "BitRate_Maximum/String;;;Y NT;;;Maximum Bit rate (with measurement)\n"
+ "BitRate_Encoded;; bps;N YF;;;Encoded (with forced padding) bit rate in bps, if some container padding is present\n"
+ "BitRate_Encoded/String;;;Y NT;;;Encoded (with forced padding) bit rate (with measurement), if some container padding is present\n"
+ "Width;; pixel;N YI;;;Width\n"
+ "Width/String;;;Y NT;;\n"
+ "Height;; pixel;N YI;;;Height\n"
+ "Height/String;;;Y NT;;\n"
+ "FrameRate_Mode;;;N YT;;;Frame rate mode (CFR, VFR)\n"
+ "FrameRate_Mode/String;;;Y NT;;;Frame rate mode (Constant, Variable)\n"
+ "FrameRate;; fps;N YF;;;Frames per second\n"
+ "FrameRate/String;;;Y NT;;;Frames per second (with measurement)\n"
+ "FrameRate_Minimum;; fps;N YF;;;Minimum Frames per second\n"
+ "FrameRate_Minimum/String;;;Y NT;;;Minimum Frames per second (with measurement)\n"
+ "FrameRate_Nominal;; fps;N YF;;;Nominal Frames per second\n"
+ "FrameRate_Nominal/String;;;Y NT;;;Nominal Frames per second (with measurement)\n"
+ "FrameRate_Maximum;; fps;N YF;;;Maximum Frames per second\n"
+ "FrameRate_Maximum/String;;;Y NT;;;Maximum Frames per second (with measurement)\n"
+ "FrameRate_Original;; fps;N YF;;;Original (in the raw stream) Frames per second\n"
+ "FrameRate_Original/String;;;Y NT;;;Original (in the raw stream) Frames per second (with measurement)\n"
+ "FrameCount;;;N NI;;;Number of frames\n"
+ "Source_FrameCount;;;N NI;;;Source Number of frames\n"
+ "ColorSpace;;;Y YT;;\n"
+ "ChromaSubsampling;;;Y YT;;\n"
+ "Resolution;; bit;N NI;;;Deprecated, do not use in new projects\n"
+ "Resolution/String;;;N NT;;;Deprecated, do not use in new projects\n"
+ "BitDepth;; bit;N YI;;\n"
+ "BitDepth/String;;;Y NT;;\n"
+ "Compression_Mode;;;N YT;;;Compression mode (Lossy or Lossless)\n"
+ "Compression_Mode/String;;;Y NT;;;Compression mode (Lossy or Lossless)\n"
+ "Compression_Ratio;;;Y YF;;;Current stream size divided by uncompressed stream size;\n"
+ "Delay;; ms;N NI;;;Delay fixed in the stream (relative) IN MS\n"
+ "Delay/String;;;N NT;;;Delay with measurement\n"
+ "Delay/String1;;;N NT;;;Delay with measurement\n"
+ "Delay/String2;;;N NT;;;Delay with measurement\n"
+ "Delay/String3;;;N NT;;;Delay in format : HH:MM:SS.MMM\n"
+ "Delay/String4;;;N NT;;;Delay in format : HH:MM:SS:FF (HH:MM:SS;FF for drop frame, if available)\n"
+ "Delay_Settings;;;N NT;;;Delay settings (in case of timecode for example)\n"
+ "Delay_Source;;;N NT;;;Delay source (Container or Stream or empty)\n"
+ "Delay_Source/String;;;N NT;;;Delay source (Container or Stream or empty)\n"
+ "Delay_Original;; ms;N NI;;;Delay fixed in the raw stream (relative) IN MS\n"
+ "Delay_Original/String;;;N NT;;;Delay with measurement\n"
+ "Delay_Original/String1;;;N NT;;;Delay with measurement\n"
+ "Delay_Original/String2;;;N NT;;;Delay with measurement\n"
+ "Delay_Original/String3;;;N NT;;;Delay in format: HH:MM:SS.MMM;\n"
+ "Delay_Original/String4;;;N NT;;;Delay in format: HH:MM:SS:FF (HH:MM:SS;FF for drop frame, if available)\n"
+ "Delay_Original_Settings;;;N NT;;;Delay settings (in case of timecode for example);\n"
+ "Delay_Original_Source;;;N NT;;;Delay source (Stream or empty)\n"
+ "Video_Delay;; ms;N NI;;;Delay fixed in the stream (absolute / video)\n"
+ "Video_Delay/String;;;Y NT;;\n"
+ "Video_Delay/String1;;;N NT;;\n"
+ "Video_Delay/String2;;;N NT;;\n"
+ "Video_Delay/String3;;;N NT;;\n"
+ "Video_Delay/String4;;;N NT;;\n"
+ "Video0_Delay;; ms;N NI;;;Deprecated, do not use in new projects\n"
+ "Video0_Delay/String;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Video0_Delay/String1;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Video0_Delay/String2;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Video0_Delay/String3;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Video0_Delay/String4;;;N NT;;;Deprecated, do not use in new projects\n"
+ "StreamSize;; byte;N YI;;;Streamsize in bytes;\n"
+ "StreamSize/String;;;Y NT;;;Streamsize in with percentage value;\n"
+ "StreamSize/String1;;;N NT;;;;\n"
+ "StreamSize/String2;;;N NT;;;;\n"
+ "StreamSize/String3;;;N NT;;;;\n"
+ "StreamSize/String4;;;N NT;;;;\n"
+ "StreamSize/String5;;;N NT;;;Streamsize in with percentage value;\n"
+ "StreamSize_Proportion;;;N NT;;;Stream size divided by file size;\n"
+ "Source_StreamSize;; byte;N YI;;;Source Streamsize in bytes;\n"
+ "Source_StreamSize/String;;;Y NT;;;Source Streamsize in with percentage value;\n"
+ "Source_StreamSize/String1;;;N NT;;;;\n"
+ "Source_StreamSize/String2;;;N NT;;;;\n"
+ "Source_StreamSize/String3;;;N NT;;;;\n"
+ "Source_StreamSize/String4;;;N NT;;;;\n"
+ "Source_StreamSize/String5;;;N NT;;;Source Streamsize in with percentage value;\n"
+ "Source_StreamSize_Proportion;;;N NT;;;Source Stream size divided by file size;\n"
+ "StreamSize_Encoded;; byte;N YI;;;Encoded Streamsize in bytes;\n"
+ "StreamSize_Encoded/String;;;Y NT;;;Encoded Streamsize in with percentage value;\n"
+ "StreamSize_Encoded/String1;;;N NT;;;;\n"
+ "StreamSize_Encoded/String2;;;N NT;;;;\n"
+ "StreamSize_Encoded/String3;;;N NT;;;;\n"
+ "StreamSize_Encoded/String4;;;N NT;;;;\n"
+ "StreamSize_Encoded/String5;;;N NT;;;Encoded Streamsize in with percentage value;\n"
+ "StreamSize_Encoded_Proportion;;;N NT;;;Encoded Stream size divided by file size;\n"
+ "Source_StreamSize_Encoded;; byte;N YI;;;Source Encoded Streamsize in bytes;\n"
+ "Source_StreamSize_Encoded/String;;;Y NT;;;Source Encoded Streamsize in with percentage value;\n"
+ "Source_StreamSize_Encoded/String1;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String2;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String3;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String4;;;N NT;;;;\n"
+ "Source_StreamSize_Encoded/String5;;;N NT;;;Source Encoded Streamsize in with percentage value;\n"
+ "Source_StreamSize_Encoded_Proportion;;;N NT;;;Source Encoded Stream size divided by file size;\n"
+ "Title;;;Y YI;;;Name of the track\n"
+ "Encoded_Library;;;N YT;;;Software used to create the file\n"
+ "Encoded_Library/String;;;Y NT;;;Software used to create the file\n"
+ "Encoded_Library/Name;;;N NT;;;Info from the software\n"
+ "Encoded_Library/Version;;;N NT;;;Version of software\n"
+ "Encoded_Library/Date;;;N NT;;;Release date of software\n"
+ "Encoded_Library_Settings;;;Y YT;;;Parameters used by the software\n"
+ "Language;;;N YT;;;Language (2-letter ISO 639-1 if exists, else 3-letter ISO 639-2, and with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn)\n"
+ "Language/String;;;Y NT;;;Language (full)\n"
+ "Language/String1;;;N NT;;;Language (full)\n"
+ "Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty)\n"
+ "Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);\n"
+ "Language/String4;;;N NT;;;Language (2-letter ISO 639-1 if exists with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn, else empty);\n"
+ "Language_More;;;Y YT;;;More info about Language (e.g. Director's Comment);\n"
+ "Default;;Yes;N YT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Default/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Forced;;Yes;N YT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Forced/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Summary;;;N NT;;;;\n"
+ "Encoded_Date;;;Y YT;;;The time that the encoding of this item was completed began.;;Temporal\n"
+ "Tagged_Date;;;Y YT;;;The time that the tags were done for this item.;;Temporal\n"
+ "Encryption;;;Y YT;;;;\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Chapters (ZtringListList &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "Count;;;N NI;;;Count of objects available in this stream\n"
+ "StreamCount;;;N NI;;;Count of streams of that kind available\n"
+ "StreamKind;Chapters;;N NI;;;Stream type name\n"
+ "StreamKind/String;;;N NI;;;Stream type name\n"
+ "StreamKindID;;;N NI;;;Number of the stream (base=0)\n"
+ "StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1)\n"
+ "StreamOrder;;;N NI;;;Stream order in the file, whatever is the kind of stream (base=0)\n"
+ "Inform;;;N NT;;;Last **Inform** call\n"
+ "ID;;;N YI;;;A ID for this stream in this file\n"
+ "ID/String;;;Y NT;;;A ID for this stream in this file\n"
+ "UniqueID;;;N YI;;;A unique ID for this stream, should be copied with stream copy\n"
+ "MenuID;;;N YI;;;The menu ID for this stream in this file\n"
+ "MenuID/String;;;Y NT;;;The menu ID for this stream in this file\n"
+ "Format;;;Y YT;;;Format used\n"
+ "Format/Info;;;Y NT;;;Info about Format\n"
+ "Format/Url;;;N NT;;;Link\n"
+ "Codec;;;N YT;;;Deprecated\n"
+ "Codec/String;;;Y NT;;;Deprecated\n"
+ "Codec/Info;;;Y NT;;;Deprecated\n"
+ "Codec/Url;;;Y YT;;;Deprecated\n"
+ "Total;;;N YT;;;Total number of chapters\n"
+ "Title;;;Y YI;;;Name of the track\n"
+ "Language/String;;;Y NT;;;Language (full);\n"
+ "Language/String1;;;N NT;;;Language (full);\n"
+ "Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty);\n"
+ "Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);\n"
+ "Language/String4;;;N NT;;;Language (2-letter ISO 639-1 if exists with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn, else empty);\n"
+ "Language_More;;;Y YT;;;More info about Language (e.g. Director's Comment);\n"
+ "Default;;Yes;N YT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Default/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Forced;;Yes;N YT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Forced/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference.\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Image (ZtringListList &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "Count;;;N YI;;;Count of objects available in this stream\n"
+ "Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished)\n"
+ "StreamCount;;;N YI;;;Count of streams of that kind available\n"
+ "StreamKind;Image;;N NI;;;Stream type name\n"
+ "StreamKind/String;;;N NI;;;Stream type name\n"
+ "StreamKindID;;;N NI;;;Number of the stream (base=0)\n"
+ "StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1)\n"
+ "StreamOrder;;;N NI;;;Stream order in the file, whatever is the kind of stream (base=0)\n"
+ "Inform;;;N NT;;;Last **Inform** call\n"
+ "ID;;;N YI;;;A ID for this stream in this file\n"
+ "ID/String;;;Y NT;;;The ID for this stream in this file\n"
+ "UniqueID;;;N YI;;;A unique ID for this stream, should be copied with stream copy\n"
+ "UniqueID/String;;;Y NT;;;A unique ID for this stream, should be copied with stream copy\n"
+ "MenuID;;;N YI;;;The menu ID for this stream in this file\n"
+ "MenuID/String;;;Y NT;;;The menu ID for this stream in this file\n"
+ "Title;;;Y YI;;;Name of the track\n"
+ "Format;;;Y YT;;;Format used\n"
+ "Format/Info;;;Y NT;;;Info about Format\n"
+ "Format/Url;;;N NT;;;Link\n"
+ "Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference\n"
+ "Format_Commercial_IfAny;;;Y NT;;;Commercial name used by vendor for theses setings if there is one\n"
+ "Format_Version;;;Y NT;;;Version of this format\n"
+ "Format_Profile;;;Y NT;;;Profile of the Format\n"
+ "Format_Compression;;;Y NT;;;Compression method used;\n"
+ "Format_Settings;;;Y NT;;;Settings needed for decoder used\n"
+ "Format_Settings_Wrapping;;;Y YT;;;Wrapping mode (Frame wrapped or Clip wrapped)\n"
+ "InternetMediaType;;;N YT;;;Internet Media Type (aka MIME Type, Content-Type)\n"
+ "CodecID;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/String;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/Info;;;Y NT;;;Info about codec ID\n"
+ "CodecID/Hint;;;Y NT;;;A hint for this codec ID\n"
+ "CodecID/Url;;;N NT;;;A link for more details about this codec ID\n"
+ "CodecID_Description;;;Y NT;;;Manual description given by the container\n"
+ "Codec;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/String;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/Family;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/Info;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Codec/Url;;;N NT;;;Deprecated, do not use in new projects\n"
+ "Width;; pixel;N YI;;;Width (aperture size if present) in pixel\n"
+ "Width/String;;;Y NT;;;Width (aperture size if present) with measurement (pixel)\n"
+ "Width_Offset;; pixel;N YI;;;Offset between original width and displayed width (aperture size) in pixel\n"
+ "Width_Offset/String;;;N NT;;;Offset between original width and displayed width (aperture size) in pixel\n"
+ "Width_Original;; pixel;N YI;;;Original (in the raw stream) width in pixel\n"
+ "Width_Original/String;;;Y NT;;;Original (in the raw stream) width with measurement (pixel)\n"
+ "Height;; pixel;N YI;;;Height (aperture size if present) in pixel\n"
+ "Height/String;;;Y NT;;;Height (aperture size if present) with measurement (pixel)\n"
+ "Height_Offset;; pixel;N YI;;;Offset between original height and displayed height (aperture size) in pixel\n"
+ "Height_Offset/String;;;N NT;;;Offset between original height and displayed height (aperture size) in pixel\n"
+ "Height_Original;; pixel;N YI;;;Original (in the raw stream) height in pixel\n"
+ "Height_Original/String;;;Y NT;;;Original (in the raw stream) height with measurement (pixel)\n"
+ "PixelAspectRatio;;;N YF;;;Pixel Aspect ratio\n"
+ "PixelAspectRatio/String;;;N NT;;;Pixel Aspect ratio\n"
+ "PixelAspectRatio_Original;;;N YF;;;Original (in the raw stream) Pixel Aspect ratio\n"
+ "PixelAspectRatio_Original/String;;;N NT;;;Original (in the raw stream) Pixel Aspect ratio\n"
+ "DisplayAspectRatio;;;N YF;;;Display Aspect ratio\n"
+ "DisplayAspectRatio/String;;;Y NT;;;Display Aspect ratio\n"
+ "DisplayAspectRatio_Original;;;N YF;;;Original (in the raw stream) Display Aspect ratio\n"
+ "DisplayAspectRatio_Original/String;;;Y NT;;;Original (in the raw stream) Display Aspect ratio\n"
+ "ColorSpace;;;Y YT;;\n"
+ "ChromaSubsampling;;;Y YT;;\n"
+ "Resolution;; bit;N NI;;;Deprecated, do not use in new projects\n"
+ "Resolution/String;;;N NT;;;Deprecated, do not use in new projects\n"
+ "BitDepth;; bit;N YI;;\n"
+ "BitDepth/String;;;Y NT;;\n"
+ "Compression_Mode;;;N YT;;;Compression mode (Lossy or Lossless)\n"
+ "Compression_Mode/String;;;Y NT;;;Compression mode (Lossy or Lossless)\n"
+ "Compression_Ratio;;;Y YF;;;Current stream size divided by uncompressed stream size;\n"
+ "StreamSize;; byte;N YI;;;Stream size in bytes\n"
+ "StreamSize/String;;;Y NT;;\n"
+ "StreamSize/String1;;;N NT;;\n"
+ "StreamSize/String2;;;N NT;;\n"
+ "StreamSize/String3;;;N NT;;\n"
+ "StreamSize/String4;;;N NT;;\n"
+ "StreamSize/String5;;;N NT;;;With proportion;\n"
+ "StreamSize_Proportion;;;N NT;;;Stream size divided by file size;\n"
+ "Encoded_Library;;;N YT;;;Software used to create the file;\n"
+ "Encoded_Library/String;;;Y NT;;;Software used to create the file;\n"
+ "Encoded_Library/Name;;;N NT;;;Info from the software;\n"
+ "Encoded_Library/Version;;;N NT;;;Version of software;\n"
+ "Encoded_Library/Date;;;N NT;;;Release date of software;\n"
+ "Encoded_Library_Settings;;;Y YT;;;Parameters used by the software;\n"
+ "Language;;;N YT;;;Language (2-letter ISO 639-1 if exists, else 3-letter ISO 639-2, and with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn);\n"
+ "Language/String;;;Y NT;;;Language (full);\n"
+ "Language/String1;;;N NT;;;Language (full);\n"
+ "Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty);\n"
+ "Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);\n"
+ "Language/String4;;;N NT;;;Language (2-letter ISO 639-1 if exists with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn, else empty);\n"
+ "Language_More;;;Y YT;;;More info about Language (e.g. Director's Comment);\n"
+ "Default;;Yes;N YT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Default/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Forced;;Yes;N YT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Forced/String;;;Y NT;;;Set if that track should be used if no language found matches the user preference.\n"
+ "Summary;;;N NT;;;;\n"
+ "Encoded_Date;;;Y YT;;;The time that the encoding of this item was completed began.;;Temporal\n"
+ "Tagged_Date;;;Y YT;;;The time that the tags were done for this item.;;Temporal\n"
+ "Encryption;;;Y YT;;;;\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Menu (ZtringListList &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "Count;;;N NI;;;Count of objects available in this stream\n"
+ "Status;;;N NI;;;bit field (0=IsAccepted, 1=IsFilled, 2=IsUpdated, 3=IsFinished)\n"
+ "StreamCount;;;N NI;;;Count of streams of that kind available\n"
+ "StreamKind;Menu;;N NI;;;Stream type name\n"
+ "StreamKind/String;;;N NI;;;Stream type name\n"
+ "StreamKindID;;;N NI;;;Number of the stream (base=0)\n"
+ "StreamKindPos;;;N NI;;;When multiple streams, number of the stream (base=1)\n"
+ "StreamOrder;;;N NI;;;Stream order in the file, whatever is the kind of stream (base=0)\n"
+ "Inform;;;N NT;;;Last **Inform** call\n"
+ "ID;;;N YI;;;A ID for this stream in this file\n"
+ "ID/String;;;Y NT;;;A ID for this stream in this file\n"
+ "UniqueID;;;N YI;;;A unique ID for this stream, should be copied with stream copy\n"
+ "UniqueID/String;;;Y NT;;;A unique ID for this stream, should be copied with stream copy\n"
+ "MenuID;;;N YI;;;A menu ID for this stream in this file\n"
+ "MenuID/String;;;Y NT;;;A menu ID for this stream in this file\n"
+ "Format;;;N YT;;;Format used\n"
+ "Format/Info;;;N NT;;;Info about Format\n"
+ "Format/Url;;;N NT;;;Link\n"
+ "Format_Commercial;;;N NT;;;Commercial name used by vendor for theses setings or Format field if there is no difference\n"
+ "Format_Commercial_IfAny;;;Y NT;;;Commercial name used by vendor for theses setings if there is one\n"
+ "Format_Version;;;Y NT;;;Version of this format\n"
+ "Format_Profile;;;Y NT;;;Profile of the Format\n"
+ "Format_Compression;;;Y NT;;;Compression method used;\n"
+ "Format_Settings;;;Y NT;;;Settings needed for decoder used\n"
+ "CodecID;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/String;;;Y NT;;;Codec ID (found in some containers);\n"
+ "CodecID/Info;;;Y NT;;;Info about this codec\n"
+ "CodecID/Hint;;;Y NT;;;A hint/popular name for this codec\n"
+ "CodecID/Url;;;N NT;;;A link to more details about this codec ID\n"
+ "CodecID_Description;;;Y NT;;;Manual description given by the container\n"
+ "Codec;;;N YT;;;Deprecated\n"
+ "Codec/String;;;N NT;;;Deprecated\n"
+ "Codec/Info;;;N NT;;;Deprecated\n"
+ "Codec/Url;;;N NT;;;Deprecated\n"
+ "Duration;; ms;N YI;;;Play time of the stream in ms\n"
+ "Duration/String;;;Y NT;;;Play time in format : XXx YYy only, YYy omited if zero\n"
+ "Duration/String1;;;N NT;;;Play time in format : HHh MMmn SSs MMMms, XX omited if zero\n"
+ "Duration/String2;;;N NT;;;Play time in format : XXx YYy only, YYy omited if zero\n"
+ "Duration/String3;;;N NT;;;Play time in format : HH:MM:SS.MMM\n"
+ "Duration_Start;;;Y YT;;\n"
+ "Duration_End;;;Y YT;;\n"
+ "Delay;; ms;N NI;;;Delay fixed in the stream (relative) IN MS\n"
+ "Delay/String;;;N NT;;;Delay with measurement\n"
+ "Delay/String1;;;N NT;;;Delay with measurement\n"
+ "Delay/String2;;;N NT;;;Delay with measurement\n"
+ "Delay/String3;;;N NT;;;Delay in format : HH:MM:SS.MMM\n"
+ "Delay/String4;;;N NT;;;Delay in format : HH:MM:SS:FF (HH:MM:SS;FF for drop frame, if available)\n"
+ "Delay_Settings;;;N NT;;;Delay settings (in case of timecode for example)\n"
+ "Delay_Source;;;N NT;;;Delay source (Container or Stream or empty)\n"
+ "List_StreamKind;;;N YT;;;List of programs available\n"
+ "List_StreamPos;;;N YT;;;List of programs available\n"
+ "List;;;N YT;;;List of programs available\n"
+ "List/String;;;Y NT;;;List of programs available\n"
+ "Title;;;Y YI;;;Name of this menu\n"
+ "Language;;;N YT;;;Language (2-letter ISO 639-1 if exists, else 3-letter ISO 639-2, and with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn)\n"
+ "Language/String;;;Y NT;;;Language (full)\n"
+ "Language/String1;;;N NT;;;Language (full);\n"
+ "Language/String2;;;N NT;;;Language (2-letter ISO 639-1 if exists, else empty);\n"
+ "Language/String3;;;N NT;;;Language (3-letter ISO 639-2 if exists, else empty);\n"
+ "Language/String4;;;N NT;;;Language (2-letter ISO 639-1 if exists with optional ISO 3166-1 country separated by a dash if available, e.g. en, en-us, zh-cn, else empty);\n"
+ "Language_More;;;Y YT;;;More info about Language (e.g. Director's Comment);\n"
+ "ServiceName;;;Y YT;;;;;Legal\n"
+ "ServiceChannel;;;Y YT;;;;;Legal\n"
+ "Service/Url;;;Y YT;;;;;Legal\n"
+ "ServiceProvider;;;Y YT;;;;;Legal\n"
+ "ServiceProviderr/Url;;;Y YT;;;;;Legal\n"
+ "ServiceType;;;Y YT;;;;;Legal\n"
+ "NetworkName;;;Y YT;;;;;Legal\n"
+ "Original/NetworkName;;;Y YT;;;;;Legal\n"
+ "Countries;;;Y YT;;;;;Legal\n"
+ "TimeZones;;;Y YT;;;;;Legal\n"
+ "Chapters_Pos_Begin;;;N NI;;;Used by third-party developers to know about the beginning of the chapters list, to be used by Get(Stream_Menu, x, Pos), where Pos is an Integer between Chapters_Pos_Begin and Chapters_Pos_End;\n"
+ "Chapters_Pos_End;;;N NI;;;Used by third-party developers to know about the end of the chapters list (this position excluded)\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Iso639_1 (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "aar;aa\n"
+ "abk;ab\n"
+ "ave;ae\n"
+ "afr;af\n"
+ "aka;ak\n"
+ "amh;am\n"
+ "arg;an\n"
+ "ara;ar\n"
+ "asm;as\n"
+ "ava;av\n"
+ "aym;ay\n"
+ "aze;az\n"
+ "bak;ba\n"
+ "bel;be\n"
+ "bul;bg\n"
+ "bih;bh\n"
+ "bis;bi\n"
+ "bam;bm\n"
+ "ben;bn\n"
+ "tib;bo\n"
+ "tib;bo\n"
+ "bre;br\n"
+ "bos;bs\n"
+ "cat;ca\n"
+ "che;ce\n"
+ "cha;ch\n"
+ "cos;co\n"
+ "cre;cr\n"
+ "ces;cs\n"
+ "cze;cs\n"
+ "chu;cu\n"
+ "chv;cv\n"
+ "cym;cy\n"
+ "wel;cy\n"
+ "dan;da\n"
+ "deu;de\n"
+ "ger;de\n"
+ "div;dv\n"
+ "dzo;dz\n"
+ "ewe;ee\n"
+ "gre;el\n"
+ "ell;el\n"
+ "eng;en\n"
+ "epo;eo\n"
+ "spa;es\n"
+ "est;et\n"
+ "baq;eu\n"
+ "eus;eu\n"
+ "fas;fa\n"
+ "per;fa\n"
+ "ful;ff\n"
+ "fin;fi\n"
+ "fij;fj\n"
+ "fao;fo\n"
+ "fra;fr\n"
+ "fre;fr\n"
+ "fry;fy\n"
+ "gle;ga\n"
+ "gla;gd\n"
+ "glg;gl\n"
+ "grn;gn\n"
+ "guj;gu\n"
+ "glv;gv\n"
+ "hau;ha\n"
+ "heb;he\n"
+ "hin;hi\n"
+ "hmo;ho\n"
+ "hrv;hr\n"
+ "hrv;hr\n"
+ "hat;ht\n"
+ "hun;hu\n"
+ "hye;hy\n"
+ "arm;hy\n"
+ "her;hz\n"
+ "ina;ia\n"
+ "ind;id\n"
+ "ile;ie\n"
+ "ibo;ig\n"
+ "iii;ii\n"
+ "ipk;ik\n"
+ "ido;io\n"
+ "ice;is\n"
+ "isl;is\n"
+ "ita;it\n"
+ "iku;iu\n"
+ "jpn;ja\n"
+ "jav;jv\n"
+ "geo;ka\n"
+ "kat;ka\n"
+ "kon;kg\n"
+ "kik;ki\n"
+ "kua;kj\n"
+ "kaz;kk\n"
+ "kal;kl\n"
+ "khm;km\n"
+ "kan;kn\n"
+ "kor;ko\n"
+ "kau;kr\n"
+ "kas;ks\n"
+ "kur;ku\n"
+ "kom;kv\n"
+ "cor;kw\n"
+ "kir;ky\n"
+ "lat;la\n"
+ "ltz;lb\n"
+ "lug;lg\n"
+ "lim;li\n"
+ "lin;ln\n"
+ "lao;lo\n"
+ "lit;lt\n"
+ "lub;lu\n"
+ "lav;lv\n"
+ "mlg;mg\n"
+ "mah;mh\n"
+ "mao;mi\n"
+ "mri;mi\n"
+ "mac;mk\n"
+ "mkd;mk\n"
+ "mal;ml\n"
+ "mon;mn\n"
+ "mol;mo\n"
+ "mar;mr\n"
+ "may;ms\n"
+ "msa;ms\n"
+ "mlt;mt\n"
+ "bur;my\n"
+ "mya;my\n"
+ "nau;na\n"
+ "nob;nb\n"
+ "nde;nd\n"
+ "nde;nd\n"
+ "nep;ne\n"
+ "ndo;ng\n"
+ "dut;nl\n"
+ "nld;nl\n"
+ "nno;nn\n"
+ "nor;no\n"
+ "nbl;nr\n"
+ "nbl;nr\n"
+ "nav;nv\n"
+ "nya;ny\n"
+ "oci;oc\n"
+ "oji;oj\n"
+ "orm;om\n"
+ "ori;or\n"
+ "oss;os\n"
+ "pan;pa\n"
+ "pli;pi\n"
+ "pol;pl\n"
+ "pus;ps\n"
+ "por;pt\n"
+ "que;qu\n"
+ "roh;rm\n"
+ "run;rn\n"
+ "ron;ro\n"
+ "rum;ro\n"
+ "rus;ru\n"
+ "kin;rw\n"
+ "san;sa\n"
+ "srd;sc\n"
+ "snd;sd\n"
+ "sme;se\n"
+ "sag;sg\n"
+ "sin;si\n"
+ "slk;sk\n"
+ "slo;sk\n"
+ "slv;sl\n"
+ "smo;sm\n"
+ "sna;sn\n"
+ "som;so\n"
+ "alb;sq\n"
+ "sqi;sq\n"
+ "scc;sr\n"
+ "srp;sr\n"
+ "ssw;ss\n"
+ "sot;st\n"
+ "sun;su\n"
+ "swe;sv\n"
+ "swa;sw\n"
+ "tam;ta\n"
+ "tel;te\n"
+ "tgk;tg\n"
+ "tha;th\n"
+ "tir;ti\n"
+ "tuk;tk\n"
+ "tgl;tl\n"
+ "tsn;tn\n"
+ "ton;to\n"
+ "tur;tr\n"
+ "tso;ts\n"
+ "tat;tt\n"
+ "twi;tw\n"
+ "tah;ty\n"
+ "uig;ug\n"
+ "ukr;uk\n"
+ "urd;ur\n"
+ "uzb;uz\n"
+ "ven;ve\n"
+ "vie;vi\n"
+ "vol;vo\n"
+ "wln;wa\n"
+ "wol;wo\n"
+ "xho;xh\n"
+ "yid;yi\n"
+ "yor;yo\n"
+ "zha;za\n"
+ "chi;zh\n"
+ "zho;zh\n"
+ "zul;zu\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Iso639_2 (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "aa;aar\n"
+ "ab;abk\n"
+ "ae;ave\n"
+ "af;afr\n"
+ "ak;aka\n"
+ "am;amh\n"
+ "an;arg\n"
+ "ar;ara\n"
+ "as;asm\n"
+ "av;ava\n"
+ "ay;aym\n"
+ "az;aze\n"
+ "ba;bak\n"
+ "be;bel\n"
+ "bg;bul\n"
+ "bh;bih\n"
+ "bi;bis\n"
+ "bm;bam\n"
+ "bn;ben\n"
+ "bo;tib\n"
+ "bo;tib\n"
+ "br;bre\n"
+ "bs;bos\n"
+ "ca;cat\n"
+ "ce;che\n"
+ "ch;cha\n"
+ "co;cos\n"
+ "cr;cre\n"
+ "cs;ces\n"
+ "cs;cze\n"
+ "cu;chu\n"
+ "cv;chv\n"
+ "cy;cym\n"
+ "cy;wel\n"
+ "da;dan\n"
+ "de;deu\n"
+ "de;ger\n"
+ "dv;div\n"
+ "dz;dzo\n"
+ "ee;ewe\n"
+ "el;gre\n"
+ "el;ell\n"
+ "en;eng\n"
+ "eo;epo\n"
+ "es;spa\n"
+ "et;est\n"
+ "eu;baq\n"
+ "eu;eus\n"
+ "fa;fas\n"
+ "fa;per\n"
+ "ff;ful\n"
+ "fi;fin\n"
+ "fj;fij\n"
+ "fo;fao\n"
+ "fr;fra\n"
+ "fr;fre\n"
+ "fy;fry\n"
+ "ga;gle\n"
+ "gd;gla\n"
+ "gl;glg\n"
+ "gn;grn\n"
+ "gu;guj\n"
+ "gv;glv\n"
+ "ha;hau\n"
+ "he;heb\n"
+ "hi;hin\n"
+ "ho;hmo\n"
+ "hr;hrv\n"
+ "hr;hrv\n"
+ "ht;hat\n"
+ "hu;hun\n"
+ "hy;hye\n"
+ "hy;arm\n"
+ "hz;her\n"
+ "ia;ina\n"
+ "id;ind\n"
+ "ie;ile\n"
+ "ig;ibo\n"
+ "ii;iii\n"
+ "ik;ipk\n"
+ "io;ido\n"
+ "is;ice\n"
+ "is;isl\n"
+ "it;ita\n"
+ "iu;iku\n"
+ "ja;jpn\n"
+ "jv;jav\n"
+ "ka;geo\n"
+ "ka;kat\n"
+ "kg;kon\n"
+ "ki;kik\n"
+ "kj;kua\n"
+ "kk;kaz\n"
+ "kl;kal\n"
+ "km;khm\n"
+ "kn;kan\n"
+ "ko;kor\n"
+ "kr;kau\n"
+ "ks;kas\n"
+ "ku;kur\n"
+ "kv;kom\n"
+ "kw;cor\n"
+ "ky;kir\n"
+ "la;lat\n"
+ "lb;ltz\n"
+ "lg;lug\n"
+ "li;lim\n"
+ "ln;lin\n"
+ "lo;lao\n"
+ "lt;lit\n"
+ "lu;lub\n"
+ "lv;lav\n"
+ "mg;mlg\n"
+ "mh;mah\n"
+ "mi;mao\n"
+ "mi;mri\n"
+ "mk;mac\n"
+ "mk;mkd\n"
+ "ml;mal\n"
+ "mn;mon\n"
+ "mo;mol\n"
+ "mr;mar\n"
+ "ms;may\n"
+ "ms;msa\n"
+ "mt;mlt\n"
+ "my;bur\n"
+ "my;mya\n"
+ "na;nau\n"
+ "nb;nob\n"
+ "nd;nde\n"
+ "nd;nde\n"
+ "ne;nep\n"
+ "ng;ndo\n"
+ "nl;dut\n"
+ "nl;nld\n"
+ "nn;nno\n"
+ "no;nor\n"
+ "nr;nbl\n"
+ "nr;nbl\n"
+ "nv;nav\n"
+ "ny;nya\n"
+ "oc;oci\n"
+ "oj;oji\n"
+ "om;orm\n"
+ "or;ori\n"
+ "os;oss\n"
+ "pa;pan\n"
+ "pi;pli\n"
+ "pl;pol\n"
+ "ps;pus\n"
+ "pt;por\n"
+ "qu;que\n"
+ "rm;roh\n"
+ "rn;run\n"
+ "ro;ron\n"
+ "ro;rum\n"
+ "ru;rus\n"
+ "rw;kin\n"
+ "sa;san\n"
+ "sc;srd\n"
+ "sd;snd\n"
+ "se;sme\n"
+ "sg;sag\n"
+ "si;sin\n"
+ "sk;slk\n"
+ "sk;slo\n"
+ "sl;slv\n"
+ "sm;smo\n"
+ "sn;sna\n"
+ "so;som\n"
+ "sq;alb\n"
+ "sq;sqi\n"
+ "sr;scc\n"
+ "sr;srp\n"
+ "ss;ssw\n"
+ "st;sot\n"
+ "su;sun\n"
+ "sv;swe\n"
+ "sw;swa\n"
+ "ta;tam\n"
+ "te;tel\n"
+ "tg;tgk\n"
+ "th;tha\n"
+ "ti;tir\n"
+ "tk;tuk\n"
+ "tl;tgl\n"
+ "tn;tsn\n"
+ "to;ton\n"
+ "tr;tur\n"
+ "ts;tso\n"
+ "tt;tat\n"
+ "tw;twi\n"
+ "ty;tah\n"
+ "ug;uig\n"
+ "uk;ukr\n"
+ "ur;urd\n"
+ "uz;uzb\n"
+ "ve;ven\n"
+ "vi;vie\n"
+ "vo;vol\n"
+ "wa;wln\n"
+ "wo;wol\n"
+ "xh;xho\n"
+ "yi;yid\n"
+ "yo;yor\n"
+ "za;zha\n"
+ "zh;chi\n"
+ "zh;zho\n"
+ "zu;zul\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Library_DivX (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "Main source;http://xmm.sourceforge.net/DivX5-6_Xvid_Bitstream_version.php\n"
+ "413;5.0.0;UTC 2002-03-04\n"
+ "450;5.0.1;UTC 2002-04-09\n"
+ "481;5.0.2;UTC 2002-05-16\n"
+ "484;5.0.2;UTC 2002-05-16\n"
+ "487;5.0.2;UTC 2002-05-16\n"
+ "696;5.0.5 Beta(Tahanea);UTC 2003-01\n"
+ "740;5.0.3;UTC 2003-01-24\n"
+ "795;5.0.4 Beta1or2(Schizo);UTC 2003-01\n"
+ "804;5.0.4 Beta3(Schizo);UTC 2003-01\n"
+ "814;5.0.4 Beta4(Schizo);UTC 2003-01\n"
+ "822;5.0.4;UTC 2003-04-17\n"
+ "830;5.0.5;UTC 2003-04-24\n"
+ "894;5.0.5 Kauehi;UTC 2003-07-02\n"
+ "922;5.1.0 Beta1(Manihi);UTC 2003-07-26\n"
+ "936;5.1.0 Beta2(Kaukura);UTC 2003-08-02\n"
+ "959;5.1.0;UTC 2003-09-02\n"
+ "985;5.1.0 (HD?);UTC 2003-10\n"
+ "1009;5.1.1 Beta1;UTC 2003-10-21\n"
+ "1025;5.1.1 Beta2;UTC 2003-11\n"
+ "1031;5.1.1 (Maupiti);UTC 2003-11-19\n"
+ "1263;5.2.0;UTC 2004-07-15\n"
+ "1272;5.2.0 (DrDivX 105);UTC 2004-07-17\n"
+ "1307;5.2.1 Alpha;UTC 2004-09-08\n"
+ "1314;5.2.1 Beta;UTC 2004-09-08\n"
+ "1328;5.2.1 (WaffleDay);UTC 2004-09-08\n"
+ "1338;5.2.1 (DrDivX 106);UTC 2004-09-08\n"
+ "1394;5.3.0 Plasma Alpha (Tritium);UTC 2004-09-08\n"
+ "1408;5.3.0 Plasma Alpha (CoreBurn);UTC 2004-10\n"
+ "1429;>5.3.0, <5.9.0\n"
+ "1438;>5.3.0, <5.9.0\n"
+ "1453;5.9.0 Fusion (InertialConfinement);UTC 2005-01\n"
+ "1461;5.9.0 Fusion (HiggsBoson);UTC 2005-01\n"
+ "1528;5.9.0 Fusion (HiggsBoson);UTC 2005-03-05\n"
+ "1571;6.0.0;UTC 2005-06-15\n"
+ "1594;6.0.0 (DivX Converter1.0);UTC 2005-06\n"
+ "1599;6.0.0 Helium;UTC 2005-06\n"
+ "1612;6.0.0 Helium (GodFatherOfSoul);UTC 2005-06-15\n"
+ "1697;6.0.3 Fusion (ThermonuclearFusion);UTC 2005-10-18\n"
+ "1737;He-3 (TwinTurbocharger);UTC 2005-12\n"
+ "1786;6.1.0;UTC 2005-12-12\n"
+ "1828;6.1.1;UTC 2006-02-01\n"
+ "1893;6.2.0 Beta1;UTC 2006-03-25\n"
+ "1910;6.2.0;UTC 2006-04-11\n"
+ "1913;6.2.1;UTC 2006-04\n"
+ "1915;6.2.1 Patch1Beta;UTC 2006-04\n"
+ "1920;6.2.2;UTC 2006-04-26\n"
+ "1977;6.2.5;UTC 2006-06-16\n"
+ "1988;6.2.5;UTC 2006-07\n"
+ "2075;>6.2.5, <6.4.0\n"
+ "2081;6.4.0 Beta1;UTC 2006-09-27\n"
+ "2086;6.4.0;UTC 2006-10-03\n"
+ "2201;6.5.0;UTC 2006-12\n"
+ "2207;6.5.1;UTC 2007-03\n"
+ "2292;6.6.0;UTC 2007-05-04\n"
+ "2306;6.6.1\n"
+ "2309;6.6.1\n"
+ "2318;6.6.1.4\n"
+ "2396;6.7 Beta;UTC 2007-08-26\n"
+ "2432;6.7.0;UTC 2007-09-20\n"
+ "2510;6.8.0;UTC 2007-12-04\n"
+ "2521;6.8.0 Converter 6.6\n"
+ "2559;6.8.2;UTC 2008-05-17\n"
+ "2676;6.8.3-6.8.4;UTC 2008-06-07\n"
+ "2816;6.8.5;UTC 2009-08-20\n"
+ "2851;6.8.5;UTC 2009-08-20\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Library_XviD (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "Main source;http://xmm.sourceforge.net/DivX5-6_Xvid_Bitstream_version.php\n"
+ "1;0.0.01;UTC 2002-10-17\n"
+ "2;0.0.02;UTC 2002-10-30\n"
+ "3;0.0.03;UTC 2002-12-09\n"
+ "4;0.0.04;UTC 2003-01\n"
+ "5;0.0.05;UTC 2003-01-11\n"
+ "6;0.0.06;UTC 2003-01-12\n"
+ "7;0.0.07;UTC 2003-01-13\n"
+ "8;0.0.08;UTC 2003-01-14\n"
+ "9;0.0.09;UTC 2003-03-25\n"
+ "10;0.0.10;UTC 2003-06-09\n"
+ "11;0.0.11;UTC 2003-06-09\n"
+ "12;0.0.12;UTC 2003-06-11\n"
+ "13;0.0.13;UTC 2003-06-11\n"
+ "14;0.0.14;UTC 2003-06-28\n"
+ "15;0.0.15;UTC 2003-07-28\n"
+ "16;0.0.16;UTC 2003-07-28\n"
+ "17;0.0.17;UTC 2003-08-06\n"
+ "18;0.0.18;UTC 2003-09-04\n"
+ "19;0.0.19;UTC 2003-09-28\n"
+ "20;0.0.20;UTC 2003-10-09\n"
+ "21;1.0.0 Beta1 (Aloha);UTC 2003-11-29\n"
+ "22;1.0.0 Beta1.5;UTC 2003-12-03\n"
+ "23;1.0.0 Beta2 (Ciao);UTC 2003-12-06\n"
+ "24;1.0.0 Beta2.5;UTC 2003-12-18\n"
+ "25;1.0.0 Beta3 (Selam);UTC 2003-12-27\n"
+ "26;1.0.0 RC1 (Niltze);UTC 2004-01-26\n"
+ "27;1.0.0 RC1b;UTC 2004-01-30\n"
+ "28;1.0.0 RC2 (Jambo);UTC 2004-02-01\n"
+ "29;1.0.0 RC3 (Nihao);UTC 2004-03-22\n"
+ "30;1.0.0 RC4 (Hola);UTC 2004-04-05\n"
+ "31;1.0.0 RC4b;UTC 2004-04-15\n"
+ "32;1.0.0 RC4c;UTC 2004-05-02\n"
+ "33;1.0.0 RC4d;UTC 2004-05-03\n"
+ "34;1.0.0;UTC 2004-05-09\n"
+ "35;1.0.1;UTC 2004-06-05\n"
+ "36;1.0.2;UTC 2004-08-29\n"
+ "37;1.0.3;UTC 2004-12-20\n"
+ "38;1.1.0 Beta1;UTC 2005-01-16\n"
+ "39;1.1.0 Beta2;UTC 2005-04-04\n"
+ "40;1.1.0 RC;UTC 2005-11-22\n"
+ "41;1.1.0;UTC 2005-11-22\n"
+ "42;1.2.0.dev42;UTC 2005-12\n"
+ "43;1.2.0SMP;UTC 2006-01-08\n"
+ "44;1.1.1;UTC 2006-07-10\n"
+ "45;1.2.0.dev45;UTC 2006-07-10\n"
+ "46;1.1.2;UTC 2006-11-01\n"
+ "47;1.2.0.dev47;UTC 2006-11-01\n"
+ "48;1.2.0.dev48\n"
+ "49;1.2.0.dev49\n"
+ "50;1.2.1;UTC 2008-12-04\n"
+ "55;1.3.0.dev55\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Library_MainConcept_Avc (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "2.0.1889;2.0.1889;UTC 2006-01-11\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Library_VorbisCom (InfoMap &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "Main source;http://wiki.hydrogenaudio.org/index.php?title=Recommended_Ogg_Vorbis\n"
+ "Xiphophorus libVorbis I 20000508;1.0 Beta 1/2;UTC 2000-05-08\n"
+ "Xiphophorus libVorbis I 20001031;1.0 Beta 3;UTC 2000-10-31\n"
+ "Xiphophorus libVorbis I 20010225;1.0 Beta 4;UTC 2001-02-25\n"
+ "Xiphophorus libVorbis I 20010615;1.0 RC1;UTC 2000-16-15\n"
+ "Xiphophorus libVorbis I 20010813;1.0 RC2;UTC 2000-18-13\n"
+ "Xiphophorus libVorbis I 20010816 (gtune 1);1.0 RC2 (GTune 1);UTC 2001-08-16\n"
+ "Xiphophorus libVorbis I 20011014 (GTune 2);1.0 RC2 (GTune 2);UTC 2001-10-14\n"
+ "Xiphophorus libVorbis I 20011217;1.0 RC3;UTC 2001-12-17\n"
+ "Xiphophorus libVorbis I 20011231;1.0 RC3;UTC 2001-12-31\n"
+ "Xiph.Org libVorbis I 20020717;1.0;UTC 2002-07-17\n"
+ "Xiph.Org/Sjeng.Org libVorbis I 20020717 (GTune 3, beta 1);1.0 (GTune 3 Beta 1);UTC 2002-07-17\n"
+ "Xiph.Org libVorbis I 20030308;1.0.1 (CVS);UTC 2003-03-08\n"
+ "Xiph.Org libVorbis I 20030909;1.0.1;UTC 2003-09-09\n"
+ "Xiph.Org/Sjeng.Org libVorbis I 20030909 (GTune 3, beta 2) EXPERIMENTAL;1.0 (GTune 3 Beta 2);UTC 2003-09-09\n"
+ "Xiph.Org libVorbis I 20031230 (1.0.1);1.0.1 (CVS);UTC 2003-12-30\n"
+ "Xiph.Org/Sjeng.Org libVorbis I 20031230 (GTune 3, beta 2);1.0.1 (GTune 3 Beta 2);UTC 2003-12-30\n"
+ "AO aoTuV b2 [20040420] (based on Xiph.Org's 1.0.1);Beta 2;UTC 2004-04-20\n"
+ "Xiph.Org libVorbis I 20040629;1.1;UTC 2004-06-29\n"
+ "Xiph.Org libVorbis I 20040920;1.1 (with impulse_trigger_profile);UTC 2004-09-20\n"
+ "AO aoTuV b3 [20041120] (based on Xiph.Org's libVorbis);Beta 3;UTC 2004-11-20\n"
+ "Xiph.Org libVorbis I 20050304;1.1.1/1.1.2;UTC 2005-03-04\n"
+ "AO aoTuV b4 [20050617] (based on Xiph.Org's libVorbis);Beta 4;UTC 2005-06-17\n"
+ "BS Lancer [20050709] (based on aoTuV b4 [20050617]);(aoTuV Beta 4);UTC 2005-07-09\n"
+ "AO aoTuV b4a [20051105] (based on Xiph.Org's libVorbis);Beta 4.5;UTC 2005-11-05\n"
+ "AO aoTuV b4b [20051117] (based on Xiph.Org's libVorbis);Beta 4.51;UTC 2005-11-17\n"
+ "BS Lancer [20051121] (based on aoTuV b4b [20051117]);(aoTuV Beta 4.51);UTC 2005-11-21\n"
+ "AO aoTuV pre-beta5 [20060321] (based on Xiph.Org's libVorbis);Beta 5 (preBeta);UTC 2006-03-21\n"
+ "AO aoTuV b5 [20061024] (based on Xiph.Org's libVorbis);Beta 5;UTC 2006-10-24\n"
+ "Xiph.Org libVorbis I 20070622;1.2;UTC 2007-06-22\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_Summary (ZtringListList &Info)
+{
+ Info.Separator_Set(0, _T("\n"));
+ Info.Write(Ztring().From_UTF8(
+ "General;[%Format%][ (%Format_Profile%)][ (%Format_Commercial_IfAny%)]$if(%Format%,$: $)%FileSize/String%[, %Duration/String%]\n"
+ "Video;[%Language/String%, ][%BitRate/String%$if(%BitRate_Nominal/String%, \\(%BitRate_Nominal/String%\\)), ][%Width%*][%Height%][ (%DisplayAspectRatio/String%), ][$at$ %FrameRate/String%, ][%Format%][ (%CodecID/Hint%)][ (%Standard%)]$if(%MuxingMode%, \\(%MuxingMode%\\))$if(%Format_Version%, \\(%Format_Version%\\))$if(%Format_Profile%, \\(%Format_Profile%\\))$if(%Format_Settings%, \\(%Format_Settings%\\))[ (%Format_Commercial_IfAny%)]\n"
+ "Audio;[%Language/String%, ][%BitRate/String%$if(%BitRate_Nominal/String%, \\(%BitRate_Nominal/String%\\)), ][%SamplingRate/String%, ][%BitDepth/String%, ][%Channel(s)/String%, ][%Format%][ (%CodecID/Hint%)]$if(%MuxingMode%, \\(%MuxingMode%\\))$if(%Format_Version%, \\(%Format_Version%\\))$if(%Format_Profile%, \\(%Format_Profile%\\))$if(%Format_Settings%, \\(%Format_Settings%\\))[ (%Format_Commercial_IfAny%)]\n"
+ "Text;[%Language/String%, ][%Format%][ (%Format_Commercial_IfAny%)]$if(%MuxingMode%, \\(%MuxingMode%\\))\n"
+ "Image;[%Language/String%, ][%Width%*][%Height%][ (%DisplayAspectRatio/String%)][, %Format%]\n"
+ "Chapters;[%Language/String%, ]%Total% chapters[, %Format%][ (%Format_Commercial_IfAny%)]\n"
+ ));
+ Info.Separator_Set(0, ZenLib::EOL);
+}
+
+} //NameSpace
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_MediaInfo.cpp b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_MediaInfo.cpp
new file mode 100644
index 000000000..1ec2814c8
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_MediaInfo.cpp
@@ -0,0 +1,1674 @@
+// MediaInfo_Config_MediaInfo - Configuration class
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "ZenLib/ZtringListListF.h"
+#if MEDIAINFO_IBI
+ #include "base64.h"
+#endif //MEDIAINFO_IBI
+#include <algorithm>
+#if MEDIAINFO_DEMUX
+ #include <cmath>
+#endif //MEDIAINFO_DEMUX
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+const size_t Buffer_NormalSize=/*188*7;//*/64*1024;
+
+//***************************************************************************
+// Info
+//***************************************************************************
+
+MediaInfo_Config_MediaInfo::MediaInfo_Config_MediaInfo()
+{
+ FileIsSeekable=true;
+ FileIsSub=false;
+ FileIsReferenced=false;
+ FileKeepInfo=false;
+ FileStopAfterFilled=false;
+ FileStopSubStreamAfterFilled=false;
+ Audio_MergeMonoStreams=false;
+ File_Demux_Interleave=false;
+ File_ID_OnlyRoot=false;
+ File_TimeToLive=0;
+ File_Buffer_Size_Hint_Pointer=NULL;
+ #if MEDIAINFO_NEXTPACKET
+ NextPacket=false;
+ #endif //MEDIAINFO_NEXTPACKET
+ #if MEDIAINFO_FILTER
+ File_Filter_HasChanged_=false;
+ #endif //MEDIAINFO_FILTER
+ #if MEDIAINFO_EVENTS
+ Event_CallBackFunction=NULL;
+ Event_UserHandler=NULL;
+ SubFile_StreamID=(int64u)-1;
+ ParseUndecodableFrames=false;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_ForceIds=false;
+ Demux_PCM_20bitTo16bit=false;
+ Demux_Unpacketize=false;
+ Demux_Rate=0;
+ Demux_FirstDts=(int64u)-1;
+ Demux_FirstFrameNumber=(int64u)-1;
+ Demux_InitData=0; //In Demux event
+ #endif //MEDIAINFO_DEMUX
+ #if MEDIAINFO_IBI
+ Ibi_Create=false;
+ #endif //MEDIAINFO_IBI
+
+ //Specific
+ File_MpegTs_ForceMenu=false;
+ File_MpegTs_stream_type_Trust=true;
+ File_MpegTs_Atsc_transport_stream_id_Trust=true;
+ File_MpegTs_RealTime=false;
+ File_Bdmv_ParseTargetedFile=true;
+ #if defined(MEDIAINFO_DVDIF_YES)
+ File_DvDif_DisableAudioIfIsInContainer=false;
+ File_DvDif_IgnoreTransmittingFlags=false;
+ #endif //defined(MEDIAINFO_DVDIF_YES)
+ #if defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ File_DvDif_Analysis=false;
+ #endif //defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ #if MEDIAINFO_MACROBLOCKS
+ File_Macroblocks_Parse=false;
+ #endif //MEDIAINFO_MACROBLOCKS
+ File_GrowingFile_Delay=10;
+ #if defined(MEDIAINFO_LIBMMS_YES)
+ File_Mmsh_Describe_Only=false;
+ #endif //defined(MEDIAINFO_LIBMMS_YES)
+ File_Eia608_DisplayEmptyStream=false;
+ File_Eia708_DisplayEmptyStream=false;
+ State=0;
+
+ //Internal to MediaInfo, not thread safe
+ File_Names_Pos=0;
+ File_Buffer=NULL;
+ File_Buffer_Size_Max=0;
+ File_Buffer_Size_ToRead=Buffer_NormalSize;
+ File_Buffer_Size=0;
+ File_Buffer_Repeat=false;
+ File_Buffer_Repeat_IsSupported=false;
+ File_IsGrowing=false;
+ File_IsNotGrowingAnymore=false;
+ File_Size=(int64u)-1;
+ #if MEDIAINFO_DEMUX
+ Demux_EventWasSent=false;
+ #if MEDIAINFO_SEEK
+ Demux_IsSeeking=false;
+ #endif //MEDIAINFO_SEEK
+ #endif //MEDIAINFO_DEMUX
+}
+
+MediaInfo_Config_MediaInfo::~MediaInfo_Config_MediaInfo()
+{
+ delete[] File_Buffer; //File_Buffer=NULL;
+}
+
+//***************************************************************************
+// Info
+//***************************************************************************
+
+Ztring MediaInfo_Config_MediaInfo::Option (const String &Option, const String &Value)
+{
+ #if MEDIAINFO_EVENTS
+ SubFile_Config(Option)=Value;
+ #endif //MEDIAINFO_EVENTS
+
+ String Option_Lower(Option);
+ size_t Egal_Pos=Option_Lower.find(_T('='));
+ if (Egal_Pos==string::npos)
+ Egal_Pos=Option_Lower.size();
+ transform(Option_Lower.begin(), Option_Lower.begin()+Egal_Pos, Option_Lower.begin(), (int(*)(int))tolower); //(int(*)(int)) is a patch for unix
+
+ if (Option_Lower==_T("file_isseekable"))
+ {
+ File_IsSeekable_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_isseekable_get"))
+ {
+ return File_IsSeekable_Get()?"1":"0";
+ }
+ if (Option_Lower==_T("file_issub"))
+ {
+ File_IsSub_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_issub_get"))
+ {
+ return File_IsSub_Get()?"1":"0";
+ }
+ if (Option_Lower==_T("file_isreferenced"))
+ {
+ File_IsReferenced_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_isreferenced_get"))
+ {
+ return File_IsReferenced_Get()?"1":"0";
+ }
+ if (Option_Lower==_T("file_keepinfo"))
+ {
+ File_KeepInfo_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_keepinfo_get"))
+ {
+ return File_KeepInfo_Get()?"1":"0";
+ }
+ if (Option_Lower==_T("file_stopafterfilled"))
+ {
+ File_StopAfterFilled_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_stopafterfilled_get"))
+ {
+ return File_StopAfterFilled_Get()?"1":"0";
+ }
+ if (Option_Lower==_T("file_stopsubstreamafterfilled"))
+ {
+ File_StopSubStreamAfterFilled_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_stopsubstreamafterfilled_get"))
+ {
+ return File_StopSubStreamAfterFilled_Get()?"1":"0";
+ }
+ if (Option_Lower==_T("file_audio_mergemonostreams"))
+ {
+ File_Audio_MergeMonoStreams_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_audio_mergemonostreams_get"))
+ {
+ return File_Audio_MergeMonoStreams_Get()?"1":"0";
+ }
+ else if (Option_Lower==_T("file_demux_interleave"))
+ {
+ File_Demux_Interleave_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_demux_interleave_get"))
+ {
+ return File_Demux_Interleave_Get()?"1":"0";
+ }
+ else if (Option_Lower==_T("file_id_onlyroot"))
+ {
+ File_ID_OnlyRoot_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_id_onlyroot_get"))
+ {
+ return File_ID_OnlyRoot_Get()?"1":"0";
+ }
+ else if (Option_Lower==_T("file_filename"))
+ {
+ File_FileName_Set(Value);
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_filename_get"))
+ {
+ return File_FileName_Get();
+ }
+ else if (Option_Lower==_T("file_filenameformat"))
+ {
+ File_FileNameFormat_Set(Value);
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_filenameformat_get"))
+ {
+ return File_FileNameFormat_Get();
+ }
+ else if (Option_Lower==_T("file_timetolive"))
+ {
+ File_TimeToLive_Set(Ztring(Value).To_float64());
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_timetolive_get"))
+ {
+ return Ztring::ToZtring(File_TimeToLive_Get(), 9);
+ }
+ else if (Option_Lower==_T("file_partial_begin"))
+ {
+ File_Partial_Begin_Set(Value);
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_partial_begin_get"))
+ {
+ return File_Partial_Begin_Get();
+ }
+ else if (Option_Lower==_T("file_partial_end"))
+ {
+ File_Partial_End_Set(Value);
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_partial_end_get"))
+ {
+ return File_Partial_End_Get();
+ }
+ else if (Option_Lower==_T("file_forceparser"))
+ {
+ File_ForceParser_Set(Value);
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_forceparser_get"))
+ {
+ return File_ForceParser_Get();
+ }
+ else if (Option_Lower==_T("file_buffer_size_hint_pointer"))
+ {
+ File_Buffer_Size_Hint_Pointer_Set((size_t*)Ztring(Value).To_int64u());
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_buffer_size_hint_pointer_get"))
+ {
+ return Ztring::ToZtring((size_t)File_Buffer_Size_Hint_Pointer_Get());
+ }
+ else if (Option_Lower==_T("file_filter"))
+ {
+ #if MEDIAINFO_FILTER
+ File_Filter_Set(Ztring(Value).To_int64u());
+ return _T("");
+ #else //MEDIAINFO_FILTER
+ return _T("Filter manager is disabled due to compilation options");
+ #endif //MEDIAINFO_FILTER
+ }
+ else if (Option_Lower==_T("file_filter_get"))
+ {
+ #if MEDIAINFO_FILTER
+ return Ztring();//.From_Number(File_Filter_Get());
+ #else //MEDIAINFO_FILTER
+ return _T("Filter manager is disabled due to compilation options");
+ #endif //MEDIAINFO_FILTER
+ }
+ else if (Option_Lower==_T("file_duplicate"))
+ {
+ #if MEDIAINFO_DUPLICATE
+ return File_Duplicate_Set(Value);
+ #else //MEDIAINFO_DUPLICATE
+ return _T("Duplicate manager is disabled due to compilation options");
+ #endif //MEDIAINFO_DUPLICATE
+ }
+ else if (Option_Lower==_T("file_duplicate_get"))
+ {
+ #if MEDIAINFO_DUPLICATE
+ //if (File_Duplicate_Get())
+ return _T("1");
+ //else
+ // return _T("");
+ #else //MEDIAINFO_DUPLICATE
+ return _T("Duplicate manager is disabled due to compilation options");
+ #endif //MEDIAINFO_DUPLICATE
+ }
+ else if (Option_Lower==_T("file_demux_forceids"))
+ {
+ #if MEDIAINFO_DEMUX
+ if (Value.empty())
+ Demux_ForceIds_Set(false);
+ else
+ Demux_ForceIds_Set(true);
+ return Ztring();
+ #else //MEDIAINFO_DEMUX
+ return _T("Demux manager is disabled due to compilation options");
+ #endif //MEDIAINFO_DEMUX
+ }
+ else if (Option_Lower==_T("file_demux_pcm_20bitto16bit"))
+ {
+ #if MEDIAINFO_DEMUX
+ if (Value.empty())
+ Demux_PCM_20bitTo16bit_Set(false);
+ else
+ Demux_PCM_20bitTo16bit_Set(true);
+ return Ztring();
+ #else //MEDIAINFO_DEMUX
+ return _T("Demux manager is disabled due to compilation options");
+ #endif //MEDIAINFO_DEMUX
+ }
+ else if (Option_Lower==_T("file_demux_unpacketize"))
+ {
+ #if MEDIAINFO_DEMUX
+ if (Value.empty())
+ Demux_Unpacketize_Set(false);
+ else
+ Demux_Unpacketize_Set(true);
+ return Ztring();
+ #else //MEDIAINFO_DEMUX
+ return _T("Demux manager is disabled due to compilation options");
+ #endif //MEDIAINFO_DEMUX
+ }
+ else if (Option_Lower==_T("file_demux_rate"))
+ {
+ #if MEDIAINFO_DEMUX
+ Demux_Rate_Set(Ztring(Value).To_float64());
+ return Ztring();
+ #else //MEDIAINFO_DEMUX
+ return _T("Demux manager is disabled due to compilation options");
+ #endif //MEDIAINFO_DEMUX
+ }
+ else if (Option_Lower==_T("file_demux_firstdts"))
+ {
+ #if MEDIAINFO_DEMUX
+ int64u ValueInt64u;
+ if (Value.find(_T(":"))!=string::npos)
+ {
+ Ztring ValueZ=Value;
+ ValueInt64u=0;
+ size_t Value_Pos=ValueZ.find(_T(":"));
+ if (Value_Pos==string::npos)
+ Value_Pos=ValueZ.size();
+ ValueInt64u+=Ztring(ValueZ.substr(0, Value_Pos)).To_int64u()*60*60*1000*1000*1000;
+ ValueZ.erase(0, Value_Pos+1);
+ Value_Pos=ValueZ.find(_T(":"));
+ if (Value_Pos==string::npos)
+ Value_Pos=ValueZ.size();
+ ValueInt64u+=Ztring(ValueZ.substr(0, Value_Pos)).To_int64u()*60*1000*1000*1000;
+ ValueZ.erase(0, Value_Pos+1);
+ Value_Pos=ValueZ.find(_T("."));
+ if (Value_Pos==string::npos)
+ Value_Pos=ValueZ.size();
+ ValueInt64u+=Ztring(ValueZ.substr(0, Value_Pos)).To_int64u()*1000*1000*1000;
+ ValueZ.erase(0, Value_Pos+1);
+ if (!ValueZ.empty())
+ ValueInt64u+=Ztring(ValueZ).To_int64u()*1000*1000*1000/(int64u)pow(10.0, (int)ValueZ.size());
+ }
+ else
+ ValueInt64u=Ztring(Value).To_int64u();
+ Demux_FirstDts_Set(ValueInt64u);
+ return Ztring();
+ #else //MEDIAINFO_DEMUX
+ return _T("Demux manager is disabled due to compilation options");
+ #endif //MEDIAINFO_DEMUX
+ }
+ else if (Option_Lower==_T("file_demux_firstframenumber"))
+ {
+ #if MEDIAINFO_DEMUX
+ Demux_FirstFrameNumber_Set(Ztring(Value).To_int64u());
+ return Ztring();
+ #else //MEDIAINFO_DEMUX
+ return _T("Demux manager is disabled due to compilation options");
+ #endif //MEDIAINFO_DEMUX
+ }
+ else if (Option_Lower==_T("file_demux_initdata"))
+ {
+ #if MEDIAINFO_DEMUX
+ Ztring Value_Lower(Value); Value_Lower.MakeLowerCase();
+ if (Value_Lower==_T("event")) Demux_InitData_Set(0);
+ else if (Value_Lower==_T("field")) Demux_InitData_Set(1);
+ else return _T("Invalid value");
+ return Ztring();
+ #else //MEDIAINFO_DEMUX
+ return _T("Demux manager is disabled due to compilation options");
+ #endif //MEDIAINFO_DEMUX
+ }
+ else if (Option_Lower==_T("file_ibi"))
+ {
+ #if MEDIAINFO_IBI
+ Ibi_Set(Value);
+ return Ztring();
+ #else //MEDIAINFO_IBI
+ return _T("IBI support is disabled due to compilation options");
+ #endif //MEDIAINFO_IBI
+ }
+ else if (Option_Lower==_T("file_ibi_create"))
+ {
+ #if MEDIAINFO_IBI
+ if (Value.empty())
+ Ibi_Create_Set(false);
+ else
+ Ibi_Create_Set(true);
+ return Ztring();
+ #else //MEDIAINFO_IBI
+ return _T("IBI support is disabled due to compilation options");
+ #endif //MEDIAINFO_IBI
+ }
+ else if (Option_Lower==_T("file_nextpacket"))
+ {
+ #if MEDIAINFO_NEXTPACKET
+ if (Value.empty())
+ NextPacket_Set(false);
+ else
+ NextPacket_Set(true);
+ return Ztring();
+ #else //MEDIAINFO_NEXTPACKET
+ return _T("NextPacket manager is disabled due to compilation options");
+ #endif //MEDIAINFO_NEXTPACKET
+ }
+ else if (Option_Lower==_T("file_subfile_streamid_set"))
+ {
+ #if MEDIAINFO_EVENTS
+ SubFile_StreamID_Set(Value.empty()?(int64u)-1:Ztring(Value).To_int64u());
+ return Ztring();
+ #else //MEDIAINFO_EVENTS
+ return _T("Event manager is disabled due to compilation options");
+ #endif //MEDIAINFO_EVENTS
+ }
+ else if (Option_Lower==_T("file_subfile_ids_set"))
+ {
+ #if MEDIAINFO_EVENTS
+ SubFile_IDs_Set(Value);
+ return Ztring();
+ #else //MEDIAINFO_EVENTS
+ return _T("Event manager is disabled due to compilation options");
+ #endif //MEDIAINFO_EVENTS
+ }
+ else if (Option_Lower==_T("file_parseundecodableframes"))
+ {
+ #if MEDIAINFO_EVENTS
+ ParseUndecodableFrames_Set(!(Value==_T("0") || Value.empty()));
+ return Ztring();
+ #else //MEDIAINFO_EVENTS
+ return _T("Event manager is disabled due to compilation options");
+ #endif //MEDIAINFO_EVENTS
+ }
+ else if (Option_Lower==_T("file_mpegts_forcemenu"))
+ {
+ File_MpegTs_ForceMenu_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_mpegts_forcemenu_get"))
+ {
+ return File_MpegTs_ForceMenu_Get()?"1":"0";
+ }
+ else if (Option_Lower==_T("file_mpegts_stream_type_trust"))
+ {
+ File_MpegTs_stream_type_Trust_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_mpegts_stream_type_trust_get"))
+ {
+ return File_MpegTs_stream_type_Trust_Get()?"1":"0";
+ }
+ else if (Option_Lower==_T("file_mpegts_atsc_transport_stream_id_trust"))
+ {
+ File_MpegTs_Atsc_transport_stream_id_Trust_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_mpegts_atsc_transport_stream_id_trust_get"))
+ {
+ return File_MpegTs_Atsc_transport_stream_id_Trust_Get()?"1":"0";
+ }
+ else if (Option_Lower==_T("file_mpegts_realtime"))
+ {
+ File_MpegTs_RealTime_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_mpegts_realtime_get"))
+ {
+ return File_MpegTs_RealTime_Get()?"1":"0";
+ }
+ else if (Option_Lower==_T("file_bdmv_parsetargetedfile"))
+ {
+ File_Bdmv_ParseTargetedFile_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_bdmv_parsetargetedfile_get"))
+ {
+ return File_Bdmv_ParseTargetedFile_Get()?"1":"0";
+ }
+ else if (Option_Lower==_T("file_dvdif_disableaudioifisincontainer"))
+ {
+ #if defined(MEDIAINFO_DVDIF_YES)
+ File_DvDif_DisableAudioIfIsInContainer_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ #else //defined(MEDIAINFO_DVDIF_YES)
+ return _T("DVDIF is disabled due to compilation options");
+ #endif //defined(MEDIAINFO_DVDIF_YES)
+ }
+ else if (Option_Lower==_T("file_dvdif_disableaudioifisincontainer_get"))
+ {
+ #if defined(MEDIAINFO_DVDIF_YES)
+ return File_DvDif_DisableAudioIfIsInContainer_Get()?"1":"0";
+ #else //defined(MEDIAINFO_DVDIF_YES)
+ return _T("DVDIF is disabled due to compilation options");
+ #endif //defined(MEDIAINFO_DVDIF_YES)
+ }
+ else if (Option_Lower==_T("file_dvdif_ignoretransmittingflags"))
+ {
+ #if defined(MEDIAINFO_DVDIF_YES)
+ File_DvDif_IgnoreTransmittingFlags_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ #else //defined(MEDIAINFO_DVDIF_YES)
+ return _T("DVDIF is disabled due to compilation options");
+ #endif //defined(MEDIAINFO_DVDIF_YES)
+ }
+ else if (Option_Lower==_T("file_dvdif_ignoretransmittingflags_get"))
+ {
+ #if defined(MEDIAINFO_DVDIF_YES)
+ return File_DvDif_IgnoreTransmittingFlags_Get()?"1":"0";
+ #else //defined(MEDIAINFO_DVDIF_YES)
+ return _T("DVDIF is disabled due to compilation options");
+ #endif //defined(MEDIAINFO_DVDIF_YES)
+ }
+ else if (Option_Lower==_T("file_dvdif_analysis"))
+ {
+ #if defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ File_DvDif_Analysis_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ #else //defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ return _T("DVDIF Analysis is disabled due to compilation options");
+ #endif //defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ }
+ else if (Option_Lower==_T("file_dvdif_analysis_get"))
+ {
+ #if defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ return File_DvDif_Analysis_Get()?"1":"0";
+ #else //defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ return _T("DVDIF Analysis is disabled due to compilation options");
+ #endif //defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ }
+ else if (Option_Lower==_T("file_macroblocks_parse"))
+ {
+ #if MEDIAINFO_MACROBLOCKS
+ File_Macroblocks_Parse_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ #else //MEDIAINFO_MACROBLOCKS
+ return _T("Macroblock parsing is disabled due to compilation options");
+ #endif //MEDIAINFO_MACROBLOCKS
+ }
+ else if (Option_Lower==_T("file_macroblocks_parse_get"))
+ {
+ #if MEDIAINFO_MACROBLOCKS
+ return File_Macroblocks_Parse_Get()?"1":"0";
+ #else //MEDIAINFO_MACROBLOCKS
+ return _T("Macroblock parsing is disabled due to compilation options");
+ #endif //MEDIAINFO_MACROBLOCKS
+ }
+ else if (Option_Lower==_T("file_growingfile_delay"))
+ {
+ File_GrowingFile_Delay_Set(Ztring(Value).To_float64());
+ return Ztring();
+ }
+ else if (Option_Lower==_T("file_growingfile_delay_get"))
+ {
+ return Ztring::ToZtring(File_GrowingFile_Delay_Get());
+ }
+ else if (Option_Lower==_T("file_curl"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ File_Curl_Set(Value);
+ return _T("");
+ #else //defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif //defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower.find(_T("file_curl,"))==0 || Option_Lower.find(_T("file_curl;"))==0)
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ File_Curl_Set(Option.substr(10), Value);
+ return _T("");
+ #else //defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif //defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("file_curl_get"))
+ {
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ return File_Curl_Get(Value);
+ #else //defined(MEDIAINFO_LIBCURL_YES)
+ return _T("Libcurl support is disabled due to compilation options");
+ #endif //defined(MEDIAINFO_LIBCURL_YES)
+ }
+ else if (Option_Lower==_T("file_mmsh_describe_only"))
+ {
+ #if defined(MEDIAINFO_LIBMMS_YES)
+ File_Mmsh_Describe_Only_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ #else //defined(MEDIAINFO_LIBMMS_YES)
+ return _T("Libmms support is disabled due to compilation options");
+ #endif //defined(MEDIAINFO_LIBMMS_YES)
+ }
+ else if (Option_Lower==_T("file_mmsh_describe_only_get"))
+ {
+ #if defined(MEDIAINFO_LIBMMS_YES)
+ return File_Mmsh_Describe_Only_Get()?"1":"0";
+ #else //defined(MEDIAINFO_LIBMMS_YES)
+ return _T("Libmms support is disabled due to compilation options");
+ #endif //defined(MEDIAINFO_LIBMMS_YES)
+ }
+ else if (Option_Lower==_T("file_eia708_displayemptystream"))
+ {
+ File_Eia708_DisplayEmptyStream_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_eia708_displayemptystream_get"))
+ {
+ return File_Eia708_DisplayEmptyStream_Get()?"1":"0";
+ }
+ else if (Option_Lower==_T("file_eia608_displayemptystream"))
+ {
+ File_Eia608_DisplayEmptyStream_Set(!(Value==_T("0") || Value.empty()));
+ return _T("");
+ }
+ else if (Option_Lower==_T("file_eia608_displayemptystream_get"))
+ {
+ return File_Eia608_DisplayEmptyStream_Get()?"1":"0";
+ }
+ else if (Option_Lower==_T("file_event_callbackfunction"))
+ {
+ #if MEDIAINFO_EVENTS
+ return Event_CallBackFunction_Set(Value);
+ #else //MEDIAINFO_EVENTS
+ return _T("Event manager is disabled due to compilation options");
+ #endif //MEDIAINFO_EVENTS
+ }
+ else
+ return _T("Option not known");
+}
+
+//***************************************************************************
+// File Is Seekable
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_IsSeekable_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ FileIsSeekable=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_IsSeekable_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return FileIsSeekable;
+}
+
+//***************************************************************************
+// File Is Sub
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_IsSub_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ FileIsSub=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_IsSub_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return FileIsSub;
+}
+
+//***************************************************************************
+// File Is Referenced
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_IsReferenced_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ FileIsReferenced=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_IsReferenced_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return FileIsReferenced;
+}
+
+//***************************************************************************
+// File Keep Info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_KeepInfo_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ FileKeepInfo=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_KeepInfo_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return FileKeepInfo;
+}
+
+//***************************************************************************
+// File Keep Info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_StopAfterFilled_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ FileStopAfterFilled=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_StopAfterFilled_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return FileStopAfterFilled;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_StopSubStreamAfterFilled_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ FileStopSubStreamAfterFilled=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_StopSubStreamAfterFilled_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return FileStopSubStreamAfterFilled;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_Audio_MergeMonoStreams_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Audio_MergeMonoStreams=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_Audio_MergeMonoStreams_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Audio_MergeMonoStreams;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_Demux_Interleave_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_Demux_Interleave=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_Demux_Interleave_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return File_Demux_Interleave;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_ID_OnlyRoot_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_ID_OnlyRoot=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_ID_OnlyRoot_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return File_ID_OnlyRoot;
+}
+
+//***************************************************************************
+// File name from somewhere else
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_FileName_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_FileName=NewValue;
+}
+
+Ztring MediaInfo_Config_MediaInfo::File_FileName_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return File_FileName;
+}
+
+//***************************************************************************
+// File name format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_FileNameFormat_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_FileNameFormat=NewValue;
+}
+
+Ztring MediaInfo_Config_MediaInfo::File_FileNameFormat_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return File_FileNameFormat;
+}
+
+//***************************************************************************
+// Time to live
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_TimeToLive_Set (float64 NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_TimeToLive=NewValue;
+}
+
+float64 MediaInfo_Config_MediaInfo::File_TimeToLive_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return File_TimeToLive;
+}
+
+//***************************************************************************
+// Partial file (begin and end are cut)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_Partial_Begin_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_Partial_Begin=NewValue;
+}
+
+Ztring MediaInfo_Config_MediaInfo::File_Partial_Begin_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return File_Partial_Begin;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_Partial_End_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_Partial_End=NewValue;
+}
+
+Ztring MediaInfo_Config_MediaInfo::File_Partial_End_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return File_Partial_End;
+}
+
+//***************************************************************************
+// Force Parser
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_ForceParser_Set (const Ztring &NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_ForceParser=NewValue;
+}
+
+Ztring MediaInfo_Config_MediaInfo::File_ForceParser_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return File_ForceParser;
+}
+
+//***************************************************************************
+// File_Buffer_Size_Hint_Pointer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_Buffer_Size_Hint_Pointer_Set (size_t* NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_Buffer_Size_Hint_Pointer=NewValue;
+}
+
+size_t* MediaInfo_Config_MediaInfo::File_Buffer_Size_Hint_Pointer_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return File_Buffer_Size_Hint_Pointer;
+}
+
+//***************************************************************************
+// Filter
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_FILTER
+void MediaInfo_Config_MediaInfo::File_Filter_Set (int64u NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_Filter_16[(int16u)NewValue]=true;
+ File_Filter_HasChanged_=true;
+}
+
+bool MediaInfo_Config_MediaInfo::File_Filter_Get (const int16u Value)
+{
+ CriticalSectionLocker CSL(CS);
+ //Test
+ bool Exists;
+ if (File_Filter_16.empty())
+ Exists=true;
+ else
+ Exists=(File_Filter_16.find(Value)!=File_Filter_16.end());
+ return Exists;
+}
+
+bool MediaInfo_Config_MediaInfo::File_Filter_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ bool Exist=!File_Filter_16.empty();
+ return Exist;
+}
+
+bool MediaInfo_Config_MediaInfo::File_Filter_HasChanged ()
+{
+ CriticalSectionLocker CSL(CS);
+ bool File_Filter_HasChanged_Temp=File_Filter_HasChanged_;
+ File_Filter_HasChanged_=false;
+ return File_Filter_HasChanged_Temp;
+}
+#endif //MEDIAINFO_FILTER
+
+//***************************************************************************
+// Duplicate
+//***************************************************************************
+
+#if MEDIAINFO_DUPLICATE
+Ztring MediaInfo_Config_MediaInfo::File_Duplicate_Set (const Ztring &Value_In)
+{
+ //Preparing for File__Duplicate...
+ CS.Enter();
+ File__Duplicate_List.push_back(Value_In);
+
+ //Handling Memory index
+ Ztring ToReturn;
+ ZtringList List=Value_In;
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ //Form= "(-)Data", if "-" the value will be removed
+ Ztring &Value=List[Pos];
+ bool ToRemove=false;
+ if (Value.find(_T('-'))==0)
+ {
+ Value.erase(Value.begin());
+ ToRemove=true;
+ }
+
+ //Testing if this is information about a target
+ if (List[Pos].find(_T("memory:"))==0 || List[Pos].find(_T("file:"))==0)
+ {
+ //Searching if already exist
+ size_t Memory_Pos=File__Duplicate_Memory_Indexes.Find(List[Pos]);
+ if (!ToRemove && Memory_Pos==Error)
+ {
+ //Does not exist yet (and adding is wanted)
+ Memory_Pos=File__Duplicate_Memory_Indexes.Find(_T(""));
+ if (Memory_Pos!=Error)
+ File__Duplicate_Memory_Indexes[Memory_Pos]=List[Pos]; //A free place is found
+ else
+ {
+ //Adding the place at the end
+ Memory_Pos=File__Duplicate_Memory_Indexes.size();
+ File__Duplicate_Memory_Indexes.push_back(List[Pos]);
+ }
+ }
+ else if (ToRemove)
+ {
+ //Exists yet but Removal is wanted
+ File__Duplicate_Memory_Indexes[Memory_Pos].clear();
+ Memory_Pos=(size_t)-1;
+ }
+
+ ToReturn+=_T(";")+Ztring().From_Number(Memory_Pos);
+ }
+ }
+ if (!ToReturn.empty())
+ ToReturn.erase(ToReturn.begin()); //Remove first ";"
+
+ CS.Leave();
+ File_IsSeekable_Set(false); //If duplication, we can not seek anymore
+
+ return ToReturn;
+}
+
+Ztring MediaInfo_Config_MediaInfo::File_Duplicate_Get (size_t AlreadyRead_Pos)
+{
+ CriticalSectionLocker CSL(CS);
+ if (AlreadyRead_Pos>=File__Duplicate_List.size())
+ return Ztring(); //Nothing or not more than the last time
+ Ztring Temp=File__Duplicate_List[AlreadyRead_Pos];
+ return Temp;
+}
+
+bool MediaInfo_Config_MediaInfo::File_Duplicate_Get_AlwaysNeeded (size_t AlreadyRead_Pos)
+{
+ CriticalSectionLocker CSL(CS);
+ bool Temp=AlreadyRead_Pos>=File__Duplicate_List.size();
+ return !Temp; //True if there is something to read
+}
+
+size_t MediaInfo_Config_MediaInfo::File__Duplicate_Memory_Indexes_Get (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ return File__Duplicate_Memory_Indexes.Find(Value);
+}
+
+void MediaInfo_Config_MediaInfo::File__Duplicate_Memory_Indexes_Erase (const Ztring &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ size_t Pos=File__Duplicate_Memory_Indexes.Find(Value);
+ if (Pos!=Error)
+ File__Duplicate_Memory_Indexes[Pos].clear();
+}
+#endif //MEDIAINFO_DUPLICATE
+
+//***************************************************************************
+// Demux
+//***************************************************************************
+
+#if MEDIAINFO_DEMUX
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::Demux_ForceIds_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Demux_ForceIds=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::Demux_ForceIds_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Demux_ForceIds;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::Demux_PCM_20bitTo16bit_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Demux_PCM_20bitTo16bit=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::Demux_PCM_20bitTo16bit_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Demux_PCM_20bitTo16bit;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::Demux_Unpacketize_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Demux_Unpacketize=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::Demux_Unpacketize_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Demux_Unpacketize;
+}
+#endif //MEDIAINFO_DEMUX
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+void MediaInfo_Config_MediaInfo::Demux_Rate_Set (float64 NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Demux_Rate=NewValue;
+}
+
+float64 MediaInfo_Config_MediaInfo::Demux_Rate_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Demux_Rate;
+}
+#endif //MEDIAINFO_DEMUX
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+void MediaInfo_Config_MediaInfo::Demux_FirstDts_Set (int64u NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Demux_FirstDts=NewValue;
+}
+
+int64u MediaInfo_Config_MediaInfo::Demux_FirstDts_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Demux_FirstDts;
+}
+#endif //MEDIAINFO_DEMUX
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+void MediaInfo_Config_MediaInfo::Demux_FirstFrameNumber_Set (int64u NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Demux_FirstFrameNumber=NewValue;
+}
+
+int64u MediaInfo_Config_MediaInfo::Demux_FirstFrameNumber_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Demux_FirstFrameNumber;
+}
+#endif //MEDIAINFO_DEMUX
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+void MediaInfo_Config_MediaInfo::Demux_InitData_Set (int8u NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Demux_InitData=NewValue;
+}
+
+int8u MediaInfo_Config_MediaInfo::Demux_InitData_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Demux_InitData;
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// IBI support
+//***************************************************************************
+
+#if MEDIAINFO_IBI
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::Ibi_Set (const Ztring &Value)
+{
+ string Data_Base64=Value.To_UTF8();
+
+ CriticalSectionLocker CSL(CS);
+ Ibi=Base64::decode(Data_Base64);
+}
+
+string MediaInfo_Config_MediaInfo::Ibi_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ibi;
+}
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::Ibi_Create_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ Ibi_Create=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::Ibi_Create_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return Ibi_Create;
+}
+#endif //MEDIAINFO_IBI
+
+//***************************************************************************
+// NextPacket
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_NEXTPACKET
+void MediaInfo_Config_MediaInfo::NextPacket_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ NextPacket=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::NextPacket_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return NextPacket;
+}
+#endif //MEDIAINFO_NEXTPACKET
+
+//***************************************************************************
+// SubFile
+//***************************************************************************
+
+#if MEDIAINFO_EVENTS
+//---------------------------------------------------------------------------
+ZtringListList MediaInfo_Config_MediaInfo::SubFile_Config_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ return SubFile_Config;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::SubFile_StreamID_Set (int64u Value)
+{
+ CriticalSectionLocker CSL(CS);
+
+ SubFile_StreamID=Value;
+}
+
+//---------------------------------------------------------------------------
+int64u MediaInfo_Config_MediaInfo::SubFile_StreamID_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ return SubFile_StreamID;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::SubFile_IDs_Set (Ztring Value)
+{
+ CriticalSectionLocker CSL(CS);
+
+ SubFile_IDs=Value;
+}
+
+//---------------------------------------------------------------------------
+Ztring MediaInfo_Config_MediaInfo::SubFile_IDs_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ return SubFile_IDs;
+}
+#endif //MEDIAINFO_EVENTS
+
+//***************************************************************************
+// SubFile
+//***************************************************************************
+
+#if MEDIAINFO_EVENTS
+//---------------------------------------------------------------------------
+bool MediaInfo_Config_MediaInfo::ParseUndecodableFrames_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ return ParseUndecodableFrames;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::ParseUndecodableFrames_Set (bool Value)
+{
+ CriticalSectionLocker CSL(CS);
+
+ ParseUndecodableFrames=Value;
+}
+#endif //MEDIAINFO_EVENTS
+
+//***************************************************************************
+// Event
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+bool MediaInfo_Config_MediaInfo::Event_CallBackFunction_IsSet ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ return Event_CallBackFunction?true:false;
+}
+#endif //MEDIAINFO_EVENTS
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+Ztring MediaInfo_Config_MediaInfo::Event_CallBackFunction_Set (const Ztring &Value)
+{
+ ZtringList List=Value;
+
+ CriticalSectionLocker CSL(CS);
+
+ if (List.empty())
+ {
+ Event_CallBackFunction=(MediaInfo_Event_CallBackFunction*)NULL;
+ Event_UserHandler=NULL;
+ }
+ else
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ if (List[Pos].find(_T("CallBack=memory://"))==0)
+ Event_CallBackFunction=(MediaInfo_Event_CallBackFunction*)Ztring(List[Pos].substr(18, std::string::npos)).To_int64u();
+ else if (List[Pos].find(_T("UserHandle=memory://"))==0)
+ Event_UserHandler=(void*)Ztring(List[Pos].substr(20, std::string::npos)).To_int64u();
+ else if (List[Pos].find(_T("UserHandler=memory://"))==0)
+ Event_UserHandler=(void*)Ztring(List[Pos].substr(21, std::string::npos)).To_int64u();
+ else
+ return("Problem during Event_CallBackFunction value parsing");
+ }
+
+ return Ztring();
+}
+#endif //MEDIAINFO_EVENTS
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+Ztring MediaInfo_Config_MediaInfo::Event_CallBackFunction_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ return _T("CallBack=memory://")+Ztring::ToZtring((size_t)Event_CallBackFunction)+_T(";UserHandler=memory://")+Ztring::ToZtring((size_t)Event_UserHandler);
+}
+#endif //MEDIAINFO_EVENTS
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+void MediaInfo_Config_MediaInfo::Event_Send (const int8u* Data_Content, size_t Data_Size)
+{
+ CriticalSectionLocker CSL(CS);
+
+ if (Event_CallBackFunction)
+ Event_CallBackFunction ((unsigned char*)Data_Content, Data_Size, Event_UserHandler);
+}
+#endif //MEDIAINFO_EVENTS
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+void MediaInfo_Config_MediaInfo::Event_Send (const int8u* Data_Content, size_t Data_Size, const Ztring &File_Name)
+{
+ CriticalSectionLocker CSL(CS);
+
+ if (Event_CallBackFunction)
+ Event_CallBackFunction ((unsigned char*)Data_Content, Data_Size, Event_UserHandler);
+ else
+ {
+ MediaInfo_Event_Generic* Event_Generic=(MediaInfo_Event_Generic*)Data_Content;
+ if ((Event_Generic->EventCode&0x00FFFF03)==((MediaInfo_Event_Global_Demux<<8)|0x03)) //Demux version 3
+ {
+ if (!MediaInfoLib::Config.Demux_Get())
+ return;
+
+ if (File_Name.empty())
+ return;
+
+ MediaInfo_Event_Global_Demux_0* Event=(MediaInfo_Event_Global_Demux_0*)Data_Content;
+
+ Ztring File_Name_Final(File_Name);
+ if (Event->StreamIDs_Size==0)
+ File_Name_Final+=_T(".demux");
+ else for (size_t Pos=0; Pos<Event->StreamIDs_Size; Pos++)
+ {
+ if (Event->StreamIDs_Width[Pos]==17)
+ {
+ Ztring ID;
+ ID.From_CC4((int32u)Event->StreamIDs[Pos]);
+ File_Name_Final+=_T('.')+ID;
+ }
+ else if (Event->StreamIDs_Width[Pos] && Event->StreamIDs_Width[Pos])
+ {
+ Ztring ID;
+ ID.From_Number(Event->StreamIDs[Pos], 16);
+ while (ID.size()<Event->StreamIDs_Width[Pos])
+ ID.insert(0, 1, _T('0'));
+ if (ID.size()>Event->StreamIDs_Width[Pos])
+ ID.erase(0, ID.size()-Event->StreamIDs_Width[Pos]);
+ File_Name_Final+=_T('.')+ID;
+ }
+ else
+ File_Name_Final+=_T(".raw");
+ }
+
+ File F;
+ F.Open(File_Name_Final, File::Access_Write_Append);
+ F.Write(Event->Content, Event->Content_Size);
+ }
+ }
+}
+#endif //MEDIAINFO_EVENTS
+
+//***************************************************************************
+// Force Parser
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_MpegTs_ForceMenu_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_MpegTs_ForceMenu=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_MpegTs_ForceMenu_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ bool Temp=File_MpegTs_ForceMenu;
+ return Temp;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_MpegTs_stream_type_Trust_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_MpegTs_stream_type_Trust=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_MpegTs_stream_type_Trust_Get ()
+{
+ CS.Enter();
+ bool Temp=File_MpegTs_stream_type_Trust;
+ CS.Leave();
+ return Temp;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_MpegTs_Atsc_transport_stream_id_Trust_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_MpegTs_Atsc_transport_stream_id_Trust=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_MpegTs_Atsc_transport_stream_id_Trust_Get ()
+{
+ CS.Enter();
+ bool Temp=File_MpegTs_Atsc_transport_stream_id_Trust;
+ CS.Leave();
+ return Temp;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_MpegTs_RealTime_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_MpegTs_RealTime=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_MpegTs_RealTime_Get ()
+{
+ CS.Enter();
+ bool Temp=File_MpegTs_RealTime;
+ CS.Leave();
+ return Temp;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_Bdmv_ParseTargetedFile_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_Bdmv_ParseTargetedFile=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_Bdmv_ParseTargetedFile_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ bool Temp=File_Bdmv_ParseTargetedFile;
+ return Temp;
+}
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DVDIF_YES)
+void MediaInfo_Config_MediaInfo::File_DvDif_DisableAudioIfIsInContainer_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_DvDif_DisableAudioIfIsInContainer=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_DvDif_DisableAudioIfIsInContainer_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ bool Temp=File_DvDif_DisableAudioIfIsInContainer;
+ return Temp;
+}
+#endif //defined(MEDIAINFO_DVDIF_YES)
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DVDIF_YES)
+void MediaInfo_Config_MediaInfo::File_DvDif_IgnoreTransmittingFlags_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_DvDif_IgnoreTransmittingFlags=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_DvDif_IgnoreTransmittingFlags_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ bool Temp=File_DvDif_IgnoreTransmittingFlags;
+ return Temp;
+}
+#endif //defined(MEDIAINFO_DVDIF_YES)
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+void MediaInfo_Config_MediaInfo::File_DvDif_Analysis_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_DvDif_Analysis=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_DvDif_Analysis_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ bool Temp=File_DvDif_Analysis;
+ return Temp;
+}
+#endif //defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_MACROBLOCKS
+void MediaInfo_Config_MediaInfo::File_Macroblocks_Parse_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_Macroblocks_Parse=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_Macroblocks_Parse_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ bool Temp=File_Macroblocks_Parse;
+ return Temp;
+}
+#endif //MEDIAINFO_MACROBLOCKS
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_GrowingFile_Delay_Set (float64 NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_GrowingFile_Delay=NewValue;
+}
+
+float64 MediaInfo_Config_MediaInfo::File_GrowingFile_Delay_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ float64 Temp=File_GrowingFile_Delay;
+ return Temp;
+}
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_LIBCURL_YES)
+void MediaInfo_Config_MediaInfo::File_Curl_Set (const Ztring &NewValue)
+{
+ size_t Pos=NewValue.find(_T(','));
+ if (Pos==string::npos)
+ Pos=NewValue.find(_T(';'));
+ if (Pos!=string::npos)
+ {
+ Ztring Field=NewValue.substr(0, Pos); Field.MakeLowerCase();
+ Ztring Value=NewValue.substr(Pos+1, string::npos);
+ CriticalSectionLocker CSL(CS);
+ Curl[Field]=Value;
+ }
+}
+
+void MediaInfo_Config_MediaInfo::File_Curl_Set (const Ztring &Field_, const Ztring &NewValue)
+{
+ Ztring Field=Field_; Field.MakeLowerCase();
+ CriticalSectionLocker CSL(CS);
+ Curl[Field]=NewValue;
+}
+
+Ztring MediaInfo_Config_MediaInfo::File_Curl_Get (const Ztring &Field_)
+{
+ Ztring Field=Field_; Field.MakeLowerCase();
+ CriticalSectionLocker CSL(CS);
+ std::map<Ztring, Ztring>::iterator Value=Curl.find(Field);
+ if (Value==Curl.end())
+ return Ztring();
+ else
+ return Curl[Field];
+}
+#endif //defined(MEDIAINFO_LIBCURL_YES)
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_LIBMMS_YES)
+void MediaInfo_Config_MediaInfo::File_Mmsh_Describe_Only_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_Mmsh_Describe_Only=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_Mmsh_Describe_Only_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ bool Temp=File_Mmsh_Describe_Only;
+ return Temp;
+}
+#endif //defined(MEDIAINFO_LIBMMS_YES)
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_Eia608_DisplayEmptyStream_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_Eia608_DisplayEmptyStream=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_Eia608_DisplayEmptyStream_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ bool Temp=File_Eia608_DisplayEmptyStream;
+ return Temp;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::File_Eia708_DisplayEmptyStream_Set (bool NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ File_Eia708_DisplayEmptyStream=NewValue;
+}
+
+bool MediaInfo_Config_MediaInfo::File_Eia708_DisplayEmptyStream_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ bool Temp=File_Eia708_DisplayEmptyStream;
+ return Temp;
+}
+
+//***************************************************************************
+// Analysis internal
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void MediaInfo_Config_MediaInfo::State_Set (float NewValue)
+{
+ CriticalSectionLocker CSL(CS);
+ State=NewValue;
+}
+
+float MediaInfo_Config_MediaInfo::State_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ float Temp=State;
+ return Temp;
+}
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_MediaInfo.h b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_MediaInfo.h
new file mode 100644
index 000000000..14300bd7b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Config_MediaInfo.h
@@ -0,0 +1,340 @@
+// MediaInfo_Config_MediaInfo - Configuration class
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Configuration of MediaInfo (per MediaInfo block)
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Config_MediaInfoH
+#define MediaInfo_Config_MediaInfoH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+#include "MediaInfo/MediaInfo_Internal_Const.h"
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Config.h"
+ #include "MediaInfo/MediaInfo_Events.h"
+ #include "ZenLib/File.h"
+#endif //MEDIAINFO_EVENTS
+#include "ZenLib/CriticalSection.h"
+#include "ZenLib/ZtringListList.h"
+#include "ZenLib/Translation.h"
+#include "ZenLib/InfoMap.h"
+#include <map>
+#include <vector>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class MediaInfo_Config_MediaInfo
+//***************************************************************************
+
+class MediaInfo_Config_MediaInfo
+{
+public :
+ //Constructor/Destructor
+ MediaInfo_Config_MediaInfo();
+ ~MediaInfo_Config_MediaInfo();
+
+ //General
+ Ztring Option (const String &Option, const String &Value=Ztring());
+
+ void File_IsSeekable_Set (bool NewValue);
+ bool File_IsSeekable_Get ();
+
+ void File_IsSub_Set (bool NewValue);
+ bool File_IsSub_Get ();
+
+ void File_IsReferenced_Set (bool NewValue);
+ bool File_IsReferenced_Get ();
+
+ void File_KeepInfo_Set (bool NewValue);
+ bool File_KeepInfo_Get ();
+
+ void File_StopAfterFilled_Set (bool NewValue);
+ bool File_StopAfterFilled_Get ();
+
+ void File_StopSubStreamAfterFilled_Set (bool NewValue);
+ bool File_StopSubStreamAfterFilled_Get ();
+
+ void File_Audio_MergeMonoStreams_Set (bool NewValue);
+ bool File_Audio_MergeMonoStreams_Get ();
+
+ void File_Demux_Interleave_Set (bool NewValue);
+ bool File_Demux_Interleave_Get ();
+
+ void File_ID_OnlyRoot_Set (bool NewValue);
+ bool File_ID_OnlyRoot_Get ();
+
+ void File_FileName_Set (const Ztring &NewValue);
+ Ztring File_FileName_Get ();
+
+ void File_FileNameFormat_Set (const Ztring &NewValue);
+ Ztring File_FileNameFormat_Get ();
+
+ void File_TimeToLive_Set (float64 NewValue);
+ float64 File_TimeToLive_Get ();
+
+ void File_Partial_Begin_Set (const Ztring &NewValue);
+ Ztring File_Partial_Begin_Get ();
+ void File_Partial_End_Set (const Ztring &NewValue);
+ Ztring File_Partial_End_Get ();
+
+ void File_ForceParser_Set (const Ztring &NewValue);
+ Ztring File_ForceParser_Get ();
+
+ void File_Buffer_Size_Hint_Pointer_Set (size_t* NewValue);
+ size_t* File_Buffer_Size_Hint_Pointer_Get ();
+
+ #if MEDIAINFO_NEXTPACKET
+ void NextPacket_Set (bool NewValue);
+ bool NextPacket_Get ();
+ #endif //MEDIAINFO_NEXTPACKET
+
+ #if MEDIAINFO_FILTER
+ void File_Filter_Set (int64u NewValue);
+ bool File_Filter_Get (const int16u Value);
+ bool File_Filter_Get ();
+ bool File_Filter_HasChanged();
+ #endif //MEDIAINFO_FILTER
+
+ #if MEDIAINFO_DUPLICATE
+ Ztring File_Duplicate_Set (const Ztring &Value);
+ Ztring File_Duplicate_Get (size_t AlreadyRead_Pos); //Requester must say how many Get() it already read
+ bool File_Duplicate_Get_AlwaysNeeded (size_t AlreadyRead_Pos); //Requester must say how many Get() it already read
+ #endif //MEDIAINFO_DEMUX
+
+ #if MEDIAINFO_DUPLICATE
+ size_t File__Duplicate_Memory_Indexes_Get (const Ztring &ToFind);
+ void File__Duplicate_Memory_Indexes_Erase (const Ztring &ToFind);
+ #endif //MEDIAINFO_DEMUX
+
+ #if MEDIAINFO_EVENTS
+ ZtringListList SubFile_Config_Get ();
+ void SubFile_StreamID_Set(int64u Value);
+ int64u SubFile_StreamID_Get();
+ void SubFile_IDs_Set(Ztring Value);
+ Ztring SubFile_IDs_Get();
+ #endif //MEDIAINFO_EVENTS
+
+ #if MEDIAINFO_EVENTS
+ bool ParseUndecodableFrames_Get ();
+ void ParseUndecodableFrames_Set (bool Value);
+ #endif //MEDIAINFO_EVENTS
+
+ #if MEDIAINFO_EVENTS
+ bool Event_CallBackFunction_IsSet ();
+ Ztring Event_CallBackFunction_Set (const Ztring &Value);
+ Ztring Event_CallBackFunction_Get ();
+ void Event_Send(const int8u* Data_Content, size_t Data_Size);
+ void Event_Send(const int8u* Data_Content, size_t Data_Size, const Ztring &File_Name);
+ #endif //MEDIAINFO_EVENTS
+
+ #if MEDIAINFO_DEMUX
+ void Demux_ForceIds_Set (bool NewValue);
+ bool Demux_ForceIds_Get ();
+ void Demux_PCM_20bitTo16bit_Set (bool NewValue);
+ bool Demux_PCM_20bitTo16bit_Get ();
+ void Demux_Unpacketize_Set (bool NewValue);
+ bool Demux_Unpacketize_Get ();
+ void Demux_Rate_Set (float64 NewValue);
+ float64 Demux_Rate_Get ();
+ void Demux_FirstDts_Set (int64u NewValue);
+ int64u Demux_FirstDts_Get ();
+ void Demux_FirstFrameNumber_Set (int64u NewValue);
+ int64u Demux_FirstFrameNumber_Get ();
+ void Demux_InitData_Set (int8u NewValue);
+ int8u Demux_InitData_Get ();
+ #endif //MEDIAINFO_DEMUX
+
+ #if MEDIAINFO_IBI
+ void Ibi_Set (const Ztring &NewValue);
+ std::string Ibi_Get ();
+ void Ibi_Create_Set (bool NewValue);
+ bool Ibi_Create_Get ();
+ #endif //MEDIAINFO_IBI
+
+ //Specific
+ void File_MpegTs_ForceMenu_Set (bool NewValue);
+ bool File_MpegTs_ForceMenu_Get ();
+ void File_MpegTs_stream_type_Trust_Set (bool NewValue);
+ bool File_MpegTs_stream_type_Trust_Get ();
+ void File_MpegTs_Atsc_transport_stream_id_Trust_Set (bool NewValue);
+ bool File_MpegTs_Atsc_transport_stream_id_Trust_Get ();
+ void File_MpegTs_RealTime_Set (bool NewValue);
+ bool File_MpegTs_RealTime_Get ();
+ void File_Bdmv_ParseTargetedFile_Set (bool NewValue);
+ bool File_Bdmv_ParseTargetedFile_Get ();
+ #if defined(MEDIAINFO_DVDIF_YES)
+ void File_DvDif_DisableAudioIfIsInContainer_Set (bool NewValue);
+ bool File_DvDif_DisableAudioIfIsInContainer_Get ();
+ void File_DvDif_IgnoreTransmittingFlags_Set (bool NewValue);
+ bool File_DvDif_IgnoreTransmittingFlags_Get ();
+ #endif //defined(MEDIAINFO_DVDIF_YES)
+ #if defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ void File_DvDif_Analysis_Set (bool NewValue);
+ bool File_DvDif_Analysis_Get ();
+ #endif //defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ #if MEDIAINFO_MACROBLOCKS
+ void File_Macroblocks_Parse_Set (bool NewValue);
+ bool File_Macroblocks_Parse_Get ();
+ #endif //MEDIAINFO_MACROBLOCKS
+ void File_GrowingFile_Delay_Set(float64 Value);
+ float64 File_GrowingFile_Delay_Get();
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ void File_Curl_Set (const Ztring &NewValue);
+ void File_Curl_Set (const Ztring &Field, const Ztring &NewValue);
+ Ztring File_Curl_Get (const Ztring &Field);
+ #endif //defined(MEDIAINFO_LIBCURL_YES)
+ #if defined(MEDIAINFO_LIBMMS_YES)
+ void File_Mmsh_Describe_Only_Set (bool NewValue);
+ bool File_Mmsh_Describe_Only_Get ();
+ #endif //defined(MEDIAINFO_LIBMMS_YES)
+ void File_Eia608_DisplayEmptyStream_Set (bool NewValue);
+ bool File_Eia608_DisplayEmptyStream_Get ();
+ void File_Eia708_DisplayEmptyStream_Set (bool NewValue);
+ bool File_Eia708_DisplayEmptyStream_Get ();
+
+ //Analysis internal
+ void State_Set (float State);
+ float State_Get ();
+
+ //Internal to MediaInfo, not thread safe
+ ZtringList File_Names;
+ std::vector<int64u> File_Sizes;
+ size_t File_Names_Pos;
+ size_t File_Buffer_Size_Max;
+ size_t File_Buffer_Size_ToRead;
+ size_t File_Buffer_Size;
+ int8u* File_Buffer;
+ bool File_Buffer_Repeat;
+ bool File_Buffer_Repeat_IsSupported;
+ bool File_IsGrowing;
+ bool File_IsNotGrowingAnymore;
+ int64u File_Current_Offset;
+ int64u File_Current_Size;
+ int64u File_Size;
+ #if MEDIAINFO_DEMUX
+ bool Demux_EventWasSent;
+ #if MEDIAINFO_SEEK
+ bool Demux_IsSeeking;
+ #endif //MEDIAINFO_SEEK
+ #endif //MEDIAINFO_DEMUX
+
+private :
+ bool FileIsSeekable;
+ bool FileIsSub;
+ bool FileIsReferenced;
+ bool FileKeepInfo;
+ bool FileStopAfterFilled;
+ bool FileStopSubStreamAfterFilled;
+ bool Audio_MergeMonoStreams;
+ bool File_Demux_Interleave;
+ bool File_ID_OnlyRoot;
+ Ztring File_FileName;
+ Ztring File_FileNameFormat;
+ float64 File_TimeToLive;
+ Ztring File_Partial_Begin;
+ Ztring File_Partial_End;
+ Ztring File_ForceParser;
+ size_t* File_Buffer_Size_Hint_Pointer;
+
+ //Extra
+ #if MEDIAINFO_NEXTPACKET
+ bool NextPacket;
+ #endif //MEDIAINFO_NEXTPACKET
+
+ #if MEDIAINFO_FILTER
+ std::map<int16u, bool> File_Filter_16;
+ bool File_Filter_HasChanged_;
+ #endif //MEDIAINFO_FILTER
+
+ #if MEDIAINFO_DUPLICATE
+ std::vector<Ztring> File__Duplicate_List;
+ ZtringList File__Duplicate_Memory_Indexes;
+ #endif //MEDIAINFO_DUPLICATE
+
+ //Event
+ #if MEDIAINFO_EVENTS
+ MediaInfo_Event_CallBackFunction* Event_CallBackFunction; //void Event_Handler(unsigned char* Data_Content, size_t Data_Size, void* UserHandler)
+ void* Event_UserHandler;
+ ZtringListList SubFile_Config;
+ int64u SubFile_StreamID;
+ bool ParseUndecodableFrames;
+ Ztring SubFile_IDs;
+ #endif //MEDIAINFO_EVENTS
+
+ #if MEDIAINFO_DEMUX
+ bool Demux_ForceIds;
+ bool Demux_PCM_20bitTo16bit;
+ bool Demux_Unpacketize;
+ float64 Demux_Rate;
+ int64u Demux_FirstDts;
+ int64u Demux_FirstFrameNumber;
+ int8u Demux_InitData;
+ #endif //MEDIAINFO_DEMUX
+
+ #if MEDIAINFO_IBI
+ std::string Ibi;
+ bool Ibi_Create;
+ #endif //MEDIAINFO_IBI
+
+ //Specific
+ bool File_MpegTs_ForceMenu;
+ bool File_MpegTs_stream_type_Trust;
+ bool File_MpegTs_Atsc_transport_stream_id_Trust;
+ bool File_MpegTs_RealTime;
+ bool File_Bdmv_ParseTargetedFile;
+ #if defined(MEDIAINFO_DVDIF_YES)
+ bool File_DvDif_DisableAudioIfIsInContainer;
+ bool File_DvDif_IgnoreTransmittingFlags;
+ #endif //defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ #if defined(MEDIAINFO_DVDIF_YES)
+ bool File_DvDif_Analysis;
+ #endif //defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ #if MEDIAINFO_MACROBLOCKS
+ bool File_Macroblocks_Parse;
+ #endif //MEDIAINFO_MACROBLOCKS
+ float64 File_GrowingFile_Delay;
+ #if defined(MEDIAINFO_LIBMMS_YES)
+ bool File_Mmsh_Describe_Only;
+ #endif //defined(MEDIAINFO_LIBMMS_YES)
+ bool File_Eia608_DisplayEmptyStream;
+ bool File_Eia708_DisplayEmptyStream;
+
+ //Analysis internal
+ float State;
+
+ //Generic
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ std::map<Ztring, Ztring> Curl;
+ #endif //defined(MEDIAINFO_LIBCURL_YES)
+
+ ZenLib::CriticalSection CS;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Const.h b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Const.h
new file mode 100644
index 000000000..f49308aaf
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Const.h
@@ -0,0 +1,143 @@
+// MediaInfo_Config - Configuration class
+// Copyright (C) 2005-2011 Jerome Martinez, Zen@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Global configuration of MediaInfo
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_ConstH
+#define MediaInfo_ConstH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include <string>
+#include <ZenLib/Conf.h>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+/// \mainpage MediaInfoLib Index Page
+///
+/// \section Interfaces
+///
+/// There is 2 access methods
+///
+/// - MediaInfo class \n
+/// To manage one file, this is the simplest interface. \n
+/// - MediaInfo::Open to analyse file \n
+/// - MediaInfo::Inform to have a summary \n
+/// - MediaInfo::Get to retreive one piece of information \n
+///
+/// - MediaInfoList class \n
+/// To manage a list of files \n
+/// - MediaInfoList::Open to analyse file \n
+/// - MediaInfoList::Inform to have a summary \n
+/// - MediaInfoList::Get to retreive one piece of information \n
+/// - MediaInfoList::Close to close one file \n
+///
+/// \section C C Interface (MediaInfo_*)
+/// For compatibility and DLL interface \n
+/// This is a C interface for the List class \n
+/// Note : Don't forget to include the MediaInfoDLL.h file in your source file! \n
+/// - Example of commands:
+/// - MediaInfo_Open to analyse file \n
+/// - MediaInfo_Inform to have a summary \n
+/// - MediaInfo_Get to retreive one piece of information \n
+/// - MediaInfo_Close to free memory \n
+///
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+/// @brief Kinds of Stream
+enum stream_t
+{
+ Stream_General, ///< StreamKind = General
+ Stream_Video, ///< StreamKind = Video
+ Stream_Audio, ///< StreamKind = Audio
+ Stream_Text, ///< StreamKind = Text
+ Stream_Chapters, ///< StreamKind = Chapters
+ Stream_Image, ///< StreamKind = Image
+ Stream_Menu, ///< StreamKind = Menu
+ Stream_Max
+};
+
+/// @brief Kind of information
+enum info_t
+{
+ Info_Name, ///< InfoKind = Unique name of parameter
+ Info_Text, ///< InfoKind = Value of parameter
+ Info_Measure, ///< InfoKind = Unique name of measure unit of parameter
+ Info_Options, ///< InfoKind = See infooptions_t
+ Info_Name_Text, ///< InfoKind = Translated name of parameter
+ Info_Measure_Text, ///< InfoKind = Translated name of measure unit
+ Info_Info, ///< InfoKind = More information about the parameter
+ Info_HowTo, ///< InfoKind = How this parameter is supported, could be N (No), B (Beta), R (Read only), W (Read/Write)
+ Info_Domain, ///< InfoKind = Domain of this piece of information
+ Info_Max
+};
+
+/// Get(...)[infooptions_t] return a string like "YNYN..." \n
+/// Use this enum to know at what correspond the Y (Yes) or N (No)
+/// If Get(...)[0]==Y, then :
+/// @brief Option if InfoKind = Info_Options
+enum infooptions_t
+{
+ InfoOption_ShowInInform, ///< Show this parameter in Inform()
+ InfoOption_Reserved, ///<
+ InfoOption_ShowInSupported, ///< Internal use only (info : Must be showed in Info_Capacities() )
+ InfoOption_TypeOfValue, ///< Value return by a standard Get() can be : T (Text), I (Integer, warning up to 64 bits), F (Float), D (Date), B (Binary datas coded Base64) (Numbers are in Base 10)
+ InfoOption_Max
+};
+
+/// @brief File opening options
+enum fileoptions_t
+{
+ FileOption_Nothing =0x00,
+ FileOption_NoRecursive =0x01, ///< Do not browse folders recursively
+ FileOption_CloseAll =0x02, ///< Close all files before open
+ FileOption_Max =0x04
+};
+
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+//Char types
+#undef _T
+#define _T(__x) __T(__x)
+#if defined(UNICODE) || defined (_UNICODE)
+ typedef wchar_t Char;
+ #undef __T
+ #define __T(__x) L ## __x
+#else
+ typedef char Char;
+ #undef __T
+ #define __T(__x) __x
+#endif
+typedef std::basic_string<MediaInfoLib::Char> String;
+typedef std::basic_stringstream<MediaInfoLib::Char> StringStream;
+typedef std::basic_istringstream<MediaInfoLib::Char> tiStringStream;
+typedef std::basic_ostringstream<MediaInfoLib::Char> toStringStream;
+//---------------------------------------------------------------------------
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Events.h b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Events.h
new file mode 100644
index 000000000..59817d388
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Events.h
@@ -0,0 +1,673 @@
+// MediaInfo_Events -
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+/*Structures for MediaInfo events */
+
+#ifndef MediaInfo_EventsH
+#define MediaInfo_EventsH
+
+/***************************************************************************/
+/* Platforms (from libzen) */
+/***************************************************************************/
+
+/*-------------------------------------------------------------------------*/
+/*Win32*/
+#if defined(__NT__) || defined(_WIN32) || defined(WIN32)
+ #ifndef WIN32
+ #define WIN32
+ #endif
+ #ifndef _WIN32
+ #define _WIN32
+ #endif
+ #ifndef __WIN32__
+ #define __WIN32__ 1
+ #endif
+#endif
+
+/*-------------------------------------------------------------------------*/
+/*Win64*/
+#if defined(_WIN64) || defined(WIN64)
+ #ifndef WIN64
+ #define WIN64
+ #endif
+ #ifndef _WIN64
+ #define _WIN64
+ #endif
+ #ifndef __WIN64__
+ #define __WIN64__ 1
+ #endif
+#endif
+
+/*-------------------------------------------------------------------------*/
+/*Windows*/
+#if defined(WIN32) || defined(WIN64)
+ #ifndef WINDOWS
+ #define WINDOWS
+ #endif
+ #ifndef _WINDOWS
+ #define _WINDOWS
+ #endif
+ #ifndef __WINDOWS__
+ #define __WINDOWS__ 1
+ #endif
+#endif
+
+/*-------------------------------------------------------------------------*/
+/*Unix (Linux, HP, Sun, BeOS...)*/
+#if defined(UNIX) || defined(_UNIX) || defined(__UNIX__) \
+ || defined(__unix) || defined(__unix__) \
+ || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) \
+ || defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) \
+ || defined(__EMX__) || defined(__VMS) || defined(__BEOS__)
+ #ifndef UNIX
+ #define UNIX
+ #endif
+ #ifndef _UNIX
+ #define _UNIX
+ #endif
+ #ifndef __UNIX__
+ #define __UNIX__ 1
+ #endif
+#endif
+
+/*-------------------------------------------------------------------------*/
+/*MacOS Classic*/
+#if defined(macintosh)
+ #ifndef MACOS
+ #define MACOS
+ #endif
+ #ifndef _MACOS
+ #define _MACOS
+ #endif
+ #ifndef __MACOS__
+ #define __MACOS__ 1
+ #endif
+#endif
+
+/*-------------------------------------------------------------------------*/
+/*MacOS X*/
+#if defined(__APPLE__) && defined(__MACH__)
+ #ifndef MACOSX
+ #define MACOSX
+ #endif
+ #ifndef _MACOSX
+ #define _MACOSX
+ #endif
+ #ifndef __MACOSX__
+ #define __MACOSX__ 1
+ #endif
+#endif
+
+/*Test of targets*/
+#if defined(WINDOWS) && defined(UNIX) && defined(MACOS) && defined(MACOSX)
+ #pragma message Multiple platforms???
+#endif
+
+#if !defined(WIN32) && !defined(UNIX) && !defined(MACOS) && !defined(MACOSX)
+ #pragma message No known platforms, assume default
+#endif
+
+/*-------------------------------------------------------------------------*/
+/*8-bit int */
+#if UCHAR_MAX==0xff
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 8
+ typedef signed char MediaInfo_int8s;
+ typedef unsigned char MediaInfo_int8u;
+#else
+ #pragma message This machine has no 8-bit integertype?
+#endif
+
+/*-------------------------------------------------------------------------*/
+/*16-bit int */
+#if UINT_MAX == 0xffff
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 16
+ typedef signed int MediaInfo_int16s;
+ typedef unsigned int MediaInfo_int16u;
+#elif USHRT_MAX == 0xffff
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 16
+ typedef signed short MediaInfo_int16s;
+ typedef unsigned short MediaInfo_int16u;
+#else
+ #pragma message This machine has no 16-bit integertype?
+#endif
+
+/*-------------------------------------------------------------------------*/
+/*32-bit int */
+#if UINT_MAX == 0xfffffffful
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 32
+ typedef signed int MediaInfo_int32s;
+ typedef unsigned int MediaInfo_int32u;
+#elif ULONG_MAX == 0xfffffffful
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 32
+ typedef signed long MediaInfo_int32s;
+ typedef unsigned long MediaInfo_int32u;
+#elif USHRT_MAX == 0xfffffffful
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 32
+ typedef signed short MediaInfo_int32s;
+ typedef unsigned short MediaInfo_int32u;
+#else
+ #pragma message This machine has no 32-bit integer type?
+#endif
+
+/*-------------------------------------------------------------------------*/
+/*64-bit int */
+#if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__) || defined(__MACOSX__)
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 64
+ typedef unsigned long long MediaInfo_int64u;
+ typedef signed long long MediaInfo_int64s;
+#elif defined(__WIN32__) || defined(_WIN32)
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 64
+ typedef unsigned __int64 MediaInfo_int64u;
+ typedef signed __int64 MediaInfo_int64s;
+#else
+ #pragma message This machine has no 64-bit integer type?
+#endif
+/*-------------------------------------------------------------------------*/
+
+
+/***************************************************************************/
+/* The callback function */
+/***************************************************************************/
+
+#if !defined(__WINDOWS__)
+ #define __stdcall
+#endif //!defined(__WINDOWS__)
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+ typedef void (__stdcall MediaInfo_Event_CallBackFunction)(unsigned char* Data_Content, size_t Data_Size, void* UserHandler);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/***************************************************************************/
+/* EventCode management */
+/***************************************************************************/
+
+#define MediaInfo_EventCode_Create(ParserID, EventID, EventVersion) \
+ ( ((MediaInfo_int32u)ParserID )<<24 \
+ | ((MediaInfo_int32u)EventID )<< 8 \
+ | ((MediaInfo_int32u)EventVersion) )
+
+/***************************************************************************/
+/* Global */
+/***************************************************************************/
+
+/*-------------------------------------------------------------------------*/
+/* Generic */
+struct MediaInfo_Event_Generic
+{
+ MediaInfo_int32u EventCode;
+};
+
+/*-------------------------------------------------------------------------*/
+/* MediaInfo_Event_Log_0 */
+#define MediaInfo_Event_Log 0x0F00
+struct MediaInfo_Event_Log_0
+{
+ MediaInfo_int32u EventCode;
+ MediaInfo_int8u Type;
+ MediaInfo_int8u Severity;
+ MediaInfo_int8u Reserved2;
+ MediaInfo_int8u Reserved3;
+ MediaInfo_int32u MessageCode;
+ MediaInfo_int32u Reserved4;
+ const wchar_t* MessageString;
+ const wchar_t* MessageStringU;
+ const char* MessageStringA;
+};
+
+/*-------------------------------------------------------------------------*/
+/* Demux */
+#define MediaInfo_Event_Global_Demux 0xAF00
+enum MediaInfo_Event_Global_Demux_0_contenttype
+{
+ MediaInfo_Event_Global_Demux_0_ContentType_MainStream,
+ MediaInfo_Event_Global_Demux_0_ContentType_SubStream,
+ MediaInfo_Event_Global_Demux_0_ContentType_Header,
+ MediaInfo_Event_Global_Demux_0_ContentType_Synchro
+};
+struct MediaInfo_Event_Global_Demux_0
+{
+ MediaInfo_int32u EventCode;
+ MediaInfo_int64u Stream_Offset;
+ MediaInfo_int64u PCR;
+ MediaInfo_int64u PTS;
+ MediaInfo_int64u DTS;
+ size_t StreamIDs_Size;
+ MediaInfo_int64u* StreamIDs;
+ MediaInfo_int8u* StreamIDs_Width;
+ MediaInfo_int8u* ParserIDs;
+ MediaInfo_int8u Content_Type; /*MediaInfo_Event_Global_Demux_0_contenttype*/
+ size_t Content_Size;
+ const MediaInfo_int8u* Content;
+};
+struct MediaInfo_Event_Global_Demux_1
+{
+ MediaInfo_int32u EventCode;
+ MediaInfo_int64u Stream_Offset;
+ MediaInfo_int64u PCR;
+ MediaInfo_int64u PTS;
+ MediaInfo_int64u DTS;
+ size_t StreamIDs_Size;
+ MediaInfo_int64u* StreamIDs;
+ MediaInfo_int8u* StreamIDs_Width;
+ MediaInfo_int8u* ParserIDs;
+ MediaInfo_int8u Content_Type; /*MediaInfo_Event_Global_Demux_0_contenttype*/
+ size_t Content_Size;
+ const MediaInfo_int8u* Content;
+ MediaInfo_int64u DUR;
+};
+struct MediaInfo_Event_Global_Demux_2
+{
+ MediaInfo_int32u EventCode;
+ MediaInfo_int64u Stream_Offset;
+ MediaInfo_int64u PCR;
+ MediaInfo_int64u PTS;
+ MediaInfo_int64u DTS;
+ size_t StreamIDs_Size;
+ MediaInfo_int64u* StreamIDs;
+ MediaInfo_int8u* StreamIDs_Width;
+ MediaInfo_int8u* ParserIDs;
+ MediaInfo_int8u Content_Type; /*MediaInfo_Event_Global_Demux_0_contenttype*/
+ size_t Content_Size;
+ const MediaInfo_int8u* Content;
+ MediaInfo_int64u DUR;
+ MediaInfo_int64u Flags; /*bit0=random_access*/
+};
+struct MediaInfo_Event_Global_Demux_3
+{
+ MediaInfo_int32u EventCode;
+ MediaInfo_int64u Stream_Offset;
+ MediaInfo_int64u PCR;
+ MediaInfo_int64u PTS;
+ MediaInfo_int64u DTS;
+ size_t StreamIDs_Size;
+ MediaInfo_int64u* StreamIDs;
+ MediaInfo_int8u* StreamIDs_Width;
+ MediaInfo_int8u* ParserIDs;
+ MediaInfo_int8u Content_Type; /*MediaInfo_Event_Global_Demux_0_contenttype*/
+ size_t Content_Size;
+ const MediaInfo_int8u* Content;
+ MediaInfo_int64u DUR;
+ MediaInfo_int64u Flags; /*bit0=random_access*/
+ MediaInfo_int64u FrameNumber;
+};
+
+/*-------------------------------------------------------------------------*/
+/* MediaInfo_Event_Video_SliceInfo_0 */
+#define MediaInfo_Event_Video_SliceInfo 0x7801
+struct MediaInfo_Event_Video_SliceInfo_0
+{
+ MediaInfo_int32u EventCode;
+ MediaInfo_int64u Stream_Offset;
+ MediaInfo_int64u PCR;
+ MediaInfo_int64u PTS;
+ MediaInfo_int64u DTS;
+ MediaInfo_int64u DUR;
+ size_t StreamIDs_Size;
+ MediaInfo_int64u* StreamIDs;
+ MediaInfo_int8u* StreamIDs_Width;
+ MediaInfo_int8u* ParserIDs;
+ MediaInfo_int64u FramePosition;
+ MediaInfo_int64u FieldPosition;
+ MediaInfo_int64u SlicePosition;
+ MediaInfo_int8u SliceType;
+ MediaInfo_int64u Flags;
+};
+
+/***************************************************************************/
+/* General */
+/***************************************************************************/
+
+#define MediaInfo_Parser_None 0x00
+
+/*-------------------------------------------------------------------------*/
+/* Start */
+#define MediaInfo_Event_General_Start 0x7001
+struct MediaInfo_Event_General_Start_0
+{
+ MediaInfo_int32u EventCode;
+ MediaInfo_int64u Stream_Size;
+};
+
+/*-------------------------------------------------------------------------*/
+/* End */
+#define MediaInfo_Event_General_End 0x7002
+struct MediaInfo_Event_General_End_0
+{
+ MediaInfo_int32u EventCode;
+ MediaInfo_int64u Stream_Bytes_Analyzed;
+};
+
+/*-------------------------------------------------------------------------*/
+/* Parser_Selected */
+#define MediaInfo_Event_General_Parser_Selected 0x7003
+struct MediaInfo_Event_General_Parser_Selected_0
+{
+ MediaInfo_int32u EventCode;
+ char Name[16];
+};
+
+/*-------------------------------------------------------------------------*/
+/* Move request */
+#define MediaInfo_Event_General_Move_Request 0x7004
+struct MediaInfo_Event_General_Move_Request_0
+{
+ MediaInfo_int32u EventCode;
+ MediaInfo_int64u Stream_Offset;
+};
+
+/*-------------------------------------------------------------------------*/
+/* Move done */
+#define MediaInfo_Event_General_Move_Done 0x7005
+struct MediaInfo_Event_General_Move_Done_0
+{
+ MediaInfo_int32u EventCode;
+ MediaInfo_int64u Stream_Offset;
+};
+
+/*-------------------------------------------------------------------------*/
+/* SubFile_Start */
+#define MediaInfo_Event_General_SubFile_Start 0x7006
+struct MediaInfo_Event_General_SubFile_Start_0
+{
+ MediaInfo_int32u EventCode;
+ size_t StreamIDs_Size;
+ MediaInfo_int64u* StreamIDs;
+ MediaInfo_int8u* StreamIDs_Width;
+ MediaInfo_int8u* ParserIDs;
+ char* FileName_Relative;
+ wchar_t* FileName_Relative_Unicode;
+ char* FileName_Absolute;
+ wchar_t* FileName_Absolute_Unicode;
+};
+
+/*-------------------------------------------------------------------------*/
+/* SubFile_End */
+#define MediaInfo_Event_General_SubFile_End 0x7007
+struct MediaInfo_Event_General_SubFile_End_0
+{
+ MediaInfo_int32u EventCode;
+};
+
+/***************************************************************************/
+/* MPEG-TS / BDAV / TSP */
+/***************************************************************************/
+
+#define MediaInfo_Parser_MpegTs 0x01
+
+/***************************************************************************/
+/* MPEG-PS */
+/***************************************************************************/
+
+#define MediaInfo_Parser_MpegPs 0x02
+#define MediaInfo_Parser_MpegPs_Ext 0x70
+
+/***************************************************************************/
+/* DV / DIF */
+/***************************************************************************/
+
+#define MediaInfo_Parser_DvDif 0x03
+
+/*-------------------------------------------------------------------------*/
+/* Analysis */
+#define MediaInfo_Event_DvDif_Analysis_Frame 0xB001
+struct MediaInfo_Event_DvDif_Analysis_Frame_0
+{
+ MediaInfo_int32u EventCode;
+ MediaInfo_int32u TimeCode;
+ MediaInfo_int32u RecordedDateTime1;
+ MediaInfo_int16u RecordedDateTime2;
+ MediaInfo_int8u Arb;
+ MediaInfo_int8u Verbosity;
+ char* Errors;
+};
+
+/***************************************************************************/
+/* CDXA */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Cdxa 0x04
+
+/***************************************************************************/
+/* FLV */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Flv 0x06
+
+/***************************************************************************/
+/* GXF */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Gxf 0x07
+
+/***************************************************************************/
+/* Matroska */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Matroska 0x08
+
+/***************************************************************************/
+/* MPEG-4 */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Mpeg4 0x09
+#define MediaInfo_Parser_Mpeg4_Desc 0x71
+
+/***************************************************************************/
+/* MXF */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Mxf 0x0A
+
+/***************************************************************************/
+/* OGG */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Ogg 0x0B
+
+/***************************************************************************/
+/* RIFF */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Riff 0x0C
+
+/***************************************************************************/
+/* WM */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Wm 0x0D
+
+/***************************************************************************/
+/* LXF */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Lxf 0x0E
+
+/***************************************************************************/
+/* HLS */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Hls 0x60
+
+/***************************************************************************/
+/* HLS Index */
+/***************************************************************************/
+
+#define MediaInfo_Parser_HlsIndex 0x61
+
+/***************************************************************************/
+/* Internet Streaming Media */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Ism 0x62
+
+/***************************************************************************/
+/* MPEG Video */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Mpegv 0x80
+
+/***************************************************************************/
+/* AVC */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Avc 0x81
+
+/***************************************************************************/
+/* VC-1 */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Vc1 0x82
+
+/***************************************************************************/
+/* Active Format Description (AFD) */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Afd 0x83
+
+/***************************************************************************/
+/* Bar Data */
+/***************************************************************************/
+
+#define MediaInfo_Parser_BarData 0x84
+
+/***************************************************************************/
+/* MPEG-4 Visual */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Mpeg4v 0x85
+
+/***************************************************************************/
+/* DTS */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Dts 0xA0
+
+/***************************************************************************/
+/* AC-3 */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Ac3 0xA1
+
+/***************************************************************************/
+/* AAC */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Aac 0xA2
+
+/***************************************************************************/
+/* MPEG Audio */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Mpega 0xA3
+
+/***************************************************************************/
+/* PCM */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Pcm 0xA4
+
+/***************************************************************************/
+/* AES-3 */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Aes3 0xA5
+
+/***************************************************************************/
+/* Dolby E */
+/***************************************************************************/
+
+#define MediaInfo_Parser_DolbyE 0xA6
+
+/***************************************************************************/
+/* Channel grouping intermediate module */
+/***************************************************************************/
+
+#define MediaInfo_Parser_ChannelGrouping 0xA7
+
+/***************************************************************************/
+/* CEA-608 (formely IEA-608) */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Eia608 0xF0
+
+/***************************************************************************/
+/* DTVCC Transport (CEA-708, formely IEA-708) */
+/***************************************************************************/
+
+#define MediaInfo_Parser_DtvccTransport 0xF1
+#define MediaInfo_Parser_Eia708 0xF1 /*Deprecated*/
+
+/***************************************************************************/
+/* DTVCC Caption (CEA-708, formely IEA-708) */
+/***************************************************************************/
+
+#define MediaInfo_Parser_DtvccCaption 0xF2
+
+/***************************************************************************/
+/* CDP */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Cdp 0xF3
+
+/***************************************************************************/
+/* DVD CC */
+/***************************************************************************/
+
+#define MediaInfo_Parser_DvdCc 0xF4
+
+/***************************************************************************/
+/* SCTE 20 */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Scte20 0xF5
+
+/***************************************************************************/
+/* DVB Subtitle */
+/***************************************************************************/
+
+#define MediaInfo_Parser_DvbSubtitle 0xF6
+
+/***************************************************************************/
+/* Teletext */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Teletext 0xF7
+
+/***************************************************************************/
+/* SCC */
+/***************************************************************************/
+
+#define MediaInfo_Parser_Scc 0xF8
+
+#endif //MediaInfo_EventsH
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Events_Internal.h b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Events_Internal.h
new file mode 100644
index 000000000..202723819
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Events_Internal.h
@@ -0,0 +1,74 @@
+// MediaInfo_Events -
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+#ifndef MediaInfo_Events_InternalH
+#define MediaInfo_Events_InternalH
+
+#include <cstring>
+using namespace std;
+
+namespace MediaInfoLib
+{
+ inline void Events_PCR(int64u PCR, int64u &Event_PCR, char* Event_PCR_HR)
+ {
+ Event_PCR=PCR;
+ if (PCR!=(int64u)-1)
+ {
+ string PCR_HR=Ztring().Duration_From_Milliseconds(PCR/1000000).To_UTF8();
+ if (PCR_HR.size()==12)
+ strcpy(Event_PCR_HR, PCR_HR.c_str());
+ else
+ memset(Event_PCR_HR, 0x00, 13);
+ }
+ else
+ memset(Event_PCR_HR, 0x00, 13);
+ }
+
+ inline void Events_PTS(int64u PTS, int64u &Event_PTS, char* Event_PTS_HR)
+ {
+ Event_PTS=PTS;
+ if (PTS!=(int64u)-1)
+ {
+ string PTS_HR=Ztring().Duration_From_Milliseconds(PTS/1000000).To_UTF8();
+ if (PTS_HR.size()==12)
+ strcpy(Event_PTS_HR, PTS_HR.c_str());
+ else
+ memset(Event_PTS_HR, 0x00, 13);
+ }
+ else
+ memset(Event_PTS_HR, 0x00, 13);
+ }
+
+ inline void Events_DTS(int64u DTS, int64u &Event_DTS, char* Event_DTS_HR)
+ {
+ Event_DTS=DTS;
+ if (DTS!=(int64u)-1)
+ {
+ string DTS_HR=Ztring().Duration_From_Milliseconds(DTS/1000000).To_UTF8();
+ if (DTS_HR.size()==12)
+ strcpy(Event_DTS_HR, DTS_HR.c_str());
+ else
+ memset(Event_DTS_HR, 0x00, 13);
+ }
+ else
+ memset(Event_DTS_HR, 0x00, 13);
+ }
+}
+
+#endif //MediaInfo_EventsH
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_File.cpp b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_File.cpp
new file mode 100644
index 000000000..712e7ed4e
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_File.cpp
@@ -0,0 +1,972 @@
+// MediaInfo_Internal - All info about media files, different parser listing part
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// How to:
+// To add a new format,
+// Fill includes, SelectFromExtension, ListFormats and LibraryIsModified
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Reader/Reader_File.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+// Multiple
+#if defined(MEDIAINFO_BDMV_YES)
+ #include "MediaInfo/Multiple/File_Bdmv.h"
+#endif
+#if defined(MEDIAINFO_CDXA_YES)
+ #include "MediaInfo/Multiple/File_Cdxa.h"
+#endif
+#if defined(MEDIAINFO_DCP_YES)
+ #include "MediaInfo/Multiple/File_Dcp.h"
+#endif
+#if defined(MEDIAINFO_DVDIF_YES)
+ #include "MediaInfo/Multiple/File_DvDif.h"
+#endif
+#if defined(MEDIAINFO_DVDV_YES)
+ #include "MediaInfo/Multiple/File_Dvdv.h"
+#endif
+#if defined(MEDIAINFO_DXW_YES)
+ #include "MediaInfo/Multiple/File_Dxw.h"
+#endif
+#if defined(MEDIAINFO_FLV_YES)
+ #include "MediaInfo/Multiple/File_Flv.h"
+#endif
+#if defined(MEDIAINFO_GXF_YES)
+ #include "MediaInfo/Multiple/File_Gxf.h"
+#endif
+#if defined(MEDIAINFO_HLS_YES)
+ #include "MediaInfo/Multiple/File_Hls.h"
+#endif
+#if defined(MEDIAINFO_IBI_YES)
+ #include "MediaInfo/Multiple/File_Ibi.h"
+#endif
+#if defined(MEDIAINFO_ISM_YES)
+ #include "MediaInfo/Multiple/File_Ism.h"
+#endif
+#if defined(MEDIAINFO_IVF_YES)
+ #include "MediaInfo/Multiple/File_Ivf.h"
+#endif
+#if defined(MEDIAINFO_LXF_YES)
+ #include "MediaInfo/Multiple/File_Lxf.h"
+#endif
+#if defined(MEDIAINFO_MK_YES)
+ #include "MediaInfo/Multiple/File_Mk.h"
+#endif
+#if defined(MEDIAINFO_MPEG4_YES)
+ #include "MediaInfo/Multiple/File_Mpeg4.h"
+#endif
+#if defined(MEDIAINFO_MPEGPS_YES)
+ #include "MediaInfo/Multiple/File_MpegPs.h"
+#endif
+#if defined(MEDIAINFO_MPEGTS_YES) || defined(MEDIAINFO_BDAV_YES) || defined(MEDIAINFO_TSP_YES)
+ #include "MediaInfo/Multiple/File_MpegTs.h"
+#endif
+#if defined(MEDIAINFO_MXF_YES)
+ #include "MediaInfo/Multiple/File_Mxf.h"
+#endif
+#if defined(MEDIAINFO_NUT_YES)
+ #include "MediaInfo/Multiple/File_Nut.h"
+#endif
+#if defined(MEDIAINFO_OGG_YES)
+ #include "MediaInfo/Multiple/File_Ogg.h"
+#endif
+#if defined(MEDIAINFO_P2_YES)
+ #include "MediaInfo/Multiple/File_P2_Clip.h"
+#endif
+#if defined(MEDIAINFO_RIFF_YES)
+ #include "MediaInfo/Multiple/File_Riff.h"
+#endif
+#if defined(MEDIAINFO_RM_YES)
+ #include "MediaInfo/Multiple/File_Rm.h"
+#endif
+#if defined(MEDIAINFO_SEQUENCEINFO_YES)
+ #include "MediaInfo/Multiple/File_SequenceInfo.h"
+#endif
+#if defined(MEDIAINFO_SKM_YES)
+ #include "MediaInfo/Multiple/File_Skm.h"
+#endif
+#if defined(MEDIAINFO_SWF_YES)
+ #include "MediaInfo/Multiple/File_Swf.h"
+#endif
+#if defined(MEDIAINFO_WM_YES)
+ #include "MediaInfo/Multiple/File_Wm.h"
+#endif
+#if defined(MEDIAINFO_XDCAM_YES)
+ #include "MediaInfo/Multiple/File_Xdcam_Clip.h"
+#endif
+#if defined(MEDIAINFO_DPG_YES)
+ #include "MediaInfo/Multiple/File_Dpg.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Video
+#if defined(MEDIAINFO_AVC_YES)
+ #include "MediaInfo/Video/File_Avc.h"
+#endif
+#if defined(MEDIAINFO_AVSV_YES)
+ #include "MediaInfo/Video/File_AvsV.h"
+#endif
+#if defined(MEDIAINFO_DIRAC_YES)
+ #include "MediaInfo/Video/File_Dirac.h"
+#endif
+#if defined(MEDIAINFO_FLIC_YES)
+ #include "MediaInfo/Video/File_Flic.h"
+#endif
+#if defined(MEDIAINFO_H263_YES)
+ #include "MediaInfo/Video/File_H263.h"
+#endif
+#if defined(MEDIAINFO_MPEG4V_YES)
+ #include "MediaInfo/Video/File_Mpeg4v.h"
+#endif
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_VC1_YES)
+ #include "MediaInfo/Video/File_Vc1.h"
+#endif
+#if defined(MEDIAINFO_VC3_YES)
+ #include "MediaInfo/Video/File_Vc3.h"
+#endif
+#if defined(MEDIAINFO_Y4M_YES)
+ #include "MediaInfo/Video/File_Y4m.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Audio
+#if defined(MEDIAINFO_AAC_YES)
+ #include "MediaInfo/Audio/File_Aac.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_AES3_YES)
+ #include "MediaInfo/Audio/File_Aes3.h"
+#endif
+#if defined(MEDIAINFO_ALS_YES)
+ #include "MediaInfo/Audio/File_Als.h"
+#endif
+#if defined(MEDIAINFO_AMR_YES)
+ #include "MediaInfo/Audio/File_Amr.h"
+#endif
+#if defined(MEDIAINFO_AMV_YES)
+ #include "MediaInfo/Audio/File_Amv.h"
+#endif
+#if defined(MEDIAINFO_APE_YES)
+ #include "MediaInfo/Audio/File_Ape.h"
+#endif
+#if defined(MEDIAINFO_AU_YES)
+ #include "MediaInfo/Audio/File_Au.h"
+#endif
+#if defined(MEDIAINFO_DTS_YES)
+ #include "MediaInfo/Audio/File_Dts.h"
+#endif
+#if defined(MEDIAINFO_DOLBYE_YES)
+ #include "MediaInfo/Audio/File_DolbyE.h"
+#endif
+#if defined(MEDIAINFO_FLAC_YES)
+ #include "MediaInfo/Audio/File_Flac.h"
+#endif
+#if defined(MEDIAINFO_IT_YES)
+ #include "MediaInfo/Audio/File_ImpulseTracker.h"
+#endif
+#if defined(MEDIAINFO_LA_YES)
+ #include "MediaInfo/Audio/File_La.h"
+#endif
+#if defined(MEDIAINFO_MIDI_YES)
+ #include "MediaInfo/Audio/File_Midi.h"
+#endif
+#if defined(MEDIAINFO_MOD_YES)
+ #include "MediaInfo/Audio/File_Module.h"
+#endif
+#if defined(MEDIAINFO_MPC_YES)
+ #include "MediaInfo/Audio/File_Mpc.h"
+#endif
+#if defined(MEDIAINFO_MPCSV8_YES)
+ #include "MediaInfo/Audio/File_MpcSv8.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if defined(MEDIAINFO_PCM_YES)
+ #include "MediaInfo/Audio/File_Pcm.h"
+#endif
+#if defined(MEDIAINFO_RKAU_YES)
+ #include "MediaInfo/Audio/File_Rkau.h"
+#endif
+#if defined(MEDIAINFO_S3M_YES)
+ #include "MediaInfo/Audio/File_ScreamTracker3.h"
+#endif
+#if defined(MEDIAINFO_TAK_YES)
+ #include "MediaInfo/Audio/File_Tak.h"
+#endif
+#if defined(MEDIAINFO_TTA_YES)
+ #include "MediaInfo/Audio/File_Tta.h"
+#endif
+#if defined(MEDIAINFO_TWINVQ_YES)
+ #include "MediaInfo/Audio/File_TwinVQ.h"
+#endif
+#if defined(MEDIAINFO_WVPK_YES)
+ #include "MediaInfo/Audio/File_Wvpk.h"
+#endif
+#if defined(MEDIAINFO_XM_YES)
+ #include "MediaInfo/Audio/File_ExtendedModule.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Text
+#if defined(MEDIAINFO_EIA608_YES)
+ #include "MediaInfo/Text/File_Eia608.h"
+#endif
+#if defined(MEDIAINFO_N19_YES)
+ #include "MediaInfo/Text/File_N19.h"
+#endif
+#if defined(MEDIAINFO_SCC_YES)
+ #include "MediaInfo/Text/File_Scc.h"
+#endif
+#if defined(MEDIAINFO_OTHERTEXT_YES)
+ #include "MediaInfo/Text/File_OtherText.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Image
+#if defined(MEDIAINFO_BMP_YES)
+ #include "MediaInfo/Image/File_Bmp.h"
+#endif
+#if defined(MEDIAINFO_DPX_YES)
+ #include "MediaInfo/Image/File_Dpx.h"
+#endif
+#if defined(MEDIAINFO_EXR_YES)
+ #include "MediaInfo/Image/File_Exr.h"
+#endif
+#if defined(MEDIAINFO_GIF_YES)
+ #include "MediaInfo/Image/File_Gif.h"
+#endif
+#if defined(MEDIAINFO_ICO_YES)
+ #include "MediaInfo/Image/File_Ico.h"
+#endif
+#if defined(MEDIAINFO_JPEG_YES)
+ #include "MediaInfo/Image/File_Jpeg.h"
+#endif
+#if defined(MEDIAINFO_PNG_YES)
+ #include "MediaInfo/Image/File_Png.h"
+#endif
+#if defined(MEDIAINFO_TIFF_YES)
+ #include "MediaInfo/Image/File_Tiff.h"
+#endif
+#if defined(MEDIAINFO_TGA_YES)
+ #include "MediaInfo/Image/File_Tga.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Archive
+#if defined(MEDIAINFO_7Z_YES)
+ #include "MediaInfo/Archive/File_7z.h"
+#endif
+#if defined(MEDIAINFO_ACE_YES)
+ #include "MediaInfo/Archive/File_Ace.h"
+#endif
+#if defined(MEDIAINFO_BZIP2_YES)
+ #include "MediaInfo/Archive/File_Bzip2.h"
+#endif
+#if defined(MEDIAINFO_ELF_YES)
+ #include "MediaInfo/Archive/File_Elf.h"
+#endif
+#if defined(MEDIAINFO_GZIP_YES)
+ #include "MediaInfo/Archive/File_Gzip.h"
+#endif
+#if defined(MEDIAINFO_ISO9660_YES)
+ #include "MediaInfo/Archive/File_Iso9660.h"
+#endif
+#if defined(MEDIAINFO_MZ_YES)
+ #include "MediaInfo/Archive/File_Mz.h"
+#endif
+#if defined(MEDIAINFO_RAR_YES)
+ #include "MediaInfo/Archive/File_Rar.h"
+#endif
+#if defined(MEDIAINFO_TAR_YES)
+ #include "MediaInfo/Archive/File_Tar.h"
+#endif
+#if defined(MEDIAINFO_ZIP_YES)
+ #include "MediaInfo/Archive/File_Zip.h"
+#endif
+
+//---------------------------------------------------------------------------
+// Other
+#if defined(MEDIAINFO_OTHER_YES)
+ #include "MediaInfo/File_Other.h"
+#endif
+#if defined(MEDIAINFO_UNKNOWN_YES)
+ #include "MediaInfo/File_Unknown.h"
+#endif
+#if defined(MEDIAINFO_DUMMY_YES)
+ #include "MediaInfo/File_Dummy.h"
+#endif
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+bool MediaInfo_Internal::SelectFromExtension (const String &Parser)
+{
+ CriticalSectionLocker CSL(CS);
+
+ //Clear last value
+ delete Info; Info=NULL;
+
+ //Searching the right File_*
+ if (0) {} //For #defines
+
+ // Multiple
+ #if defined(MEDIAINFO_BDAV_YES)
+ else if (Parser==_T("Bdav")) {Info=new File_MpegTs(); ((File_MpegTs*)Info)->BDAV_Size=4;}
+ #endif
+ #if defined(MEDIAINFO_BDMV_YES)
+ else if (Parser==_T("Bdmv")) Info=new File_Bdmv();
+ #endif
+ #if defined(MEDIAINFO_CDXA_YES)
+ else if (Parser==_T("Cdxa")) Info=new File_Cdxa();
+ #endif
+ #if defined(MEDIAINFO_DCP_YES)
+ else if (Parser==_T("Dcp")) Info=new File_Dcp();
+ #endif
+ #if defined(MEDIAINFO_DVDIF_YES)
+ else if (Parser==_T("DvDif")) Info=new File_DvDif();
+ #endif
+ #if defined(MEDIAINFO_DVDV_YES)
+ else if (Parser==_T("Dvdv")) Info=new File_Dvdv();
+ #endif
+ #if defined(MEDIAINFO_DXW_YES)
+ else if (Parser==_T("Dxw")) Info=new File_Dxw();
+ #endif
+ #if defined(MEDIAINFO_FLV_YES)
+ else if (Parser==_T("Flv")) Info=new File_Flv();
+ #endif
+ #if defined(MEDIAINFO_GXF_YES)
+ else if (Parser==_T("Gxf")) Info=new File_Gxf();
+ #endif
+ #if defined(MEDIAINFO_HLS_YES)
+ else if (Parser==_T("Hls")) Info=new File_Hls();
+ #endif
+ #if defined(MEDIAINFO_IVF_YES)
+ else if (Parser==_T("Ivf")) Info=new File_Ivf();
+ #endif
+ #if defined(MEDIAINFO_ISM_YES)
+ else if (Parser==_T("Ism")) Info=new File_Ism();
+ #endif
+ #if defined(MEDIAINFO_LXF_YES)
+ else if (Parser==_T("Lxf")) Info=new File_Lxf();
+ #endif
+ #if defined(MEDIAINFO_MK_YES)
+ else if (Parser==_T("Mk")) Info=new File_Mk();
+ #endif
+ #if defined(MEDIAINFO_MPEG4_YES)
+ else if (Parser==_T("Mpeg4")) Info=new File_Mpeg4();
+ #endif
+ #if defined(MEDIAINFO_MPEGPS_YES)
+ else if (Parser==_T("MpegPs")) Info=new File_MpegPs();
+ #endif
+ #if defined(MEDIAINFO_MPEGTS_YES)
+ else if (Parser==_T("MpegTs")) Info=new File_MpegTs();
+ #endif
+ #if defined(MEDIAINFO_MXF_YES)
+ else if (Parser==_T("Mxf")) Info=new File_Mxf();
+ #endif
+ #if defined(MEDIAINFO_NUT_YES)
+ else if (Parser==_T("Nut")) Info=new File_Nut();
+ #endif
+ #if defined(MEDIAINFO_OGG_YES)
+ else if (Parser==_T("Ogg")) Info=new File_Ogg();
+ #endif
+ #if defined(MEDIAINFO_P2_YES)
+ else if (Parser==_T("P2_Clip")) Info=new File_P2_Clip();
+ #endif
+ #if defined(MEDIAINFO_RIFF_YES)
+ else if (Parser==_T("Riff")) Info=new File_Riff();
+ #endif
+ #if defined(MEDIAINFO_RM_YES)
+ else if (Parser==_T("Rm")) Info=new File_Rm();
+ #endif
+ #if defined(MEDIAINFO_SEQUENCEINFO_YES)
+ else if (Parser==_T("SequenceInfo")) Info=new File_SequenceInfo();
+ #endif
+ #if defined(MEDIAINFO_SKM_YES)
+ else if (Parser==_T("Skm")) Info=new File_Skm();
+ #endif
+ #if defined(MEDIAINFO_SWF_YES)
+ else if (Parser==_T("Swf")) Info=new File_Swf();
+ #endif
+ #if defined(MEDIAINFO_WM_YES)
+ else if (Parser==_T("Wm")) Info=new File_Wm();
+ #endif
+ #if defined(MEDIAINFO_XDCAM_YES)
+ else if (Parser==_T("Xdcam_Clip")) Info=new File_Xdcam_Clip();
+ #endif
+ #if defined(MEDIAINFO_DPG_YES)
+ else if (Parser==_T("Dpg")) Info=new File_Dpg();
+ #endif
+
+ // Video
+ #if defined(MEDIAINFO_AVC_YES)
+ else if (Parser==_T("Avc")) Info=new File_Avc();
+ #endif
+ #if defined(MEDIAINFO_AVSV_YES)
+ else if (Parser==_T("AvsV")) Info=new File_AvsV();
+ #endif
+ #if defined(MEDIAINFO_DIRAC_YES)
+ else if (Parser==_T("Dirac")) Info=new File_Dirac();
+ #endif
+ #if defined(MEDIAINFO_FLIC_YES)
+ else if (Parser==_T("Flic")) Info=new File_Flic();
+ #endif
+ #if defined(MEDIAINFO_H263_YES)
+ else if (Parser==_T("H263")) Info=new File_H263();
+ #endif
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ else if (Parser==_T("Mpeg4v")) Info=new File_Mpeg4v();
+ #endif
+ #if defined(MEDIAINFO_MPEGV_YES)
+ else if (Parser==_T("Mpegv")) Info=new File_Mpegv();
+ #endif
+ #if defined(MEDIAINFO_VC1_YES)
+ else if (Parser==_T("Vc1")) Info=new File_Vc1();
+ #endif
+ #if defined(MEDIAINFO_VC3_YES)
+ else if (Parser==_T("Vc3")) Info=new File_Vc3();
+ #endif
+ #if defined(MEDIAINFO_Y4M_YES)
+ else if (Parser==_T("Y4m")) Info=new File_Y4m();
+ #endif
+
+ // Audio
+ #if defined(MEDIAINFO_AAC_YES)
+ else if (Parser==_T("Aac")) {Info=new File_Aac(); ((File_Aac*)Info)->Mode=File_Aac::Mode_ADIF;}
+ #endif
+ #if defined(MEDIAINFO_AAC_YES)
+ else if (Parser==_T("Aac")) {Info=new File_Aac(); ((File_Aac*)Info)->Mode=File_Aac::Mode_ADTS;}
+ #endif
+ #if defined(MEDIAINFO_AC3_YES)
+ else if (Parser==_T("Ac3")) Info=new File_Ac3();
+ #endif
+ #if defined(MEDIAINFO_AES3_YES)
+ else if (Parser==_T("Aes3")) Info=new File_Aes3();
+ #endif
+ #if defined(MEDIAINFO_ALS_YES)
+ else if (Parser==_T("Als")) Info=new File_Als();
+ #endif
+ #if defined(MEDIAINFO_AMR_YES)
+ else if (Parser==_T("Amr")) Info=new File_Amr();
+ #endif
+ #if defined(MEDIAINFO_AMV_YES)
+ else if (Parser==_T("Amv")) Info=new File_Amv();
+ #endif
+ #if defined(MEDIAINFO_APE_YES)
+ else if (Parser==_T("Ape")) Info=new File_Ape();
+ #endif
+ #if defined(MEDIAINFO_AU_YES)
+ else if (Parser==_T("Au")) Info=new File_Au();
+ #endif
+ #if defined(MEDIAINFO_DTS_YES)
+ else if (Parser==_T("Dts")) Info=new File_Dts();
+ #endif
+ #if defined(MEDIAINFO_DOLBYE_YES)
+ else if (Parser==_T("DolbyE")) Info=new File_DolbyE();
+ #endif
+ #if defined(MEDIAINFO_FLAC_YES)
+ else if (Parser==_T("Flac")) Info=new File_Flac();
+ #endif
+ #if defined(MEDIAINFO_IT_YES)
+ else if (Parser==_T("It")) Info=new File_ImpulseTracker();
+ #endif
+ #if defined(MEDIAINFO_LA_YES)
+ else if (Parser==_T("La")) Info=new File_La();
+ #endif
+ #if defined(MEDIAINFO_MIDI_YES)
+ else if (Parser==_T("Midi")) Info=new File_Midi();
+ #endif
+ #if defined(MEDIAINFO_MOD_YES)
+ else if (Parser==_T("Mod")) Info=new File_Module();
+ #endif
+ #if defined(MEDIAINFO_MPC_YES)
+ else if (Parser==_T("Mpc")) Info=new File_Mpc();
+ #endif
+ #if defined(MEDIAINFO_MPCSV8_YES)
+ else if (Parser==_T("Mpc")) Info=new File_MpcSv8();
+ #endif
+ #if defined(MEDIAINFO_MPEGA_YES)
+ else if (Parser==_T("Mpega")) Info=new File_Mpega();
+ #endif
+ #if defined(MEDIAINFO_PCM_YES)
+ //else if (Parser==_T("Pcm")) Info=new File_Pcm();
+ #endif
+ #if defined(MEDIAINFO_AU_YES)
+ else if (Parser==_T("Au")) Info=new File_Au();
+ #endif
+ #if defined(MEDIAINFO_RKAU_YES)
+ else if (Parser==_T("Rkau")) Info=new File_Rkau();
+ #endif
+ #if defined(MEDIAINFO_S3M_YES)
+ else if (Parser==_T("S3m")) Info=new File_ScreamTracker3();
+ #endif
+ #if defined(MEDIAINFO_TAK_YES)
+ else if (Parser==_T("Tak")) Info=new File_Tak();
+ #endif
+ #if defined(MEDIAINFO_TTA_YES)
+ else if (Parser==_T("Tta")) Info=new File_Tta();
+ #endif
+ #if defined(MEDIAINFO_TWINVQ_YES)
+ else if (Parser==_T("TwinVQ")) Info=new File_TwinVQ();
+ #endif
+ #if defined(MEDIAINFO_WVPK_YES)
+ else if (Parser==_T("Wvpk")) Info=new File_Wvpk();
+ #endif
+ #if defined(MEDIAINFO_XM_YES)
+ else if (Parser==_T("Xm")) Info=new File_ExtendedModule();
+ #endif
+
+ // Text
+ #if defined(MEDIAINFO_EIA608_YES)
+ else if (Parser==_T("CEA-608")) Info=new File_Eia608();
+ else if (Parser==_T("EIA-608")) Info=new File_Eia608();
+ #endif
+ #if defined(MEDIAINFO_OTHERTEXT_YES)
+ else if (Parser==_T("N19")) Info=new File_N19();
+ #endif
+ #if defined(MEDIAINFO_SCC_YES)
+ else if (Parser==_T("SCC")) Info=new File_Scc();
+ #endif
+ #if defined(MEDIAINFO_OTHERTEXT_YES)
+ else if (Parser==_T("OtherText")) Info=new File_OtherText();
+ #endif
+
+ // Image
+ #if defined(MEDIAINFO_GIF_YES)
+ else if (Parser==_T("Gif")) Info=new File_Gif();
+ #endif
+ #if defined(MEDIAINFO_BMP_YES)
+ else if (Parser==_T("Bmp")) Info=new File_Bmp();
+ #endif
+ #if defined(MEDIAINFO_DPX_YES)
+ else if (Parser==_T("Dpx")) Info=new File_Dpx();
+ #endif
+ #if defined(MEDIAINFO_EXR_YES)
+ else if (Parser==_T("Exr")) Info=new File_Exr();
+ #endif
+ #if defined(MEDIAINFO_ICO_YES)
+ else if (Parser==_T("Ico")) Info=new File_Ico();
+ #endif
+ #if defined(MEDIAINFO_JPEG_YES)
+ else if (Parser==_T("Jpeg")) Info=new File_Jpeg();
+ #endif
+ #if defined(MEDIAINFO_PNG_YES)
+ else if (Parser==_T("Png")) Info=new File_Png();
+ #endif
+ #if defined(MEDIAINFO_TIFF_YES)
+ else if (Parser==_T("Tiff")) Info=new File_Tiff();
+ #endif
+ #if defined(MEDIAINFO_TGA_YES)
+ else if (Parser==_T("Tga")) Info=new File_Tga();
+ #endif
+
+ // Archive
+ #if defined(MEDIAINFO_7Z_YES)
+ else if (Parser==_T("7z")) Info=new File_7z();
+ #endif
+ #if defined(MEDIAINFO_ACE_YES)
+ else if (Parser==_T("Ace")) Info=new File_Ace();
+ #endif
+ #if defined(MEDIAINFO_BZIP2_YES)
+ else if (Parser==_T("Bzip2")) Info=new File_Bzip2();
+ #endif
+ #if defined(MEDIAINFO_ELF_YES)
+ else if (Parser==_T("Elf")) Info=new File_Elf();
+ #endif
+ #if defined(MEDIAINFO_GZIP_YES)
+ else if (Parser==_T("Gzip")) Info=new File_Gzip();
+ #endif
+ #if defined(MEDIAINFO_ISO9660_YES)
+ else if (Parser==_T("Iso9660")) Info=new File_Iso9660();
+ #endif
+ #if defined(MEDIAINFO_MZ_YES)
+ else if (Parser==_T("Mz")) Info=new File_Mz();
+ #endif
+ #if defined(MEDIAINFO_RAR_YES)
+ else if (Parser==_T("Rar")) Info=new File_Rar();
+ #endif
+ #if defined(MEDIAINFO_TAR_YES)
+ else if (Parser==_T("Tar")) Info=new File_Tar();
+ #endif
+ #if defined(MEDIAINFO_ZIP_YES)
+ else if (Parser==_T("Zip")) Info=new File_Zip();
+ #endif
+
+ // Other
+ #if defined(MEDIAINFO_OTHER_YES)
+ else if (Parser==_T("Other")) Info=new File_Other();
+ #endif
+
+ //No parser
+ else
+ return false;
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+#if !defined(MEDIAINFO_READER_NO)
+int MediaInfo_Internal::ListFormats(const String &File_Name)
+{
+ // Multiple
+ #if defined(MEDIAINFO_BDAV_YES)
+ delete Info; Info=new File_MpegTs(); ((File_MpegTs*)Info)->BDAV_Size=4; if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_BDMV_YES)
+ delete Info; Info=new File_Bdmv(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_CDXA_YES)
+ delete Info; Info=new File_Cdxa(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_DCP_YES)
+ delete Info; Info=new File_Dcp(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_DVDIF_YES)
+ delete Info; Info=new File_DvDif(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_DVDV_YES)
+ delete Info; Info=new File_Dvdv(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_DXW_YES)
+ delete Info; Info=new File_Dxw(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_FLV_YES)
+ delete Info; Info=new File_Flv(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_GXF_YES)
+ delete Info; Info=new File_Gxf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_HLS_YES)
+ delete Info; Info=new File_Hls(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_IBI_YES)
+ delete Info; Info=new File_Ibi(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_ISM_YES)
+ delete Info; Info=new File_Ism(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_IVF_YES)
+ delete Info; Info=new File_Ivf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_LXF_YES)
+ delete Info; Info=new File_Lxf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MK_YES)
+ delete Info; Info=new File_Mk(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MPEG4_YES)
+ delete Info; Info=new File_Mpeg4(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MPEGPS_YES)
+ delete Info; Info=new File_MpegPs(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MPEGTS_YES)
+ delete Info; Info=new File_MpegTs(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MPLI_YES)
+ delete Info; Info=new File_Mpli(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MXF_YES)
+ delete Info; Info=new File_Mxf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_NUT_YES)
+ delete Info; Info=new File_Nut(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_OGG_YES)
+ delete Info; Info=new File_Ogg(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_P2_YES)
+ delete Info; Info=new File_P2_Clip(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_RIFF_YES)
+ delete Info; Info=new File_Riff(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_RM_YES)
+ delete Info; Info=new File_Rm(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_SEQUENCEINFO_YES)
+ delete Info; Info=new File_SequenceInfo(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_SKM_YES)
+ delete Info; Info=new File_Skm(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_SWF_YES)
+ delete Info; Info=new File_Swf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_TSP_YES)
+ delete Info; Info=new File_MpegTs(); ((File_MpegTs*)Info)->TSP_Size=16; if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_WM_YES)
+ delete Info; Info=new File_Wm(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_XDCAM_YES)
+ delete Info; Info=new File_Xdcam_Clip(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_DPG_YES)
+ delete Info; Info=new File_Dpg(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+
+ // Video
+ #if defined(MEDIAINFO_AVC_YES)
+ delete Info; Info=new File_Avc(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_AVSV_YES)
+ delete Info; Info=new File_AvsV(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_DIRAC_YES)
+ delete Info; Info=new File_Dirac(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_FLIC_YES)
+ delete Info; Info=new File_Flic(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_H263_YES)
+ delete Info; Info=new File_H263(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ delete Info; Info=new File_Mpeg4v(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MPEGV_YES)
+ delete Info; Info=new File_Mpegv(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_VC1_YES)
+ delete Info; Info=new File_Vc1(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_VC3_YES)
+ delete Info; Info=new File_Vc3(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_Y4M_YES)
+ delete Info; Info=new File_Y4m(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+
+ // Audio
+ #if defined(MEDIAINFO_AAC_YES)
+ delete Info; Info=new File_Aac(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_AC3_YES)
+ delete Info; Info=new File_Ac3(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_AES3_YES)
+ delete Info; Info=new File_Aes3(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_ALS_YES)
+ delete Info; Info=new File_Als(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_AMR_YES)
+ delete Info; Info=new File_Amr(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_AMV_YES)
+ delete Info; Info=new File_Amv(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_APE_YES)
+ delete Info; Info=new File_Ape(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_AU_YES)
+ delete Info; Info=new File_Au(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_DTS_YES)
+ delete Info; Info=new File_Dts(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_DOLBYE_YES)
+ delete Info; Info=new File_DolbyE(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_FLAC_YES)
+ delete Info; Info=new File_Flac(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_IT_YES)
+ delete Info; Info=new File_ImpulseTracker(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_LA_YES)
+ delete Info; Info=new File_La(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MIDI_YES)
+ delete Info; Info=new File_Midi(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MOD_YES)
+ delete Info; Info=new File_Module(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MPC_YES)
+ delete Info; Info=new File_Mpc(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MPCSV8_YES)
+ delete Info; Info=new File_MpcSv8(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MPEGA_YES)
+ delete Info; Info=new File_Mpega(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_PCM_YES)
+ //delete Info; Info=new File_Pcm(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_RKAU_YES)
+ delete Info; Info=new File_Rkau(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_TAK_YES)
+ delete Info; Info=new File_Tak(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_S3M_YES)
+ delete Info; Info=new File_ScreamTracker3(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_TTA_YES)
+ delete Info; Info=new File_Tta(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_TWINVQ_YES)
+ delete Info; Info=new File_TwinVQ(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_WVPK_YES)
+ delete Info; Info=new File_Wvpk(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_XM_YES)
+ delete Info; Info=new File_ExtendedModule(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+
+ // Text
+ #if defined(MEDIAINFO_N19_YES)
+ delete Info; Info=new File_N19(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_SCC_YES)
+ delete Info; Info=new File_Scc(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_OTHERTEXT_YES)
+ delete Info; Info=new File_OtherText(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+
+ // Image
+ #if defined(MEDIAINFO_BMP_YES)
+ delete Info; Info=new File_Bmp(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_DPX_YES)
+ delete Info; Info=new File_Dpx(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_GIF_YES)
+ delete Info; Info=new File_Gif(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_ICO_YES)
+ delete Info; Info=new File_Ico(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_JPEG_YES)
+ delete Info; Info=new File_Jpeg(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_PNG_YES)
+ delete Info; Info=new File_Png(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_TIFF_YES)
+ delete Info; Info=new File_Tiff(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_TGA_YES)
+ delete Info; Info=new File_Tga(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+
+ // Archive
+ #if defined(MEDIAINFO_ACE_YES)
+ delete Info; Info=new File_Ace(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_7Z_YES)
+ delete Info; Info=new File_7z(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_BZIP2_YES)
+ delete Info; Info=new File_Bzip2(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_ELF_YES)
+ delete Info; Info=new File_Elf(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_GZIP_YES)
+ delete Info; Info=new File_Gzip(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_ISO9660_YES)
+ delete Info; Info=new File_Iso9660(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_MZ_YES)
+ delete Info; Info=new File_Mz(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_RAR_YES)
+ delete Info; Info=new File_Rar(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_TAR_YES)
+ delete Info; Info=new File_Tar(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+ #if defined(MEDIAINFO_ZIP_YES)
+ delete Info; Info=new File_Zip(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+
+ // Other
+ #if !defined(MEDIAINFO_OTHER_NO)
+ delete Info; Info=new File_Other(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ #endif
+
+ // Default (empty)
+ delete Info; Info=new File_Unknown(); if (((Reader_File*)Reader)->Format_Test_PerParser(this, File_Name)>0) return 1;
+ return 0;
+}
+#endif //!defined(MEDIAINFO_READER_NO)
+
+//---------------------------------------------------------------------------
+bool MediaInfo_Internal::LibraryIsModified ()
+{
+ #if defined(MEDIAINFO_MULTI_NO) || defined(MEDIAINFO_VIDEO_NO) || defined(MEDIAINFO_AUDIO_NO) || defined(MEDIAINFO_TEXT_NO) || defined(MEDIAINFO_IMAGE_NO) || defined(MEDIAINFO_ARCHIVE_NO) \
+ || defined(MEDIAINFO_BDAV_NO) || defined(MEDIAINFO_MK_NO) || defined(MEDIAINFO_OGG_NO) || defined(MEDIAINFO_RIFF_NO) || defined(MEDIAINFO_MPEG4_NO) || defined(MEDIAINFO_MPEGPS_NO) || defined(MEDIAINFO_MPEGTS_NO) || defined(MEDIAINFO_DXW_NO) || defined(MEDIAINFO_FLV_NO) || defined(MEDIAINFO_GXF_NO) || defined(MEDIAINFO_HLS_NO) || defined(MEDIAINFO_ISM_NO) || defined(MEDIAINFO_IVF_NO) || defined(MEDIAINFO_LXF_NO) || defined(MEDIAINFO_SWF_NO) || defined(MEDIAINFO_MXF_NO) || defined(MEDIAINFO_NUT_NO) || defined(MEDIAINFO_WM_NO) || defined(MEDIAINFO_QT_NO) || defined(MEDIAINFO_RM_NO) || defined(MEDIAINFO_DVDIF_NO) || defined(MEDIAINFO_DVDV_NO) || defined(MEDIAINFO_CDXA_NO) || defined(MEDIAINFO_DPG_NO) || defined(MEDIAINFO_TSP_NO) \
+ || defined(MEDIAINFO_AVC_NO) || defined(MEDIAINFO_AVSV_NO) || defined(MEDIAINFO_MPEG4V_NO) || defined(MEDIAINFO_MPEGV_NO) || defined(MEDIAINFO_FLIC_NO) || defined(MEDIAINFO_THEORA_NO) || defined(MEDIAINFO_Y4M_NO) \
+ || defined(MEDIAINFO_AC3_NO) || defined(MEDIAINFO_ADIF_NO) || defined(MEDIAINFO_ADTS_NO) || defined(MEDIAINFO_AES3_NO) || defined(MEDIAINFO_AMR_NO) || defined(MEDIAINFO_DTS_NO) || defined(MEDIAINFO_DOLBYE_NO) || defined(MEDIAINFO_FLAC_NO) || defined(MEDIAINFO_APE_NO) || defined(MEDIAINFO_MPC_NO) || defined(MEDIAINFO_MPCSV8_NO) || defined(MEDIAINFO_MPEGA_NO) || defined(MEDIAINFO_TWINVQ_NO) || defined(MEDIAINFO_XM_NO) || defined(MEDIAINFO_MOD_NO) || defined(MEDIAINFO_S3M_NO) || defined(MEDIAINFO_IT_NO) || defined(MEDIAINFO_SPEEX_NO) || defined(MEDIAINFO_TAK_NO) || defined(MEDIAINFO_PS2A_NO) \
+ || defined(MEDIAINFO_CMML_NO) || defined(MEDIAINFO_KATE_NO) || defined(MEDIAINFO_PGS_NO) || defined(MEDIAINFO_OTHERTEXT_NO) \
+ || defined(MEDIAINFO_BMP_NO) || defined(MEDIAINFO_DPX_NO) || defined(MEDIAINFO_EXR_NO) || defined(MEDIAINFO_GIF_NO) || defined(MEDIAINFO_ICO_NO) || defined(MEDIAINFO_JPEG_NO) || defined(MEDIAINFO_PNG_NO) || defined(MEDIAINFO_TGA_NO) || defined(MEDIAINFO_TIFF_NO) \
+ || defined(MEDIAINFO_7Z_NO) || defined(MEDIAINFO_ZIP_NO) || defined(MEDIAINFO_RAR_NO) || defined(MEDIAINFO_ACE_NO) || defined(MEDIAINFO_ELF_NO) || defined(MEDIAINFO_MZ_NO) \
+ || defined(MEDIAINFO_OTHER_NO) || defined(MEDIAINFO_DUMMY_NO)
+ return true;
+ #else
+ return false;
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Internal::CreateDummy (const String&)
+{
+ #if defined(MEDIAINFO_DUMMY_YES)
+ Info=new File_Dummy();
+ ((File_Dummy*)Info)->KindOfDummy=Value;
+ #endif
+}
+
+} //NameSpace
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Inform.cpp b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Inform.cpp
new file mode 100644
index 000000000..63acb9c84
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Inform.cpp
@@ -0,0 +1,623 @@
+// MediaInfo_Inform - Base for other files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Inform part
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Utils.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "MediaInfo/Export/Export_Mpeg7.h"
+#include "MediaInfo/Export/Export_reVTMD.h"
+#include "MediaInfo/Export/Export_PBCore.h"
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern MediaInfo_Config Config;
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+Ztring MediaInfo_Internal::Inform()
+{
+ CS.Enter();
+ if (Info && Info->Status[File__Analyze::IsUpdated])
+ Info->Open_Buffer_Update();
+ CS.Leave();
+
+ #if MEDIAINFO_TRACE
+ if (MediaInfoLib::Config.Trace_Level_Get() || MediaInfoLib::Config.Inform_Get()==_T("Details"))
+ {
+ if (!Details.empty())
+ {
+ Ztring Content=Details;
+
+ return Details;
+ }
+ else if (Info)
+ return Info->Details_Get();
+ }
+ #endif //MEDIAINFO_TRACE
+
+ if (MediaInfoLib::Config.Inform_Get()==_T("MPEG-7"))
+ return Export_Mpeg7().Transform(*this);
+ if (MediaInfoLib::Config.Inform_Get()==_T("PBCore") || MediaInfoLib::Config.Inform_Get()==_T("PBCore_1.2"))
+ return Export_PBCore().Transform(*this);
+ if (MediaInfoLib::Config.Inform_Get()==_T("reVTMD"))
+ return _T("reVTMD is disabled due to its non-free licensing."); //return Export_reVTMD().Transform(*this);
+
+ if (!(
+ MediaInfoLib::Config.Inform_Get(_T("General")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Video")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Audio")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Text")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Chapters")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Image")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Menu")).empty()
+ ))
+ {
+ Ztring Retour;
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("File_Begin"));
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("General_Begin"));
+ Retour+=Inform(Stream_General, 0, false);
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("General_End"));
+ if (Count_Get(Stream_Video))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Video_Begin"));
+ for (size_t I1=0; I1<Count_Get(Stream_Video); I1++)
+ {
+ Retour+=Inform(Stream_Video, I1, false);
+ if (I1!=Count_Get(Stream_Video)-1)
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Video_Middle"));
+ }
+ if (Count_Get(Stream_Video))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Video_End"));
+ if (Count_Get(Stream_Audio))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Audio_Begin"));
+ for (size_t I1=0; I1<Count_Get(Stream_Audio); I1++)
+ {
+ Retour+=Inform(Stream_Audio, I1, false);
+ if (I1!=Count_Get(Stream_Audio)-1)
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Audio_Middle"));
+ }
+ if (Count_Get(Stream_Audio))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Audio_End"));
+ if (Count_Get(Stream_Text))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Text_Begin"));
+ for (size_t I1=0; I1<Count_Get(Stream_Text); I1++)
+ {
+ Retour+=Inform(Stream_Text, I1, false);
+ if (I1!=Count_Get(Stream_Text)-1)
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Text_Middle"));
+ }
+ if (Count_Get(Stream_Text))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Text_End"));
+ if (Count_Get(Stream_Chapters))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Chapters_Begin"));
+ for (size_t I1=0; I1<Count_Get(Stream_Chapters); I1++)
+ {
+ Retour+=Inform(Stream_Chapters, I1, false);
+ if (I1!=Count_Get(Stream_Chapters)-1)
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Chapters_Middle"));
+ }
+ if (Count_Get(Stream_Chapters))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Chapters_End"));
+ if (Count_Get(Stream_Image))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Image_Begin"));
+ for (size_t I1=0; I1<Count_Get(Stream_Image); I1++)
+ {
+ Retour+=Inform(Stream_Image, I1, false);
+ if (I1!=Count_Get(Stream_Image)-1)
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Image_Middle"));
+ }
+ if (Count_Get(Stream_Image))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Image_End"));
+ if (Count_Get(Stream_Menu))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Menu_Begin"));
+ for (size_t I1=0; I1<Count_Get(Stream_Menu); I1++)
+ {
+ Retour+=Inform(Stream_Menu, I1, false);
+ if (I1!=Count_Get(Stream_Menu)-1)
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Menu_Middle"));
+ }
+ if (Count_Get(Stream_Menu))
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("Menu_End"));
+ Retour+=MediaInfoLib::Config.Inform_Get(_T("File_End"));
+
+ Retour.FindAndReplace(_T("\\r\\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\r"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\r\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\r"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\n"), MediaInfoLib::Config.LineSeparator_Get(), 0, Ztring_Recursive);
+
+ //Special characters
+ Retour.FindAndReplace(_T("|SC1|"), _T("\\"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC2|"), _T("["), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC3|"), _T("]"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC4|"), _T(","), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC5|"), _T(";"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC6|"), _T("("), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC7|"), _T(")"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC8|"), _T(")"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC9|"), _T("),"), 0, Ztring_Recursive);
+
+ return Retour;
+ }
+
+ //Informations
+ Ztring Retour;
+ bool HTML=false;
+ bool XML=false;
+ bool CSV=false;
+ if (MediaInfoLib::Config.Inform_Get()==_T("HTML"))
+ HTML=true;
+ if (MediaInfoLib::Config.Inform_Get()==_T("XML"))
+ XML=true;
+ if (MediaInfoLib::Config.Inform_Get()==_T("CSV"))
+ CSV=true;
+
+ if (HTML) Retour+=_T("<html>\n\n<head>\n<META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /></head>\n<body>\n");
+ if (XML) Retour+=_T("<File>\n");
+
+ for (size_t StreamKind=(size_t)Stream_General; StreamKind<Stream_Max; StreamKind++)
+ {
+ //Pour chaque type de flux
+ for (size_t StreamPos=0; StreamPos<(size_t)Count_Get((stream_t)StreamKind); StreamPos++)
+ {
+ //Pour chaque stream
+ if (HTML) Retour+=_T("<table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"2\" style=\"border:1px solid Navy\">\n<tr>\n <td width=\"150\"><h2>");
+ if (XML) Retour+=_T("<track type=\"");
+ Ztring A=Get((stream_t)StreamKind, StreamPos, _T("StreamKind/String"));
+ Ztring B=Get((stream_t)StreamKind, StreamPos, _T("StreamKindPos"));
+ if (!XML && !B.empty())
+ {
+ if (CSV)
+ A+=_T(",");
+ else
+ A+=MediaInfoLib::Config.Language_Get(_T(" Config_Text_NumberTag"));
+ A+=B;
+ }
+ Retour+=A;
+ if (XML)
+ {
+ Retour+=_T("\"");
+ if (!B.empty())
+ {
+ Retour+=_T(" streamid=\"");
+ Retour+=B;
+ Retour+=_T("\"");
+ }
+ }
+ if (HTML) Retour+=_T("</h2></td>\n </tr>");
+ if (XML) Retour+=_T(">");
+ Retour+=MediaInfoLib::Config.LineSeparator_Get();
+ Retour+=Inform((stream_t)StreamKind, StreamPos, false);
+ Retour.FindAndReplace(_T("\\"), _T("|SC1|"), 0, Ztring_Recursive);
+ if (HTML) Retour+=_T("</table>\n<br />");
+ if (XML) Retour+=_T("</track>\n");
+ Retour+=MediaInfoLib::Config.LineSeparator_Get();
+ }
+ }
+
+ if (HTML) Retour+=_T("\n</body>\n</html>\n");
+ if (XML) Retour+=_T("</File>\n");
+
+ Retour.FindAndReplace(_T("\\r\\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\r"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\r\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\r"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\n"), MediaInfoLib::Config.LineSeparator_Get(), 0, Ztring_Recursive);
+
+ //Special characters
+ Retour.FindAndReplace(_T("|SC1|"), _T("\\"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC2|"), _T("["), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC3|"), _T("]"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC4|"), _T(","), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC5|"), _T(";"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC6|"), _T("("), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC7|"), _T(")"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC8|"), _T(")"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC9|"), _T("),"), 0, Ztring_Recursive);
+
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+Ztring MediaInfo_Internal::Inform (stream_t StreamKind, size_t StreamPos, bool IsDirect)
+{
+ //Integrity
+ if (StreamKind>=Stream_Max || StreamPos>=Stream[StreamKind].size())
+ return Ztring();
+
+ if (MediaInfoLib::Config.Inform_Get(_T("General")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Video")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Audio")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Text")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Chapters")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Image")).empty()
+ && MediaInfoLib::Config.Inform_Get(_T("Menu")).empty())
+ {
+ Ztring Retour;
+ bool HTML=false;
+ bool XML=false;
+ bool CSV=false;
+ if (MediaInfoLib::Config.Inform_Get()==_T("HTML"))
+ HTML=true;
+ if (MediaInfoLib::Config.Inform_Get()==_T("XML"))
+ XML=true;
+ if (MediaInfoLib::Config.Inform_Get()==_T("CSV"))
+ CSV=true;
+ size_t Size=Count_Get(StreamKind, StreamPos);
+ for (size_t Champ_Pos=0; Champ_Pos<Size; Champ_Pos++)
+ {
+ //Pour chaque champ
+ //Ztring A=Get((stream_t)4, 2, 0, Info_Measure_Text); // TODO Bug sinon? voir Ztring
+ Ztring A=Get((stream_t)StreamKind, StreamPos, Champ_Pos, Info_Measure_Text); // TODO Bug sinon? voir Ztring
+ if ((MediaInfoLib::Config.Complete_Get() || Get((stream_t)StreamKind, StreamPos, Champ_Pos, Info_Options)[InfoOption_ShowInInform]==_T('Y')) && !Get((stream_t)StreamKind, StreamPos, Champ_Pos, Info_Text).empty())
+ {
+ Ztring Nom=Get((stream_t)StreamKind, StreamPos, Champ_Pos, Info_Name_Text);
+ if (Nom.empty())
+ Nom=Get((stream_t)StreamKind, StreamPos, Champ_Pos, Info_Name); //Texte n'existe pas
+ if (!HTML && !XML && !CSV)
+ {
+ int8u Nom_Size=MediaInfoLib::Config.Language_Get(_T(" Config_Text_ColumnSize")).To_int8u();
+ if (Nom_Size==0)
+ Nom_Size=32; //Default
+ Nom.resize(Nom_Size, ' ');
+ }
+ Ztring Valeur=Get((stream_t)StreamKind, StreamPos, Champ_Pos, Info_Text);
+ Valeur.FindAndReplace(_T("\\"), _T("|SC1|"), 0, Ztring_Recursive);
+ if (HTML)
+ {
+ Retour+=_T(" <tr>\n <td><i>");
+ Retour+=Nom;
+ Retour+=_T(" :</i></td>\n <td colspan=\"3\">");
+ Retour+=Valeur;
+ Retour+=_T("</td>\n </tr>");
+ }
+ else if (XML)
+ {
+ Nom=Xml_Name_Escape(Nom);
+ Xml_Content_Escape_Modifying(Valeur);
+
+ Retour+=_T("<");
+ Retour+=Nom;
+ Retour+=_T(">");
+ Retour+=Valeur;
+ Retour+=_T("</");
+ Retour+=Nom;
+ Retour+=_T(">");
+ }
+ else if (CSV)
+ {
+ Retour+=Nom;
+ Retour+=_T(",");
+ Retour+=Valeur;
+ }
+ else
+ Retour+=Nom + MediaInfoLib::Config.Language_Get(_T(" Config_Text_Separator")) + Valeur;
+ Retour+=MediaInfoLib::Config.LineSeparator_Get();
+ }
+ }
+
+ Retour.FindAndReplace(_T("\\r\\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\r"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\r\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\r"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\n"), MediaInfoLib::Config.LineSeparator_Get(), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC1|"), _T("\\"), 0, Ztring_Recursive);
+ return Retour;
+ }
+
+ Ztring Retour=MediaInfoLib::Config.Inform_Get(Get(StreamKind, 0, _T("StreamKind"), Info_Text));
+ ZtringList Info;
+
+ if (StreamKind>=Stream_Max)
+ return Ztring();
+ Info=Stream[StreamKind][StreamPos];
+
+ //Special characters
+ Retour.FindAndReplace(_T("\\\\"), _T("|SC1|"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\["), _T("|SC2|"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\]"), _T("|SC3|"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\,"), _T("|SC4|"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\;"), _T("|SC5|"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\("), _T("|SC6|"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\)"), _T("|SC7|"), 0, Ztring_Recursive);
+
+ //Gestion $xx$
+ size_t PosX=0;
+ while (Retour.find(_T("$"), PosX)!=(size_t)-1)
+ {
+ PosX=Retour.find(_T("$"), PosX);
+ if (Retour.size()>PosX+2 && !(Retour(PosX+1)==_T('i') && Retour(PosX+2)==_T('f') && Retour(PosX+3)==_T('('))) //To keep out "%" without any signification, or "$if(..."
+ {
+ Ztring ARemplacer=Ztring(_T("$")+Retour.SubString(_T("$"), _T("$"), PosX))+_T("$");
+ Ztring RemplacerPar=MediaInfoLib::Config.Language_Get(Retour.SubString(_T("$"), _T("$"), PosX)); //TODO : case sensitive
+ Retour.FindAndReplace(ARemplacer, RemplacerPar);
+ }
+ else
+ PosX++;
+ }
+
+ //Gestion $if()
+ size_t Position=Retour.find(_T("$if("));
+ while (Position!=Error && Position>0)
+ {
+ ZtringList Elements;
+ size_t Elements_Index;
+ Elements.Separator_Set(0, _T(","));
+ Elements.Write(Retour.SubString(_T("$if("), _T(")"), Position));
+ Elements(0)=Elements(0).SubString(_T("%"), _T("%"));
+
+ //Test if there is something to replace
+ size_t Pos=MediaInfoLib::Config.Info_Get(StreamKind).Find(Elements(0));
+ if (Pos!=std::string::npos)
+ {
+ if (Info(Pos).size()>0)
+ Elements_Index=1;
+ else
+ Elements_Index=2;
+ }
+ else
+ Elements_Index=2;
+
+ //Replace
+ while (Elements(Elements_Index).SubString(_T("%"), _T("%")).size()>0)
+ {
+ Ztring ToReplace=Elements(Elements_Index).SubString(_T("%"), _T("%"));
+ Ztring ReplacedBy=Info(MediaInfoLib::Config.Info_Get(StreamKind).Find(ToReplace));
+ ToReplace=Ztring(_T("%"))+ToReplace+Ztring(_T("%"));
+ Elements(Elements_Index).FindAndReplace(ToReplace, ReplacedBy);
+ }
+
+ Ztring ToReplace=Ztring(_T("$if("))+Retour.SubString(_T("$if("), _T(")"), Position)+_T(")");
+ Retour.FindAndReplace(ToReplace, Elements(Elements_Index));
+ Position=Retour.find(_T("$if("));
+ }
+
+ //Gestion []
+ while (!Retour.SubString(_T("["), _T("]")).empty())
+ {
+ Ztring Crochets=Retour.SubString(_T("["), _T("]"));
+ Ztring ValueToFind=Crochets.SubString(_T("%"), _T("%"));
+ size_t ValueToFind_Pos=MediaInfoLib::Config.Info_Get(StreamKind).Find(ValueToFind);
+ Ztring ARemplacer=Ztring(_T("[")+Crochets+_T("]"));
+ if (ValueToFind_Pos!=Error)
+ {
+ Ztring RemplacerPar=Info(ValueToFind_Pos);
+ if (RemplacerPar.empty())
+ Retour.FindAndReplace(ARemplacer, Ztring());
+ else
+ {
+ //Formate l'interieur
+ Ztring ATraiter=Crochets;
+ Ztring Crochets_ARemplacer=Ztring(_T("%")+ATraiter.SubString(_T("%"), _T("%")))+_T("%");
+ Ztring Crochets_RemplacerPar=Info(MediaInfoLib::Config.Info_Get(StreamKind).Find(ATraiter.SubString(_T("%"), _T("%"))));
+ ATraiter.FindAndReplace(Crochets_ARemplacer, Crochets_RemplacerPar);
+ Retour.FindAndReplace(ARemplacer, ATraiter);
+ }
+ }
+ else
+ Retour.FindAndReplace(ARemplacer, Ztring());
+ }
+
+ //Gestion %xxx%
+ PosX=0;
+ while (Retour.find(_T("%"), PosX)!=(size_t)-1)
+ {
+ PosX=Retour.find(_T("%"), PosX);
+ if (Retour.size()>PosX+2 && Retour[PosX+1]>=_T('A') && Retour[PosX+1]<=_T('Z')) //To keep out "%" without any signification
+ {
+ Ztring ARemplacer=Ztring(_T("%")+Retour.SubString(_T("%"), _T("%"), PosX))+_T("%");
+ Ztring RemplacerPar=Get(StreamKind, StreamPos, Retour.SubString(_T("%"), _T("%"), PosX));
+ RemplacerPar.FindAndReplace(_T("\\"), _T("|SC1|"), 0, Ztring_Recursive);
+ RemplacerPar.FindAndReplace(_T("),"), _T("|SC9|"), 0, Ztring_Recursive);
+ RemplacerPar.FindAndReplace(_T(")"), _T("|SC8|"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(ARemplacer, RemplacerPar);
+ }
+ else
+ PosX++;
+ }
+
+ //Retour=_T("<table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"2\" style=\"border:1px solid Navy\">\n<tr>\n <td width=\"150\">Video #0</td>\n </tr>\r\n <tr>\n <td><i>Codec :</i></td>\n <td colspan=\"3\">WMV1</td>\n </tr>\r\n <tr>\n <td><i>Codec/Info :</i></td>\n <td colspan=\"3\">Windows Media Video 7</td>\n </tr>\r\n <tr>\n <td><i>Width :</i></td>\n <td colspan=\"3\">200 pixels</td>\n </tr>\r\n <tr>\n <td><i>Height :</i></td>\n <td colspan=\"3\">150 pixels</td>\n </tr>\r\n <tr>\n <td><i>Aspect ratio :</i></td>\n <td colspan=\"3\">4/3</td>\n </tr>\r\n <tr>\n <td><i>Resolution :</i></td>\n <td colspan=\"3\">24 bits</td>\n </tr>\r\n</table>\n");
+ Retour.FindAndReplace(_T("\\r\\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\r"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\r\n"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\r"), _T("\n"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("\n"), MediaInfoLib::Config.LineSeparator_Get(), 0, Ztring_Recursive);
+
+ //Special characters
+ if (IsDirect)
+ {
+ Retour.FindAndReplace(_T("|SC1|"), _T("\\"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC2|"), _T("["), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC3|"), _T("]"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC4|"), _T(","), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC5|"), _T(";"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC6|"), _T("("), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC7|"), _T(")"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC8|"), _T(")"), 0, Ztring_Recursive);
+ Retour.FindAndReplace(_T("|SC9|"), _T("),"), 0, Ztring_Recursive);
+ }
+
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Internal::Traiter(Ztring &C)
+{
+ //$if(%a%,zezeze%a%,rrere)
+ size_t Position=C.find(_T("$if("));
+ while (Position>0)
+ {
+ //Recuperation de la chaine entiere
+ Ztring Total;
+ Ztring ARemplacer;
+ ZtringList Total1;
+ Total1.Separator_Set(0, _T("),"));
+ Total=C.SubString(_T("$if("), _T(")"), Position);
+ ARemplacer=Ztring(_T("$if(")+Total+_T(")"));
+ Total1.Write(Total);
+ if (Total1(0).empty()) //mettre champ2
+ C.FindAndReplace(ARemplacer, Total1(2), Position);
+ else
+ C.FindAndReplace(ARemplacer, Total1(1), Position);
+ Position=C.find(_T("$if("), Position);
+ }
+
+ //reformatage
+ C.FindAndReplace(_T("|SC8|"), _T(")"), 0, Ztring_Recursive);
+ C.FindAndReplace(_T("|SC9|"), _T("),"), 0, Ztring_Recursive);
+ //C.FindAndReplace(_T("\\r\\n"), _T("\n"), 0, Ztring_Recursive);
+}
+
+//---------------------------------------------------------------------------
+Ztring MediaInfo_Internal::Xml_Name_Escape (const Ztring &Name)
+{
+ Ztring ToReturn(Name);
+
+ if (ToReturn.operator()(0)>='0' && ToReturn.operator()(0)<='9')
+ ToReturn.insert(0, 1, _T('_'));
+ ToReturn.FindAndReplace(_T(" "), _T("_"), 0, Ztring_Recursive);
+ ToReturn.FindAndReplace(_T("/"), _T("_"), 0, Ztring_Recursive);
+ ToReturn.FindAndReplace(_T("("), _T("_"), 0, Ztring_Recursive);
+ ToReturn.FindAndReplace(_T(")"), _T("_"), 0, Ztring_Recursive);
+ ToReturn.FindAndReplace(_T("*"), _T("_"), 0, Ztring_Recursive);
+ ToReturn.FindAndReplace(_T(","), _T("_"), 0, Ztring_Recursive);
+ ToReturn.FindAndReplace(_T(":"), _T("_"), 0, Ztring_Recursive);
+ ToReturn.FindAndReplace(_T("@"), _T("_"), 0, Ztring_Recursive);
+ size_t ToReturn_Pos=0;
+ while (ToReturn_Pos<ToReturn.size())
+ {
+ if (!(ToReturn[ToReturn_Pos]>=_T('A') && ToReturn[ToReturn_Pos]<=_T('Z'))
+ && !(ToReturn[ToReturn_Pos]>=_T('a') && ToReturn[ToReturn_Pos]<=_T('z'))
+ && !(ToReturn[ToReturn_Pos]>=_T('0') && ToReturn[ToReturn_Pos]<=_T('9'))
+ && !(ToReturn[ToReturn_Pos]==_T('_')))
+ ToReturn.erase(ToReturn_Pos, 1);
+ else
+ ToReturn_Pos++;
+ }
+ if (ToReturn.empty())
+ ToReturn="Unknown";
+
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+Ztring MediaInfo_Internal::Xml_Content_Escape (const Ztring &Content)
+{
+ Ztring ToReturn(Content);
+ return Xml_Content_Escape_Modifying(ToReturn);
+}
+
+//---------------------------------------------------------------------------
+size_t Xml_Content_Escape_MustEscape(const Ztring &Content)
+{
+ size_t Pos=0;
+ size_t Size=Content.size();
+ for (; Pos<Size; Pos++)
+ {
+ switch (Content[Pos])
+ {
+ case _T('\"'):
+ case _T('&') :
+ case _T('\''):
+ case _T('<') :
+ case _T('>') :
+ return Pos;
+ default :
+ if (Content[Pos]<0x20)
+ return Pos;
+ }
+ }
+
+ return Pos;
+}
+Ztring &MediaInfo_Internal::Xml_Content_Escape_Modifying (Ztring &Content)
+{
+ size_t Pos=Xml_Content_Escape_MustEscape(Content);
+ if (Pos>=Content.size())
+ return Content;
+
+ for (; Pos<Content.size(); Pos++)
+ {
+ switch (Content[Pos])
+ {
+ case _T('\"'):
+ Content[Pos]=_T('&');
+ Content.insert(Pos+1, _T("quot;"));
+ Pos+=5;
+ break;
+ case _T('&') :
+ Content[Pos]=_T('&');
+ Content.insert(Pos+1, _T("amp;"));
+ Pos+=4;
+ break;
+ case _T('\''):
+ Content[Pos]=_T('&');
+ Content.insert(Pos+1, _T("apos;"));
+ Pos+=5;
+ break;
+ case _T('<') :
+ Content[Pos]=_T('&');
+ Content.insert(Pos+1, _T("lt;"));
+ Pos+=3;
+ break;
+ case _T('>') :
+ Content[Pos]=_T('&');
+ Content.insert(Pos+1, _T("gt;"));
+ Pos+=3;
+ break;
+ default :
+ if (Content[Pos]<0x20)
+ {
+ Ztring Character=_T("#x")+Ztring::ToZtring(Content[Pos]/16, 16)+Ztring::ToZtring(Content[Pos]%16, 16)+_T(";");
+ Content[Pos]=_T('&');
+ Content.insert(Pos+1, Character);
+ Pos+=5;
+ }
+ }
+ }
+
+ return Content;
+}
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal.cpp b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal.cpp
new file mode 100644
index 000000000..fca93516a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal.cpp
@@ -0,0 +1,1122 @@
+// MediaInfo_Internal - All info about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/File__MultipleParsing.h"
+#include "ZenLib/Dir.h"
+#include "ZenLib/File.h"
+#if defined(MEDIAINFO_DIRECTORY_YES)
+ #include "MediaInfo/Reader/Reader_Directory.h"
+#endif
+#if defined(MEDIAINFO_FILE_YES)
+ #include "MediaInfo/Reader/Reader_File.h"
+#endif
+#if defined(MEDIAINFO_LIBCURL_YES)
+ #include "MediaInfo/Reader/Reader_libcurl.h"
+#endif
+#if defined(MEDIAINFO_LIBMMS_YES)
+ #include "MediaInfo/Reader/Reader_libmms.h"
+#endif
+#include <cmath>
+#ifdef MEDIAINFO_DEBUG_WARNING_GET
+ #include <iostream>
+#endif //MEDIAINFO_DEBUG_WARNING_GET
+#ifdef MEDIAINFO_DEBUG_BUFFER
+ #include "ZenLib/FileName.h"
+ #include <cstring>
+#endif //MEDIAINFO_DEBUG_BUFFER
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+//To clarify the code
+namespace MediaInfo_Debug_MediaInfo_Internal
+{
+
+#if defined (MEDIAINFO_DEBUG_CONFIG) || defined (MEDIAINFO_DEBUG_BUFFER) || defined (MEDIAINFO_DEBUG_OUTPUT)
+ #ifdef WINDOWS
+ const Char* MediaInfo_Debug_Name=_T("MediaInfo_Debug");
+ #else
+ const Char* MediaInfo_Debug_Name=_T("/tmp/MediaInfo_Debug");
+ #endif
+#endif
+
+#ifdef MEDIAINFO_DEBUG_CONFIG
+ #define MEDIAINFO_DEBUG_CONFIG_TEXT(_TOAPPEND) \
+ { \
+ Ztring Debug; \
+ _TOAPPEND; \
+ Debug+=_T("\r\n"); \
+ if (!Debug_Config.Opened_Get()) \
+ { \
+ if (File_Names.empty()) \
+ Debug_Config.Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".Config.txt")); \
+ else \
+ { \
+ Ztring File_Temp; \
+ if (File_Names[0].rfind(_T('\\'))!=string::npos) \
+ File_Temp=File_Names[0].substr(File_Names[0].rfind(_T('\\'))+1, string::npos); \
+ else if (File_Names[0].rfind(_T('/'))!=string::npos) \
+ File_Temp=File_Names[0].substr(File_Names[0].rfind(_T('/'))+1, string::npos); \
+ else \
+ File_Temp=File_Names[0]; \
+ Debug_Config.Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".")+File_Temp+_T(".Config.txt")); \
+ } \
+ } \
+ Debug_Config.Write(Debug); \
+ }
+#else // MEDIAINFO_DEBUG_CONFIG
+ #define MEDIAINFO_DEBUG_CONFIG_TEXT(_TOAPPEND)
+#endif // MEDIAINFO_DEBUG_CONFIG
+
+#ifdef MEDIAINFO_DEBUG_CONFIG
+ #define EXECUTE_SIZE_T(_METHOD,_DEBUGB) \
+ { \
+ size_t ToReturn=_METHOD; \
+ MEDIAINFO_DEBUG_CONFIG_TEXT(_DEBUGB) \
+ return ToReturn; \
+ }
+#else //MEDIAINFO_DEBUG_CONFIG
+ #define EXECUTE_SIZE_T(_METHOD, _DEBUGB) \
+ return _METHOD;
+#endif //MEDIAINFO_DEBUG_CONFIG
+
+#ifdef MEDIAINFO_DEBUG_CONFIG
+ #define EXECUTE_INT64U(_METHOD,_DEBUGB) \
+ { \
+ int64u ToReturn=_METHOD; \
+ MEDIAINFO_DEBUG_CONFIG_TEXT(_DEBUGB) \
+ return ToReturn; \
+ }
+#else //MEDIAINFO_DEBUG_CONFIG
+ #define EXECUTE_INT64U(_METHOD, _DEBUGB) \
+ return _METHOD;
+#endif //MEDIAINFO_DEBUG_CONFIG
+
+#ifdef MEDIAINFO_DEBUG_CONFIG
+ #define EXECUTE_STRING(_METHOD,_DEBUGB) \
+ { \
+ Ztring ToReturn=_METHOD; \
+ MEDIAINFO_DEBUG_CONFIG_TEXT(_DEBUGB) \
+ return ToReturn; \
+ }
+#else //MEDIAINFO_DEBUG_CONFIG
+ #define EXECUTE_STRING(_METHOD,_DEBUGB) \
+ return _METHOD;
+#endif //MEDIAINFO_DEBUG_CONFIG
+
+#ifdef MEDIAINFO_DEBUG_BUFFER
+ #define MEDIAINFO_DEBUG_BUFFER_SAVE(_BUFFER, _SIZE) \
+ { \
+ if (!Debug_Buffer_Stream.Opened_Get()) \
+ { \
+ if (File_Names.empty()) \
+ Debug_Buffer_Stream.Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".Buffer.Stream.0000000000000000")); \
+ else \
+ { \
+ Ztring File_Temp; \
+ if (File_Names[0].rfind(_T('\\'))!=string::npos) \
+ File_Temp=File_Names[0].substr(File_Names[0].rfind(_T('\\'))+1, string::npos); \
+ else if (File_Names[0].rfind(_T('/'))!=string::npos) \
+ File_Temp=File_Names[0].substr(File_Names[0].rfind(_T('/'))+1, string::npos); \
+ else \
+ File_Temp=File_Names[0]; \
+ Debug_Buffer_Stream.Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".")+File_Temp+_T(".Buffer.Stream.0000000000000000")); \
+ } \
+ Debug_Buffer_Stream_Order=0; \
+ if (File_Names.empty()) \
+ Debug_Buffer_Sizes.Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".Buffer.Sizes.0000000000000000")); \
+ else \
+ { \
+ Ztring File_Temp; \
+ if (File_Names[0].rfind(_T('\\'))!=string::npos) \
+ File_Temp=File_Names[0].substr(File_Names[0].rfind(_T('\\'))+1, string::npos); \
+ else if (File_Names[0].rfind(_T('/'))!=string::npos) \
+ File_Temp=File_Names[0].substr(File_Names[0].rfind(_T('/'))+1, string::npos); \
+ else \
+ File_Temp=File_Names[0]; \
+ Debug_Buffer_Sizes.Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".")+File_Temp+_T(".Buffer.Sizes.0000000000000000")); \
+ } \
+ Debug_Buffer_Sizes_Count=0; \
+ } \
+ Debug_Buffer_Stream.Write(_BUFFER, _SIZE); \
+ Debug_Buffer_Sizes.Write((int8u*)&_SIZE, sizeof(size_t)); \
+ Debug_Buffer_Sizes_Count+=_SIZE; \
+ if (Debug_Buffer_Sizes_Count>=MEDIAINFO_DEBUG_BUFFER_SAVE_FileSize) \
+ { \
+ Debug_Buffer_Stream.Close(); \
+ Debug_Buffer_Sizes.Close(); \
+ Ztring Before=Ztring::ToZtring(Debug_Buffer_Stream_Order-1); \
+ while (Before.size()<16) \
+ Before.insert(0, 1, _T('0')); \
+ Ztring Next=Ztring::ToZtring(Debug_Buffer_Stream_Order+1); \
+ while (Next.size()<16) \
+ Next.insert(0, 1, _T('0')); \
+ Debug_Buffer_Stream.Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".Buffer.Stream.")+Next); \
+ Debug_Buffer_Sizes.Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".Buffer.Sizes.")+Next); \
+ File::Delete(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".Buffer.Stream.")+Before); \
+ File::Delete(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".Buffer.Sizes.")+Before); \
+ Debug_Buffer_Stream_Order++; \
+ Debug_Buffer_Sizes_Count=0; \
+ } \
+ }
+#else // MEDIAINFO_DEBUG_BUFFER
+ #define MEDIAINFO_DEBUG_BUFFER_SAVE(_BUFFER, _SIZE)
+#endif // MEDIAINFO_DEBUG_BUFFER
+
+#ifdef MEDIAINFO_DEBUG_OUTPUT
+ #define MEDIAINFO_DEBUG_OUTPUT_INIT(_VALUE, _DEBUGB) \
+ { \
+ if (OptionLower==_T("file_duplicate")) \
+ { \
+ size_t Pos=(size_t)ToReturn2.To_int64u(); \
+ if (Pos>=Debug_Output_Pos_Stream.size()) \
+ { \
+ Debug_Output_Pos_Stream.resize(Pos+1); \
+ Debug_Output_Pos_Stream[Pos]=new File(); \
+ Debug_Output_Pos_Sizes.resize(Pos+1); \
+ Debug_Output_Pos_Sizes[Pos]=new File(); \
+ Debug_Output_Pos_Pointer.resize(Pos+1); \
+ Debug_Output_Pos_Pointer[Pos]=(void*)Ztring(Value).SubString(_T("memory://"), _T(":")).To_int64u(); \
+ } \
+ } \
+ EXECUTE_STRING(_VALUE, _DEBUGB) \
+ }
+#else // MEDIAINFO_DEBUG_OUTPUT
+ #define MEDIAINFO_DEBUG_OUTPUT_INIT(_VALUE, _DEBUGB) \
+ EXECUTE_STRING(_VALUE, _DEBUGB)
+#endif // MEDIAINFO_DEBUG_OUTPUT
+
+#ifdef MEDIAINFO_DEBUG_OUTPUT
+ #define MEDIAINFO_DEBUG_OUTPUT_VALUE(_VALUE, _METHOD) \
+ { \
+ size_t ByteCount=Info->Output_Buffer_Get(Value); \
+ void* ValueH=(void*)Ztring(Value).SubString(_T("memory://"), _T(":")).To_int64u(); \
+ map<void*, File>::iterator F_Stream=Debug_Output_Value_Stream.find(ValueH); \
+ if (F_Stream!=Debug_Output_Value_Stream.end()) \
+ { \
+ map<void*, File>::iterator F_Sizes=Debug_Output_Value_Stream.find(ValueH); \
+ if (!F_Stream->second.Opened_Get()) \
+ { \
+ F_Stream->second.Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".Output.")+Ztring::ToZtring((size_t)ValueH, 16)+_T(".Stream")); \
+ F_Sizes->second.Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".Output.")+Ztring::ToZtring((size_t)ValueH, 16)+_T(".Sizes")); \
+ } \
+ F_Stream->second.Write((int8u*)ValueH, ByteCount); \
+ F_Sizes->second.Write((int8u*)&ByteCount, sizeof(ByteCount)); \
+ } \
+ return ByteCount; \
+ }
+#else // MEDIAINFO_DEBUG_OUTPUT
+ #define MEDIAINFO_DEBUG_OUTPUT_VALUE(_VALUE, _METHOD) \
+ return _METHOD
+#endif // MEDIAINFO_DEBUG_OUTPUT
+
+#ifdef MEDIAINFO_DEBUG_OUTPUT
+ #define MEDIAINFO_DEBUG_OUTPUT_POS(_POS, _METHOD) \
+ { \
+ size_t ByteCount=Info->Output_Buffer_Get(_POS); \
+ if (_POS<Debug_Output_Pos_Stream.size()) \
+ { \
+ if (!Debug_Output_Pos_Stream[_POS]->Opened_Get()) \
+ { \
+ Debug_Output_Pos_Stream[_POS]->Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".Output.")+Ztring::ToZtring(Pos, 16)+_T(".Stream")); \
+ Debug_Output_Pos_Sizes[_POS]->Create(Ztring(MediaInfo_Debug_Name)+_T(".")+Ztring::ToZtring((size_t)this, 16)+_T(".Output.")+Ztring::ToZtring(Pos, 16)+_T(".Sizes")); \
+ } \
+ Debug_Output_Pos_Stream[_POS]->Write((int8u*)Debug_Output_Pos_Pointer[_POS], ByteCount); \
+ Debug_Output_Pos_Sizes[_POS]->Write((int8u*)&ByteCount, sizeof(ByteCount)); \
+ } \
+ return ByteCount; \
+ }
+#else // MEDIAINFO_DEBUG_OUTPUT
+ #define MEDIAINFO_DEBUG_OUTPUT_POS(_VALUE, _METHOD) \
+ return _METHOD
+#endif // MEDIAINFO_DEBUG_OUTPUT
+
+}
+using namespace MediaInfo_Debug_MediaInfo_Internal;
+
+//***************************************************************************
+// Constructor/destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+MediaInfo_Internal::MediaInfo_Internal()
+: Thread()
+{
+ CriticalSectionLocker CSL(CS);
+
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Construction");)
+
+ MediaInfoLib::Config.Init(); //Initialize Configuration
+
+ BlockMethod=BlockMethod_Local;
+ Info=NULL;
+ #if !defined(MEDIAINFO_READER_NO)
+ Reader=NULL;
+ #endif //!defined(MEDIAINFO_READER_NO)
+ Info_IsMultipleParsing=false;
+
+ Stream.resize(Stream_Max);
+ Stream_More.resize(Stream_Max);
+
+ //Position in a MediaInfoList class
+ IsFirst=true;
+ IsLast=true;
+
+ //Threading
+ BlockMethod=0;
+ IsInThread=false;
+}
+
+//---------------------------------------------------------------------------
+MediaInfo_Internal::~MediaInfo_Internal()
+{
+ Close();
+
+ CriticalSectionLocker CSL(CS);
+
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Destruction");)
+
+ delete Info; //Info=NULL;
+ #if !defined(MEDIAINFO_READER_NO)
+ delete Reader; //Reader=NULL;
+ #endif //!defined(MEDIAINFO_READER_NO)
+ #ifdef MEDIAINFO_DEBUG_OUTPUT
+ for (size_t Pos=0; Pos<Debug_Output_Pos_Stream.size(); Pos++)
+ {
+ delete Debug_Output_Pos_Stream[Pos]; //Debug_Output_Pos_Stream[Pos]=NULL;
+ delete Debug_Output_Pos_Sizes[Pos]; //Debug_Output_Pos_Sizes[Pos]=NULL;
+ }
+ #endif //MEDIAINFO_DEBUG_OUTPUT
+}
+
+//***************************************************************************
+// Files
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t MediaInfo_Internal::Open(const String &File_Name_)
+{
+ Close();
+
+ CS.Enter();
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Open, File=");Debug+=Ztring(File_Name_).c_str();)
+ Config.File_Names.clear();
+ if (Config.File_FileNameFormat_Get()==_T("CSV"))
+ {
+ Config.File_Names.Separator_Set(0, _T(","));
+ Config.File_Names.Write(File_Name_);
+ }
+ else if (!File_Name_.empty())
+ Config.File_Names.push_back(File_Name_);
+ if (Config.File_Names.empty())
+ {
+ CS.Leave();
+ return 0;
+ }
+ Config.File_Names_Pos=1;
+ CS.Leave();
+
+ //Parsing
+ if (BlockMethod==1)
+ {
+ if (!IsInThread) //If already created, the routine will read the new files
+ {
+ Run();
+ IsInThread=true;
+ }
+ return 0;
+ }
+ else
+ {
+ Entry(); //Normal parsing
+ return Count_Get(Stream_General);
+ }
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Internal::Entry()
+{
+ CS.Enter();
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Entry");)
+ Config.State_Set(0);
+ CS.Leave();
+
+ if ((Config.File_Names[0].size()>=6
+ && Config.File_Names[0][0]==_T('m')
+ && Config.File_Names[0][1]==_T('m')
+ && Config.File_Names[0][2]==_T('s')
+ && Config.File_Names[0][3]==_T(':')
+ && Config.File_Names[0][4]==_T('/')
+ && Config.File_Names[0][5]==_T('/'))
+ || (Config.File_Names[0].size()>=7
+ && Config.File_Names[0][0]==_T('m')
+ && Config.File_Names[0][1]==_T('m')
+ && Config.File_Names[0][2]==_T('s')
+ && Config.File_Names[0][3]==_T('h')
+ && Config.File_Names[0][4]==_T(':')
+ && Config.File_Names[0][5]==_T('/')
+ && Config.File_Names[0][6]==_T('/')))
+ #if defined(MEDIAINFO_LIBMMS_YES)
+ Reader_libmms().Format_Test(this, Config.File_Names[0]);
+ #else //MEDIAINFO_LIBMMS_YES
+ {
+ #if MEDIAINFO_EVENTS
+ struct MediaInfo_Event_Log_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_Log, 0);
+ Event.Type=0xC0;
+ Event.Severity=0xFF;
+ Event.MessageCode=0;
+ Event.MessageStringU=L"Libmms cupport is disabled due to compilation options";
+ Event.MessageStringA="Libmms cupport is disabled due to compilation options";
+ MediaInfoLib::Config.Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_Log_0));
+ #endif //MEDIAINFO_EVENTS
+ }
+ #endif //MEDIAINFO_LIBMMS_YES
+
+ else if (Config.File_Names[0].find(_T("://"))!=string::npos)
+ #if defined(MEDIAINFO_LIBCURL_YES)
+ {
+ CS.Enter();
+ if (Reader)
+ {
+ CS.Leave();
+ return; //There is a problem
+ }
+ Reader=new Reader_libcurl();
+ CS.Leave();
+
+ Reader->Format_Test(this, Config.File_Names[0]);
+
+ #if MEDIAINFO_NEXTPACKET
+ if (Config.NextPacket_Get())
+ return;
+ #endif //MEDIAINFO_NEXTPACKET
+ }
+ #else //MEDIAINFO_LIBCURL_YES
+ {
+ #if MEDIAINFO_EVENTS
+ struct MediaInfo_Event_Log_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_Log, 0);
+ Event.Type=0xC0;
+ Event.Severity=0xFF;
+ Event.MessageCode=0;
+ Event.MessageStringU=L"Libcurl support is disabled due to compilation options";
+ Event.MessageStringA="Libcurl support is disabled due to compilation options";
+ MediaInfoLib::Config.Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_Log_0));
+ #endif //MEDIAINFO_EVENTS
+ }
+ #endif //MEDIAINFO_LIBCURL_YES
+
+ #if defined(MEDIAINFO_DIRECTORY_YES)
+ else if (Dir::Exists(Config.File_Names[0]))
+ Reader_Directory().Format_Test(this, Config.File_Names[0]);
+ #endif //MEDIAINFO_DIRECTORY_YES
+
+ #if defined(MEDIAINFO_FILE_YES)
+ else if (File::Exists(Config.File_Names[0]))
+ {
+ CS.Enter();
+ if (Reader)
+ {
+ CS.Leave();
+ return; //There is a problem
+ }
+ Reader=new Reader_File();
+ CS.Leave();
+
+ Reader->Format_Test(this, Config.File_Names[0]);
+
+ #if MEDIAINFO_NEXTPACKET
+ if (Config.NextPacket_Get())
+ return;
+ #endif //MEDIAINFO_NEXTPACKET
+ }
+ #endif //MEDIAINFO_FILE_YES
+
+ CS.Enter();
+ Config.State_Set(1);
+ CS.Leave();
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo_Internal::Open (const int8u* Begin, size_t Begin_Size, const int8u* End, size_t End_Size, int64u File_Size)
+{
+ Open_Buffer_Init(File_Size);
+ Open_Buffer_Continue(Begin, Begin_Size);
+ if (End && Begin_Size+End_Size<=File_Size)
+ {
+ Open_Buffer_Init(File_Size, File_Size-End_Size);
+ Open_Buffer_Continue(End, End_Size);
+ }
+ Open_Buffer_Finalize();
+
+ return 1;
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo_Internal::Open_Buffer_Init (int64u File_Size_, const String &File_Name)
+{
+ CriticalSectionLocker CSL(CS);
+ if (Info==NULL)
+ {
+ if (!Config.File_ForceParser_Get().empty())
+ {
+ CS.Leave();
+ SelectFromExtension(Config.File_ForceParser_Get());
+ CS.Enter();
+ }
+ else
+ {
+ Info=new File__MultipleParsing;
+ Info_IsMultipleParsing=true;
+ }
+ }
+ #if MEDIAINFO_TRACE
+ Info->Init(&Config, &Details, &Stream, &Stream_More);
+ #else //MEDIAINFO_TRACE
+ Info->Init(&Config, &Stream, &Stream_More);
+ #endif //MEDIAINFO_TRACE
+ if (!File_Name.empty())
+ Info->File_Name=File_Name;
+ Info->Open_Buffer_Init(File_Size_);
+
+ return 1;
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo_Internal::Open_Buffer_Init (int64u File_Size_, int64u File_Offset_)
+{
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Open_Buffer_Init, File_Size=");Debug+=Ztring::ToZtring(File_Size_);Debug+=_T(", File_Offset=");Debug+=Ztring::ToZtring(File_Offset_);)
+ #ifdef MEDIAINFO_DEBUG_BUFFER
+ if (Info && File_Offset_>Info->File_Offset)
+ {
+ size_t Temp_Size=(size_t)(File_Offset_-Info->File_Offset);
+ int8u* Temp=new int8u[Temp_Size];
+ std::memset(Temp, 0xCC, Temp_Size);
+ MEDIAINFO_DEBUG_BUFFER_SAVE(Temp, Temp_Size);
+ delete[] Temp;
+ }
+ #endif //MEDIAINFO_DEBUG_BUFFER
+
+ if (Info==NULL || File_Size_!=(int64u)-1)
+ Open_Buffer_Init(File_Size_);
+
+ if (File_Offset_!=(int64u)-1 && Info)
+ {
+ CriticalSectionLocker CSL(CS);
+ Info->Open_Buffer_Position_Set(File_Offset_);
+ }
+
+ #if MEDIAINFO_EVENTS
+ if (Info && Info->Status[File__Analyze::IsAccepted])
+ {
+ struct MediaInfo_Event_General_Move_Done_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_Move_Done, 0);
+ Event.Stream_Offset=File_Offset_;
+ Config.Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_General_Move_Done_0));
+ }
+ else
+ {
+ struct MediaInfo_Event_General_Start_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_Start, 0);
+ Event.Stream_Size=File_Size_;
+ Config.Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_General_Start_0));
+ }
+ #endif //MEDIAINFO_EVENTS
+
+ EXECUTE_SIZE_T(1, Debug+=_T("Open_Buffer_Init, will return 1");)
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Internal::Open_Buffer_Unsynch ()
+{
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Open_Buffer_Unsynch");)
+
+ if (Info==NULL)
+ return;
+
+ CriticalSectionLocker CSL(CS);
+ Info->Open_Buffer_Unsynch();
+}
+
+//---------------------------------------------------------------------------
+std::bitset<32> MediaInfo_Internal::Open_Buffer_Continue (const int8u* ToAdd, size_t ToAdd_Size)
+{
+ CriticalSectionLocker CSL(CS);
+ MEDIAINFO_DEBUG_BUFFER_SAVE(ToAdd, ToAdd_Size);
+ if (Info==NULL)
+ return 0;
+
+ Info->Open_Buffer_Continue(ToAdd, ToAdd_Size);
+
+ if (Info_IsMultipleParsing && Info->Status[File__Analyze::IsAccepted])
+ {
+ //Found
+ File__Analyze* Info_ToDelete=Info;
+ Info=((File__MultipleParsing*)Info)->Parser_Get();
+ delete Info_ToDelete; //Info_ToDelete=NULL;
+ Info_IsMultipleParsing=false;
+ }
+
+ #if 0 //temp, for old users
+ //The parser wanted seek but the buffer is not seekable
+ if (Info->File_GoTo!=(int64u)-1 && Config.File_IsSeekable_Get()==0)
+ {
+ Info->Open_Buffer_Finalize(true);
+ Info->File_GoTo=(int64u)-1;
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Open_Buffer_Continue, will return 0");)
+ return 0;
+ }
+
+ return 1;
+ #else
+ //The parser wanted seek but the buffer is not seekable
+ if (Info->File_GoTo!=(int64u)-1 && Config.File_IsSeekable_Get()==0)
+ {
+ Info->Fill();
+ Info->File_GoTo=(int64u)-1;
+ }
+
+ return Info->Status;
+ #endif
+}
+
+//---------------------------------------------------------------------------
+int64u MediaInfo_Internal::Open_Buffer_Continue_GoTo_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ if (Info==NULL)
+ return (int64u)-1;
+
+ if (Info->File_GoTo==(int64u)-1
+ || (Info->File_GoTo>=Info->File_Offset && Info->File_GoTo<Info->File_Offset+0x10000)) //If jump is tiny, this is not worth the performance cost due to seek
+ return (int64u)-1;
+ else
+ return Info->File_GoTo;
+}
+
+//---------------------------------------------------------------------------
+bool MediaInfo_Internal::Open_Buffer_Position_Set(int64u File_Offset)
+{
+ CriticalSectionLocker CSL(CS);
+ if (Info==NULL)
+ return false;
+
+ Info->Open_Buffer_Position_Set(File_Offset);
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t MediaInfo_Internal::Open_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ CriticalSectionLocker CSL(CS);
+ if (Info==NULL)
+ return false;
+
+ return Info->Open_Buffer_Seek(Method, Value, ID);
+}
+#endif //MEDIAINFO_SEEK
+
+//---------------------------------------------------------------------------
+size_t MediaInfo_Internal::Open_Buffer_Finalize ()
+{
+ CS.Enter();
+ if (Info && Info->Status[File__Analyze::IsUpdated])
+ {
+ Info->Open_Buffer_Update();
+ Info->Status[File__Analyze::IsUpdated]=false;
+ for (size_t Pos=File__Analyze::User_16; Pos<File__Analyze::User_16+16; Pos++)
+ Info->Status[Pos]=false;
+ }
+ CS.Leave();
+
+ CriticalSectionLocker CSL(CS);
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Open_Buffer_Finalize");)
+ if (Info==NULL)
+ return 0;
+
+ Info->Open_Buffer_Finalize();
+ #if MEDIAINFO_DEMUX
+ if (Config.Demux_EventWasSent)
+ return 0;
+ #endif //MEDIAINFO_DEMUX
+
+ //Cleanup
+ if (!Config.File_IsSub_Get() && !Config.File_KeepInfo_Get()) //We need info for the calling parser
+ {
+ delete Info; Info=NULL;
+ }
+ if (Config.File_Names_Pos>=Config.File_Names.size())
+ {
+ delete[] Config.File_Buffer; Config.File_Buffer=NULL; Config.File_Buffer_Size=0; Config.File_Buffer_Size_Max=0;
+ }
+
+ EXECUTE_SIZE_T(1, Debug+=_T("Open_Buffer_Finalize, will return 1"))
+}
+
+//---------------------------------------------------------------------------
+std::bitset<32> MediaInfo_Internal::Open_NextPacket ()
+{
+ CriticalSectionLocker CSL(CS);
+
+ bool Demux_EventWasSent=false;
+ if (Info==NULL || !Info->Status[File__Analyze::IsFinished])
+ {
+ #if !defined(MEDIAINFO_READER_NO)
+ if (Reader)
+ {
+ CS.Leave();
+ Demux_EventWasSent=(Reader->Format_Test_PerParser_Continue(this)==2);
+ CS.Enter();
+ }
+ #endif //defined(MEDIAINFO_READER_NO)
+ }
+
+ std::bitset<32> ToReturn=Info==NULL?std::bitset<32>(0x0F):Info->Status;
+ if (Demux_EventWasSent)
+ ToReturn[8]=true; //bit 8 is for the reception of a frame
+
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+void MediaInfo_Internal::Close()
+{
+ if (IsRunning())
+ {
+ RequestTerminate();
+ while(IsExited())
+ Yield();
+ }
+
+ CriticalSectionLocker CSL(CS);
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Close");)
+ Stream.clear();
+ Stream.resize(Stream_Max);
+ Stream_More.clear();
+ Stream_More.resize(Stream_Max);
+ delete Info; Info=NULL;
+ #if !defined(MEDIAINFO_READER_NO)
+ delete Reader; Reader=NULL;
+ #endif //defined(MEDIAINFO_READER_NO)
+}
+
+//***************************************************************************
+// Get File info
+//***************************************************************************
+
+/*//---------------------------------------------------------------------------
+Ztring MediaInfo_Internal::Inform(size_t)
+{
+ //Info case
+ if (Info)
+ return Info->Inform();
+
+ if (!Info)
+ return MediaInfoLib::Config.EmptyString_Get();
+
+ return Info->Inform();
+} */
+
+//---------------------------------------------------------------------------
+Ztring MediaInfo_Internal::Get(stream_t StreamKind, size_t StreamPos, size_t Parameter, info_t KindOfInfo)
+{
+ CriticalSectionLocker CSL(CS);
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Get, StreamKind=");Debug+=Ztring::ToZtring((size_t)StreamKind);Debug+=_T(", StreamPos=");Debug+=Ztring::ToZtring(StreamPos);Debug+=_T(", Parameter=");Debug+=Ztring::ToZtring(Parameter);)
+
+ if (Info && Info->Status[File__Analyze::IsUpdated])
+ {
+ Info->Open_Buffer_Update();
+ Info->Status[File__Analyze::IsUpdated]=false;
+ for (size_t Pos=File__Analyze::User_16; Pos<File__Analyze::User_16+16; Pos++)
+ Info->Status[Pos]=false;
+ }
+
+ //Check integrity
+ if (StreamKind>=Stream_Max || StreamPos>=Stream[StreamKind].size() || Parameter>=MediaInfoLib::Config.Info_Get(StreamKind).size()+Stream_More[StreamKind][StreamPos].size() || KindOfInfo>=Info_Max)
+ return MediaInfoLib::Config.EmptyString_Get(); //Parameter is unknown
+
+ else if (Parameter<MediaInfoLib::Config.Info_Get(StreamKind).size())
+ {
+ //Optimization : KindOfInfo>Info_Text is in static lists
+ if (KindOfInfo!=Info_Text)
+ EXECUTE_STRING(MediaInfoLib::Config.Info_Get(StreamKind, Parameter, KindOfInfo), Debug+=_T("Get, will return ");Debug+=ToReturn;) //look for static information only
+ else if (Parameter<Stream[StreamKind][StreamPos].size())
+ EXECUTE_STRING(Stream[StreamKind][StreamPos][Parameter], Debug+=_T("Get, will return ");Debug+=ToReturn;)
+ else
+ EXECUTE_STRING(MediaInfoLib::Config.EmptyString_Get(), Debug+=_T("Get, will return ");Debug+=ToReturn;) //This parameter is known, but not filled
+ }
+ else
+ EXECUTE_STRING(Stream_More[StreamKind][StreamPos][Parameter-MediaInfoLib::Config.Info_Get(StreamKind).size()](KindOfInfo), Debug+=_T("Get, will return ");Debug+=ToReturn;)
+}
+
+//---------------------------------------------------------------------------
+Ztring MediaInfo_Internal::Get(stream_t StreamKind, size_t StreamPos, const String &Parameter, info_t KindOfInfo, info_t KindOfSearch)
+{
+ //Legacy
+ if (Parameter.find(_T("_String"))!=Error)
+ {
+ Ztring S1=Parameter;
+ S1.FindAndReplace(_T("_String"), _T("/String"));
+ return Get(StreamKind, StreamPos, S1, KindOfInfo, KindOfSearch);
+ }
+ if (Parameter==_T("Channels"))
+ return Get(StreamKind, StreamPos, _T("Channel(s)"), KindOfInfo, KindOfSearch);
+ if (Parameter==_T("Artist"))
+ return Get(StreamKind, StreamPos, _T("Performer"), KindOfInfo, KindOfSearch);
+ if (Parameter==_T("AspectRatio"))
+ return Get(StreamKind, StreamPos, _T("DisplayAspectRatio"), KindOfInfo, KindOfSearch);
+ if (Parameter==_T("AspectRatio/String"))
+ return Get(StreamKind, StreamPos, _T("DisplayAspectRatio/String"), KindOfInfo, KindOfSearch);
+ if (Parameter==_T("Chroma"))
+ return Get(StreamKind, StreamPos, _T("Colorimetry"), KindOfInfo, KindOfSearch);
+ if (Parameter==_T("PlayTime"))
+ return Get(StreamKind, StreamPos, _T("Duration"), KindOfInfo, KindOfSearch);
+ if (Parameter==_T("PlayTime/String"))
+ return Get(StreamKind, StreamPos, _T("Duration/String"), KindOfInfo, KindOfSearch);
+ if (Parameter==_T("PlayTime/String1"))
+ return Get(StreamKind, StreamPos, _T("Duration/String1"), KindOfInfo, KindOfSearch);
+ if (Parameter==_T("PlayTime/String2"))
+ return Get(StreamKind, StreamPos, _T("Duration/String2"), KindOfInfo, KindOfSearch);
+ if (Parameter==_T("PlayTime/String3"))
+ return Get(StreamKind, StreamPos, _T("Duration/String3"), KindOfInfo, KindOfSearch);
+ if (StreamKind==Stream_General && Parameter==_T("BitRate"))
+ return Get(Stream_General, StreamPos, _T("OverallBitRate"), KindOfInfo, KindOfSearch);
+ if (StreamKind==Stream_General && Parameter==_T("BitRate/String"))
+ return Get(Stream_General, StreamPos, _T("OverallBitRate/String"), KindOfInfo, KindOfSearch);
+ if (StreamKind==Stream_General && Parameter==_T("BitRate_Minimum"))
+ return Get(Stream_General, StreamPos, _T("OverallBitRate_Minimum"), KindOfInfo, KindOfSearch);
+ if (StreamKind==Stream_General && Parameter==_T("BitRate_Minimum/String"))
+ return Get(Stream_General, StreamPos, _T("OverallBitRate_Minimum/String"), KindOfInfo, KindOfSearch);
+ if (StreamKind==Stream_General && Parameter==_T("BitRate_Nominal"))
+ return Get(Stream_General, StreamPos, _T("OverallBitRate_Nominal"), KindOfInfo, KindOfSearch);
+ if (StreamKind==Stream_General && Parameter==_T("BitRate_Nominal/String"))
+ return Get(Stream_General, StreamPos, _T("OverallBitRate_Nominal/String"), KindOfInfo, KindOfSearch);
+ if (StreamKind==Stream_General && Parameter==_T("BitRate_Maximum"))
+ return Get(Stream_General, StreamPos, _T("OverallBitRate_Maximum"), KindOfInfo, KindOfSearch);
+ if (StreamKind==Stream_General && Parameter==_T("BitRate_Maximum/String"))
+ return Get(Stream_General, StreamPos, _T("OverallBitRate_Maximum/String"), KindOfInfo, KindOfSearch);
+ if (Parameter==_T("AFD"))
+ return Get(StreamKind, StreamPos, _T("ActiveFormatDescription"), KindOfInfo, KindOfSearch);
+
+ CS.Enter();
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Get, StreamKind=");Debug+=Ztring::ToZtring((size_t)StreamKind);Debug+=_T(", StreamKind=");Debug+=Ztring::ToZtring(StreamPos);Debug+=_T(", Parameter=");Debug+=Ztring(Parameter);)
+
+ if (Info && Info->Status[File__Analyze::IsUpdated])
+ {
+ Info->Open_Buffer_Update();
+ Info->Status[File__Analyze::IsUpdated]=false;
+ for (size_t Pos=File__Analyze::User_16; Pos<File__Analyze::User_16+16; Pos++)
+ Info->Status[Pos]=false;
+ }
+
+ //Check integrity
+ if (StreamKind>=Stream_Max || StreamPos>=Stream[StreamKind].size() || KindOfInfo>=Info_Max)
+ {
+ CS.Leave();
+ EXECUTE_STRING(MediaInfoLib::Config.EmptyString_Get(), Debug+=_T("Get, stream and/or pos is invalid will return empty string");) //Parameter is unknown
+ }
+
+ //Special cases
+ //-Inform for a stream
+ if (Parameter==_T("Inform"))
+ {
+ CS.Leave();
+ Ztring InformZtring=Inform(StreamKind, StreamPos, true);
+ CS.Enter();
+ size_t Pos=MediaInfoLib::Config.Info_Get(StreamKind).Find(_T("Inform"));
+ if (Pos!=Error)
+ Stream[StreamKind][StreamPos](Pos)=InformZtring;
+ }
+
+ //Case of specific info
+ size_t ParameterI=MediaInfoLib::Config.Info_Get(StreamKind).Find(Parameter, KindOfSearch);
+ if (ParameterI==Error)
+ {
+ ParameterI=Stream_More[StreamKind][StreamPos].Find(Parameter, KindOfSearch);
+ if (ParameterI==Error)
+ {
+ #ifdef MEDIAINFO_DEBUG_WARNING_GET
+ if (Ztring(Parameter)!=_T("SCTE35_PID")) //TODO: define a special interface for parser-specific parameters
+ std::cerr<<"MediaInfo: Warning, Get(), parameter \""<<Ztring(Parameter).To_Local()<<"\""<<std::endl;
+ #endif //MEDIAINFO_DEBUG_WARNING_GET
+
+ CS.Leave();
+ EXECUTE_STRING(MediaInfoLib::Config.EmptyString_Get(), Debug+=_T("Get, parameter is unknown, will return empty string");) //Parameter is unknown
+ }
+ CS.Leave();
+ CriticalSectionLocker CSL(CS);
+ return Stream_More[StreamKind][StreamPos][ParameterI](KindOfInfo);
+ }
+
+ CS.Leave();
+
+ EXECUTE_STRING(Get(StreamKind, StreamPos, ParameterI, KindOfInfo), Debug+=_T("Get, will return ");Debug+=ToReturn;)
+}
+
+//***************************************************************************
+// Set File info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t MediaInfo_Internal::Set(const String &ToSet, stream_t StreamKind, size_t StreamPos, size_t Parameter, const String &OldValue)
+{
+ CriticalSectionLocker CSL(CS);
+ if (!Info)
+ return 0;
+
+ return Info->Set(StreamKind, StreamPos, Parameter, ToSet, OldValue);
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo_Internal::Set(const String &ToSet, stream_t StreamKind, size_t StreamPos, const String &Parameter, const String &OldValue)
+{
+ CriticalSectionLocker CSL(CS);
+ if (!Info)
+ return 0;
+
+ return Info->Set(StreamKind, StreamPos, Parameter, ToSet, OldValue);
+}
+
+//***************************************************************************
+// Output buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t MediaInfo_Internal::Output_Buffer_Get (const String &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ if (!Info)
+ return 0;
+
+ MEDIAINFO_DEBUG_OUTPUT_VALUE(Value, Info->Output_Buffer_Get(Value));
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo_Internal::Output_Buffer_Get (size_t Pos)
+{
+ CriticalSectionLocker CSL(CS);
+ if (!Info)
+ return 0;
+
+ MEDIAINFO_DEBUG_OUTPUT_POS(Pos, Info->Output_Buffer_Get(Pos));
+}
+
+//***************************************************************************
+// Information
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+String MediaInfo_Internal::Option (const String &Option, const String &Value)
+{
+ CriticalSectionLocker CSL(CS);
+ MEDIAINFO_DEBUG_CONFIG_TEXT(Debug+=_T("Option, Option=");Debug+=Ztring(Option);Debug+=_T(", Value=");Debug+=Ztring(Value);)
+ Ztring OptionLower=Option; OptionLower.MakeLowerCase();
+ if (Option.empty())
+ return _T("");
+ else if (OptionLower==_T("language_update"))
+ {
+ if (!Info || Info->Get(Stream_General, 0, _T("CompleteName"))==_T(""))
+ return _T("");
+
+ ZtringListList Language=Value.c_str();
+ MediaInfoLib::Config.Language_Set(Language);
+
+ return _T("");
+ }
+ else if (OptionLower==_T("create_dummy"))
+ {
+ CreateDummy (Value);
+ delete Info; Info=NULL;
+ return _T("");
+ }
+ else if (OptionLower==_T("thread"))
+ {
+ BlockMethod=1;
+ return _T("");
+ }
+ else if (Option==_T("info_capacities"))
+ {
+ return _T("Option removed");
+ }
+ #if MEDIAINFO_TRACE
+ else if (OptionLower.find(_T("file_details_clear"))==0)
+ {
+ if (Info)
+ Info->Details_Clear();
+
+ return _T("");
+ }
+ #endif //MEDIAINFO_TRACE
+ else if (OptionLower.find(_T("file_seek"))==0)
+ {
+ #if MEDIAINFO_SEEK
+ if (Reader==NULL)
+ return _T("Error: Reader pointer is empty");
+
+ size_t Method=(size_t)-1;
+ int64u SeekValue=(int64u)-1;
+ int64u ID=(int64u)-1;
+
+ ZtringList List; List.Separator_Set(0, _T(","));
+ List.Write(Value);
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ if (!List[Pos].empty() && List[Pos].find(_T('%'))==List[Pos].size()-1)
+ {
+ Method=1;
+ SeekValue=(int64u)(Ztring(List[Pos]).To_float32()*100);
+ }
+ else if (!List[Pos].empty() && List[Pos].find_first_not_of(_T("0123456789"))==string::npos)
+ {
+ Method=0;
+ SeekValue=Ztring(List[Pos]).To_int64u();
+ }
+ else if (!List[Pos].empty() && List[Pos].find(_T("Frame="))!=string::npos)
+ {
+ Method=3;
+ Ztring FrameNumberZ=List[Pos].substr(List[Pos].find(_T("Frame="))+6, string::npos);
+ SeekValue=FrameNumberZ.To_int64u();
+ }
+ else if (!List[Pos].empty() && List[Pos].find(_T(":"))!=string::npos)
+ {
+ Method=2;
+ Ztring ValueZ=List[Pos];
+ SeekValue=0;
+ size_t Value_Pos=ValueZ.find(_T(":"));
+ if (Value_Pos==string::npos)
+ Value_Pos=ValueZ.size();
+ SeekValue+=Ztring(ValueZ.substr(0, Value_Pos)).To_int64u()*60*60*1000*1000*1000;
+ ValueZ.erase(0, Value_Pos+1);
+ Value_Pos=ValueZ.find(_T(":"));
+ if (Value_Pos==string::npos)
+ Value_Pos=ValueZ.size();
+ SeekValue+=Ztring(ValueZ.substr(0, Value_Pos)).To_int64u()*60*1000*1000*1000;
+ ValueZ.erase(0, Value_Pos+1);
+ Value_Pos=ValueZ.find(_T("."));
+ if (Value_Pos==string::npos)
+ Value_Pos=ValueZ.size();
+ SeekValue+=Ztring(ValueZ.substr(0, Value_Pos)).To_int64u()*1000*1000*1000;
+ ValueZ.erase(0, Value_Pos+1);
+ if (!ValueZ.empty())
+ SeekValue+=Ztring(ValueZ).To_int64u()*1000*1000*1000/(int64u)pow(10.0, (int)ValueZ.size());
+ }
+ else if (!List[Pos].empty() && List[Pos].find(_T("ID="))!=string::npos)
+ {
+ Ztring IDZ=List[Pos].substr(List[Pos].find(_T("ID="))+3, string::npos);
+ ID=IDZ.To_int64u();
+ }
+ }
+
+ CS.Leave();
+ size_t Result=Reader->Format_Test_PerParser_Seek(this, Method, SeekValue, ID);
+ CS.Enter();
+ switch (Result)
+ {
+ case 1 : return _T("");
+ case 2 : return _T("Invalid value");
+ #if MEDIAINFO_IBI
+ case 3 : return _T("Feature not supported / IBI file not provided");
+ case 4 : return _T("Problem during IBI file parsing");
+ #endif //MEDIAINFO_IBI
+ case 5 : return _T("Invalid ID");
+ case 6 : return _T("Internal error");
+ #if !MEDIAINFO_IBI
+ case (size_t)-2 : return _T("Feature not supported / IBI support disabled due to compilation options");
+ #endif //MEDIAINFO_IBI
+ case (size_t)-1 : return _T("Feature not supported");
+ default : return _T("Unknown error");
+ }
+ #else //MEDIAINFO_SEEK
+ return _T("Seek manager is disabled due to compilation options");
+ #endif //MEDIAINFO_SEEK
+ }
+ else if (OptionLower.find(_T("file_"))==0)
+ {
+ Ztring ToReturn2=Config.Option(Option, Value);
+ if (Info)
+ Info->Option_Manage();
+
+ MEDIAINFO_DEBUG_OUTPUT_INIT(ToReturn2, Debug+=_T("Option, will return ");Debug+=ToReturn;)
+ }
+ else
+ EXECUTE_STRING(MediaInfoLib::Config.Option(Option, Value), Debug+=_T("Option, will return ");Debug+=ToReturn;)
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo_Internal::Count_Get (stream_t StreamKind, size_t StreamPos)
+{
+ CriticalSectionLocker CSL(CS);
+
+ if (Info && Info->Status[File__Analyze::IsUpdated])
+ {
+ Info->Open_Buffer_Update();
+ Info->Status[File__Analyze::IsUpdated]=false;
+ for (size_t Pos=File__Analyze::User_16; Pos<File__Analyze::User_16+16; Pos++)
+ Info->Status[Pos]=false;
+ }
+
+ //Integrity
+ if (StreamKind>=Stream_Max)
+ return 0;
+
+ //Count of streams
+ if (StreamPos==Error)
+ return Stream[StreamKind].size();
+
+ //Integrity
+ if (StreamPos>=Stream[StreamKind].size())
+ return 0;
+
+ //Count of piece of information in a stream
+ return MediaInfoLib::Config.Info_Get(StreamKind).size()+Stream_More[StreamKind][StreamPos].size();
+}
+
+//---------------------------------------------------------------------------
+size_t MediaInfo_Internal::State_Get ()
+{
+ CriticalSectionLocker CSL(CS);
+ return (size_t)(Config.State_Get()*10000);
+}
+
+} //NameSpace
+
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal.h b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal.h
new file mode 100644
index 000000000..66fe88544
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal.h
@@ -0,0 +1,189 @@
+// MediaInfo_Internal - All information about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Give information about a lot of media files
+// Dispatch the file to be tested by all containers
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_InternalH
+#define MediaInfo_InternalH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+// For developer: you can disable or enable traces
+//#define MEDIAINFO_DEBUG_CONFIG
+//#define MEDIAINFO_DEBUG_BUFFER
+//#define MEDIAINFO_DEBUG_OUTPUT
+//#define MEDIAINFO_DEBUG_WARNING_GET
+// For developer: customization of traces
+#ifdef MEDIAINFO_DEBUG_BUFFER
+ const size_t MEDIAINFO_DEBUG_BUFFER_SAVE_FileSize=128*1024*1024;
+#endif //MEDIAINFO_DEBUG_BUFFER
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo_Internal_Const.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "ZenLib/Thread.h"
+#include "ZenLib/CriticalSection.h"
+#include <bitset>
+#if defined (MEDIAINFO_DEBUG_CONFIG) || defined (MEDIAINFO_DEBUG_BUFFER) || defined (MEDIAINFO_DEBUG_OUTPUT)
+ #include <ZenLib/File.h>
+ #include <map>
+#endif //MEDIAINFO_DEBUG
+using namespace std;
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class File__Analyze;
+class Internet__Base;
+class Reader__Base;
+
+//***************************************************************************
+/// @brief MediaInfo_Internal
+/// @version 0.7
+//***************************************************************************
+
+class MediaInfo_Internal : public ZenLib::Thread
+{
+public :
+ //Constructor/Destructor
+ MediaInfo_Internal ();
+ ~MediaInfo_Internal ();
+
+ //File
+ size_t Open (const String &File_Name);
+ size_t Open (const ZenLib::int8u* Begin, size_t Begin_Size, const ZenLib::int8u* End=NULL, size_t End_Size=0, ZenLib::int64u File_Size=0);
+ size_t Open_Buffer_Init (ZenLib::int64u File_Size=(ZenLib::int64u)-1, const String &File_Name=String());
+ size_t Open_Buffer_Init (ZenLib::int64u File_Size, ZenLib::int64u File_Offset);
+ std::bitset<32> Open_Buffer_Continue (const ZenLib::int8u* Buffer, size_t Buffer_Size);
+ ZenLib::int64u Open_Buffer_Continue_GoTo_Get ();
+ bool Open_Buffer_Position_Set(int64u File_Offset);
+ #if MEDIAINFO_SEEK
+ size_t Open_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+ void Open_Buffer_Unsynch ();
+ size_t Open_Buffer_Finalize ();
+ std::bitset<32> Open_NextPacket ();
+ void Close ();
+
+ //General information
+ Ztring Inform ();
+ Ztring Inform (stream_t StreamKind, size_t StreamNumber, bool IsDirect); //All about only a specific stream
+
+ //Get
+ Ztring Get (stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind=Info_Text);
+ Ztring Get (stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind=Info_Text, info_t SearchKind=Info_Name);
+
+ //Set
+ size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=_T(""));
+ size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=_T(""));
+
+ //Output_Buffered
+ size_t Output_Buffer_Get (const String &Value);
+ size_t Output_Buffer_Get (size_t Pos);
+
+ //Info
+ String Option (const String &Option, const String &Value=_T(""));
+ size_t State_Get ();
+ size_t Count_Get (stream_t StreamKind, size_t StreamNumber=(size_t)-1);
+
+ //Position in a MediaInfoList class
+ bool IsFirst;
+ bool IsLast;
+
+ //Internal
+ static bool LibraryIsModified(); //Is the library has been modified? (#defines...)
+
+private :
+ friend class File_Bdmv; //Theses classes need access to internal structure for optimization. There is recursivity with theses formats
+ friend class File_Cdxa; //Theses classes need access to internal structure for optimization. There is recursivity with theses formats
+ friend class File_Lxf; //Theses classes need access to internal structure for optimization. There is recursivity with theses formats
+ friend class File_Mpeg4; //Theses classes need access to internal structure for optimization. There is recursivity with theses formats
+ friend class File_MpegTs;//Theses classes need access to internal structure for optimization. There is recursivity with theses formats
+ friend class File_MpegPs;//Theses classes need access to internal structure for optimization. There is recursivity with theses formats
+ friend class File_Mxf; //Theses classes need access to internal structure for optimization. There is recursivity with theses formats
+ friend class File__ReferenceFilesHelper; //Theses classes need access to internal structure for optimization. There is recursivity with theses formats
+
+ //Parsing handles
+ File__Analyze* Info;
+ Internet__Base* Internet;
+ #if !defined(MEDIAINFO_READER_NO)
+ Reader__Base* Reader;
+ #endif //defined(MEDIAINFO_READER_NO)
+
+ //Helpers
+ void CreateDummy (const String& Value); //Create dummy Information
+ MediaInfo_Internal(const MediaInfo_Internal&); // Copy Constructor
+
+ //Open Buffer
+ bool Info_IsMultipleParsing;
+
+ //Config
+ std::vector<std::vector<ZtringList> > Stream;
+ std::vector<std::vector<ZtringListList> > Stream_More;
+ Ztring Details;
+ void Traiter(Ztring &C); //enleve les $if...
+
+public :
+ bool SelectFromExtension (const String &Parser); //Select File_* from the parser name
+ #if !defined(MEDIAINFO_READER_NO)
+ int ListFormats(const String &File_Name=String());
+ #else //!defined(MEDIAINFO_READER_NO)
+ int ListFormats(const String &File_Name=String()) {return 0;}
+ #endif //!defined(MEDIAINFO_READER_NO)
+ MediaInfo_Config_MediaInfo Config;
+
+ Ztring Xml_Name_Escape(const Ztring &Name);
+ Ztring Xml_Content_Escape(const Ztring &Content);
+ Ztring &Xml_Content_Escape_Modifying(Ztring &Content);
+
+private :
+ //Threading
+ size_t BlockMethod; //Open() return: 0=immedialtly, 1=after local info, 2=when user interaction is needed
+ bool IsInThread;
+ void Entry();
+ ZenLib::CriticalSection CS;
+
+ #ifdef MEDIAINFO_DEBUG_CONFIG
+ File Debug_Config;
+ #endif //MEDIAINFO_DEBUG_CONFIG
+ #ifdef MEDIAINFO_DEBUG_BUFFER
+ File Debug_Buffer_Stream;
+ int64u Debug_Buffer_Stream_Order;
+ File Debug_Buffer_Sizes;
+ int64u Debug_Buffer_Sizes_Count;
+ #endif //MEDIAINFO_DEBUG_BUFFER
+ #ifdef MEDIAINFO_DEBUG_OUTPUT
+ map<void*, File> Debug_Output_Value_Stream; //Key is the memory address
+ map<void*, File> Debug_Output_Value_Sizes; //Key is the memory address
+ vector<File*> Debug_Output_Pos_Stream; //Key is the pos
+ vector<File*> Debug_Output_Pos_Sizes; //Key is the pos
+ vector<void*> Debug_Output_Pos_Pointer; //Key is the pos
+ #endif //MEDIAINFO_DEBUG_OUTPUT
+};
+
+} //NameSpace
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal_Const.h b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal_Const.h
new file mode 100644
index 000000000..16fb98f70
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/MediaInfo_Internal_Const.h
@@ -0,0 +1,151 @@
+// MediaInfo_Config - Configuration class
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Global configuration of MediaInfo
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Internal_ConstH
+#define MediaInfo_Internal_ConstH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+#include "MediaInfo/MediaInfo_Const.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+/// @brief Used with Format info
+enum infoformat_t
+{
+ InfoFormat_Name, ///<
+ InfoFormat_LongName, ///<
+ InfoFormat_Family, ///<
+ InfoFormat_KindofFormat, ///<
+ InfoFormat_Parser, ///<
+ InfoFormat_Info, ///<
+ InfoFormat_Extensions, ///<
+ InfoFormat_InternetMediaType, ///<
+ InfoFormat_Url, ///<
+ InfoFormat_Compression_Mode, ///<
+ InfoFormat_Max
+};
+
+/// @brief Used with Codec ID info
+enum infocodecid_t
+{
+ InfoCodecID_Codec, ///<
+ InfoCodecID_Format, ///<
+ InfoCodecID_Hint, ///<
+ InfoCodecID_Description, ///<
+ InfoCodecID_Url, ///<
+ InfoCodecID_Profile, ///<
+ InfoCodecID_Version, ///<
+ InfoCodecID_ColorSpace, ///<
+ InfoCodecID_ChromaSubsampling, ///<
+ InfoCodecID_BitDepth, ///<
+ InfoCodecID_Compression_Mode, ///<
+ InfoCodecID_Max
+};
+
+/// @brief Used with Codec ID info (Format type part)
+enum infocodecid_format_t
+{
+ InfoCodecID_Format_Matroska, ///<
+ InfoCodecID_Format_Mpeg4, ///<
+ InfoCodecID_Format_Real, ///<
+ InfoCodecID_Format_Riff, ///<
+ InfoCodecID_Format_Max
+};
+
+/// @brief Used with Codec info
+enum infocodec_t
+{
+ InfoCodec_Codec, ///<
+ InfoCodec_Name, ///<
+ InfoCodec_KindOfCode, ///<
+ InfoCodec_KindOfStream, ///<
+ InfoCodec_KindofCodec, ///<
+ InfoCodec_BitRate_Mode, ///<
+ InfoCodec_Description, ///<
+ InfoCodec_Url, ///<
+ InfoCodec_Max
+};
+
+/// @brief Used with Encoder info
+enum infoencoder_t
+{
+ InfoEncoder_Name, ///<
+ InfoEncoder_LongName, ///<
+ InfoEncoder_Date, ///<
+ InfoEncoder_Max
+};
+
+/// @brief Used with Library info
+enum infolibrary_t
+{
+ InfoLibrary_Numlber, ///<
+ InfoLibrary_Version, ///<
+ InfoLibrary_Date, ///<
+ InfoLibrary_Max
+};
+
+/// @brief Used with Library info (Format type part)
+enum infolibrary_format_t
+{
+ InfoLibrary_Format_DivX, ///<
+ InfoLibrary_Format_XviD, ///<
+ InfoLibrary_Format_MainConcept_Avc, ///<
+ InfoLibrary_Format_VorbisCom, ///<
+ InfoLibrary_Format_Max
+};
+
+/// @brief Used by BlockMethod
+enum blockmethod_t
+{
+ BlockMethod_Now, ///< Return now, without parsing (init only)
+ BlockMethod_Often, ///< Return as often as possible
+ BlockMethod_Local, ///< Return after local parsing (no Internet connection)
+ BlockMethod_Needed, ///< Return when a user interaction is needed
+ BlockMethod_Max
+};
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+//Char types
+#undef _T
+#define _T(__x) __T(__x)
+#if defined(UNICODE) || defined (_UNICODE)
+ typedef wchar_t Char;
+ #undef __T
+ #define __T(__x) L ## __x
+#else
+ typedef char Char;
+ #undef __T
+ #define __T(__x) __x
+#endif
+//---------------------------------------------------------------------------
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ancillary.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ancillary.cpp
new file mode 100644
index 000000000..497901379
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ancillary.cpp
@@ -0,0 +1,469 @@
+// File_Ancillary - Info for Ancillary (SMPTE ST291) streams
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_ANCILLARY_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Ancillary.h"
+#if defined(MEDIAINFO_CDP_YES)
+ #include "MediaInfo/Text/File_Cdp.h"
+#endif
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#include <cstring>
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+namespace MediaInfoLib
+{
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+const char* Ancillary_DataID(int8u DataID, int8u SecondaryDataID)
+{
+ if (DataID==0x00)
+ return "Undefined format";
+ else if (DataID<=0x03)
+ return "Reserved";
+ else if (DataID<=0x0F)
+ return "Reserved for 8-bit applications";
+ else if (DataID<=0x3F)
+ return "Reserved";
+ else if (DataID==0x41)
+ {
+ //SMPTE 2016-3-2007
+ switch (SecondaryDataID)
+ {
+ case 0x05 : return "Bar Data";
+ default : return "Internationally registered";
+ }
+ }
+ else if (DataID==0x45)
+ {
+ //SMPTE 2020-1-2008
+ switch (SecondaryDataID)
+ {
+ case 0x01 : return "Audio Metadata - No association";
+ case 0x02 : return "Audio Metadata - Channels 1/2";
+ case 0x03 : return "Audio Metadata - Channels 3/4";
+ case 0x04 : return "Audio Metadata - Channels 5/6";
+ case 0x05 : return "Audio Metadata - Channels 7/8";
+ case 0x06 : return "Audio Metadata - Channels 9/10";
+ case 0x07 : return "Audio Metadata - Channels 11/12";
+ case 0x08 : return "Audio Metadata - Channels 13/14";
+ case 0x09 : return "Audio Metadata - Channels 15/16";
+ default : return "SMPTE 2020-1-2008?";
+ }
+ }
+ else if (DataID<=0x4F)
+ return "Internationally registered";
+ else if (DataID<=0x5F)
+ return "Reserved";
+ else if (DataID==0x60)
+ return "Ancillary time code"; //RP188
+ else if (DataID==0x61)
+ {
+ switch (SecondaryDataID)
+ {
+ case 0x01 : return "CEA-708 (CDP)";
+ case 0x02 : return "CEA-608";
+ default : return "S334-1-2007 Defined data services?";
+ }
+ }
+ else if (DataID==0x62)
+ {
+ switch (SecondaryDataID)
+ {
+ case 0x01 : return "Program description";
+ case 0x02 : return "Data broadcast";
+ case 0x03 : return "VBI data";
+ default : return "S334-1-2007 Variable-format data services?";
+ }
+ }
+ else if (DataID<=0x7F)
+ return "Internationally registered";
+ else if (DataID==0x80)
+ return "Ancillary packet marked for deletion";
+ else if (DataID<=0x83)
+ return "Reserved";
+ else if (DataID==0x84)
+ return "Optional ancillary packet data end marker";
+ else if (DataID<=0x87)
+ return "Reserved";
+ else if (DataID==0x88)
+ return "Optional ancillary packet data start marker";
+ else if (DataID<=0x9F)
+ return "Reserved";
+ else if (DataID<=0xBF)
+ return "Internationally registered";
+ else if (DataID<=0xCF)
+ return "User application";
+ else if (DataID<=0xDF)
+ return "Internationally registered";
+ else
+ return "Internationally registered";
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Ancillary::File_Ancillary()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("Ancillary");
+
+ //In
+ WithTenBit=false;
+ WithChecksum=false;
+ HasBFrames=false;
+ InDecodingOrder=false;
+ AspectRatio=0;
+ FrameRate=0;
+
+ //Temp
+ Cdp_Parser=NULL;
+}
+
+//---------------------------------------------------------------------------
+File_Ancillary::~File_Ancillary()
+{
+ delete Cdp_Parser; //Cdp_Parser=NULL;
+ for (size_t Pos=0; Pos<Cdp_Data.size(); Pos++)
+ delete Cdp_Data[Pos]; //Cdp_Data[Pos]=NULL;
+ for (size_t Pos=0; Pos<AfdBarData_Data.size(); Pos++)
+ delete AfdBarData_Data[Pos]; //AfdBarData_Data[Pos]=NULL;
+}
+
+//---------------------------------------------------------------------------
+void File_Ancillary::Streams_Finish()
+{
+ #if defined(MEDIAINFO_CDP_YES)
+ if (Cdp_Parser && !Cdp_Parser->Status[IsFinished] && Cdp_Parser->Status[IsAccepted])
+ {
+ Finish(Cdp_Parser);
+ for (size_t StreamPos=0; StreamPos<Cdp_Parser->Count_Get(Stream_Text); StreamPos++)
+ {
+ Merge(*Cdp_Parser, Stream_Text, StreamPos, StreamPos);
+ Ztring MuxingMode=Cdp_Parser->Retrieve(Stream_Text, StreamPos, "MuxingMode");
+ Fill(Stream_Text, StreamPos, "MuxingMode", _T("Ancillary data / ")+MuxingMode, true);
+ }
+ }
+ #endif //defined(MEDIAINFO_CDP_YES)
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Ancillary::Synchronize()
+{
+ //Synchronizing
+ while (Buffer_Offset+6<=Buffer_Size && ( Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+ 1]!=0xFF
+ || Buffer[Buffer_Offset+ 2]!=0xFF))
+ Buffer_Offset++;
+
+ if (!Status[IsAccepted])
+ {
+ Accept();
+
+ Fill(Stream_General, 0, General_Format, "Ancillary");
+ }
+
+ //Synched is OK
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Ancillary::Synched_Test()
+{
+ Synchronize(); //This is not always in synch directly, there may be some garbage
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+6>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (CC3(Buffer+Buffer_Offset)!=0x00FFFF)
+ Synched=false;
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ancillary::Read_Buffer_Continue()
+{
+ if (!Cdp_Data.empty() && AspectRatio && FrameRate)
+ {
+ ((File_Cdp*)Cdp_Parser)->AspectRatio=AspectRatio;
+ for (size_t Pos=0; Pos<Cdp_Data.size(); Pos++)
+ {
+ if (Cdp_Parser->PTS_DTS_Needed)
+ Cdp_Parser->FrameInfo.DTS=FrameInfo.DTS-(Cdp_Data.size()-Pos)*FrameInfo.DUR;
+ Open_Buffer_Continue(Cdp_Parser, Cdp_Data[Pos]->Data, Cdp_Data[Pos]->Size);
+ delete Cdp_Data[Pos]; //Cdp_Data[0]=NULL;
+ }
+ Cdp_Data.clear();
+ }
+
+ if (Element_Size==0)
+ {
+ //Keeping only one, TODO: parse it without video stream
+ for (size_t Pos=1; Pos<AfdBarData_Data.size(); Pos++)
+ delete AfdBarData_Data[Pos]; //AfdBarData_Data[0]=NULL;
+ if (!AfdBarData_Data.empty())
+ AfdBarData_Data.resize(1);
+
+ return;
+ }
+
+ if (!Status[IsAccepted] && !MustSynchronize)
+ Accept();
+}
+
+//---------------------------------------------------------------------------
+void File_Ancillary::Read_Buffer_AfterParsing()
+{
+ Buffer_Offset=Buffer_Size; //This is per frame
+}
+
+//---------------------------------------------------------------------------
+void File_Ancillary::Read_Buffer_Unsynched()
+{
+ #if defined(MEDIAINFO_CDP_YES)
+ for (size_t Pos=0; Pos<Cdp_Data.size(); Pos++)
+ delete Cdp_Data[Pos]; //Cdp_Data[Pos]=NULL;
+ Cdp_Data.clear();
+ if (Cdp_Parser)
+ Cdp_Parser->Open_Buffer_Unsynch();
+ #endif //defined(MEDIAINFO_CDP_YES)
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ for (size_t Pos=0; Pos<AfdBarData_Data.size(); Pos++)
+ delete AfdBarData_Data[Pos]; //AfdBarData_Data[Pos]=NULL;
+ AfdBarData_Data.clear();
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+ AspectRatio=0;
+}
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ancillary::Header_Parse()
+{
+ //Parsing
+ if (MustSynchronize)
+ {
+ if (WithTenBit)
+ {
+ Skip_L2( "Ancillary data flag");
+ Skip_L2( "Ancillary data flag");
+ Skip_L2( "Ancillary data flag");
+ }
+ else
+ {
+ Skip_L1( "Ancillary data flag");
+ Skip_L1( "Ancillary data flag");
+ Skip_L1( "Ancillary data flag");
+ }
+ }
+ Get_L1 (DataID, "Data ID");
+ if (WithTenBit)
+ Skip_L1( "Parity+Unused"); //even:1, odd:2
+ Get_L1 (SecondaryDataID, "Secondary Data ID"); Param_Info1(Ancillary_DataID(DataID, SecondaryDataID));
+ if (WithTenBit)
+ Skip_L1( "Parity+Unused"); //even:1, odd:2
+ Get_L1 (DataCount, "Data count");
+ if (WithTenBit)
+ Skip_L1( "Parity+Unused"); //even:1, odd:2
+
+ //Test (in some container formats, Cheksum is present sometimes)
+ bool WithChecksum_Temp=WithChecksum;
+ if (!MustSynchronize && !WithChecksum && (size_t)((3+DataCount+1)*(WithTenBit?2:1))==Buffer_Size)
+ WithChecksum_Temp=true;
+
+ //Filling
+ Header_Fill_Code((((int16u)DataID)<<8)|SecondaryDataID, Ztring().From_CC1(DataID)+_T('-')+Ztring().From_CC1(SecondaryDataID));
+ Header_Fill_Size(((MustSynchronize?3:0)+3+DataCount+(WithChecksum_Temp?1:0))*(WithTenBit?2:1));
+}
+
+//---------------------------------------------------------------------------
+void File_Ancillary::Data_Parse()
+{
+ Element_Info1(Ancillary_DataID(DataID, SecondaryDataID));
+
+ //Buffer
+ int8u* Payload=new int8u[DataCount];
+ for(int8u Pos=0; Pos<DataCount; Pos++)
+ {
+ Get_L1 (Payload[Pos], "Data");
+ if (WithTenBit)
+ Skip_L1( "Parity+Unused"); //even:1, odd:2
+ }
+
+ //Parsing
+ if (WithChecksum)
+ Skip_L1( "Checksum");
+ if (WithTenBit)
+ Skip_L1( "Parity+Unused"); //even:1, odd:2
+
+ FILLING_BEGIN();
+ switch (DataID)
+ {
+ case 0x41 : // (from SMPTE 2016-3)
+ switch (SecondaryDataID)
+ {
+ case 0x05 : //Bar Data (from SMPTE 2016-3), saving data for future use
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ {
+ buffered_data* AfdBarData=new buffered_data;
+ AfdBarData->Data=new int8u[(size_t)DataCount];
+ std::memcpy(AfdBarData->Data, Payload, (size_t)DataCount);
+ AfdBarData->Size=(size_t)DataCount;
+ AfdBarData_Data.push_back(AfdBarData);
+ }
+ #endif //MEDIAINFO_AFDBARDATA_YES
+ break;
+ default : ;
+ ;
+ }
+ break;
+ case 0x45 : // (from SMPTE 2020-1)
+ switch (SecondaryDataID)
+ {
+ case 0x01 : //No association
+ case 0x02 : //Channel pair 1/2
+ case 0x03 : //Channel pair 3/4
+ case 0x04 : //Channel pair 5/6
+ case 0x05 : //Channel pair 7/8
+ case 0x06 : //Channel pair 9/10
+ case 0x07 : //Channel pair 11/12
+ case 0x08 : //Channel pair 13/14
+ case 0x09 : //Channel pair 15/16
+ break;
+ default : ;
+ ;
+ }
+ break;
+ case 0x61 : //Defined data services (from SMPTE 331-1)
+ switch (SecondaryDataID)
+ {
+ case 0x01 : //CDP (from SMPTE 331-1)
+ #if defined(MEDIAINFO_CDP_YES)
+ {
+ if (Cdp_Parser==NULL)
+ {
+ Cdp_Parser=new File_Cdp;
+ Open_Buffer_Init(Cdp_Parser);
+ }
+ Demux(Payload, (size_t)DataCount, ContentType_MainStream);
+ if (InDecodingOrder || (!HasBFrames && AspectRatio && FrameRate))
+ {
+ if (!Cdp_Parser->Status[IsFinished])
+ {
+ if (Cdp_Parser->PTS_DTS_Needed)
+ Cdp_Parser->FrameInfo.DTS=FrameInfo.DTS;
+ ((File_Cdp*)Cdp_Parser)->AspectRatio=AspectRatio;
+ Open_Buffer_Continue(Cdp_Parser, Payload, (size_t)DataCount);
+ }
+ }
+ else
+ {
+ //Saving data for future use
+ buffered_data* Cdp=new buffered_data;
+ Cdp->Data=new int8u[(size_t)DataCount];
+ std::memcpy(Cdp->Data, Payload, (size_t)DataCount);
+ Cdp->Size=(size_t)DataCount;
+ Cdp_Data.push_back(Cdp);
+ }
+ }
+ #endif //MEDIAINFO_CDP_YES
+ break;
+ case 0x02 : //CEA-608 (from SMPTE 331-1)
+ #if defined(MEDIAINFO_EIA608_YES)
+ if (DataCount==3) //This must be 3-byte data
+ {
+ //CEA-608 in video presentation order
+ }
+ #endif //MEDIAINFO_EIA608_YES
+ break;
+ default : ;
+ ;
+ }
+ break;
+ case 0x62 : //Variable-format data services (from SMPTE 331-1)
+ switch (SecondaryDataID)
+ {
+ case 0x01 : //Program description (from SMPTE 331-1),
+ break;
+ case 0x02 : //Data broadcast (from SMPTE 331-1)
+ break;
+ case 0x03 : //VBI data (from SMPTE 331-1)
+ break;
+ default : ;
+ ;
+ }
+ break;
+ default : ;
+ }
+
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ FILLING_END();
+
+ delete[] Payload; //Payload=NULL
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_ANCILLARY_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ancillary.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ancillary.h
new file mode 100644
index 000000000..a74047dc5
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ancillary.h
@@ -0,0 +1,107 @@
+// File_Ancillary - Info for Ancillary (SMPTE ST291) streams
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Ancillary data (SMPTE ST291)
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_AncillaryH
+#define MediaInfo_AncillaryH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Ancillary
+//***************************************************************************
+
+class File_Ancillary : public File__Analyze
+{
+public :
+ //In
+ bool WithTenBit;
+ bool WithChecksum;
+ bool HasBFrames;
+ bool InDecodingOrder;
+ float64 AspectRatio;
+ float64 FrameRate;
+
+ //In/Out
+ struct buffered_data
+ {
+ size_t Size;
+ int8u* Data;
+
+ buffered_data()
+ {
+ Size=0;
+ Data=NULL;
+ }
+
+ ~buffered_data()
+ {
+ delete[] Data; //Data=NULL;
+ }
+ };
+ #if defined(MEDIAINFO_CDP_YES)
+ std::vector<buffered_data*> Cdp_Data;
+ File__Analyze* Cdp_Parser;
+ #endif //defined(MEDIAINFO_CDP_YES)
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ std::vector<buffered_data*> AfdBarData_Data;
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+
+ //Constructor/Destructor
+ File_Ancillary();
+ ~File_Ancillary();
+
+private :
+ //Streams management
+ void Streams_Finish();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+
+ //Buffer - Global
+ void Read_Buffer_Continue();
+ void Read_Buffer_AfterParsing();
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Temp
+ int8u DataID;
+ int8u SecondaryDataID;
+ int8u DataCount;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Bdmv.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Bdmv.cpp
new file mode 100644
index 000000000..d5491ecfb
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Bdmv.cpp
@@ -0,0 +1,1624 @@
+// File_Mpls - Info for Blu-ray Movie files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_BDMV_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Bdmv.h"
+#include "MediaInfo/MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "ZenLib/Dir.h"
+#include "ZenLib/FileName.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// index (INDX) with title
+// --> MovieObject (MOBJ) with mobj
+// --> PlayList (MPLS)
+// --> PlayItem (MPLS) with Mark
+// --> ClipInfo (CLPI)
+// --> Clip (?) (CLPI)
+// --> Stream (M2TS)
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+namespace Elements
+{
+ const int32u CLPI=0x48444D56; //HDMV
+ const int32u INDX=0x494E4458;
+ const int32u MOBJ=0x4D4F424A;
+ const int32u MPLS=0x4D504C53;
+}
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Clpi_Offsets[]=
+{
+ "ClipInfo",
+ "SequenceInfo",
+ "ProgramInfo",
+ "CPI",
+ "ClipMark",
+ "ExtensionData",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+};
+
+//---------------------------------------------------------------------------
+const char* Indx_Offsets[]=
+{
+ "AppInfoBDMV",
+ "Indexes",
+ "ExtensionData",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+};
+
+//---------------------------------------------------------------------------
+const char* Mobj_Offsets[]=
+{
+ "MovieObjects",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpls_Offsets[]=
+{
+ "AppInfoPlayList",
+ "PlayList",
+ "PlayListMarks",
+ "ExtensionData",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+};
+
+//---------------------------------------------------------------------------
+const char* Bdmv_Type(int32u Type_Indicator, size_t Start_Adress_Pos)
+{
+ switch (Type_Indicator)
+ {
+ case Elements::CLPI : return Clpi_Offsets[Start_Adress_Pos];
+ case Elements::INDX : return Indx_Offsets[Start_Adress_Pos];
+ case Elements::MOBJ : return Mobj_Offsets[Start_Adress_Pos];
+ case Elements::MPLS : return Mpls_Offsets[Start_Adress_Pos];
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Clpi_Format(int8u StreamType)
+{
+ switch (StreamType)
+ {
+ case 0x01 : return "MPEG-1 Video";
+ case 0x02 : return "MPEG-2 Video";
+ case 0x03 : return "MPEG-1 Audio";
+ case 0x04 : return "MPEG-2 Audio";
+ case 0x1B : return "AVC";
+ case 0x20 : return "AVC";
+ case 0x80 : return "PCM";
+ case 0x81 : return "AC-3";
+ case 0x82 : return "DTS";
+ case 0x83 : return "TrueHD";
+ case 0x84 : return "E-AC-3";
+ case 0x85 : return "DTS";
+ case 0x86 : return "DTS";
+ case 0x90 : return "PGS";
+ case 0x91 : return "Interactive";
+ case 0x92 : return "Subtitle";
+ case 0xA1 : return "E-AC-3"; //Secondary
+ case 0xA2 : return "DTS"; //Secondary
+ case 0xEA : return "VC-1";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Clpi_Format_Profile(int8u StreamType)
+{
+ switch (StreamType)
+ {
+ case 0x85 : return "HD";
+ case 0x86 : return "MA";
+ case 0xA2 : return "HD"; //Secondary
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+stream_t Clpi_Type(int8u StreamType)
+{
+ switch (StreamType)
+ {
+ case 0x01 : return Stream_Video;
+ case 0x02 : return Stream_Video;
+ case 0x03 : return Stream_Audio;
+ case 0x04 : return Stream_Audio;
+ case 0x1B : return Stream_Video;
+ case 0x20 : return Stream_Video;
+ case 0x80 : return Stream_Audio;
+ case 0x81 : return Stream_Audio;
+ case 0x82 : return Stream_Audio;
+ case 0x83 : return Stream_Audio;
+ case 0x84 : return Stream_Audio;
+ case 0x85 : return Stream_Audio;
+ case 0x86 : return Stream_Audio;
+ case 0x90 : return Stream_Text;
+ case 0x91 : return Stream_Max;
+ case 0x92 : return Stream_Text;
+ case 0xA1 : return Stream_Audio;
+ case 0xA2 : return Stream_Audio;
+ case 0xEA : return Stream_Video;
+ default : return Stream_Max;
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Clpi_Video_Format[]=
+{
+ "",
+ "480i",
+ "576i",
+ "480p",
+ "1080i",
+ "720p",
+ "1080p",
+ "576p",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Clpi_Video_Interlacement[]=
+{
+ "",
+ "Interlaced",
+ "Interlaced",
+ "PPF",
+ "Interlaced",
+ "PPF",
+ "PPF",
+ "PPF",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Clpi_Video_Standard[]=
+{
+ "",
+ "NTSC",
+ "PAL",
+ "NTSC",
+ "",
+ "",
+ "",
+ "PAL",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+int16u Clpi_Video_Width[]=
+{
+ 0,
+ 720,
+ 720,
+ 720,
+ 1920,
+ 1280,
+ 1920,
+ 720,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+int16u Clpi_Video_Height[]=
+{
+ 0,
+ 480,
+ 576,
+ 480,
+ 1080,
+ 720,
+ 1080,
+ 576,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+float32 Clpi_Video_FrameRate[]=
+{
+ (float32) 0.000,
+ (float32)23.976,
+ (float32)24.000,
+ (float32)25.000,
+ (float32)29.970,
+ (float32) 0.000,
+ (float32)50.000,
+ (float32)59.940,
+ (float32) 0.000,
+ (float32) 0.000,
+ (float32) 0.000,
+ (float32) 0.000,
+ (float32) 0.000,
+ (float32) 0.000,
+ (float32) 0.000,
+ (float32) 0.000,
+};
+
+//---------------------------------------------------------------------------
+float32 Clpi_Video_AspectRatio[]=
+{
+ (float32)0.000,
+ (float32)0.000,
+ (float32)1.333,
+ (float32)1.778,
+ (float32)2.210,
+ (float32)0.000,
+ (float32)0.000,
+ (float32)0.000,
+ (float32)0.000,
+ (float32)0.000,
+ (float32)0.000,
+ (float32)0.000,
+ (float32)0.000,
+ (float32)0.000,
+ (float32)0.000,
+ (float32)0.000,
+};
+
+//---------------------------------------------------------------------------
+int8u Clpi_Audio_Channels[]=
+{
+ 0,
+ 1,
+ 0,
+ 2,
+ 0,
+ 0,
+ 0, //Multi 6-8
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, //Combo
+ 0,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+int32u Clpi_Audio_SamplingRate[]=
+{
+ 0,
+ 48000,
+ 0,
+ 0,
+ 96000,
+ 192000,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 48000, //192000?
+ 48000, // 96000?
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+const char* Indx_object_type[]=
+{
+ "",
+ "HDMV",
+ "BD-J",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Indx_playback_type[4][4]=
+{
+ {"", "", "", "", },
+ {"Movie", "Interactive", "", "", },
+ {"", "", "Movie", "Interactive", },
+ {"", "", "", "", },
+};
+
+//---------------------------------------------------------------------------
+const char* Indx_title_search[]=
+{
+ "Permitted",
+ "Prohibited1",
+ "Prohibited2",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpls_playback_type[]=
+{
+ "Sequential",
+ "Random",
+ "Shuffle",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpls_PlayListMarks_Mark_type(int8u type)
+{
+ switch (type)
+ {
+ case 1 : return "entry-mark";
+ case 2 : return "link point";
+ default: return "";
+ }
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Ztring Bdmv_Decimal_Hexa(int64u Number)
+{
+ Ztring Temp;
+ Temp.From_Number(Number);
+ Temp+=_T(" (0x");
+ Temp+=Ztring::ToZtring(Number, 16);
+ Temp+=_T(")");
+ return Temp;
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Bdmv::FileHeader_Begin()
+{
+ size_t BDMV_Pos=File_Name.find(Ztring(1, PathSeparator)+_T("BDMV"));
+ if (BDMV_Pos!=string::npos && BDMV_Pos+5==File_Name.size()) //Blu-ray directory
+ return true;
+
+ //Element_Size
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ switch (CC4(Buffer))
+ {
+ case Elements::CLPI :
+ case Elements::INDX :
+ case Elements::MOBJ :
+ case Elements::MPLS :
+ break;
+ default : Reject("Blu-ray");
+ return false;
+ }
+
+ //Init
+ Mpls_PlayList_IsParsed=false;
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Read_Buffer_Continue()
+{
+ size_t BDMV_Pos=File_Name.find(Ztring(1, PathSeparator)+_T("BDMV"));
+ if (BDMV_Pos!=string::npos && BDMV_Pos+5==File_Name.size()) //Blu-ray directory
+ {
+ BDMV();
+ return;
+ }
+
+ if (Buffer_Size<File_Size)
+ {
+ Element_WaitForMoreData();
+ return; //Wait for more data
+ }
+
+ //Parsing
+ int32u type_indicator;
+ int16u version_numberH;
+ Element_Begin1("Header");
+ Get_C4 (type_indicator, "type_indicator");
+ Data_Accept("Blu-ray");
+ Get_C2 (version_numberH, "version_number (High)");
+ Skip_C2( "version_number (Low)");
+ Element_End0();
+
+ FILLING_BEGIN();
+ Accept("BDMV");
+ switch (type_indicator)
+ {
+ case Elements::CLPI : Fill(Stream_General, 0, General_Format, "Blu-ray Clip info"); break;
+ case Elements::INDX : Fill(Stream_General, 0, General_Format, "Blu-ray Index"); break;
+ case Elements::MOBJ : Fill(Stream_General, 0, General_Format, "Blu-ray Movie object"); break;
+ case Elements::MPLS : Fill(Stream_General, 0, General_Format, "Blu-ray Playlist"); break;
+ default : ;
+ }
+ FILLING_END();
+
+ if (version_numberH==0x3031 || version_numberH==0x3032) //Version 1 or 2
+ {
+ Element_Begin1("Offsets");
+ Types[0x28]=0; //First object
+ for (size_t Start_Adress_Pos=1; Start_Adress_Pos<9; Start_Adress_Pos++)
+ {
+ int32u Start_Adress;
+ Get_B4 (Start_Adress, Bdmv_Type(type_indicator, Start_Adress_Pos));
+ Types[Start_Adress]=Start_Adress_Pos;
+ }
+ Element_End0();
+
+ for (std::map<int32u, size_t>::iterator Type=Types.begin(); Type!=Types.end(); Type++)
+ {
+ if (Type->first>=Element_Offset) //If valid
+ {
+ if (Type->first>Element_Offset)
+ Skip_XX(Type->first-Element_Offset, "unknown");
+
+ Element_Begin1(Bdmv_Type(type_indicator, Type->second));
+ int32u length;
+ Get_B4 (length, "length");
+ int64u End=Element_Offset+length;
+ switch (type_indicator)
+ {
+ case Elements::CLPI :
+ switch(Type->second)
+ {
+ case 2 : Clpi_ProgramInfo(); break;
+ case 5 : Clpi_ExtensionData(); break;
+ default: ;
+ }
+ break;
+ case Elements::INDX :
+ switch(Type->second)
+ {
+ case 0 : Indx_AppInfoBDMV(); break;
+ case 1 : Indx_Indexes(); break;
+ case 2 : Indx_ExtensionData(); break;
+ default: ;
+ }
+ break;
+ case Elements::MOBJ :
+ switch(Type->second)
+ {
+ case 0 : Mobj_MovieObjects(); break;
+ case 1 : Mobj_ExtensionData(); break;
+ default: ;
+ }
+ break;
+ case Elements::MPLS :
+ switch(Type->second)
+ {
+ case 0 : Mpls_AppInfoPlayList(); break;
+ case 1 : Mpls_PlayList(); break;
+ case 2 : Mpls_PlayListMarks (); break;
+ case 3 : Mpls_ExtensionData (); break;
+ default: ;
+ }
+ break;
+ default : ;
+ }
+ if (End>Element_Offset)
+ Skip_XX(End-Element_Offset, "Unknown");
+ Element_End0();
+ }
+ }
+
+ if (Element_Size>Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ }
+ else
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Bdmv::BDMV()
+{
+ Accept("BDMV");
+
+ //Searching the longest playlist
+ ZtringList List=Dir::GetAllFileNames(File_Name+PathSeparator+_T("PLAYLIST")+PathSeparator+_T("*.mpls"), Dir::Include_Files);
+ std::vector<MediaInfo_Internal*> MIs;
+ MIs.resize(List.size());
+ size_t MaxDuration_Pos=(size_t)-1;
+ int64u MaxDuration=0;
+ if (Config->File_Bdmv_ParseTargetedFile_Get())
+ {
+ for (size_t Pos=0; Pos<MIs.size(); Pos++)
+ {
+ MIs[Pos]=new MediaInfo_Internal();
+ MIs[Pos]->Option(_T("File_Bdmv_ParseTargetedFile"), _T("0"));
+ MIs[Pos]->Open(List[Pos]);
+ int64u Duration=Ztring(MIs[Pos]->Get(Stream_General, 0, General_Duration)).To_int64u();
+ if (Duration>MaxDuration)
+ {
+ MaxDuration=Duration;
+ MaxDuration_Pos=Pos;
+ }
+ }
+ }
+
+ if (MaxDuration_Pos!=(size_t)-1)
+ {
+ //Merging
+ MediaInfo_Internal MI;
+ MI.Open(List[MaxDuration_Pos]); //Open it again for having the M2TS part
+ Merge(MI);
+
+ Clear(Stream_General, 0, General_Format);
+ Clear(Stream_General, 0, General_Format_String);
+ Clear(Stream_General, 0, General_Format_Extensions);
+ Clear(Stream_General, 0, General_Format_Info);
+ Clear(Stream_General, 0, General_Codec);
+ Clear(Stream_General, 0, General_Codec_String);
+ Clear(Stream_General, 0, General_Codec_Extensions);
+ Clear(Stream_General, 0, General_FileSize);
+ Clear(Stream_Video, 0, Video_ScanType_String);
+ Clear(Stream_Video, 0, Video_Bits__Pixel_Frame_);
+ }
+
+ for (size_t Pos=0; Pos<MIs.size(); Pos++)
+ delete MIs[Pos]; //MIs[Pos]=NULL;
+ MIs.clear();
+
+ //Detecting some directories
+ if (Dir::Exists(File_Name+PathSeparator+_T("BDSVM"))
+ || Dir::Exists(File_Name+PathSeparator+_T("SLYVM"))
+ || Dir::Exists(File_Name+PathSeparator+_T("ANYVM")))
+ Fill(Stream_General, 0, General_Format_Profile, "BD+");
+ if (Dir::Exists(File_Name+PathSeparator+_T("BDJO")) && !Dir::GetAllFileNames(File_Name+PathSeparator+_T("BDJO")).empty())
+ Fill(Stream_General, 0, General_Format_Profile, "BD-Java");
+
+ //Filling
+ File_Name.resize(File_Name.size()-5); //Removing "/BDMV"
+ Fill(Stream_General, 0, General_Format, "Blu-ray movie", Unlimited, true, true);
+ Fill(Stream_General, 0, General_CompleteName, File_Name, true);
+ Fill(Stream_General, 0, General_FolderName, FileName::Path_Get(File_Name), true);
+ if (FileName::Extension_Get(File_Name).empty())
+ Fill(Stream_General, 0, General_FileName, FileName::Name_Get(File_Name), true);
+ else
+ Fill(Stream_General, 0, General_FileName, FileName::Name_Get(File_Name)+_T('.')+FileName::Extension_Get(File_Name), true);
+ File_Name.clear();
+
+ Finish("BDMV");
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Clpi_ProgramInfo()
+{
+ //Retrieving data from the M2TS file
+ std::map<int16u, stream_t> PIDs_StreamKind;
+ std::map<int16u, size_t> PIDs_StreamPos;
+ if (Config->File_Bdmv_ParseTargetedFile_Get() && File_Name.size()>10+1+7)
+ {
+ Ztring file=File_Name.substr(File_Name.size()-10, 5);
+ Ztring M2TS_File=File_Name;
+ M2TS_File.resize(M2TS_File.size()-(10+1+7));
+ M2TS_File+=_T("STREAM");
+ M2TS_File+=PathSeparator;
+ M2TS_File+=file;
+ M2TS_File+=_T(".m2ts");
+
+ MediaInfo_Internal MI;
+ MI.Option(_T("File_Bdmv_ParseTargetedFile"), _T("0"));
+ if (MI.Open(M2TS_File))
+ {
+ Merge(MI);
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Count_Get((stream_t)StreamKind); StreamPos++)
+ Fill((stream_t)StreamKind, StreamPos, "Source", file+_T(".m2ts"));
+ }
+
+ //Retrieving PID mapping
+ for (size_t StreamKind=(size_t)Stream_General+1; StreamKind<(size_t)Stream_Max; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Count_Get((stream_t)StreamKind); StreamPos++)
+ {
+ int16u PID=Retrieve((stream_t)StreamKind, StreamPos, General_ID).To_int16u();
+ PIDs_StreamKind[PID]=(stream_t)StreamKind;
+ PIDs_StreamPos[PID]=StreamPos;
+ }
+ }
+
+ //Parsing
+ int8u number_of_program_sequences;
+ Skip_B1( "Unknown");
+ Get_B1 (number_of_program_sequences, "number_of_program_sequences");
+ for (int8u program_sequence=0; program_sequence<number_of_program_sequences; program_sequence++)
+ {
+ int8u number_of_streams_in_ps;
+ Skip_B4( "Unknown");
+ Skip_B2( "program_map_PID");
+ Get_B1 (number_of_streams_in_ps, "number_of_streams_in_ps");
+ Skip_B1( "Unknown");
+ for (int16u Pos=0; Pos<number_of_streams_in_ps; Pos++)
+ {
+ Element_Begin1("Stream");
+ int16u stream_PID;
+ int8u Stream_Length;
+ Get_B2 (stream_PID, "stream_PID");
+ Get_B1 (Stream_Length, "Length");
+ int64u Stream_End=Element_Offset+Stream_Length;
+ StreamKind_Last=Stream_Max;
+ std::map<int16u, stream_t>::iterator PID_StreamKind=PIDs_StreamKind.find(stream_PID);
+ if (PID_StreamKind!=PIDs_StreamKind.end())
+ {
+ StreamKind_Last=PID_StreamKind->second;
+ StreamPos_Last=PIDs_StreamPos.find(stream_PID)->second;
+ }
+ Get_B1 (stream_type, "Stream type"); Param_Info1(Clpi_Format(stream_type)); Element_Info1(Clpi_Format(stream_type));
+ switch (Clpi_Type(stream_type))
+ {
+ case Stream_Video : StreamCodingInfo_Video(); break;
+ case Stream_Audio : StreamCodingInfo_Audio(); break;
+ case Stream_Text : StreamCodingInfo_Text() ; break;
+ default : ;
+ }
+
+ if (Stream_End-Element_Offset)
+ Skip_XX(Stream_End-Element_Offset, "Unknown");
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (StreamKind_Last!=Stream_Max)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, stream_PID, 10, true);
+ Fill(StreamKind_Last, StreamPos_Last, General_ID_String, Bdmv_Decimal_Hexa(stream_PID), true);
+ }
+ FILLING_END();
+ }
+ }
+}
+
+struct entry
+{
+ int16u ID1;
+ int16u ID2;
+ int32u Length;
+};
+typedef std::map<int32u, entry> entries; //Key is the start address
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Clpi_ExtensionData()
+{
+ entries Entries; //Key is the start address
+
+ int32u Base_Pos=(int32u)Element_Offset-4;
+
+ int8u number_of_ext_data_entries;
+ Skip_B4( "Unknown");
+ Skip_B3( "Unknown");
+ Element_Begin1("Offsets");
+ Get_B1 (number_of_ext_data_entries, "number_of_ext_data_entries");
+ for (size_t Start_Adress_Pos=0; Start_Adress_Pos<number_of_ext_data_entries; Start_Adress_Pos++)
+ {
+ int32u Start_Adress, Length;
+ int16u ID1, ID2;
+ Get_B2 (ID1, "ID1");
+ Get_B2 (ID2, "ID2");
+ Get_B4 (Start_Adress, "Start_Adress");
+ Get_B4 (Length, "Length");
+ Entries[Base_Pos+Start_Adress].ID1=ID1;
+ Entries[Base_Pos+Start_Adress].ID2=ID2;
+ Entries[Base_Pos+Start_Adress].Length=Length;
+ }
+ Element_End0();
+
+ for (entries::iterator Entry=Entries.begin(); Entry!=Entries.end(); Entry++)
+ {
+ if (Entry->first>=Element_Offset) //If valid
+ {
+ if (Entry->first>Element_Offset)
+ Skip_XX(Entry->first-Element_Offset, "unknown");
+
+ Element_Begin1("Entry");
+ int32u length;
+ Get_B4 (length, "length");
+ int64u End=Element_Offset+length;
+ switch (Entry->second.ID1)
+ {
+ case 0x0002 :
+ switch(Entry->second.ID2)
+ {
+ case 0x0005 : Clpi_ProgramInfo(); break;
+ default: ;
+ }
+ break;
+ default : ;
+ }
+ if (End>Element_Offset)
+ Skip_XX(End-Element_Offset, "Unknown");
+ Element_End0();
+ }
+ }
+
+ if (Element_Size>Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Indx_AppInfoBDMV()
+{
+ //Parsing
+ Skip_B2( "reserved");
+ Skip_Local(32, "user_data");
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Indx_Indexes()
+{
+ //Parsing
+ int16u number_of_Titles;
+ Element_Begin1("FirstPlayback");
+ BS_Begin();
+ int8u FirstPlayback_object_type;
+ Get_S1 ( 2, FirstPlayback_object_type, "object_type"); Param_Info1(Indx_object_type[FirstPlayback_object_type]);
+ Skip_S4(30, "reserved");
+ BS_End();
+ Indx_Indexes_Index(FirstPlayback_object_type);
+ Element_End0();
+ Element_Begin1("TopMenu");
+ BS_Begin();
+ int8u TopMenu_object_type;
+ Get_S1 ( 2, TopMenu_object_type, "object_type"); Param_Info1(Indx_object_type[TopMenu_object_type]);
+ Skip_S4(30, "reserved");
+ BS_End();
+ Indx_Indexes_Index(TopMenu_object_type);
+ Element_End0();
+ Get_B2 (number_of_Titles, "number_of_Titles");
+ for (int16u Pos=0; Pos<number_of_Titles; Pos++)
+ {
+ Element_Begin1("Title");
+ BS_Begin();
+ int8u Title_object_type;
+ Get_S1 ( 2, Title_object_type, "object_type"); Param_Info1(Indx_object_type[Title_object_type]);
+ Info_S1( 2, Title_title_search, "title_search"); Param_Info1(Indx_title_search[Title_title_search]);
+ Skip_S4(28, "reserved");
+ BS_End();
+ Indx_Indexes_Index(Title_object_type);
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Indx_Indexes_Index(int8u object_type)
+{
+ BS_Begin();
+ Info_S1( 2, playback_type, "playback_type"); Param_Info1(Indx_playback_type[object_type][playback_type]);
+ Skip_S2(14, "reserved");
+ BS_End();
+ switch (object_type)
+ {
+ case 1 : //HDMV
+ {
+ Info_B2(id_ref, "id_ref"); Element_Info1(id_ref);
+ Skip_B4( "reserved");
+ }
+ break;
+ case 2 : //BD-J
+ {
+ Info_Local(5, id_ref, "id_ref"); Element_Info1(id_ref);
+ Skip_B1( "reserved");
+ }
+ break;
+ default:
+ Skip_XX(6, "unknown");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Indx_ExtensionData()
+{
+ //Parsing
+ std::map<int32u, int32u> exts; //Key is the start address, value is length
+ int64u Base_Offset=Element_Offset-4; //Size is included
+ int8u number_of_ext_data_entries;
+ Skip_B4( "data_block_start_adress");
+ Skip_B3( "reserved");
+ Get_B1 (number_of_ext_data_entries, "number_of_ext_data_entries");
+ for (int16u Pos=0; Pos<number_of_ext_data_entries; Pos++)
+ {
+ Element_Begin1("ext_data_entry");
+ int32u ext_data_start_adress, ext_data_length;
+ Skip_B2( "ID1 (AVCHD)");
+ Skip_B2( "ID2 (Version)");
+ Get_B4 (ext_data_start_adress, "ext_data_start_adress");
+ Get_B4 (ext_data_length, "ext_data_length");
+ Element_End0();
+ exts[ext_data_start_adress]=ext_data_length;
+ }
+
+ for (std::map<int32u, int32u>::iterator ext=exts.begin(); ext!=exts.end(); ext++)
+ {
+ if (Base_Offset+ext->first>=Element_Offset)
+ {
+ if (Base_Offset+ext->first>Element_Offset)
+ Skip_XX(ext->first-Element_Offset, "Unknown");
+
+ Element_Begin0();
+ int64u End=Element_Offset+ext->second;
+
+ int32u type_indicator;
+ Get_C4(type_indicator, "type_indicator"); Element_Info1(Ztring().From_CC4(type_indicator));
+ switch (type_indicator)
+ {
+ case 0x49444558 : Indx_ExtensionData_IDEX(); break;
+ default : Element_Name("Unknown");
+ Skip_XX(ext->second-4, "Unknown");
+ }
+ if (End>Element_Offset)
+ Skip_XX(End-Element_Offset, "Unknown");
+ Element_End0();
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Indx_ExtensionData_IDEX()
+{
+ Element_Name("IndexExtension");
+
+ //Parsing
+ int64u Base_Offset=Element_Offset-4; //Size is included
+ int32u TableOfPlayLists_start_adress, MakersPrivateData_start_adress;
+ Skip_B4( "reserved");
+ Get_B4 (TableOfPlayLists_start_adress, "TableOfPlayLists_start_adress");
+ Get_B4 (MakersPrivateData_start_adress, "MakersPrivateData_start_adress");
+ Skip_XX(24, "reserved");
+
+ Indx_ExtensionData_IDEX_UIAppInfoAVCHD();
+ if (TableOfPlayLists_start_adress)
+ {
+ if (Base_Offset+TableOfPlayLists_start_adress>Element_Offset)
+ Skip_XX(Base_Offset+TableOfPlayLists_start_adress-Element_Offset, "Unknown");
+ Indx_ExtensionData_IDEX_TableOfPlayLists();
+ }
+ if (MakersPrivateData_start_adress)
+ {
+ if (Base_Offset+MakersPrivateData_start_adress>Element_Offset)
+ Skip_XX(Base_Offset+MakersPrivateData_start_adress-Element_Offset, "Unknown");
+ Indx_ExtensionData_IDEX_MakersPrivateData();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Indx_ExtensionData_IDEX_UIAppInfoAVCHD()
+{
+ Element_Begin1("UIAppInfoAVCHD");
+
+ //Parsing
+ int32u length, length2;
+ int8u AVCHD_name_length;
+ Get_B4 (length, "length");
+ Skip_B2( "maker_ID");
+ Skip_B2( "maker_model_code");
+ Skip_XX(32, "maker_private_area");
+ BS_Begin();
+ Skip_BS(15, "reserved");
+ Skip_SB( "AVCHD_write_protect_flag");
+ BS_End();
+ Skip_B2( "ref_to_menu_thumbail_index");
+ Skip_B1( "time_zone");
+ Skip_XX(7, "record_time_and_date");
+ Skip_B1( "reserved");
+ Skip_B1( "AVCHD_character_set");
+ Get_B1 (AVCHD_name_length, "AVCHD_name_length");
+ Skip_Local(AVCHD_name_length, "AVCHD_name");
+ Skip_XX(255-AVCHD_name_length, "AVCHD_name (junk)");
+ Element_Begin1("additional data");
+ Get_B4 (length2, "length2");
+ Skip_XX(length2, "reserved");
+ Element_End0();
+
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Indx_ExtensionData_IDEX_TableOfPlayLists()
+{
+ Element_Begin1("TableOfPlayLists");
+
+ //Parsing
+ int32u length;
+ Get_B4 (length, "length");
+ Skip_XX(length, "unknown");
+
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Indx_ExtensionData_IDEX_MakersPrivateData()
+{
+ Element_Begin1("MakersPrivateData");
+
+ //Parsing
+ int64u Base_Offset=Element_Offset-4; //Size is included
+ int32u length, datablock_start_adress;
+ int8u number_of_maker_entries;
+ Get_B4 (length, "length");
+ Get_B4 (datablock_start_adress, "datablock_start_adress");
+ Skip_XX(24, "reserved");
+ Get_B1 (number_of_maker_entries, "number_of_maker_entries");
+ for (int8u Pos=0; Pos<number_of_maker_entries; Pos++)
+ {
+ Element_Begin1("maker_entry");
+ Skip_B2( "maker_ID");
+ Skip_B2( "maker_model_code");
+ Skip_B4( "mpd_start_adress");
+ Skip_B4( "mpd_length");
+ Element_End0();
+ }
+
+ if (datablock_start_adress)
+ {
+ if (Base_Offset+datablock_start_adress>Element_Offset)
+ Skip_XX(Base_Offset+datablock_start_adress-Element_Offset, "Unknown");
+ Skip_XX(length-datablock_start_adress, "Unknown");
+ }
+
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mobj_MovieObjects()
+{
+ //Parsing
+ int16u number_of_mobjs;
+ Skip_B4( "reserved");
+ Get_B2 (number_of_mobjs, "number_of_mobj");
+ for (int16u mobjs_Pos=0; mobjs_Pos<number_of_mobjs; mobjs_Pos++)
+ {
+ Element_Begin1("mobj");
+ int16u number_of_navigation_commands;
+ BS_Begin();
+ Info_SB(resume, "resume"); Param_Info1(resume?"suspend":"discard");
+ Info_SB(menu_call, "menu_call"); Param_Info1(menu_call?"enable":"disable");
+ Info_SB(title_search, "title_search"); Param_Info1(title_search?"enable":"disable");
+ Skip_BS(13, "reserved");
+ BS_End();
+ Get_B2 (number_of_navigation_commands, "number_of_navigation_commands");
+ for (int16u navigation_command_Pos=0; navigation_command_Pos<number_of_navigation_commands; navigation_command_Pos++)
+ {
+ Element_Begin1("navigation_command");
+ Skip_B4( "opcode");
+ Skip_B4( "destination");
+ Skip_B4( "source");
+ Element_End0();
+ }
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mobj_ExtensionData()
+{
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mpls_AppInfoPlayList()
+{
+ //Parsing
+ Skip_B1( "unknown");
+ BS_Begin();
+ Skip_S1(6, "unknown");
+ Info_S2(2, playback_type, "playback_type"); Param_Info1(Mpls_playback_type[playback_type]);
+ BS_End();
+ Skip_B2( "playback_count");
+ Skip_B4( "user_operation_mask_code 1");
+ Skip_B4( "user_operation_mask_code 2");
+ BS_Begin();
+ Skip_SB( "random access");
+ Skip_SB( "audio mix");
+ Skip_SB( "bypass mixer");
+ Skip_S2(13, "reserved");
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mpls_PlayList()
+{
+ //Parsing
+ Mpls_PlayList_Duration=0;
+ int16u number_of_PlayItems, number_of_SubPaths;
+ Skip_B2( "reserved");
+ Get_B2 (number_of_PlayItems, "number_of_PlayItems");
+ Get_B2 (number_of_SubPaths, "number_of_SubPaths");
+ for (int16u Pos=0; Pos<number_of_PlayItems; Pos++)
+ Mpls_PlayList_PlayItem();
+
+ if (Mpls_PlayList_Duration)
+ Fill(Stream_General, 0, General_Duration, Mpls_PlayList_Duration/45);
+
+ for (int16u SubPath_Pos=0; SubPath_Pos<number_of_SubPaths; SubPath_Pos++)
+ {
+ Element_Begin1("SubPath");
+ int32u SubPath_length;
+ int16u number_of_SubPlayItems;
+ Get_B4 (SubPath_length, "length");
+ int64u SubPath_End=Element_Offset+SubPath_length;
+ Skip_B1( "Unknown");
+ Skip_B1( "SubPath_type");
+ Skip_B2( "repeat");
+ Get_B2 (number_of_SubPlayItems, "number_of_SubPlayItems");
+ for (int16u SubPlayItem=0; SubPlayItem<number_of_SubPlayItems; SubPlayItem++)
+ Mpls_PlayList_SubPlayItem();
+
+ if (SubPath_End>Element_Offset)
+ Skip_XX(SubPath_End-Element_Offset, "unknown");
+ Element_End0();
+ }
+
+ FILLING_BEGIN();
+ if (!Mpls_PlayList_IsParsed)
+ {
+ Mpls_PlayList_number_of_SubPaths=number_of_SubPaths;
+ Mpls_PlayList_IsParsed=true;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mpls_PlayList_PlayItem()
+{
+ Element_Begin1("PlayItem");
+ Ztring Clip_Information_file_name;
+ int32u Time_In, Time_Out;
+ int16u length;
+ Get_B2 (length, "length");
+ int64u End=Element_Offset+length;
+ Get_Local (5, Clip_Information_file_name, "Clip_Information_file_name"); Element_Info1(Clip_Information_file_name);
+ Skip_Local(4, "Clip_codec_identifier");
+ Skip_B2( "unknown");
+ Skip_B1( "Unknown");
+ Get_B4 (Time_In, "Time (In)"); Param_Info1((float32)Time_In/45000);
+ Get_B4 (Time_Out, "Time (Out)"); Param_Info1((float32)Time_Out/45000);
+ Skip_B4( "UO1");
+ Skip_B4( "UO2");
+ Skip_B4( "An?");
+
+ if (Time_Out>Time_In)
+ Mpls_PlayList_Duration+=Time_Out-Time_In;
+
+ Mpls_PlayList_PlayItem_STN_table();
+
+ if (Clip_Information_file_names.find(Clip_Information_file_name)==Clip_Information_file_names.end() && File_Name.size()>10+1+8)
+ {
+ Ztring CLPI_File=File_Name;
+ CLPI_File.resize(CLPI_File.size()-(10+1+8));
+ CLPI_File+=_T("CLIPINF");
+ CLPI_File+=PathSeparator;
+ CLPI_File+=Clip_Information_file_name;
+ CLPI_File+=_T(".clpi");
+
+ MediaInfo_Internal MI;
+ MI.Option(_T("File_Bdmv_ParseTargetedFile"), Config->File_Bdmv_ParseTargetedFile_Get()?_T("1"):_T("0"));
+ if (MI.Open(CLPI_File))
+ Merge(MI, Stream_Video, 0, 0);
+
+ Clip_Information_file_names.insert(Clip_Information_file_name);
+ }
+
+ if (End>Element_Offset)
+ Skip_XX(End-Element_Offset, "unknown");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mpls_PlayList_PlayItem_STN_table()
+{
+ Element_Begin1("STN");
+
+ int16u length;
+ Get_B2 (length, "length");
+ int64u End=Element_Offset+length;
+ if (End>Element_Size)
+ {
+ Skip_XX(Element_Size-Element_Offset, "Problem");
+ return;
+ }
+ Skip_B2( "unknown");
+ Skip_B1( "Vi");
+ Skip_B1( "Au");
+ Skip_B1( "PG");
+ Skip_B1( "IG");
+ Skip_B1( "sV");
+ Skip_B1( "sA");
+ Skip_B1( "PIP");
+ Skip_B1( "unknown");
+ Skip_B1( "unknown");
+ Skip_B1( "unknown");
+ Skip_B1( "unknown");
+ Skip_B1( "unknown");
+
+ while (Element_Offset+16<=End)
+ {
+ Element_Begin0();
+ Ztring language;
+ int16u mPID;
+ int8u IDs_length;
+ Skip_B1( "type");
+ Skip_B1( "unknown");
+ Get_B2 (mPID, "mPID"); Element_Name(Ztring::ToZtring(mPID, 16));
+ Skip_B2( "SPid");
+ Skip_B2( "sCid");
+ Skip_B2( "sPID");
+ Get_B1 (IDs_length, "length");
+ int64u IDs_End=Element_Offset+IDs_length;
+ Get_B1 (stream_type, "stream_type"); Param_Info1(Clpi_Format(stream_type)); Element_Info1(Clpi_Format(stream_type));
+ switch (Clpi_Type(stream_type))
+ {
+ case Stream_Video : Mpls_PlayList_PlayItem_STN_table_Video(); break;
+ case Stream_Audio : Mpls_PlayList_PlayItem_STN_table_Audio(); break;
+ case Stream_Text : Mpls_PlayList_PlayItem_STN_table_Text() ; break;
+ default : StreamKind_Last=Stream_Max;
+ }
+ Get_Local(3, language, "language"); Element_Info1(language);
+
+ if (IDs_End-Element_Offset)
+ Skip_XX(IDs_End-Element_Offset, "unknown");
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (StreamKind_Last!=Stream_Max)
+ {
+ if (mPID)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, mPID, 10, true);
+ Fill(StreamKind_Last, StreamPos_Last, General_ID_String, Bdmv_Decimal_Hexa(mPID), true);
+ }
+ Fill(StreamKind_Last, StreamPos_Last, "Language", language);
+ }
+ FILLING_END();
+ }
+
+ if (End>Element_Offset)
+ Skip_XX(End-Element_Offset, "unknown");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mpls_PlayList_PlayItem_STN_table_Video()
+{
+ //Parsing
+ int8u Format, FrameRate;
+ BS_Begin();
+ Get_S1 (4, Format, "format"); Param_Info1(Clpi_Video_Format[Format]);
+ Get_S1 (4, FrameRate, "frame_rate"); Param_Info1(Clpi_Video_FrameRate[FrameRate]);
+ BS_End();
+
+ FILLING_BEGIN();
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, StreamPos_Last, Video_Format, Clpi_Format(stream_type));
+ if (Clpi_Video_Width[Format])
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Clpi_Video_Width[Format]);
+ if (Clpi_Video_Height[Format])
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Clpi_Video_Height[Format]);
+ Fill(Stream_Video, StreamPos_Last, Video_Interlacement, Clpi_Video_Interlacement[Format]);
+ Fill(Stream_Video, StreamPos_Last, Video_Standard, Clpi_Video_Standard[Format]);
+ if (Clpi_Video_FrameRate[FrameRate])
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, Clpi_Video_FrameRate[FrameRate]);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mpls_PlayList_PlayItem_STN_table_Audio()
+{
+ //Parsing
+ int8u Channels, SamplingRate;
+ BS_Begin();
+ Get_S1 (4, Channels, "channel_layout"); Param_Info1(Clpi_Audio_Channels[Channels]);
+ Get_S1 (4, SamplingRate, "sampling_rate"); Param_Info1(Clpi_Audio_SamplingRate[SamplingRate]);
+ BS_End();
+
+ FILLING_BEGIN();
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format, Clpi_Format(stream_type));
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, Clpi_Format_Profile(stream_type));
+ if (Clpi_Audio_Channels[Channels])
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Clpi_Audio_Channels[Channels]);
+ if (Clpi_Audio_SamplingRate[SamplingRate])
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, Clpi_Audio_SamplingRate[SamplingRate]);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mpls_PlayList_PlayItem_STN_table_Text()
+{
+ //Parsing
+ if (stream_type==0x92) //Subtitle
+ Skip_B1( "Unknown");
+
+ FILLING_BEGIN();
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, StreamPos_Last, Text_Format, Clpi_Format(stream_type));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mpls_PlayList_SubPlayItem()
+{
+ Element_Begin1("SubPlayItem");
+ Ztring Clip_Information_file_name;
+ int16u length;
+ Get_B2 (length, "length");
+ int64u End=Element_Offset+length;
+ Get_Local (5, Clip_Information_file_name, "Clip_Information_file_name"); Element_Info1(Clip_Information_file_name);
+ Skip_Local(4, "Clip_codec_identifier");
+ Skip_B4( "unknown");
+ Skip_B1( "unknown");
+ Info_B4(Time_In, "time (in)"); Param_Info1((float32)Time_In/45000);
+ Info_B4(Time_Out, "time (out)"); Param_Info1((float32)Time_Out/45000);
+ Skip_B2( "sync PI");
+ Skip_B4( "sync PTS");
+
+ if (End>Element_Offset)
+ Skip_XX(End-Element_Offset, "unknown");
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (Mpls_PlayList_IsParsed)
+ {
+ if (!File_Name.empty())
+ {
+ Ztring CLPI_File=File_Name;
+ CLPI_File.resize(CLPI_File.size()-10-1-8);
+ CLPI_File+=_T("CLIPINF");
+ CLPI_File+=PathSeparator;
+ CLPI_File+=Clip_Information_file_name;
+ CLPI_File+=_T(".clpi");
+
+ MediaInfo_Internal MI;
+ MI.Option(_T("File_Bdmv_ParseTargetedFile"), Config->File_Bdmv_ParseTargetedFile_Get()?_T("1"):_T("0"));
+ if (MI.Open(CLPI_File))
+ {
+ Ztring ID=Retrieve(Stream_Video, 0, Video_ID);
+ Ztring ID_String=Retrieve(Stream_Video, 0, Video_ID_String);
+ Ztring Format_Profile=Retrieve(Stream_Video, 0, Video_Format_Profile);
+ Ztring BitRate=Retrieve(Stream_Video, 0, Video_BitRate);
+ Ztring Source=Retrieve(Stream_Video, 0, "Source");
+ Fill(Stream_Video, 0, Video_ID, MI.Get(Stream_Video, 0, Video_ID)+_T(" / ")+ID, true);
+ Fill(Stream_Video, 0, Video_ID_String, MI.Get(Stream_Video, 0, Video_ID_String)+_T(" / ")+ID_String, true);
+ if (!Format_Profile.empty())
+ Fill(Stream_Video, 0, Video_Format_Profile, MI.Get(Stream_Video, 0, Video_Format_Profile)+_T(" / ")+Format_Profile, true);
+ if (!BitRate.empty())
+ Fill(Stream_Video, 0, Video_BitRate, Ztring::ToZtring(BitRate.To_int32u()+MI.Get(Stream_Video, 0, Video_BitRate).To_int32u())+_T(" / ")+BitRate, true);
+ if (!Source.empty())
+ Fill(Stream_Video, 0, "Source", Clip_Information_file_name +_T(".m2ts / ")+Source, true);
+ }
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mpls_PlayListMarks()
+{
+ Stream_Prepare(Stream_Menu);
+ Fill(Stream_Menu, StreamPos_Last, Menu_Chapters_Pos_Begin, Count_Get(Stream_Menu, StreamPos_Last), 10, true);
+
+ //Parsing
+ int32u time_Pos0=0, time_Pos=1;
+ int16u count;
+ Get_B2 (count, "count");
+ for (int16u Pos=0; Pos<count; Pos++)
+ {
+ Element_Begin1("Mark");
+ int8u type;
+ Skip_B1( "unknown");
+ Get_B1 (type, "type"); Param_Info1(Mpls_PlayListMarks_Mark_type(type));
+ switch (type)
+ {
+ case 1 : //entry-mark
+ case 2 : //link point
+ {
+ int32u time;
+ int16u stream_file_index;
+ Get_B2 (stream_file_index, "stream_file_index");
+ Get_B4 (time, "time"); Param_Info2(time/45, " milliseconds");
+ Skip_B2( "unknown");
+ Skip_B4( "unknown");
+
+ FILLING_BEGIN();
+ if (Pos==0)
+ time_Pos0=time;
+ if (stream_file_index==0 && type==1) //We currently handle only the first file
+ {
+ Fill(Stream_Menu, 0, Ztring().Duration_From_Milliseconds((int64u)((time-time_Pos0)/45)).To_UTF8().c_str(), _T("Chapter ")+Ztring::ToZtring(time_Pos));
+ time_Pos++;
+ }
+ FILLING_END();
+ }
+ break;
+ default:
+ Skip_XX(12, "unknwon");
+ }
+ Element_End0();
+ }
+
+ Fill(Stream_Menu, StreamPos_Last, Menu_Chapters_Pos_End, Count_Get(Stream_Menu, StreamPos_Last), 10, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mpls_ExtensionData()
+{
+ entries Entries; //Key is the start address
+
+ int32u Base_Pos=(int32u)Element_Offset-4;
+
+ int8u number_of_ext_data_entries;
+ Skip_B4( "Unknown");
+ Skip_B3( "Unknown");
+ Element_Begin1("Offsets");
+ Get_B1 (number_of_ext_data_entries, "number_of_ext_data_entries");
+ for (size_t Start_Adress_Pos=0; Start_Adress_Pos<number_of_ext_data_entries; Start_Adress_Pos++)
+ {
+ int32u Start_Adress, Length;
+ int16u ID1, ID2;
+ Get_B2 (ID1, "ID1");
+ Get_B2 (ID2, "ID2");
+ Get_B4 (Start_Adress, "Start_Adress");
+ Get_B4 (Length, "Length");
+ Entries[Base_Pos+Start_Adress].ID1=ID1;
+ Entries[Base_Pos+Start_Adress].ID2=ID2;
+ Entries[Base_Pos+Start_Adress].Length=Length;
+ }
+ Element_End0();
+
+ for (entries::iterator Entry=Entries.begin(); Entry!=Entries.end(); Entry++)
+ {
+ if (Entry->first>=Element_Offset) //If valid
+ {
+ if (Entry->first>Element_Offset)
+ Skip_XX(Entry->first-Element_Offset, "unknown");
+
+ Element_Begin1("Entry");
+ int64u End=Element_Offset+Entry->second.Length;
+ switch (Entry->second.ID1)
+ {
+ case 0x0001 :
+ switch(Entry->second.ID2)
+ {
+ case 0x0001 : break; //Mpls_ExtensionData_pip_metadata(); break;
+ default: ;
+ }
+ break;
+ case 0x0002 :
+ switch(Entry->second.ID2)
+ {
+ case 0x0001 : break; //Mpls_ExtensionData_STN_table(); break;
+ case 0x0002 : Mpls_ExtensionData_SubPath_entries(); break;
+ case 0x0003 : break; //Mpls_ExtensionData_active_video_window(); break;
+ default: ;
+ }
+ break;
+ default : ;
+ }
+ if (End>Element_Offset)
+ Skip_XX(End-Element_Offset, "Unknown");
+ Element_End0();
+ }
+ }
+
+ if (Element_Size>Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::Mpls_ExtensionData_SubPath_entries()
+{
+ Element_Begin1("SubPath_entries");
+ int32u length;
+ int16u number_of_SubPath_extensions;
+ int8u SubPath_type;
+ Get_B4 (length, "length");
+ int64u End=Element_Offset+length;
+ Get_B2 (number_of_SubPath_extensions, "number_of_SubPath_extensions");
+ for (int8u SubPath_extension=0; SubPath_extension<number_of_SubPath_extensions+Mpls_PlayList_number_of_SubPaths; SubPath_extension++)
+ {
+ Element_Begin1("SubPath_extension");
+ int32u SubPath_extension_length;
+ Get_B4 (SubPath_extension_length, "length");
+ int64u SubPath_extension_End=Element_Offset+SubPath_extension_length;
+ Skip_B1( "Unknown");
+ Get_B1 (SubPath_type, "SubPath_type");
+ switch(SubPath_type)
+ {
+ case 0x08 :
+ {
+ int8u number_of_SubPlayItems;
+ Skip_B3( "Unknown");
+ Get_B1 (number_of_SubPlayItems, "number_of_SubPlayItems");
+ for (int8u Pos=0; Pos<number_of_SubPlayItems; Pos++)
+ Mpls_PlayList_SubPlayItem();
+ }
+ default : ;
+ }
+ if (SubPath_extension_End-Element_Offset)
+ Skip_XX(SubPath_extension_End-Element_Offset, "Padding");
+ Element_End0();
+ }
+ if (End-Element_Offset)
+ Skip_XX(End-Element_Offset, "Padding");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::StreamCodingInfo_Video()
+{
+ //Parsing
+ int8u Format, FrameRate, AspectRatio;
+ BS_Begin();
+ Get_S1 (4, Format, "Format"); Param_Info1(Clpi_Video_Format[Format]);
+ Get_S1 (4, FrameRate, "Frame rate"); Param_Info1(Clpi_Video_FrameRate[FrameRate]);
+ Get_S1 (4, AspectRatio, "Aspect ratio"); Param_Info1(Clpi_Video_AspectRatio[AspectRatio]);
+ Skip_BS(4, "Reserved");
+ BS_End();
+
+ FILLING_BEGIN();
+ if (StreamKind_Last==Stream_Max)
+ {
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, StreamPos_Last, Video_Format, Clpi_Format(stream_type));
+ if (Clpi_Video_Width[Format])
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Clpi_Video_Width[Format]);
+ if (Clpi_Video_Height[Format])
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Clpi_Video_Height[Format]);
+ Fill(Stream_Video, StreamPos_Last, Video_Interlacement, Clpi_Video_Interlacement[Format]);
+ Fill(Stream_Video, StreamPos_Last, Video_Standard, Clpi_Video_Standard[Format]);
+ if (Clpi_Video_FrameRate[FrameRate])
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, Clpi_Video_FrameRate[FrameRate]);
+ if (Clpi_Video_Height[AspectRatio])
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, Clpi_Video_AspectRatio[AspectRatio], 3, true);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::StreamCodingInfo_Audio()
+{
+ //Parsing
+ int8u Channels, SamplingRate;
+ BS_Begin();
+ Get_S1 (4, Channels, "Channel layout"); Param_Info1(Clpi_Audio_Channels[Channels]);
+ Get_S1 (4, SamplingRate, "Sampling Rate"); Param_Info1(Clpi_Audio_SamplingRate[SamplingRate]);
+ BS_End();
+ Info_Local(3, Language, "Language"); Element_Info1(Language);
+
+ FILLING_BEGIN();
+ if (StreamKind_Last==Stream_Max)
+ {
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format, Clpi_Format(stream_type));
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, Clpi_Format_Profile(stream_type));
+ if (Clpi_Audio_Channels[Channels])
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Clpi_Audio_Channels[Channels]);
+ if (Clpi_Audio_SamplingRate[SamplingRate])
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, Clpi_Audio_SamplingRate[SamplingRate]);
+ }
+ Fill(Stream_Audio, StreamPos_Last, Audio_Language, Language);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Bdmv::StreamCodingInfo_Text()
+{
+ //Parsing
+ if (stream_type==0x92) //Subtitle
+ Skip_B1( "Unknown");
+ Info_Local(3, Language, "Language"); Element_Info1(Language);
+
+ FILLING_BEGIN();
+ if (StreamKind_Last==Stream_Max)
+ {
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, StreamPos_Last, Text_Format, Clpi_Format(stream_type));
+ }
+ Fill(Stream_Text, StreamPos_Last, Text_Language, Language);
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_BDMV_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Bdmv.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Bdmv.h
new file mode 100644
index 000000000..ab84f28a0
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Bdmv.h
@@ -0,0 +1,93 @@
+// File_Bdmv - Info for Blu-ray Movie files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Blu-ray Movie files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_BdmvH
+#define MediaInfo_File_BdmvH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <set>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Bdmv
+//***************************************************************************
+
+class File_Bdmv : public File__Analyze
+{
+public :
+ void BDMV(); //The BDMV directory
+
+private :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+
+ //Elements
+ void Clpi_ProgramInfo();
+ void Clpi_ExtensionData();
+ void Indx_AppInfoBDMV();
+ void Indx_Indexes();
+ void Indx_Indexes_Index(int8u object_type);
+ void Indx_ExtensionData();
+ void Indx_ExtensionData_IDEX();
+ void Indx_ExtensionData_IDEX_UIAppInfoAVCHD();
+ void Indx_ExtensionData_IDEX_TableOfPlayLists();
+ void Indx_ExtensionData_IDEX_MakersPrivateData();
+ void Mobj_MovieObjects();
+ void Mobj_ExtensionData();
+ void Mpls_AppInfoPlayList();
+ void Mpls_PlayList();
+ void Mpls_PlayList_PlayItem();
+ void Mpls_PlayList_PlayItem_STN_table();
+ void Mpls_PlayList_PlayItem_STN_table_Video();
+ void Mpls_PlayList_PlayItem_STN_table_Audio();
+ void Mpls_PlayList_PlayItem_STN_table_Text();
+ void Mpls_PlayList_SubPlayItem();
+ void Mpls_PlayListMarks();
+ void Mpls_ExtensionData();
+ void Mpls_ExtensionData_SubPath_entries();
+ void StreamCodingInfo_Video();
+ void StreamCodingInfo_Audio();
+ void StreamCodingInfo_Text();
+
+ //Temp
+ int8u stream_type;
+ std::map<int32u, size_t> Types; //Key is the start address
+ int64u Mpls_PlayList_Duration;
+ int16u Mpls_PlayList_number_of_SubPaths;
+ bool Mpls_PlayList_IsParsed;
+ std::set<Ztring> Clip_Information_file_names;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Cdxa.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Cdxa.cpp
new file mode 100644
index 000000000..ceb81076a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Cdxa.cpp
@@ -0,0 +1,321 @@
+// File_Cdxa - Info for CDXA files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_CDXA_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Cdxa.h"
+#include "ZenLib/Utils.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Format
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// CDXA = RIFF header + Raw sectors
+// Riff header size = 44
+// Raw sector size = 2352
+//
+// Raw sector :
+// Sync 12 bytes (00 FF .. FF 00)
+// Header 4 bytes
+// SubHeader 8 bytes
+// Datas 2324 bytes
+// EDC (CRC) 4 bytes
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Cdxa::File_Cdxa()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("CDXA");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Cdxa;
+ StreamIDs_Width[0]=0;
+ #endif //MEDIAINFO_EVENTS
+ MustSynchronize=true;
+
+ //Temp
+ MI=NULL;
+}
+
+//---------------------------------------------------------------------------
+File_Cdxa::~File_Cdxa()
+{
+ delete MI; //MI=NULL;
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+// RIFF Header, 44 bytes
+// RIFF header 4 bytes, Pos=0
+// RIFF data size 4 bytes, Pos=4
+// Format (CDXA) 4 bytes, Pos=8
+// Format Header 4 bytes, Pos=12
+// Format Size 4 bytes, Pos=16
+// Format user_id 2 bytes, Pos=20
+// Format group_id 2 bytes, Pos=22
+// Format attributes 2 bytes, Pos=24
+// Format xa_signature 2 bytes, Pos=26 ("XA")
+// Format xa_track_number 4 bytes, Pos=28
+// Format Reserved 4 bytes, Pos=32
+// Data Header 4 bytes, Pos=36
+// Data Size 4 bytes, Pos=40
+//
+// Attributes (big endian):
+// 15 Directory
+// 14 CDDA
+// 13 Interleaved
+// 12 Mode2Form2 --> 2324 bytes/block
+// 11 Mode2Form1 --> 2048 bytes/block
+// 10 Exec_Other
+// 09 Reserved
+// 08 Read_Other
+// 07 Reserved
+// 06 Exec_Group
+// 05 Reserved
+// 04 Read_Group
+// 03 Reserved
+// 02 Exec_User
+// 01 Reserved
+// 00 Read_User
+
+//---------------------------------------------------------------------------
+bool File_Cdxa::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<0x28)
+ return false; //Must wait for more data
+
+ if ( CC4(Buffer+0x00)!=0x52494646 //"RIFF"
+ || LittleEndian2int32u(Buffer+0x04)!=LittleEndian2int32u(Buffer+0x28)+0x24 //Sizes of chunks
+ || CC4(Buffer+0x08)!=0x43445841 //"CDXA"
+ || CC4(Buffer+0x0C)!=0x666D7420 //"fmt "
+ || LittleEndian2int32u(Buffer+0x10)!=0x10
+ || CC2(Buffer+0x1A)!=0x5841 //"XA"
+ || CC4(Buffer+0x24)!=0x64617461) //"data"
+ {
+ Reject("CDXA");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Cdxa::FileHeader_Parse()
+{
+ //Parsing
+ Skip_C4( "RIFF header");
+ Skip_L4( "RIFF data size");
+ Skip_C4( "CDXA");
+ Skip_C4( "fmt header");
+ Skip_L4( "fmt size");
+ Skip_L2( "user_id");
+ Skip_L2( "group_id");
+ Skip_L2( "attributes");
+ Skip_C2( "xa_signature");
+ Skip_L4( "xa_track_number");
+ Skip_L4( "reserved");
+ Skip_C4( "data header");
+ Skip_L4( "data size");
+
+ FILLING_BEGIN();
+ Accept("CDXA");
+ MI=new MediaInfo_Internal;
+ MI->Option(_T("FormatDetection_MaximumOffset"), _T("1048576"));
+ //MI->Option(_T("File_IsSub"), _T("1"));
+ MI->Open_Buffer_Init(File_Size, File_Offset+Buffer_Offset);
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Cdxa::Synchronize()
+{
+ //Synchronizing
+ while ( Buffer_Offset+2352*3+12<=Buffer_Size
+ && !(CC8(Buffer+Buffer_Offset+2352*0)==0x00FFFFFFFFFFFFFFLL && CC4(Buffer+Buffer_Offset+2352*0+8)==0xFFFFFF00
+ && CC8(Buffer+Buffer_Offset+2352*1)==0x00FFFFFFFFFFFFFFLL && CC4(Buffer+Buffer_Offset+2352*1+8)==0xFFFFFF00
+ && CC8(Buffer+Buffer_Offset+2352*2)==0x00FFFFFFFFFFFFFFLL && CC4(Buffer+Buffer_Offset+2352*2+8)==0xFFFFFF00
+ && CC8(Buffer+Buffer_Offset+2352*3)==0x00FFFFFFFFFFFFFFLL && CC4(Buffer+Buffer_Offset+2352*3+8)==0xFFFFFF00))
+ Buffer_Offset++;
+ if (Buffer_Offset+2352*3+12>Buffer_Size)
+ return false;
+
+ //Synched is OK
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Cdxa::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+12>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (!(CC8(Buffer+Buffer_Offset)==0x00FFFFFFFFFFFFFFLL && CC4(Buffer+Buffer_Offset+8)==0xFFFFFF00))
+ Synched=false;
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Cdxa::Streams_Finish ()
+{
+ if (!MI)
+ return;
+
+ //If nothing
+ if (MI->Info==NULL || !MI->Info->Status[IsAccepted])
+ {
+ Fill(Stream_General, 0, General_Format, "CDXA");
+ }
+ else
+ {
+
+ //General
+ MI->Info->Open_Buffer_Finalize();
+ Merge(*(MI->Info));
+ Merge(*(MI->Info), Stream_General, 0, 0);
+ const Ztring &Format=Retrieve(Stream_General, 0, General_Format);
+ Fill(Stream_General, 0, General_Format, (Ztring(_T("CDXA/"))+Format).c_str(), Unlimited, true);
+ Clear(Stream_General, 0, General_Duration);
+ Clear(Stream_Video, 0, Video_Duration);
+ }
+
+ //Purge what is not needed anymore
+ if (!File_Name.empty()) //Only if this is not a buffer, with buffer we can have more data
+ {
+ delete MI; MI=NULL;
+ }
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Cdxa::Header_Parse()
+{
+ //Parsing
+ Skip_B4( "Sync1");
+ Skip_B4( "Sync2");
+ Skip_B4( "Sync3");
+ Skip_B4( "Header");
+ Skip_B8( "SubHeader");
+
+ //Filling
+ Header_Fill_Size(2352);
+ Header_Fill_Code(0, "Chunk");
+}
+
+//---------------------------------------------------------------------------
+void File_Cdxa::Data_Parse()
+{
+ if (MI==NULL)
+ {
+ //Where is the header? --> Problem
+ Reject("CDXA");
+ return;
+ }
+
+ //CRC or not?
+ int64u CRC_Size=4;
+ if (Element_Size!=2328)
+ CRC_Size=0;
+
+ //Parsing
+ Skip_XX(Element_Size-CRC_Size, "Data");
+ if (CRC_Size>0)
+ Skip_B4( "CRC");
+
+ //Preparing to fill MediaInfo with a buffer
+ MI->Open_Buffer_Position_Set(File_Offset+Buffer_Offset);
+
+ //Sending the buffer to MediaInfo
+ MI->Open_Buffer_Continue(Buffer+Buffer_Offset, (size_t)(Element_Size-CRC_Size));
+
+ //Testing if filled
+ if (MI->Info->Status[IsFilled]) {
+
+ }
+
+ //Testing if MediaInfo always need data
+ File_GoTo=MI->Open_Buffer_Continue_GoTo_Get();
+ if (File_GoTo==(int64u)-1 && MI->Info->Status[IsFilled] && File_Size!=(int64u)-1 && File_Offset+Buffer_Size<File_Size/2)
+ GoToFromEnd(File_Offset+Buffer_Size);
+ if (File_GoTo!=(int64u)-1)
+ Info("CDXA, Jumping to end of file");
+
+ //Details
+ #if MEDIAINFO_TRACE
+ if (Config_Trace_Level)
+ {
+ if (!MI->Inform().empty())
+ Element_Show_Add(MI->Inform());
+ }
+ #endif //MEDIAINFO_TRACE
+
+ //Demux
+ Demux(Buffer+Buffer_Offset, (size_t)(Element_Size-CRC_Size), ContentType_MainStream);
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_CDXA_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Cdxa.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Cdxa.h
new file mode 100644
index 000000000..a0c9b3d5c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Cdxa.h
@@ -0,0 +1,73 @@
+// File_Cdxa - Info for CDXA files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about CDXA files
+// (like Video-CD...)
+// CDXA are read by MS-Windows with CRC bytes
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_CdxaH
+#define MediaInfo_File_CdxaH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class MediaInfo_Internal;
+
+//***************************************************************************
+// Class File_Cdxa
+//***************************************************************************
+
+class File_Cdxa : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Cdxa();
+ ~File_Cdxa();
+
+private :
+ //Streams management
+ void Streams_Finish ();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Temp
+ MediaInfo_Internal* MI;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dcp.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dcp.cpp
new file mode 100644
index 000000000..0e380f41b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dcp.cpp
@@ -0,0 +1,182 @@
+// File_Dcp - Info for DCP (XML) files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DCP_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Dcp.h"
+#include "MediaInfo/MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/Multiple/File__ReferenceFilesHelper.h"
+#include "ZenLib/Dir.h"
+#include "ZenLib/FileName.h"
+#include "tinyxml2.h"
+using namespace tinyxml2;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Dcp::File_Dcp()
+:File__Analyze()
+{
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_None; //TODO
+ StreamIDs_Width[0]=sizeof(size_t)*2;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_EventWasSent_Accept_Specific=true;
+ #endif //MEDIAINFO_DEMUX
+
+ //Temp
+ ReferenceFiles=NULL;
+}
+
+//---------------------------------------------------------------------------
+File_Dcp::~File_Dcp()
+{
+ delete ReferenceFiles; //ReferenceFiles=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dcp::Streams_Finish()
+{
+ if (ReferenceFiles==NULL)
+ return;
+
+ ReferenceFiles->ParseReferences();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_Dcp::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ if (ReferenceFiles==NULL)
+ return 0;
+
+ return ReferenceFiles->Read_Buffer_Seek(Method, Value, ID);
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Dcp::FileHeader_Begin()
+{
+ XMLDocument document;
+ if (!FileHeader_Begin_XML(document))
+ return false;
+
+ {
+ std::string NameSpace;
+ XMLElement* AssetMap=document.FirstChildElement("AssetMap");
+ if (AssetMap==NULL)
+ {
+ NameSpace="am:";
+ AssetMap=document.FirstChildElement((NameSpace+"AssetMap").c_str());
+ }
+ if (AssetMap)
+ {
+ Accept("Dcp");
+ Fill(Stream_General, 0, General_Format, "DCP");
+ Fill(Stream_General, 0, General_Format_Version, NameSpace=="am:"?"SMPTE":"Interop");
+
+ ReferenceFiles=new File__ReferenceFilesHelper(this, Config);
+
+ XMLElement* IssueDate=AssetMap->FirstChildElement((NameSpace+"IssueDate").c_str());
+ if (IssueDate)
+ Fill(Stream_General, 0, General_Encoded_Date, IssueDate->GetText());
+ XMLElement* Issuer=AssetMap->FirstChildElement((NameSpace+"Issuer").c_str());
+ if (Issuer)
+ Fill(Stream_General, 0, General_EncodedBy, Issuer->GetText());
+ XMLElement* Creator=AssetMap->FirstChildElement((NameSpace+"Creator").c_str());
+ if (Creator)
+ Fill(Stream_General, 0, General_Encoded_Library, Creator->GetText());
+
+ XMLElement* AssetList=AssetMap->FirstChildElement((NameSpace+"AssetList").c_str());
+ if (AssetList)
+ {
+ XMLElement* Asset=AssetList->FirstChildElement((NameSpace+"Asset").c_str());
+ while (Asset)
+ {
+ XMLElement* ChunkList=Asset->FirstChildElement((NameSpace+"ChunkList").c_str());
+ if (ChunkList)
+ {
+ XMLElement* Chunk=ChunkList->FirstChildElement((NameSpace+"Chunk").c_str());
+ if (Chunk)
+ {
+ XMLElement* Path=Chunk->FirstChildElement((NameSpace+"Path").c_str());
+ if (Path)
+ {
+ File__ReferenceFilesHelper::reference ReferenceFile;
+ ReferenceFile.FileNames.push_back(Path->GetText());
+ ReferenceFile.StreamID=ReferenceFiles->References.size()+1;
+ ReferenceFiles->References.push_back(ReferenceFile);
+ }
+ }
+ }
+
+ Asset=Asset->NextSiblingElement();
+ }
+ }
+ }
+ else
+ {
+ Reject("Dcp");
+ return false;
+ }
+ }
+
+ //All should be OK...
+ return true;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_P2_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dcp.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dcp.h
new file mode 100644
index 000000000..a0403bcd1
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dcp.h
@@ -0,0 +1,69 @@
+// File_Dcp - Info for DCP (XML) files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about DCP files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_DcpH
+#define MediaInfo_File_DcpH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class File__ReferenceFilesHelper;
+
+//***************************************************************************
+// Class File_Dcp
+//***************************************************************************
+
+class File_Dcp : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Dcp();
+ ~File_Dcp();
+
+private :
+ //Streams management
+ void Streams_Finish ();
+
+ //Buffer - Global
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Temp
+ File__ReferenceFilesHelper* ReferenceFiles;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dpg.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dpg.cpp
new file mode 100644
index 000000000..ec4e5b483
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dpg.cpp
@@ -0,0 +1,191 @@
+// File_Dpg - Info for DPG files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Format:
+// * File header
+// * MPEG Audio stream
+// * MPEG Video stream
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DPG_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Dpg.h"
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Dpg::File_Dpg()
+{
+ //Data
+ Parser=NULL;
+}
+
+//---------------------------------------------------------------------------
+File_Dpg::~File_Dpg()
+{
+ delete Parser; //Parser=NULL;
+}
+
+//***************************************************************************
+// Buffer - File offset
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Dpg::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<0x14)
+ return false; //Must wait for more data
+
+ if ( CC4(Buffer )!=0x44504730 //"DPG0"
+ || LittleEndian2int32u(Buffer+0x10)!=0) //Zero
+ {
+ Reject("DPG");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Dpg::FileHeader_Parse()
+{
+ //Parsing
+ int32u FrameCount, FrameRate, SamplingRate;
+ Skip_C4( "Signature");
+ Get_L4 (FrameCount, "Frame count");
+ Get_L4 (FrameRate, "Frame rate"); Param_Info2(FrameRate/0x100, " fps");
+ Get_L4 (SamplingRate, "Sampling rate");
+ Skip_L4( "0x00000000");
+ Get_L4 (Audio_Offset, "Audio Offset");
+ Get_L4 (Audio_Size, "Audio Size");
+ Get_L4 (Video_Offset, "Video Offset");
+ Get_L4 (Video_Size, "Video Size");
+
+ FILLING_BEGIN();
+ Accept("DPG");
+
+ Fill(Stream_General, 0, General_Format, "DPG");
+
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_FrameRate, (float)(FrameRate/0x100), 3);
+ Fill(Stream_Video, 0, Video_FrameCount, FrameCount);
+ Fill(Stream_Video, 0, Video_StreamSize, Video_Size);
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, SamplingRate);
+ Fill(Stream_Audio, 0, Audio_StreamSize, Audio_Size);
+
+ //Positionning
+ #if defined(MEDIAINFO_MPEGA_YES)
+ Parser=new File_Mpega();
+ Open_Buffer_Init(Parser);
+ GoTo(Audio_Offset, "DPG");
+ #elif defined(MEDIAINFO_MPEGV_YES)
+ Audio_Size=0;
+ Parser=new File_Mpegv();
+ Open_Buffer_Init(Parser);
+ GoTo(Video_Offset, "DPG");
+ #else
+ Finish("DPG");
+ #endif
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dpg::Read_Buffer_Continue()
+{
+ if (!Parser)
+ return; //Not ready
+
+ if (Audio_Size)
+ {
+ #if defined(MEDIAINFO_MPEGA_YES)
+ Open_Buffer_Continue(Parser, (size_t)((File_Offset+Buffer_Size<Audio_Offset+Audio_Size)?Buffer_Size:(Audio_Offset+Audio_Size-File_Offset)));
+ if (Parser->Status[IsAccepted])
+ {
+ Finish(Parser);
+ Merge(*Parser, Stream_Audio, 0, 0);
+ #if defined(MEDIAINFO_MPEGV_YES)
+ Audio_Size=0;
+ Open_Buffer_Unsynch();
+ Data_GoTo(Video_Offset, "DPG");
+ delete Parser; Parser=new File_Mpegv();
+ Open_Buffer_Init(Parser);
+ #else
+ Finish("DPG");
+ #endif
+ }
+ #endif
+ }
+ else
+ {
+ #if defined(MEDIAINFO_MPEGV_YES)
+ Open_Buffer_Continue(Parser, (size_t)((File_Offset+Buffer_Size<Video_Offset+Video_Size)?Buffer_Size:(Video_Offset+Video_Size-File_Offset)));
+ if (Parser->Status[IsAccepted])
+ {
+ //Merging
+ Finish(Parser);
+ Merge(*Parser, Stream_Video, 0, 0);
+
+ Finish("DPG");
+ }
+ #endif
+ }
+
+ //Positioning
+ Buffer_Offset=Buffer_Size; //We have already parsed this data
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_DPG_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dpg.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dpg.h
new file mode 100644
index 000000000..a67b09617
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dpg.h
@@ -0,0 +1,71 @@
+// File_Dpg - Info for DPG files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about DPG (Nintendo DS) files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_DpgH
+#define MediaInfo_File_DpgH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Dpg
+//***************************************************************************
+
+class File_Dpg : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Dpg();
+ ~File_Dpg();
+
+private :
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer
+ void Read_Buffer_Continue();
+
+ //Elements
+ void Audio();
+ void Video();
+
+ //Data
+ File__Analyze* Parser;
+
+ //Temp
+ int32u Audio_Offset;
+ int32u Audio_Size;
+ int32u Video_Offset;
+ int32u Video_Size;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif.cpp
new file mode 100644
index 000000000..e4e32a8ad
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif.cpp
@@ -0,0 +1,1842 @@
+// File_DvDif - Info for DV-DIF files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DVDIF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_DvDif.h"
+#if defined(MEDIAINFO_EIA608_YES)
+ #include "MediaInfo/Text/File_Eia608.h"
+#endif
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#if MEDIAINFO_SEEK
+ #include "MediaInfo/MediaInfo_Internal.h"
+#endif //MEDIAINFO_SEEK
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+const char* Dv_sct[]=
+{
+ "Header",
+ "Subcode",
+ "VAUX",
+ "Audio",
+ "Video",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Dv_Ssyb_Pc0(int8u Pc0)
+{
+ switch (Pc0)
+ {
+ case 0x13 : return "Timecode";
+ case 0x14 : return "Binary group";
+ case 0x50 :
+ case 0x60 : return "Source";
+ case 0x51 :
+ case 0x61 : return "Source control";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Dv_Disp[]=
+{
+ "4/3", //S306M, S314M
+ "16/9", //S306M
+ "16/9", //S306M, S314M
+ "4/3", //Which spec?
+ "",
+ "",
+ "",
+ "16/9 or 4/3 depends of ssyb AP3", //Which spec?
+};
+
+//---------------------------------------------------------------------------
+const int32u Dv_Audio_SamplingRate[]=
+{
+ 48000,
+ 44100,
+ 32000,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+const char* Dv_StereoMode[]=
+{
+ "Multi-Stero",
+ "Lumped",
+};
+
+//---------------------------------------------------------------------------
+const int32u Dv_Audio_BitDepth[]=
+{
+ 16,
+ 12,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+const int8u Dv_ChannelsPerBlock[]=
+{
+ 1,
+ 2,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+const char* Dv_Pair[]=
+{
+ "One pair of channels",
+ "Independent channels",
+};
+
+//---------------------------------------------------------------------------
+const char* Dv_CopyGenerationManagementSystem[]=
+{
+ "Unrestricted",
+ "Not used",
+ "One generation only",
+ "No copy",
+};
+
+//---------------------------------------------------------------------------
+const char* Dv_InputType[]=
+{
+ "Analog",
+ "Digital",
+ "Reserved",
+ "No information",
+};
+
+//---------------------------------------------------------------------------
+const char* Dv_CompressionTimes[]=
+{
+ "Once",
+ "Twice",
+ "Three+",
+ "No information",
+};
+
+//---------------------------------------------------------------------------
+const char* Dv_Emphasis[]=
+{
+ "Enphasis off",
+ "Enphasis on",
+ "Reserved",
+ "Reserved",
+};
+
+//---------------------------------------------------------------------------
+const char* Dv_consumer_camera_1_ae_mode[]=
+{
+ "full automatic",
+ "gain priority mode",
+ "shutter priority mode",
+ "iris priority mode",
+ "manual",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "", //no info
+};
+
+//---------------------------------------------------------------------------
+const char* Dv_consumer_camera_1_wb_mode[]=
+{
+ "automatic",
+ "hold",
+ "one push",
+ "pre-set",
+ "",
+ "",
+ "",
+ "", //no info
+};
+
+//---------------------------------------------------------------------------
+const char* Dv_consumer_camera_1_white_balance(int8u white_balance)
+{
+ switch (white_balance)
+ {
+ case 0x00 : return "candle";
+ case 0x01 : return "incandescent lamp";
+ case 0x02 : return "low color temperature; florescent lamp";
+ case 0x03 : return "high color temperature; florescent lamp";
+ case 0x04 : return "sunlight";
+ case 0x05 : return "cloudy weather";
+ case 0x1F : return ""; //No info
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Dv_consumer_camera_1_fcm[]=
+{
+ "auto focus",
+ "manual focus",
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_DvDif::File_DvDif()
+:File__Analyze()
+{
+ //Configuration
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+
+ //In
+ Frame_Count_Valid=2;
+ AuxToAnalyze=0x00; //No Aux to analyze
+ IgnoreAudio=false;
+
+ //Temp
+ FrameSize_Theory=0;
+ Duration=0;
+ TimeCode_First=(int64u)-1;
+ Synched_Test_Reset();
+ DSF_IsValid=false;
+ APT=0xFF; //Impossible
+ video_source_stype=0xFF;
+ audio_source_stype=0xFF;
+ ssyb_AP3=0xFF;
+ TF1=false; //Valid by default, for direct analyze
+ TF2=false; //Valid by default, for direct analyze
+ TF3=false; //Valid by default, for direct analyze
+ system=false;
+ FSC_WasSet=false;
+ FSP_WasNotSet=false;
+ video_sourcecontrol_IsParsed=false;
+ audio_locked=false;
+
+ #if MEDIAINFO_SEEK
+ Duration_Detected=false;
+ #endif //MEDIAINFO_SEEK
+
+ #ifdef MEDIAINFO_DVDIF_ANALYZE_YES
+ Analyze_Activated=false;
+ video_source_Detected=false;
+ Speed_FrameCount=0;
+ Speed_FrameCount_Video_STA_Errors=0;
+ Speed_FrameCount_Audio_Errors.resize(8);
+ Speed_FrameCount_Timecode_Incoherency=0;
+ Speed_FrameCount_Contains_NULL=0;
+ Speed_Contains_NULL=0;
+ Speed_FrameCount_Arb_Incoherency=0;
+ Speed_FrameCount_Stts_Fluctuation=0;
+ System_IsValid=false;
+ Frame_AtLeast1DIF=false;
+ QU=(int8u)-1;
+ CH_IsPresent.resize(8);
+ Speed_TimeCode_IsValid=false;
+ Speed_Arb_IsValid=false;
+ Mpeg4_stts=NULL;
+ Mpeg4_stts_Pos=0;
+ Stats.resize(10);
+ Stats_Total=0;
+ Stats_Total_WithoutArb=0;
+ Stats_Total_AlreadyDetected=false;
+ #endif //MEDIAINFO_DVDIF_ANALYZE_YES
+}
+
+//---------------------------------------------------------------------------
+File_DvDif::~File_DvDif()
+{
+ for (size_t Pos=0; Pos<Streams_Audio.size(); Pos++)
+ delete Streams_Audio[Pos];
+
+ #if defined(MEDIAINFO_EIA608_YES)
+ for (size_t Pos=0; Pos<CC_Parsers.size(); Pos++)
+ delete CC_Parsers[Pos]; //CC_Parsers[Pos]=NULL;
+ #endif
+ #if defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ delete Mpeg4_stts; //Mpeg4_stts=NULL;
+ #endif
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DvDif::Streams_Fill()
+{
+ Fill(Stream_General, 0, General_Format, "DV", Unlimited, true, true);
+
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "DV");
+ Fill(Stream_Video, 0, Video_Codec, "DV");
+ Fill(Stream_Video, 0, Video_Standard, system?"PAL":"NTSC");
+ Fill(Stream_Video, 0, Video_BitDepth, 8);
+ bool IsHd=false;
+ switch (video_source_stype)
+ {
+ case 0x00 :
+ case 0x04 :
+ Fill(Stream_Video, 0, Video_Width, 720);
+ Fill(Stream_Video, 0, Video_Height, system?576:480);
+ break;
+ case 0x14 :
+ case 0x15 :
+ Fill(Stream_Video, 0, Video_Width, system?1440:1280);
+ Fill(Stream_Video, 0, Video_Height, video_source_stype==0x14?1080:1035);
+ IsHd=true;
+ break;
+ case 0x18 :
+ Fill(Stream_Video, 0, Video_Width, 960);
+ Fill(Stream_Video, 0, Video_Height, 720);
+ IsHd=true;
+ break;
+ default : ;
+ }
+ Fill(Stream_Video, 0, Video_FrameRate, system?25.000:29.970);
+ Fill(Stream_Video, 0, Video_FrameRate_Mode, "CFR");
+ if (video_sourcecontrol_IsParsed)
+ {
+ if (FSC_WasSet && FSP_WasNotSet)
+ {
+ switch (video_source_stype)
+ {
+ case 0x14 :
+ case 0x15 :
+ Fill(Stream_Video, 0, Video_ScanType, "Interlaced");
+ Fill(Stream_Video, 0, Video_Interlacement, "Interlaced");
+ break;
+ case 0x18 :
+ Fill(Stream_Video, 0, Video_ScanType, "Progressive");
+ Fill(Stream_Video, 0, Video_Interlacement, "Progressive");
+ break;
+ default : ;
+ }
+ }
+ else if (Interlaced)
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Interlaced");
+ if (FieldOrder_FF)
+ Fill(Stream_Video, 0, Video_ScanOrder, FieldOrder_FS?"BFF":"TFF");
+ else
+ Fill(Stream_Video, 0, Video_ScanOrder, FieldOrder_FS?"Bottom field only":"Top field only");
+ Fill(Stream_Video, 0, Video_Interlacement, "Interlaced");
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_ScanType, Interlaced?"Interlaced":"Progressive");
+ Fill(Stream_Video, 0, Video_Interlacement, Interlaced?"Interlaced":"PFF");
+ }
+ switch (aspect)
+ {
+ case 0 :
+ case 4 : Fill(Stream_Video, 0, Video_DisplayAspectRatio, 4.0/3.0, 3, true); break;
+ case 1 :
+ case 2 : Fill(Stream_Video, 0, Video_DisplayAspectRatio, 16.0/9.0, 3, true); break;
+ case 7 : switch (ssyb_AP3)
+ {
+ case 0 : Fill(Stream_Video, 0, Video_DisplayAspectRatio, 16.0/9.0, 3, true); break;
+ case 7 : Fill(Stream_Video, 0, Video_DisplayAspectRatio, 4.0/3.0, 3, true); break;
+ default: ; //No indication of aspect ratio?
+ }
+ default: ;
+ }
+ }
+
+ if (!FSC_WasSet) //Original DV 25 Mbps
+ {
+ if (system==false) //NTSC
+ {
+ switch (video_source_stype)
+ {
+ case 0 : Fill(Stream_Video, 0, Video_Colorimetry, "4:1:1"); break; //NTSC 25 Mbps
+ default : ;
+ }
+ }
+ else //PAL
+ {
+ switch (video_source_stype)
+ {
+ case 0 : if (APT==0)
+ Fill(Stream_Video, 0, Video_Colorimetry, "4:2:0"); //PAL 25 Mbps (IEC 61834)
+ else
+ Fill(Stream_Video, 0, Video_Colorimetry, "4:1:1"); //PAL 25 Mbps (SMPTE 314M)
+ break;
+ default : ;
+ }
+ }
+ }
+ else //DV 50 Mbps and 100 Mbps
+ Fill(Stream_Video, 0, Video_Colorimetry, "4:2:2");
+
+ if (FrameSize_Theory && !IsHd)
+ {
+ float64 OverallBitRate=FrameSize_Theory*(DSF?((float64)25.000):((float64)30000/1001))*8;
+ if (FSC_WasSet)
+ {
+ if (FSP_WasNotSet)
+ OverallBitRate*=4; //DV100
+ else
+ OverallBitRate*=2; //DV50
+ }
+ if (OverallBitRate)
+ {
+ if (IsSub)
+ Fill(Stream_Video, 0, Video_BitRate_Encoded, OverallBitRate, 0);
+ else
+ Fill(Stream_General, 0, General_OverallBitRate, OverallBitRate, 0);
+ Fill(Stream_Video, 0, (FSC_WasSet && FSP_WasNotSet)?Video_BitRate_Maximum:Video_BitRate, OverallBitRate*134/150*76/80, 0); //134 Video DIF from 150 DIF, 76 bytes from 80 byte DIF
+ }
+ }
+
+ if (!Config->File_DvDif_DisableAudioIfIsInContainer_Get())
+ for (size_t Pos=0; Pos<Streams_Audio.size(); Pos++)
+ {
+ Stream_Prepare(Stream_Audio);
+ for (std::map<std::string, Ztring>::iterator Info=Streams_Audio[Pos]->Infos.begin(); Info!=Streams_Audio[Pos]->Infos.end(); Info++)
+ Fill(Stream_Audio, StreamPos_Last, Info->first.c_str(), Info->second, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate_Encoded, 0);
+ }
+
+ if (Stream_BitRateFromContainer && Retrieve(Stream_Video, 0, Video_BitRate).empty())
+ {
+ if (Stream_BitRateFromContainer>=28800000*0.98 && Stream_BitRateFromContainer<=28800000*1.02)
+ {
+ Fill(Stream_Video, 0, Video_BitRate, ((float64)28800000)*134/150*76/80, 0);
+ Fill(Stream_Video, 0, Video_BitRate_Encoded, 28800000);
+ }
+ if (Stream_BitRateFromContainer>=57600000*0.98 && Stream_BitRateFromContainer<=57600000*1.02)
+ {
+ Fill(Stream_Video, 0, Video_BitRate, ((float64)57600000)*134/150*76/80, 0);
+ Fill(Stream_Video, 0, Video_BitRate_Encoded, 57600000);
+ }
+ if (Stream_BitRateFromContainer>=115200000*0.98 && Stream_BitRateFromContainer<=115200000*1.02)
+ {
+ Fill(Stream_Video, 0, Video_BitRate, ((float64)115200000)*134/150*76/80, 0);
+ Fill(Stream_Video, 0, Video_BitRate_Encoded, 115200000);
+ }
+ }
+
+ //Library settings
+ Fill(Stream_Video, 0, Video_Encoded_Library_Settings, Encoded_Library_Settings);
+
+ //Profile
+ if (FSC_WasSet || IsHd)
+ {
+ if (FSP_WasNotSet || IsHd)
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "DVCPRO HD");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "DVCPRO HD");
+ Fill(Stream_Video, 0, Video_BitDepth, 10, 10, true); //MXF files say that DVCPRO HD are 10 bits, exact?
+ }
+ else
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "DVCPRO 50");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "DVCPRO 50");
+ Fill(Stream_Video, 0, Video_BitRate_Mode, "CBR");
+ }
+ }
+ else if (audio_locked || (Retrieve(Stream_Video, 0, Video_Standard)==_T("PAL") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:1:1")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "DVCPRO");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "DVCPRO");
+ Fill(Stream_Video, 0, Video_BitRate_Mode, "CBR");
+ }
+ else
+ Fill(Stream_Video, 0, Video_BitRate_Mode, "CBR");
+
+ //Delay
+ if (TimeCode_First!=(int64u)-1)
+ {
+ Fill(Stream_Video, 0, Video_Delay, TimeCode_First);
+ Fill(Stream_Video, 0, Video_Delay_Source, "Stream");
+ for (size_t Pos=0; Pos<Count_Get(Stream_Audio); Pos++)
+ {
+ Fill(Stream_Audio, Pos, Audio_Delay, TimeCode_First);
+ Fill(Stream_Audio, Pos, Audio_Delay_Source, "Stream");
+ }
+ }
+
+ #if defined(MEDIAINFO_EIA608_YES)
+ for (size_t Pos=0; Pos<CC_Parsers.size(); Pos++)
+ if (CC_Parsers[Pos] && CC_Parsers[Pos]->Status[IsAccepted])
+ {
+ Finish(CC_Parsers[Pos]);
+ for (size_t Pos2=0; Pos2<CC_Parsers[Pos]->Count_Get(Stream_Text); Pos2++)
+ {
+ Stream_Prepare(Stream_Text);
+ Merge(*CC_Parsers[Pos], Stream_Text, Pos2, StreamPos_Last);
+ Fill(Stream_Text, StreamPos_Last, Text_ID, CC_Parsers[Pos]->Retrieve(Stream_Text, Pos2, Text_ID), true);
+ }
+ }
+ #endif //defined(MEDIAINFO_EIA608_YES)
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::Streams_Finish()
+{
+ if (!Recorded_Date_Date.empty())
+ {
+ Ztring Recorded_Date(Recorded_Date_Date);
+ if (Recorded_Date_Time.size()>4)
+ {
+ Recorded_Date+=_T(" ");
+ Recorded_Date+=Recorded_Date_Time;
+ }
+ if (Count_Get(Stream_General)==0)
+ Stream_Prepare(Stream_General);
+ Fill(Stream_General, 0, General_Recorded_Date, Recorded_Date, true);
+ }
+ if (!IsSub && Duration)
+ Fill(Stream_General, 0, General_Duration, Duration);
+
+ #ifdef MEDIAINFO_DVDIF_ANALYZE_YES
+ if (Config->File_DvDif_Analysis_Get())
+ {
+ //Errors stats
+ Status[IsFinished]=true; //We need to fill it before the call to Errors_Stats_Update
+ Errors_Stats_Update();
+ Errors_Stats_Update_Finnish();
+ }
+ #endif //MEDIAINFO_DVDIF_ANALYZE_YES
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_DvDif::FileHeader_Begin()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Size<8)
+ return false; //Must wait for more data
+
+ //False positives detection: detect some headers from other files, DV parser is not smart enough
+ if (CC4(Buffer)==0x52494646 //RIFF
+ || CC4(Buffer+4)==0x66747970 //ftyp
+ || CC4(Buffer+4)==0x66726565 //free
+ || CC4(Buffer+4)==0x6D646174 //mdat
+ || CC4(Buffer+4)==0x6D6F6F76 //moov
+ || CC4(Buffer+4)==0x736B6970 //skip
+ || CC4(Buffer+4)==0x77696465 //wide
+ || CC4(Buffer)==0x060E2B34) //MXF begin
+ {
+ Finish();
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_DvDif::Synchronize()
+{
+ if (AuxToAnalyze)
+ {
+ Accept();
+ return true;
+ }
+
+ while (Buffer_Offset+8*80<=Buffer_Size //8 blocks
+ && !((Buffer[Buffer_Offset+0*80]&0xE0)==0x00 && (Buffer[Buffer_Offset+0*80+1]&0xF0)==0x00 && Buffer[Buffer_Offset+0*80+2]==0x00 //Header 0
+ && (Buffer[Buffer_Offset+1*80]&0xE0)==0x20 && (Buffer[Buffer_Offset+1*80+1]&0xF0)==0x00 && Buffer[Buffer_Offset+1*80+2]==0x00 //Subcode 0
+ && (Buffer[Buffer_Offset+2*80]&0xE0)==0x20 && (Buffer[Buffer_Offset+2*80+1]&0xF0)==0x00 && Buffer[Buffer_Offset+2*80+2]==0x01 //Subcode 1
+ && (Buffer[Buffer_Offset+3*80]&0xE0)==0x40 && (Buffer[Buffer_Offset+3*80+1]&0xF0)==0x00 && Buffer[Buffer_Offset+3*80+2]==0x00 //VAUX 0
+ && (Buffer[Buffer_Offset+4*80]&0xE0)==0x40 && (Buffer[Buffer_Offset+4*80+1]&0xF0)==0x00 && Buffer[Buffer_Offset+4*80+2]==0x01 //VAUX 1
+ && (Buffer[Buffer_Offset+5*80]&0xE0)==0x40 && (Buffer[Buffer_Offset+5*80+1]&0xF0)==0x00 && Buffer[Buffer_Offset+5*80+2]==0x02 //VAUX 2
+ && (Buffer[Buffer_Offset+6*80]&0xE0)==0x60 && (Buffer[Buffer_Offset+6*80+1]&0xF0)==0x00 && Buffer[Buffer_Offset+6*80+2]==0x00 //Audio 0
+ && (Buffer[Buffer_Offset+7*80]&0xE0)==0x80 && (Buffer[Buffer_Offset+7*80+1]&0xF0)==0x00 && Buffer[Buffer_Offset+7*80+2]==0x00)) //Video 0
+ Buffer_Offset++;
+
+ if (Buffer_Offset+8*80>Buffer_Size)
+ return false;
+
+ if (!Status[IsAccepted])
+ Accept();
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_DvDif::Synched_Test()
+{
+ if (AuxToAnalyze)
+ return true;
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+80>Buffer_Size)
+ return false;
+
+ //NULL blocks
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x00)
+ return true;
+
+ SCT =(Buffer[Buffer_Offset ]&0xE0)>>5;
+ DBN = Buffer[Buffer_Offset+2];
+
+ //DIF Sequence Numbers
+ if (DSF_IsValid)
+ {
+ if (Dseq_Old!=Dseq)
+ {
+ if (Dseq==0
+ && !(!DSF && Dseq_Old==9)
+ && !( DSF && Dseq_Old==11))
+ {
+ if (!Status[IsAccepted])
+ Trusted_IsNot("Wrong order");
+ else
+ Synched_Test_Reset();
+ }
+ Dseq_Old=Dseq;
+ }
+ }
+
+ //DIF Block Numbers
+ if (SCT!=(int8u)-1)
+ {
+ int8u Number=DBN_Olds[SCT]+1;
+ switch (SCT)
+ {
+ case 0 : //Header
+ if (SCT_Old!=4
+ || DBN!=0)
+ {
+ if (!Status[IsAccepted])
+ Trusted_IsNot("Wrong order");
+ else
+ Synched_Test_Reset();
+ }
+ break;
+ case 1 : //Subcode
+ if (!((DBN==0 && SCT_Old==0) || (DBN!=0 && SCT_Old==1))
+ || (Number!=DBN && !(Number==2 && DBN==0)))
+ {
+ if (!Status[IsAccepted])
+ Trusted_IsNot("Wrong order");
+ else
+ Synched_Test_Reset();
+ }
+ break;
+ case 2 : //VAUX
+ if (!((DBN==0 && SCT_Old==1) || (DBN!=0 && SCT_Old==2))
+ || (Number!=DBN && !(Number==3 && DBN==0)))
+ {
+ if (!Status[IsAccepted])
+ Trusted_IsNot("Wrong order");
+ else
+ Synched_Test_Reset();
+ }
+ break;
+ case 3 : //Audio
+ if (!((DBN==0 && SCT_Old==2) || (DBN!=0 && SCT_Old==4))
+ || (Number!=DBN && !(Number==9 && DBN==0)))
+ {
+ if (!Status[IsAccepted])
+ Trusted_IsNot("Wrong order");
+ else
+ Synched_Test_Reset();
+ }
+ break;
+ case 4 : //Video
+ if (!(SCT_Old==3 || SCT_Old==4)
+ || (Number!=DBN && !(Number==135 && DBN==0)))
+ {
+ if (!Status[IsAccepted])
+ Trusted_IsNot("Wrong order");
+ else
+ Synched_Test_Reset();
+ }
+ break;
+ default: ;
+ }
+
+ if (SCT!=(int8u)-1)
+ {
+ SCT_Old=SCT;
+ DBN_Olds[SCT]=DBN;
+ }
+ }
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::Synched_Test_Reset()
+{
+ //Temp
+ SCT=(int8u)-1;
+ SCT_Old=4; //Video
+ DBN_Olds[0]=0;
+ DBN_Olds[1]=1; //SubCode
+ DBN_Olds[2]=2; //Vaux
+ DBN_Olds[3]=8; //Audio
+ DBN_Olds[4]=134; //Video
+ DBN_Olds[5]=0;
+ DBN_Olds[6]=0;
+ DBN_Olds[7]=0;
+
+ //Synch
+ Synched=false;
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::Synched_Init()
+{
+ //FrameInfo
+ if (FrameInfo.DTS==(int64u)-1)
+ FrameInfo.DTS=0; //No DTS in container
+ if (FrameInfo.PTS==(int64u)-1)
+ FrameInfo.PTS=0; //No PTS in container
+ if (Frame_Count_NotParsedIncluded==(int64u)-1)
+ Frame_Count_NotParsedIncluded=0; //No Frame_Count_NotParsedIncluded in the container
+}
+
+//***************************************************************************
+// Buffer - Demux
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+bool File_DvDif::Demux_UnpacketizeContainer_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+8*80>Buffer_Size)
+ return false;
+
+ if ((Buffer[Buffer_Offset]&0xE0)==0x00 //Speed up the parsing
+ && (CC3(Buffer+Buffer_Offset+0*80)&0xE0FCFF)==0x000400 //Header 0 (with FSC==false and FSP==true)
+ && (CC3(Buffer+Buffer_Offset+1*80)&0xE0F0FF)==0x200000 //Subcode 0
+ && (CC3(Buffer+Buffer_Offset+2*80)&0xE0F0FF)==0x200001 //Subcode 1
+ && (CC3(Buffer+Buffer_Offset+3*80)&0xE0F0FF)==0x400000 //VAUX 0
+ && (CC3(Buffer+Buffer_Offset+4*80)&0xE0F0FF)==0x400001 //VAUX 1
+ && (CC3(Buffer+Buffer_Offset+5*80)&0xE0F0FF)==0x400002 //VAUX 2
+ && (CC3(Buffer+Buffer_Offset+6*80)&0xE0F0FF)==0x600000 //Audio 0
+ && (CC3(Buffer+Buffer_Offset+7*80)&0xE0F0FF)==0x800000) //Video 0
+ {
+ if (Demux_Offset==0)
+ {
+ Demux_Offset=Buffer_Offset+1;
+ }
+
+ while (Demux_Offset+8*80<=Buffer_Size //8 blocks
+ && !((Buffer[Demux_Offset]&0xE0)==0x00 //Speed up the parsing
+ && (CC3(Buffer+Demux_Offset+0*80)&0xE0FCFF)==0x000400 //Header 0 (with FSC==false and FSP==true)
+ && (CC3(Buffer+Demux_Offset+1*80)&0xE0F0FF)==0x200000 //Subcode 0
+ && (CC3(Buffer+Demux_Offset+2*80)&0xE0F0FF)==0x200001 //Subcode 1
+ && (CC3(Buffer+Demux_Offset+3*80)&0xE0F0FF)==0x400000 //VAUX 0
+ && (CC3(Buffer+Demux_Offset+4*80)&0xE0F0FF)==0x400001 //VAUX 1
+ && (CC3(Buffer+Demux_Offset+5*80)&0xE0F0FF)==0x400002 //VAUX 2
+ && (CC3(Buffer+Demux_Offset+6*80)&0xE0F0FF)==0x600000 //Audio 0
+ && (CC3(Buffer+Demux_Offset+7*80)&0xE0F0FF)==0x800000)) //Video 0
+ Demux_Offset++;
+
+ if (Demux_Offset+8*80>Buffer_Size && File_Offset+Buffer_Size!=File_Size)
+ return false; //No complete frame
+ if (Demux_Offset+8*80>Buffer_Size && File_Offset+Buffer_Size==File_Size)
+ Demux_Offset=(size_t)(File_Size-File_Offset); //Using the complete buffer (no next sync)
+
+ Demux_UnpacketizeContainer_Demux();
+ }
+
+ return true;
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DvDif::Read_Buffer_Unsynched()
+{
+ Synched_Test_Reset();
+ if (!IsSub && File_GoTo!=(int64u)-1 && (Frame_Count
+ #if MEDIAINFO_SEEK
+ || Duration_Detected
+ #endif //MEDIAINFO_SEEK
+ ) && !FSP_WasNotSet)
+ {
+ int64u BytesPerFrame=12000*(DSF?12:10);
+ if (FSC_WasSet)
+ BytesPerFrame*=2;
+ Frame_Count_NotParsedIncluded=File_GoTo/BytesPerFrame;
+ FrameInfo.PTS=FrameInfo.DTS=float64_int64s(Frame_Count_NotParsedIncluded/(DSF?25.000:(30.000*1000/1001))*1000000000);
+ }
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_DvDif::Read_Buffer_Seek (size_t Method, int64u Value, int64u /*ID*/)
+{
+ //Init
+ if (!Duration_Detected)
+ {
+ MediaInfo_Internal MI;
+ MI.Option(_T("File_KeepInfo"), _T("1"));
+ Ztring ParseSpeed_Save=MI.Option(_T("ParseSpeed_Get"), _T(""));
+ Ztring Demux_Save=MI.Option(_T("Demux_Get"), _T(""));
+ MI.Option(_T("ParseSpeed"), _T("0"));
+ MI.Option(_T("Demux"), Ztring());
+ size_t MiOpenResult=MI.Open(File_Name);
+ MI.Option(_T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
+ MI.Option(_T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
+ if (!MiOpenResult || MI.Get(Stream_General, 0, General_Format)!=_T("DV"))
+ return 0;
+
+ TotalFrames=Ztring(MI.Get(Stream_Video, 0, Video_FrameCount)).To_int64u();
+ int64u VideoBitRate=Ztring(MI.Get(Stream_Video, 0, Video_BitRate)).To_int64u();
+ if (VideoBitRate==0 || VideoBitRate>=50000000)
+ {
+ FSC_WasSet=true;
+ FSP_WasNotSet=true;
+ }
+ else if (VideoBitRate>=30000000)
+ FSC_WasSet=true;
+ float32 FrameRate=Ztring(MI.Get(Stream_Video, 0, Video_FrameRate)).To_float32();
+ if (FrameRate>=24.0 && FrameRate<26.0)
+ DSF=system=true;
+ if (FrameRate>=29.0 && FrameRate<31.0)
+ DSF=system=false;
+ Duration_Detected=true;
+ }
+
+ //Parsing
+ switch (Method)
+ {
+ case 0 :
+ GoTo(Value);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 1 :
+ GoTo(File_Size*Value/10000);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 2 : //Timestamp
+ {
+ //We transform TimeStamp to a frame number
+ Value=float64_int64s(((float64)Value)*(DSF?25.000:(30.000*1000/1001))/1000000000);
+ }
+ //No break;
+ case 3 : //FrameNumber
+ if (!FSP_WasNotSet)
+ {
+ int64u BytesPerFrame=12000*(DSF?12:10);
+ if (FSC_WasSet)
+ BytesPerFrame*=2;
+ GoTo(BytesPerFrame*Value);
+ Open_Buffer_Unsynch();
+ Frame_Count_NotParsedIncluded=Value;
+ FrameInfo.PTS=FrameInfo.DTS=float64_int64s(Frame_Count_NotParsedIncluded/(DSF?25.000:(30.000*1000/1001))*1000000000);
+ return 1;
+ }
+ else
+ return (size_t)-1; //Not supported
+ default : return (size_t)-1; //Not supported
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DvDif::Header_Parse()
+#if MEDIAINFO_TRACE
+{
+ if (AuxToAnalyze!=0x00)
+ {
+ SCT=(int8u)-1;
+ Header_Fill_Code(AuxToAnalyze, Ztring::ToZtring(AuxToAnalyze, 16));
+ Header_Fill_Size(4);
+ return;
+ }
+
+ //Unsynch problems
+ if (Element_Size<80)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x00)
+ {
+ SCT=(int8u)-1;
+ Header_Fill_Code((int64u)-1);
+ Header_Fill_Size(80);
+ return;
+ }
+
+ //Parsing
+ BS_Begin();
+ //0
+ Get_S1 (3, SCT, "SCT - Section Type"); Param_Info1(Dv_sct[SCT]);
+ Skip_SB( "Res - Reserved");
+ Skip_S1(4, "Arb - Arbitrary bits");
+ //1
+ Get_S1 (4, Dseq, "Dseq - DIF sequence number"); //0-9 for 525/60; 0-11 for 625/50
+ Get_SB ( FSC, "FSC - Channel number");
+ Get_SB ( FSP, "FSP - Channel number"); //SMPTE 370M only
+ Skip_S1(2, "Res - Reserved");
+ BS_End();
+ //2
+ Get_B1 (DBN, "DBN - DIF block number"); //Video: 0-134, Audio: 0-8
+
+ Header_Fill_Code(SCT, Dv_sct[SCT]);
+ Header_Fill_Size(80);
+}
+#else //MEDIAINFO_TRACE
+{
+ if (AuxToAnalyze!=0x00)
+ {
+ SCT=(int8u)-1;
+ Header_Fill_Code(AuxToAnalyze);
+ Header_Fill_Size(4);
+ return;
+ }
+
+ //Unsynch problems
+ if (Element_Size<80)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x00)
+ {
+ SCT=(int8u)-1;
+ Header_Fill_Code((int64u)-1);
+ Header_Fill_Size(80);
+ return;
+ }
+
+ //Parsing
+ SCT =(Buffer[Buffer_Offset ]&0xE0)>>5;
+ Dseq=(Buffer[Buffer_Offset+1]&0xF0)>>4;
+ FSC =(Buffer[Buffer_Offset+1]&0x08)==0x08;
+ FSP =(Buffer[Buffer_Offset+1]&0x04)==0x04;
+ DBN = Buffer[Buffer_Offset+2];
+ Element_Offset+=3;
+
+ Header_Fill_Code(SCT);
+ Header_Fill_Size(80);
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+void File_DvDif::Data_Parse()
+{
+ if (Element_Code==(int64u)-1)
+ {
+ Skip_XX(Element_Size, "Junk");
+ return;
+ }
+
+ //Config
+ if (SCT!=(int8u)-1)
+ {
+ if (!FSC_WasSet && FSC)
+ FSC_WasSet=true;
+
+ if (!FSP_WasNotSet && !FSP)
+ FSP_WasNotSet=true;
+ }
+
+ if (AuxToAnalyze!=0x00)
+ {
+ Element();
+ return;
+ }
+
+ Element_Info1(DBN);
+
+ switch (SCT)
+ {
+ case 0 : Header(); break;
+ case 1 : Subcode(); break;
+ case 2 : VAUX(); break;
+ case 3 : Audio(); break;
+ case 4 : Video(); break;
+ default: Skip_XX(Element_Size, "Unknown");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DvDif::Header()
+#if MEDIAINFO_TRACE
+{
+ BS_Begin();
+ //3
+ Get_SB ( DSF, "DSF - DIF Sequence Flag"); //0=NTSC, 1=PAL
+ Skip_SB( "Zero");
+ Skip_S1(6, "Reserved");
+
+ //4
+ Skip_S1(5, "Reserved");
+ Get_S1 (3, APT, "APT"); //Track application ID, 0=4:2:0, 1=not 4:2:0
+
+ //5
+ Get_SB ( TF1, "TF1 - Audio data is not valid");
+ Skip_S1(4, "Reserved");
+ Skip_S1(3, "AP1 - Audio application ID");
+
+ //6
+ Get_SB ( TF2, "TF2 - Video data is not valid");
+ Skip_S1(4, "Reserved");
+ Skip_S1(3, "AP2 - Video application ID");
+
+ //7
+ Get_SB ( TF3, "TF3 - Subcode is not valid");
+ Skip_S1(4, "Reserved");
+ Skip_S1(3, "AP3 - Subcode application ID");
+
+ //8-79
+ BS_End();
+ Skip_XX(72, "Reserved"); //Should be filled with 0xFF
+
+ if (Config->File_DvDif_IgnoreTransmittingFlags_Get())
+ {
+ TF1=false;
+ TF2=false;
+ TF3=false;
+ }
+
+ FILLING_BEGIN();
+ DSF_IsValid=true;
+ Dseq_Old=DSF?11:9;
+ FrameSize_Theory=(DSF?12:10)*150*80; //12 DIF sequences for PAL, 10 for NTSC
+
+ if (TF1 && TF2)
+ {
+ //This is not logic, the header says no audio and no video! We do not trust the header, resetting all
+ TF1=false;
+ TF2=false;
+ TF3=false;
+ }
+ FILLING_END();
+}
+#else //MEDIAINFO_TRACE
+{
+ if (Element_Size<77)
+ {
+ Trusted_IsNot("Size is wrong");
+ return;
+ }
+
+ DSF=(Buffer[Buffer_Offset ]&0x80)?true:false;
+ APT=(Buffer[Buffer_Offset+1]&0x07);
+ TF1=(Buffer[Buffer_Offset+2]&0x80)?true:false;
+ TF2=(Buffer[Buffer_Offset+3]&0x80)?true:false;
+ TF3=(Buffer[Buffer_Offset+4]&0x80)?true:false;
+
+ if (Config->File_DvDif_IgnoreTransmittingFlags_Get())
+ {
+ TF1=false;
+ TF2=false;
+ TF3=false;
+ }
+
+ FILLING_BEGIN();
+ DSF_IsValid=true;
+ Dseq_Old=DSF?11:9;
+ FrameSize_Theory=(DSF?12:10)*150*80; //12 DIF sequences for PAL, 10 for NTSC
+
+ if (TF1 && TF2)
+ {
+ //This is not logic, the header says no audio and no video! We do not trust the header, resetting all
+ TF1=false;
+ TF2=false;
+ TF3=false;
+ }
+ FILLING_END();
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+void File_DvDif::Subcode()
+#if MEDIAINFO_TRACE
+{
+ //Present?
+ if (TF3)
+ {
+ Skip_XX(Element_Size, "Unused");
+ return;
+ }
+
+ //Parsing
+ for (int8u syb_num=0; syb_num<6; syb_num++)
+ Subcode_Ssyb(syb_num);
+ Skip_XX(29, "Unused");
+}
+#else //MEDIAINFO_TRACE
+{
+ if (TF3)
+ return;
+
+ for (int8u syb_num=0; syb_num<6; syb_num++)
+ Subcode_Ssyb(syb_num);
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+void File_DvDif::Subcode_Ssyb(int8u syb_num)
+{
+ Element_Begin1("ssyb");
+
+ //Parsing
+ BS_Begin();
+ //ID0-ID1
+ Skip_SB( "FR - Identification of half of channel"); //1=first half, 0=second
+ if (syb_num==0)
+ {
+ if (FSC==false)
+ Get_S1 ( 3, ssyb_AP3, "AP3 - Subcode application ID");
+ else
+ Skip_S1( 3, "AP3 - Subcode application ID");
+ }
+ else if (DBN==1 && syb_num==5)
+ Skip_S1(3, "APT - track application ID");
+ else
+ Skip_S1(3, "Res - Reserved");
+ Skip_S1(8, "Arb - Arbitrary bits");
+ Skip_S1(4, "Syb - SSYSB number");
+ BS_End();
+ //FFh
+ Skip_B1( "0xFF");
+ //PC0-PC4
+ Element();
+
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::VAUX()
+{
+ //Present?
+ if (TF2)
+ {
+ Skip_XX(Element_Size, "Unused");
+ return;
+ }
+
+ //Parsing
+ for (int8u i=0; i<15; i++)
+ Element();
+ Skip_XX(2, "Unused");
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::Audio()
+{
+ //Present?
+ if (TF1)
+ {
+ Skip_XX(Element_Size, "Unused");
+ return;
+ }
+
+ Element_Name("Audio");
+
+ Element(); //First 5 bytes
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::Video()
+{
+ #if MEDIAINFO_TRACE
+ //Present?
+ if (TF2)
+ {
+ Skip_XX(Element_Size, "Unused");
+ return;
+ }
+
+ Element_Name("Video");
+
+ //Parsing
+ BS_Begin();
+ Skip_S1(4, "STA");
+ Skip_S1(4, "QNO");
+ BS_End();
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ #endif //MEDIAINFO_TRACE
+
+ FILLING_BEGIN();
+ if (DBN==134 && video_source_stype!=(int8u)-1)
+ {
+ if (!Status[IsAccepted])
+ {
+ Accept("DV DIF");
+
+ if (!IsSub)
+ Fill(Stream_General, 0, General_Format, "DV");
+ }
+ if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid)
+ #ifdef MEDIAINFO_DVDIF_ANALYZE_YES
+ {
+ if (Config->File_DvDif_Analysis_Get())
+ Fill("DV DIF");
+ else
+ Finish("DV DIF");
+ }
+ #else //MEDIAINFO_DVDIF_ANALYZE_YES
+ Finish("DV DIF");
+ #endif //MEDIAINFO_DVDIF_ANALYZE_YES
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::Element()
+{
+ Element_Begin0();
+ int8u PackType;
+ if (AuxToAnalyze==0x00)
+ Get_B1 (PackType, "Pack Type");
+ else
+ PackType=AuxToAnalyze; //Forced by parser
+
+ switch(PackType)
+ {
+ case 0x13 : timecode(); break;
+ case 0x14 : binary_group(); break;
+ case 0x50 : audio_source(); break;
+ case 0x51 : audio_sourcecontrol(); break;
+ case 0x52 : audio_recdate(); break;
+ case 0x53 : audio_rectime(); break;
+ case 0x60 : video_source(); break;
+ case 0x61 : video_sourcecontrol(); break;
+ case 0x62 : video_recdate(); break;
+ case 0x63 : video_rectime(); break;
+ case 0x65 : closed_captions(); break;
+ case 0x70 : consumer_camera_1(); break;
+ case 0x71 : consumer_camera_2(); break;
+ case 0xFF : Element_Name(Ztring().From_Number(PackType, 16));
+ Skip_B4( "Unused"); break;
+ default : Element_Name(Ztring().From_Number(PackType, 16));
+ Skip_B4( "Unknown");
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::binary_group()
+{
+ Element_Name("binary_group");
+
+ if (Buffer[Buffer_Offset+(size_t)Element_Offset ]==0xFF
+ && Buffer[Buffer_Offset+(size_t)Element_Offset+1]==0xFF
+ && Buffer[Buffer_Offset+(size_t)Element_Offset+2]==0xFF
+ && Buffer[Buffer_Offset+(size_t)Element_Offset+3]==0xFF
+ )
+ {
+ Skip_XX(4, "All one");
+ return;
+ }
+
+ //Parsing
+ BS_Begin();
+ Skip_S1(4, "Binary group 2");
+ Skip_S1(4, "Binary group 1");
+ Skip_S1(4, "Binary group 4");
+ Skip_S1(4, "Binary group 3");
+ Skip_S1(4, "Binary group 6");
+ Skip_S1(4, "Binary group 5");
+ Skip_S1(4, "Binary group 8");
+ Skip_S1(4, "Binary group 7");
+ BS_End();
+}
+
+
+//---------------------------------------------------------------------------
+void File_DvDif::timecode()
+{
+ Element_Name("timecode");
+
+ if (Buffer[Buffer_Offset+(size_t)Element_Offset ]==0x00
+ && Buffer[Buffer_Offset+(size_t)Element_Offset+1]==0x00
+ && Buffer[Buffer_Offset+(size_t)Element_Offset+2]==0x00
+ && Buffer[Buffer_Offset+(size_t)Element_Offset+3]==0x00
+ )
+ {
+ Skip_XX(4, "All zero");
+ return;
+ }
+
+ //PArsing
+ int8u Temp;
+ int64u MilliSeconds=0;
+ int8u Frames=0;
+ bool DropFrame=false;
+ BS_Begin();
+ Skip_SB( "CF - Color fame");
+ if (!DSF_IsValid)
+ Skip_SB( "Arbitrary bit or DP");
+ else if (DSF) //625/50
+ Skip_SB( "Arbitrary bit");
+ else //525/60
+ Get_SB (DropFrame, "DP - Drop frame"); //525/60
+ Get_S1 (2, Temp, "Frames (Tens)");
+ Frames+=Temp*10;
+ Get_S1 (4, Temp, "Frames (Units)");
+ Frames+=Temp;
+
+ if (!DSF_IsValid)
+ Skip_SB( "BGF0 or PC");
+ else if (DSF) //625/50
+ Skip_SB( "BGF0 - Binary group flag");
+ else //525/60
+ Skip_SB( "PC - Biphase mark polarity correction"); //0=even; 1=odd
+ Get_S1 (3, Temp, "Seconds (Tens)");
+ MilliSeconds+=Temp*10*1000;
+ Get_S1 (4, Temp, "Seconds (Units)");
+ MilliSeconds+=Temp*1000;
+
+ if (!DSF_IsValid)
+ Skip_SB( "BGF2 or BGF0");
+ else if (DSF) //625/50
+ Skip_SB( "BGF2 - Binary group flag");
+ else //525/60
+ Skip_SB( "BGF0 - Binary group flag");
+ Get_S1 (3, Temp, "Minutes (Tens)");
+ MilliSeconds+=Temp*10*60*1000;
+ Get_S1 (4, Temp, "Minutes (Units)");
+ MilliSeconds+=Temp*60*1000;
+
+ if (!DSF_IsValid)
+ Skip_SB( "PC or BGF1");
+ else if (DSF) //625/50
+ Skip_SB( "PC - Biphase mark polarity correction"); //0=even; 1=odd
+ else //525/60
+ Skip_SB( "BGF1 - Binary group flag");
+ Skip_SB( "BGF2 - Binary group flag");
+ Get_S1 (2, Temp, "Hours (Tens)");
+ MilliSeconds+=Temp*10*60*60*1000;
+ Get_S1 (4, Temp, "Hours (Units)");
+ MilliSeconds+=Temp*60*60*1000;
+ Element_Info1(Ztring().Duration_From_Milliseconds(MilliSeconds+((DSF_IsValid && Frames!=45)?((int64u)(Frames/(DSF?25.000:29.970)*1000)):0)));
+ BS_End();
+
+ if (TimeCode_First==(int64u)-1 && MilliSeconds!=167185000) //if all bits are set to 1, this is not a valid timestamp
+ {
+ TimeCode_First=MilliSeconds;
+ if (DSF_IsValid && Frames!=45) //all bits are set to 1
+ TimeCode_First+=(int64u)(Frames/(DSF?25.000:29.970)*1000);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::audio_source()
+{
+ if (TF1)
+ {
+ Skip_XX(4, "Unused");
+ return;
+ }
+
+ Element_Name("audio_source");
+
+ int8u SamplingRate, Resolution;
+ BS_Begin();
+ //PC1
+ Get_SB ( audio_locked, "LF - Locked mode");
+ Skip_SB( "Reserved");
+ Skip_S1(6, "AF - Samples in this frame");
+
+ //PC2
+ Info_S1(1, StereoMode, "SM - Stereo mode"); Param_Info1(Dv_StereoMode[StereoMode]);
+ Info_S1(2, ChannelsPerBlock, "CHN - Channels per block"); Param_Info1(Dv_ChannelsPerBlock[ChannelsPerBlock]);
+ Info_S1(1, Pair, "PA - Pair"); Param_Info1(Dv_Pair[Pair]);
+ Skip_S1(4, "AM - Audio mode");
+
+ Skip_SB( "Reserved");
+ Skip_SB( "ML - Multi-language");
+ Skip_SB( "50/60");
+ Get_S1 (5, audio_source_stype, "STYPE - audio blocks per video frame"); Param_Info1(audio_source_stype==0?"2 channels":(audio_source_stype==2?"4 channels":"Unknown")); //0=25 Mbps, 2=50 Mbps
+
+ Skip_SB( "EF - Emphasis off");
+ Skip_SB( "TC - Time constant of emphasis");
+ Get_S1 (3, SamplingRate, "SMP - Sampling rate"); Param_Info1(Dv_Audio_SamplingRate[SamplingRate]);
+ Get_S1 (3, Resolution, "QU - Resolution"); Param_Info1(Dv_Audio_BitDepth[Resolution]);
+ BS_End();
+
+ FILLING_BEGIN();
+ if (!IgnoreAudio && (Frame_Count==1 || AuxToAnalyze)) //Only the first time
+ {
+ //Calculating the count of audio
+ size_t Audio_Count=1;
+ if (audio_source_stype==2 || (Resolution==1 && SamplingRate==2)) //stype=2 or (Resolution=12 bits and SamplingRate=32 KHz)
+ Audio_Count=2;
+ if (audio_source_stype==3)
+ Audio_Count=4;
+
+ //Filling
+ if (Streams_Audio.size()<Audio_Count)
+ Streams_Audio.resize(Audio_Count);
+ for (size_t Pos=0; Pos<Audio_Count; Pos++)
+ {
+ if (Streams_Audio[Pos]==NULL)
+ Streams_Audio[Pos]=new stream;
+ Streams_Audio[Pos]->Infos["ID"].From_Number(Pos);
+ Streams_Audio[Pos]->Infos["Format"]=_T("PCM");
+ Streams_Audio[Pos]->Infos["Codec"]=_T("PCM");
+ Streams_Audio[Pos]->Infos["BitRate_Mode"]=_T("CBR");
+ Streams_Audio[Pos]->Infos["Channel(s)"].From_Number(audio_source_stype==3?1:2);
+ Streams_Audio[Pos]->Infos["SamplingRate"].From_Number(Dv_Audio_SamplingRate[SamplingRate]);
+ Streams_Audio[Pos]->Infos["BitDepth"].From_Number(Dv_Audio_BitDepth[Resolution]);
+ Streams_Audio[Pos]->Infos["BitRate"].From_Number((audio_source_stype==3?1:2)*Dv_Audio_SamplingRate[SamplingRate]*Dv_Audio_BitDepth[Resolution]);
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::audio_sourcecontrol()
+{
+ if (TF1)
+ {
+ Skip_XX(4, "Unused");
+ return;
+ }
+
+ Element_Name("audio_control");
+
+ BS_Begin();
+
+ //PC1
+ Info_S1(2, CopyGenerationManagementSystem, "CGMS - Copy generation management system"); Param_Info1(Dv_CopyGenerationManagementSystem[CopyGenerationManagementSystem]);
+ Info_S1(2, InputType, "ISR - Input type"); Param_Info1(Dv_InputType[InputType]);
+ Info_S1(2, CompressionTimes, "CMP - Compression times"); Param_Info1(Dv_CompressionTimes[CompressionTimes]);
+ Info_S1(2, Emphasis, "EFC - Emphasis"); Param_Info1(Dv_Emphasis[Emphasis]);
+
+ //PC2
+ Skip_SB( "REC S Non-recording start point");
+ Skip_SB( "REC E - Non-recording end point");
+ Skip_SB( "FADE S - Recording mode"); //1=Original
+ Skip_SB( "FADE E - Unknown");
+ Skip_SB( "Reserved");
+ Skip_SB( "Reserved");
+ Skip_SB( "Reserved");
+ Skip_SB( "Reserved");
+
+ //PC3
+ Skip_SB( "DRF - Direction"); //1=Forward
+ Skip_S1(7, "SPD - Speed");
+
+ //PC4
+ Skip_SB( "Reserved");
+ Skip_S1(7, "GEN - Category");
+
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::audio_recdate()
+{
+ if (TF1)
+ {
+ Skip_XX(4, "Unused");
+ return;
+ }
+
+ Element_Name("audio_recdate");
+
+ recdate();
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::audio_rectime()
+{
+ if (TF1)
+ {
+ Skip_XX(4, "Unused");
+ return;
+ }
+
+ Element_Name("audio_rectime");
+
+ rectime();
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::video_source()
+{
+ if (TF2)
+ {
+ Skip_XX(4, "Unused");
+ return;
+ }
+
+ Element_Name("video_source");
+
+ BS_Begin();
+ //PC1
+ Skip_S1(4, "TVCH (tens of units, 0–9)");
+ Skip_S1(4, "TVCH (units, 0–9)");
+
+ //PC2
+ Skip_SB( "B/W - Black and White"); //0=Black and White, 1=Color
+ Skip_SB( "EN - Color Frames is not valid");
+ Skip_S1(2, "CLF - Color frames id");
+ Skip_S1(4, "TVCH (hundreds of units, 0–9)");
+
+ //PC3
+ Skip_S1(2, "SRC");
+ Get_SB ( system, "50/60 - System");
+ Get_S1 (5, video_source_stype, "STYPE - Signal type of video signal"); //0=not 4:2:2, 4=4:2:2
+
+ //PC4
+ BS_End();
+ Skip_B1( "TUN/VISC");
+
+ FILLING_BEGIN();
+ if (FSC==false && FSP==true && Dseq==0)
+ {
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ FrameInfo.DUR=float64_int64s(((float64)1000000000)/(DSF?25.000:29.970));
+ if (FrameInfo.DTS!=(int64u)-1)
+ FrameInfo.DTS+=FrameInfo.DUR;
+ if (FrameInfo.PTS!=(int64u)-1)
+ FrameInfo.PTS+=FrameInfo.DUR;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::video_sourcecontrol()
+{
+ if (TF2)
+ {
+ Skip_XX(4, "Unused");
+ return;
+ }
+
+ Element_Name("video_control");
+
+ BS_Begin();
+ //PC1
+ Info_S1(2, CopyGenerationManagementSystem, "CGMS - Copy generation management system"); Param_Info1(Dv_CopyGenerationManagementSystem[CopyGenerationManagementSystem]);
+ Skip_S1(2, "ISR");
+ Skip_S1(2, "CMP");
+ Skip_S2(2, "SS");
+
+ //PC2
+ Skip_SB( "REC S");
+ Skip_SB( "Reserved");
+ Skip_S1(2, "REC M");
+ Skip_SB( "Reserved");
+ Get_S1 (3, aspect, "DISP - Aspect ratio"); Param_Info1(Dv_Disp[aspect]);
+
+ //PC3
+ Get_SB ( FieldOrder_FF, "FF - Frame/Field"); //1=Frame, 0=Field
+ Get_SB ( FieldOrder_FS, "FS - First/second field"); //0=Field 2, 1=Field 1, if FF=0 x is output twice, if FF=1, Field x fisrst, other second
+ Skip_SB( "FC - Frame Change"); //0=Same picture as before
+ Get_SB ( Interlaced, "IL - Interlaced"); //1=Interlaced
+ Skip_SB( "SF");
+ Skip_SB( "SC");
+ Skip_S1(2, "BCS");
+
+ //PC4
+ Skip_SB( "Reserved");
+ Skip_S1(7, "GEN - Category");
+
+ BS_End();
+
+ FILLING_BEGIN();
+ video_sourcecontrol_IsParsed=true;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::video_recdate()
+{
+ if (TF2)
+ {
+ Skip_XX(4, "Unused");
+ return;
+ }
+
+ Element_Name("video_recdate");
+
+ Ztring Date=recdate();
+ if (Recorded_Date_Date.empty())
+ Recorded_Date_Date=Date;
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::video_rectime()
+{
+ if (TF2)
+ {
+ Skip_XX(4, "Unused");
+ return;
+ }
+
+ Element_Name("video_rectime");
+
+ Ztring Date=rectime();
+ if (Recorded_Date_Time.empty())
+ Recorded_Date_Time=Date;
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::closed_captions()
+{
+ Element_Name("closed_captions");
+
+ #if defined(MEDIAINFO_EIA608_YES)
+ if (CC_Parsers.empty())
+ {
+ CC_Parsers.resize(2);
+ for (int8u Pos=0; Pos<2; Pos++)
+ {
+ CC_Parsers[Pos]=new File_Eia608();
+ ((File_Eia608*)CC_Parsers[Pos])->cc_type=Pos;
+ }
+ Frame_Count_Valid*=10; //More frames
+ }
+ if (Dseq==0) //CC are duplicated for each DIF sequence!
+ {
+ for (size_t Pos=0; Pos<2; Pos++)
+ {
+ Open_Buffer_Init(CC_Parsers[Pos]);
+ Open_Buffer_Continue(CC_Parsers[Pos], 2);
+ }
+ }
+
+ #else
+ Skip_XX(4, "Captions");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::consumer_camera_1()
+{
+ Element_Name("consumer_camera_1");
+
+ //Parsing
+ BS_Begin();
+ int8u ae_mode, wb_mode, white_balance, fcm;
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Skip_S1(6, "iris");
+ Get_S1 (4, ae_mode, "ae mode"); Param_Info1(Dv_consumer_camera_1_ae_mode[ae_mode]);
+ Skip_S1(4, "agc(Automatic Gain Control)");
+ Get_S1 (3, wb_mode, "wb mode (white balance mode)"); Param_Info1(Dv_consumer_camera_1_wb_mode[wb_mode]);
+ Get_S1 (5, white_balance, "white balance"); Param_Info1(Dv_consumer_camera_1_white_balance(white_balance));
+ Get_S1 (1, fcm, "fcm (Focus mode)"); Param_Info1(Dv_consumer_camera_1_fcm[fcm]);
+ Skip_S1(7, "focus (focal point)");
+ BS_End();
+
+ if (Encoded_Library_Settings.empty())
+ {
+ if (ae_mode<0x0F) Encoded_Library_Settings+=_T("ae mode=")+Ztring(Dv_consumer_camera_1_ae_mode[ae_mode])+_T(" / ");
+ if (wb_mode<0x08) Encoded_Library_Settings+=_T("wb mode=")+Ztring(Dv_consumer_camera_1_wb_mode[wb_mode])+_T(" / ");
+ if (wb_mode<0x1F) Encoded_Library_Settings+=_T("white balance=")+Ztring(Dv_consumer_camera_1_white_balance(white_balance))+_T(" / ");
+ Encoded_Library_Settings+=_T("fcm=")+Ztring(Dv_consumer_camera_1_fcm[fcm]);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_DvDif::consumer_camera_2()
+{
+ Element_Name("consumer_camera_2");
+
+ //Parsing
+ BS_Begin();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Skip_S1(1, "vpd");
+ Skip_S1(5, "vertical panning speed");
+ Skip_S1(1, "is");
+ Skip_S1(1, "hpd");
+ Skip_S1(6, "horizontal panning speed");
+ Skip_S1(8, "focal length");
+ Skip_S1(1, "zen");
+ Info_S1(3, zoom_U, "units of e-zoom");
+ Info_S1(4, zoom_D, "1/10 of e-zoom"); /*if (zoom_D!=0xF)*/ Param_Info1(_T("zoom=")+Ztring().From_Number(zoom_U+((float32)zoom_U)/10, 2));
+ BS_End();
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Ztring File_DvDif::recdate()
+{
+ BS_Begin();
+
+ int8u Temp;
+ int16u Year=0;
+ int8u Month=0, Day=0;
+ Skip_S1(8, "Time zone specific"); //ds, tm, tens of time zone, units of time zone, 0xFF for Unknwon
+ Skip_SB( "1");
+ Skip_SB( "1");
+ Get_S1 (2, Temp, "Days (Tens)");
+ Day+=Temp*10;
+ Get_S1 (4, Temp, "Days (Units)");
+ Day+=Temp;
+ Skip_SB( "1");
+ Skip_SB( "1");
+ Skip_SB( "1");
+ Get_S1 (1, Temp, "Month (Tens)");
+ Month+=Temp*10;
+ Get_S1 (4, Temp, "Month (Units)");
+ Month+=Temp;
+ Get_S1 (4, Temp, "Year (Tens)");
+ Year+=Temp*10;
+ Get_S1 (4, Temp, "Year (Units)");
+ Year+=Temp;
+ Year+=Year<25?2000:1900;
+ Element_Info1(Ztring::ToZtring(Year)+_T("-")+Ztring::ToZtring(Month)+_T("-")+Ztring::ToZtring(Day));
+
+ BS_End();
+
+ if (Month>12 || Day>31)
+ return Ztring(); //If all bits are set to 1, this is invalid
+ Ztring MonthString;
+ if (Month<10)
+ MonthString=_T("0");
+ MonthString+=Ztring::ToZtring(Month);
+ Ztring DayString;
+ if (Day<10)
+ DayString=_T("0");
+ DayString+=Ztring::ToZtring(Day);
+ return Ztring::ToZtring(Year)+_T("-")+MonthString+_T("-")+DayString;
+}
+
+//---------------------------------------------------------------------------
+Ztring File_DvDif::rectime()
+{
+ if (!DSF_IsValid)
+ {
+ Trusted_IsNot("Not in right order");
+ return Ztring();
+ }
+
+ BS_Begin();
+
+ if (Buffer[Buffer_Offset+(size_t)Element_Offset ]==0x00
+ && Buffer[Buffer_Offset+(size_t)Element_Offset+1]==0x00
+ && Buffer[Buffer_Offset+(size_t)Element_Offset+2]==0x00
+ && Buffer[Buffer_Offset+(size_t)Element_Offset+3]==0x00
+ )
+ {
+ Skip_XX(4, "All zero");
+ return Ztring();
+ }
+
+ int8u Temp;
+ int64u Time=0;
+ int8u Frames=0;
+ Skip_SB( "Unknown");
+ Skip_SB( "1");
+ Get_S1 (2, Temp, "Frames (Tens)");
+ Frames+=Temp*10;
+ Get_S1 (4, Temp, "Frames (Units)");
+ Frames+=Temp;
+ if (Temp!=0xF && DSF_IsValid)
+ Time+=(int64u)(Frames/(DSF?25.000:29.970));
+ Skip_SB( "1");
+ Get_S1 (3, Temp, "Seconds (Tens)");
+ Time+=Temp*10*1000;
+ Get_S1 (4, Temp, "Seconds (Units)");
+ Time+=Temp*1000;
+ Skip_SB( "1");
+ Get_S1 (3, Temp, "Minutes (Tens)");
+ Time+=Temp*10*60*1000;
+ Get_S1 (4, Temp, "Minutes (Units)");
+ Time+=Temp*60*1000;
+ Skip_SB( "1");
+ Skip_SB( "1");
+ Get_S1 (2, Temp, "Hours (Tens)");
+ Time+=Temp*10*60*60*1000;
+ Get_S1 (4, Temp, "Hours (Units)");
+ Time+=Temp*60*60*1000;
+ Element_Info1(Ztring().Duration_From_Milliseconds(Time));
+
+ BS_End();
+
+ if (Time!=167185000)
+ return Ztring().Duration_From_Milliseconds(Time);
+ else
+ return Ztring(); //If all bits are set to 1, this is invalid
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_DV_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif.h
new file mode 100644
index 000000000..ca10ac261
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif.h
@@ -0,0 +1,361 @@
+// File_DvDif - Info for DVD objects (IFO) files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about DV-DIF (DV Digital Interface Format)
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_DvDifH
+#define MediaInfo_File_DvDifH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_DvDif
+//***************************************************************************
+
+class File_DvDif : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ int8u AuxToAnalyze; //Only Aux must be parsed
+ bool IgnoreAudio;
+
+ //Constructor/Destructor
+ File_DvDif();
+ ~File_DvDif();
+
+protected :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+ void Synched_Test_Reset();
+ void Synched_Init();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test();
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Global
+ #ifdef MEDIAINFO_DVDIF_ANALYZE_YES
+ void Read_Buffer_Continue();
+ #endif //MEDIAINFO_DVDIF_ANALYZE_YES
+ void Read_Buffer_Unsynched();
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements - Main
+ void Header();
+ void Subcode();
+ void Subcode_Ssyb(int8u syb_num);
+ void VAUX();
+ void Audio();
+ void Video();
+
+ //Elements - Sub
+ void Element();
+ void timecode();
+ void binary_group();
+ void audio_source();
+ void audio_sourcecontrol();
+ void audio_recdate();
+ void audio_rectime();
+ void video_source();
+ void video_sourcecontrol();
+ void video_recdate();
+ void video_rectime();
+ void closed_captions();
+ void consumer_camera_1();
+ void consumer_camera_2();
+
+ //Helpers
+ Ztring recdate();
+ Ztring rectime();
+
+ //Streams
+ struct stream
+ {
+ std::map<std::string, Ztring> Infos;
+ };
+ std::vector<stream*> Streams_Audio;
+
+ //Temp
+ #if defined(MEDIAINFO_EIA608_YES)
+ std::vector<File__Analyze*> CC_Parsers;
+ #endif
+ Ztring Recorded_Date_Date;
+ Ztring Recorded_Date_Time;
+ Ztring Encoded_Library_Settings;
+ int64u Duration;
+ int64u TimeCode_First;
+ int64u FrameSize_Theory; //The size of a frame
+ int8u SCT;
+ int8u SCT_Old;
+ int8u Dseq;
+ int8u Dseq_Old;
+ int8u DBN;
+ int8u DBN_Olds[8];
+ int8u video_source_stype;
+ int8u audio_source_stype;
+ bool FSC;
+ bool FSP;
+ bool DSF;
+ bool DSF_IsValid;
+ int8u APT;
+ bool TF1;
+ bool TF2;
+ bool TF3;
+ int8u aspect;
+ int8u ssyb_AP3;
+ bool FieldOrder_FF;
+ bool FieldOrder_FS;
+ bool Interlaced;
+ bool system;
+ bool FSC_WasSet;
+ bool FSP_WasNotSet;
+ bool video_sourcecontrol_IsParsed;
+ bool audio_locked;
+
+ #if MEDIAINFO_SEEK
+ bool Duration_Detected;
+ int64u TotalFrames;
+ #endif //MEDIAINFO_SEEK
+
+ #ifdef MEDIAINFO_DVDIF_ANALYZE_YES
+ bool Analyze_Activated;
+ bool video_source_Detected;
+
+ void Errors_Stats_Update();
+ void Errors_Stats_Update_Finnish();
+ Ztring Errors_Stats_03;
+ Ztring Errors_Stats_05;
+ Ztring Errors_Stats_09;
+ Ztring Errors_Stats_10;
+ Ztring Date;
+ Ztring Time;
+ int64u Speed_FrameCount; //Global - Total
+ int64u Speed_FrameCount_Video_STA_Errors; //Global - Error 1
+ std::vector<int64u> Speed_FrameCount_Audio_Errors; //Global - Error 2
+ int64u Speed_FrameCount_Timecode_Incoherency; //Global - Error 3
+ int64u Speed_FrameCount_Contains_NULL; //Global - Error 4
+ int64u Speed_Contains_NULL; //Per Frame - Error 4
+ int64u Speed_FrameCount_Arb_Incoherency; //Global - Error 5
+ int64u Speed_FrameCount_Stts_Fluctuation; //Global - Error 6
+ int8u QU;
+ bool QU_FSC; //Validity is with QU
+ bool QU_System; //Validity is with QU
+ bool REC_ST;
+ bool REC_END;
+ bool REC_IsValid;
+ bool System;
+ bool System_IsValid;
+ bool Frame_AtLeast1DIF;
+ struct dvdate
+ {
+ int8u Days;
+ int8u Months;
+ int8u Years;
+ bool MultipleValues;
+ bool IsValid;
+
+ dvdate() {Clear();}
+
+ void Clear()
+ {
+ MultipleValues=false;
+ IsValid=false;
+ }
+ };
+ struct dvtime
+ {
+ struct time
+ {
+ int8u Frames;
+ int8u Seconds;
+ int8u Minutes;
+ int8u Hours;
+ bool DropFrame;
+
+ time()
+ {
+ Frames=(int8u)-1;
+ Seconds=(int8u)-1;
+ Minutes=(int8u)-1;
+ Hours=(int8u)-1;
+ DropFrame=false;
+ }
+ };
+ time Time;
+ bool MultipleValues;
+ bool IsValid;
+
+ dvtime() {Clear();}
+
+ void Clear()
+ {
+ MultipleValues=false;
+ IsValid=false;
+ }
+ };
+ dvtime Speed_TimeCode_Last;
+ dvtime Speed_TimeCode_Current;
+ dvtime Speed_TimeCode_Current_Theory;
+ Ztring Speed_TimeCodeZ_First;
+ Ztring Speed_TimeCodeZ_Last;
+ Ztring Speed_TimeCodeZ_Current;
+ bool Speed_TimeCode_IsValid;
+ dvtime Speed_RecTime_Current;
+ dvtime Speed_RecTime_Current_Theory;
+ dvtime Speed_RecTime_Current_Theory2;
+ Ztring Speed_RecTimeZ_First;
+ Ztring Speed_RecTimeZ_Last;
+ Ztring Speed_RecTimeZ_Current;
+ dvdate Speed_RecDate_Current;
+ Ztring Speed_RecDateZ_First;
+ Ztring Speed_RecDateZ_Last;
+ Ztring Speed_RecDateZ_Current;
+ std::vector<size_t> Video_STA_Errors; //Per STA type
+ std::vector<size_t> Video_STA_Errors_Total; //Per STA type
+ std::vector<size_t> Audio_Errors; //Per Dseq
+ std::vector<size_t> audio_source_IsPresent;
+ std::vector<bool> CH_IsPresent;
+ std::vector<std::vector<size_t> > Audio_Errors_Total; //Per Channel and Dseq
+ std::vector<std::vector<size_t> > Audio_Invalids; //Per Channel and Dseq
+ std::vector<std::vector<size_t> > Audio_Invalids_Total; //Per Channel and Dseq
+ struct recZ_Single
+ {
+ int64u FramePos;
+ Ztring Date;
+ Ztring Time;
+
+ recZ_Single()
+ {
+ FramePos=(int64u)-1;
+ }
+ };
+ struct recZ
+ {
+ recZ_Single First;
+ recZ_Single Last;
+ };
+ std::vector<recZ> Speed_RecZ;
+ struct timeCodeZ_Single
+ {
+ int64u FramePos;
+ Ztring TimeCode;
+
+ timeCodeZ_Single()
+ {
+ FramePos=(int64u)-1;
+ }
+ };
+ struct timeCodeZ
+ {
+ timeCodeZ_Single First;
+ timeCodeZ_Single Last;
+ };
+ std::vector<timeCodeZ> Speed_TimeCodeZ;
+ struct timeStampsZ_Single
+ {
+ int64u FramePos;
+ Ztring Time;
+ Ztring TimeCode;
+ Ztring Date;
+
+ timeStampsZ_Single()
+ {
+ FramePos=(int64u)-1;
+ }
+ };
+ struct timeStampsZ
+ {
+ timeStampsZ_Single First;
+ timeStampsZ_Single Last;
+ };
+ std::vector<timeStampsZ> Speed_TimeStampsZ;
+
+
+
+ struct arb
+ {
+ std::vector<size_t> Value_Counters;
+ int8u Value;
+ bool MultipleValues;
+ bool IsValid;
+
+ arb() {Clear();}
+
+ void Clear()
+ {
+ Value_Counters.clear();
+ Value_Counters.resize(16);
+ Value=0xF; //Used only when we are sure
+ MultipleValues=false;
+ IsValid=false;
+ }
+ };
+ arb Speed_Arb_Last;
+ arb Speed_Arb_Current;
+ arb Speed_Arb_Current_Theory;
+ bool Speed_Arb_IsValid;
+
+ //Stats
+ std::vector<size_t> Stats;
+ size_t Stats_Total;
+ size_t Stats_Total_WithoutArb;
+ bool Stats_Total_AlreadyDetected;
+
+public:
+ //From MPEG-4 container
+ struct stts_part
+ {
+ int64u Pos_Begin;
+ int64u Pos_End;
+ int32u Duration;
+ };
+ typedef std::vector<stts_part> stts;
+ stts* Mpeg4_stts;
+ size_t Mpeg4_stts_Pos;
+ #endif //MEDIAINFO_DVDIF_ANALYZE_YES
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif_Analysis.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif_Analysis.cpp
new file mode 100644
index 000000000..38232f7cd
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_DvDif_Analysis.cpp
@@ -0,0 +1,1629 @@
+// File_DvDif - Info for DV-DIF files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DVDIF_YES) && defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_DvDif.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Analysis
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DvDif::Read_Buffer_Continue()
+{
+ if (!Analyze_Activated)
+ {
+ if (Config->File_DvDif_Analysis_Get())
+ Analyze_Activated=true;
+ else
+ return;
+ }
+
+ //Errors stats
+ while (Buffer_Offset+80<=Buffer_Size)
+ {
+ if ((Buffer[Buffer_Offset]&0xE0)==0x00 //SCT=0 (Header)
+ && !(Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x00))
+ {
+ Frame_AtLeast1DIF=true;
+
+ if (!DSF_IsValid)
+ {
+ DSF=(Buffer[Buffer_Offset+3]&0x80)?true:false;
+ DSF_IsValid=true;
+ Dseq_Old=DSF?11:9;
+ }
+ }
+
+ //Quick search depends of SCT
+ switch(Buffer[Buffer_Offset]&0xE0)
+ {
+ case 0x20 : //SCT=1 (Subcode)
+ {
+ Frame_AtLeast1DIF=true;
+
+ for (size_t Pos=3*8; Pos<40; Pos+=2*8)
+ {
+ int8u PackType=Buffer[Buffer_Offset+3+Pos+3];
+ //dv_timecode
+ if (PackType==0x13) //Pack type=0x13 (dv_timecode)
+ {
+ bool DropFrame =( Buffer[Buffer_Offset+3+Pos+3+1]&0x40)?true:false;
+ int8u Frames =((Buffer[Buffer_Offset+3+Pos+3+1]&0x30)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+3+1]&0x0F) ) ;
+ int8u Seconds =((Buffer[Buffer_Offset+3+Pos+3+2]&0x70)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+3+2]&0x0F)) ;
+ int8u Minutes =((Buffer[Buffer_Offset+3+Pos+3+3]&0x70)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+3+3]&0x0F) ) ;
+ int8u Hours =((Buffer[Buffer_Offset+3+Pos+3+4]&0x30)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+3+4]&0x0F) ) ;
+
+ if (Frames ==0x00
+ && Seconds==0x00
+ && Minutes==0x00
+ && Hours ==0x00
+ && Buffer[Buffer_Offset+3+Pos+3+1]==0x00
+ && Buffer[Buffer_Offset+3+Pos+3+2]==0x00
+ && Buffer[Buffer_Offset+3+Pos+3+3]==0x00
+ && Buffer[Buffer_Offset+3+Pos+3+4]==0x00
+ )
+ {
+ Frames =45;
+ Seconds=85;
+ Minutes=85;
+ Hours =45;
+ }
+ if (Frames !=45
+ && Seconds!=85
+ && Minutes!=85
+ && Hours !=45) //If not disabled
+ {
+ if (Speed_TimeCode_Current.IsValid
+ && (Speed_TimeCode_Current.Time.DropFrame !=DropFrame
+ || Speed_TimeCode_Current.Time.Frames !=Frames
+ || Speed_TimeCode_Current.Time.Seconds !=Seconds
+ || Speed_TimeCode_Current.Time.Minutes !=Minutes
+ || Speed_TimeCode_Current.Time.Hours !=Hours))
+ {
+ Speed_TimeCode_Current.MultipleValues=true; //There are 2+ different values
+ }
+ else if (!Speed_TimeCode_Current.IsValid && !Speed_TimeCode_Current.MultipleValues)
+ {
+ Speed_TimeCode_Current.Time.DropFrame=DropFrame;
+ Speed_TimeCode_Current.Time.Frames =Frames;
+ Speed_TimeCode_Current.Time.Seconds =Seconds;
+ Speed_TimeCode_Current.Time.Minutes =Minutes;
+ Speed_TimeCode_Current.Time.Hours =Hours;
+ Speed_TimeCode_Current.IsValid =true;
+ }
+ }
+ }
+
+ //video_recdate
+ if (PackType==0x62) //Pack type=0x62 (video_rectime)
+ {
+ int8u Days =((Buffer[Buffer_Offset+3+Pos+2]&0x30)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+2]&0x0F) ) ;
+ int8u Months =((Buffer[Buffer_Offset+3+Pos+3]&0x10)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+3]&0x0F) ) ;
+ int8u Years =((Buffer[Buffer_Offset+3+Pos+4]&0xF0)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+4]&0x0F) ) ;
+ if (Months<=12
+ && Days <=31)
+ {
+ if (Speed_RecDate_Current.IsValid
+ && Speed_RecDate_Current.Days !=Days
+ && Speed_RecDate_Current.Months !=Months
+ && Speed_RecDate_Current.Years !=Years)
+ {
+ Speed_RecDate_Current.MultipleValues=true; //There are 2+ different values
+ }
+ else if (!Speed_RecTime_Current.MultipleValues)
+ {
+ Speed_RecDate_Current.Days =Days;
+ Speed_RecDate_Current.Months =Months;
+ Speed_RecDate_Current.Years =Years;
+ Speed_RecDate_Current.IsValid =true;
+ }
+ }
+ }
+
+ //video_rectime
+ if (PackType==0x63) //Pack type=0x63 (video_rectime)
+ {
+ int8u Frames =((Buffer[Buffer_Offset+3+Pos+1]&0x30)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+1]&0x0F) ) ;
+ int8u Seconds =((Buffer[Buffer_Offset+3+Pos+2]&0x70)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+2]&0x0F)) ;
+ int8u Minutes =((Buffer[Buffer_Offset+3+Pos+3]&0x70)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+3]&0x0F) ) ;
+ int8u Hours =((Buffer[Buffer_Offset+3+Pos+4]&0x30)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+4]&0x0F) ) ;
+ if (Seconds<61
+ && Minutes<60
+ && Hours <24) //If not disabled
+ {
+ if (Speed_RecTime_Current.IsValid
+ && Speed_RecTime_Current.Time.Frames !=Frames
+ && Speed_RecTime_Current.Time.Seconds !=Seconds
+ && Speed_RecTime_Current.Time.Minutes !=Minutes
+ && Speed_RecTime_Current.Time.Hours !=Hours)
+ {
+ Speed_RecTime_Current.MultipleValues=true; //There are 2+ different values
+ }
+ else if (!Speed_RecTime_Current.MultipleValues)
+ {
+ Speed_RecTime_Current.Time.Frames =Frames;
+ Speed_RecTime_Current.Time.Seconds =Seconds;
+ Speed_RecTime_Current.Time.Minutes =Minutes;
+ Speed_RecTime_Current.Time.Hours =Hours;
+ Speed_RecTime_Current.IsValid =true;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case 0x40 : //SCT=2 (VAUX)
+ {
+ Frame_AtLeast1DIF=true;
+
+ for (size_t Pos=0; Pos<15*5; Pos+=5)
+ {
+ int8u PackType=Buffer[Buffer_Offset+3+Pos];
+ //video_source
+ if (PackType==0x60 && !System_IsValid) //Pack type=0x60 (video_source)
+ {
+ System=(Buffer[Buffer_Offset+3+Pos+3]&0x20)==0x20?true:false;
+ System_IsValid=true;
+ video_source_Detected=true;
+ }
+
+ //video_recdate
+ if (PackType==0x62) //Pack type=0x62 (video_rectime)
+ {
+ int8u Days =((Buffer[Buffer_Offset+3+Pos+2]&0x30)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+2]&0x0F) ) ;
+ int8u Months =((Buffer[Buffer_Offset+3+Pos+3]&0x10)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+3]&0x0F) ) ;
+ int8u Years =((Buffer[Buffer_Offset+3+Pos+4]&0xF0)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+4]&0x0F) ) ;
+ if (Months<=12
+ && Days <=31)
+ {
+ if (Speed_RecDate_Current.IsValid
+ && Speed_RecDate_Current.Days !=Days
+ && Speed_RecDate_Current.Months !=Months
+ && Speed_RecDate_Current.Years !=Years)
+ {
+ Speed_RecDate_Current.MultipleValues=true; //There are 2+ different values
+ }
+ else if (!Speed_RecTime_Current.MultipleValues)
+ {
+ Speed_RecDate_Current.Days =Days;
+ Speed_RecDate_Current.Months =Months;
+ Speed_RecDate_Current.Years =Years;
+ Speed_RecDate_Current.IsValid =true;
+ }
+ }
+ }
+
+ //video_rectime
+ if (PackType==0x63) //Pack type=0x63 (video_rectime)
+ {
+ int8u Frames =((Buffer[Buffer_Offset+3+Pos+1]&0x30)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+1]&0x0F) ) ;
+ int8u Seconds =((Buffer[Buffer_Offset+3+Pos+2]&0x70)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+2]&0x0F)) ;
+ int8u Minutes =((Buffer[Buffer_Offset+3+Pos+3]&0x70)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+3]&0x0F) ) ;
+ int8u Hours =((Buffer[Buffer_Offset+3+Pos+4]&0x30)>>4)*10
+ + ((Buffer[Buffer_Offset+3+Pos+4]&0x0F) ) ;
+ if (Seconds!=85
+ && Minutes!=85
+ && Hours !=45) //If not disabled
+ {
+ if (Speed_RecTime_Current.IsValid
+ && Speed_RecTime_Current.Time.Frames !=Frames
+ && Speed_RecTime_Current.Time.Seconds !=Seconds
+ && Speed_RecTime_Current.Time.Minutes !=Minutes
+ && Speed_RecTime_Current.Time.Hours !=Hours)
+ {
+ Speed_RecTime_Current.MultipleValues=true; //There are 2+ different values
+ }
+ else if (!Speed_RecTime_Current.MultipleValues)
+ {
+ Speed_RecTime_Current.Time.Frames =Frames;
+ Speed_RecTime_Current.Time.Seconds =Seconds;
+ Speed_RecTime_Current.Time.Minutes =Minutes;
+ Speed_RecTime_Current.Time.Hours =Hours;
+ Speed_RecTime_Current.IsValid =true;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case 0x60 : //SCT=3 (Audio)
+ {
+ //audio_source
+ if (Buffer[Buffer_Offset+3+0]==0x50) //audio_source
+ {
+ QU_FSC =(Buffer[Buffer_Offset+1 ]&0x08)?true:false; //FSC
+ QU_System =(Buffer[Buffer_Offset+3+3]&0x20)?true:false; //50/60
+
+ int8u AUDIO_MODE=Buffer[Buffer_Offset+3+2]&0x0F;
+ QU =Buffer[Buffer_Offset+3+4]&0x07;
+
+ size_t Channel=(QU_FSC?2:0)+((Buffer[Buffer_Offset+1]>>4)>=(QU_System?6:5)?1:0); //If Dseq>=5 or 6
+ if (audio_source_IsPresent.empty())
+ audio_source_IsPresent.resize(8);
+ audio_source_IsPresent[Channel]=true;
+
+ if (AUDIO_MODE==0x0F)
+ {
+ if (Audio_Invalids.empty())
+ {
+ Audio_Invalids.resize(8);
+ for (size_t Pos=0; Pos<8; Pos++)
+ Audio_Invalids[Pos].resize(16);
+ }
+ Audio_Invalids[Channel][Buffer[Buffer_Offset+1]>>4]+=9;
+ }
+ }
+
+ //audio_source_control
+ if (Buffer[Buffer_Offset+3+0]==0x51) //audio_source_control
+ {
+ REC_ST =(Buffer[Buffer_Offset+3+2]&0x80)?true:false;
+ REC_END=(Buffer[Buffer_Offset+3+2]&0x40)?true:false;
+ REC_IsValid=true;
+ }
+
+ //audio_recdate
+ if (Buffer[Buffer_Offset+3+0]==0x52) //Pack type=0x52 (audio_rectime)
+ {
+ int8u Days =((Buffer[Buffer_Offset+3+2]&0x30)>>4)*10
+ + ((Buffer[Buffer_Offset+3+2]&0x0F) ) ;
+ int8u Months =((Buffer[Buffer_Offset+3+3]&0x10)>>4)*10
+ + ((Buffer[Buffer_Offset+3+3]&0x0F) ) ;
+ int8u Years =((Buffer[Buffer_Offset+3+4]&0xF0)>>4)*10
+ + ((Buffer[Buffer_Offset+3+4]&0x0F) ) ;
+ if (Months<=12
+ && Days <=31)
+ {
+ if (Speed_RecDate_Current.IsValid
+ && Speed_RecDate_Current.Days !=Days
+ && Speed_RecDate_Current.Months !=Months
+ && Speed_RecDate_Current.Years !=Years)
+ {
+ Speed_RecDate_Current.MultipleValues=true; //There are 2+ different values
+ }
+ else if (!Speed_RecTime_Current.MultipleValues)
+ {
+ Speed_RecDate_Current.Days =Days;
+ Speed_RecDate_Current.Months =Months;
+ Speed_RecDate_Current.Years =Years;
+ Speed_RecDate_Current.IsValid =true;
+ }
+ }
+ }
+
+ //audio_rectime
+ if (Buffer[Buffer_Offset+3+0]==0x53) //Pack type=0x53 (audio_rectime)
+ {
+ int8u Frames =((Buffer[Buffer_Offset+3+1]&0x30)>>4)*10
+ + ((Buffer[Buffer_Offset+3+1]&0x0F) ) ;
+ int8u Seconds =((Buffer[Buffer_Offset+3+2]&0x70)>>4)*10
+ + ((Buffer[Buffer_Offset+3+2]&0x0F)) ;
+ int8u Minutes =((Buffer[Buffer_Offset+3+3]&0x70)>>4)*10
+ + ((Buffer[Buffer_Offset+3+3]&0x0F) ) ;
+ int8u Hours =((Buffer[Buffer_Offset+3+4]&0x30)>>4)*10
+ + ((Buffer[Buffer_Offset+3+4]&0x0F) ) ;
+ if (Seconds!=85
+ && Minutes!=85
+ && Hours !=45) //If not disabled
+ {
+ if (Speed_RecTime_Current.IsValid
+ && Speed_RecTime_Current.Time.Frames !=Frames
+ && Speed_RecTime_Current.Time.Seconds !=Seconds
+ && Speed_RecTime_Current.Time.Minutes !=Minutes
+ && Speed_RecTime_Current.Time.Hours !=Hours)
+ {
+ Speed_RecTime_Current.MultipleValues=true; //There are 2+ different values
+ }
+ else if (!Speed_RecTime_Current.MultipleValues)
+ {
+ Speed_RecTime_Current.Time.Frames =Frames;
+ Speed_RecTime_Current.Time.Seconds =Seconds;
+ Speed_RecTime_Current.Time.Minutes =Minutes;
+ Speed_RecTime_Current.Time.Hours =Hours;
+ Speed_RecTime_Current.IsValid =true;
+ }
+ }
+ }
+
+ //Audio errors
+ if (Buffer[Buffer_Offset+8]==0x80)
+ {
+ if ((QU==0 && Buffer[Buffer_Offset+ 9]==0x00) //16-bit 0x8000
+ || (QU==1 && Buffer[Buffer_Offset+10]==0x00) //12-bit 0x800
+ || (QU==(int8u)-1 && ((Buffer[Buffer_Offset+ 9]==0x00 && Buffer[Buffer_Offset+10]==0x80 && Buffer[Buffer_Offset+11]==0x00)
+ || (Buffer[Buffer_Offset+ 9]==0x80 && Buffer[Buffer_Offset+10]==0x00)))) //In case of QU is not already detected
+ {
+ if (Audio_Errors.empty())
+ Audio_Errors.resize(16);
+ Audio_Errors[Buffer[Buffer_Offset+1]>>4]++;
+ }
+ }
+ }
+ break;
+
+ case 0x80 : //SCT=4 (Video)
+ {
+ //Speed_Arb_Current
+ int8u Value=Buffer[Buffer_Offset+0]&0x0F;
+ Speed_Arb_Current.Value_Counters[Value]++;
+ if (Value==0xF)
+ {
+ if (!Speed_Arb_Current.IsValid)
+ {
+ Speed_Arb_Current.Value =0xF;
+ Speed_Arb_Current.IsValid=true;
+ }
+ }
+ else
+ {
+ if (Speed_Arb_Current.IsValid
+ && Speed_Arb_Current.Value!=0xF
+ && Speed_Arb_Current.Value!=Value)
+ Speed_Arb_Current.MultipleValues=true; //There are 2+ different values
+ else if (!Speed_Arb_Current.MultipleValues)
+ {
+ Speed_Arb_Current.Value =Value;
+ Speed_Arb_Current.IsValid=true;
+ }
+ }
+
+ //STA
+ if (Buffer[Buffer_Offset+3]&0xF0)
+ {
+ if (video_source_Detected)
+ {
+ if (Video_STA_Errors.empty())
+ Video_STA_Errors.resize(16);
+ Video_STA_Errors[Buffer[Buffer_Offset+3]>>4]++;
+ }
+ }
+ }
+ break;
+ }
+
+ //Errors stats
+ if (Frame_AtLeast1DIF &&
+ (Buffer[Buffer_Offset ]&0xE0)==0x00 //SCT=0 (Header)
+ && (Buffer[Buffer_Offset+1]&0xF0)==0x00 //Dseq=0
+ && (Buffer[Buffer_Offset+1]&0x08)==0x00) //FSC=0
+ Errors_Stats_Update();
+
+ //Coherency test
+ if (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x00)
+ Speed_Contains_NULL++;
+
+ Buffer_Offset+=80;
+ }
+
+ if (!Status[IsAccepted])
+ File__Analyze::Buffer_Offset=0;
+ Config->State_Set(((float)File_Offset)/File_Size);
+}
+
+void File_DvDif::Errors_Stats_Update()
+{
+ if (!Analyze_Activated)
+ {
+ if (Config->File_DvDif_Analysis_Get())
+ Analyze_Activated=true;
+ else
+ return;
+ }
+
+ bool Errors_AreDetected=false;
+ bool Infos_AreDetected=false;
+ bool Arb_AreDetected=false;
+ Ztring Errors_Stats_Line;
+ if (Speed_FrameCount) //We must have at least one complete frame
+ {
+ #if MEDIAINFO_EVENTS
+ //Demux
+ struct MediaInfo_Event_DvDif_Analysis_Frame_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_DvDif, MediaInfo_Event_DvDif_Analysis_Frame, 0);
+ Event.TimeCode=0;
+ Event.RecordedDateTime1=0;
+ Event.RecordedDateTime2=0;
+ Event.Arb=0;
+ Event.Verbosity=0;
+ Event.Errors=NULL;
+ #endif //MEDIAINFO_EVENTS
+
+ //Framerate computing
+ float64 FrameRate=29.970;
+ if (System_IsValid)
+ FrameRate=System?25.000:29.970;
+ else if (DSF_IsValid)
+ FrameRate=DSF?25.000:29.970;
+ else
+ FrameRate=29.970;
+ if (FrameRate==29.970 && Speed_TimeCode_Current.IsValid && !Speed_TimeCode_Current.Time.DropFrame)
+ FrameRate=30.000;
+
+ //Frame number
+ Ztring Frame_Number_Padded=Ztring::ToZtring(Speed_FrameCount-1);
+ if (Frame_Number_Padded.size()<8)
+ Frame_Number_Padded.insert(0, 8-Frame_Number_Padded.size(), _T(' '));
+ Errors_Stats_Line+=Frame_Number_Padded;
+ Errors_Stats_Line+=_T('\t');
+
+ //Time Offset
+ float64 Time_Offset=(Speed_FrameCount-1)*1000/FrameRate;
+ Errors_Stats_Line+=Ztring().Duration_From_Milliseconds((int64u)Time_Offset);
+ Errors_Stats_Line+=_T('\t');
+
+ //Timecode
+ if (Speed_TimeCode_Current.IsValid)
+ {
+ Speed_TimeCodeZ_Last=Speed_TimeCodeZ_Current;
+ Speed_TimeCodeZ_Current.clear();
+ Speed_TimeCodeZ_Current.reserve(12);
+ Speed_TimeCodeZ_Current.reserve(11);
+ Speed_TimeCodeZ_Current+=_T('0')+Speed_TimeCode_Current.Time.Hours /10;
+ Speed_TimeCodeZ_Current+=_T('0')+Speed_TimeCode_Current.Time.Hours %10;
+ Speed_TimeCodeZ_Current+=_T(':');
+ Speed_TimeCodeZ_Current+=_T('0')+Speed_TimeCode_Current.Time.Minutes/10;
+ Speed_TimeCodeZ_Current+=_T('0')+Speed_TimeCode_Current.Time.Minutes%10;
+ Speed_TimeCodeZ_Current+=_T(':');
+ Speed_TimeCodeZ_Current+=_T('0')+Speed_TimeCode_Current.Time.Seconds/10;
+ Speed_TimeCodeZ_Current+=_T('0')+Speed_TimeCode_Current.Time.Seconds%10;
+ Speed_TimeCodeZ_Current+=(!DSF && Speed_TimeCode_Current.Time.DropFrame)?_T(';'):_T(':');
+ Speed_TimeCodeZ_Current+=_T('0')+Speed_TimeCode_Current.Time.Frames /10;
+ Speed_TimeCodeZ_Current+=_T('0')+Speed_TimeCode_Current.Time.Frames %10;
+ Errors_Stats_Line+=Speed_TimeCodeZ_Current;
+ if (Speed_TimeCodeZ.empty())
+ {
+ Speed_TimeCodeZ.resize(1);
+ Speed_TimeCodeZ[0].First.FramePos=Speed_FrameCount;
+ Speed_TimeCodeZ[0].First.TimeCode=Speed_TimeCodeZ_Current;
+ }
+ if (Speed_TimeStampsZ.empty())
+ {
+ Speed_TimeStampsZ.resize(1);
+ Speed_TimeStampsZ[0].First.FramePos=Speed_FrameCount;
+ Speed_TimeStampsZ[0].First.Time+=Ztring().Duration_From_Milliseconds((int64u)Time_Offset);
+ }
+ if (Speed_TimeStampsZ[0].First.FramePos==Speed_FrameCount)
+ Speed_TimeStampsZ[0].First.TimeCode=Speed_TimeCodeZ_Current;
+ #if MEDIAINFO_EVENTS
+ int32u Seconds=Speed_TimeCode_Current.Time.Hours *60*60
+ + Speed_TimeCode_Current.Time.Minutes *60
+ + Speed_TimeCode_Current.Time.Seconds ;
+ Event.TimeCode|=Seconds<<8;
+ Event.TimeCode|=(!DSF && Speed_TimeCode_Current.Time.DropFrame)<<7;
+ Event.TimeCode|=Speed_TimeCode_Current.Time.Frames;
+ #endif //MEDIAINFO_EVENTS
+ }
+ else
+ {
+ Errors_Stats_Line+=_T("XX:XX:XX:XX");
+ #if MEDIAINFO_EVENTS
+ Event.TimeCode|=0x7FFFF<<8;
+ //Event.TimeCode|=Speed_TimeCode_Current.Time.DropFrame<<7;
+ Event.TimeCode|=0x3F;
+ #endif //MEDIAINFO_EVENTS
+ }
+ Errors_Stats_Line+=_T('\t');
+
+ //Timecode order coherency
+ if (!Speed_TimeCode_IsValid && Speed_TimeCode_Current.IsValid
+ && (Speed_TimeCode_Current.Time.Hours!=0
+ || Speed_TimeCode_Current.Time.Minutes!=0
+ || Speed_TimeCode_Current.Time.Seconds!=0
+ || Speed_TimeCode_Current.Time.Frames!=0))
+ Speed_TimeCode_IsValid=true;
+ bool TimeCode_Disrupted=false;
+ if (Speed_TimeCode_IsValid && Speed_TimeCode_Current.IsValid && Speed_TimeCode_Last.IsValid
+ && Speed_TimeCode_Current.Time.Frames ==Speed_TimeCode_Last.Time.Frames
+ && Speed_TimeCode_Current.Time.Seconds==Speed_TimeCode_Last.Time.Seconds
+ && Speed_TimeCode_Current.Time.Minutes==Speed_TimeCode_Last.Time.Minutes
+ && Speed_TimeCode_Current.Time.Hours ==Speed_TimeCode_Last.Time.Hours)
+ {
+ Errors_Stats_Line+=_T('R');
+ #if MEDIAINFO_EVENTS
+ Event.TimeCode|=1<<31;
+ #endif //MEDIAINFO_EVENTS
+ if (Speed_TimeCode_Current.Time.Hours
+ || Speed_TimeCode_Current.Time.Seconds
+ || Speed_TimeCode_Current.Time.Minutes
+ || Speed_TimeCode_Current.Time.Hours)
+ Errors_AreDetected=true;
+ }
+ else if (Speed_TimeCode_IsValid && Speed_TimeCode_Current.IsValid && Speed_TimeCode_Current_Theory.IsValid
+ && ( Speed_TimeCode_Current.Time.Frames !=Speed_TimeCode_Current_Theory.Time.Frames
+ || Speed_TimeCode_Current.Time.Seconds!=Speed_TimeCode_Current_Theory.Time.Seconds
+ || Speed_TimeCode_Current.Time.Minutes!=Speed_TimeCode_Current_Theory.Time.Minutes
+ || Speed_TimeCode_Current.Time.Hours !=Speed_TimeCode_Current_Theory.Time.Hours))
+ {
+ size_t Speed_TimeCodeZ_Pos=Speed_TimeCodeZ.size();
+ Speed_TimeCodeZ.resize(Speed_TimeCodeZ_Pos+1);
+ Speed_TimeCodeZ[Speed_TimeCodeZ_Pos].First.FramePos=Speed_FrameCount-1;
+ Speed_TimeCodeZ[Speed_TimeCodeZ_Pos].First.TimeCode=Speed_TimeCodeZ_Current;
+ Speed_TimeCodeZ[Speed_TimeCodeZ_Pos-1].Last.FramePos=Speed_FrameCount-1;
+ Speed_TimeCodeZ[Speed_TimeCodeZ_Pos-1].Last.TimeCode=Speed_TimeCodeZ_Last;
+
+ Errors_Stats_Line+=_T('N');
+ #if MEDIAINFO_EVENTS
+ Event.TimeCode|=1<<30;
+ #endif //MEDIAINFO_EVENTS
+ Speed_TimeCode_Current_Theory=Speed_TimeCode_Current;
+ TimeCode_Disrupted=true;
+ Errors_AreDetected=true;
+ }
+ else
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+
+ //RecDate/RecTime
+ if (Speed_RecDate_Current.IsValid)
+ {
+ Speed_RecDateZ_Last=Speed_RecDateZ_Current;
+ Speed_RecDateZ_Current.clear();
+ Speed_RecDateZ_Current.reserve(10);
+ Speed_RecDateZ_Current+=Speed_RecDate_Current.Years<75?_T("20"):_T("19");
+ Speed_RecDateZ_Current+=_T('0')+Speed_RecDate_Current.Years /10;
+ Speed_RecDateZ_Current+=_T('0')+Speed_RecDate_Current.Years %10;
+ Speed_RecDateZ_Current+=_T('-');
+ Speed_RecDateZ_Current+=_T('0')+Speed_RecDate_Current.Months /10;
+ Speed_RecDateZ_Current+=_T('0')+Speed_RecDate_Current.Months %10;
+ Speed_RecDateZ_Current+=_T('-');
+ Speed_RecDateZ_Current+=_T('0')+Speed_RecDate_Current.Days /10;
+ Speed_RecDateZ_Current+=_T('0')+Speed_RecDate_Current.Days %10;
+ Errors_Stats_Line+=Speed_RecDateZ_Current;
+ if (Speed_RecZ.empty())
+ {
+ Speed_RecZ.resize(1);
+ Speed_RecZ[0].First.FramePos=Speed_FrameCount;
+ Speed_RecZ[0].First.Date=Speed_RecDateZ_Current;
+ }
+ if (Speed_TimeStampsZ.empty())
+ {
+ Speed_TimeStampsZ.resize(1);
+ Speed_TimeStampsZ[0].First.FramePos=Speed_FrameCount;
+ Speed_TimeStampsZ[0].First.Time+=Ztring().Duration_From_Milliseconds((int64u)Time_Offset);
+ }
+ if (Speed_TimeStampsZ[0].First.FramePos==Speed_FrameCount)
+ Speed_TimeStampsZ[0].First.Date=Speed_RecDateZ_Current;
+ #if MEDIAINFO_EVENTS
+ Event.RecordedDateTime1|=Speed_RecDate_Current.Years<<17;
+ Event.RecordedDateTime2|=Speed_RecDate_Current.Months<<12;
+ Event.RecordedDateTime2|=Speed_RecDate_Current.Days<<8;
+ #endif //MEDIAINFO_EVENTS
+ }
+ else
+ {
+ Errors_Stats_Line+=_T("XXXX-XX-XX");
+ #if MEDIAINFO_EVENTS
+ Event.RecordedDateTime1|=0x7F<<17;
+ Event.RecordedDateTime2|=0x0F<<12;
+ Event.RecordedDateTime2|=0x1F<<8;
+ #endif //MEDIAINFO_EVENTS
+ }
+ Errors_Stats_Line+=_T(" ");
+ if (Speed_RecTime_Current.IsValid)
+ {
+ Speed_RecTimeZ_Last=Speed_RecTimeZ_Current;
+ Speed_RecTimeZ_Current.clear();
+ Speed_RecTimeZ_Current.reserve(12);
+ Speed_RecTimeZ_Current+=_T('0')+Speed_RecTime_Current.Time.Hours /10;
+ Speed_RecTimeZ_Current+=_T('0')+Speed_RecTime_Current.Time.Hours %10;
+ Speed_RecTimeZ_Current+=_T(':');
+ Speed_RecTimeZ_Current+=_T('0')+Speed_RecTime_Current.Time.Minutes/10;
+ Speed_RecTimeZ_Current+=_T('0')+Speed_RecTime_Current.Time.Minutes%10;
+ Speed_RecTimeZ_Current+=_T(':');
+ Speed_RecTimeZ_Current+=_T('0')+Speed_RecTime_Current.Time.Seconds/10;
+ Speed_RecTimeZ_Current+=_T('0')+Speed_RecTime_Current.Time.Seconds%10;
+ #if MEDIAINFO_EVENTS
+ int32u Seconds=Speed_RecTime_Current.Time.Hours *60*60
+ + Speed_RecTime_Current.Time.Minutes *60
+ + Speed_RecTime_Current.Time.Seconds ;
+ Event.RecordedDateTime1|=Seconds;
+ #endif //MEDIAINFO_EVENTS
+ if (Speed_RecTime_Current.Time.Frames!=45)
+ {
+ int32u Milliseconds;
+ if (System_IsValid)
+ Milliseconds=Speed_RecTime_Current.Time.Frames*(System?40:33);
+ else if (DSF_IsValid)
+ Milliseconds=Speed_RecTime_Current.Time.Frames*(DSF?40:33);
+ else
+ Milliseconds=Speed_RecTime_Current.Time.Frames*33;
+ Speed_RecTimeZ_Current+=_T('.');
+ Speed_RecTimeZ_Current+=_T('0')+(Char)(Milliseconds/100);
+ Speed_RecTimeZ_Current+=_T('0')+(Char)((Milliseconds%100)/10);
+ Speed_RecTimeZ_Current+=_T('0')+(Char)(Milliseconds%10);
+ #if MEDIAINFO_EVENTS
+ Event.RecordedDateTime2|=Speed_RecTime_Current.Time.Frames;
+ #endif //MEDIAINFO_EVENTS
+ }
+ else
+ {
+ Speed_RecTimeZ_Current+=_T(" ");
+ #if MEDIAINFO_EVENTS
+ Event.RecordedDateTime2|=0x7F;
+ #endif //MEDIAINFO_EVENTS
+ }
+ Errors_Stats_Line+=Speed_RecTimeZ_Current;
+ if (Speed_RecZ.empty() || Speed_RecZ[0].First.FramePos==Speed_FrameCount) //Empty or the same frame as RecDate
+ {
+ if (Speed_RecZ.empty())
+ Speed_RecZ.resize(1);
+ Speed_RecZ[0].First.FramePos=Speed_FrameCount;
+ Speed_RecZ[0].First.Time=Speed_RecTimeZ_Current;
+ }
+ if (Speed_TimeStampsZ.empty())
+ {
+ Speed_TimeStampsZ.resize(1);
+ Speed_TimeStampsZ[0].First.FramePos=Speed_FrameCount;
+ Speed_TimeStampsZ[0].First.Time+=Ztring().Duration_From_Milliseconds((int64u)Time_Offset);
+ }
+ if (Speed_TimeStampsZ[0].First.FramePos==Speed_FrameCount) //Empty or the same frame as RecDate or the same frame as TimeCode
+ Speed_TimeStampsZ[0].First.Time=Speed_RecTimeZ_Current;
+ }
+ else
+ {
+ Errors_Stats_Line+=_T("XX:XX:XX.XXX");
+ #if MEDIAINFO_EVENTS
+ Event.RecordedDateTime1|=0x1FFFF;
+ Event.RecordedDateTime2|=0x7F;
+ #endif //MEDIAINFO_EVENTS
+ }
+ Errors_Stats_Line+=_T('\t');
+
+ //RecDate/RecTime coherency, Rec start/end
+ bool RecTime_Disrupted=false;
+ if (Speed_RecTime_Current.IsValid && Speed_RecTime_Current_Theory.IsValid
+ && !( Speed_RecTime_Current.Time.Seconds==Speed_RecTime_Current_Theory.Time.Seconds
+ && Speed_RecTime_Current.Time.Minutes==Speed_RecTime_Current_Theory.Time.Minutes
+ && Speed_RecTime_Current.Time.Hours ==Speed_RecTime_Current_Theory.Time.Hours)
+ && !( Speed_RecTime_Current.Time.Seconds==Speed_RecTime_Current_Theory2.Time.Seconds
+ && Speed_RecTime_Current.Time.Minutes==Speed_RecTime_Current_Theory2.Time.Minutes
+ && Speed_RecTime_Current.Time.Hours ==Speed_RecTime_Current_Theory2.Time.Hours))
+ {
+ size_t Speed_RecZ_Pos=Speed_RecZ.size();
+ Speed_RecZ.resize(Speed_RecZ_Pos+1);
+ Speed_RecZ[Speed_RecZ_Pos].First.FramePos=Speed_FrameCount-1;
+ Speed_RecZ[Speed_RecZ_Pos].First.Date=Speed_RecDateZ_Current;
+ Speed_RecZ[Speed_RecZ_Pos].First.Time=Speed_RecTimeZ_Current;
+ Speed_RecZ[Speed_RecZ_Pos-1].Last.FramePos=Speed_FrameCount-1;
+ Speed_RecZ[Speed_RecZ_Pos-1].Last.Date=Speed_RecDateZ_Last;
+ Speed_RecZ[Speed_RecZ_Pos-1].Last.Time=Speed_RecTimeZ_Last;
+
+ Errors_Stats_Line+=_T('N');
+ #if MEDIAINFO_EVENTS
+ Event.RecordedDateTime1|=1<<30;
+ #endif //MEDIAINFO_EVENTS
+ if (!REC_IsValid || REC_ST)
+ {
+ RecTime_Disrupted=true;
+ Errors_AreDetected=true; //If there is a start, this is not an error
+ }
+ }
+ else
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+
+ //Speed_Arb_Current
+ if (Speed_Arb_Current.IsValid)
+ {
+ //Searching the bigest value count
+ int8u Biggest_Pos=0xF;
+ size_t Biggest_Count=0;
+ for (int8u Pos=0; Pos<=0xF; Pos++) //0xF is not considered as a valid value.
+ if (Speed_Arb_Current.Value_Counters[Pos]>Biggest_Count)
+ {
+ Biggest_Pos=Pos;
+ Biggest_Count=Speed_Arb_Current.Value_Counters[Pos];
+ }
+ Errors_Stats_Line+=Ztring::ToZtring(Biggest_Pos, 16);
+ #if MEDIAINFO_EVENTS
+ Event.Arb|=Biggest_Pos;
+ Event.Arb|=1<<4;
+ #endif //MEDIAINFO_EVENTS
+ Speed_Arb_Current.Value=Biggest_Pos;
+ }
+ else
+ Errors_Stats_Line+=_T('X');
+ Errors_Stats_Line+=_T('\t');
+
+ //Speed_Arb_Current coherency
+ if (!Speed_Arb_IsValid && Speed_Arb_Current.IsValid && Speed_Arb_Current.Value!=0)
+ Speed_Arb_IsValid=true;
+ if (Speed_Arb_IsValid && Speed_Arb_Current.IsValid && Speed_Arb_Last.IsValid
+ && Speed_Arb_Current.Value ==Speed_Arb_Last.Value
+ && Speed_Arb_Current.Value!=0xF)
+ {
+ Errors_Stats_Line+=_T('R');
+ #if MEDIAINFO_EVENTS
+ Event.Arb|=1<<7;
+ #endif //MEDIAINFO_EVENTS
+ if (Speed_Arb_Current.Value!=0xF)
+ Arb_AreDetected=true;
+
+ Speed_Arb_Current_Theory.IsValid=false;
+ }
+ else if (Speed_Arb_IsValid && Speed_Arb_Current.IsValid && Speed_Arb_Current_Theory.IsValid
+ && Speed_Arb_Current.Value != Speed_Arb_Current_Theory.Value)
+ {
+ Errors_Stats_Line+=_T('N');
+ #if MEDIAINFO_EVENTS
+ Event.Arb|=1<<6;
+ #endif //MEDIAINFO_EVENTS
+ Speed_Arb_Current_Theory=Speed_Arb_Current;
+ Arb_AreDetected=true;
+ }
+ else
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+
+ //Start
+ if (REC_IsValid && !REC_ST)
+ {
+ Errors_Stats_Line+=_T('S');
+ #if MEDIAINFO_EVENTS
+ Event.RecordedDateTime1|=1<<29;
+ #endif //MEDIAINFO_EVENTS
+ Infos_AreDetected=true;
+ }
+ else
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+
+ //End
+ if (REC_IsValid && !REC_END)
+ {
+ Errors_Stats_Line+=_T('E');
+ #if MEDIAINFO_EVENTS
+ Event.RecordedDateTime1|=1<<28;
+ #endif //MEDIAINFO_EVENTS
+ Infos_AreDetected=true;
+ }
+ else
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+
+ //TimeStamp (RecDate/RecTime and TimeCode together)
+ if (TimeCode_Disrupted || RecTime_Disrupted)
+ {
+ size_t Speed_TimeStampsZ_Pos=Speed_TimeStampsZ.size();
+ Speed_TimeStampsZ.resize(Speed_TimeStampsZ_Pos+1);
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].First.FramePos=Speed_FrameCount-1;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].First.TimeCode=Speed_TimeCodeZ_Current;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].First.Date=Speed_RecDateZ_Current;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].First.Time=Speed_RecTimeZ_Current;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos-1].Last.FramePos=Speed_FrameCount-1;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos-1].Last.TimeCode=Speed_TimeCodeZ_Last;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos-1].Last.Date=Speed_RecDateZ_Last;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos-1].Last.Time=Speed_RecTimeZ_Last;
+ }
+
+ //Channels
+ for (size_t Channel=0; Channel<8; Channel++)
+ {
+ if (!audio_source_IsPresent.empty() && audio_source_IsPresent[Channel])
+ {
+ if (Channel<4 && (!Audio_Invalids.empty() || !Audio_Errors.empty()))
+ {
+ size_t Audio_Errors_Count=0;
+ size_t Pos_Begin=(Channel%2)*(QU_System?6:5);
+ size_t Pos_End=(Channel%2+1)*(QU_System?6:5);
+ if ((Channel>=2 && !QU_FSC)
+ || (Channel< 2 && QU_FSC))
+ Pos_End=Pos_Begin; //Not here
+ if (!Audio_Invalids.empty())
+ for (size_t Pos=Pos_Begin; Pos<Pos_End; Pos++)
+ if (Audio_Invalids[Channel][Pos])
+ Audio_Errors_Count+=Audio_Invalids[Channel][Pos];
+ if (!Audio_Errors.empty())
+ for (size_t Pos=Pos_Begin; Pos<Pos_End; Pos++)
+ if (Audio_Errors[Pos])
+ Audio_Errors_Count+=Audio_Errors[Pos];
+ if (Audio_Errors_Count>=(size_t)((QU_System?6:5)*9))
+ audio_source_IsPresent[Channel]=false;
+ else
+ CH_IsPresent[Channel]=true;
+ }
+ }
+ }
+
+
+ //Error 1: Video errors
+ Ztring Errors_Stats_Line_Details;
+ if (!Video_STA_Errors.empty())
+ {
+ if (!Stats_Total_AlreadyDetected)
+ {
+ Stats_Total_AlreadyDetected=true;
+ Stats_Total++;
+ Stats_Total_WithoutArb++;
+ }
+ Stats[1]++;
+ Errors_Stats_Line+=_T('1');
+
+ size_t Video_STA_Errors_Count=0;
+ Ztring Video_STA_Errors_Details;
+ for (size_t Pos=0; Pos<16; Pos++)
+ {
+ if (Video_STA_Errors[Pos])
+ {
+ Video_STA_Errors_Count+=Video_STA_Errors[Pos];
+ Ztring Video_STA_Errors_Count_Padded=Ztring::ToZtring(Video_STA_Errors[Pos]);
+ if (Video_STA_Errors_Count_Padded.size()<8)
+ Video_STA_Errors_Count_Padded.insert(0, 8-Video_STA_Errors_Count_Padded.size(), _T(' '));
+ Video_STA_Errors_Details+=Video_STA_Errors_Count_Padded;
+ Video_STA_Errors_Details+=_T(" \"");
+ Video_STA_Errors_Details+=Ztring::ToZtring(Pos, 16);
+ Video_STA_Errors_Details+=_T("\" errors, ");
+ if (Video_STA_Errors_Total.empty())
+ Video_STA_Errors_Total.resize(16);
+ Video_STA_Errors_Total[Pos]+=Video_STA_Errors[Pos];
+ }
+ }
+ if (Video_STA_Errors_Details.size()>2)
+ {
+ Ztring Video_STA_Errors_Count_Padded=Ztring::ToZtring(((float)Video_STA_Errors_Count)*100/((DSF_IsValid && DSF)?1500:1350)*(QU_FSC?2:1), 2);
+ if (Video_STA_Errors_Count_Padded.size()<5)
+ Video_STA_Errors_Count_Padded.insert(0, 5-Video_STA_Errors_Count_Padded.size(), _T(' '));
+ Errors_Stats_Line_Details+=Video_STA_Errors_Count_Padded+_T("%");
+ Video_STA_Errors_Details.resize(Video_STA_Errors_Details.size()-2);
+ Errors_Stats_Line_Details+=_T(" (")+Video_STA_Errors_Details+_T(")");
+ Speed_FrameCount_Video_STA_Errors++;
+ Errors_AreDetected=true;
+ }
+ }
+ else
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+ Errors_Stats_Line_Details+=_T('\t');
+
+ //Error 2: Audio errors
+ if (QU!=(int8u)-1 && (!Audio_Invalids.empty() || !Audio_Errors.empty()))
+ {
+ if (Audio_Errors.empty())
+ Audio_Errors.resize(16);
+ bool ErrorsAreAlreadyDetected=false;
+ for (size_t Channel=0; Channel<4; Channel++)
+ {
+ size_t Audio_Errors_Count=0;
+ Ztring Audio_Errors_Details;
+ size_t Pos_Begin=(Channel%2)*(QU_System?6:5);
+ size_t Pos_End=(Channel%2+1)*(QU_System?6:5);
+ if ((Channel>=2 && !QU_FSC)
+ || (Channel< 2 && QU_FSC)
+ || !CH_IsPresent[Channel])
+ Pos_End=Pos_Begin; //Not here
+ for (size_t Pos=Pos_Begin; Pos<Pos_End; Pos++)
+ {
+ if (Audio_Errors[Pos])
+ {
+ Audio_Errors_Count+=Audio_Errors[Pos];
+ Ztring Audio_Errors_Count_Padded=Ztring::ToZtring(Audio_Errors[Pos]);
+ if (Audio_Errors_Count_Padded.size()<2)
+ Audio_Errors_Count_Padded.insert(0, 2-Audio_Errors_Count_Padded.size(), _T(' '));
+ Audio_Errors_Details+=Audio_Errors_Count_Padded;
+ Audio_Errors_Details+=_T(" Dseq=");
+ Audio_Errors_Details+=Ztring::ToZtring(Pos, 16);
+ Audio_Errors_Details+=_T(", ");
+ if (Audio_Errors_Total.empty())
+ {
+ Audio_Errors_Total.resize(8);
+ for (size_t Audio_Errors_Pos=0; Audio_Errors_Pos<8; Audio_Errors_Pos++)
+ Audio_Errors_Total[Audio_Errors_Pos].resize(16);
+ }
+ Audio_Errors_Total[Channel][Pos]+=Audio_Errors[Pos];
+ }
+ }
+ if (Audio_Errors_Count)
+ {
+ if (!ErrorsAreAlreadyDetected)
+ {
+ if (!Stats_Total_AlreadyDetected)
+ {
+ Stats_Total_AlreadyDetected=true;
+ Stats_Total++;
+ Stats_Total_WithoutArb++;
+ }
+ Stats[2]++;
+ Errors_Stats_Line+=_T('2');
+ }
+
+ Ztring Audio_Errors_Count_Padded=Ztring::ToZtring(((float)Audio_Errors_Count)*100/((DSF_IsValid && DSF)?54:45)*(QU_FSC?2:1), 2);
+ if (Audio_Errors_Count_Padded.size()<2)
+ Audio_Errors_Count_Padded.insert(0, 2-Audio_Errors_Count_Padded.size(), _T(' '));
+ if (ErrorsAreAlreadyDetected)
+ Errors_Stats_Line_Details+=_T(", ");
+ if (Audio_Errors_Count<(size_t)((QU_System?6:5)*9))
+ {
+ Errors_Stats_Line_Details+=_T("CH")+Ztring::ToZtring(Channel+1)+_T(": ")+Audio_Errors_Count_Padded+_T("%");
+ Audio_Errors_Details.resize(Audio_Errors_Details.size()-2);
+ Errors_Stats_Line_Details+=_T(" (")+Audio_Errors_Details+_T(")");
+ }
+ else
+ Errors_Stats_Line_Details+=_T("CH")+Ztring::ToZtring(Channel+1)+_T(": no valid DIF");
+
+ Speed_FrameCount_Audio_Errors[Channel]++;
+ ErrorsAreAlreadyDetected=true;
+ Errors_AreDetected=true;
+ }
+ }
+ if (!ErrorsAreAlreadyDetected)
+ Errors_Stats_Line+=_T(' ');
+ }
+ else
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+ Errors_Stats_Line_Details+=_T('\t');
+
+ //Error 3: Timecode incoherency
+ if (Speed_TimeCode_Current.MultipleValues)
+ {
+ if (!Stats_Total_AlreadyDetected)
+ {
+ Stats_Total_AlreadyDetected=true;
+ Stats_Total++;
+ Stats_Total_WithoutArb++;
+ }
+ Stats[3]++;
+ Errors_Stats_Line+=_T('3');
+ Errors_Stats_Line_Details+=_T("Timecode incoherency, first detected value is used");
+ Speed_FrameCount_Timecode_Incoherency++;
+ Errors_AreDetected=true;
+ }
+ else
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+ Errors_Stats_Line_Details+=_T('\t');
+
+ //Error 4: DIF order incoherency
+ if (Speed_Contains_NULL)
+ {
+ if (!Stats_Total_AlreadyDetected)
+ {
+ Stats_Total_AlreadyDetected=true;
+ Stats_Total++;
+ Stats_Total_WithoutArb++;
+ }
+ Stats[4]++;
+ Errors_Stats_Line+=_T('4');
+ Errors_Stats_Line_Details+=Ztring::ToZtring(Speed_Contains_NULL)+_T(" NULL DIFs");
+ Speed_FrameCount_Contains_NULL++;
+ Errors_AreDetected=true;
+ }
+ else
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+ Errors_Stats_Line_Details+=_T('\t');
+
+ //Error 5: Speed_Arb_Current incoherency
+ if (Speed_Arb_Current.MultipleValues)
+ {
+ if (!Stats_Total_AlreadyDetected)
+ {
+ Stats_Total_AlreadyDetected=true;
+ Stats_Total++;
+ }
+ Stats[5]++;
+ Errors_Stats_Line+=_T('5');
+ Ztring Arb_Errors;
+ for (size_t Pos=0; Pos<16; Pos++)
+ if (Speed_Arb_Current.Value_Counters[Pos])
+ {
+ Arb_Errors+=Ztring::ToZtring(Speed_Arb_Current.Value_Counters[Pos]);
+ Arb_Errors+=_T(" Arb bit=\"");
+ Arb_Errors+=Ztring::ToZtring(Pos, 16);
+ Arb_Errors+=_T("\", ");
+ }
+ if (Arb_Errors.size()>2)
+ {
+ Arb_Errors.resize(Arb_Errors.size()-2);
+ Errors_Stats_Line_Details+=Arb_Errors;
+ }
+ Speed_FrameCount_Arb_Incoherency++;
+ Arb_AreDetected=true;
+ }
+ else
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+ Errors_Stats_Line_Details+=_T('\t');
+
+ //Error 6:
+ if (Mpeg4_stts && Mpeg4_stts_Pos<Mpeg4_stts->size() && Speed_FrameCount-1>=Mpeg4_stts->at(Mpeg4_stts_Pos).Pos_Begin && Speed_FrameCount-1<Mpeg4_stts->at(Mpeg4_stts_Pos).Pos_End)
+ {
+ if (!Stats_Total_AlreadyDetected)
+ {
+ Stats_Total_AlreadyDetected=true;
+ Stats_Total++;
+ Stats_Total_WithoutArb++;
+ }
+ Stats[6]++;
+ Errors_Stats_Line+=_T('6');
+ Errors_Stats_Line_Details+=_T("stts flucuation");
+ Speed_FrameCount_Stts_Fluctuation++;
+ Errors_AreDetected=true;
+ }
+ else
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+ Errors_Stats_Line_Details+=_T('\t');
+
+ //Error 7:
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+ Errors_Stats_Line_Details+=_T('\t');
+
+ //Error 8:
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+ Errors_Stats_Line_Details+=_T('\t');
+
+ //Error 9:
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+ Errors_Stats_Line_Details+=_T('\t');
+
+ //Error 0:
+ Errors_Stats_Line+=_T(' ');
+ Errors_Stats_Line+=_T('\t');
+ Errors_Stats_Line_Details+=_T('\t');
+
+ //Filling the main text if needed
+ {
+ #if MEDIAINFO_EVENTS
+ if (!Config->Event_CallBackFunction_IsSet())
+ {
+ Errors_Stats_10+=Errors_Stats_Line;
+ Errors_Stats_10+=Errors_Stats_Line_Details;
+ Errors_Stats_10+=_T("&");
+ }
+ Event.Verbosity=10;
+ #endif //MEDIAINFO_EVENTS
+ }
+ if (Speed_FrameCount==1
+ || Status[IsFinished]
+ || Errors_AreDetected
+ || Infos_AreDetected
+ || Arb_AreDetected)
+ {
+ #if MEDIAINFO_EVENTS
+ if (!Config->Event_CallBackFunction_IsSet())
+ {
+ Errors_Stats_09+=Errors_Stats_Line;
+ Errors_Stats_09+=Errors_Stats_Line_Details;
+ Errors_Stats_09+=_T("&");
+ }
+ Event.Verbosity=9;
+ #endif //MEDIAINFO_EVENTS
+
+ if (Speed_FrameCount==1
+ || Status[IsFinished]
+ || Errors_AreDetected
+ || Infos_AreDetected)
+ {
+ #if MEDIAINFO_EVENTS
+ if (!Config->Event_CallBackFunction_IsSet())
+ {
+ Errors_Stats_05+=Errors_Stats_Line;
+ Errors_Stats_05+=Errors_Stats_Line_Details;
+ Errors_Stats_05+=_T("&");
+ }
+ Event.Verbosity=5;
+ #endif //MEDIAINFO_EVENTS
+
+ if (Speed_FrameCount==1
+ || Status[IsFinished]
+ || Errors_AreDetected)
+ {
+ #if MEDIAINFO_EVENTS
+ if (!Config->Event_CallBackFunction_IsSet())
+ {
+ Errors_Stats_03+=Errors_Stats_Line;
+ Errors_Stats_03+=Errors_Stats_Line_Details;
+ Errors_Stats_03+=_T("&");
+ }
+ Event.Verbosity=3;
+ #endif //MEDIAINFO_EVENTS
+ }
+ }
+ }
+
+ #if MEDIAINFO_EVENTS
+ std::string Errors;
+ if (Errors_Stats_Line_Details.size()>10)
+ {
+ Errors=Errors_Stats_Line_Details.To_Local();
+ Event.Errors=(char*)Errors.c_str();
+ }
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_DvDif_Analysis_Frame_0));
+ #endif //MEDIAINFO_EVENTS
+ }
+
+ //Speed_TimeCode_Current
+ if (!Speed_TimeCode_Current_Theory.IsValid)
+ Speed_TimeCode_Current_Theory=Speed_TimeCode_Current;
+ if (Speed_TimeCode_Current_Theory.IsValid)
+ {
+ int8u Frames_Max;
+ if (System_IsValid)
+ Frames_Max=System?25:30;
+ else if (DSF_IsValid)
+ Frames_Max=DSF?25:30;
+ else
+ Frames_Max=30;
+
+ Speed_TimeCode_Current_Theory.Time.Frames++;
+ if (Speed_TimeCode_Current_Theory.Time.Frames>=Frames_Max)
+ {
+ Speed_TimeCode_Current_Theory.Time.Seconds++;
+ Speed_TimeCode_Current_Theory.Time.Frames=0;
+ if (Speed_TimeCode_Current_Theory.Time.Seconds>=60)
+ {
+ Speed_TimeCode_Current_Theory.Time.Seconds=0;
+ Speed_TimeCode_Current_Theory.Time.Minutes++;
+
+ if (!DSF && Speed_TimeCode_Current_Theory.Time.DropFrame && Speed_TimeCode_Current_Theory.Time.Minutes%10)
+ Speed_TimeCode_Current_Theory.Time.Frames=2; //frames 0 and 1 are dropped for every minutes except 00 10 20 30 40 50
+
+ if (Speed_TimeCode_Current_Theory.Time.Minutes>=60)
+ {
+ Speed_TimeCode_Current_Theory.Time.Minutes=0;
+ Speed_TimeCode_Current_Theory.Time.Hours++;
+ if (Speed_TimeCode_Current_Theory.Time.Hours>=24)
+ {
+ Speed_TimeCode_Current_Theory.Time.Hours=0;
+ }
+ }
+ }
+ }
+ }
+
+ //Speed_RecTime_Current_Theory
+ Speed_RecTime_Current_Theory=Speed_RecTime_Current;
+ Speed_RecTime_Current_Theory2=Speed_RecTime_Current; //Don't change it
+ if (Speed_RecTime_Current_Theory.IsValid)
+ {
+ Speed_RecTime_Current_Theory.Time.Seconds++;
+ if (Speed_RecTime_Current_Theory.Time.Seconds>=60)
+ {
+ Speed_RecTime_Current_Theory.Time.Seconds=0;
+ Speed_RecTime_Current_Theory.Time.Minutes++;
+ if (Speed_RecTime_Current_Theory.Time.Seconds>=60)
+ {
+ Speed_RecTime_Current_Theory.Time.Minutes=0;
+ Speed_RecTime_Current_Theory.Time.Hours++;
+ if (Speed_RecTime_Current_Theory.Time.Hours>=24)
+ {
+ Speed_RecTime_Current_Theory.Time.Hours=0;
+ }
+ }
+ }
+ }
+
+ //Speed_Arb_Current_Theory
+ if (!Speed_Arb_Current_Theory.IsValid && Speed_Arb_Current.Value!=0xF)
+ Speed_Arb_Current_Theory=Speed_Arb_Current;
+ if (Speed_Arb_Current_Theory.IsValid && Speed_Arb_Current.Value!=0xF)
+ {
+ Speed_Arb_Current_Theory.Value++;
+ if (Speed_Arb_Current_Theory.Value>=12)
+ {
+ Speed_Arb_Current_Theory.Value=0;
+ }
+ }
+
+ Speed_TimeCode_Last=Speed_TimeCode_Current;
+ Speed_TimeCode_Current.Clear();
+ Speed_RecDate_Current.IsValid=false;
+ Speed_RecDate_Current.MultipleValues=false;
+ Speed_RecTime_Current.IsValid=false;
+ Speed_RecTime_Current.MultipleValues=false;
+ Speed_Arb_Last=Speed_Arb_Current;
+ Speed_Arb_Current.Clear();
+ Speed_FrameCount++;
+ REC_IsValid=false;
+ Speed_Contains_NULL=0;
+ Frame_AtLeast1DIF=true;
+ if (Buffer_Offset+2>=Buffer_Size
+ || (Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x00))
+ Frame_AtLeast1DIF=false;
+ Video_STA_Errors.clear();
+ Audio_Errors.clear();
+ Audio_Invalids.clear();
+ Stats_Total_AlreadyDetected=false;
+}
+
+void File_DvDif::Errors_Stats_Update_Finnish()
+{
+ if (!Analyze_Activated)
+ {
+ if (Config->File_DvDif_Analysis_Get())
+ Analyze_Activated=true;
+ else
+ return;
+ }
+
+ //Preparing next frame
+ Speed_FrameCount--;
+ Ztring Errors_Stats_End_03;
+ Ztring Errors_Stats_End_05;
+ Ztring Errors_Stats_End_Lines;
+
+ //Frames
+ if (Speed_FrameCount)
+ Errors_Stats_End_Lines+=_T("Frame Count: ")+Ztring::ToZtring(Speed_FrameCount)+_T('&');
+
+ //One block
+ if (!Errors_Stats_End_Lines.empty())
+ {
+ Errors_Stats_End_05+=Errors_Stats_End_Lines;
+ Errors_Stats_End_05+=_T('&');
+ Errors_Stats_End_Lines.clear();
+ }
+
+ //Error 1: Video error concealment
+ if (Speed_FrameCount_Video_STA_Errors)
+ Errors_Stats_End_Lines+=_T("Frame count with video error concealment: ")+Ztring::ToZtring(Speed_FrameCount_Video_STA_Errors)+_T(" frames &");
+ if (!Video_STA_Errors_Total.empty())
+ {
+ Ztring Errors_Details;
+ size_t Errors_Count=0;
+ for (size_t Pos=0; Pos<16; Pos++)
+ {
+ if (Video_STA_Errors_Total[Pos])
+ {
+ Errors_Count+=Video_STA_Errors_Total[Pos];
+ Ztring Errors_Count_Padded=Ztring::ToZtring(Video_STA_Errors_Total[Pos]);
+ if (Errors_Count_Padded.size()<8)
+ Errors_Count_Padded.insert(0, 8-Errors_Count_Padded.size(), _T(' '));
+ Errors_Details+=Errors_Count_Padded;
+ Errors_Details+=_T(" \"");
+ Errors_Details+=Ztring::ToZtring(Pos, 16);
+ Errors_Details+=_T("\" errors, ");
+ }
+ }
+ if (Errors_Details.size()>2)
+ {
+ Errors_Stats_End_Lines+=_T("Total video error concealment: ");
+ Ztring Errors_Count_Padded=Ztring::ToZtring(Errors_Count);
+ if (Errors_Count_Padded.size()<8)
+ Errors_Count_Padded.insert(0, 8-Errors_Count_Padded.size(), _T(' '));
+ Errors_Stats_End_Lines+=_T(" ")+Errors_Count_Padded+_T(" errors");
+ Errors_Details.resize(Errors_Details.size()-2);
+ Errors_Stats_End_Lines+=_T(" (")+Errors_Details+_T(")")+_T('&');
+ }
+ }
+
+ //Error 2: Audio error code
+ if (!Audio_Errors_Total.empty())
+ {
+ for (size_t Channel=0; Channel<8; Channel++)
+ {
+ if (Speed_FrameCount_Audio_Errors[Channel])
+ Errors_Stats_End_Lines+=_T("Frame count with CH")+Ztring::ToZtring(Channel+1)+_T(" audio error code: ")+Ztring::ToZtring(Speed_FrameCount_Audio_Errors[Channel])+_T(" frames &");
+
+ Ztring Errors_Details;
+ size_t Errors_Count=0;
+ for (size_t Pos=0; Pos<16; Pos++)
+ {
+ if (Audio_Errors_Total[Channel][Pos])
+ {
+ Errors_Count+=Audio_Errors_Total[Channel][Pos];
+ Ztring Errors_Count_Padded=Ztring::ToZtring(Audio_Errors_Total[Channel][Pos]);
+ if (Errors_Count_Padded.size()<8)
+ Errors_Count_Padded.insert(0, 8-Errors_Count_Padded.size(), _T(' '));
+ Errors_Details+=Errors_Count_Padded;
+ Errors_Details+=_T(" Dseq=");
+ Errors_Details+=Ztring::ToZtring(Pos, 16);
+ Errors_Details+=_T(", ");
+ }
+ }
+ if (Errors_Details.size()>2)
+ {
+ Errors_Stats_End_Lines+=_T("Total audio error code for CH")+Ztring::ToZtring(Channel+1)+_T(": ");
+ Ztring Errors_Count_Padded=Ztring::ToZtring(Errors_Count);
+ if (Errors_Count_Padded.size()<8)
+ Errors_Count_Padded.insert(0, 8-Errors_Count_Padded.size(), _T(' '));
+ Errors_Stats_End_Lines+=_T(" ")+Errors_Count_Padded+_T(" errors");
+ Errors_Details.resize(Errors_Details.size()-2);
+ Errors_Stats_End_Lines+=_T(" (")+Errors_Details+_T(")")+_T('&');
+ }
+ }
+ }
+
+ //Error 3: Timecode incoherency
+ if (Speed_FrameCount_Timecode_Incoherency)
+ Errors_Stats_End_Lines+=_T("Frame count with DV timecode incoherency: ")+Ztring::ToZtring(Speed_FrameCount_Timecode_Incoherency)+_T(" frames &");
+
+ //Error 4: DIF incohereny
+ if (Speed_FrameCount_Contains_NULL)
+ Errors_Stats_End_Lines+=_T("Frame count with DIF incoherency: ")+Ztring::ToZtring(Speed_FrameCount_Contains_NULL)+_T(" frames &");
+
+ //Error 5: Arbitrary bit inconsistency
+ if (Speed_FrameCount_Arb_Incoherency)
+ Errors_Stats_End_Lines+=_T("Frame count with Arbitrary bit inconsistency: ")+Ztring::ToZtring(Speed_FrameCount_Arb_Incoherency)+_T(" frames &");
+
+ //Error 6: Stts fluctuation
+ if (Speed_FrameCount_Stts_Fluctuation)
+ Errors_Stats_End_Lines+=_T("Frame count with stts fluctuation: ")+Ztring::ToZtring(Speed_FrameCount_Stts_Fluctuation)+_T(" frames &");
+
+ //One block
+ if (!Errors_Stats_End_Lines.empty())
+ {
+ Errors_Stats_End_03+=Errors_Stats_End_Lines;
+ Errors_Stats_End_03+=_T('&');
+ Errors_Stats_End_05+=Errors_Stats_End_Lines;
+ Errors_Stats_End_05+=_T('&');
+ Errors_Stats_End_Lines.clear();
+ }
+
+ //TimeStamps (RecDate/RecTime and TimeCode)
+ if (!Speed_RecDateZ_Current.empty() || !Speed_RecTimeZ_Current.empty()) //Date and Time must be both available
+ {
+ size_t Speed_TimeStampsZ_Pos=Speed_TimeStampsZ.size();
+ if (Speed_TimeStampsZ_Pos)
+ {
+ Speed_TimeStampsZ_Pos--;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].Last.FramePos=Speed_FrameCount;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].Last.FramePos=Speed_FrameCount;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].Last.TimeCode=Speed_TimeCodeZ_Current;
+ if (Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].Last.FramePos-(Speed_TimeStampsZ_Pos?Speed_TimeStampsZ[Speed_TimeStampsZ_Pos-1].Last.FramePos:0)==1) //Only one frame, the "Last" part is not filled
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].Last.TimeCode=Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].First.TimeCode;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].Last.Date=Speed_RecDateZ_Current;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].Last.Time=Speed_RecTimeZ_Current;
+ if (Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].Last.FramePos-(Speed_TimeStampsZ_Pos?Speed_TimeStampsZ[Speed_TimeStampsZ_Pos-1].Last.FramePos:0)==1)
+ {
+ //Only one frame, the "Last" part is not filled
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].Last.Date=Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].First.Date;
+ Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].Last.Time=Speed_TimeStampsZ[Speed_TimeStampsZ_Pos].First.Time;
+ }
+
+ //Framerate computing
+ float64 FrameRate=29.970;
+ if (System_IsValid)
+ FrameRate=System?25.000:29.970;
+ else if (DSF_IsValid)
+ FrameRate=DSF?25.000:29.970;
+ else
+ FrameRate=29.970;
+ if (FrameRate==29.970 && Speed_TimeCode_Current.IsValid && !Speed_TimeCode_Current.Time.DropFrame)
+ FrameRate=30.000;
+
+ Errors_Stats_End_Lines+=_T("Absolute time\tDV timecode range \tRecorded date/time range \tFrame range&");
+ for (size_t Pos=0; Pos<Speed_TimeStampsZ.size(); Pos++)
+ {
+ //Time
+ float64 Time_Offset=(Pos?Speed_TimeStampsZ[Pos-1].Last.FramePos:0)*1000/FrameRate;
+ Errors_Stats_End_Lines+=Ztring().Duration_From_Milliseconds((int64u)Time_Offset);
+
+ Errors_Stats_End_Lines+=_T("\t");
+
+ //TimeCode_range
+ Errors_Stats_End_Lines+=Speed_TimeStampsZ[Pos].First.TimeCode.empty()?Ztring(_T("XX:XX:XX:XX")):Speed_TimeStampsZ[Pos].First.TimeCode;
+
+ Errors_Stats_End_Lines+=_T(" - ");
+
+ Errors_Stats_End_Lines+=Speed_TimeStampsZ[Pos].Last.TimeCode.empty()?Ztring(_T("XX:XX:XX:XX")):Speed_TimeStampsZ[Pos].Last.TimeCode;
+
+ Errors_Stats_End_Lines+=_T("\t");
+
+ //Recorded date/time_range
+ Errors_Stats_End_Lines+=Speed_TimeStampsZ[Pos].First.Date.empty()?Ztring(_T("XXXX-XX-XX")):Speed_TimeStampsZ[Pos].First.Date;
+ Errors_Stats_End_Lines+=_T(' ');
+ Errors_Stats_End_Lines+=Speed_TimeStampsZ[Pos].First.Time.empty()?Ztring(_T("XX:XX:XX:XX")):Speed_TimeStampsZ[Pos].First.Time;
+
+ Errors_Stats_End_Lines+=_T(" - ");
+
+ Errors_Stats_End_Lines+=Speed_TimeStampsZ[Pos].Last.Date.empty()?Ztring(_T("XXXX-XX-XX")):Speed_TimeStampsZ[Pos].Last.Date;
+ Errors_Stats_End_Lines+=_T(' ');
+ Errors_Stats_End_Lines+=Speed_TimeStampsZ[Pos].Last.Time.empty()?Ztring(_T("XX:XX:XX:XX")):Speed_TimeStampsZ[Pos].Last.Time;
+
+ Errors_Stats_End_Lines+=_T("\t");
+
+ //Frame range
+ int64u Start=Pos?Speed_TimeStampsZ[Pos-1].Last.FramePos:0;
+ Ztring Start_Padded=Ztring::ToZtring(Start);
+ if (Start_Padded.size()<8)
+ Start_Padded.insert(0, 8-Start_Padded.size(), _T(' '));
+
+ Errors_Stats_End_Lines+=Start_Padded;
+
+ int64u End=Speed_TimeStampsZ[Pos].Last.FramePos-1;
+ Ztring End_Padded=Ztring::ToZtring(End);
+ if (End_Padded.size()<8)
+ End_Padded.insert(0, 8-End_Padded.size(), _T(' '));
+ Errors_Stats_End_Lines+=_T(" - ")+End_Padded;
+
+ Errors_Stats_End_Lines+=_T('&');
+ }
+ }
+ }
+
+ //One block
+ if (!Errors_Stats_End_Lines.empty())
+ {
+ Errors_Stats_End_05+=Errors_Stats_End_Lines;
+ Errors_Stats_End_05+=_T('&');
+ Errors_Stats_End_Lines.clear();
+ }
+
+ //Stats
+ if (Stats_Total)
+ {
+ Errors_Stats_End_Lines+=_T("Percent of frames with Error: ");
+ Errors_Stats_End_Lines+=Ztring::ToZtring(((float)Stats_Total_WithoutArb*100)/Speed_FrameCount, 2);
+ Errors_Stats_End_Lines+=_T("%");
+ Errors_Stats_End_Lines+=_T('&');
+ Errors_Stats_End_Lines+=_T("Percent of frames with Error (including Arbitrary bit inconsistency): ");
+ Errors_Stats_End_Lines+=Ztring::ToZtring(((float)Stats_Total*100)/Speed_FrameCount, 2);
+ Errors_Stats_End_Lines+=_T("%");
+ Errors_Stats_End_Lines+=_T('&');
+
+ if (Stats[1])
+ {
+ Errors_Stats_End_Lines+=_T("Percent of frames with Video Error Concealment: ");
+ Errors_Stats_End_Lines+=Ztring::ToZtring(((float)Stats[1]*100)/Speed_FrameCount, 2);
+ Errors_Stats_End_Lines+=_T("%");
+ Errors_Stats_End_Lines+=_T('&');
+ }
+
+ if (Stats[2])
+ {
+ Errors_Stats_End_Lines+=_T("Percent of frames with Audio Errors: ");
+ Errors_Stats_End_Lines+=Ztring::ToZtring(((float)Stats[2]*100)/Speed_FrameCount, 2);
+ Errors_Stats_End_Lines+=_T("%");
+ Errors_Stats_End_Lines+=_T('&');
+ }
+
+ if (Stats[3])
+ {
+ Errors_Stats_End_Lines+=_T("Percent of frames with Timecode Incoherency: ");
+ Errors_Stats_End_Lines+=Ztring::ToZtring(((float)Stats[3]*100)/Speed_FrameCount, 2);
+ Errors_Stats_End_Lines+=_T("%");
+ Errors_Stats_End_Lines+=_T('&');
+ }
+
+ if (Stats[4])
+ {
+ Errors_Stats_End_Lines+=_T("Percent of frames with DIF Incoherency: ");
+ Errors_Stats_End_Lines+=Ztring::ToZtring(((float)Stats[4]*100)/Speed_FrameCount, 2);
+ Errors_Stats_End_Lines+=_T("%");
+ Errors_Stats_End_Lines+=_T('&');
+ }
+
+ if (Stats[5])
+ {
+ Errors_Stats_End_Lines+=_T("Percent of frames with Arbitrary bit inconsistency: ");
+ Errors_Stats_End_Lines+=Ztring::ToZtring(((float)Stats[5]*100)/Speed_FrameCount, 2);
+ Errors_Stats_End_Lines+=_T("%");
+ Errors_Stats_End_Lines+=_T('&');
+ }
+
+ if (Stats[6])
+ {
+ Errors_Stats_End_Lines+=_T("Percent of frames with Stts Fluctuation: ");
+ Errors_Stats_End_Lines+=Ztring::ToZtring(((float)Stats[6]*100)/Speed_FrameCount, 2);
+ Errors_Stats_End_Lines+=_T("%");
+ Errors_Stats_End_Lines+=_T('&');
+ }
+ }
+
+ //One block
+ if (!Errors_Stats_End_Lines.empty())
+ {
+ Errors_Stats_End_05+=Errors_Stats_End_Lines;
+ Errors_Stats_End_05+=_T('&');
+ Errors_Stats_End_Lines.clear();
+ }
+
+ //
+ if (Errors_Stats_End_03.size()>2)
+ Errors_Stats_End_03.resize(Errors_Stats_End_03.size()-2); //Removing last carriage returns
+ if (Errors_Stats_End_05.size()>2)
+ Errors_Stats_End_05.resize(Errors_Stats_End_05.size()-2); //Removing last carriage returns
+
+ if (Errors_Stats_End_03.empty())
+ {
+ Errors_Stats_End_03+=_T("No identified errors");
+ Errors_Stats_End_05+=_T("&&No identified errors");
+ }
+
+ //Filling
+ if (Count_Get(Stream_Video)==0)
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, "Errors_Stats_Begin", "Frame # \tAbsolute time\tDV timecode\tN\tRecorded date/time \tN\tA\tN\tS\tE\t1\t2\t3\t4\t5\t6\t7\t8\t9\t0\t1\t2\t3\t4\t5\t6\t7\t8\t9\t0");
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("Errors_Stats_Begin"), Info_Options)=_T("N NT");
+ Fill(Stream_Video, 0, "Errors_Stats_03", Errors_Stats_03);
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("Errors_Stats_03"), Info_Options)=_T("N NT");
+ Fill(Stream_Video, 0, "Errors_Stats_05", Errors_Stats_05);
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("Errors_Stats_05"), Info_Options)=_T("N NT");
+ Fill(Stream_Video, 0, "Errors_Stats_09", Errors_Stats_09);
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("Errors_Stats_09"), Info_Options)=_T("N NT");
+ Fill(Stream_Video, 0, "Errors_Stats_10", Errors_Stats_10);
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("Errors_Stats_10"), Info_Options)=_T("N NT");
+ if (MediaInfoLib::Config.Verbosity_Get()>=(float32)1.0)
+ Fill(Stream_Video, 0, "Errors_Stats", Errors_Stats_10);
+ else if (MediaInfoLib::Config.Verbosity_Get()>=(float32)0.5)
+ Fill(Stream_Video, 0, "Errors_Stats", Errors_Stats_09);
+ else if (MediaInfoLib::Config.Verbosity_Get()>=(float32)0.9)
+ Fill(Stream_Video, 0, "Errors_Stats", Errors_Stats_05);
+ else
+ Fill(Stream_Video, 0, "Errors_Stats", Errors_Stats_03);
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("Errors_Stats"), Info_Options)=_T("N NT");
+ Fill(Stream_Video, 0, "Errors_Stats_End_03", Errors_Stats_End_03);
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("Errors_Stats_End_03"), Info_Options)=_T("N NT");
+ Fill(Stream_Video, 0, "Errors_Stats_End_05", Errors_Stats_End_05);
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("Errors_Stats_End_05"), Info_Options)=_T("N NT");
+ if (MediaInfoLib::Config.Verbosity_Get()>=(float32)0.5)
+ Fill(Stream_Video, 0, "Errors_Stats_End", Errors_Stats_End_05);
+ else
+ Fill(Stream_Video, 0, "Errors_Stats_End", Errors_Stats_End_03);
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("Errors_Stats_End"), Info_Options)=_T("N NT");
+ Fill(Stream_Video, 0, "FrameCount_Speed", Speed_FrameCount);
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("FrameCount_Speed"), Info_Options)=_T("N NT");
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_DV_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dvdv.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dvdv.cpp
new file mode 100644
index 000000000..841c84bac
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dvdv.cpp
@@ -0,0 +1,1586 @@
+// File_Dvdv - Info for DVD objects (IFO) files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about DVD objects
+// (.ifo files on DVD-Video)
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Mainly from http://dvd.sourceforge.net/dvdinfo/ifo.html
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include <vector>
+#ifdef SS
+ #undef SS //Solaris defines this somewhere
+#endif
+using namespace std;
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DVDV_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Dvdv.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+const char* IFO_VTS_Category[]=
+{
+ "Normal",
+ "Karaoke",
+};
+
+const char* IFO_Format_V[]=
+{
+ "MPEG Video",
+ "MPEG Video",
+ "",
+ "",
+};
+
+const char* IFO_Format_Version_V[]=
+{
+ "Version 1",
+ "Version 2",
+ "",
+ "",
+};
+
+const char* IFO_CodecV[]=
+{
+ "MPEG-1V",
+ "MPEG-2V",
+ "",
+ "",
+};
+
+const char* IFO_Standard[]=
+{
+ "NTSC",
+ "PAL",
+ "",
+ "",
+};
+
+float32 IFO_AspectRatio[]=
+{
+ (float32)1.333,
+ (float32)0.000,
+ (float32)0.000,
+ (float32)1.778,
+};
+
+const char* IFO_BitRate_Mode[]=
+{
+ "VBR",
+ "CBR",
+};
+
+const size_t IFO_Width[]=
+{720, 704, 352, 352, 0, 0, 0, 0};
+
+const size_t IFO_Height[4][8]=
+{{480, 480, 480, 240, 0, 0, 0, 0}, //NTSC
+ {576, 576, 576, 288, 0, 0, 0, 0}, //PAL
+ { 0, 0, 0, 0, 0, 0, 0, 0}, //Unknown
+ { 0, 0, 0, 0, 0, 0, 0, 0}, //Unknown
+ };
+
+const float64 IFO_FrameRate[]=
+{29.970, 25.000};
+
+const char* IFO_Format_A[]=
+{
+ "AC-3",
+ "",
+ "MPEG Audio",
+ "MPEG Audio",
+ "PCM",
+ "",
+ "DTS",
+ "SDDS",
+};
+
+const char* IFO_Format_Profile_A[]=
+{
+ "",
+ "",
+ "Version 1",
+ "Version 2",
+ "",
+ "",
+ "",
+ "",
+};
+
+const char* IFO_CodecA[]=
+{
+ "AC3",
+ "",
+ "MPEG-1A",
+ "MPEG-2A",
+ "LPCM (Big Endian)",
+ "",
+ "DTS",
+ "SDDS",
+};
+
+const char* IFO_ModeA[]=
+{
+ "",
+ "Karaoke",
+ "Surround",
+ "",
+};
+
+const char* IFO_ResolutionA[]=
+{
+ "16",
+ "20",
+ "24",
+ "DRC",
+};
+
+const int16u IFO_SamplingRate[]=
+{48000, 0, 0, 0, 0, 0, 0, 0};
+
+const char* IFO_Language_MoreA[]=
+{
+ "",
+ "",
+ "For visually impaired",
+ "Director's comments",
+ "Director's comments",
+ "",
+ "",
+ "",
+};
+
+const char* IFO_Format_T[]=
+{
+ "RLE",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+const char* IFO_Resolution_T[]=
+{
+ "2",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+const char* IFO_CodecT[]=
+{
+ "2-bit RLE",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+const char* IFO_Language_MoreT[]=
+{
+ "",
+ "Normal",
+ "Large",
+ "Children",
+ "",
+ "",
+ "Large",
+ "Children",
+ "",
+ "Forced",
+ "",
+ "",
+ "",
+ "Director comments",
+ "Director comments large",
+ "Director comments children",
+};
+
+const size_t IFO_PlaybackTime_FrameRate[]=
+{1, 25, 1, 30};
+
+const char* IFO_MenuType[]=
+{
+ "",
+ "",
+ "",
+ "root",
+ "sub-picture",
+ "audio",
+ "angle",
+ "PTT (chapter)",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+extern const char* AC3_ChannelPositions[];
+extern const char* AC3_ChannelPositions2[];
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Dvdv::File_Dvdv()
+:File__Analyze()
+{
+ //Temp
+ VTS_Attributes_AreHere=false;
+ Program_Pos=0;
+ Time_Pos=0;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dvdv::Streams_Finish()
+{
+ //Purge what is not needed anymore
+ if (!File_Name.empty()) //Only if this is not a buffer, with buffer we can have more data
+ Sectors.clear();
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dvdv::FileHeader_Parse()
+{
+ //Parsing
+ int64u Identifier;
+ int32u Type;
+ Get_C8 (Identifier, "Identifier");
+ Get_C4 (Type, "Type");
+
+ FILLING_BEGIN();
+ //Identifier
+ if (Identifier!=CC8("DVDVIDEO"))
+ {
+ Reject("DVD Video");
+ return;
+ }
+
+ Accept("DVD Video");
+
+ Fill(Stream_General, 0, General_Format, "DVD Video");
+
+ //Versions
+ switch (Type)
+ {
+ case Dvdv::VMG : VMG(); break;
+ case Dvdv::VTS : VTS(); break;
+ default :
+ Reject("DVD Video");
+ return;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+#define SUBELEMENT(_ELEMENT) \
+ { \
+ Element_Begin1(#_ELEMENT); \
+ _ELEMENT(); \
+ Element_End0(); \
+ } \
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VMG()
+{
+ int32u Sector_Pointer_LastSector, Sector_Pointer_TT_SRPT, Sector_Pointer_VMGM_PGCI_UT, Sector_Pointer_VMG_PTL_MAIT, Sector_Pointer_VMG_VTS_ATRT, Sector_Pointer_VMG_TXTDT_MG, Sector_Pointer_VMGM_C_ADT, Sector_Pointer_VMGM_VOBU_ADMAP;
+ int16u Version, Audio_Count, Text_Count;
+ Element_Info1("DVD Video - VMG");
+ Element_Begin1("Header");
+ Info_B4(LastSector, "Last sector of VMG set (last sector of BUP)"); Param_Info2((LastSector+1)*2048, " bytes");
+ Skip_XX(12, "Unknown");
+ Get_B4 (Sector_Pointer_LastSector, "last sector of IFO");
+ Get_B2 (Version, "version number"); Param_Info1(Ztring::ToZtring((Version&0x00F0)>>4)+_T(".")+Ztring::ToZtring(Version&0x000F));
+ Info_B4(Category, "VMG category");
+ Skip_B2( "number of volumes");
+ Skip_B2( "volume number");
+ Skip_B1( "side ID");
+ Skip_XX(19, "Unknown");
+ Skip_B2( "number of title sets");
+ Skip_Local(32, "Provider ID");
+ Skip_B8( "VMG POS");
+ Skip_XX(24, "Unknown");
+ Skip_B4( "end byte address of VMGI_MAT");
+ Skip_B4( "start address of FP_PGC (First Play program chain)");
+ Skip_XX(56, "Unknown");
+ Info_B4(Sector_Pointer_Menu, "start sector of Menu VOB");
+ Get_B4 (Sector_Pointer_TT_SRPT, "sector pointer to TT_SRPT (table of titles)");
+ Get_B4 (Sector_Pointer_VMGM_PGCI_UT, "sector pointer to VMGM_PGCI_UT (Menu Program Chain table)");
+ Get_B4 (Sector_Pointer_VMG_PTL_MAIT, "sector pointer to VMG_PTL_MAIT (Parental Management masks)");
+ Get_B4 (Sector_Pointer_VMG_VTS_ATRT, "sector pointer to VMG_VTS_ATRT (copies of VTS audio/sub-picture attributes)");
+ Get_B4 (Sector_Pointer_VMG_TXTDT_MG, "sector pointer to VMG_TXTDT_MG (text data)");
+ Get_B4 (Sector_Pointer_VMGM_C_ADT, "sector pointer to VMGM_C_ADT (menu cell address table)");
+ Get_B4 (Sector_Pointer_VMGM_VOBU_ADMAP, "sector pointer to VMGM_VOBU_ADMAP (menu VOBU address map)");
+ Skip_XX(32, "Unknown");
+ Element_End0();
+
+ //-VTSM
+ VTS_Attributes_AreHere=true;
+ Element_Begin1("VMGM (VMG for Menu)");
+ Element_Begin1("Video streams");
+ Element_Info2(1, " streams");
+ SUBELEMENT(Video)
+ Element_End0();
+ Element_Begin1("Audio streams");
+ Get_B2 (Audio_Count, "number of audio streams in VMGM_VOBS");
+ Element_Info2(Audio_Count, " streams");
+ for (int16u Pos=0; Pos<8; Pos++)
+ {
+ if (Pos<Audio_Count)
+ SUBELEMENT(Audio)
+ else
+ Skip_XX(8, "Reserved for Audio");
+ }
+ Skip_XX(16, "Unknown");
+ Element_End0();
+ Element_Begin1("Text streams");
+ Get_B2 (Text_Count, "number of subpicture streams in VMGM_VOBS");
+ Element_Info2(Text_Count, " streams");
+ for (int16u Pos=0; Pos<1; Pos++)
+ {
+ if (Pos<Text_Count)
+ SUBELEMENT(Text)
+ else
+ Skip_XX(6, "Reserved for Text");
+ }
+ Skip_XX(164, "Unknown");
+ Element_End0();
+ Element_End0();
+ Skip_XX(2048-Element_Offset, "Junk");
+
+ //Filling
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_Format_Profile, "Menu");
+
+ if (Version>0x001F)
+ return;
+ Sectors.resize(Sector_Pointer_LastSector+1);
+ if (Sector_Pointer_TT_SRPT<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_TT_SRPT]=Sector_TT_SRPT;
+ if (Sector_Pointer_VMGM_PGCI_UT<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VMGM_PGCI_UT]=Sector_VMGM_PGCI_UT;
+ if (Sector_Pointer_VMG_PTL_MAIT<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VMG_PTL_MAIT]=Sector_VMG_PTL_MAIT;
+ if (Sector_Pointer_VMG_VTS_ATRT<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VMG_VTS_ATRT]=Sector_VMG_VTS_ATRT;
+ if (Sector_Pointer_VMG_TXTDT_MG<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VMG_TXTDT_MG]=Sector_VMG_TXTDT_MG;
+ if (Sector_Pointer_VMGM_C_ADT<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VMGM_C_ADT]=Sector_VMGM_C_ADT;
+ if (Sector_Pointer_VMGM_VOBU_ADMAP<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VMGM_VOBU_ADMAP]=Sector_VMGM_VOBU_ADMAP;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VTS()
+{
+ //Parsing
+ int32u Sector_Pointer_LastSector, Sector_Pointer_VTS_PTT_SRPT, Sector_Pointer_VTS_PGCI, Sector_Pointer_VTSM_PGCI_UT, Sector_Pointer_VTS_TMAPTI, Sector_Pointer_VTSM_C_ADT, Sector_Pointer_VTSM_VOBU_ADMAP, Sector_Pointer_VTS_C_ADT, Sector_Pointer_VTS_VOBU_ADMAP;
+ int16u Version, Audio_Count, Text_Count;
+ Element_Info1("DVD Video - VTS (Video Title Set)");
+ Element_Begin1("Header");
+ Info_B4(LastSector, "Last sector of Title set (last sector of BUP)"); Param_Info2((LastSector+1)*2048, " bytes");
+ Skip_XX(12, "Unknown");
+ Get_B4 (Sector_Pointer_LastSector, "last sector of IFO");
+ Get_B2 (Version, "version number"); Param_Info1(Ztring::ToZtring((Version&0x00F0)>>4)+_T(".")+Ztring::ToZtring(Version&0x000F));
+ Info_B4(Category, "VTS category");
+ #if MEDIAINFO_TRACE
+ if (Category<2) Param_Info1(IFO_VTS_Category[Category]);
+ #endif //MEDIAINFO_TRACE
+ Skip_XX(90, "Unknown");
+ Skip_B4( "end byte address of VTS_MAT");
+ Skip_XX(60, "Unknown");
+ Info_B4(StartSector_Menu, "start sector of Menu VOB"); Param_Info2((StartSector_Menu+1)*2048, " bytes");
+ Info_B4(StartSector_Title, "start sector of Title Vob"); Param_Info2((StartSector_Title+1)*2048, " bytes");
+ Get_B4 (Sector_Pointer_VTS_PTT_SRPT, "sector pointer to VTS_PTT_SRPT (Table of Titles and Chapters)");
+ Get_B4 (Sector_Pointer_VTS_PGCI, "sector pointer to VTS_PGCI (Title Program Chain table)");
+ Get_B4 (Sector_Pointer_VTSM_PGCI_UT, "sector pointer to VTSM_PGCI_UT (Menu Program Chain table)");
+ Get_B4 (Sector_Pointer_VTS_TMAPTI, "sector pointer to VTS_TMAPTI (Time map)");
+ Get_B4 (Sector_Pointer_VTSM_C_ADT, "sector pointer to VTSM_C_ADT (Menu cell address table)");
+ Get_B4 (Sector_Pointer_VTSM_VOBU_ADMAP, "sector pointer to VTSM_VOBU_ADMAP(menu VOBU address map)");
+ Get_B4 (Sector_Pointer_VTS_C_ADT, "sector pointer to VTS_C_ADT (Title set cell address table)");
+ Get_B4 (Sector_Pointer_VTS_VOBU_ADMAP, "sector pointer to VTS_VOBU_ADMAP (Title set VOBU address map)");
+ Skip_XX(24, "Unknown");
+ Element_End0();
+
+ //-VTSM
+ Element_Begin1("VTSM (VTS for Menu, Vob 0)");
+ Element_Begin1("Video streams");
+ Element_Info2(1, " streams");
+ SUBELEMENT(Video)
+ Element_End0();
+ Element_Begin1("Audio streams");
+ Get_B2 (Audio_Count, "number of audio streams in VTSM_VOBS");
+ Element_Info2(Audio_Count, " streams");
+ for (int16u Pos=0; Pos<8; Pos++)
+ {
+ if (Pos<Audio_Count)
+ SUBELEMENT(Audio)
+ else
+ Skip_XX(8, "Reserved for Audio");
+ }
+ Skip_XX(16, "Unknown");
+ Element_End0();
+ Element_Begin1("Text streams");
+ Get_B2 (Text_Count, "number of subpicture streams in VTSM_VOBS");
+ Element_Info2(Text_Count, " streams");
+ for (int16u Pos=0; Pos<1; Pos++)
+ {
+ if (Pos<Text_Count)
+ SUBELEMENT(Text)
+ else
+ Skip_XX(6, "Reserved for Text");
+ }
+ Skip_XX(164, "Unknown");
+ Element_End0();
+ Element_End0();
+
+ //-VTS
+ VTS_Attributes_AreHere=true;
+ Element_Begin1("VTS (VTS for movie, Vob 1-9)");
+ Element_Begin1("Video streams");
+ Element_Info2(1, " streams");
+ SUBELEMENT(Video)
+ Element_End0();
+ Element_Begin1("Audio streams");
+ Get_B2 (Audio_Count, "number of audio streams in VMGM_VOBS");
+ Element_Info2(Audio_Count, " streams");
+ for (int16u Pos=0; Pos<8; Pos++)
+ {
+ if (Pos<Audio_Count)
+ SUBELEMENT(Audio)
+ else
+ Skip_XX(8, "Reserved for Audio");
+ }
+ Skip_XX(16, "Unknown");
+ Element_End0();
+ Element_Begin1("Text streams");
+ Get_B2 (Text_Count, "number of subpicture streams in VMGM_VOBS");
+ Element_Info2(Text_Count, " streams");
+ for (int16u Pos=0; Pos<32; Pos++)
+ {
+ if (Pos<Text_Count)
+ SUBELEMENT(Text)
+ else
+ Skip_XX(6, "Reserved for Text");
+ }
+ Skip_XX(2, "Unknown");
+ Element_End0();
+ Element_Begin1("MultiChannel Info");
+ Element_Info2(Audio_Count, " streams");
+ for (int16u Pos=0; Pos<8; Pos++)
+ {
+ if (Pos<Audio_Count)
+ SUBELEMENT(MultiChannel)
+ else
+ Skip_XX(24, "Reserved for multichannel extension");
+ }
+ Element_End0();
+ Element_End0();
+ Skip_XX(2048-Element_Offset, "Junk");
+
+ //Filling
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_Format_Profile, "Program");
+
+ if (Version>0x001F)
+ return;
+ if (Sector_Pointer_LastSector==(int32u)-1 || Sector_Pointer_LastSector+1>File_Size/2048)
+ Sector_Pointer_LastSector=(int32u)(File_Size/2048);
+ Sectors.resize(Sector_Pointer_LastSector+1);
+ if (Sector_Pointer_VTS_PTT_SRPT<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VTS_PTT_SRPT]=Sector_VTS_PTT_SRPT;
+ if (Sector_Pointer_VTS_PGCI<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VTS_PGCI]=Sector_VTS_PGCI;
+ if (Sector_Pointer_VTSM_PGCI_UT<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VTSM_PGCI_UT]=Sector_VTSM_PGCI_UT;
+ if (Sector_Pointer_VTS_TMAPTI<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VTS_TMAPTI]=Sector_VTS_TMAPTI;
+ if (Sector_Pointer_VTSM_C_ADT<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VTSM_C_ADT]=Sector_VTSM_C_ADT;
+ if (Sector_Pointer_VTSM_VOBU_ADMAP<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VTSM_VOBU_ADMAP]=Sector_VTSM_VOBU_ADMAP;
+ if (Sector_Pointer_VTS_C_ADT<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VTS_C_ADT]=Sector_VTS_C_ADT;
+ if (Sector_Pointer_VTS_VOBU_ADMAP<=Sector_Pointer_LastSector)
+ Sectors[Sector_Pointer_VTS_VOBU_ADMAP]=Sector_VTS_VOBU_ADMAP;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::Video()
+{
+ //Parsing
+ int32u Codec, Standard, AspectRatio, Resolution, BitRate_Mode;
+ BS_Begin();
+ Get_BS (2, Codec, "Coding mode"); Param_Info1(IFO_CodecV[Codec]);
+ Get_BS (2, Standard, "Standard"); Param_Info1(IFO_Standard[Standard]);
+ Get_BS (2, AspectRatio, "Aspect ratio"); Param_Info1(IFO_AspectRatio[AspectRatio]);
+ Info_BS(1, Pan, "Automatic Pan/Scan"); Param_Info1(Pan?"No":"Yes");
+ Info_BS(1, Letter, "Automatic Letterbox"); Param_Info1(Letter?"No":"Yes");
+ Skip_BS(1, "CC for line 21 field 1 in GOP (NTSC only)");
+ Skip_BS(1, "CC for line 21 field 2 in GOP (NTSC only)");
+ Get_BS (3, Resolution, "Resolution"); Param_Info1(Ztring::ToZtring(IFO_Width[Resolution])+_T("x")+Ztring::ToZtring(IFO_Height[Standard][Resolution]));
+ Info_BS(1, Letterboxed, "Letterboxed"); Param_Info1(Letter?"Yes":"No");
+ Get_BS (1, BitRate_Mode, "Bitrate mode"); Param_Info1(IFO_BitRate_Mode[BitRate_Mode]);
+ Info_BS(1, Camera, "Camera/Film"); Param_Info1(Letter?"Film":"Camera");
+ BS_End();
+
+ //Filling
+ FILLING_BEGIN();
+ if (VTS_Attributes_AreHere)
+ {
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, StreamPos_Last, Video_Format, IFO_Format_V[Codec]);
+ Fill(Stream_Video, StreamPos_Last, Video_Format_Version, IFO_Format_Version_V[Codec]);
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, IFO_CodecV[Codec]);
+ Fill(Stream_Video, StreamPos_Last, Video_Width, IFO_Width[Resolution]);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, IFO_Height[Standard][Resolution]);
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, IFO_AspectRatio[AspectRatio], 3, true);
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, IFO_FrameRate[Standard]);
+ Fill(Stream_Video, StreamPos_Last, Video_BitRate_Mode, IFO_BitRate_Mode[BitRate_Mode]);
+ Fill(Stream_Video, StreamPos_Last, General_ID, _T("224"));
+ Fill(Stream_Video, StreamPos_Last, General_ID_String, _T("224 (0xE0)"), Unlimited, true);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::Audio()
+{
+ //Parsing
+ Ztring Language;
+ int32u Codec, LanguageType, Mode, Resolution, SamplingRate, Channels;
+ int8u Language_Extension, ChannelsK=(int8u)-1;
+ BS_Begin();
+ Get_BS (3, Codec, "Coding mode"); Param_Info1(IFO_CodecA[Codec]);
+ Info_BS(1, MultiChannel, "Multichannel extension present"); Param_Info1(MultiChannel?"Yes":"No");
+ Get_BS (2, LanguageType, "Language type"); Param_Info1(LanguageType==1?"2CC":"Unknown");
+ Get_BS (2, Mode, "Application mode"); Param_Info1(IFO_ModeA[Mode]);
+ Get_BS (2, Resolution, "Resolution"); Param_Info1C((Codec==2 || Codec==3), IFO_ResolutionA[Resolution]); Param_Info1C((Codec==4), Mode?"DRC":"No DRC");
+ Get_BS (2, SamplingRate, "Sampling rate"); Param_Info1(Ztring::ToZtring(IFO_SamplingRate[SamplingRate]));
+ Get_BS (4, Channels, "Channels"); Param_Info2(Channels+1, " channels");
+ BS_End();
+ Get_Local(3, Language, "Language code");
+ if (!Language.empty() && Language[0]>=0x80)
+ Language.clear(); //this is 0xFF...
+ if (Language==_T("iw"))
+ Language=_T("he"); //Hebrew patch, is "iw" in DVDs
+ Get_B1 (Language_Extension, "Language extension"); Param_Info1C((Language_Extension<8), IFO_Language_MoreA[Language_Extension]);
+ Skip_B1( "Unknown");
+ switch (Mode)
+ {
+ case 1 : //Karaoke
+ {
+ BS_Begin();
+ Skip_BS(1, "Zero");
+ Get_S1 (3, ChannelsK, "Channels");
+ #ifdef MEDIAINFO_AC3_YES
+ Param_Info1(AC3_ChannelPositions[ChannelsK]);
+ #endif //MEDIAINFO_AC3_YES
+ Skip_BS(2, "Version");
+ Info_BS(1, MC, "MC intro present"); Param_Info1(MC?"Yes":"No");
+ Info_BS(1, Duet, "Duet"); Param_Info1(Duet?"Duet":"Solo");
+ BS_End();
+ }
+ break;
+ case 2 : //Surround
+ {
+ BS_Begin();
+ Skip_BS(4, "Reserved");
+ Info_BS(1, DolbyDecode, "Suitable for Dolby surround decoding"); Param_Info1(DolbyDecode?"Yes":"No");
+ Skip_BS(3, "Reserved");
+ BS_End();
+ }
+ break;
+ default:
+ {
+ Skip_B1( "Reserved");
+ }
+ }
+
+ //Filling
+ FILLING_BEGIN();
+ if (VTS_Attributes_AreHere)
+ {
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format, IFO_Format_A[Codec]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, IFO_Format_Profile_A[Codec]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, IFO_CodecA[Codec]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, IFO_SamplingRate[SamplingRate]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels+1);
+ if (Codec==3)
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, IFO_ResolutionA[Resolution]);
+ else if (Codec==4 && Mode)
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, "DRC");
+ Fill(Stream_Audio, StreamPos_Last, Audio_Language, Language);
+ if (Language_Extension<8)
+ Fill(Stream_Audio, StreamPos_Last, Audio_Language_More, IFO_Language_MoreA[Language_Extension]);
+ #ifdef MEDIAINFO_AC3_YES
+ if (Codec==0 && ChannelsK!=(int8u)-1) //AC-3
+ {
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, AC3_ChannelPositions[ChannelsK]);
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, AC3_ChannelPositions2[ChannelsK]);
+ }
+ #endif //MEDIAINFO_AC3_YES
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::Text()
+{
+ //Parsing
+ Ztring Language;
+ int32u Codec, LanguageType;
+ int8u Language_Extension;
+ BS_Begin();
+ Get_BS (3, Codec, "Coding mode"); Param_Info1(IFO_CodecT[Codec]);
+ Skip_BS(3, "Reserved");
+ Get_BS (2, LanguageType, "Language type"); Param_Info1(LanguageType==1?"2CC":"Unknown");
+ BS_End();
+ Skip_B1( "Reserved");
+ Get_Local(3, Language, "Language code");
+ if (!Language.empty() && Language[0]>=0x80)
+ Language.clear(); //this is 0xFF...
+ if (Language==_T("iw"))
+ Language=_T("he"); //Hebrew patch, is "iw" in DVDs
+ Get_B1 (Language_Extension, "Language extension"); Param_Info1C((Language_Extension<16), IFO_Language_MoreT[Language_Extension]);
+
+ //Filling
+ FILLING_BEGIN();
+ if (VTS_Attributes_AreHere)
+ {
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, StreamPos_Last, Text_Format, IFO_Format_T[Codec]);
+ Fill(Stream_Text, StreamPos_Last, Text_BitDepth, IFO_Resolution_T[Codec]);
+ Fill(Stream_Text, StreamPos_Last, Text_Codec, IFO_CodecT[Codec]);
+ Fill(Stream_Text, StreamPos_Last, Text_Language, Language);
+
+ if (Language_Extension<16)
+ Fill(Stream_Text, StreamPos_Last, Text_Language_More, IFO_Language_MoreT[Language_Extension]);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::MultiChannel()
+{
+ //Parsing
+ BS_Begin();
+ Element_Begin1("ACH0");
+ Skip_BS(7, "Reserved");
+ Skip_BS(1, "ACH0 Guide Melody exists");
+ Element_End0();
+ Element_Begin1("ACH1");
+ Skip_BS(7, "Reserved");
+ Skip_BS(1, "ACH1 Guide Melody exists");
+ Element_End0();
+ Element_Begin1("ACH2");
+ Skip_BS(4, "Reserved");
+ Skip_BS(1, "ACH2 Guide Vocal 1 exists");
+ Skip_BS(1, "ACH2 Guide Vocal 2 exists");
+ Skip_BS(1, "ACH2 Guide Melody 1 exists");
+ Skip_BS(1, "ACH2 Guide Melody 2 exists");
+ Element_End0();
+ Element_Begin1("ACH3");
+ Skip_BS(4, "Reserved");
+ Skip_BS(1, "ACH3 Guide Vocal 1 exists");
+ Skip_BS(1, "ACH3 Guide Vocal 2 exists");
+ Skip_BS(1, "ACH3 Guide Melody A exists");
+ Skip_BS(1, "ACH3 Sound Effect A exists");
+ Element_End0();
+ Element_Begin1("ACH4");
+ Skip_BS(4, "Reserved");
+ Skip_BS(1, "ACH4 Guide Vocal 1 exists");
+ Skip_BS(1, "ACH4 Guide Vocal 2 exists");
+ Skip_BS(1, "ACH4 Guide Melody B exists");
+ Skip_BS(1, "ACH4 Sound Effect B exists");
+ Element_End0();
+ BS_End();
+ Skip_XX(19, "Unknown");
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dvdv::Header_Parse()
+{
+ //Calculating
+ size_t Sector_Pos=(size_t)((File_Offset+Buffer_Offset)/2048);
+ size_t Sector_Count=1;
+ while (Sector_Pos+Sector_Count<Sectors.size() && Sectors[Sector_Pos+Sector_Count]==Sector_Nothing)
+ Sector_Count++;
+
+ //Filling
+ Header_Fill_Size(Sector_Count*2048);
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::Data_Parse()
+{
+ //Parsing
+ size_t Sector_Pos=(size_t)((File_Offset+Buffer_Offset)/2048);
+ if (Sector_Pos>=Sectors.size())
+ {
+ Accept("DVD Video");
+ Finish("DVD Video");
+ return;
+ }
+
+ //Parsing
+ switch(Sectors[Sector_Pos])
+ {
+ case Sector_VTS_PTT_SRPT : VTS_PTT_SRPT(); break;
+ case Sector_VTS_PGCI : VTS_PGCI(); break;
+ case Sector_VTSM_PGCI_UT : VTSM_PGCI_UT(); break;
+ case Sector_VTS_TMAPTI : VTS_TMAPTI(); break;
+ case Sector_VTSM_C_ADT : VTSM_C_ADT(); break;
+ case Sector_VTSM_VOBU_ADMAP : VTSM_VOBU_ADMAP(); break;
+ case Sector_VTS_C_ADT : VTS_C_ADT(); break;
+ case Sector_VTS_VOBU_ADMAP : VTS_VOBU_ADMAP(); break;
+ case Sector_TT_SRPT : TT_SRPT(); break;
+ case Sector_VMGM_PGCI_UT : VMGM_PGCI_UT(); break;
+ case Sector_VMG_PTL_MAIT : VMG_PTL_MAIT(); break;
+ case Sector_VMG_VTS_ATRT : VMG_VTS_ATRT(); break;
+ case Sector_VMG_TXTDT_MG : VMG_TXTDT_MG(); break;
+ case Sector_VMGM_C_ADT : VMGM_C_ADT(); break;
+ case Sector_VMGM_VOBU_ADMAP : VMGM_VOBU_ADMAP(); break;
+ default : ;
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VTS_PTT_SRPT ()
+{
+ Element_Name("Table of Titles and Chapters");
+
+ //Parsing
+ int32u Element_RealSize;
+ Element_Begin1("Header");
+ Skip_B2( "Count of elements");
+ Skip_B2( "Unknown");
+ Get_B4 (Element_RealSize, "End address");
+ Element_RealSize++; //Last byte
+ Element_End0();
+ Element_Begin1("Extra data");
+ int32u Offset;
+ Get_B4 (Offset, "Offset of first element");
+ int64u Extra_Size=Offset-Element_Offset;
+ if (Extra_Size>0)
+ Skip_XX(Extra_Size, "Extra data (Unknown)");
+ Element_End0();
+
+ //For each chapter
+ while (Element_Offset<Element_RealSize)
+ {
+ //VTS_PTT
+ int16u PGCN, PGN;
+ Element_Begin0();
+ Get_B2 (PGCN, "Program Chain (PGCN)");
+ Get_B2 (PGN, "Program (PGN)");
+ Element_Name("Chapter"); Element_Info1(Ztring::ToZtring(PGCN)); Element_Info1(Ztring::ToZtring(PGN));
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VTS_PGCI ()
+{
+ Element_Name("Title Program Chain table");
+
+ //Parsing
+ int32u EndAddress;
+ Element_Begin1("Header");
+ int32u Offset;
+ Skip_B2( "Number of Program Chains");
+ Skip_B2( "Reserved");
+ Get_B4 (EndAddress, "End address");
+ if (EndAddress>=Element_Size)
+ EndAddress=(int32u)Element_Size-1;
+ Element_Begin1("PGC category");
+ BS_Begin();
+ Skip_BS(1, "entry PGC");
+ Skip_BS(7, "title number");
+ BS_End();
+ Skip_B1( "Unknown");
+ Skip_B2( "parental management mask");
+ Element_End0();
+ Get_B4 (Offset, "offset to VTS_PGC - relative to VTS_PGCI");
+ if (Offset-16>0)
+ Skip_XX(Offset-16, "Unknown");
+ Element_End0();
+
+ //For each Program
+ //DETAILLEVEL_SET(1.0);
+ while (Element_Offset<=EndAddress)
+ {
+ PGC(Offset, true);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VTSM_PGCI_UT ()
+{
+ Element_Name("Menu Program Chain table");
+
+ //Parsing
+ int16u LU_Count;
+ Element_Begin1("Header");
+ int32u EndAddress, Offset;
+ int8u Flags;
+ Get_B2 (LU_Count, "Number of Language Units");
+ Skip_B2( "Reserved");
+ Get_B4 (EndAddress, "End address");
+ if (EndAddress>=Element_Size)
+ EndAddress=(int32u)Element_Size-1;
+ Skip_C3( "Language");
+ Get_B1 (Flags, "Menu existence flags");
+ Skip_Flags(Flags, 3, "PTT");
+ Skip_Flags(Flags, 4, "angle");
+ Skip_Flags(Flags, 5, "audio");
+ Skip_Flags(Flags, 6, "sub-picture");
+ Skip_Flags(Flags, 7, "root");
+ Get_B4 (Offset, "Offset to VTSM_LU relative to VTSM_PGCI_UT");
+ if (Offset-16>0)
+ Skip_XX(Offset-16, "Unknown");
+ Element_End0();
+
+ for (int16u LU_Pos=0; LU_Pos<LU_Count; LU_Pos++)
+ {
+ Element_Begin1("Language Unit");
+ int32u LU_Size;
+ int16u PGC_Count;
+ Element_Begin1("Header");
+ Get_B2 (PGC_Count, "Number of Program Chains");
+ Skip_B2( "Reserved");
+ Get_B4 (LU_Size, "end address (last byte of last PGC in this LU) relative to VTSM_LU");
+ LU_Size++; //Last byte
+ Element_Begin1("PGC category");
+ int32u EntryPGC;
+ BS_Begin();
+ Get_BS (1, EntryPGC, "Entry PGC");
+ Skip_BS(3, "Unknown");
+ if (EntryPGC)
+ {
+ Info_BS(4, MenuType, "menu type"); Param_Info1(IFO_MenuType[MenuType]);
+ }
+ else
+ {
+ Skip_BS(4, "Reserved");
+ }
+ BS_End();
+ Skip_B1( "Unknown");
+ Skip_B2( "parental management mask");
+ Element_End0();
+ Get_B4 (Offset, "offset to VTSM_PGC relative to VTSM_LU");
+ if (Offset-16>0)
+ Skip_XX(Offset-16, "Unknown");
+ Element_End0();
+ for (int16u PGC_Pos=0; PGC_Pos<PGC_Count; PGC_Pos++)
+ PGC(Element_Offset);
+
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VTS_TMAPTI ()
+{
+ Element_Name("Time map");
+
+ //Parsing
+ Element_Begin1("Header");
+ int32u EndAddress, Offset;
+ Skip_B2( "Number of program chains");
+ Skip_B2( "Reserved");
+ Get_B4 (EndAddress, "End address");
+ if (EndAddress>=Element_Size)
+ EndAddress=(int32u)Element_Size-1;
+ Get_B4 (Offset, "Offset to VTS_TMAP 1");
+ if (Offset-12>0)
+ Skip_XX(Offset-12, "Unknown");
+ Element_End0();
+
+ //DETAILLEVEL_SET(1.0);
+ while (Element_Offset<=EndAddress)
+ {
+ //VTS_TMAP
+ Element_Begin1("Time Map");
+ //std::vector<size_t> Sector_Times;
+ int8u Sector_Times_SecondsPerTime;
+ int16u Count;
+ Get_B1 (Sector_Times_SecondsPerTime, "Time unit (seconds)");
+ Skip_B1( "Unknown");
+ Get_B2 (Count, "Number of entries in map");
+ //Sector_Times.resize(Count);
+ BS_Begin();
+ for (int16u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("Sector Offset");
+ int32u SectorOffset;
+ Skip_BS( 1, "discontinuous with previous");
+ Get_BS (31, SectorOffset, "Sector offset within VOBS of nearest VOBU");
+ //Get_B4 (Sector_Times[Pos], Sector offset within VOBS of nearest VOBU);// Param_Info1(Ztring().Duration_From_Milliseconds((Pos+1)*Sectors_Times_SecondsPerTime[Program_Pos]));
+ //Sector_Times[Pos]&=0x7FFFFFFF; //bit 31 is set if VOBU time codes are discontinuous with previous
+ Element_Info1(SectorOffset);
+ Element_End0();
+ }
+ BS_End();
+ Element_End0();
+
+ //Filling
+ //Sectors_Times.push_back(Sector_Times);
+ //Sectors_Times_SecondsPerTime.push_back(Sector_Times_SecondsPerTime);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VTSM_C_ADT ()
+{
+ Element_Name("Menu cell address table");
+
+ //Parsing
+ int32u EndAddress;
+ Element_Begin1("Header");
+ Skip_B2( "Number of cells");
+ Skip_B2( "Reserved");
+ Get_B4 (EndAddress, "End address");
+ if (EndAddress>=Element_Size)
+ EndAddress=(int32u)Element_Size-1;
+ Element_End0();
+
+ //DETAILLEVEL_SET(1.0);
+ while (Element_Offset<=EndAddress)
+ {
+ //ADT
+ Element_Begin1("Entry");
+ Skip_B2( "VOBidn");
+ Skip_B1( "CELLidn");
+ Skip_B1( "Unknown");
+ Skip_B4( "Starting sector within VOB");
+ Skip_B4( "Ending sector within VOB");
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VTSM_VOBU_ADMAP ()
+{
+ Element_Name("Menu VOBU address map");
+
+ //Parsing
+ int32u EndAddress;
+ Element_Begin1("Header");
+ Get_B4 (EndAddress, "End address");
+ if (EndAddress>=Element_Size)
+ EndAddress=(int32u)Element_Size-1;
+ Element_End0();
+
+ //DETAILLEVEL_SET(1.0);
+ while (Element_Offset<=EndAddress)
+ {
+ //ADMAP
+ Skip_B4( "Starting sector within VOB of first VOBU");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VTS_C_ADT ()
+{
+ Element_Name("Title set cell address table");
+
+ //Parsing
+ int32u EndAddress;
+ Element_Begin1("Header");
+ Skip_B2( "Number of cells");
+ Skip_B2( "Reserved");
+ Get_B4 (EndAddress, "End address");
+ if (EndAddress>=Element_Size)
+ EndAddress=(int32u)Element_Size-1;
+ Element_End0();
+
+ //DETAILLEVEL_SET(1.0);
+ while (Element_Offset<=EndAddress)
+ {
+ //ADT
+ Element_Begin1("Entry");
+ int32u Start, End;
+ int16u VOBidn;
+ int8u CELLidn;
+ Get_B2 (VOBidn, "VOBidn");
+ Get_B1 (CELLidn, "CELLidn");
+ Skip_B1( "Unknown");
+ Get_B4 (Start, "Starting sector within VOB"); Param_Info1(Time_ADT(Start));
+ Get_B4 (End, "Ending sector within VOB"); Param_Info1(Time_ADT(End));
+ Element_End0();
+
+ //Filling
+ FILLING_BEGIN();
+ FILLING_END();
+ //Fill(Ztring::ToZtring(CELLidn).To_Local().c_str(), Time_ADT(Start));
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VTS_VOBU_ADMAP ()
+{
+ Element_Name("Title set VOBU address map");
+
+ //Parsing
+ int32u EndAddress;
+ Element_Begin1("Header");
+ Get_B4 (EndAddress, "End address");
+ if (EndAddress>=Element_Size)
+ EndAddress=(int32u)Element_Size-1;
+ Element_End0();
+
+ //DETAILLEVEL_SET(1.0);
+ while (Element_Offset<Element_Size)
+ {
+ //ADMAP
+ Skip_B4( "Starting sector within VOB of first VOBU");
+ }
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Ztring File_Dvdv::Time_ADT(int32u)
+{
+ return Ztring();
+ /*
+ if (Sectors_Times.empty())
+ return Ztring(); //TODO: it can be empty?
+
+ while (Time_Pos<Sectors_Times[Program_Pos].size() && Sectors_Times[Program_Pos][Time_Pos]<Value)
+ Time_Pos++;
+ if (Time_Pos<Sectors_Times[Program_Pos].size())
+ {
+ int32u Time=(Time_Pos+1)*Sectors_Times_SecondsPerTime[Program_Pos]*1000;
+ float32 Part;
+ //True time is between Time and Time+Sectors_Times_SecondsPerTime, finding where...
+ int32u Sectors_Count;
+ if (Time_Pos==0)
+ Sectors_Count=Sectors_Times[Program_Pos][Time_Pos];
+ else
+ Sectors_Count=Sectors_Times[Program_Pos][Time_Pos]-Sectors_Times[Program_Pos][Time_Pos-1];
+ Part=(Sectors_Times[Program_Pos][Time_Pos]-Value); //Count of more sectors after
+ Part/=Sectors_Count; //Percentage
+ Time=(int32u)((Time_Pos+1-Part)*Sectors_Times_SecondsPerTime[Program_Pos]*1000);
+
+ return Ztring().Duration_From_Milliseconds(Time*1000);
+ }
+ else
+ {
+ int32u Time=(Time_Pos+1)*Sectors_Times_SecondsPerTime[Program_Pos]*1000;
+ float32 Part;
+ //True time is between Time and Time+Sectors_Times_SecondsPerTime, finding where... but with the last offset diffrence
+ int32u Sectors_Count=Sectors_Times[Program_Pos][Time_Pos-1]-Sectors_Times[Program_Pos][Time_Pos-2];
+ Part=((int32s)Sectors_Times[Program_Pos][Time_Pos-1])-((int32s)Value); //Count of more sectors after
+ Part/=Sectors_Count; //Percentage
+ Part+=1; //We were one offset less
+ Time=(int32u)((Time_Pos+1-Part)*Sectors_Times_SecondsPerTime[Program_Pos]*1000);
+
+ return Ztring().Duration_From_Milliseconds(Time*1000);
+ }
+ */
+}
+
+void File_Dvdv::Get_Duration(int64u &Duration, const Ztring &Name)
+{
+ int32u FrameRate, FF;
+ int8u HH, MM, SS;
+ Element_Begin1(Name);
+ Get_B1 (HH, "Hours (BCD)");
+ Get_B1 (MM, "Minutes (BCD)");
+ Get_B1 (SS, "Seconds (BCD)");
+ BS_Begin();
+ Get_BS (2, FrameRate, "Frame rate"); Param_Info2(IFO_PlaybackTime_FrameRate[FrameRate], " fps");
+ Get_BS (6, FF, "Frames (BCD)");
+ BS_End();
+
+ Duration= Ztring::ToZtring(HH, 16).To_int64u() * 60 * 60 * 1000 //BCD
+ + Ztring::ToZtring(MM, 16).To_int64u() * 60 * 1000 //BCD
+ + Ztring::ToZtring(SS, 16).To_int64u() * 1000 //BCD
+ + Ztring::ToZtring(FF, 16).To_int64u() * 1000/IFO_PlaybackTime_FrameRate[FrameRate]; //BCD
+
+ Element_Info1(Ztring::ToZtring(Duration));
+ Element_End0();
+}
+
+
+void File_Dvdv::PGC(int64u Offset, bool Title)
+{
+ vector<int8u> Stream_Control_Audio;
+ vector<int8u> Stream_Control_SubPicture_43;
+ vector<int8u> Stream_Control_SubPicture_Wide;
+ vector<int8u> Stream_Control_SubPicture_Letterbox;
+ vector<int8u> Stream_Control_SubPicture_PanScan;
+ vector<int64u> CellDurations;
+ vector<int8u> ProgramMap;
+
+ //VTS_PGC
+ Element_Begin1("PGC");
+ int16u commands, program_map, cell_playback, cell_position;
+ int8u Program_Count;
+ Element_Begin1("Header");
+ int32u Flags;
+ int8u Cells;
+ int64u TotalDuration;
+ Skip_B2( "Unknown");
+ Get_B1 (Program_Count, "number of programs");
+ Get_B1 (Cells, "number of cells");
+ Get_Duration(TotalDuration, "Duration");
+ Get_B4 (Flags, "prohibited user ops");
+ /*Skip_Flags(Flags, 0, "Time play or search");
+ Skip_Flags(Flags, 1, PTT play or search);
+ Skip_Flags(Flags, 2, Title play);
+ Skip_Flags(Flags, 3, Stop);
+ Skip_Flags(Flags, 4, GoUp);
+ Skip_Flags(Flags, 5, Time or PTT search);
+ Skip_Flags(Flags, 6, TopPG or PrevPG search);
+ Skip_Flags(Flags, 7, NextPG search);
+ Skip_Flags(Flags, 8, Forward scan);
+ Skip_Flags(Flags, 9, Backward scan);
+ Skip_Flags(Flags, 10, Menu call - Title);
+ Skip_Flags(Flags, 11, Menu call - Root);
+ Skip_Flags(Flags, 12, Menu call - Subpicture);
+ Skip_Flags(Flags, 13, Menu call - Audio);
+ Skip_Flags(Flags, 14, Menu call - Angle);
+ Skip_Flags(Flags, 15, Menu call - PTT);
+ Skip_Flags(Flags, 16, Resume);
+ Skip_Flags(Flags, 17, Button select or activate);
+ Skip_Flags(Flags, 18, Still off);
+ Skip_Flags(Flags, 19, Pause on);
+ Skip_Flags(Flags, 20, Audio stream change);
+ Skip_Flags(Flags, 21, Subpicture stream change);
+ Skip_Flags(Flags, 22, Angle change);
+ Skip_Flags(Flags, 23, Karaoke audio mix change);
+ Skip_Flags(Flags, 24, Video presentation mode change);
+ */
+ /*
+ Skip_Flags(Flags, 0, Video presentation mode change);
+ Skip_Flags(Flags, 1, Karaoke audio mix change);
+ Skip_Flags(Flags, 2, Angle change);
+ Skip_Flags(Flags, 3, Subpicture stream change);
+ Skip_Flags(Flags, 4, Audio stream change);
+ Skip_Flags(Flags, 5, Pause on);
+ Skip_Flags(Flags, 6, Still off);
+ Skip_Flags(Flags, 7, Button select or activate);
+ Skip_Flags(Flags, 8, Resume);
+ Skip_Flags(Flags, 9, Menu call - PTT);
+ Skip_Flags(Flags, 10, Menu call - Angle);
+ Skip_Flags(Flags, 11, Menu call - Audio);
+ Skip_Flags(Flags, 12, Menu call - Subpicture);
+ Skip_Flags(Flags, 13, Menu call - Root);
+ Skip_Flags(Flags, 14, Menu call - Title);
+ Skip_Flags(Flags, 15, Backward scan);
+ Skip_Flags(Flags, 16, Forward scan);
+ Skip_Flags(Flags, 17, NextPG search);
+ Skip_Flags(Flags, 18, TopPG or PrevPG search);
+ Skip_Flags(Flags, 19, Time or PTT search);
+ Skip_Flags(Flags, 20, GoUp);
+ Skip_Flags(Flags, 21, Stop);
+ Skip_Flags(Flags, 22, Title play);
+ Skip_Flags(Flags, 23, PTT play or search);
+ Skip_Flags(Flags, 24, Time play or search);
+ */
+ Element_Begin1("Audio Stream Controls");
+ for (size_t Pos=0; Pos<8; Pos++)
+ {
+ Element_Begin1("Audio Stream Control");
+ Element_Info1(Ztring::ToZtring(Pos));
+ int8u Number;
+ bool Available;
+ BS_Begin();
+ Get_SB ( Available, "Stream available");
+ Get_S1 (7, Number, "Stream number");
+ BS_End();
+ Skip_B1( "Reserved");
+ Element_End0();
+ if (Available)
+ Stream_Control_Audio.push_back(Number);
+
+ if (Available && Retrieve(Stream_Audio, Pos, Text_ID).empty() && Sectors[(size_t)((File_Offset+Buffer_Offset)/2048)]==Sector_VTS_PGCI)
+ {
+ while (Pos>Count_Get(Stream_Audio))
+ Stream_Prepare(Stream_Audio);
+
+ int8u ToAdd=0;
+ if (Retrieve(Stream_Audio, Pos, Audio_Format)==_T("AC-3"))
+ ToAdd=0x80;
+ if (Retrieve(Stream_Audio, Pos, Audio_Format)==_T("DTS"))
+ ToAdd=0x88;
+ if (Retrieve(Stream_Audio, Pos, Audio_Format)==_T("LPCM"))
+ ToAdd=0xA0;
+ Ztring ID_String; ID_String.From_Number(ToAdd+Number); ID_String+=_T(" (0x"); ID_String+=Ztring::ToZtring(ToAdd+Number, 16); ID_String+=_T(")");
+ Fill(Stream_Audio, Pos, Audio_ID, ID_String);
+ Fill(Stream_Audio, Pos, Audio_ID_String, ID_String, true);
+ }
+ }
+ Element_End0();
+ Element_Begin1("Subpicture Stream Controls");
+ for (size_t Pos=0; Pos<32; Pos++)
+ {
+ Element_Begin1("Subpicture Stream Control");
+ Element_Info1(Ztring::ToZtring(Pos));
+ int8u Number_43, Number_Wide, Number_Letterbox, Number_PanScan;
+ bool Available;
+ BS_Begin();
+ Get_SB ( Available, "Stream available");
+ Get_S1 (7, Number_43, "Stream number for 4/3");
+ BS_End();
+ Get_B1 (Number_Wide, "Stream number for Wide");
+ Get_B1 (Number_Letterbox, "Stream number for Letterbox");
+ Get_B1 (Number_PanScan, "Stream number for Pan&Scan");
+ Element_End0();
+ if (Available)
+ {
+ Stream_Control_SubPicture_43.push_back(Number_43);
+ Stream_Control_SubPicture_Wide.push_back(Number_Wide);
+ Stream_Control_SubPicture_Letterbox.push_back(Number_Letterbox);
+ Stream_Control_SubPicture_PanScan.push_back(Number_PanScan);
+ }
+
+ if (Available && Retrieve(Stream_Text, Pos, Text_ID).empty() && Sectors[(size_t)((File_Offset+Buffer_Offset)/2048)]==Sector_VTS_PGCI)
+ {
+ while (Pos>Count_Get(Stream_Text))
+ Stream_Prepare(Stream_Text);
+
+ Ztring ID_String; ID_String.From_Number(0x20+Number_Wide); ID_String+=_T(" (0x"); ID_String+=Ztring::ToZtring(0x20+Number_Wide, 16); ID_String+=_T(")");
+ Fill(Stream_Text, Pos, Text_ID, ID_String);
+ Fill(Stream_Text, Pos, Text_ID_String, ID_String, true);
+ }
+ }
+ Element_End0();
+ Skip_B2( "next PGCN");
+ Skip_B2( "previous PGCN");
+ Skip_B2( "goup PGCN");
+ Skip_B1( "PGC still time - 255=infinite");
+ Skip_B1( "PG playback mode");
+ Element_Begin1("palette");
+ for (int Pos=0; Pos<16; Pos++)
+ {
+ Skip_B4( "palette (0 - Y - Cr - Cb)");
+ }
+ Element_End0();
+ Get_B2 (commands, "offset within PGC to commands");
+ Get_B2 (program_map, "offset within PGC to program map");
+ Get_B2 (cell_playback, "offset within PGC to cell playback information table");
+ Get_B2 (cell_position, "offset within PGC to cell position information table");
+ Element_End0();
+
+ //commands
+ if (commands>0)
+ {
+ if (Element_Offset<Offset+commands)
+ Skip_XX(Offset+commands-Element_Offset, "Unknown");
+ Element_Begin1("commands");
+ int16u PreCommands_Count, PostCommands_Count, CellCommands_Count, EndAdress;
+ Get_B2 (PreCommands_Count, "Number of pre commands");
+ Get_B2 (PostCommands_Count, "Number of post commands");
+ Get_B2 (CellCommands_Count, "Number of cell commands");
+ Get_B2 (EndAdress, "End address relative to command table");
+ if (PreCommands_Count>0)
+ {
+ Element_Begin1("Pre commands");
+ for (int16u Pos=0; Pos<PreCommands_Count; Pos++)
+ {
+ Element_Begin1("Pre command");
+ Skip_XX(8, "Pre command");
+ Element_End0();
+ }
+ Element_End0();
+ }
+ if (PostCommands_Count>0)
+ {
+ Element_Begin1("Post commands");
+ for (int16u Pos=0; Pos<PostCommands_Count; Pos++)
+ {
+ Element_Begin1("Post command");
+ Skip_XX(8, "Post command");
+ Element_End0();
+ }
+ Element_End0();
+ }
+ if (CellCommands_Count>0)
+ {
+ Element_Begin1("Cell commands");
+ for (int16u Pos=0; Pos<CellCommands_Count; Pos++)
+ {
+ Element_Begin1("Cell command");
+ Skip_XX(8, "Cell command");
+ Element_End0();
+ }
+ Element_End0();
+ }
+ Element_End0();
+ }
+
+ //program map
+ if (program_map>0)
+ {
+ if (Element_Offset<Offset+program_map)
+ Skip_XX(Offset+program_map-Element_Offset, "Unknown");
+ Element_Begin1("program map");
+ for (int8u Pos=0; Pos<Program_Count; Pos++)
+ {
+ Element_Begin1("Entry");
+ int8u entry;
+ Get_B1( entry, "Entry cell number");
+ ProgramMap.push_back(entry);
+ //Skip_B1( "Entry cell number");
+ Element_End0();
+ }
+ Element_End0();
+ }
+
+ //cell playback
+ if (cell_playback>0)
+ {
+ if (Element_Offset<Offset+cell_playback)
+ Skip_XX(Offset+cell_playback-Element_Offset, "Unknown");
+ Element_Begin1("cell playback");
+ for (int8u Pos=0; Pos<Cells; Pos++)
+ {
+ int64u CellDuration;
+ Element_Begin1("cell");
+ Skip_XX(4, "ToDo");
+ Get_Duration(CellDuration, "Time");
+ Skip_B4( "first VOBU start sector");
+ Skip_B4( "first ILVU end sector");
+ Skip_B4( "last VOBU start sector");
+ Skip_B4( "last VOBU end sector");
+ Element_Info1(Ztring::ToZtring(Pos)); Element_Info1(Ztring::ToZtring(CellDuration));
+ Element_End0();
+
+ CellDurations.push_back(CellDuration);
+ }
+ Element_End0();
+ }
+
+ //cell position
+ if (cell_position>0)
+ {
+ if (Element_Offset<Offset+cell_position)
+ Skip_XX(Offset+cell_position-Element_Offset, "Unknown");
+ Element_Begin1("cell position");
+ for (int8u Pos=0; Pos<Cells; Pos++)
+ {
+ Element_Begin1("cell");
+ Skip_B2( "VOBid");
+ Skip_B1( "reserved");
+ Skip_B1( "Cell id");
+ Element_End0();
+ }
+ Element_End0();
+ }
+
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (Title)
+ {
+ Stream_Prepare(Stream_Menu);
+
+ int64u ProgramTotalDuration=0;
+ Fill(Stream_Menu, StreamPos_Last, Menu_Chapters_Pos_Begin, Count_Get(Stream_Menu, StreamPos_Last), 10, true);
+ for (int8u Pos=0; Pos<ProgramMap.size(); Pos++)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, Ztring().Duration_From_Milliseconds(ProgramTotalDuration).To_Local().c_str(), Ztring(_T("Chapter "))+Ztring::ToZtring(Pos+1));
+
+ int8u End;
+ if (Pos+1>=Program_Count)
+ End=Cells+1;
+ else
+ End=ProgramMap[Pos+1];
+
+ int64u ProgramDuration=0;
+ if (Pos<ProgramMap.size())
+ for (int8u CellPos=ProgramMap[Pos]; CellPos<End; CellPos++)
+ if (CellPos && CellPos<=CellDurations.size())
+ ProgramDuration+=CellDurations[CellPos-1];
+ ProgramTotalDuration+=ProgramDuration;
+ }
+ Fill(Stream_Menu, StreamPos_Last, Menu_Chapters_Pos_End, Count_Get(Stream_Menu, StreamPos_Last), 10, true);
+ Fill(Stream_Menu, StreamPos_Last, Menu_Duration, TotalDuration);
+
+ for (size_t Pos=0; Pos<Stream_Control_Audio.size(); Pos++)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, "List (Audio)", Stream_Control_Audio[Pos]);
+ }
+ for (size_t Pos=0; Pos<Stream_Control_SubPicture_43.size(); Pos++)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, "List (Subtitles 4/3)", Stream_Control_SubPicture_43[Pos]);
+ }
+ for (size_t Pos=0; Pos<Stream_Control_SubPicture_Wide.size(); Pos++)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, "List (Subtitles Wide)", Stream_Control_SubPicture_Wide[Pos]);
+ }
+ for (size_t Pos=0; Pos<Stream_Control_SubPicture_Letterbox.size(); Pos++)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, "List (Subtitles Letterbox)", Stream_Control_SubPicture_Letterbox[Pos]);
+ }
+ for (size_t Pos=0; Pos<Stream_Control_SubPicture_PanScan.size(); Pos++)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, "List (Subtitles Pan&Scan)", Stream_Control_SubPicture_PanScan[Pos]);
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::TT_SRPT()
+{
+ Element_Name("table of titles");
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VMGM_PGCI_UT()
+{
+ Element_Name("Menu Program Chain table");
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VMG_PTL_MAIT()
+{
+ Element_Name("Parental Management masks");
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VMG_VTS_ATRT()
+{
+ Element_Name("copies of VTS audio/sub-picture attributes");
+
+ //Parsing
+ int32u EndAddress;
+ Element_Begin1("Header");
+ int32u Offset;
+ Skip_B4( "Number of title sets");
+ Get_B4 (EndAddress, "End address");
+ if (EndAddress>=Element_Size)
+ EndAddress=(int32u)Element_Size-1;
+ Get_B4 (Offset, "Offset to VTSM_LU relative to VTSM_PGCI_UT");
+ if (Offset-12>0)
+ Skip_XX(Offset-12, "Unknown");
+ Element_End0();
+
+ while (Element_Offset<=EndAddress)
+ {
+ Element_Begin1("VTS_ATRT");
+ Element_Begin1("Header");
+ int32u Size;
+ Get_B4 (Size, "End address");
+ Size++; //Last byte
+ Element_End0();
+ Element_Begin1("Copy of VTS Category");
+ Skip_B4( "VTS Category");
+ Element_End0();
+ Element_Begin1("Copy of VTS attributes");
+ Skip_XX(Size-8, "VTS attributes");
+ Element_End0();
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VMG_TXTDT_MG()
+{
+ Element_Name("text data");
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VMGM_C_ADT()
+{
+ Element_Name("menu cell address table");
+}
+
+//---------------------------------------------------------------------------
+void File_Dvdv::VMGM_VOBU_ADMAP()
+{
+ Element_Name("menu VOBU address map");
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_DVDV_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dvdv.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dvdv.h
new file mode 100644
index 000000000..a977aa262
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dvdv.h
@@ -0,0 +1,129 @@
+// File_Dvdv - Info for DVD objects (IFO) files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about DVD objects
+// (.ifo files on DVD-Video)
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_DvdvH
+#define MediaInfo_File_DvdvH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Dvdv
+//***************************************************************************
+
+class File_Dvdv : public File__Analyze
+{
+protected :
+ //Streams management
+ void Streams_Finish();
+
+public :
+ File_Dvdv();
+
+private :
+ //Buffer
+ void FileHeader_Parse ();
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void VMG();
+ void VTS();
+ void VTS_PTT_SRPT();
+ void VTS_PGCI();
+ void VTSM_PGCI_UT();
+ void VTS_TMAPTI();
+ void VTSM_C_ADT();
+ void VTSM_VOBU_ADMAP();
+ void VTS_C_ADT();
+ void VTS_VOBU_ADMAP();
+ void TT_SRPT();
+ void VMGM_PGCI_UT();
+ void VMG_PTL_MAIT();
+ void VMG_VTS_ATRT();
+ void VMG_TXTDT_MG();
+ void VMGM_C_ADT();
+ void VMGM_VOBU_ADMAP();
+
+ void Video();
+ void Audio();
+ void Text();
+ void MultiChannel();
+
+ //Temp
+ bool VTS_Attributes_AreHere;
+ //std::vector<size_t> Sectors;
+ //std::vector<std::vector<size_t> > Sectors_Times;
+ //std::vector<int8u> Sectors_Times_SecondsPerTime;
+
+ enum sector
+ {
+ Sector_Nothing,
+ Sector_VTS_PTT_SRPT,
+ Sector_VTS_PGCI,
+ Sector_VTSM_PGCI_UT,
+ Sector_VTS_TMAPTI,
+ Sector_VTSM_C_ADT,
+ Sector_VTSM_VOBU_ADMAP,
+ Sector_VTS_C_ADT,
+ Sector_VTS_VOBU_ADMAP,
+ Sector_TT_SRPT,
+ Sector_VMGM_PGCI_UT,
+ Sector_VMG_PTL_MAIT,
+ Sector_VMG_VTS_ATRT,
+ Sector_VMG_TXTDT_MG,
+ Sector_VMGM_C_ADT,
+ Sector_VMGM_VOBU_ADMAP,
+ };
+ std::vector<sector> Sectors;
+
+ //Helpers
+ Ztring Time_ADT(int32u Value);
+ size_t Program_Pos;
+ size_t Time_Pos;
+ void Get_Duration(int64u &Duration, const Ztring &Name);
+ Ztring Time_String; //Value from Time_*()
+ void PGC(int64u Offset, bool Title=false);
+};
+
+//***************************************************************************
+// Const
+//***************************************************************************
+
+namespace Dvdv
+{
+ const int32u VMG=0x2D564D47;
+ const int32u VTS=0x2D565453;
+}
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dxw.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dxw.cpp
new file mode 100644
index 000000000..d03f53e3b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dxw.cpp
@@ -0,0 +1,211 @@
+// File_Dxw - Info for DXW files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DXW_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Dxw.h"
+#include "MediaInfo/MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/Multiple/File__ReferenceFilesHelper.h"
+#include "ZenLib/Dir.h"
+#include "ZenLib/FileName.h"
+#include "ZenLib/Format/Http/Http_Utils.h"
+#include "tinyxml2.h"
+using namespace tinyxml2;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Dxw::File_Dxw()
+:File__Analyze()
+{
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_None; //TODO
+ StreamIDs_Width[0]=sizeof(size_t)*2;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_EventWasSent_Accept_Specific=true;
+ #endif //MEDIAINFO_DEMUX
+
+ //Temp
+ ReferenceFiles=NULL;
+}
+
+//---------------------------------------------------------------------------
+File_Dxw::~File_Dxw()
+{
+ delete ReferenceFiles; //ReferenceFiles=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dxw::Streams_Finish()
+{
+ if (ReferenceFiles==NULL)
+ return;
+
+ ReferenceFiles->ParseReferences();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_Dxw::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ if (ReferenceFiles==NULL)
+ return 0;
+
+ return ReferenceFiles->Read_Buffer_Seek(Method, Value, ID);
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Dxw::FileHeader_Begin()
+{
+ XMLDocument document;
+ if (!FileHeader_Begin_XML(document))
+ return false;
+
+ {
+ XMLElement* Root=document.FirstChildElement("indexFile");
+ if (Root)
+ {
+ const char* Attribute=Root->Attribute("xmlns");
+ if (Attribute==NULL || Ztring().From_UTF8(Attribute)!=_T("urn:digimetrics-xml-wrapper"))
+ {
+ Reject("DXW");
+ return false;
+ }
+
+ Accept("DXW");
+ Fill(Stream_General, 0, General_Format, "DXW");
+
+ ReferenceFiles=new File__ReferenceFilesHelper(this, Config);
+
+ XMLElement* Track=Root->FirstChildElement();
+ while (Track)
+ {
+ if (string(Track->Value())=="clip")
+ {
+ File__ReferenceFilesHelper::reference ReferenceFile;
+
+ Attribute=Track->Attribute("file");
+ if (Attribute)
+ {
+ ReferenceFile.FileNames.push_back(Ztring().From_UTF8(Attribute));
+
+ Attribute=Track->Attribute("type");
+ if (Attribute)
+ {
+ Ztring StreamKind; StreamKind.From_UTF8(Attribute);
+ if (StreamKind==_T("video"))
+ ReferenceFile.StreamKind=Stream_Video;
+ if (StreamKind==_T("audio"))
+ ReferenceFile.StreamKind=Stream_Audio;
+ if (StreamKind==_T("data"))
+ ReferenceFile.StreamKind=Stream_Text; //Not sure this is a right mapping, but this is only used when file is missing
+ }
+
+ ReferenceFile.StreamID=ReferenceFiles->References.size()+1;
+ }
+
+ Attribute=Track->Attribute("framerate");
+ if (Attribute)
+ {
+ ReferenceFile.FrameRate=Ztring().From_UTF8(Attribute).To_float64();
+
+ Attribute=Track->Attribute("type");
+ if (Attribute)
+ {
+ Ztring StreamKind; StreamKind.From_UTF8(Attribute);
+ if (StreamKind==_T("video"))
+ ReferenceFile.StreamKind=Stream_Video;
+ if (StreamKind==_T("audio"))
+ ReferenceFile.StreamKind=Stream_Audio;
+ if (StreamKind==_T("data"))
+ ReferenceFile.StreamKind=Stream_Text; //Not sure this is a right mapping, but this is only used when file is missing
+ }
+
+ XMLElement* Frame=Track->FirstChildElement();
+ while (Frame)
+ {
+ if (string(Frame->Value())=="frame")
+ {
+ Attribute=Frame->Attribute("file");
+ if (Attribute)
+ ReferenceFile.FileNames.push_back(Ztring().From_UTF8(Attribute));
+ }
+
+ Frame=Frame->NextSiblingElement();
+ }
+ }
+
+ ReferenceFile.StreamID=ReferenceFiles->References.size()+1;
+ ReferenceFiles->References.push_back(ReferenceFile);
+ }
+
+ Track=Track->NextSiblingElement();
+ }
+ }
+ else
+ {
+ Reject("DXW");
+ return false;
+ }
+ }
+
+ //All should be OK...
+ return true;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_DXW_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dxw.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dxw.h
new file mode 100644
index 000000000..13cf4176b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Dxw.h
@@ -0,0 +1,69 @@
+// File_Dxw - Info for DXW files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about DXW files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_DxwH
+#define MediaInfo_File_DxwH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class File__ReferenceFilesHelper;
+
+//***************************************************************************
+// Class File_Dxw
+//***************************************************************************
+
+class File_Dxw : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Dxw();
+ ~File_Dxw();
+
+private :
+ //Streams management
+ void Streams_Finish ();
+
+ //Buffer - Global
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Temp
+ File__ReferenceFilesHelper* ReferenceFiles;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Flv.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Flv.cpp
new file mode 100644
index 000000000..d2b2d0d45
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Flv.cpp
@@ -0,0 +1,1519 @@
+// File_Flv - Info for Flash files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+//
+// Examples:
+// http://samples.mplayerhq.hu/FLV/
+//
+// Reverse engineering
+// http://osflash.org/documentation/amf/astypes
+//
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_FLV_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Flv.h"
+#if defined(MEDIAINFO_AVC_YES)
+ #include "MediaInfo/Video/File_Avc.h"
+#endif
+#if defined(MEDIAINFO_AAC_YES)
+ #include "MediaInfo/Audio/File_Aac.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if defined(MEDIAINFO_RM_YES)
+ #include "MediaInfo/Multiple/File_Rm.h"
+#endif
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#include <algorithm>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+const int16u Flv_Channels[]=
+{
+ 1,
+ 2,
+};
+
+const int16u Flv_Resolution[]=
+{
+ 8,
+ 16,
+};
+
+const int16u Flv_SamplingRate[]=
+{
+ 5500,
+ 11025,
+ 22050,
+ 44100,
+ 8000, //Special case for Nellymoser 8kHz mono
+};
+
+const char* Flv_Format_Audio[]=
+{
+ "PCM",
+ "ADPCM",
+ "MPEG Audio",
+ "PCM",
+ "Nellymoser", //16 KHz
+ "Nellymoser", //8 KHz
+ "Nellymoser",
+ "ADPCM",
+ "ADPCM",
+ "",
+ "AAC",
+ "Speex",
+ "",
+ "",
+ "MPEG Audio", //8 KHz
+ "",
+};
+
+const char* Flv_Format_Profile_Audio[]=
+{
+ "",
+ "",
+ "Layer 3",
+ "",
+ "",
+ "",
+ "",
+ "A-law",
+ "U-law",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "Layer 3", //8 KHz
+ "",
+};
+
+const char* Flv_Codec_Audio[]=
+{
+ "Uncompressed",
+ "ADPCM",
+ "MPEG-1 Audio Layer 3",
+ "",
+ "Nellymoser 16kHz mono",
+ "Nellymoser 8kHz mono",
+ "Nellymoser",
+ "ADPCM",
+ "ADPCM",
+ "",
+ "AAC",
+ "Speex",
+ "",
+ "",
+ "MPEG Audio Layer 3",
+ "",
+};
+
+const char* Flv_CodecID_Hint_Audio[]=
+{
+ "",
+ "",
+ "MP3",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "MP3", //8 KHz
+ "",
+};
+
+const char* Flv_Format_Video[]=
+{
+ "",
+ "",
+ "Sorenson Spark",
+ "Screen video",
+ "VP6",
+ "VP6",
+ "Screen video 2",
+ "AVC",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+const char* Flv_Format_Profile_Video[]=
+{
+ "",
+ "",
+ "",
+ "",
+ "",
+ "Alpha channel",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+const char* Flv_Codec_Video[]=
+{
+ "",
+ "",
+ "Sorenson H263",
+ "Screen video",
+ "On2 VP6",
+ "On2 VP6 with alpha channel",
+ "Screen video 2",
+ "AVC",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+const char* Flv_CodecID_Hint_Video[]=
+{
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+const char* Flv_H263_PictureSize[]=
+{
+ "custom, 1 byte",
+ "custom, 2 bytes",
+ "CIF (352x288)",
+ "QCIF (176x144)",
+ "SQCIF (128x96)",
+ "320x240",
+ "160x120",
+ "",
+};
+
+const int16u Flv_H263_WidthHeight[8][2]=
+{
+ { 0, 0},
+ { 0, 0},
+ {352, 288},
+ {176, 144},
+ {128, 96},
+ {320, 240},
+ {160, 120},
+ {0, 0},
+};
+
+const char* Flv_H263_PictureType[]=
+{
+ "IntraFrame",
+ "InterFrame",
+ "InterFrame (Disposable)",
+ "",
+};
+const char* Flv_VP6_FrameMode[]=
+{
+ "IntraFrame",
+ "",
+};
+
+const char* Flv_VP6_Marker[]=
+{
+ "VP6.1/6.2",
+ "VP6.0",
+};
+
+const char* Flv_VP6_Version[]=
+{
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "VP6.0/6.1",
+ "VP6.0 (Electronic Arts)",
+ "VP6.2",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+const char* Flv_VP6_Version2[]=
+{
+ "VP6.0",
+ "",
+ "",
+ "VP6.1/6.2",
+};
+
+const char* Flv_FrameType[]=
+{
+ "",
+ "KeyFrame",
+ "InterFrame",
+ "InterFrame (Disposable)",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+const char* Flv_TagType[]=
+{
+ "DOUBLE",
+ "UI8",
+ "SCRIPTDATASTRING",
+ "SCRIPTDATAOBJECT[n]",
+ "SCRIPTDATASTRING defining the MovieClip path",
+ "Null",
+ "Undefined",
+ "UI16",
+ "SCRIPTDATAVARIABLE[ECMAArrayLength]",
+ "EndOfObject",
+ "SCRIPTDATAVARIABLE[n]",
+ "SCRIPTDATADATE",
+ "SCRIPTDATALONGSTRING",
+ "Unsupported",
+ "Recordset",
+ "XML",
+ "TypedObject",
+ "AMF3 data",
+};
+
+const char* Flv_Amf3Type[]=
+{
+ "Undefined",
+ "Null",
+ "Boolean-false",
+ "Boolean-true",
+ "Integer",
+ "Number",
+ "String",
+ "XML",
+ "Data",
+ "Array",
+ "Object",
+ "XML String",
+ "ByteArray",
+};
+
+const char* Flv_AVCPacketType(int8u Value)
+{
+ switch (Value)
+ {
+ case 0 : return "AVC sequence header";
+ case 1 : return "NALU";
+ case 2 : return "end of sequence";
+ default: return "";
+ }
+}
+
+const char* Flv_AACPacketType(int8u Value)
+{
+ switch (Value)
+ {
+ case 0 : return "AAC sequence header";
+ case 1 : return "AAC Raw";
+ default: return "";
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Flv::File_Flv()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("FLV");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Flv;
+ StreamIDs_Width[0]=2;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ #endif //MEDIAINFO_DEMUX
+
+ //Internal
+ Stream.resize(3); //Null, Video, Audio
+
+ //Temp
+ Searching_Duration=false;
+ MetaData_NotTrustable=false;
+ PreviousTagSize=(int32u)-1;
+ meta_filesize=(int64u)-1;
+ meta_duration=0;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Flv::Streams_Fill()
+{
+ //Coherency
+ if (Count_Get(Stream_Video) && Count_Get(Stream_Audio) && !Retrieve(Stream_Video, 0, Video_BitRate).empty() && Retrieve(Stream_Audio, 0, Audio_BitRate).empty())
+ {
+ Fill(Stream_General, 0, General_OverallBitRate, Retrieve(Stream_Video, 0, Video_BitRate));
+ Clear(Stream_Video, 0, Video_BitRate);
+ }
+
+ //Trying to detect VFR
+ std::vector<int64u> video_stream_FrameRate_Between;
+ for (size_t Pos=1; Pos<video_stream_FrameRate.size(); Pos++)
+ video_stream_FrameRate_Between.push_back(video_stream_FrameRate[Pos]-video_stream_FrameRate[Pos-1]);
+ std::sort(video_stream_FrameRate_Between.begin(), video_stream_FrameRate_Between.end());
+ if (!video_stream_FrameRate_Between.empty())
+ {
+ if (video_stream_FrameRate_Between[0]*0.9<video_stream_FrameRate_Between[video_stream_FrameRate_Between.size()-1]
+ && video_stream_FrameRate_Between[0]*1.1>video_stream_FrameRate_Between[video_stream_FrameRate_Between.size()-1])
+ {
+ float Time;
+ if (video_stream_FrameRate.size()>30)
+ Time=((float)(video_stream_FrameRate[30]-video_stream_FrameRate[0]))/30; //30 frames for handling 30 fps rounding problems
+ else
+ Time=((float)(video_stream_FrameRate[video_stream_FrameRate.size()-1]-video_stream_FrameRate[0]))/(video_stream_FrameRate.size()-1); //30 frames for handling 30 fps rounding problems
+ if (Time)
+ {
+ Fill(Stream_Video, 0, Video_FrameRate, 1000/Time);
+ Fill(Stream_Video, 0, Video_FrameRate_Mode, "CFR");
+ }
+ }
+ else
+ Fill(Stream_Video, 0, Video_FrameRate_Mode, "VFR");
+ }
+
+ //Parsers
+ if (Stream[Stream_Video].Parser!=NULL)
+ {
+ Fill(Stream[Stream_Video].Parser);
+ Merge(*Stream[Stream_Video].Parser, Stream_Video, 0, 0);
+ }
+ if (Stream[Stream_Audio].Parser!=NULL)
+ {
+ Fill(Stream[Stream_Audio].Parser);
+ Merge(*Stream[Stream_Audio].Parser, Stream_Audio, 0, 0);
+
+ //Special case: AAC
+ if (Retrieve(Stream_Audio, 0, Audio_Format)==_T("AAC")
+ || Retrieve(Stream_Audio, 0, Audio_Format)==_T("MPEG Audio")
+ || Retrieve(Stream_Audio, 0, Audio_Format)==_T("Vorbis"))
+ Clear(Stream_Audio, 0, Audio_BitDepth); //Resolution is not valid for AAC / MPEG Audio / Vorbis
+ }
+
+ //Delay
+ if (Stream[Stream_Video].Delay!=(int32u)-1)
+ {
+ Fill(Stream_Video, 0, Video_Delay, Stream[Stream_Video].Delay+Retrieve(Stream_Video, 0, Video_Delay).To_int32u(), 10, true);
+ Fill(Stream_Video, 0, Video_Delay_Source, "Container");
+ }
+ if (Stream[Stream_Audio].Delay!=(int32u)-1)
+ {
+ Fill(Stream_Audio, 0, Audio_Delay, Stream[Stream_Audio].Delay+Retrieve(Stream_Audio, 0, Audio_Delay).To_int32u(), 10, true);
+ Fill(Stream_Audio, 0, Audio_Delay_Source, "Container");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::Streams_Finish()
+{
+ //Duration
+ //if (meta_duration)
+ // Fill(Stream_General, 0, General_Duration, meta_duration, 10, true);
+ Streams_Finish_PerStream(Stream_Video);
+ Streams_Finish_PerStream(Stream_Audio);
+
+ /*
+ float64 FrameRate=Retrieve(Stream_Video, 0, Video_FrameRate).To_float64();
+ if (LastFrame_Time!=(int32u)-1 && FirstFrame_Time!=(int32u)-1)
+ Duration_Final=LastFrame_Time-FirstFrame_Time+((LastFrame_Type==9 && FrameRate)?((int64u)(1000/FrameRate)):0);
+ if (Duration_Final)
+ {
+ if (Count_Get(Stream_Video))
+ Fill(Stream_Video, 0, Video_Duration, Duration_Final, 10, true);
+ if (Count_Get(Stream_Audio))
+ Fill(Stream_Audio, 0, Audio_Duration, Duration_Final, 10, true);
+
+ //Integrity
+ if (Count_Get(Stream_Video) && File_Size!=(int64u)-1 && !Retrieve(Stream_Video, 0, Video_BitRate).empty() && !Retrieve(Stream_Video, 0, Video_Duration).empty())
+ {
+ int64u BitRate_Video_Meta=Retrieve(Stream_Video, 0, Video_BitRate).To_int64u();
+ int64u Duration=Retrieve(Stream_Video, 0, Video_Duration).To_int64u();
+ int64u BitRate_Video_Duration=File_Size*8*1000/Duration;
+ if (Count_Get(Stream_Audio) && !Retrieve(Stream_Audio, 0, Audio_BitRate).empty())
+ {
+ int64u BitRate_Audio=Retrieve(Stream_Audio, 0, Audio_BitRate).To_int64u();
+ if (BitRate_Audio<BitRate_Video_Duration)
+ BitRate_Video_Duration-=BitRate_Audio;
+ else if (BitRate_Audio)
+ BitRate_Video_Duration=0; //There is a problem
+ }
+ if (BitRate_Video_Meta<BitRate_Video_Duration/2 || BitRate_Video_Meta>BitRate_Video_Duration*2)
+ Clear(Stream_Video, 0, Video_BitRate);
+ }
+ }
+ */
+
+ if (Stream[Stream_Video].Parser!=NULL)
+ {
+ Finish(Stream[Stream_Video].Parser);
+ Merge(*Stream[Stream_Video].Parser, Stream_Video, 0, 0);
+ }
+ if (Stream[Stream_Audio].Parser!=NULL)
+ {
+ Finish(Stream[Stream_Audio].Parser);
+ Merge(*Stream[Stream_Audio].Parser, Stream_Audio, 0, 0);
+ }
+
+ if (Retrieve(Stream_General, 0, General_Duration).empty() && Retrieve(Stream_Video, 0, Video_Duration).empty() && meta_duration)
+ Fill(Stream_General, 0, General_Duration, meta_duration, 0, true);
+
+ //Purge what is not needed anymore
+ if (!File_Name.empty()) //Only if this is not a buffer, with buffer we can have more data
+ Stream.clear();
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::Streams_Finish_PerStream(stream_t StreamKind)
+{
+ if (Stream[StreamKind].TimeStamp!=(int32u)-1)
+ {
+ //Calculating the last timestamp (last block included)
+ if (!Stream[StreamKind].Durations.empty())
+ {
+ int64u Durations_Total=0;
+ for (size_t Pos=0; Pos<Stream[StreamKind].Durations.size(); Pos++)
+ Durations_Total+=Stream[StreamKind].Durations[Pos];
+ int32u Duration_Average=float32_int32s(((float32)Durations_Total)/Stream[StreamKind].Durations.size());
+ Stream[StreamKind].TimeStamp+=Duration_Average;
+ }
+
+ Fill(StreamKind, 0, "Duration", Stream[StreamKind].TimeStamp, 10, true);
+ }
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Flv::FileHeader_Parse()
+{
+ //Parsing
+ Element_Begin1("FLV header");
+ std::string Signature;
+ int32u Size;
+ int8u Version, Flags;
+ Get_String(3, Signature, "Signature");
+ Get_B1 (Version, "Version");
+ Get_B1 (Flags, "Flags");
+ Get_Flags (Flags, 0, video_stream_Count, "Video");
+ Get_Flags (Flags, 2, audio_stream_Count, "Audio");
+ Get_B4 (Size, "Size");
+ if (Size>9)
+ Skip_XX(Size-9, "Unknown");
+ Element_End0();
+
+ FILLING_BEGIN();
+ //Integrity
+ if (Signature!="FLV" || Version==0 || Size<9)
+ {
+ Reject();
+ return;
+ }
+
+ //Filling
+ Accept();
+
+ Fill(Stream_General, 0, General_Format, "Flash Video");
+ if (!video_stream_Count && !audio_stream_Count)
+ {
+ //TODO: quick and awful hack for a file having both bools unset, should detect directly the streams
+ video_stream_Count=true;
+ audio_stream_Count=true;
+ }
+ if (video_stream_Count)
+ {
+ Stream_Prepare(Stream_Video);
+ video_stream_FrameRate_Detected=false;
+ }
+ else
+ video_stream_FrameRate_Detected=true;
+ if (audio_stream_Count)
+ Stream_Prepare(Stream_Audio);
+
+ if (Version>1)
+ {
+ Finish();
+ return; //Version more than 1 is not supported
+ }
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Flv::Synchronize()
+{
+ //Synchronizing
+ while (Buffer_Offset+15<=Buffer_Size)
+ {
+ if (Buffer[Buffer_Offset+4]==0x08 || Buffer[Buffer_Offset+4]==0x09)
+ {
+ int32u BodyLength=BigEndian2int24u(Buffer+Buffer_Offset+5);
+ if (File_Offset+Buffer_Offset+15+BodyLength==File_Size)
+ break; //Last block
+ if (File_Offset+Buffer_Offset+15+BodyLength<File_Size)
+ {
+ if (Buffer_Offset+15+BodyLength+15>Buffer_Size)
+ return false; //Need more data
+
+ if (Buffer[Buffer_Offset+15+BodyLength+4]==0x08 || Buffer[Buffer_Offset+15+BodyLength+4]==0x09)
+ break;
+ }
+ }
+
+ Buffer_Offset++;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+15>Buffer_Size)
+ return false;
+
+ //Synched
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Flv::Read_Buffer_Unsynched()
+{
+ if (!Searching_Duration) //If Searching_Duration, we are looking for end in inverse order, no timestamp reset
+ {
+ Stream[Stream_Video].TimeStamp=(int32u)-1;
+ if (Stream[Stream_Video].Parser)
+ Stream[Stream_Video].Parser->Open_Buffer_Unsynch();
+ Stream[Stream_Audio].TimeStamp=(int32u)-1;
+ if (Stream[Stream_Audio].Parser)
+ Stream[Stream_Audio].Parser->Open_Buffer_Unsynch();
+ }
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Flv::Header_Parse()
+{
+ if (Searching_Duration && File_Offset+Buffer_Offset==File_Size-4)
+ {
+ Get_B4 (PreviousTagSize, "PreviousTagSize");
+
+ //Filling
+ Header_Fill_Code((int64u)-1, "End");
+ Header_Fill_Size(4);
+ return;
+ }
+
+ //Parsing
+ int32u BodyLength;
+ int8u Type;
+ Get_B4 (PreviousTagSize, "PreviousTagSize");
+ if (File_Offset+Buffer_Offset+4<File_Size)
+ {
+ int32u Timestamp_Base;
+ int8u Timestamp_Extended;
+ Get_B1 (Type, "Type"); //Param_Info1(Type<19?Flv_Type[Type]:_T("Unknown"));
+ Get_B3 (BodyLength, "BodyLength");
+ Get_B3 (Timestamp_Base, "Timestamp_Base"); //in ms
+ Get_B1 (Timestamp_Extended, "Timestamp_Extended"); //TimeStamp = Timestamp_Extended*0x01000000+Timestamp_Base
+ Skip_B3( "StreamID");
+
+ // For audio, check if it's just an audio config.
+ bool Skip_Timestamps=false;
+ if (Type==0x08)
+ {
+ int16u Format_Info;
+ Peek_B2(Format_Info);
+ int8u Format=(Format_Info>>12)&0x0F;
+ if (Format==10 && (Format_Info&0xFF)==0) // AAC sequence header
+ Skip_Timestamps=true;
+ }
+
+ //Filling
+ if ((Type==0x08 && !Skip_Timestamps) || Type==0x09)
+ {
+ Time=(((int32u)Timestamp_Extended)<<24)|Timestamp_Base;
+ stream_t StreamKind=(Type==0x08)?Stream_Audio:Stream_Video;
+ if (Stream[StreamKind].Delay==(int32u)-1)
+ Stream[StreamKind].Delay=Time;
+ else if (Stream[StreamKind].TimeStamp!=(int32u)-1 && Time>Stream[StreamKind].TimeStamp)
+ Stream[StreamKind].Durations.push_back(Time-Stream[StreamKind].TimeStamp);
+ if (!Searching_Duration || Stream[StreamKind].TimeStamp==(int32u)-1)
+ Stream[StreamKind].TimeStamp=Time;
+ }
+ }
+ else
+ {
+ Type=0;
+ BodyLength=0;
+ }
+
+ //Filling
+ Header_Fill_Code(Type, Ztring().From_Number(Type, 16));
+ Header_Fill_Size(Element_Offset+BodyLength);
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::Data_Parse()
+{
+ switch (Element_Code)
+ {
+ case 0x00 : Element_Name("End Of File"); break;
+ case 0x08 : audio(); break;
+ case 0x09 : video(); break;
+ case 0x12 : meta(); break;
+ case 0xFA : Rm(); break;
+ case (int64u)-1 : //When searching the last frame
+ if (PreviousTagSize>File_Size)
+ {
+ //There is a problem, trying to sync
+ Searching_Duration=false;
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=File_Size;
+ GoToFromEnd(65536);
+ return;
+ }
+ GoTo(File_Size-PreviousTagSize-8, "FLV");
+ return;
+ default : if (Searching_Duration)
+ {
+ Finish(); //This is surely a bad en of file, don't try anymore
+ return;
+ }
+
+ }
+
+ if (Searching_Duration && !MustSynchronize)
+ {
+ if ((((Count_Get(Stream_Video)==0 || Stream[Stream_Video].TimeStamp!=(int32u)-1)
+ && (Count_Get(Stream_Audio)==0 || Stream[Stream_Audio].TimeStamp!=(int32u)-1))
+ || (File_Size>65536*2 && File_Offset+Buffer_Offset-Header_Size-PreviousTagSize-4<File_Size-65536))
+ && Config_ParseSpeed<1)
+ Finish();
+ else if (Element_Code==0xFA) //RM metadata have a malformed PreviousTagSize, always
+ {
+ //Trying to sync
+ Searching_Duration=false;
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=File_Size;
+ GoToFromEnd(Header_Size+Element_Size+65536);
+ return;
+ }
+ else
+ GoTo(File_Offset+Buffer_Offset-Header_Size-PreviousTagSize-4);
+ }
+ else if (!video_stream_Count && !audio_stream_Count && video_stream_FrameRate_Detected && File_Offset+65536*2<File_Size && MediaInfoLib::Config.ParseSpeed_Get()<1) //All streams are parsed
+ {
+ Fill();
+
+ //Trying to find the last frame for duration
+ Read_Buffer_Unsynched(); //This is not synched yet, so we call directly this method instead of Open_Buffer_Unsynched
+ GoToFromEnd(4, "FLV");
+ Searching_Duration=true;
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Flv::video()
+{
+ Element_Name("Video");
+ Stream[Stream_Video].PacketCount++;
+ Element_Info1(Stream[Stream_Video].PacketCount);
+
+ //Handling FrameRate
+ if (!video_stream_FrameRate_Detected)
+ {
+ if (video_stream_FrameRate.empty() || Time!=video_stream_FrameRate[video_stream_FrameRate.size()-1]) //if 2 block witht the same timestamp
+ video_stream_FrameRate.push_back(Time);
+ if (video_stream_FrameRate.size()>30)
+ video_stream_FrameRate_Detected=true;
+ }
+
+ if (Element_Size==0) //Header says that video is present, but there is only one null packet
+ {
+ Element_Info1("Null");
+ return;
+ }
+
+ Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset), ContentType_MainStream);
+
+ //Needed?
+ if (!video_stream_Count && Config_ParseSpeed<1)
+ return; //No more need of Video stream
+
+ //Parsing
+ int8u Codec, FrameType;
+ Element_Begin1("Stream header");
+ BS_Begin();
+ Get_S1 (4, FrameType, "frameType"); Param_Info1(Flv_FrameType[FrameType]);
+ Get_S1 (4, Codec, "codecID"); Param_Info1(Flv_Codec_Video[Codec]); Element_Info1(Flv_Codec_Video[Codec]);
+ BS_End();
+ Element_End0();
+
+ FILLING_BEGIN();
+ //Filling
+ if (Retrieve(Stream_Video, 0, Video_Format).empty())
+ {
+ if (Count_Get(Stream_Video)==0)
+ Stream_Prepare(Stream_Video);
+ if (Codec<8)
+ {
+ Fill(Stream_Video, 0, Video_Format, Flv_Format_Video[Codec]);
+ Fill(Stream_Video, 0, Video_Format_Profile, Flv_Format_Profile_Video[Codec]);
+ Fill(Stream_Video, 0, Video_Codec, Flv_Codec_Video[Codec]);
+ Fill(Stream_Video, 0, Video_CodecID, Codec);
+ Fill(Stream_Video, 0, Video_CodecID_Hint, Flv_CodecID_Hint_Video[Codec]);
+ Fill(Stream_Video, 0, Video_BitDepth, 8); //FLV is not known to support another bit depth
+ }
+ }
+
+ //Parsing video data
+ switch (Codec)
+ {
+ case 2 : video_H263(); break;
+ case 3 : video_ScreenVideo(1); break;
+ case 4 : video_VP6(false); break;
+ case 5 : video_VP6(true); break;
+ case 6 : video_ScreenVideo(2); break;
+ case 7 : video_AVC(); break;
+ default : Skip_XX(Element_Size-Element_Offset, "Unknown");
+ video_stream_Count=false; //No more need of Video stream;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::video_H263()
+{
+ //Parsing
+ int16u Width=0, Height=0;
+ int8u Version, PictureSize, PictureType;
+ bool ExtraInformationFlag;
+ BS_Begin();
+ Skip_S3(17, "PictureStartCode");
+ Get_S1 ( 5, Version, "Version");
+ if (Version>1)
+ return;
+ Skip_S1( 8, "TemporalReference");
+ Get_S1 ( 3, PictureSize, "PictureSize"); Param_Info1(Flv_H263_PictureSize[PictureSize]);
+ switch (PictureSize)
+ {
+ case 0 :
+ Get_S2 ( 8, Width, "Width");
+ Get_S2 ( 8, Height, "Height");
+ break;
+ case 1 :
+ Get_S2 (16, Width, "Width");
+ Get_S2 (16, Height, "Height");
+ break;
+ default :
+ if (PictureSize<8)
+ {
+ Width=Flv_H263_WidthHeight[PictureSize][0];
+ Height=Flv_H263_WidthHeight[PictureSize][1];
+ }
+ }
+ Get_S1 ( 2, PictureType, "PictureSize"); Param_Info1(Flv_H263_PictureType[PictureType]);
+ Skip_SB( "DeblockingFlag");
+ Skip_S1( 5, "Quantizer");
+ Get_SB ( ExtraInformationFlag, "ExtraInformationFlag");
+ while (ExtraInformationFlag)
+ {
+ Skip_S1( 8, "ExtraInformation");
+ Get_SB ( ExtraInformationFlag, "ExtraInformationFlag");
+ }
+ BS_End();
+
+ FILLING_BEGIN();
+ Fill(Stream_Video, 0, Video_Width, Width, 10, true);
+ Fill(Stream_Video, 0, Video_Height, Height, 10, true);
+ video_stream_Count=false; //No more need of Video stream
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::video_ScreenVideo(int8u Version)
+{
+ //Parsing
+ int16u Width, Height;
+ BS_Begin();
+ Info_S1( 4, BlockWidth, "BlockWidth"); Param_Info1((BlockWidth+1)*16);
+ Get_S2 (12, Width, "ImageWidth");
+ Info_S1( 4, BlockHeight, "BlockHeight"); Param_Info1((BlockHeight+1)*16);
+ Get_S2 (12, Height, "ImageHeight");
+ if (Version==2)
+ {
+ Skip_S1(6, "Reserved");
+ Skip_SB( "has IFrameImage");
+ Skip_SB( "has PaletteInfo");
+ }
+ BS_End();
+
+ FILLING_BEGIN();
+ Fill(Stream_Video, 0, Video_Width, Width, 10, true);
+ Fill(Stream_Video, 0, Video_Height, Height, 10, true);
+ video_stream_Count=false; //No more need of Video stream
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// From: http://wiki.multimedia.cx/index.php?title=On2_VP6
+//
+void File_Flv::video_VP6(bool WithAlpha)
+{
+ //Parsing
+ int8u HorizontalAdjustment, VerticalAdjustment;
+ bool FrameMode, Marker;
+ BS_Begin();
+ Get_S1 ( 4, HorizontalAdjustment, "HorizontalAdjustment");
+ Get_S1 ( 4, VerticalAdjustment, "VerticalAdjustment");
+ if (WithAlpha)
+ Skip_S3(24, "OffsetToAlpha");
+ Get_SB ( FrameMode, "FrameMode"); Param_Info1(Flv_VP6_FrameMode[FrameMode]);
+ Skip_S1( 6, "Quantization");
+ Get_SB ( Marker, "Marker"); Param_Info1(Flv_VP6_Marker[Marker]);
+ BS_End();
+ if (FrameMode)
+ {
+ if (Marker==1)
+ Skip_B2( "Offset");
+ }
+ else
+ {
+ int8u Version, Version2, Width, Height;
+ BS_Begin();
+ Get_S1 ( 5, Version, "Version");
+ Get_S1 ( 2, Version2, "Version2");
+ Skip_SB( "Interlace");
+ BS_End();
+ if (Marker || Version2==0)
+ Skip_B2( "Offset");
+ Skip_B1( "MacroBlock_Height");
+ Skip_B1( "MacroBlock_Width");
+ Get_B1 (Height, "Height"); Param_Info1(Ztring::ToZtring(Height*16)+_T(" pixels"));
+ Get_B1 (Width, "Width"); Param_Info1(Ztring::ToZtring(Width*16)+_T(" pixels"));
+
+ FILLING_BEGIN();
+ if (Width && Height)
+ {
+ Fill(Stream_Video, 0, Video_Width, Width*16-HorizontalAdjustment, 10, true);
+ Fill(Stream_Video, 0, Video_Height, Height*16-VerticalAdjustment, 10, true);
+ }
+ video_stream_Count=false; //No more need of Video stream
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::video_AVC()
+{
+ int8u AVCPacketType;
+ Get_B1 (AVCPacketType, "AVCPacketType"); Param_Info1(Flv_AVCPacketType(AVCPacketType));
+ Info_B3(CompositionTime, "CompositionTime"); Param_Info1(Ztring::ToZtring((int32s)(CompositionTime+0xFF000000)));
+
+ switch (AVCPacketType)
+ {
+ case 0 :
+ #ifdef MEDIAINFO_AVC_YES
+ if (Stream[Stream_Video].Parser==NULL)
+ {
+ Stream[Stream_Video].Parser=new File_Avc;
+ Open_Buffer_Init(Stream[Stream_Video].Parser);
+ ((File_Avc*)Stream[Stream_Video].Parser)->MustParse_SPS_PPS=true;
+ ((File_Avc*)Stream[Stream_Video].Parser)->SizedBlocks=true;
+ ((File_Avc*)Stream[Stream_Video].Parser)->MustSynchronize=false;
+ }
+
+ //Parsing
+ Open_Buffer_Continue(Stream[Stream_Video].Parser);
+ #else
+ Skip_XX(Element_Size-Element_Offset, "AVC Data");
+ video_stream_Count=false; //Unable to parse it
+ #endif
+ break;
+ case 1 :
+ #ifdef MEDIAINFO_AVC_YES
+ if (Stream[Stream_Video].Parser==NULL)
+ {
+ //Data before header, this is wrong
+ video_stream_Count=false;
+ break;
+ }
+
+ //Parsing
+ Open_Buffer_Continue(Stream[Stream_Video].Parser);
+
+ //Disabling this stream
+ if (Stream[Stream_Video].Parser->File_GoTo!=(int64u)-1 || Stream[Stream_Video].Parser->Count_Get(Stream_Video)>0)
+ video_stream_Count=false;
+ #else
+ Skip_XX(Element_Size-Element_Offset, "AVC Data");
+ video_stream_Count=false; //Unable to parse it
+ #endif
+ break;
+ default: Skip_XX(Element_Size-Element_Offset, "Unknown");
+ video_stream_Count=false; //Unable to parse it
+ }
+}
+//---------------------------------------------------------------------------
+void File_Flv::audio()
+{
+ Element_Name("Audio");
+ Stream[Stream_Audio].PacketCount++;
+ Element_Info1(Stream[Stream_Audio].PacketCount);
+
+ if (Element_Size==0) //Header says that audio is present, but there is only one null packet
+ {
+ Element_Info1("Null");
+ return;
+ }
+
+ Demux(Buffer+Buffer_Offset+(size_t)Element_Offset+1, (size_t)(Element_Size-Element_Offset-1), ContentType_MainStream);
+
+ //Needed?
+ if (!audio_stream_Count && Config_ParseSpeed<1)
+ return; //No more need of Audio stream
+
+ //Parsing
+ int8u codec, sampling_rate;
+ bool is_16bit, is_stereo;
+ Element_Begin1("Stream header");
+ BS_Begin();
+ Get_S1 (4, codec, "codec"); Param_Info1(Flv_Codec_Audio[codec]); Element_Info1(Flv_Codec_Audio[codec]);
+ Get_S1 (2, sampling_rate, "sampling_rate"); Param_Info1(Ztring::ToZtring(Flv_SamplingRate[sampling_rate])+_T(" Hz"));
+ Get_SB ( is_16bit, "is_16bit"); Param_Info1(Ztring::ToZtring(Flv_Resolution[is_16bit])+_T(" bits"));
+ Get_SB ( is_stereo, "is_stereo"); Param_Info1(Ztring::ToZtring(Flv_Channels[is_stereo])+_T(" channel(s)"));
+ BS_End();
+ Element_End0();
+
+ //Special case
+ if (codec==5) //Nellymoser 8kHz mono
+ {
+ sampling_rate=5; //8000 Hz forced
+ is_stereo=false; //Mono forced
+ }
+
+ FILLING_BEGIN();
+ if (Retrieve(Stream_Audio, 0, Audio_Format).empty())
+ {
+ //Filling
+ if (Count_Get(Stream_Audio)==0)
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Flv_Channels[is_stereo], 10, true);
+ if (codec!=2 && codec!=10 && codec!=14) //MPEG Audio and AAC are not fixed bit depth
+ Fill(Stream_Audio, 0, Audio_BitDepth, Flv_Resolution[is_16bit], 10, true);
+ if (sampling_rate<4)
+ Fill(Stream_Audio, 0, Audio_SamplingRate, Flv_SamplingRate[sampling_rate], 10, true);
+ Fill(Stream_Audio, 0, Audio_Format, Flv_Format_Audio[codec]);
+ Fill(Stream_Audio, 0, Audio_Format_Profile, Flv_Format_Profile_Audio[codec]);
+ Fill(Stream_Audio, 0, Audio_Codec, Flv_Codec_Audio[codec]);
+ Fill(Stream_Audio, 0, Audio_CodecID, codec);
+ Fill(Stream_Audio, 0, Audio_CodecID_Hint, Flv_CodecID_Hint_Audio[codec]);
+ if (codec==1)
+ {
+ //ADPCM
+ Fill(Stream_Audio, 0, Audio_Format_Settings, "ShockWave");
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Firm, "ShockWave");
+ Fill(Stream_Audio, 0, Audio_Codec_Settings, "SWF");
+ Fill(Stream_Audio, 0, Audio_Codec_Settings_Firm, "SWF");
+
+ }
+ }
+
+ //Parsing audio data
+ switch (codec)
+ {
+ case 2 :
+ case 14 : audio_MPEG(); break;
+ case 10 : audio_AAC(); break;
+ default : Skip_XX(Element_Size-Element_Offset, "Unknown");
+ audio_stream_Count=false; //No more need of Audio stream
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::audio_MPEG()
+{
+ #if defined(MEDIAINFO_MPEGA_YES)
+ if (Stream[Stream_Audio].Parser==NULL)
+ {
+ Stream[Stream_Audio].Parser=new File_Mpega;
+ Open_Buffer_Init(Stream[Stream_Audio].Parser);
+ ((File_Mpega*)Stream[Stream_Audio].Parser)->FrameIsAlwaysComplete=true;
+ }
+
+ //Parsing
+ Open_Buffer_Continue(Stream[Stream_Audio].Parser);
+
+ //Disabling this stream
+ if (Stream[Stream_Audio].Parser->File_GoTo!=(int64u)-1 || Stream[Stream_Audio].Parser->Count_Get(Stream_Audio)>0)
+ audio_stream_Count=false;
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::audio_AAC()
+{
+ int8u AACPacketType;
+ Get_B1 (AACPacketType, "AACPacketType"); Param_Info1(Flv_AACPacketType(AACPacketType));
+
+ switch (AACPacketType)
+ {
+ case 0 :
+ #if defined(MEDIAINFO_MPEG4_YES)
+ if (Stream[Stream_Audio].Parser==NULL)
+ {
+ Stream[Stream_Audio].Parser=new File_Aac;
+ ((File_Aac*)Stream[Stream_Audio].Parser)->Mode=File_Aac::Mode_AudioSpecificConfig;
+ Open_Buffer_Init(Stream[Stream_Audio].Parser);
+ }
+
+ //Parsing
+ Open_Buffer_Continue(Stream[Stream_Audio].Parser);
+ #else
+ Skip_XX(Element_Size-Element_Offset, "AAC Data");
+ audio_stream_Count=false; //Unable to parse it
+ #endif
+ break;
+ case 1 :
+ //Parsing
+ Open_Buffer_Continue(Stream[Stream_Audio].Parser);
+
+ audio_stream_Count=false; //No need of more
+ break;
+ default: Skip_XX(Element_Size-Element_Offset, "Unknown");
+ audio_stream_Count=false; //Unable to parse it
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::meta()
+{
+ Element_Name("Meta");
+
+ //Parsing
+ meta_Level=0;
+ meta_SCRIPTDATAOBJECT();
+
+ if (MetaData_NotTrustable)
+ {
+ meta_duration=0;
+ Clear(Stream_Video, 0, Video_StreamSize);
+ Clear(Stream_Video, 0, Video_BitRate);
+ Clear(Stream_Video, 0, Video_Bits__Pixel_Frame_);
+ Clear(Stream_Audio, 0, Audio_StreamSize);
+ Clear(Stream_Audio, 0, Audio_BitRate);
+ Clear(Stream_General, 0, General_Duration);
+ Clear(Stream_General, 0, General_OverallBitRate);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::meta_SCRIPTDATAOBJECT()
+{
+ //Parsing Value
+ std::string StringData;
+ meta_SCRIPTDATAVALUE(StringData);
+ meta_SCRIPTDATAVALUE(StringData);
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::meta_SCRIPTDATAVARIABLE()
+{
+ std::string StringData;
+ int16u StringLength;
+ Element_Begin0();
+ Get_B2 (StringLength, "StringLength");
+ Get_String(StringLength, StringData, "StringData");
+ Element_Name(StringData.c_str());
+
+ //Parsing Value
+ meta_SCRIPTDATAVALUE(StringData);
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::meta_SCRIPTDATAVALUE(const std::string &StringData)
+{
+ //Parsing
+ int8u Type;
+ Get_B1 (Type, "Type"); Param_Info1C((Type<0x12), Flv_TagType[Type]);
+ switch (Type)
+ {
+ case 0x00 : //DOUBLE --> 64 bits Big endian float
+ {
+ float64 Value;
+ Get_BF8(Value, "Value");
+ if (Value==0)
+ break;
+ std::string ToFill;
+ Ztring ValueS;
+ stream_t StreamKind=Stream_General;
+ if (StringData=="width") {ToFill="Width"; StreamKind=Stream_Video; ValueS.From_Number(Value, 0); video_stream_Count=true;} //1 file with FrameRate tag and video stream but no video present tag
+ else if (StringData=="height") {ToFill="Height"; StreamKind=Stream_Video; ValueS.From_Number(Value, 0); video_stream_Count=true;} //1 file with FrameRate tag and video stream but no video present tag
+ else if (StringData=="duration") meta_duration=Value*1000;
+ else if (StringData=="audiodatarate") {ToFill="BitRate"; StreamKind=Stream_Audio; ValueS.From_Number(Value*1000, 0);}
+ else if (StringData=="framerate") {ToFill="FrameRate"; StreamKind=Stream_Video; ValueS.From_Number(Value, 3); video_stream_FrameRate_Detected=true; video_stream_Count=true;} //1 file with FrameRate tag and video stream but no video present tag
+ else if (StringData=="videoframerate") {ToFill="FrameRate"; StreamKind=Stream_Video; ValueS.From_Number(Value, 3); video_stream_FrameRate_Detected=true; video_stream_Count=true;} //1 file with FrameRate tag and video stream but no video present tag
+ else if (StringData=="filesize") {meta_filesize=(int64u)Value;}
+ else if (StringData=="audiosize") {ToFill="StreamSize"; StreamKind=Stream_Audio; ValueS.From_Number(Value, 0); if (Value>File_Size) MetaData_NotTrustable=true;}
+ else if (StringData=="videosize") {ToFill="StreamSize"; StreamKind=Stream_Video; ValueS.From_Number(Value, 0); if (Value>File_Size) MetaData_NotTrustable=true; video_stream_Count=true;} //1 file with FrameRate tag and video stream but no video present tag
+ else if (StringData=="videodatarate") {ToFill="BitRate"; StreamKind=Stream_Video; ValueS.From_Number(Value*1000, 0); video_stream_Count=true;} //1 file with FrameRate tag and video stream but no video present tag
+ else if (StringData=="videocodecid") {; video_stream_Count=true;} //1 file with FrameRate tag and video stream but no video present tag
+ else if (StringData=="audiodelay") {ToFill="Delay"; StreamKind=Stream_Audio; if (Value>0) ValueS.From_Number(Value*1000, 0);}
+ else if (StringData=="audiosamplerate") {ToFill="SamplingRate"; StreamKind=Stream_Audio; if (Value>0) ValueS.From_Number(Value, 0);}
+ else if (StringData=="audiosamplesize") {ToFill="BitDepth"; StreamKind=Stream_Audio; if (Value>0) ValueS.From_Number(Value, 0);}
+ else if (StringData=="totalduration") {ToFill="Duration"; StreamKind=Stream_General; ValueS.From_Number(Value*1000, 0);}
+ else if (StringData=="totaldatarate") {ToFill="OverallBitRate"; StreamKind=Stream_General; ValueS.From_Number(Value*1000, 0);}
+ else if (StringData=="bytelength") {if (File_Size!=Value) MetaData_NotTrustable=true;}
+ else if (!(StringData=="datasize"
+ || StringData=="lasttimestamp"
+ || StringData=="lastkeyframetimestamp"
+ || StringData=="lastkeyframelocation"
+ || StringData=="canSeekToEnd"
+ || StringData=="keyframes_times"
+ || StringData=="keyframes_filepositions"
+ || StringData=="aacaot"
+ || StringData=="audiochannels"
+ || StringData=="audiocodecid"
+ || StringData=="avclevel"
+ || StringData=="avcprofile"
+ || StringData=="moovPosition")) {StreamKind=Stream_General; ToFill=StringData; ValueS.From_Number(Value);}
+ #if MEDIAINFO_TRACE
+ if (ValueS.empty())
+ ValueS.From_Number(Value, 0);
+ Element_Info1(ValueS);
+ #endif //MEDIAINFO_TRACE
+ if (!ToFill.empty())
+ {
+ Fill(StreamKind, 0, ToFill.c_str(), ValueS);
+ if (ToFill=="FrameRate")
+ Fill(StreamKind, 0, "FrameRate_Mode", "CFR");
+ }
+ }
+ break;
+ case 0x01 : //UI8
+ {
+ int8u Value;
+ Get_B1 (Value, "Value");
+ std::string ToFill;
+ if (StringData=="haskeyframes") {}
+ else if (StringData=="hasKeyframes") {}
+ else if (StringData=="hasVideo") {}
+ else if (StringData=="stereo") {}
+ else if (StringData=="canSeekToEnd") {}
+ else if (StringData=="hasAudio") {}
+ else if (StringData=="hasmetadata") {}
+ else if (StringData=="hasMetadata") {}
+ else if (StringData=="hasCuePoints") {}
+ else if (StringData=="canseekontime") {}
+ else {ToFill=StringData;}
+ Element_Info1(Value);
+ Fill(Stream_General, 0, ToFill.c_str(), Value?"Yes":"No");
+ }
+ break;
+ case 0x02 : //SCRIPTDATASTRING
+ {
+ int16u Value_Size;
+ Get_B2 (Value_Size, "Value_Size");
+ if (Value_Size)
+ {
+ Ztring Value;
+ Get_UTF8(Value_Size, Value, "Value");
+ size_t ToFill=(size_t)-1;
+ std::string ToFillS;
+ if (StringData=="creator") {ToFill=General_Encoded_Application;}
+ else if (StringData=="creationdate") {ToFill=General_Encoded_Date; Value.Date_From_String(Value.To_UTF8().c_str());}
+ else if (StringData=="encoder") {ToFill=General_Encoded_Application;}
+ else if (StringData=="Encoded_With") {ToFill=General_Encoded_Application;}
+ else if (StringData=="Encoded_By") {ToFill=General_Encoded_Application;}
+ else if (StringData=="metadatacreator") {ToFill=General_Tagged_Application;}
+ else if (StringData=="sourcedata") {}
+ else if (StringData=="audiocodecid") {}
+ else if (StringData=="videocodecid") {}
+ else
+ ToFillS=StringData;
+ if (Value.find(_T('\r'))!=std::string::npos)
+ Value.resize(Value.find(_T('\r')));
+ if (Value.find(_T('\n'))!=std::string::npos)
+ Value.resize(Value.find(_T('\n')));
+ Element_Info1(Value);
+ if (ToFill!=(size_t)-1)
+ Fill(Stream_General, 0, ToFill, Value);
+ else if (!ToFillS.empty())
+ Fill(Stream_General, 0, StringData.c_str(), Value);
+ }
+ }
+ break;
+ case 0x03 : //SCRIPTDATAOBJECT[n]
+ case 0x10 : //Typed object - SCRIPTDATAOBJECT[n]
+ {
+ std::string StringData2;
+ int16u StringLength2;
+ meta_Level++;
+ meta_LevelFinished[meta_Level]=false;
+ while (!meta_LevelFinished[meta_Level])
+ {
+ if (Element_Offset>=Element_Size)
+ break;
+ Element_Begin0();
+ Get_B2 (StringLength2, "StringLength2");
+ Get_String(StringLength2, StringData2, "StringData2");
+ Element_Name(StringData2.empty()?"EndOfObject":StringData2.c_str());
+ meta_SCRIPTDATAVALUE(StringData+'_'+StringData2);
+ Element_End0();
+ }
+ meta_Level--;
+ }
+ break;
+ case 0x04 : //SCRIPTDATASTRING defining the MovieClip path
+ {
+ int16u Value_Size;
+ Get_B2 (Value_Size, "Value_Size");
+ if (Value_Size)
+ {
+ Ztring Value;
+ Get_Local(Value_Size, Value, "Value");
+ if (Value==_T("unknown")) Value.clear();
+ Element_Info1C((!Value.empty()), Value);
+ Fill(Stream_General, 0, StringData.c_str(), Value);
+ }
+ }
+ break;
+ case 0x05 : //NULL
+ case 0x06 : //Undefined - NULL
+ case 0x0D : //Unsupported - NULL
+ break;
+ case 0x07 : //UI16
+ {
+ int16u Value;
+ Get_B2 (Value, "Value");
+ Element_Info1(Value);
+ Fill(Stream_General, 0, StringData.c_str(), Value);
+ }
+ break;
+ case 0x08 : //SCRIPTDATAVARIABLE[ECMAArrayLength]
+ {
+ int32u ECMAArrayLength;
+ Get_B4 (ECMAArrayLength, "ECMAArrayLength");
+ Element_Info1(Ztring::ToZtring(ECMAArrayLength)+_T(" elements"));
+ for (int32u Pos=0; Pos<ECMAArrayLength; Pos++)
+ {
+ meta_SCRIPTDATAVARIABLE();
+ if (meta_LevelFinished[meta_Level])
+ Pos=ECMAArrayLength; //Finished
+ }
+ }
+ break;
+ case 0x09 :
+ Element_Info1("EndOfObject");
+ meta_LevelFinished[meta_Level]=true;
+ break;
+ case 0x0A : //SCRIPTDATAVARIABLE[n]
+ case 0x0E : //RecordSet - SCRIPTDATAVARIABLE[n]
+ {
+ int32u Count;
+ Get_B4 (Count, "Count");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ meta_SCRIPTDATAVALUE(StringData);
+ }
+ break;
+ case 0x0B : //SCRIPTDATADATE
+ {
+ float64 Value;
+ Get_BF8(Value, "Value");
+ Ztring ValueS;
+ ValueS.Date_From_Seconds_1970((int32u)(Value/1000));
+ Param_Info1(ValueS);
+ Skip_B2( "Local_Offset_Minutes");
+ std::string ToFill;
+ if (StringData=="metadatadate") {ToFill="Tagged_Date";}
+ else {ToFill=StringData;}
+ Element_Info1(ValueS);
+ Fill(Stream_General, 0, ToFill.c_str(), ValueS);
+ }
+ break;
+ case 0x0C : //SCRIPTDATALONGSTRING
+ case 0x0F : //XML - SCRIPTDATALONGSTRING
+ {
+ int32u Value_Size;
+ Get_B4 (Value_Size, "Value_Size");
+ if (Value_Size)
+ {
+ Ztring Value;
+ Get_UTF16B(Value_Size, Value, "Value");
+ std::string ToFill;
+ if (StringData=="creator") {ToFill="Encoded_Application";}
+ else if (StringData=="liveXML") {}
+ else if (StringData=="metadatacreator") {ToFill="Tagged_Application";}
+ else if (StringData=="creationdate") {ToFill="Encoded_Date"; Value.Date_From_String(Value.To_UTF8().c_str());}
+ else {ToFill=StringData;}
+ Element_Info1(Value);
+ if (!ToFill.empty())
+ Fill(Stream_General, 0, ToFill.c_str(), Value);
+ }
+ }
+ break;
+ case 0x11 : //AMF3 data
+ {
+ int32u TypeCode;
+ Get_B4 (TypeCode, "AMF3 type code"); Param_Info1C((TypeCode<0x0D), Flv_Amf3Type[TypeCode]);
+ switch (TypeCode)
+ {
+ case 0x00 : //undefined
+ case 0x01 : //null
+ case 0x02 : //boolean-false
+ case 0x03 : //boolean-true
+ break;
+ default : //Not implemented or unknown
+ Element_Offset=Element_Size;
+ }
+ }
+ break;
+ default : //Unknown
+ Element_Offset=Element_Size; //Forcing the end of parsing
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Flv::Rm()
+{
+ Element_Name("Real Media tags");
+
+ //Creating the parser
+ File_Rm MI;
+ Open_Buffer_Init(&MI);
+
+ //Parsing
+ Open_Buffer_Continue(&MI);
+
+ //Filling
+ Finish(&MI);
+ Merge(MI, Stream_General, 0, 0);
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_FLV_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Flv.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Flv.h
new file mode 100644
index 000000000..03603615c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Flv.h
@@ -0,0 +1,124 @@
+// File_Flv - Info for Flash files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Flash files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_FlvH
+#define MediaInfo_File_FlvH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Flv
+//***************************************************************************
+
+class File_Flv : public File__Analyze
+{
+public :
+ File_Flv();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+ void Streams_Finish_PerStream(stream_t StreamID);
+
+ //Buffer - File header
+ void FileHeader_Parse();
+
+ //Buffer - Synchro
+ bool Synchronize();
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void header();
+ void video();
+ void video_H263();
+ void video_ScreenVideo(int8u Version);
+ void video_VP6(bool WithAlpha);
+ void video_AVC();
+ void audio();
+ void audio_MPEG();
+ void audio_AAC();
+ void meta();
+ void meta_SCRIPTDATAOBJECT();
+ void meta_SCRIPTDATAVARIABLE();
+ void meta_SCRIPTDATAVALUE(const std::string &StringData);
+ void Rm();
+
+ //Streams
+ struct stream
+ {
+ File__Analyze* Parser;
+ size_t PacketCount;
+ int32u Delay;
+ int32u TimeStamp;
+ std::vector<int32u> Durations;
+
+ stream()
+ {
+ Parser=NULL;
+ PacketCount=0;
+ Delay=(int32u)-1;
+ TimeStamp=(int32u)-1;
+ }
+
+ ~stream()
+ {
+ delete Parser; //Parser=NULL;
+ }
+ };
+ std::vector<stream> Stream; //Null, Video, Audio
+
+ //Count
+ bool video_stream_Count;
+ bool audio_stream_Count;
+
+ //Temp
+ bool video_stream_FrameRate_Detected;
+ std::vector<int32u> video_stream_FrameRate;
+ int32u Time;
+ int8u meta_Level;
+ std::map<int8u, bool> meta_LevelFinished;
+ bool Searching_Duration;
+ bool MetaData_NotTrustable;
+ int32u PreviousTagSize;
+ int64u meta_filesize;
+ float64 meta_duration;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf.cpp
new file mode 100644
index 000000000..0b9d803f0
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf.cpp
@@ -0,0 +1,1469 @@
+// File_Gxf - Info for GXF (SMPTE 360M) files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_GXF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Gxf.h"
+#include "MediaInfo/Multiple/File_Gxf_TimeCode.h"
+#if defined(MEDIAINFO_DVDIF_YES)
+ #include "MediaInfo/Multiple/File_DvDif.h"
+#endif
+#if defined(MEDIAINFO_RIFF_YES)
+ #include "MediaInfo/Multiple/File_Riff.h"
+#endif
+#if defined(MEDIAINFO_GXF_YES)
+ #include "MediaInfo/Multiple/File_Umf.h"
+#endif
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_AES3_YES)
+ #include "MediaInfo/Audio/File_ChannelGrouping.h"
+#endif
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "ZenLib/Utils.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Gxf_Tag_Name(int8u Tag)
+{
+ switch (Tag)
+ {
+ case 0x40 : return "Media file name of material";
+ case 0x41 : return "First field of material in stream";
+ case 0x42 : return "Last field of material in stream";
+ case 0x43 : return "Mark in for the stream";
+ case 0x44 : return "Mark out for the stream";
+ case 0x45 : return "Estimated size of stream in 1024 byte units";
+ case 0x46 :
+ case 0x47 :
+ case 0x48 :
+ case 0x49 :
+ case 0x4A :
+ case 0x4B : return "Reserved";
+ case 0x4C : return "Media file name";
+ case 0x4D : return "Auxiliary Information";
+ case 0x4E : return "Media file system version";
+ case 0x4F : return "MPEG auxiliary information";
+ case 0x50 : return "Frame rate";
+ case 0x51 : return "Lines per frame";
+ case 0x52 : return "Fields per frame";
+ default : return "Unknown";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Gxf_MediaTypes(int8u Type)
+{
+ switch (Type)
+ {
+ case 3 : return "JPEG"; //525 lines
+ case 4 : return "JPEG"; //625 lines
+ case 7 : return "SMPTE 12M"; //525 lines
+ case 8 : return "SMPTE 12M"; //625 lines
+ case 9 : return "PCM"; //24-bit
+ case 10 : return "PCM"; //16-bit
+ case 11 : return "MPEG-2 Video"; //525 lines
+ case 12 : return "MPEG-2 Video"; //625 lines
+ case 13 : return "DV"; //25 Mbps, 525 lines
+ case 14 : return "DV"; //25 Mbps, 625 lines
+ case 15 : return "DV"; //50 Mbps, 525 lines
+ case 16 : return "DV"; //50 Mbps, 625 lines
+ case 17 : return "AC-3"; //16-bit
+ case 18 : return "AES"; //non-PCM
+ case 19 : return "Reserved";
+ case 20 : return "MPEG-2 Video"; //HD, Main Profile at High Level
+ case 21 : return "Ancillary data"; //SMPTE 291M 10-bit type 2 component ancillary data
+ case 22 : return "MPEG-1 Video"; //525 lines
+ case 23 : return "MPEG-1 Video"; //625 lines
+ case 24 : return "SMPTE 12M"; //HD
+ default : return "Unknown";
+ }
+}
+
+//---------------------------------------------------------------------------
+stream_t Gxf_MediaTypes_StreamKind(int8u Type)
+{
+ switch (Type)
+ {
+ case 3 : return Stream_Video;
+ case 4 : return Stream_Video;
+ case 7 : return Stream_Max;
+ case 8 : return Stream_Max;
+ case 9 : return Stream_Audio;
+ case 10 : return Stream_Audio;
+ case 11 : return Stream_Video;
+ case 12 : return Stream_Video;
+ case 13 : return Stream_Video;
+ case 14 : return Stream_Video;
+ case 15 : return Stream_Video;
+ case 16 : return Stream_Video;
+ case 17 : return Stream_Audio;
+ case 18 : return Stream_Audio;
+ case 19 : return Stream_Max;
+ case 20 : return Stream_Video;
+ case 21 : return Stream_Max;
+ case 22 : return Stream_Video;
+ case 23 : return Stream_Video;
+ case 24 : return Stream_Max;
+ default : return Stream_Max;
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Gxf_MediaTypes_Format(int8u Type)
+{
+ switch (Type)
+ {
+ case 3 : return "JPEG"; //525 lines
+ case 4 : return "JPEG"; //625 lines
+ case 9 : return "PCM"; //24-bit
+ case 10 : return "PCM"; //16-bit
+ case 11 : return "MPEG Video"; //525 lines
+ case 12 : return "MPEG Video"; //625 lines
+ case 13 : return "DV"; //25 Mbps, 525 lines
+ case 14 : return "DV"; //25 Mbps, 625 lines
+ case 15 : return "DV"; //50 Mbps, 525 lines
+ case 16 : return "DV"; //50 Mbps, 625 lines
+ case 17 : return "AC-3"; //16-bit
+ case 18 : return "SMPTE 338M, table 1, data type 28"; //SMPTE 338M, table 1, data type 28
+ case 20 : return "MPEG Video"; //HD, Main Profile at High Level
+ case 22 : return "MPEG Video"; //525 lines
+ case 23 : return "MPEG Video"; //625 lines
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+double Gxf_FrameRate(int32u Content)
+{
+ switch (Content)
+ {
+ case 1 : return 60.000;
+ case 2 : return 59.940;
+ case 3 : return 50.000;
+ case 4 : return 30.000;
+ case 5 : return 29.970;
+ case 6 : return 25.000;
+ case 7 : return 24.000;
+ case 8 : return 23.976;
+ default: return 0.000;
+ }
+}
+
+//---------------------------------------------------------------------------
+int32u Gxf_LinesPerFrame_Height(int32u Content)
+{
+ switch (Content)
+ {
+ case 1 : return 480;
+ case 2 : return 576;
+ case 4 : return 1080;
+ case 6 : return 720;
+ default: return 0;
+ }
+}
+
+//---------------------------------------------------------------------------
+int32u Gxf_LinesPerFrame_Width(int32u Content)
+{
+ switch (Content)
+ {
+ case 1 : return 720;
+ case 2 : return 720;
+ case 4 : return 1920;
+ case 6 : return 1080;
+ default: return 0;
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Gxf_FieldsPerFrame(int32u Tag)
+{
+ switch (Tag)
+ {
+ case 1 : return "Progressive";
+ case 2 : return "Interlaced";
+ default: return "";
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Gxf::File_Gxf()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("GXF");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Gxf;
+ StreamIDs_Width[0]=2;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ #endif //MEDIAINFO_DEMUX
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+ Buffer_TotalBytes_Fill_Max=(int64u)-1; //Disabling this feature for this format, this is done in the parser
+ #if MEDIAINFO_DEMUX
+ Demux_EventWasSent_Accept_Specific=true;
+ #endif //MEDIAINFO_DEMUX
+
+ //Temp
+ Material_Fields_FieldsPerFrame=1; //Progressive by default
+ Parsers_Count=0;
+ AncillaryData_StreamID=(int8u)-1;
+ Material_Fields_First_IsValid=false;
+ Material_Fields_Last_IsValid=false;
+ Material_File_Size_IsValid=false;
+ UMF_File=NULL;
+ #if defined(MEDIAINFO_ANCILLARY_YES)
+ Ancillary=NULL;
+ #endif //defined(MEDIAINFO_ANCILLARY_YES)
+ SizeToAnalyze=16*1024*1024;
+ Audio_Count=0;
+ Element_Code=0x00; //Element_Code is used as a test for pre-existing parsing, it must be initialized
+
+ #if MEDIAINFO_DEMUX
+ Demux_HeaderParsed=false;
+ #endif //MEDIAINFO_DEMUX
+ #if MEDIAINFO_SEEK
+ Flt_FieldPerEntry=(int32u)-1;
+ IFrame_IsParsed=false;
+ #endif //MEDIAINFO_SEEK
+}
+
+//---------------------------------------------------------------------------
+File_Gxf::~File_Gxf()
+{
+ //Temp
+ delete Ancillary; //Ancillary=NULL;
+ delete UMF_File; //UMF_File=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Gxf::Streams_Finish()
+{
+ //Merging audio if Title are same
+ for (size_t StreamID=0; StreamID<Streams.size(); StreamID++)
+ {
+ if (Gxf_MediaTypes_StreamKind(Streams[StreamID].MediaType)==Stream_Video)
+ {
+ Ztring Title=Streams[StreamID].MediaName;
+ size_t Title_Extension_Offset=Title.find(_T(".M0"));
+ if (Title_Extension_Offset==std::string::npos || Title_Extension_Offset!=Title.size()-3)
+ Title_Extension_Offset=Title.find(_T(".H0"));
+ if (Title_Extension_Offset!=std::string::npos && Title_Extension_Offset==Title.size()-3)
+ {
+ Title.resize(Title.size()-3);
+ Streams[StreamID].MediaName=Title;
+ }
+ }
+ if (Gxf_MediaTypes_StreamKind(Streams[StreamID].MediaType)==Stream_Audio && Config->File_Audio_MergeMonoStreams_Get())
+ {
+ Ztring Title=Streams[StreamID].MediaName;
+ size_t Title_Extension_Offset=Title.find(_T(".A0"));
+ if (Title_Extension_Offset!=std::string::npos && Title_Extension_Offset==Title.size()-3)
+ {
+ Title.resize(Title.size()-3);
+ for (size_t StreamID2=StreamID+1; StreamID2<Streams.size(); StreamID2++)
+ {
+ if (Streams[StreamID2].MediaName==Title+_T(".A")+Ztring::ToZtring(StreamID2-StreamID))
+ {
+ Streams[StreamID].MediaName=Title;
+ if (Streams[StreamID].Parser && Streams[StreamID2].Parser)
+ {
+ int32u Channels=Streams[StreamID].Parser->Retrieve(Stream_Audio, 0, Audio_Channel_s_).To_int32u()+Streams[StreamID2].Parser->Retrieve(Stream_Audio, 0, Audio_Channel_s_).To_int32u();
+ Streams[StreamID].Parser->Fill(Stream_Audio, 0, Audio_Channel_s_, Channels, 10, true);
+ int32u BitRate=Streams[StreamID].Parser->Retrieve(Stream_Audio, 0, Audio_BitRate).To_int32u()+Streams[StreamID2].Parser->Retrieve(Stream_Audio, 0, Audio_BitRate).To_int32u();
+ Streams[StreamID].Parser->Fill(Stream_Audio, 0, Audio_BitRate, BitRate, 10, true);
+ }
+ Streams[StreamID2].MediaType=(int8u)-1;
+ }
+ }
+ }
+ }
+ }
+
+ //For each Streams
+ for (size_t StreamID=0; StreamID<Streams.size(); StreamID++)
+ Streams_Finish_PerStream(StreamID, Streams[StreamID]);
+
+ //Global
+ if (Material_Fields_First_IsValid && Material_Fields_Last_IsValid && Material_Fields_Last-Material_Fields_First)
+ {
+ int64u FrameCount=(Material_Fields_Last+1-Material_Fields_First)/Material_Fields_FieldsPerFrame;
+ Fill(Stream_Video, 0, Video_FrameCount, FrameCount);
+ if (Gxf_FrameRate(Streams[0x00].FrameRate_Code))
+ Fill(Stream_Video, 0, Video_Duration, ((float64)FrameCount)/Gxf_FrameRate(Streams[0x00].FrameRate_Code)*1000, 0); //In milliseconds
+
+ //We trust more the MPEG Video bitrate thant the rest
+ //TODO: Chech why there is incohenrency (mainly about Material File size info in the sample)
+ if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video"))
+ Fill(Stream_Video, 0, Video_BitRate, Retrieve(Stream_Video, 0, Video_BitRate_Nominal));
+ }
+ if (Material_File_Size_IsValid)
+ {
+ //Fill(Stream_General, 0, General_OverallBitRate, ((int64u)Material_File_Size)*1024*8/???);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Gxf::Streams_Finish_PerStream(size_t StreamID, stream &Temp)
+{
+ if (Temp.MediaType==(int8u)-1)
+ return;
+
+ //By the parser
+ if (Temp.Parser && Temp.Parser->Status[IsAccepted])
+ {
+ StreamKind_Last=Stream_Max;
+ StreamPos_Last=(size_t)-1;
+ if (Config_ParseSpeed<=1.0)
+ {
+ Fill(Temp.Parser);
+ Temp.Parser->Open_Buffer_Unsynch();
+ }
+ Finish(Temp.Parser);
+
+ //Video
+ bool IsTimeCode=false;
+ for (std::map<int8u, int64u>::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); TimeCode++)
+ if (StreamID==TimeCode->first)
+ IsTimeCode=true;
+ if (!IsTimeCode && Temp.DisplayInfo)
+ {
+ if (Temp.Parser->Count_Get(Stream_Video))
+ {
+ Stream_Prepare(Stream_Video);
+
+ if (TimeCodes.empty())
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Delay, ((float64)(Material_Fields_First/Material_Fields_FieldsPerFrame))/Gxf_FrameRate(Streams[0x00].FrameRate_Code)*1000, 0);
+ Fill(Stream_Video, StreamPos_Last, Video_Delay_Source, "Container");
+ }
+ else
+ for (std::map<int8u, int64u>::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); TimeCode++)
+ {
+ int64u TimeCode_First=((File_Gxf_TimeCode*)Streams[TimeCode->first].Parser)->TimeCode_First;
+ if (TimeCode_First==(int64u)-1)
+ TimeCode_First=TimeCode->second;
+ if (TimeCode_First!=(int64u)-1)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Delay, TimeCode_First, 0);
+ Fill(Stream_Video, StreamPos_Last, Video_Delay_Source, "Container");
+ }
+ }
+
+ Merge(*Temp.Parser, Stream_Video, 0, StreamPos_Last);
+
+ Fill(Stream_Video, StreamPos_Last, Video_ID, StreamID, 10, true);
+ Fill(Stream_Video, StreamPos_Last, "Title", Temp.MediaName);
+
+ //Special cases
+ if (Temp.Parser->Count_Get(Stream_Text))
+ {
+ //Video and Text are together
+ size_t Parser_Text_Count=Temp.Parser->Count_Get(Stream_Text);
+ for (size_t Parser_Text_Pos=0; Parser_Text_Pos<Parser_Text_Count; Parser_Text_Pos++)
+ {
+ Stream_Prepare(Stream_Text);
+ Merge(*Temp.Parser, Stream_Text, Parser_Text_Pos, StreamPos_Last);
+ Ztring ID=Retrieve(Stream_Text, StreamPos_Last, Text_ID);
+ Fill(Stream_Text, StreamPos_Last, Text_ID, Ztring::ToZtring(AncillaryData_StreamID)+_T("-")+ID, true);
+ Fill(Stream_Text, StreamPos_Last, Text_ID_String, Ztring::ToZtring(AncillaryData_StreamID)+_T("-")+ID, true);
+ Fill(Stream_Text, StreamPos_Last, Text_Delay, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_Delay), true);
+ Fill(Stream_Text, StreamPos_Last, Text_Delay_Source, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_Delay_Source), true);
+ Fill(Stream_Text, StreamPos_Last, Text_Delay_Original, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_Delay_Original), true);
+ Fill(Stream_Text, StreamPos_Last, Text_Delay_Original_Source, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_Delay_Original_Source), true);
+ }
+
+ StreamKind_Last=Stream_Video;
+ StreamPos_Last=Count_Get(Stream_Video)-1;
+ }
+ }
+
+ //Audio
+ for (size_t Pos=0; Pos<Temp.Parser->Count_Get(Stream_Audio); Pos++)
+ {
+ Stream_Prepare(Stream_Audio);
+
+ if (TimeCodes.empty())
+ {
+ Fill(Stream_Audio, StreamPos_Last, Audio_Delay, ((float64)(Material_Fields_First/Material_Fields_FieldsPerFrame))/Gxf_FrameRate(Streams[0x00].FrameRate_Code)*1000, 0);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Delay_Source, "Container");
+ }
+ else
+ for (std::map<int8u, int64u>::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); TimeCode++)
+ {
+ int64u TimeCode_First=((File_Gxf_TimeCode*)Streams[TimeCode->first].Parser)->TimeCode_First;
+ if (TimeCode_First==(int64u)-1)
+ TimeCode_First=TimeCode->second;
+ Fill(Stream_Audio, StreamPos_Last, Audio_Delay, TimeCode_First, 0);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Delay_Source, "Container");
+ }
+
+ Merge(*Temp.Parser, Stream_Audio, Pos, StreamPos_Last, false);
+
+ Ztring ID=Ztring::ToZtring(StreamID);
+ if (Temp.IsChannelGrouping)
+ ID+=_T(" / ")+Ztring::ToZtring(StreamID+1); //Second half of the channel grouping
+ Ztring ID_String=ID;
+ if (!Retrieve(Stream_Audio, StreamPos_Last, Audio_ID).empty())
+ {
+ ID+=_T('-')+Retrieve(Stream_Audio, StreamPos_Last, Audio_ID);
+ ID_String+=_T('-')+Retrieve(Stream_Audio, StreamPos_Last, Audio_ID_String);
+ }
+ Fill(Stream_Audio, StreamPos_Last, Audio_ID, ID, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_ID_String, ID_String, true);
+ Fill(Stream_Audio, StreamPos_Last, "Title", Temp.MediaName);
+ if (Temp.IsChannelGrouping)
+ Fill(StreamKind_Last, StreamPos_Last, "Title", Streams[StreamID+1].MediaName); //Second half of the channel grouping
+
+ for (std::map<std::string, Ztring>::iterator Info=Temp.Infos.begin(); Info!=Temp.Infos.end(); Info++)
+ if (Retrieve(Stream_Audio, StreamPos_Last, Info->first.c_str()).empty())
+ Fill(Stream_Audio, StreamPos_Last, Info->first.c_str(), Info->second);
+ }
+
+ //Text
+ if (Temp.Parser->Count_Get(Stream_Text))
+ {
+ size_t Parser_Text_Count=Temp.Parser->Count_Get(Stream_Text);
+ for (size_t Parser_Text_Pos=0; Parser_Text_Pos<Parser_Text_Count; Parser_Text_Pos++)
+ {
+ Stream_Prepare(Stream_Text);
+ Merge(*Temp.Parser, Stream_Text, Parser_Text_Pos, StreamPos_Last);
+ Ztring ID=Retrieve(Stream_Text, StreamPos_Last, Text_ID);
+ Fill(Stream_Text, StreamPos_Last, Text_ID, Ztring::ToZtring(AncillaryData_StreamID)+_T("-")+ID, true);
+ Fill(Stream_Text, StreamPos_Last, Text_ID_String, Ztring::ToZtring(AncillaryData_StreamID)+_T("-")+ID, true);
+ Fill(Stream_Text, StreamPos_Last, Text_Delay, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_Delay), true);
+ Fill(Stream_Text, StreamPos_Last, Text_Delay_Source, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_Delay_Source), true);
+ Fill(Stream_Text, StreamPos_Last, Text_Delay_Original, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_Delay_Original), true);
+ Fill(Stream_Text, StreamPos_Last, Text_Delay_Original_Source, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_Delay_Original_Source), true);
+ Fill(Stream_Text, StreamPos_Last, "Title", Temp.MediaName);
+ }
+
+ StreamKind_Last=Stream_Max;
+ StreamPos_Last=(size_t)-1;
+ }
+ }
+ }
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Gxf::Synchronize()
+{
+ //Synchronizing
+ while (Buffer_Offset+16<=Buffer_Size)
+ {
+ while (Buffer_Offset+16<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x00
+ || Buffer[Buffer_Offset+3]!=0x00
+ || Buffer[Buffer_Offset+4]!=0x01
+ || Buffer[Buffer_Offset+14]!=0xE1
+ || Buffer[Buffer_Offset+15]!=0xE2))
+ {
+ Buffer_Offset+=4;
+ while (Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Buffer_Offset+=4;
+ for (int8u Pos=0; Pos<3; Pos++)
+ if (Buffer_Offset>=Buffer_Size || Buffer[Buffer_Offset-1]==0x00)
+ Buffer_Offset--;
+ }
+
+ if (Buffer_Offset+16<=Buffer_Size) //Testing if size is coherant
+ {
+ //Retrieving some info
+ int32u Size=BigEndian2int32u(Buffer+Buffer_Offset+6);
+
+ //Testing
+ if (Buffer_Offset+Size+16>Buffer_Size)
+ return false; //Need more data
+ if (Buffer[Buffer_Offset+Size ]!=0x00
+ || Buffer[Buffer_Offset+Size+1]!=0x00
+ || Buffer[Buffer_Offset+Size+2]!=0x00
+ || Buffer[Buffer_Offset+Size+3]!=0x00
+ || Buffer[Buffer_Offset+Size+4]!=0x01
+ || Buffer[Buffer_Offset+Size+14]!=0xE1
+ || Buffer[Buffer_Offset+Size+15]!=0xE2)
+ Buffer_Offset++;
+ else
+ break;
+ }
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+16>Buffer_Size)
+ {
+ return false;
+ }
+
+ if (!Status[IsAccepted])
+ {
+ Accept("GXF");
+ Fill(Stream_General, 0, General_Format, "GXF");
+ Streams.resize(0x40);
+ }
+
+ //Synched is OK
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Gxf::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+16>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (CC5(Buffer+Buffer_Offset )!=0x0000000001
+ || CC2(Buffer+Buffer_Offset+14)!=0xE1E2)
+ Synched=false;
+
+ //Test if the next synchro is available
+ int32u PacketLength=BigEndian2int32u(Buffer+Buffer_Offset+6);
+ if (File_Offset+Buffer_Offset+PacketLength+16<=File_Size)
+ {
+ if (Buffer_Offset+PacketLength+16>Buffer_Size)
+ return false;
+ if (CC5(Buffer+Buffer_Offset+PacketLength )!=0x0000000001
+ || CC2(Buffer+Buffer_Offset+PacketLength+14)!=0xE1E2)
+ Synched=false;
+ }
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Gxf::Read_Buffer_Unsynched()
+{
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ if (Streams[Pos].Parser)
+ Streams[Pos].Parser->Open_Buffer_Unsynch();
+
+ #if MEDIAINFO_SEEK
+ IFrame_IsParsed=false;
+ #endif //MEDIAINFO_SEEK
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_Gxf::Read_Buffer_Seek (size_t Method, int64u Value, int64u)
+{
+ //Parsing
+ switch (Method)
+ {
+ case 0 : Open_Buffer_Unsynch(); GoTo(Value); return 1;
+ case 1 : Open_Buffer_Unsynch(); GoTo(File_Size*Value/10000); return 1;
+ case 2 : //Timestamp
+ {
+ //We transform TimeStamp to a frame number
+ if (Streams.empty() || Gxf_FrameRate(Streams[0x00].FrameRate_Code)==0)
+ return (size_t)-1; //Not supported
+
+ int64u Delay=0;
+ if (TimeCodes.empty())
+ {
+ if (Material_Fields_First_IsValid)
+ Delay=float64_int64s(((float64)(Material_Fields_First/Material_Fields_FieldsPerFrame))/Gxf_FrameRate(Streams[0x00].FrameRate_Code)*1000000000);
+ else
+ Delay=0;
+ }
+ else
+ {
+ for (std::map<int8u, int64u>::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); TimeCode++)
+ {
+ int64u TimeCode_First=((File_Gxf_TimeCode*)Streams[TimeCode->first].Parser)->TimeCode_First;
+ if (TimeCode_First==(int64u)-1)
+ TimeCode_First=TimeCode->second;
+ if (TimeCode_First==(int64u)-1)
+ Delay=0;
+ else
+ {
+ Delay=TimeCode_First*1000000;
+ break;
+ }
+ }
+ }
+
+ if (Value<Delay)
+ Value=0;
+ else
+ Value=float64_int64s(((float64)(Value-Delay))/1000000000*Gxf_FrameRate(Streams[0x00].FrameRate_Code));
+ }
+ //No break;
+ case 3 : //FrameNumber
+ {
+ if (Seeks.empty())
+ return (size_t)-1; //Not supported
+
+ //Search previous I-Frame
+ if (UMF_File && ((File_Umf*)UMF_File)->GopSize!=(int64u)-1)
+ {
+ Value/=((File_Umf*)UMF_File)->GopSize;
+ Value*=((File_Umf*)UMF_File)->GopSize;
+ }
+ Value*=Material_Fields_FieldsPerFrame;
+
+ for (size_t Pos=0; Pos<Seeks.size(); Pos++)
+ {
+ if (Material_Fields_First+Value<=Seeks[Pos].FrameNumber)
+ {
+ if (Material_Fields_First+Value<Seeks[Pos].FrameNumber && Pos)
+ Pos--;
+ Open_Buffer_Unsynch();
+ GoTo(((int64u)Seeks[Pos].StreamOffset)*1024);
+
+ return 1;
+ }
+ }
+
+ return 2; //Invalid value
+ }
+ default : return (size_t)-1; //Not supported
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Gxf::Header_Begin()
+{
+ #if MEDIAINFO_DEMUX
+ //Handling of multiple frames in one block
+ if (Element_Code==0xBF && Config->Demux_Unpacketize_Get()) //media block
+ {
+ Open_Buffer_Continue(Streams[TrackNumber].Parser, Buffer+Buffer_Offset, 0);
+ if (Config->Demux_EventWasSent)
+ return false;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Gxf::Header_Parse()
+{
+ //Parsing
+ int32u PacketLength;
+ int8u PacketType;
+ Skip_B5( "Packet leader");
+ Get_B1 (PacketType, "Packet type");
+ Get_B4 (PacketLength, "Packet length");
+ Skip_B4( "Reserved");
+ Skip_B2( "Packet trailer");
+
+ //Filling
+ Header_Fill_Size(PacketLength);
+ Header_Fill_Code(PacketType);
+
+ #if MEDIAINFO_DEMUX
+ if (!Demux_HeaderParsed)
+ {
+ if (PacketType==0xBF) //media
+ {
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ Config->Demux_EventWasSent=true; //First set is to indicate the user that header is parsed
+ Demux_HeaderParsed=true;
+ }
+ }
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_Gxf::Data_Parse()
+{
+ //Counting
+ Frame_Count++;
+
+ switch (Element_Code)
+ {
+ case 0x00 : Finish("GXF"); break;
+ case 0xBC : map(); break;
+ case 0xBF : media(); break;
+ case 0xFB : end_of_stream(); break;
+ case 0xFC : field_locator_table(); break;
+ case 0xFD : UMF_file(); break;
+ default: ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Gxf::map()
+{
+ Element_Name("map");
+
+ //Parsing
+ int8u Version;
+ Element_Begin1("Preamble");
+ BS_Begin();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Get_S1(5, Version, "Version");
+ BS_End();
+ Skip_B1( "Reserved");
+ Element_End0();
+
+ Element_Begin1("Material Data");
+ int16u SectionLength;
+ Get_B2 (SectionLength, "Section Length");
+ if (Element_Offset+SectionLength>=Element_Size)
+ SectionLength=(int16u)(Element_Size-Element_Offset);
+ int64u Material_Data_End=Element_Offset+SectionLength;
+ while (Element_Offset<Material_Data_End)
+ {
+ Element_Begin1("Tag");
+ int8u Tag, DataLength;
+ Get_B1(Tag, "Tag");
+ Get_B1(DataLength, "Data Length");
+ Element_Name(Gxf_Tag_Name(Tag));
+ switch (Tag)
+ {
+ case 0x40 : //Media file name of material
+ {
+ Ztring MediaFileName;
+ Get_Local(DataLength, MediaFileName, "Content");
+ Fill(Stream_General, 0, General_Title, MediaFileName, true);
+ }
+ break;
+ case 0x41 : //First field of material in stream
+ if (DataLength==4)
+ {
+ if (Material_Fields_First_IsValid)
+ Skip_B4( "Content");
+ else
+ {
+ Get_B4 (Material_Fields_First, "Content");
+ Material_Fields_First_IsValid=true;
+ }
+ }
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ case 0x42 : //Last field of material in stream
+ if (DataLength==4)
+ {
+ if (Material_Fields_Last_IsValid)
+ Skip_B4( "Content");
+ else
+ {
+ Get_B4 (Material_Fields_Last, "Content");
+ Material_Fields_Last_IsValid=true;
+ }
+ }
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ case 0x43 : //Mark in for the stream
+ if (DataLength==4)
+ Skip_B4( "Content");
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ case 0x44 : //Mark out for the stream
+ if (DataLength==4)
+ Skip_B4( "Content");
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ case 0x45 : //Estimated size of stream in 1024 byte units
+ if (DataLength==4)
+ {
+ Get_B4 (Material_File_Size , "Content");
+ Material_File_Size_IsValid=true;
+ }
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ case 0x46 : //Reserved
+ if (DataLength==4)
+ Skip_B4( "Content");
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ case 0x47 : //Reserved
+ if (DataLength==8)
+ Skip_B8( "Content");
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ case 0x48 : //Reserved
+ Skip_String(DataLength, "Content");
+ break;
+ case 0x49 : //Reserved
+ Skip_String(DataLength, "Content");
+ break;
+ case 0x4A : //Reserved
+ Skip_String(DataLength, "Content");
+ break;
+ case 0x4B : //Reserved
+ Skip_String(DataLength, "Content");
+ break;
+ default : Skip_XX(DataLength, "Unknown");
+ }
+ Element_End0();
+ }
+ Element_End0();
+
+ Element_Begin1("Track Description");
+ int32u Stream_Video_FrameRate_Code=(int32u)-1, Stream_Video_FieldsPerFrame_Code=(int32u)-1;
+ Get_B2 (SectionLength, "Section Length");
+ if (Element_Offset+SectionLength>=Element_Size)
+ SectionLength=(int16u)(Element_Size-Element_Offset);
+ int64u Track_Data_End=Element_Offset+SectionLength;
+ while (Element_Offset<Track_Data_End)
+ {
+ Element_Begin1("Track");
+ int16u TrackLength;
+ int8u MediaType, TrackID;
+ Get_B1 (MediaType, "Media type"); Param_Info1(Gxf_MediaTypes(MediaType&0x7F));
+ Get_B1 (TrackID, "Track ID");
+ Get_B2 (TrackLength, "Track Length");
+ if (Element_Offset+TrackLength>=Track_Data_End)
+ TrackLength=(int16u)(Track_Data_End-Element_Offset);
+ int64u Track_End=Element_Offset+TrackLength;
+ Element_Info1(TrackID&0x3F);
+ Element_Info1(Gxf_MediaTypes(MediaType&0x7F));
+
+ FILLING_BEGIN();
+ MediaType&=0x7F; //Remove the last bit
+ TrackID&=0x3F; //Remove the 2 last bits
+ Streams[TrackID].MediaType=MediaType;
+ Streams[TrackID].TrackID=TrackID;
+ if (Streams[TrackID].Parser==NULL)
+ {
+ Streams[TrackID].MediaType=MediaType;
+ Streams[TrackID].TrackID=TrackID;
+
+ //Parsers
+ #if MEDIAINFO_DEMUX
+ Element_Code=TrackID;
+ #endif //MEDIAINFO_DEMUX
+ switch (MediaType)
+ {
+ case 3 :
+ case 4 : //JPEG
+ Streams[TrackID].Parser=new File__Analyze; //Filling with following data
+ Open_Buffer_Init(Streams[TrackID].Parser);
+ Streams[TrackID].Parser->Accept();
+ Streams[TrackID].Parser->Fill();
+ Streams[TrackID].Parser->Stream_Prepare(Stream_Video);
+ Streams[TrackID].Parser->Fill(Stream_Video, 0, Video_Format, "JPEG");
+ break;
+ case 7 :
+ case 8 :
+ case 24 : //TimeCode
+ Streams[TrackID].Parser=new File_Gxf_TimeCode;
+ Open_Buffer_Init(Streams[TrackID].Parser);
+ Parsers_Count++;
+ Streams[TrackID].Searching_Payload=true;
+ TimeCodes[TrackID]=(int64u)-1;
+ break;
+ case 9 :
+ case 10 :
+ Streams[TrackID].Parser=new File__Analyze; //Filling with following data
+ Open_Buffer_Init(Streams[TrackID].Parser);
+ Streams[TrackID].Parser->Accept();
+ Streams[TrackID].Parser->Fill();
+ Streams[TrackID].Parser->Stream_Prepare(Stream_Audio);
+ Streams[TrackID].Parser->Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ Streams[TrackID].Parser->Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, "Little");
+ Audio_Count++;
+ break;
+ case 11 :
+ case 12 :
+ case 20 :
+ case 22 :
+ case 23 : //MPEG Video
+ Streams[TrackID].Parser=new File_Mpegv();
+ ((File_Mpegv*)Streams[TrackID].Parser)->FrameIsAlwaysComplete=true;
+ ((File_Mpegv*)Streams[TrackID].Parser)->Ancillary=&Ancillary;
+ Open_Buffer_Init(Streams[TrackID].Parser);
+ Parsers_Count++;
+ Streams[TrackID].Searching_Payload=true;
+ break;
+ case 13 :
+ case 14 :
+ case 15 :
+ case 16 : //DV
+ Streams[TrackID].Parser=new File_DvDif();
+ Open_Buffer_Init(Streams[TrackID].Parser);
+ Parsers_Count++;
+ Streams[TrackID].Searching_Payload=true;
+ break;
+ break;
+ case 17 : //AC-3 in AES3 (half)
+ case 18 : //Dolby E in AES3 (half)
+ Streams[TrackID].Parser=ChooseParser_ChannelGrouping(TrackID);
+ if (Streams[TrackID].Parser)
+ {
+ Open_Buffer_Init(Streams[TrackID].Parser);
+ Parsers_Count++;
+ Streams[TrackID].Searching_Payload=true;
+ }
+ Audio_Count++;
+ break;
+ case 21 : //Ancillary Metadata
+ Streams[TrackID].Parser=new File_Riff();
+ ((File_Riff*)Streams[TrackID].Parser)->Ancillary=&Ancillary;
+ Open_Buffer_Init(Streams[TrackID].Parser);
+ Parsers_Count++;
+ Streams[TrackID].Searching_Payload=true;
+ Ancillary=new File_Ancillary;
+ Ancillary->WithTenBit=true;
+ Ancillary->WithChecksum=true;
+ Open_Buffer_Init(Ancillary);
+ AncillaryData_StreamID=TrackID;
+ if (SizeToAnalyze<8*16*1024*1024)
+ SizeToAnalyze*=8; //10x more, to be sure to find captions
+ break;
+ default : ;
+ }
+
+ if (Gxf_MediaTypes_StreamKind(MediaType)==Stream_Audio)
+ {
+ //Resolution
+ switch (MediaType)
+ {
+ case 9 :
+ case 18 : //24-bit
+ Streams[TrackID].Infos["BitDepth"].From_Number(24);
+ break;
+ case 10 :
+ case 17 : //16-bit
+ Streams[TrackID].Infos["BitDepth"].From_Number(16);
+ break;
+ default : ;
+ }
+
+ //Channels
+ switch (MediaType)
+ {
+ case 9 :
+ case 10 : //Mono
+ Streams[TrackID].Infos["Channel(s)"].From_Number(1);
+ break;
+ case 18 : //Stereo
+ Streams[TrackID].Infos["Channel(s)"].From_Number(2);
+ break;
+ default : ;
+ }
+
+ //Sampling rate
+ switch (MediaType)
+ {
+ case 9 :
+ case 10 :
+ case 17 :
+ case 18 : //48000
+ Streams[TrackID].Infos["SamplingRate"].From_Number(48000);
+ break;
+ default : ;
+ }
+
+ //Bit rate
+ switch (MediaType)
+ {
+ case 9 : //Mono, 48 KHz, 24-bit (or padded up to 24-bit)
+ Streams[TrackID].Infos["BitRate"].From_Number(1*48000*24);
+ break;
+ case 10 : //Mono, 48 KHz, 16-bit
+ Streams[TrackID].Infos["BitRate"].From_Number(1*48000*16);
+ break;
+ case 18 : //Stereo, 48 KHz, 24-bit (or padded up to 24-bit)
+ Streams[TrackID].Infos["BitRate"].From_Number(2*48000*24);
+ break;
+ default : ;
+ }
+ }
+ }
+ FILLING_END();
+
+ int8u Hours=(int8u)-1, Minutes=(int8u)-1, Seconds=(int8u)-1, Fields=(int8u)-1;
+ bool Invalid=true, DropFrame=true;
+ bool TimeCode_Parsed=false;
+
+ while (Element_Offset<Track_End)
+ {
+ Element_Begin1("Tag");
+ int8u Tag, DataLength;
+ Get_B1(Tag, "Tag");
+ Get_B1(DataLength, "Data Length");
+ Element_Name(Gxf_Tag_Name(Tag));
+ switch (Tag)
+ {
+ case 0x4C : //Media name
+ {
+ Get_Local(DataLength, Streams[TrackID].MediaName, "Content");
+ }
+ break;
+ case 0x4D : //Auxiliary Information
+ if (DataLength==8)
+ {
+ if (MediaType==21)
+ {
+ //Ancillary
+ Skip_B1( "Reserved");
+ Skip_B1( "Reserved");
+ Skip_B1( "Ancillary data presentation format");
+ Skip_B1( "Number of ancillary data fields per ancillary data media packet");
+ Skip_B2( "Byte size of each ancillary data field");
+ Skip_B2( "Byte size of the ancillary data media packet in 256 byte units");
+ }
+ else if (MediaType==7 || MediaType==8 || MediaType==24)
+ {
+ //TimeCode
+ Get_B1 (Fields, "Fields");
+ Get_B1 (Seconds, "Second");
+ Get_B1 (Minutes, "Minute");
+ BS_Begin();
+ Get_SB ( Invalid, "Invalid");
+ Skip_SB( "Color frame");
+ Get_SB ( DropFrame, "Drop frame");
+ Get_S1 (5, Hours, "Hour");
+ BS_End();
+ Skip_B1( "User bits");
+ Skip_B1( "User bits");
+ Skip_B1( "User bits");
+ Skip_B1( "User bits");
+ if (!Invalid)
+ TimeCode_Parsed=true;
+ }
+ else
+ Skip_B8( "Content");
+ }
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ case 0x4E : //Media file system version
+ if (DataLength==4)
+ Skip_B4( "Content");
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ case 0x4F : //MPEG auxiliary information
+ Skip_String(DataLength, "Content");
+ break;
+ case 0x50 : //Frame rate
+ if (DataLength==4)
+ {
+ Get_B4 (Streams[TrackID].FrameRate_Code, "Content"); Param_Info1(Gxf_FrameRate(Streams[TrackID].FrameRate_Code)); Element_Info1(Gxf_FrameRate(Streams[TrackID].FrameRate_Code));
+ for (std::map<int8u, int64u>::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); TimeCode++)
+ if (TrackID==TimeCode->first)
+ ((File_Gxf_TimeCode*)Streams[TrackID].Parser)->FrameRate_Code=Streams[0x00].FrameRate_Code;
+ if (Gxf_MediaTypes_StreamKind(MediaType)==Stream_Video)
+ Stream_Video_FrameRate_Code=Streams[TrackID].FrameRate_Code;
+ }
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ case 0x51 : //Lines per frame
+ if (DataLength==4)
+ {
+ Get_B4 (Streams[TrackID].LinesPerFrame_Code, "Content"); Param_Info1(Gxf_LinesPerFrame_Height(Streams[TrackID].LinesPerFrame_Code)); Element_Info1(Gxf_LinesPerFrame_Height(Streams[TrackID].LinesPerFrame_Code));
+ }
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ case 0x52 : //Fields per frame
+ if (DataLength==4)
+ {
+ Get_B4 (Streams[TrackID].FieldsPerFrame_Code, "Content"); Param_Info1(Gxf_FieldsPerFrame(Streams[TrackID].FieldsPerFrame_Code)); Element_Info1(Gxf_FieldsPerFrame(Streams[TrackID].FieldsPerFrame_Code));
+ if (Gxf_MediaTypes_StreamKind(MediaType)==Stream_Video)
+ {
+ Stream_Video_FieldsPerFrame_Code=Streams[TrackID].FieldsPerFrame_Code;
+ Material_Fields_FieldsPerFrame=Streams[TrackID].FieldsPerFrame_Code;
+ }
+ for (std::map<int8u, int64u>::iterator TimeCode=TimeCodes.begin(); TimeCode!=TimeCodes.end(); TimeCode++)
+ if (TrackID==TimeCode->first)
+ ((File_Gxf_TimeCode*)Streams[TrackID].Parser)->FieldsPerFrame_Code=Streams[0x00].FieldsPerFrame_Code;
+ }
+ else
+ Skip_XX(DataLength, "Unknown");
+ break;
+ default : Skip_XX(DataLength, "Unknown");
+ }
+ Element_End0();
+ }
+ Element_End0();
+
+ //Test on TimeCode
+ if (TimeCode_Parsed && !Invalid)
+ {
+ std::map<int8u, int64u>::iterator TimeCode=TimeCodes.find(TrackID);
+ if (TimeCode==TimeCodes.end() || TimeCode->second==(int64u)-1)
+ {
+ float64 FrameRate=Gxf_FrameRate(Streams[TrackID].FrameRate_Code);
+ TimeCodes[TrackID]=Hours *60*60*1000
+ +Minutes *60*1000
+ +Seconds *1000
+ +float64_int64s(Fields*1000/(FrameRate*2));
+ }
+ }
+ }
+ Element_End0();
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Padding");
+
+ //Filling missing frame rates for PCM
+ for (size_t TrackID=0; TrackID<Streams.size(); TrackID++)
+ {
+ if (Gxf_FrameRate(Streams[TrackID].FrameRate_Code)==0)
+ {
+ Streams[TrackID].FrameRate_Code=Stream_Video_FrameRate_Code;
+ Streams[TrackID].FieldsPerFrame_Code=Stream_Video_FieldsPerFrame_Code;
+ }
+ if (Material_Fields_First_IsValid && Gxf_MediaTypes_StreamKind(Streams[TrackID].MediaType)==Stream_Audio) //In case of offset, MediaFieldNumber-Material_Fields_First is not well rounded
+ {
+ float64 Temp=((float64)Material_Fields_First/Streams[TrackID].FieldsPerFrame_Code)/Gxf_FrameRate(Streams[TrackID].FrameRate_Code);
+ Temp*=48000; //TODO: find where this piece of info is available
+ Temp/=32768;
+ Temp-=(int64u)(Temp);
+ if (Temp)
+ {
+ Temp=((float64)32768)/48000*(1-Temp); //Duration of the first frame not counted
+ Streams[TrackID].FirstFrameDuration=float64_int64s(Temp*1000000000);
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Gxf::media()
+{
+ Element_Name("media");
+
+ //Parsing
+ int32u MediaFieldNumber;
+ int8u MediaType;
+ Element_Begin1("Preamble");
+ Get_B1 (MediaType, "Media type");
+ Get_B1 (TrackNumber, "Track number");
+ Get_B4 (MediaFieldNumber, "Media field number");
+ Skip_B1( "Field information");
+ Skip_B1( "Field information");
+ Skip_B1( "Field information");
+ Skip_B1( "Field information");
+ Skip_B4( "Time line field number");
+ Skip_B1( "Flags");
+ Skip_B1( "Reserved");
+ TrackNumber&=0x3F;
+ Element_End0();
+ Element_Info1(TrackNumber);
+
+ //Managing audio 32768-sample DTS synchro
+ if (Gxf_MediaTypes_StreamKind(MediaType)==Stream_Audio && MediaFieldNumber==Material_Fields_First && Gxf_FrameRate(Streams[TrackNumber].FrameRate_Code) && Streams[TrackNumber].FirstFrameDuration)
+ {
+ float64 Temp=((float64)MediaFieldNumber/Material_Fields_FieldsPerFrame)/Gxf_FrameRate(Streams[TrackNumber].FrameRate_Code);
+ Temp*=48000; //TODO: find where this piece of info is available
+ Temp/=32768;
+ Temp-=(int64u)(Temp);
+ Temp*=(Element_Size-Element_Offset);
+ int64u ByteOffset=(int64u)Temp;
+ int64u SampleSize=(Element_Size-Element_Offset)/32768;
+ ByteOffset/=SampleSize; //Need to be in sync with sample size
+ ByteOffset*=SampleSize;
+ Element_Offset+=ByteOffset;
+ }
+
+ #if MEDIAINFO_SEEK
+ if (!IFrame_IsParsed)
+ {
+ if (UMF_File && ((File_Umf*)UMF_File)->GopSize!=(int64u)-1)
+ IFrame_IsParsed=(((MediaFieldNumber-(Material_Fields_First_IsValid?Material_Fields_First:0))/Material_Fields_FieldsPerFrame)%((File_Umf*)UMF_File)->GopSize)==0;
+ else if (Gxf_MediaTypes_StreamKind(Streams[TrackNumber].MediaType)==Stream_Video)
+ IFrame_IsParsed=true;
+ }
+ #endif //MEDIAINFO_SEEK
+
+ #if MEDIAINFO_DEMUX
+ if (Streams[TrackNumber].MediaType!=8) //Not a TimeCode stream
+ {
+ Element_Code=TrackNumber;
+ int64u TimeCode_First=0;
+ if (!TimeCodes.empty())
+ {
+ TimeCode_First=((File_Gxf_TimeCode*)Streams[TimeCodes.begin()->first].Parser)->TimeCode_First;
+ if (TimeCode_First==(int64u)-1)
+ TimeCode_First=TimeCodes.begin()->second;
+ }
+ if (TimeCode_First!=(int64u)-1)
+ TimeCode_First*=1000000;
+ if (Gxf_MediaTypes_StreamKind(Streams[TrackNumber].MediaType)==Stream_Video)
+ {
+ if (Gxf_FrameRate(Streams[TrackNumber].FrameRate_Code))
+ {
+ FrameInfo.DTS=TimeCode_First+float64_int64s(((float64)MediaFieldNumber-(Material_Fields_First_IsValid?Material_Fields_First:0))/Material_Fields_FieldsPerFrame*1000000000/Gxf_FrameRate(Streams[TrackNumber].FrameRate_Code));
+ FrameInfo.PTS=(int64u)-1;
+ FrameInfo.DUR=float64_int64s(((float64)1000000000)/Gxf_FrameRate(Streams[TrackNumber].FrameRate_Code));
+ }
+ else
+ FrameInfo.DTS=FrameInfo.PTS=FrameInfo.DUR=(int64u)-1;
+ if (MediaFieldNumber-(Material_Fields_First_IsValid?Material_Fields_First:0)==0)
+ Demux_random_access=true;
+ else
+ {
+ if (UMF_File && ((File_Umf*)UMF_File)->GopSize!=(int64u)-1)
+ Demux_random_access=(((MediaFieldNumber-(Material_Fields_First_IsValid?Material_Fields_First:0))/Material_Fields_FieldsPerFrame)%((File_Umf*)UMF_File)->GopSize)==0;
+ else
+ Demux_random_access=false;
+ }
+ }
+ else if (Gxf_MediaTypes_StreamKind(Streams[TrackNumber].MediaType)==Stream_Audio)
+ {
+ if (Gxf_FrameRate(Streams[TrackNumber].FrameRate_Code))
+ {
+ Frame_Count_NotParsedIncluded=(int64u)((MediaFieldNumber-(Material_Fields_First_IsValid?Material_Fields_First:0))/Gxf_FrameRate(Streams[TrackNumber].FrameRate_Code)*48000/32768/Material_Fields_FieldsPerFrame); //A block is 32768 samples at 48 KHz
+ FrameInfo.PTS=TimeCode_First+Frame_Count_NotParsedIncluded*1000000000*32768/48000; //A block is 32768 samples at 48 KHz
+ if (Material_Fields_First_IsValid && MediaFieldNumber!=Material_Fields_First && Streams[TrackNumber].FirstFrameDuration) //In case of offset, MediaFieldNumber-Material_Fields_First is not well rounded
+ {
+ FrameInfo.PTS+=Streams[TrackNumber].FirstFrameDuration;
+ Frame_Count_NotParsedIncluded++;
+ }
+ FrameInfo.DTS=FrameInfo.PTS;
+ }
+ else
+ FrameInfo.DTS=FrameInfo.PTS=(int64u)-1;
+ FrameInfo.DUR=float64_int64s(((float64)1000000000)*32768/48000);
+ Demux_random_access=true;
+ }
+ else
+ {
+ if (Gxf_FrameRate(Streams[0x00].FrameRate_Code))
+ FrameInfo.DTS=FrameInfo.PTS=TimeCode_First+float64_int64s(((float64)(MediaFieldNumber-(Material_Fields_First_IsValid?Material_Fields_First:0)))*1000000000/Gxf_FrameRate(Streams[0x00].FrameRate_Code)/Material_Fields_FieldsPerFrame);
+ else
+ FrameInfo.DTS=FrameInfo.PTS=(int64u)-1;
+ FrameInfo.DUR=(int64u)-1;
+ Demux_random_access=true;
+ }
+ #if MEDIAINFO_SEEK
+ if (Gxf_MediaTypes_StreamKind(Streams[TrackNumber].MediaType)!=Stream_Video || IFrame_IsParsed)
+ #endif //MEDIAINFO_SEEK
+ {
+ if (Gxf_MediaTypes_StreamKind(Streams[TrackNumber].MediaType)!=Stream_Audio)
+ Frame_Count_NotParsedIncluded=(MediaFieldNumber-(Material_Fields_First_IsValid?Material_Fields_First:0))/Material_Fields_FieldsPerFrame;
+ Demux_Level=(Streams[TrackNumber].Parser && (Streams[TrackNumber].Parser->Demux_UnpacketizeContainer || Streams[TrackNumber].Parser->Demux_Level==2))?4:2; //Intermediate (D-10 Audio) / Container
+ Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset), ContentType_MainStream);
+ }
+ Element_Code=0xBF; //media
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ //Needed?
+ if (!Streams[TrackNumber].Searching_Payload)
+ {
+ Skip_XX(Element_Size-Element_Offset, "data");
+ //Element_DoNotShow();
+ return;
+ }
+
+ if (Streams[TrackNumber].Parser)
+ {
+ Streams[TrackNumber].Parser->FrameInfo.DTS=FrameInfo.DTS;
+ Open_Buffer_Continue(Streams[TrackNumber].Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+ if (MediaInfoLib::Config.ParseSpeed_Get()<1 && Streams[TrackNumber].Parser->Status[IsFilled])
+ {
+ Streams[TrackNumber].Searching_Payload=false;
+
+ if (Parsers_Count>0)
+ Parsers_Count--;
+ if (Parsers_Count==0)
+ {
+ Finish();
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Gxf::end_of_stream()
+{
+ Element_Name("end of stream");
+}
+
+//---------------------------------------------------------------------------
+void File_Gxf::field_locator_table()
+{
+ Element_Name("field locator table");
+
+ //Parsing
+ int32u Entries;
+ #if MEDIAINFO_SEEK
+ Get_L4 (Flt_FieldPerEntry, "Number of fields per FLT entry");
+ #else //MEDIAINFO_SEEK
+ Skip_L4( "Number of fields per FLT entry");
+ #endif //MEDIAINFO_SEEK
+ Get_L4 (Entries, "Number of FLT entries");
+ for (size_t Pos=0; Pos<Entries; Pos++)
+ {
+ #if MEDIAINFO_SEEK
+ int32u Offset;
+ Get_L4 (Offset, "Offset to fields");
+ Flt_Offsets.push_back(Offset);
+ #else //MEDIAINFO_SEEK
+ Skip_L4( "Offset to fields");
+ #endif //MEDIAINFO_SEEK
+ if (Element_Offset==Element_Size)
+ break;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Gxf::UMF_file()
+{
+ Element_Name("UMF file");
+
+ //Parsing
+ int32u PayloadDataLength;
+ Element_Begin1("Preamble");
+ Skip_B1( "First/last packet flag");
+ Get_B4 (PayloadDataLength, "Payload data length");
+ Element_End0();
+
+ if (UMF_File==NULL)
+ {
+ UMF_File=new File_Umf();
+ Open_Buffer_Init(UMF_File);
+ }
+ Open_Buffer_Continue(UMF_File, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+
+ #if MEDIAINFO_SEEK
+ if (Seeks.empty() && Flt_FieldPerEntry!=(int32u)-1 && ((File_Umf*)UMF_File)->GopSize!=(int64u)-1)
+ {
+ size_t NextIFrame=0;
+ for (size_t Pos=0; Pos<Flt_Offsets.size(); Pos++)
+ if (Pos*Flt_FieldPerEntry>=NextIFrame)
+ {
+ seek Seek;
+ Seek.FrameNumber=(Material_Fields_First_IsValid?Material_Fields_First:0)+Pos*Flt_FieldPerEntry;
+ Seek.StreamOffset=Flt_Offsets[Pos];
+ Seeks.push_back(Seek);
+ NextIFrame+=(size_t)((File_Umf*)UMF_File)->GopSize*Material_Fields_FieldsPerFrame;
+ }
+ Flt_Offsets.clear();
+ }
+ #endif //MEDIAINFO_SEEK
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Gxf::Detect_EOF()
+{
+ if (File_Offset+Buffer_Size>=SizeToAnalyze)
+ {
+ Finish();
+ }
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Gxf::ChooseParser_ChannelGrouping(int8u TrackID)
+{
+ File_ChannelGrouping* Parser;
+ if (Audio_Count%2)
+ {
+ if (!Streams[TrackID-1].IsChannelGrouping)
+ return NULL; //Not a channel grouping
+
+ Parser=new File_ChannelGrouping;
+ Parser->Channel_Pos=1;
+ Parser->Common=((File_ChannelGrouping*)Streams[TrackID-1].Parser)->Common;
+ Parser->StreamID=TrackID-1;
+ Streams[TrackID].DisplayInfo=false;
+ }
+ else
+ {
+ Parser=new File_ChannelGrouping;
+ Parser->Channel_Pos=0;
+ //if (Descriptor->second.Infos.find("SamplingRate")!=Descriptor->second.Infos.end())
+ Parser->SampleRate=48000; //TODO: find where this piece of info is avaialble
+ Streams[TrackID].IsChannelGrouping=true;
+ }
+ Parser->Channel_Total=2;
+ Parser->Endianness='L';
+ Parser->ByteDepth=3;
+ Parser->IsAes3=true;
+
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer)
+ {
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ return Parser;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_GXF_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf.h
new file mode 100644
index 000000000..348ccb7ed
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf.h
@@ -0,0 +1,168 @@
+// File_Gxf - Info for GXF (SMPTE 360M) files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about GXF files
+// SMPTE 360M - General Exchange Format
+// SMPTE RDD 14-2007 - General Exchange Format-2
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_GxfH
+#define MediaInfo_File_GxfH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#if defined(MEDIAINFO_ANCILLARY_YES)
+ #include <MediaInfo/Multiple/File_Ancillary.h>
+#endif //defined(MEDIAINFO_ANCILLARY_YES)
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Gxf
+//***************************************************************************
+
+class File_Gxf : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Gxf();
+ ~File_Gxf();
+
+private :
+ //Streams management
+ void Streams_Finish();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched();
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - Per element
+ bool Header_Begin();
+ void Header_Parse();
+ void Data_Parse();
+
+ //Packets
+ void map();
+ void media();
+ void end_of_stream();
+ void field_locator_table();
+ void UMF_file();
+
+ //Temp - Global
+ #if defined(MEDIAINFO_ANCILLARY_YES)
+ File_Ancillary* Ancillary;
+ #endif //defined(MEDIAINFO_ANCILLARY_YES)
+ int32u Material_Fields_First;
+ int32u Material_Fields_Last;
+ int32u Material_File_Size;
+ int32u Material_Fields_FieldsPerFrame;
+ int8u Parsers_Count;
+ int8u AncillaryData_StreamID;
+ std::map<int8u, int64u> TimeCodes; //Key is StreamID
+ bool Material_Fields_First_IsValid;
+ bool Material_Fields_Last_IsValid;
+ bool Material_File_Size_IsValid;
+
+ //Temp - Stream
+ struct stream
+ {
+ File__Analyze* Parser;
+ int64u FirstFrameDuration; //In case of audio, indicates the duration of the first frame
+ stream_t StreamKind;
+ size_t StreamPos;
+ int32u TimeStamp_Start;
+ int32u TimeStamp_End;
+ int32u FrameRate_Code;
+ int32u LinesPerFrame_Code;
+ int32u FieldsPerFrame_Code;
+ int8u MediaType;
+ int8u TrackID;
+ bool Searching_Payload;
+ bool Searching_TimeStamp_Start;
+ bool Searching_TimeStamp_End;
+ bool IsChannelGrouping;
+ bool DisplayInfo; //In case of channel grouping, info is about the complete (2*half) stream, so second stream info must not be used
+ Ztring MediaName;
+ std::map<std::string, Ztring> Infos;
+
+ stream()
+ {
+ Parser=NULL;
+ FirstFrameDuration=0;
+ StreamKind=Stream_Max;
+ StreamPos=(size_t)-1;
+ Searching_Payload=false;
+ Searching_TimeStamp_Start=false;
+ Searching_TimeStamp_End=false;
+ FrameRate_Code=(int32u)-1;
+ LinesPerFrame_Code=(int32u)-1;
+ FieldsPerFrame_Code=(int32u)-1;
+ MediaType=(int8u)-1;
+ TrackID=(int8u)-1;
+ IsChannelGrouping=false;
+ DisplayInfo=true;
+ }
+ ~stream()
+ {
+ delete Parser; //Parser=NULL
+ }
+ };
+ std::vector<stream> Streams;
+ File__Analyze* UMF_File;
+ int64u SizeToAnalyze; //Total size of a chunk to analyse, it may be changed by the parser
+ int8u Audio_Count;
+ int8u TrackNumber;
+
+ //File__Analyze helpers
+ void Streams_Finish_PerStream(size_t StreamID, stream &Temp);
+ void Detect_EOF();
+ File__Analyze* ChooseParser_ChannelGrouping(int8u TrackID);
+
+ #if MEDIAINFO_DEMUX
+ bool Demux_HeaderParsed;
+ #endif //MEDIAINFO_DEMUX
+
+ #if MEDIAINFO_SEEK
+ int32u Flt_FieldPerEntry;
+ std::vector<int32u> Flt_Offsets; //In 1024-byte
+ struct seek
+ {
+ int64u FrameNumber;
+ int32u StreamOffset; //In 1024-byte
+ };
+ std::vector<seek> Seeks;
+ bool IFrame_IsParsed;
+ #endif //MEDIAINFO_SEEK
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf_TimeCode.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf_TimeCode.cpp
new file mode 100644
index 000000000..745a11225
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf_TimeCode.cpp
@@ -0,0 +1,207 @@
+// File_Gxf_TimeCode - Info for GXF (SMPTE 360M) files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_GXF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Gxf_TimeCode.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+extern double Gxf_FrameRate(int32u Content);
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Gxf_TimeCode::File_Gxf_TimeCode()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("GXF");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Gxf;
+ StreamIDs_Width[0]=2;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ #endif //MEDIAINFO_DEMUX
+
+ //In
+ FrameRate_Code=(int32u)-1;
+ FieldsPerFrame_Code=(int32u)-1;
+
+ //Out
+ TimeCode_First=(int64u)-1;
+}
+
+//---------------------------------------------------------------------------
+File_Gxf_TimeCode::~File_Gxf_TimeCode()
+{
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Gxf_TimeCode::Streams_Fill()
+{
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Delay, TimeCode_First);
+ Fill(Stream_Video, 0, Video_Delay_Source, "Container");
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Delay, TimeCode_First);
+ Fill(Stream_Audio, 0, Audio_Delay_Source, "Container");
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Gxf_TimeCode::Read_Buffer_Continue()
+{
+ if (Element_Size!=4096)
+ {
+ Skip_XX(Element_Size, "Data");
+ return;
+ }
+
+ //Reading bitmap first (validity of first byte is at the end)
+ Element_Offset=504*8;
+ Element_Begin1("Validity");
+ int8u Validity[504];
+ BS_Begin_LE(); //is Little Endian
+ for (size_t Pos=0; Pos<504; Pos++)
+ {
+ bool Validity_Bit;
+ Get_TB (Validity_Bit, "Bit");
+ Validity[Pos]=Validity_Bit?1:0;
+ }
+ BS_End_LE();
+ Skip_B1( "Pad");
+ Element_End0();
+
+ //Parsing
+ Element_Offset=0;
+ for (size_t Pos=0; Pos<504; Pos++)
+ {
+ if (Validity[Pos])
+ {
+ Element_Begin1("TimeCode");
+ int8u Frames_Units, Frames_Tens, Seconds_Units, Seconds_Tens, Minutes_Units, Minutes_Tens, Hours_Units, Hours_Tens;
+ bool DropFrame;
+ BS_Begin();
+
+ Skip_S1(4, "BG1");
+ Get_S1 (4, Frames_Units, "Frames (Units)");
+
+ Skip_S1(4, "BG2");
+ Skip_SB( "CF - Color fame");
+ Get_SB ( DropFrame, "DP - Drop frame");
+ Get_S1 (2, Frames_Tens, "Frames (Tens)");
+
+ Skip_S1(4, "BG3");
+ Get_S1 (4, Seconds_Units, "Seconds (Units)");
+
+ Skip_S1(4, "BG4");
+ Skip_SB( "FM - Frame Mark");
+ Get_S1 (3, Seconds_Tens, "Seconds (Tens)");
+
+ Skip_S1(4, "BG5");
+ Get_S1 (4, Minutes_Units, "Minutes (Units)");
+
+ Skip_S1(4, "BG6");
+ Skip_SB( "BGF0");
+ Get_S1 (3, Minutes_Tens, "Minutes (Tens)");
+
+ Skip_S1(4, "BG7");
+ Get_S1 (4, Hours_Units, "Hours (Units)");
+
+ Skip_S1(4, "BG8");
+ Skip_SB( "BGF2");
+ Skip_SB( "BGF1");
+ Get_S1 (2, Hours_Tens, "Hours (Tens)");
+
+ int64u TimeCode_Ms=(int64u)(Hours_Tens *10*60*60*1000
+ + Hours_Units *60*60*1000
+ + Minutes_Tens *10*60*1000
+ + Minutes_Units *60*1000
+ + Seconds_Tens *10*1000
+ + Seconds_Units *1000
+ + (Gxf_FrameRate(FrameRate_Code)==0?0:((Frames_Tens*10+Frames_Units)*1000/float64_int32s(Gxf_FrameRate(FrameRate_Code)/(Gxf_FrameRate(FrameRate_Code)>30?2:1)))));
+
+ Element_Info1(Ztring().Duration_From_Milliseconds(TimeCode_Ms));
+
+ BS_End();
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (TimeCode_First==(int64u)-1)
+ TimeCode_First=TimeCode_Ms;
+ FILLING_END();
+ }
+ else
+ Skip_XX(8, "Junk");
+ }
+
+ //bitmap, already parsed
+ Element_Offset+=64;
+
+ FILLING_BEGIN();
+ if (!Status[IsFilled] && TimeCode_First!=(int64u)-1)
+ {
+ Accept();
+ Fill();
+
+ if (MediaInfoLib::Config.ParseSpeed_Get()<1)
+ Finish();
+ }
+
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_GXF_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf_TimeCode.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf_TimeCode.h
new file mode 100644
index 000000000..1d6a56b10
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Gxf_TimeCode.h
@@ -0,0 +1,70 @@
+// File_Gxf - Info for GXF (SMPTE 360M) files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about GXF files
+// SMPTE 360M - General Exchange Format
+// SMPTE RDD 14-2007 - General Exchange Format-2
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Gxf_TimeCodeH
+#define MediaInfo_File_Gxf_TimeCodeH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#if defined(MEDIAINFO_ANCILLARY_YES)
+ #include <MediaInfo/Multiple/File_Ancillary.h>
+#endif //defined(MEDIAINFO_ANCILLARY_YES)
+#include "MediaInfo/TimeCode.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Gxf_TimeCode
+//***************************************************************************
+
+class File_Gxf_TimeCode : public File__Analyze
+{
+public :
+ //In
+ int32u FrameRate_Code;
+ int32u FieldsPerFrame_Code;
+
+ //Out
+ int64u TimeCode_First;
+
+ //Constructor/Destructor
+ File_Gxf_TimeCode();
+ ~File_Gxf_TimeCode();
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Hls.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Hls.cpp
new file mode 100644
index 000000000..1a4f9c93a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Hls.cpp
@@ -0,0 +1,198 @@
+// File_Hls - Info for HLS files
+// Copyright (C) 2010-2012 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_HLS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Hls.h"
+#include "MediaInfo/MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/Multiple/File__ReferenceFilesHelper.h"
+#include "ZenLib/Dir.h"
+#include "ZenLib/FileName.h"
+#include "ZenLib/ZtringList.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Hls::File_Hls()
+:File__Analyze()
+{
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Hls;
+ StreamIDs_Width[0]=0;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_EventWasSent_Accept_Specific=true;
+ #endif //MEDIAINFO_DEMUX
+
+ //Temp
+ ReferenceFiles=NULL;
+}
+
+//---------------------------------------------------------------------------
+File_Hls::~File_Hls()
+{
+ delete ReferenceFiles; //ReferenceFiles=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Hls::Streams_Finish()
+{
+ if (ReferenceFiles==NULL)
+ return;
+
+ ReferenceFiles->ParseReferences();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_Hls::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ if (ReferenceFiles==NULL)
+ return 0;
+
+ return ReferenceFiles->Read_Buffer_Seek(Method, Value, ID);
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Hls::FileHeader_Begin()
+{
+ //Element_Size
+ if (File_Size>1024*1024 || File_Size<10)
+ {
+ Reject("HLS");
+ return false; //HLS files are not big
+ }
+
+ if (Buffer_Size<File_Size)
+ return false; //Wait for complete file
+
+ Ztring Document; Document.From_UTF8((char*)Buffer, Buffer_Size);
+ ZtringList Lines;
+ size_t LinesSeparator_Pos=Document.find_first_of(_T("\r\n"));
+ if (LinesSeparator_Pos>File_Size-1)
+ {
+ Reject("HLS");
+ return false;
+ }
+ Ztring LinesSeparator;
+ if (Document[LinesSeparator_Pos]==_T('\r') && Document[LinesSeparator_Pos+1]==_T('\n'))
+ LinesSeparator=_T("\r\n");
+ else if (Document[LinesSeparator_Pos]==_T('\r'))
+ LinesSeparator=_T("\r");
+ else if (Document[LinesSeparator_Pos]==_T('\n'))
+ LinesSeparator=_T("\n");
+ else
+ {
+ Reject("HLS");
+ return false;
+ }
+ Lines.Separator_Set(0, LinesSeparator);
+ Lines.Write(Document);
+
+ if (Lines(0)!=_T("#EXTM3U"))
+ {
+ Reject("HLS");
+ return false;
+ }
+
+ Accept("HLS");
+ Fill(Stream_General, 0, General_Format, "HLS");
+
+ ReferenceFiles=new File__ReferenceFilesHelper(this, Config);
+
+ File__ReferenceFilesHelper::reference ReferenceFile;
+
+ bool IsGroup=false;
+ for (size_t Line=0; Line<Lines.size(); Line++)
+ {
+ if (!Lines[Line].empty())
+ {
+ if (Lines[Line].find(_T("#EXT-X-STREAM-INF"))==0)
+ IsGroup=true;
+ else if (Lines[Line][0]==_T('#'))
+ ;
+ else
+ {
+ if (IsGroup)
+ {
+ File__ReferenceFilesHelper::reference ReferenceStream;
+ ReferenceStream.FileNames.push_back(Lines[Line]);
+ ReferenceStream.StreamID=ReferenceFiles->References.size()+1;
+ ReferenceFiles->References.push_back(ReferenceStream);
+ IsGroup=false;
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_HlsIndex;
+ StreamIDs_Width[0]=sizeof(size_t)*2;
+ #endif //MEDIAINFO_EVENTS
+ }
+ else
+ ReferenceFile.FileNames.push_back(Lines[Line]);
+ }
+ }
+ }
+
+ if (ReferenceFiles->References.empty())
+ {
+ ReferenceFiles->References.push_back(ReferenceFile);
+ ReferenceFiles->TestContinuousFileNames=true;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_HLS_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Hls.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Hls.h
new file mode 100644
index 000000000..5b618cf93
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Hls.h
@@ -0,0 +1,69 @@
+// File_Hls - Info for HLS files
+// Copyright (C) 2010-2012 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about HLS files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_HlsH
+#define MediaInfo_File_HlsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class File__ReferenceFilesHelper;
+
+//***************************************************************************
+// Class File_Hls
+//***************************************************************************
+
+class File_Hls : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Hls();
+ ~File_Hls();
+
+private :
+ //Streams management
+ void Streams_Finish ();
+
+ //Buffer - Global
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Temp
+ File__ReferenceFilesHelper* ReferenceFiles;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi.cpp
new file mode 100644
index 000000000..0f27cfb24
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi.cpp
@@ -0,0 +1,765 @@
+// File_Mk - Info for Ibi files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_IBI
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Ibi.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include <zlib.h>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Ibi::File_Ibi()
+:File__Analyze()
+{
+ //Configuration
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ #endif //MEDIAINFO_DEMUX
+ DataMustAlwaysBeComplete=false;
+
+ //In
+ Ibi=NULL;
+
+ //Temp
+ Ibi_MustDelete=false;
+}
+
+//---------------------------------------------------------------------------
+File_Ibi::~File_Ibi()
+{
+ if (Ibi_MustDelete)
+ delete Ibi; //Ibi=NULL;
+}
+
+//***************************************************************************
+// Get information
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const Ztring &File_Ibi::Get (stream_t /*StreamKind*/, size_t /*StreamNumber*/, const Ztring &Parameter, info_t /*KindOfInfo*/, info_t /*KindOfSearch*/)
+{
+ ibi::streams::iterator IbiStream_Temp=Ibi->Streams.begin(); //TODO: management of multiple streams
+ if (IbiStream_Temp!=Ibi->Streams.end() && !IbiStream_Temp->second->Infos.empty())
+ {
+ int64u FrameNumber=Parameter.To_int64u();
+
+ for (size_t Pos=0; Pos<IbiStream_Temp->second->Infos.size()-1; Pos++)
+ if (IbiStream_Temp->second->Infos[Pos].FrameNumber==FrameNumber || IbiStream_Temp->second->Infos[Pos+1].FrameNumber>FrameNumber)
+ {
+ Get_Temp=_T("StreamOffset=")+Ztring::ToZtring(IbiStream_Temp->second->Infos[Pos].StreamOffset)
+ + _T(" / FrameNumber=")+Ztring::ToZtring(IbiStream_Temp->second->Infos[Pos].FrameNumber)
+ + _T(" / Dts=")+Ztring::ToZtring(IbiStream_Temp->second->Infos[Pos].Dts);
+ return Get_Temp;
+ }
+ }
+
+ //Can not be found
+ Get_Temp.clear();
+ return Get_Temp;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ibi::Streams_Accept()
+{
+ Fill(Stream_General, 0, General_Format, "Ibi");
+
+ if (Ibi==NULL)
+ {
+ Ibi=new ibi();
+ Ibi_MustDelete=true;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Streams_Finish()
+{
+ Config->File_KeepInfo_Set(true); //In order to let Get() available
+
+ for (ibi::streams::iterator IbiStream_Temp=Ibi->Streams.begin(); IbiStream_Temp!=Ibi->Streams.end(); IbiStream_Temp++)
+ {
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, StreamPos_Last, General_ID, IbiStream_Temp->first);
+ }
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ibi::Header_Parse()
+{
+ //Test of zero padding
+ int8u Null;
+ Peek_B1(Null);
+ if (Null==0x00)
+ {
+ Skip_B1( "Zero byte");
+ Header_Fill_Code((int32u)-1); //Should be (int64u)-1 but Borland C++ does not like this
+ Header_Fill_Size(1);
+ return;
+ }
+
+ //Parsing
+ int64u Name, Size;
+ Get_EB (Name, "Name");
+ Get_EB (Size, "Size");
+
+ //Filling
+ Header_Fill_Code(Name, Ztring().From_Number(Name, 16));
+ Header_Fill_Size(Element_Offset+Size);
+}
+
+//---------------------------------------------------------------------------
+namespace Elements
+{
+ //Common
+ const int64u Zero=(int32u)-1; //Should be (int64u)-1 but Borland C++ does not like this
+ const int64u CRC32=0x3F;
+ const int64u Void=0x6C;
+
+ //EBML
+ const int64u Ebml=0xA45DFA3;
+ const int64u Ebml_Version=0x286;
+ const int64u Ebml_ReadVersion=0x2F7;
+ const int64u Ebml_MaxIDLength=0x2F2;
+ const int64u Ebml_MaxSizeLength=0x2F3;
+ const int64u Ebml_DocType=0x282;
+ const int64u Ebml_DocTypeVersion=0x287;
+ const int64u Ebml_DocTypeReadVersion=0x285;
+
+ //Segment
+ const int64u Stream=0x01;
+ const int64u Stream_Header=0x01;
+ const int64u Stream_ByteOffset=0x02;
+ const int64u Stream_FrameNumber=0x03;
+ const int64u Stream_Dts=0x04;
+ const int64u CompressedIndex=0x02;
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Data_Parse()
+{
+ #define LIS2(_ATOM, _NAME) \
+ case Elements::_ATOM : \
+ if (Level==Element_Level) \
+ { \
+ Element_Name(_NAME); \
+ _ATOM(); \
+ Element_ThisIsAList(); \
+ } \
+
+ #define ATO2(_ATOM, _NAME) \
+ case Elements::_ATOM : \
+ if (Level==Element_Level) \
+ { \
+ if (Element_IsComplete_Get()) \
+ { \
+ Element_Name(_NAME); \
+ _ATOM(); \
+ } \
+ else \
+ { \
+ Element_WaitForMoreData(); \
+ return; \
+ } \
+ } \
+ break; \
+
+ #define ATOM_END_MK \
+ ATOM(Zero) \
+ ATOM(CRC32) \
+ ATOM(Void) \
+ ATOM_END
+
+ //Parsing
+ DATA_BEGIN
+ LIST(Ebml)
+ ATOM_BEGIN
+ ATOM(Ebml_Version)
+ ATOM(Ebml_ReadVersion)
+ ATOM(Ebml_MaxIDLength)
+ ATOM(Ebml_MaxSizeLength)
+ ATOM(Ebml_DocType)
+ ATOM(Ebml_DocTypeVersion)
+ ATOM(Ebml_DocTypeReadVersion)
+ ATOM_END_MK
+ LIST(Stream)
+ ATOM_BEGIN
+ ATOM(Stream_Header)
+ ATOM(Stream_ByteOffset)
+ ATOM(Stream_FrameNumber)
+ ATOM(Stream_Dts)
+ ATOM_END_MK
+ ATOM(CompressedIndex)
+ DATA_DEFAULT
+ Finish("Ibi");
+ DATA_END_DEFAULT
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ibi::Zero()
+{
+ Element_Name("ZeroPadding");
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::CRC32()
+{
+ Element_Name("CRC32");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Void()
+{
+ Element_Name("Void");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Ebml()
+{
+ Element_Name("Ebml");
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Ebml_Version()
+{
+ Element_Name("Version");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Ebml_ReadVersion()
+{
+ Element_Name("ReadVersion");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Ebml_MaxIDLength()
+{
+ Element_Name("MaxIDLength");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Ebml_MaxSizeLength()
+{
+ Element_Name("MaxSizeLength");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Ebml_DocType()
+{
+ Element_Name("DocType");
+
+ //Parsing
+ Ztring Data;
+ Get_Local(Element_Size, Data, "Data"); Element_Info1(Data);
+
+ //Filling
+ FILLING_BEGIN();
+
+ if (Data==_T("MediaInfo Index"))
+ Accept("Ibi");
+ else
+ {
+ Reject("Ibi");
+ return;
+ }
+
+ Buffer_MaximumSize=8*1024*1024;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Ebml_DocTypeVersion()
+{
+ Element_Name("DocTypeVersion");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Ebml_DocTypeReadVersion()
+{
+ Element_Name("DocTypeReadVersion");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi::Stream()
+{
+ Element_Name("Stream");
+
+ ID_Current=(int64u)-1;
+}
+
+void File_Ibi::Stream_Header()
+{
+ Element_Name("Stream Header");
+ Get_EB (ID_Current, "ID");
+
+ FILLING_BEGIN();
+ if (Ibi)
+ {
+ //Filling information for ID after data
+ ibi::streams::iterator IbiStream_Temp=Ibi->Streams.find((int64u)-1);
+ if (IbiStream_Temp!=Ibi->Streams.end())
+ {
+ Ibi->Streams[ID_Current]=IbiStream_Temp->second;
+ Ibi->Streams.erase(IbiStream_Temp);
+ }
+ }
+ FILLING_END();
+}
+
+void File_Ibi::Stream_ByteOffset()
+{
+ Element_Name("Byte Offset");
+
+ //Parsing
+ size_t Pos=0;
+ int64u Offset=0;
+ while (Element_Offset<Element_Size)
+ {
+ int64u Item;
+ Get_EB (Item, "Item");
+ Offset+=Item;
+ Param_Info1(Pos);
+ Param_Info1(Ztring::ToZtring(Offset)+_T(" (0x")+Ztring::ToZtring(Offset, 16)+_T(')'));
+
+ FILLING_BEGIN();
+ if (Ibi)
+ {
+ //Filling information for ID after data
+ if (Ibi->Streams[ID_Current]==NULL)
+ Ibi->Streams[ID_Current]=new ibi::stream();
+ if (Pos>=Ibi->Streams[ID_Current]->Infos.size())
+ {
+ Ibi->Streams[ID_Current]->Infos.push_back(ibi::stream::info());
+ Ibi->Streams[ID_Current]->Infos[Pos].IsContinuous=true; //default
+ }
+ Ibi->Streams[ID_Current]->Infos[Pos].StreamOffset=Offset;
+ Pos++;
+ }
+ FILLING_END();
+ }
+}
+
+void File_Ibi::Stream_FrameNumber()
+{
+ Element_Name("Frame Number");
+
+ //Parsing
+ size_t Pos=0;
+ int64u Offset=0;
+ while (Element_Offset<Element_Size)
+ {
+ int64u Item;
+ Get_EB (Item, "Item");
+ Offset+=Item;
+ Param_Info1(Pos);
+ Param_Info1(Ztring::ToZtring(Offset)+_T(" (0x")+Ztring::ToZtring(Offset, 16)+_T(')'));
+
+ FILLING_BEGIN();
+ if (Ibi)
+ {
+ //Filling information for ID after data
+ if (Ibi->Streams[ID_Current]==NULL)
+ Ibi->Streams[ID_Current]=new ibi::stream();
+ if (Pos>=Ibi->Streams[ID_Current]->Infos.size())
+ {
+ Ibi->Streams[ID_Current]->Infos.push_back(ibi::stream::info());
+ Ibi->Streams[ID_Current]->Infos[Pos].IsContinuous=true; //default
+ }
+ Ibi->Streams[ID_Current]->Infos[Pos].FrameNumber=Offset;
+ Pos++;
+ }
+ FILLING_END();
+ }
+}
+
+void File_Ibi::Stream_Dts()
+{
+ Element_Name("DTS");
+
+ //Parsing
+ int64u Item;
+ Get_EB (Item, "DtsFrequencyNumerator");
+ FILLING_BEGIN();
+ if (Ibi)
+ Ibi->Streams[ID_Current]->DtsFrequencyNumerator=Item;
+ FILLING_END();
+ Get_EB (Item, "DtsFrequencyDenominator");
+ FILLING_BEGIN();
+ if (Ibi)
+ {
+ Ibi->Streams[ID_Current]->DtsFrequencyDenominator=Item;
+
+ //Handling of previous inverted Numerator/Denominator
+ if (Ibi->Streams[ID_Current]->DtsFrequencyNumerator<Ibi->Streams[ID_Current]->DtsFrequencyDenominator)
+ std::swap(Ibi->Streams[ID_Current]->DtsFrequencyNumerator, Ibi->Streams[ID_Current]->DtsFrequencyDenominator);
+ }
+ FILLING_END();
+
+ size_t Pos=0;
+ int64u Offset=0;
+ while (Element_Offset<Element_Size)
+ {
+ int64u Item;
+ Get_EB (Item, "Item");
+ Offset+=Item;
+ Param_Info1(Pos);
+ Param_Info1(Ztring::ToZtring(Offset)+_T(" (0x")+Ztring::ToZtring(Offset, 16)+_T(')'));
+
+ FILLING_BEGIN();
+ if (Ibi)
+ {
+ //Filling information for ID after data
+ if (Ibi->Streams[ID_Current]==NULL)
+ Ibi->Streams[ID_Current]=new ibi::stream();
+ if (Pos>=Ibi->Streams[ID_Current]->Infos.size())
+ {
+ Ibi->Streams[ID_Current]->Infos.push_back(ibi::stream::info());
+ Ibi->Streams[ID_Current]->Infos[Pos].IsContinuous=true; //default
+ }
+ Ibi->Streams[ID_Current]->Infos[Pos].Dts=Offset;
+ Pos++;
+ }
+ FILLING_END();
+ }
+}
+
+void File_Ibi::CompressedIndex()
+{
+ Element_Name("Compressed Index");
+ int64u UncompressedSize;
+ Get_EB (UncompressedSize, "Uncompressed size");
+
+ //Sizes
+ unsigned long Source_Size=(unsigned long)(Element_Size-Element_Offset);
+ unsigned long Dest_Size=(unsigned long)UncompressedSize;
+
+ //Uncompressing
+ int8u* Dest=new int8u[Dest_Size];
+ if (uncompress((Bytef*)Dest, &Dest_Size, (const Bytef*)Buffer+Buffer_Offset+(size_t)Element_Offset, Source_Size)<0)
+ {
+ Skip_XX(Element_Size-Element_Offset, "Problem during the decompression");
+ delete[] Dest; //Dest=NULL;
+ return;
+ }
+
+ //Exiting this element
+ Skip_XX(Element_Size-Element_Offset, "Will be parsed");
+
+ //Configuring buffer
+ const int8u* Buffer_Sav=Buffer;
+ size_t Buffer_Size_Sav=Buffer_Size;
+ int8u* Buffer_Temp_Sav=Buffer_Temp;
+ size_t Buffer_Temp_Size_Sav=Buffer_Temp_Size;
+ size_t Buffer_Offset_Sav=Buffer_Offset;
+ size_t Buffer_Offset_Temp_Sav=Buffer_Offset_Temp;
+ Buffer=NULL;
+ Buffer_Size=0;
+ Buffer_Temp=NULL;
+ Buffer_Temp_Size=0;
+ Buffer_Offset=0;
+ Buffer_Offset_Temp=0;
+
+ //Configuring level
+ std::vector<int64u> Element_Sizes_Sav;
+ size_t Element_Level_Sav=Element_Level;
+ while(Element_Level)
+ {
+ Element_Sizes_Sav.push_back(Element_TotalSize_Get());
+ Element_End0();
+ }
+
+ //Configuring file size
+ int64u File_Size_Sav=File_Size;
+ if (File_Size<File_Offset+Buffer_Offset+Element_Offset+Dest_Size)
+ File_Size=File_Offset+Buffer_Offset+Element_Offset+Dest_Size;
+ Element_Level++;
+ Header_Fill_Size(File_Size);
+ Element_Level--;
+
+ //Parsing
+ Open_Buffer_Continue(Dest, Dest_Size);
+ delete[] Dest; //Dest=NULL;
+
+ //Resetting file size
+ File_Size=File_Size_Sav;
+ while(Element_Level)
+ Element_End0();
+ Element_Level++;
+ Header_Fill_Size(File_Size);
+ Element_Level--;
+
+ //Configuring level
+ while(Element_Level<Element_Level_Sav)
+ {
+ Element_Begin0();
+ Element_Begin0();
+ Header_Fill_Size(Element_Sizes_Sav[0]);
+ Element_End0();
+ }
+
+ //Resetting buffer
+ Buffer=Buffer_Sav;
+ Buffer_Size=Buffer_Size_Sav;
+ Buffer_Temp=Buffer_Temp_Sav;
+ Buffer_Temp_Size=Buffer_Temp_Size_Sav;
+ Buffer_Offset=Buffer_Offset_Sav;
+ Buffer_Offset_Temp=Buffer_Offset_Temp_Sav;
+}
+
+//***************************************************************************
+// Data
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ibi::UInteger_Info()
+{
+ switch (Element_Size)
+ {
+ case 1 :
+ {
+ Info_B1(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 2 :
+ {
+ Info_B2(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 3 :
+ {
+ Info_B3(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 4 :
+ {
+ Info_B4(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 5 :
+ {
+ Info_B5(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 6 :
+ {
+ Info_B6(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 7 :
+ {
+ Info_B7(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 8 :
+ {
+ Info_B8(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 16:
+ {
+ Info_B16(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ default : Skip_XX(Element_Size, "Data");
+ }
+}
+
+//---------------------------------------------------------------------------
+int64u File_Ibi::UInteger_Get()
+{
+ switch (Element_Size)
+ {
+ case 1 :
+ {
+ int8u Data;
+ Get_B1 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 2 :
+ {
+ int16u Data;
+ Get_B2 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 3 :
+ {
+ int32u Data;
+ Get_B3 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 4 :
+ {
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 5 :
+ {
+ int64u Data;
+ Get_B5 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 6 :
+ {
+ int64u Data;
+ Get_B6 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 7 :
+ {
+ int64u Data;
+ Get_B7 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 8 :
+ {
+ int64u Data;
+ Get_B8 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ default : Skip_XX(Element_Size, "Data");
+ return 0;
+ }
+}
+
+//---------------------------------------------------------------------------
+int128u File_Ibi::UInteger16_Get()
+{
+ switch (Element_Size)
+ {
+ case 1 :
+ {
+ int8u Data;
+ Get_B1 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 2 :
+ {
+ int16u Data;
+ Get_B2 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 3 :
+ {
+ int32u Data;
+ Get_B3 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 4 :
+ {
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 5 :
+ {
+ int64u Data;
+ Get_B5 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 6 :
+ {
+ int64u Data;
+ Get_B6 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 7 :
+ {
+ int64u Data;
+ Get_B7 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 8 :
+ {
+ int64u Data;
+ Get_B8 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 16:
+ {
+ int128u Data;
+ Get_B16(Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ default : Skip_XX(Element_Size, "Data");
+ return 0;
+ }
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_IBI_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi.h
new file mode 100644
index 000000000..bf02ee3c5
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi.h
@@ -0,0 +1,95 @@
+// File_Mk - Info for Ibi Video/Audio files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Ibi files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_IbiH
+#define MediaInfo_File_IbiH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Classe File_Ibi
+//***************************************************************************
+
+class File_Ibi : public File__Analyze
+{
+public :
+ File_Ibi();
+ ~File_Ibi();
+
+ //In
+ ibi* Ibi;
+
+private :
+ //Get information
+ const Ztring &Get (stream_t StreamKind, size_t StreamNumber, const Ztring &Parameter, info_t KindOfInfo=Info_Text, info_t KindOfSearch=Info_Name);
+
+ //Streams management
+ void Streams_Accept();
+ void Streams_Finish();
+
+ //Buffer - Element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Zero();
+ void CRC32();
+ void Void();
+ void Ebml();
+ void Ebml_Version();
+ void Ebml_ReadVersion();
+ void Ebml_MaxIDLength();
+ void Ebml_MaxSizeLength();
+ void Ebml_DocType();
+ void Ebml_DocTypeVersion();
+ void Ebml_DocTypeReadVersion();
+ void Stream();
+ void Stream_Header();
+ void Stream_ByteOffset();
+ void Stream_FrameNumber();
+ void Stream_Dts();
+ void CompressedIndex();
+
+ //Data
+ int64u UInteger_Get();
+ int128u UInteger16_Get();
+ void UInteger_Info();
+
+ //Temp
+ Ztring Get_Temp;
+ int64u ID_Current;
+ bool Ibi_MustDelete;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi_Creation.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi_Creation.cpp
new file mode 100644
index 000000000..7e103f9cc
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi_Creation.cpp
@@ -0,0 +1,445 @@
+// File_Ibi_Creation - Creation of Ibi files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_IBI
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Ibi_Creation.h"
+#include <cstring>
+#include <zlib.h>
+#include "base64.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Ibi structure
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+ibi::ibi()
+{
+}
+
+//---------------------------------------------------------------------------
+ibi::~ibi()
+{
+ for (streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); Stream++)
+ delete Stream->second; //Stream->second=NULL;
+}
+
+//---------------------------------------------------------------------------
+void ibi::stream::Add (const info &Info)
+{
+ if (!IsSynchronized)
+ {
+ //Searching the right insertion point
+ for (Infos_Pos=0; Infos_Pos<Infos.size(); Infos_Pos++)
+ if (Info.StreamOffset<Infos[Infos_Pos].StreamOffset)
+ break;
+ }
+
+ //Testing if new data is same as current insertion point
+ if (Infos_Pos && Infos[Infos_Pos-1].FrameNumber==Info.FrameNumber && Info.FrameNumber!=(int64u)-1)
+ {
+ IsSynchronized=true;
+ return;
+ }
+ if (Infos_Pos && Info.Dts==Infos[Infos_Pos-1].Dts && Info.Dts!=(int64u)-1)
+ {
+ //Duplicate, updating it (in case of new frame count)
+ if (Infos_Pos && Info.FrameNumber!=(int64u)-1)
+ Infos[Infos_Pos-1].FrameNumber=Info.FrameNumber;
+
+ IsSynchronized=true;
+ return;
+ }
+ if (Infos_Pos && Info.StreamOffset==Infos[Infos_Pos-1].StreamOffset)
+ {
+ //Duplicate, updating it (in case of new frame count)
+ if (Infos_Pos && Info.FrameNumber!=(int64u)-1)
+ Infos[Infos_Pos-1].FrameNumber=Info.FrameNumber;
+
+ IsSynchronized=true;
+ return;
+ }
+
+ //Previous item
+ if (IsSynchronized && Infos_Pos)
+ {
+ Infos[Infos_Pos-1].IsContinuous=true;
+ IsContinuous=true;
+
+ IsModified=true;
+ }
+ IsSynchronized=true;
+
+ //Testing if new data is same as next insertion point
+ if (Infos_Pos<Infos.size() && Infos[Infos_Pos].FrameNumber==Info.FrameNumber && Info.FrameNumber!=(int64u)-1)
+ {
+ Infos_Pos++;
+
+ IsSynchronized=true;
+ return;
+ }
+ if (Infos_Pos<Infos.size() && Info.Dts==Infos[Infos_Pos].Dts && Info.Dts!=(int64u)-1)
+ {
+ Infos_Pos++;
+
+ IsSynchronized=true;
+ return;
+ }
+ if (Infos_Pos<Infos.size() && Info.StreamOffset==Infos[Infos_Pos].StreamOffset)
+ {
+ //Duplicate, updating it (in case of new frame count)
+ if (IsSynchronized && Info.FrameNumber!=(int64u)-1)
+ Infos[Infos_Pos].FrameNumber=Info.FrameNumber;
+
+ Infos_Pos++;
+
+ IsSynchronized=true;
+ return;
+ }
+
+ Infos.insert(Infos.begin()+Infos_Pos, Info);
+ Infos_Pos++;
+
+ IsModified=true;
+}
+
+//---------------------------------------------------------------------------
+void ibi::stream::Unsynch ()
+{
+ Infos_Pos=0;
+ IsModified=false;
+ IsContinuous=false;
+ IsSynchronized=false;
+}
+
+//***************************************************************************
+// Utils
+//***************************************************************************
+
+size_t int64u2Ebml(int8u* List, int64u Value)
+{
+ //1 byte
+ if (Value<=126) //2^7-2
+ {
+ if (List)
+ {
+ List[0]=0x80|((int8u)Value);
+ }
+ return 1;
+ }
+
+ //2 bytes
+ if (Value<=16382) //2^14-2
+ {
+ if (List)
+ {
+ List[0]=0x40|((int8u)(Value>>8));
+ List[1]=(int8u)Value;
+ }
+ return 2;
+ }
+
+ //3 bytes
+ if (Value<=2097150) //2^21-2
+ {
+ if (List)
+ {
+ List[0]=0x20|((int8u)(Value>>16));
+ List[1]=(int8u)(Value>>8);
+ List[2]=(int8u)Value;
+ }
+ return 3;
+ }
+
+ //4 bytes
+ if (Value<=268435454) //2^28-2
+ {
+ if (List)
+ {
+ List[0]=0x10|((int8u)(Value>>24));
+ List[1]=(int8u)(Value>>16);
+ List[2]=(int8u)(Value>>8);
+ List[3]=(int8u)Value;
+ }
+ return 4;
+ }
+
+ //5 bytes
+ if (Value<=34359738366LL) //2^35-2
+ {
+ if (List)
+ {
+ List[0]=0x08|((int8u)(Value>>32));
+ List[1]=(int8u)(Value>>24);
+ List[2]=(int8u)(Value>>16);
+ List[3]=(int8u)(Value>>8);
+ List[4]=(int8u)Value;
+ }
+ return 5;
+ }
+
+ //6 bytes
+ if (Value<=4398046511102LL) //2^42-2
+ {
+ if (List)
+ {
+ List[0]=0x04|((int8u)(Value>>40));
+ List[1]=(int8u)(Value>>32);
+ List[2]=(int8u)(Value>>24);
+ List[3]=(int8u)(Value>>16);
+ List[4]=(int8u)(Value>>8);
+ List[5]=(int8u)Value;
+ }
+ return 6;
+ }
+
+ //7 bytes
+ if (Value<=562949953421310LL) //2^49-2
+ {
+ if (List)
+ {
+ List[0]=0x02|((int8u)(Value>>48));
+ List[1]=(int8u)(Value>>40);
+ List[2]=(int8u)(Value>>32);
+ List[3]=(int8u)(Value>>24);
+ List[4]=(int8u)(Value>>16);
+ List[5]=(int8u)(Value>>8);
+ List[6]=(int8u)Value;
+ }
+ return 7;
+ }
+
+ //8 bytes
+ if (Value<=72057594037927934LL) //2^56-2
+ {
+ if (List)
+ {
+ List[0]=0x01;
+ List[1]=(int8u)(Value>>56);
+ List[2]=(int8u)(Value>>40);
+ List[3]=(int8u)(Value>>32);
+ List[4]=(int8u)(Value>>24);
+ List[5]=(int8u)(Value>>16);
+ List[6]=(int8u)(Value>>8);
+ List[7]=(int8u)Value;
+ }
+ return 8;
+ }
+
+ if (List)
+ List[0]=0xFF;
+ return 1;
+}
+
+size_t EbmlBlock(int8u* List, size_t List_MaxSize, int64u Code, int8u* Content, size_t Content_Size)
+{
+ if (Content_Size==0)
+ return 0;
+
+ size_t Code_EbmlSize=int64u2Ebml(NULL, Code);
+ size_t Content_EbmlSize=int64u2Ebml(NULL, Content_Size);
+
+ if (List && Code_EbmlSize+Content_EbmlSize+Content_Size>List_MaxSize)
+ return 0;
+
+ if (List)
+ {
+ List+=int64u2Ebml(List, Code);
+ List+=int64u2Ebml(List, Content_Size);
+ std::memcpy(List, Content, Content_Size); List+=Content_Size;//Content
+ }
+
+ return Code_EbmlSize+Content_EbmlSize+Content_Size;
+}
+
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Ibi_Creation::File_Ibi_Creation()
+{
+}
+
+//---------------------------------------------------------------------------
+File_Ibi_Creation::~File_Ibi_Creation()
+{
+ for (size_t Pos=0; Pos<Buffers.size(); Pos++)
+ delete Buffers[Pos];
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ibi_Creation::Set(const ibi &Ibi)
+{
+ for (ibi::streams::const_iterator IbiStream_Temp=Ibi.Streams.begin(); IbiStream_Temp!=Ibi.Streams.end(); IbiStream_Temp++)
+ Add(IbiStream_Temp->first, *IbiStream_Temp->second);
+}
+
+//---------------------------------------------------------------------------
+void File_Ibi_Creation::Add(int64u ID, const ibi::stream &Stream)
+{
+ //Useful?
+ if (Stream.Infos.empty())
+ return;
+
+ //Header
+ int8u* IbiHeader;
+ size_t IbiHeader_Offset=0;
+ if (ID!=(int64u)-1)
+ {
+ IbiHeader=new int8u[int64u2Ebml(NULL, ID)];
+ IbiHeader_Offset+=int64u2Ebml(IbiHeader, ID);
+ }
+ else
+ IbiHeader=NULL;
+
+ //Init - Byte Offset
+ int8u* IbiByteOffset=new int8u[8*Stream.Infos.size()];
+ size_t IbiByteOffset_Offset=0;
+
+ //Init - Frame Number
+ int8u* IbiFrameNumber=new int8u[8*Stream.Infos.size()];
+ size_t IbiFrameNumber_Offset=0;
+
+ //Init - DTS
+ int8u* IbiDts=new int8u[8*Stream.Infos.size()];
+ size_t IbiDts_Offset=0;
+ IbiDts_Offset+=int64u2Ebml(IbiDts+IbiDts_Offset, Stream.DtsFrequencyNumerator);
+ IbiDts_Offset+=int64u2Ebml(IbiDts+IbiDts_Offset, Stream.DtsFrequencyDenominator);
+
+ //Per item
+ for (size_t Pos=0; Pos<Stream.Infos.size(); Pos++)
+ {
+ IbiByteOffset_Offset+=int64u2Ebml(IbiByteOffset+IbiByteOffset_Offset, Stream.Infos[Pos].StreamOffset-(Pos?Stream.Infos[Pos-1].StreamOffset:0));
+ IbiFrameNumber_Offset+=int64u2Ebml(IbiFrameNumber+IbiFrameNumber_Offset, Stream.Infos[Pos].FrameNumber-(Pos?Stream.Infos[Pos-1].FrameNumber:0));
+ IbiDts_Offset+=int64u2Ebml(IbiDts+IbiDts_Offset, Stream.Infos[Pos].Dts-(Pos?Stream.Infos[Pos-1].Dts:0));
+ }
+
+ //Sizes
+ size_t IbiHeader_EbmlSize=EbmlBlock(NULL, 0, 0x01, NULL, IbiHeader_Offset);
+ size_t IbiByteOffset_EbmlSize=EbmlBlock(NULL, 0, 0x02, NULL, IbiByteOffset_Offset);
+ size_t IbiFrameNumber_EbmlSize=EbmlBlock(NULL, 0, 0x03, NULL, IbiFrameNumber_Offset);
+ size_t IbiDts_EbmlSize=EbmlBlock(NULL, 0, 0x04, NULL, IbiDts_Offset);
+
+ //Buffer
+ buffer* Buffer=new buffer;
+ Buffer->Content=new int8u[1+int64u2Ebml(NULL, IbiHeader_EbmlSize+IbiByteOffset_EbmlSize+IbiFrameNumber_EbmlSize+IbiDts_EbmlSize)+IbiHeader_EbmlSize+IbiByteOffset_EbmlSize+IbiFrameNumber_EbmlSize+IbiDts_EbmlSize];
+ Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, 0x01); //Stream
+ Buffer->Size+=int64u2Ebml(Buffer->Content+Buffer->Size, IbiHeader_EbmlSize+IbiByteOffset_EbmlSize+IbiFrameNumber_EbmlSize+IbiDts_EbmlSize); //Size
+ Buffer->Size+=EbmlBlock(Buffer->Content+Buffer->Size, IbiHeader_EbmlSize, 0x01, IbiHeader, IbiHeader_Offset); //IbiHeader
+ Buffer->Size+=EbmlBlock(Buffer->Content+Buffer->Size, IbiByteOffset_EbmlSize, 0x02, IbiByteOffset, IbiByteOffset_Offset); //ByteOffset
+ Buffer->Size+=EbmlBlock(Buffer->Content+Buffer->Size, IbiFrameNumber_EbmlSize, 0x03, IbiFrameNumber, IbiFrameNumber_Offset); //FrameNumber
+ Buffer->Size+=EbmlBlock(Buffer->Content+Buffer->Size, IbiDts_EbmlSize, 0x04, IbiDts, IbiDts_Offset); //Dts
+
+ Buffers.push_back(Buffer);
+}
+
+Ztring File_Ibi_Creation::Finish()
+{
+ //Test
+ if (Buffers.empty())
+ return Ztring();
+
+ //Size computing
+ size_t Size=4+1+2+1+15+2+1+1; //Header size
+ for (size_t Pos=0; Pos<Buffers.size(); Pos++)
+ Size+=Buffers[Pos]->Size;
+
+ //Buffer creation
+ int8u* Main=new int8u[Size];
+ size_t Main_Offset=0;
+
+ //Header
+ Main_Offset+=int64u2Ebml(Main+Main_Offset, 0x0A45DFA3); //EBML
+ Main_Offset+=int64u2Ebml(Main+Main_Offset, 2+1+15+2+1+1); //Size (Code + Size + Content, twice)
+ Main_Offset+=int64u2Ebml(Main+Main_Offset, 0x0282); //DocType
+ Main_Offset+=int64u2Ebml(Main+Main_Offset, 15); //Size
+ std::memcpy(Main+Main_Offset, "MediaInfo Index", 15); Main_Offset+=15; //Content
+ Main_Offset+=int64u2Ebml(Main+Main_Offset, 0x0285); //DocTypeReadVersion
+ Main_Offset+=int64u2Ebml(Main+Main_Offset, 1); //Size
+ Main[Main_Offset]=0x01; Main_Offset+=1; //Content
+
+ //for each stream
+ for (size_t Pos=0; Pos<Buffers.size(); Pos++)
+ {
+ std::memcpy(Main+Main_Offset, Buffers[Pos]->Content, Buffers[Pos]->Size);
+ Main_Offset+=Buffers[Pos]->Size;
+ }
+
+
+
+ //Compressed
+ buffer Buffer;
+ int8u* Compressed=new int8u[Main_Offset];
+ unsigned long Compressed_OffsetWihtoutHeader=(unsigned long)Main_Offset;
+ if (compress2(Compressed, &Compressed_OffsetWihtoutHeader, Main, (unsigned long)Main_Offset, Z_BEST_COMPRESSION)==Z_OK && Compressed_OffsetWihtoutHeader+100<Main_Offset)
+ {
+ size_t Header_Offset=4+1+2+1+15+2+1+1; //Same header
+ Header_Offset+=int64u2Ebml(Main+Header_Offset, 0x02); //Compressed index
+ Header_Offset+=int64u2Ebml(Main+Header_Offset, int64u2Ebml(NULL, Main_Offset)+Compressed_OffsetWihtoutHeader); //Size
+ Header_Offset+=int64u2Ebml(Main+Header_Offset, Main_Offset); //Uncompressed size
+
+ //Filling
+ Buffer.Size=Header_Offset+Compressed_OffsetWihtoutHeader;
+ Buffer.Content=new int8u[Buffer.Size];
+ std::memcpy(Buffer.Content, Main, Header_Offset); //Same header + Compressed index header
+ std::memcpy(Buffer.Content+Header_Offset, Compressed, Compressed_OffsetWihtoutHeader); //Same header
+ }
+ else
+ {
+ //Filling
+ Buffer.Size=Main_Offset;
+ Buffer.Content=new int8u[Buffer.Size];
+ std::memcpy(Buffer.Content, Main, Main_Offset);
+ }
+
+ std::string Data_Raw((const char*)Buffer.Content, Buffer.Size);
+ std::string Data_Base64(Base64::encode(Data_Raw));
+
+ return Ztring().From_UTF8(Data_Base64);
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_IBI_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi_Creation.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi_Creation.h
new file mode 100644
index 000000000..732db8923
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ibi_Creation.h
@@ -0,0 +1,129 @@
+// File_Ibi_Creation - Creation of Ibi files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Ibi files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Ibi_CreationH
+#define MediaInfo_File_Ibi_CreationH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Ztring.h"
+#include <map>
+#include <vector>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Ibi structure
+//***************************************************************************
+
+struct ibi
+{
+ struct stream
+ {
+ int64u DtsFrequencyNumerator;
+ int64u DtsFrequencyDenominator;
+ struct info
+ {
+ int64u StreamOffset;
+ int64u FrameNumber;
+ int64u Dts;
+ bool IsContinuous;
+
+ info()
+ {
+ StreamOffset=(int64u)-1;
+ FrameNumber=(int64u)-1;
+ Dts=(int64u)-1;
+ IsContinuous=false;
+ }
+ };
+ std::vector<info> Infos;
+ size_t Infos_Pos;
+ bool IsContinuous;
+ bool IsModified;
+ bool IsSynchronized;
+
+ stream()
+ {
+ DtsFrequencyNumerator=1000000000; //nanosecond
+ DtsFrequencyDenominator=1;
+ Infos_Pos=0;
+ IsContinuous=false;
+ IsModified=false;
+ IsSynchronized=false;
+ }
+
+ void Add (const info &Info);
+ void Unsynch();
+ };
+ typedef std::map<int64u, stream*> streams;
+ streams Streams;
+
+ //Constructor/Destructor
+ ibi();
+ ~ibi();
+};
+
+//***************************************************************************
+// File_Ibi_Creation class
+//***************************************************************************
+
+class File_Ibi_Creation
+{
+public :
+ File_Ibi_Creation();
+ File_Ibi_Creation(const ibi &Ibi) {Set(Ibi);}
+ ~File_Ibi_Creation();
+
+ void Set(const ibi &Ibi);
+ void Add(int64u ID, const ibi::stream &Stream);
+ Ztring Finish();
+
+private :
+ struct buffer
+ {
+ int8u* Content;
+ size_t Size;
+
+ buffer()
+ {
+ Content=NULL;
+ Size=0;
+ }
+
+ ~buffer()
+ {
+ delete[] Content; //Content=NULL;
+ }
+ };
+ std::vector<buffer*> Buffers;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ism.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ism.cpp
new file mode 100644
index 000000000..b6eb53018
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ism.cpp
@@ -0,0 +1,202 @@
+// File_Ism - Info for ISM files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_ISM_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Ism.h"
+#include <set>
+#include "MediaInfo/MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/Multiple/File__ReferenceFilesHelper.h"
+#include "ZenLib/Dir.h"
+#include "ZenLib/FileName.h"
+#include "ZenLib/Format/Http/Http_Utils.h"
+#include "tinyxml2.h"
+using namespace tinyxml2;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Ism::File_Ism()
+:File__Analyze()
+{
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Ism;
+ StreamIDs_Width[0]=sizeof(size_t)*2;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_EventWasSent_Accept_Specific=true;
+ #endif //MEDIAINFO_DEMUX
+
+ //Temp
+ ReferenceFiles=NULL;
+}
+
+//---------------------------------------------------------------------------
+File_Ism::~File_Ism()
+{
+ delete ReferenceFiles; //ReferenceFiles=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ism::Streams_Finish()
+{
+ if (ReferenceFiles==NULL)
+ return;
+
+ ReferenceFiles->ParseReferences();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_Ism::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ if (ReferenceFiles==NULL)
+ return 0;
+
+ return ReferenceFiles->Read_Buffer_Seek(Method, Value, ID);
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Ism::FileHeader_Begin()
+{
+ XMLDocument document;
+ if (!FileHeader_Begin_XML(document))
+ return false;
+
+ {
+ XMLElement* Root=document.FirstChildElement("smil");
+ if (Root)
+ {
+ Accept("ISM");
+ Fill(Stream_General, 0, General_Format, "ISM");
+
+ ReferenceFiles=new File__ReferenceFilesHelper(this, Config);
+
+ std::set<Ztring> FileNames;
+
+ XMLElement* Body=Root->FirstChildElement();
+ while (Body)
+ {
+ if (string(Body->Value())=="body")
+ {
+ XMLElement* Switch=Body->FirstChildElement();
+ while (Switch)
+ {
+ if (string(Switch->Value())=="switch")
+ {
+ XMLElement* Stream=Switch->FirstChildElement();
+ while (Stream)
+ {
+ if (string(Stream->Value())=="video" || string(Stream->Value())=="audio")
+ {
+ File__ReferenceFilesHelper::reference ReferenceFile;
+
+ if (string(Stream->Value())=="video")
+ ReferenceFile.StreamKind=Stream_Video;
+ if (string(Stream->Value())=="audio")
+ ReferenceFile.StreamKind=Stream_Audio;
+
+ const char* Attribute=Stream->Attribute("src");
+ if (Attribute)
+ ReferenceFile.FileNames.push_back(Ztring().From_UTF8(Attribute));
+
+ XMLElement* Param=Stream->FirstChildElement();
+ while (Param)
+ {
+ if (string(Param->Value())=="param")
+ {
+ Attribute=Param->Attribute("name");
+ if (Attribute && Ztring().From_UTF8(Attribute)==_T("trackID"))
+ {
+ Attribute=Param->Attribute("value");
+ if (Attribute)
+ ReferenceFile.StreamID=Ztring().From_UTF8(Attribute).To_int64u();
+ }
+ }
+ Param=Param->NextSiblingElement();
+ }
+
+ if (!ReferenceFile.FileNames.empty() && !ReferenceFile.FileNames[0].empty() && FileNames.find(ReferenceFile.FileNames[0])==FileNames.end())
+ {
+ ReferenceFiles->References.push_back(ReferenceFile);
+ FileNames.insert(ReferenceFile.FileNames[0]);
+ }
+ }
+
+ Stream=Stream->NextSiblingElement();
+ }
+ }
+
+ Switch=Switch->NextSiblingElement();
+ }
+ }
+
+ Body=Body->NextSiblingElement();
+ }
+ }
+ else
+ {
+ Reject("ISM");
+ return false;
+ }
+ }
+
+ //All should be OK...
+ return true;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_ISM_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ism.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ism.h
new file mode 100644
index 000000000..f2a478663
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ism.h
@@ -0,0 +1,68 @@
+// File_Ism - Info for DXW files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about DXW files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_IsmH
+#define MediaInfo_File_IsmH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class File__ReferenceFilesHelper;
+
+//***************************************************************************
+// Class File_Ism
+//***************************************************************************
+
+class File_Ism : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Ism();
+ ~File_Ism();
+
+private :
+ //Streams management
+ void Streams_Finish ();
+
+ //Buffer - Global
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Temp
+ File__ReferenceFilesHelper* ReferenceFiles;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ivf.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ivf.cpp
new file mode 100644
index 000000000..b3c586903
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ivf.cpp
@@ -0,0 +1,134 @@
+// File_Ivf - Info for Ivf files
+// Copyright (C) 2010-2011 Lionel Duchateau, kurtnoise@free.fr
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// From : http://www.webmproject.org/
+// Specs: http://wiki.multimedia.cx/index.php?title=IVF
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_IVF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Ivf.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Ivf::FileHeader_Begin()
+{
+ //Synchro
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ if (CC4(Buffer+Buffer_Offset)!=0x444B4946) //"DKIF"
+ return false;
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Ivf::FileHeader_Parse()
+{
+ //Parsing
+ int32u frame_rate_num, frame_rate_den, frame_count, fourcc;
+ int16u version, header_size, width, height;
+
+ Skip_C4 ( "Signature");
+ Get_L2 (version, "Version");
+ if (version==0)
+ {
+ Get_L2 (header_size, "Header Size");
+ if (header_size>=32)
+ {
+ Get_C4 (fourcc, "Fourcc");
+ Get_L2 (width, "Width");
+ Get_L2 (height, "Height");
+ Get_L4 (frame_rate_num, "FrameRate Numerator");
+ Get_L4 (frame_rate_den, "FrameRate Denominator");
+ Get_L4 (frame_count, "Frame Count");
+ Skip_L4( "Unused");
+ if (header_size-32)
+ Skip_XX(header_size-32, "Unknown");
+ }
+ else
+ {
+ fourcc=0x00000000;
+ width=0;
+ height=0;
+ frame_rate_num=0;
+ frame_rate_den=0;
+ frame_count=0;
+ }
+ }
+ else
+ {
+ header_size=0;
+ fourcc=0x00000000;
+ width=0;
+ height=0;
+ frame_rate_num=0;
+ frame_rate_den=0;
+ frame_count=0;
+ }
+
+ FILLING_BEGIN();
+ Accept("IVF");
+
+ Fill(Stream_General, 0, General_Format, "IVF");
+
+ if (version==0 && header_size>=32)
+ {
+ Stream_Prepare(Stream_Video);
+ CodecID_Fill(Ztring().From_CC4(fourcc), Stream_Video, 0, InfoCodecID_Format_Riff);
+ Fill(Stream_Video, 0, Video_FrameRate, (float)frame_rate_num / frame_rate_den);
+ Fill(Stream_Video, 0, Video_FrameCount, frame_count);
+ Fill(Stream_Video, 0, Video_Width, width);
+ Fill(Stream_Video, 0, Video_Height, height);
+ Fill(Stream_Video, 0, Video_StreamSize, File_Size-header_size-12*frame_count); //Overhead is 12 byte per frame
+ }
+
+ //No more need data
+ Finish("IVF");
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_IVF_*
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ivf.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ivf.h
new file mode 100644
index 000000000..0a98b6cb0
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ivf.h
@@ -0,0 +1,55 @@
+// File_Ivf - Info for Ivf files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+// Copyright (C) 2010 Lionel DUCHATEAU, kurtnoise at free dot fr
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about IVF files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_IvfH
+#define MediaInfo_IvfH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Ivf
+//***************************************************************************
+
+class File_Ivf : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+private :
+ //Buffer
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Lxf.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Lxf.cpp
new file mode 100644
index 000000000..e5b0ed0e2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Lxf.cpp
@@ -0,0 +1,1312 @@
+// File_Lxf - Info for LXF files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_LXF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Lxf.h"
+#if defined(MEDIAINFO_DVDIF_YES)
+ #include "MediaInfo/Multiple/File_DvDif.h"
+#endif
+#if defined(MEDIAINFO_AVC_YES)
+ #include "MediaInfo/Video/File_Avc.h"
+#endif
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_ANCILLARY_YES)
+ #include "MediaInfo/Multiple/File_Ancillary.h"
+#endif //defined(MEDIAINFO_ANCILLARY_YES)
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include <bitset>
+#include <MediaInfo/MediaInfo_Internal.h>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+const char* Lxf_Format_Video[16]=
+{
+ "JPEG",
+ "MPEG Video", //Version 1
+ "MPEG Video", //Version 2, 4:2:0
+ "MPEG Video", //Version 2, 4:2:2
+ "DV", //25 Mbps 4:1:1 or 4:2:0
+ "DV", //DVCPRO
+ "DV", //DVCPRO 50 / HD
+ "RGB", //RGB uncompressed
+ "Gray", //Gray uncompressed
+ "MPEG Video", //Version 2, 4:2:2, GOP=9
+ "AVC",
+ "AVC",
+ "AVC",
+ "AVC",
+ "",
+ "",
+};
+
+const char* Lxf_PictureType[4]=
+{
+ "I", //Closed
+ "I", //Open
+ "P",
+ "B",
+};
+
+extern const float32 Mpegv_frame_rate[]; //In Video/File_Mpegv.cpp
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Lxf::File_Lxf()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("LXF");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Lxf;
+ StreamIDs_Width[0]=4; //2 numbers for Code, 2 numbers for subcode
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ #endif //MEDIAINFO_DEMUX
+ MustSynchronize=true;
+ Buffer_TotalBytes_Fill_Max=(int64u)-1; //Disabling this feature for this format, this is done in the parser
+ #if MEDIAINFO_DEMUX
+ Demux_EventWasSent_Accept_Specific=true;
+ #endif //MEDIAINFO_DEMUX
+
+ //Temp
+ LookingForLastFrame=false;
+ Stream_Count=0;
+ Info_General_StreamSize=0;
+ Video_Sizes_Pos=(size_t)-1;
+ Audio_Sizes_Pos=(size_t)-1;
+
+ //Seek
+ #if MEDIAINFO_SEEK
+ SeekRequest=(int64u)-1;
+ #endif //MEDIAINFO_SEEK
+ FrameRate=0;
+ TimeStamp_Rate=720000;
+ Duration_Detected=false;
+ LastAudio_BufferOffset=(int64u)-1;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Lxf::Streams_Fill()
+{
+ Fill(Stream_General, 0, General_Format_Version, _T("Version "+Ztring::ToZtring(Version)));
+
+ for (size_t Pos=0; Pos<Videos.size(); Pos++)
+ Streams_Fill_PerStream(Videos[Pos].Parser, 1, Pos);
+ for (size_t Pos=0; Pos<Audios.size(); Pos++)
+ Streams_Fill_PerStream(Audios[Pos].Parser, 2, Pos);
+
+ if (!Videos.empty())
+ Fill(Stream_Video, 0, Video_CodecID, VideoFormat);
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Streams_Fill_PerStream(File__Analyze* Parser, size_t Container_StreamKind, size_t Parser_Pos)
+{
+ if (Parser==NULL)
+ return;
+
+ Fill(Parser);
+ if (Parser->Count_Get(Stream_Audio) && Config->File_Audio_MergeMonoStreams_Get())
+ {
+ if (Count_Get(Stream_Audio)==0)
+ {
+ Merge(*Parser);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, Audio_Sizes.size(), 10, true);
+ int64u BitRate=Retrieve(Stream_Audio, 0, Audio_BitRate).To_int64u();
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate*Audio_Sizes.size(), 10, true);
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_ForceIds_Get())
+ {
+ for (size_t Audio_Pos=0; Audio_Pos<Audio_Sizes.size(); Audio_Pos++)
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, 0x200+Audio_Pos);
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+ }
+ else
+ {
+ Merge(*Parser);
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_ForceIds_Get())
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Parser->Count_Get((stream_t)StreamKind); StreamPos++)
+ {
+ Ztring ID=Ztring::ToZtring(0x100*Container_StreamKind+Parser_Pos);
+ if (!Parser->Retrieve((stream_t)StreamKind, StreamPos, General_ID).empty())
+ ID+=_T('-')+Parser->Retrieve((stream_t)StreamKind, StreamPos, General_ID);
+ Fill((stream_t)StreamKind, Count_Get((stream_t)StreamKind)-Parser->Count_Get((stream_t)StreamKind)+StreamPos, General_ID, ID, true);
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Streams_Finish()
+{
+ if (Videos[1].Parser && Count_Get(Stream_Text)==0) //TODO: better handling of fill/finish
+ {
+ Finish(Videos[1].Parser);
+ Streams_Fill_PerStream(Videos[1].Parser, Stream_Video, 1);
+ }
+
+ if (Audios_Header.TimeStamp_End!=(int64u)-1 && Audios_Header.TimeStamp_Begin!=(int64u)-1)
+ {
+ int64u Duration=float64_int64s(((float64)(Audios_Header.TimeStamp_End-Audios_Header.TimeStamp_Begin))/TimeStamp_Rate*1000);
+ int64u FrameCount=float64_int64s(((float64)(Audios_Header.TimeStamp_End-Audios_Header.TimeStamp_Begin))/Audios_Header.Duration);
+ for (size_t Pos=0; Pos<Count_Get(Stream_Audio); Pos++)
+ {
+ Fill(Stream_Audio, Pos, Audio_Duration, Duration);
+ Fill(Stream_Audio, Pos, Audio_FrameCount, FrameCount);
+ }
+ Info_General_StreamSize+=FrameCount*0x48;
+ }
+ if (Videos_Header.TimeStamp_End!=(int64u)-1 && Videos_Header.TimeStamp_Begin!=(int64u)-1)
+ {
+ int64u Duration=float64_int64s(((float64)(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin))/TimeStamp_Rate*1000);
+ int64u FrameCount=float64_int64s(((float64)(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin))/Videos_Header.Duration);
+ if (Duration)
+ for (size_t Pos=0; Pos<Count_Get(Stream_Video); Pos++)
+ Fill(Stream_Video, Pos, Video_Duration, Duration, 10, true);
+ Info_General_StreamSize+=FrameCount*0x48;
+
+ if (Count_Get(Stream_Video)==1 && Retrieve(Stream_Video, 0, Video_BitRate).empty())
+ {
+ for (size_t Pos=0; Pos<Videos.size(); Pos++)
+ if (Videos[Pos].BytesPerFrame!=(int64u)-1)
+ Info_General_StreamSize+=Videos[Pos].BytesPerFrame*FrameCount;
+ for (size_t Pos=0; Pos<Audios.size(); Pos++)
+ if (Audios[Pos].BytesPerFrame!=(int64u)-1)
+ Info_General_StreamSize+=Audios[Pos].BytesPerFrame*Retrieve(Stream_Audio, Pos, Audio_FrameCount).To_int64u();
+ Fill(Stream_General, 0, General_StreamSize, Info_General_StreamSize);
+ Fill(Stream_Video, 0, Video_StreamSize, File_Size-Info_General_StreamSize);
+ }
+ }
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Lxf::Synchronize()
+{
+ //Synchronizing
+ while (Buffer_Offset+20<=Buffer_Size && ( Buffer[Buffer_Offset ]!=0x4C
+ || Buffer[Buffer_Offset+ 1]!=0x45
+ || Buffer[Buffer_Offset+ 2]!=0x49
+ || Buffer[Buffer_Offset+ 3]!=0x54
+ || Buffer[Buffer_Offset+ 4]!=0x43
+ || Buffer[Buffer_Offset+ 5]!=0x48
+ || Buffer[Buffer_Offset+ 6]!=0x00
+ || Buffer[Buffer_Offset+ 7]!=0x00
+ #if MEDIAINFO_SEEK
+ || (Buffer[Buffer_Offset+16]!=0x02 && Buffer[Buffer_Offset+16]!=0x00)
+ #endif //MEDIAINFO_SEEK
+ ))
+ {
+ Buffer_Offset+=6+2;
+ while (Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Buffer_Offset+=2;
+ if (Buffer_Offset>=Buffer_Size || Buffer[Buffer_Offset-1]==0x00)
+ Buffer_Offset--;
+ Buffer_Offset-=6;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+20>Buffer_Size)
+ {
+ while (Buffer_Offset+8>Buffer_Size)
+ if (Buffer_Offset+8==Buffer_Size && CC8(Buffer+Buffer_Offset)!=0x4C45495443480000LL)
+ Buffer_Offset++;
+ else
+ break;
+ if (Buffer_Offset+7==Buffer_Size && CC7(Buffer+Buffer_Offset)!=0x4C454954434800LL)
+ Buffer_Offset++;
+ if (Buffer_Offset+6==Buffer_Size && CC6(Buffer+Buffer_Offset)!=0x4C4549544348LL)
+ Buffer_Offset++;
+ if (Buffer_Offset+5==Buffer_Size && CC5(Buffer+Buffer_Offset)!=0x4C45495443LL)
+ Buffer_Offset++;
+ if (Buffer_Offset+4==Buffer_Size && CC4(Buffer+Buffer_Offset)!=0x4C454954)
+ Buffer_Offset++;
+ if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x4C4549)
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x4C45)
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x4C)
+ Buffer_Offset++;
+ return false;
+ }
+
+ if (!Status[IsAccepted])
+ {
+ Accept();
+
+ Fill(Stream_General, 0, General_Format, "LXF");
+
+ File_Buffer_Size_Hint_Pointer=Config->File_Buffer_Size_Hint_Pointer_Get();
+ Buffer_MaximumSize=16*1024*1024;
+ }
+
+ #if MEDIAINFO_SEEK
+ //TimeStamp
+ if (SeekRequest!=(int64u)-1)
+ {
+ if (TimeOffsets.find(File_Offset+Buffer_Offset)==TimeOffsets.end()) //Not already saved
+ {
+ if (Buffer_Offset+0x48>=Buffer_Size)
+ return false;
+ int32u Type =LittleEndian2int32u(Buffer+Buffer_Offset+16);
+ if (Type==0) //Video
+ {
+ //Filling with the new frame
+ Version=LittleEndian2int32u(Buffer+Buffer_Offset+8);
+ int64u TimeStamp, Duration;
+ switch (Version)
+ {
+ case 0 : TimeStamp =LittleEndian2int32u(Buffer+Buffer_Offset+24);
+ Duration =LittleEndian2int32u(Buffer+Buffer_Offset+28);
+ break;
+ case 1 : TimeStamp =LittleEndian2int64u(Buffer+Buffer_Offset+24);
+ Duration =LittleEndian2int64u(Buffer+Buffer_Offset+32);
+ break;
+ default: TimeStamp=Duration=0;
+ }
+ int8u PictureType=(LittleEndian2int8u (Buffer+Buffer_Offset+42)&0xC0)>>6;
+ TimeOffsets[File_Offset+Buffer_Offset]=stream_header(TimeStamp, TimeStamp+Duration, Duration, PictureType);
+ SeekRequest_Divider=2;
+ }
+ }
+ if (Read_Buffer_Seek(2, (int64u)-1, (int64u)-1))
+ return false;
+ }
+ #endif //MEDIAINFO_SEEK
+
+ //Synched is OK
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Lxf::Synched_Test()
+{
+ if (Video_Sizes_Pos<Video_Sizes.size())
+ return true;
+ if (Audio_Sizes_Pos<Audio_Sizes.size())
+ return true;
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+16>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (CC8(Buffer+Buffer_Offset)!=0x4C45495443480000LL)
+ Synched=false;
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Lxf::Read_Buffer_Unsynched()
+{
+ Video_Sizes.clear();
+ Audio_Sizes.clear();
+ LastAudio_BufferOffset=(int64u)-1;
+ LastAudio_TimeOffset=stream_header();
+ Video_Sizes_Pos=(size_t)-1;
+ Audio_Sizes_Pos=(size_t)-1;
+ Videos_Header.TimeStamp_End=(int64u)-1;
+ Audios_Header.TimeStamp_End=(int64u)-1;
+
+ for (size_t Pos=0; Pos<Audios.size(); Pos++)
+ if (Audios[Pos].Parser)
+ Audios[Pos].Parser->Open_Buffer_Unsynch();
+ for (size_t Pos=0; Pos<Videos.size(); Pos++)
+ if (Videos[Pos].Parser)
+ Videos[Pos].Parser->Open_Buffer_Unsynch();
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_Lxf::Read_Buffer_Seek (size_t Method, int64u Value, int64u)
+{
+ //Init
+ if (!Duration_Detected)
+ {
+ MediaInfo_Internal MI;
+ MI.Option(_T("File_KeepInfo"), _T("1"));
+ Ztring ParseSpeed_Save=MI.Option(_T("ParseSpeed_Get"), _T(""));
+ Ztring Demux_Save=MI.Option(_T("Demux_Get"), _T(""));
+ MI.Option(_T("ParseSpeed"), _T("0"));
+ MI.Option(_T("Demux"), Ztring());
+ size_t MiOpenResult=MI.Open(File_Name);
+ MI.Option(_T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
+ MI.Option(_T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
+ if (!MiOpenResult || MI.Get(Stream_General, 0, General_Format)!=_T("LXF"))
+ return 0;
+ for (time_offsets::iterator TimeOffset=((File_Lxf*)MI.Info)->TimeOffsets.begin(); TimeOffset!=((File_Lxf*)MI.Info)->TimeOffsets.end(); TimeOffset++)
+ TimeOffsets[TimeOffset->first]=TimeOffset->second;
+ int64u Duration=float64_int64s(Ztring(MI.Get(Stream_General, 0, _T("Duration"))).To_float64()*TimeStamp_Rate/1000);
+ TimeOffsets[File_Size]=stream_header(Duration, Duration, 0, (int8u)-1);
+ SeekRequest_Divider=2;
+ Duration_Detected=true;
+ }
+
+ //Parsing
+ switch (Method)
+ {
+ case 0 : Open_Buffer_Unsynch(); GoTo(Value); return 1;
+ case 1 : Open_Buffer_Unsynch(); GoTo(File_Size*Value/10000); return 1;
+ case 3 : //Frame
+ {
+ if (FrameRate==0 && Videos_Header.TimeStamp_End!=(int64u)-1 && Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin!=0)
+ FrameRate=TimeStamp_Rate/(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin);
+ if (FrameRate==0)
+ return (size_t)-1; //Not supported
+ float64 TimeStamp=((float64)Value)/FrameRate;
+ Value=float64_int64s(TimeStamp*1000000000); // In nanoseconds
+ }
+ case 2 : //Timestamp
+ {
+ if (Value!=(int64u)-1)
+ {
+ Value=float64_int64s((float64)Value*TimeStamp_Rate/1000000000); //Convert in LXF unit
+ time_offsets::iterator End=TimeOffsets.end();
+ End--;
+ if (Value>=End->second.TimeStamp_End)
+ return 2; //Higher than total size
+ SeekRequest=Value;
+ }
+
+ //Looking if we already have the timestamp
+ int64u SeekRequest_Mini=SeekRequest; if (SeekRequest_Mini>1000000) SeekRequest_Mini-=float64_int64s(TimeStamp_Rate/1000); //-1ms
+ int64u SeekRequest_Maxi=SeekRequest+float64_int64s(TimeStamp_Rate/1000); //+1ms
+ for (time_offsets::iterator TimeOffset=TimeOffsets.begin(); TimeOffset!=TimeOffsets.end(); TimeOffset++)
+ {
+ if (TimeOffset->second.TimeStamp_Begin<=SeekRequest_Maxi && TimeOffset->second.TimeStamp_End>=SeekRequest_Mini) //If it is found in a frame we know
+ {
+ //Looking for the corresponding I-Frame
+ while (TimeOffset->second.PictureType&0x2 && TimeOffset!=TimeOffsets.begin()) //Not an I-Frame (and not fisrt frame)
+ {
+ time_offsets::iterator Previous=TimeOffset;
+ Previous--;
+ if (Previous->second.TimeStamp_End!=TimeOffset->second.TimeStamp_Begin) //Testing if the previous frame is not known.
+ {
+ SeekRequest=TimeOffset->second.TimeStamp_Begin-(float64_int64s(TimeStamp_Rate/1000)+1); //1ms+1, so we are sure to not synch on the current frame again
+ Open_Buffer_Unsynch();
+ GoTo((Previous->first+TimeOffset->first)/2);
+ return 1; //Looking for previous frame
+
+ }
+ TimeOffset=Previous;
+ }
+
+ //We got the right I-Frame
+ if (Value==0)
+ {
+ for (size_t Pos=0; Pos<Videos.size(); Pos++)
+ if (Videos[Pos].Parser)
+ Videos[Pos].Parser->Unsynch_Frame_Count=0;
+ }
+ Open_Buffer_Unsynch();
+ GoTo(TimeOffset->first);
+ SeekRequest=(int64u)-1;
+ return 1;
+ }
+
+ if (TimeOffset->second.TimeStamp_Begin>SeekRequest_Maxi) //Testing if too far
+ {
+ time_offsets::iterator Previous=TimeOffset; Previous--;
+ int64u ReferenceOffset;
+ if (File_Offset+Buffer_Offset==TimeOffset->first && TimeOffset->second.TimeStamp_Begin>SeekRequest) //If current frame is already too far
+ ReferenceOffset=File_Offset+Buffer_Offset;
+ else
+ ReferenceOffset=TimeOffset->first;
+ if (SeekRequest_Divider==0)
+ {
+ SeekRequest=Previous->second.TimeStamp_Begin-(float64_int64s(TimeStamp_Rate/1000)+1); //1ms+1, so we are sure to not synch on the current frame again
+ ReferenceOffset=Previous->first;
+ Previous--;
+ SeekRequest_Divider=2;
+ }
+ Open_Buffer_Unsynch();
+ GoTo(Previous->first+(ReferenceOffset-Previous->first)/SeekRequest_Divider);
+ SeekRequest_Divider*=2;
+ return 1;
+ }
+ }
+ }
+ return 0;
+ default : return (size_t)-1;
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Lxf::Header_Begin()
+{
+ if (Buffer_Offset+16>Buffer_Size)
+ return false;
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Header_Parse()
+{
+ while (Video_Sizes_Pos<Video_Sizes.size() && Video_Sizes[Video_Sizes_Pos]==0)
+ Video_Sizes_Pos++;
+ if (Video_Sizes_Pos<Video_Sizes.size())
+ {
+ //Filling
+ Header_Fill_Code(0x010100+Video_Sizes_Pos, _T("Stream"));
+ Header_Fill_Size(Video_Sizes[Video_Sizes_Pos]);
+ Video_Sizes_Pos++;
+ return;
+ }
+ while (Audio_Sizes_Pos<Audio_Sizes.size() && Audio_Sizes[Audio_Sizes_Pos]==0)
+ Audio_Sizes_Pos++;
+ if (Audio_Sizes_Pos<Audio_Sizes.size())
+ {
+ //Filling
+ Header_Fill_Code(0x010200+Audio_Sizes_Pos, _T("Stream"));
+ Header_Fill_Size(Audio_Sizes[Audio_Sizes_Pos]);
+ Audio_Sizes_Pos++;
+ return;
+ }
+
+ //Parsing
+ int64u BlockSize=0, TimeStamp=0, Duration=0;
+ int32u HeaderSize, Type;
+ Skip_C8( "Signature");
+ Get_L4 (Version, "Version"); //0=start and duration are in field, 1=in 27 MHz values
+ Get_L4 (HeaderSize, "Header size");
+ if (Element_Size<HeaderSize)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ if (Version>1)
+ {
+ //Filling
+ Header_Fill_Code(0, "Unknown");
+ Header_Fill_Size(HeaderSize);
+ Synched=false;
+ return;
+ }
+ Get_L4 (Type, "Type");
+ Skip_L4( "Stream ID");
+ switch (Version)
+ {
+ case 0 :
+ {
+ int32u TimeStamp4, Duration4;
+ Get_L4 (TimeStamp4, "TimeStamp");
+ TimeStamp=TimeStamp4;
+ Param_Info3(((float64)TimeStamp4)/TimeStamp_Rate, 3, " s");
+ FrameInfo.DTS=float64_int64s(((float64)TimeStamp)*1000000000/TimeStamp_Rate);
+ Get_L4 (Duration4, "Duration");
+ Duration=Duration4;
+ Param_Info3(((float64)Duration)/TimeStamp_Rate, 3, " s");
+ FrameInfo.DUR=float64_int64s(((float64)Duration)*1000000000/TimeStamp_Rate);
+ }
+ break;
+ case 1 :
+ Get_L8 (TimeStamp, "TimeStamp"); Param_Info3(((float64)TimeStamp)/720000, 3, " s"); FrameInfo.DTS=float64_int64s(((float64)TimeStamp)*1000000/720);
+ Get_L8 (Duration, "Duration"); Param_Info3(((float64)Duration)/720000, 3, " s"); FrameInfo.DUR=float64_int64s(((float64)Duration)*1000000/720);
+ break;
+ default: ;
+ }
+ switch(Type)
+ {
+ case 0 : //Video
+ {
+ Video_Sizes.resize(3);
+ int32u Size;
+ int8u GOP_M, PictureType;
+ BS_Begin_LE();
+ Get_T1 (4, VideoFormat, "Format"); Param_Info1(Lxf_Format_Video[VideoFormat]);
+ Skip_T1(7, "GOP (N)");
+ Get_T1 (3, GOP_M, "GOP (M)");
+ Info_T1(8, BitRate, "Bit rate"); Param_Info2(BitRate*1000000, " bps");
+ Get_T1 (2, PictureType, "Picture type"); Param_Info1(Lxf_PictureType[PictureType]);
+ BS_End_LE();
+ Skip_L1( "Reserved");
+ Get_L4(Size, "Video data size");
+ Skip_L4( "Zero");
+ Video_Sizes[2]=Size;
+ BlockSize+=Size;
+ Get_L4(Size, "VBI data size");
+ Video_Sizes[1]=Size;
+ BlockSize+=Size;
+ Skip_L4( "Zero");
+ Get_L4(Size, "Meta data size");
+ Video_Sizes[0]=Size;
+ BlockSize+=Size;
+ if (Videos_Header.TimeStamp_Begin==(int64u)-1)
+ Videos_Header.TimeStamp_Begin=TimeStamp;
+ Videos_Header.TimeStamp_End=TimeStamp+Duration;
+ Videos_Header.Duration=Duration;
+ if (TimeStamp==LastAudio_TimeOffset.TimeStamp_Begin)
+ TimeOffsets[LastAudio_BufferOffset]=stream_header(TimeStamp, TimeStamp+Duration, Duration, PictureType);
+ else
+ TimeOffsets[File_Offset+Buffer_Offset]=stream_header(TimeStamp, TimeStamp+Duration, Duration, PictureType);
+ int64u PTS_Computing=TimeStamp;
+ #if MEDIAINFO_DEMUX
+ switch (PictureType)
+ {
+ case 2 :
+ case 3 : Demux_random_access=false; break; //P-Frame, B-Frame
+ default: Demux_random_access=true ; //I-Frame
+ }
+ #endif //MEDIAINFO_DEMUX
+ if (GOP_M>1) //With B-frames
+ {
+ switch (PictureType)
+ {
+ case 2 : PTS_Computing+=GOP_M*Duration; break; //P-Frame
+ case 3 : break; //B-Frame
+ default: PTS_Computing+=Duration; //I-Frame
+ }
+ }
+ FrameInfo.PTS=float64_int64s(((float64)PTS_Computing)*1000000000/TimeStamp_Rate);
+ }
+ break;
+ case 1 : //Audio
+ {
+ int32u Size;
+ int8u Channels_Count=0;
+ bitset<32> Channels;
+
+ if (Version==0)
+ {
+ Skip_L4( "First Active Field");
+ Skip_L4( "Total fields in packet");
+ }
+ BS_Begin_LE();
+ Get_T1 ( 6, SampleSize, "Sample size");
+ Skip_T1( 6, "Sample precision");
+ Skip_T1(20, "Reserved");
+ BS_End_LE();
+ Element_Begin1("Tracks mask");
+ BS_Begin_LE();
+ for (size_t Pos=0; Pos<32; Pos++)
+ {
+ bool Channel;
+ Get_TB(Channel, "Channel");
+ Channels[Pos]=Channel;
+ if (Channel)
+ Channels_Count++;
+ }
+ BS_End_LE();
+ Element_End0();
+ Get_L4(Size, "Track size");
+ Skip_L4( "Zero");
+ if (Version>=1)
+ {
+ Skip_L4( "Zero");
+ Skip_L4( "Zero");
+ }
+ Audio_Sizes.resize(Channels_Count);
+ for (size_t Pos=0; Pos<Audio_Sizes.size(); Pos++)
+ Audio_Sizes[Pos]=Size;
+ BlockSize=Size*Channels_Count;
+ if (Audios_Header.TimeStamp_Begin==(int64u)-1)
+ Audios_Header.TimeStamp_Begin=TimeStamp;
+ Audios_Header.TimeStamp_End=TimeStamp+Duration;
+ Audios_Header.Duration=Duration;
+ LastAudio_BufferOffset=File_Offset+Buffer_Offset;
+ LastAudio_TimeOffset=stream_header(TimeStamp, TimeStamp+Duration, Duration, (int8u)-1);
+ #if MEDIAINFO_DEMUX
+ Demux_random_access=true;
+ #endif //MEDIAINFO_DEMUX
+ }
+ break;
+ case 2 : //Header
+ {
+ Header_Sizes.resize(2);
+ int32u SegmentFormat, Size;
+
+ Get_L4 (SegmentFormat, "Segment format");
+ Get_L4 (Size, "Data size");
+ Header_Sizes[0]=Size;
+ BlockSize+=Size;
+ if (SegmentFormat)
+ {
+ Get_L4 (Size, "Extended fields size");
+ Header_Sizes[1]=Size;
+ BlockSize+=Size;
+ }
+ Skip_L4( "Zero");
+ Skip_L4( "Zero");
+ Skip_L4( "Zero");
+ }
+ break;
+ default : BlockSize=0;
+ }
+ Skip_L4( "Checksum");
+ if (Version)
+ Skip_L4( "Zero");
+
+ if (Element_Offset<HeaderSize)
+ Skip_XX(Header_Size-Element_Offset, "Unknown");
+
+ if (Buffer_Offset+Element_Offset+BlockSize>Buffer_Size)
+ {
+ //Hints
+ if (File_Buffer_Size_Hint_Pointer)
+ {
+ size_t Buffer_Size_Target=(size_t)(Buffer_Offset+0x48+BlockSize+0x48); //+0x48 for next packet header
+ if ((*File_Buffer_Size_Hint_Pointer)<Buffer_Size_Target)
+ (*File_Buffer_Size_Hint_Pointer)=Buffer_Size_Target;
+ }
+ }
+
+ //Filling
+ Header_Fill_Code(Type, Ztring::ToZtring(Type));
+ Header_Fill_Size(HeaderSize+BlockSize);
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Data_Parse()
+{
+ switch(Element_Code)
+ {
+ case 0 : Video(); break;
+ case 1 : Audio(); break;
+ case 2 : Header(); break;
+ default :
+ if (Element_Code&0x000100)
+ Video_Stream(Element_Code&0xFF);
+ else if (Element_Code&0x000200)
+ Audio_Stream(Element_Code&0xFF);
+ else
+ Skip_XX(Element_Size, "Unknown");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Lxf::Header()
+{
+ Element_Name("Header");
+
+ for (size_t Pos=0; Pos<Header_Sizes.size(); Pos++)
+ {
+ switch(Pos)
+ {
+ case 0 : Header_Info(); break;
+ case 1 : Header_Meta(); break;
+ default : Skip_XX(Header_Sizes[Pos], "Data");
+ }
+ }
+ Header_Sizes.clear();
+
+ Info_General_StreamSize=0x48+Element_Size;
+
+ #if MEDIAINFO_DEMUX
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ Config->Demux_EventWasSent=true; //First set is to indicate the user that header is parsed
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Header_Info()
+{
+ Element_Begin1("Disk segment");
+
+ //Parsing
+ int64u End=Element_Offset+Header_Sizes[0];
+ if (Header_Sizes[0]>=120)
+ {
+ Skip_L4( "prev");
+ Skip_L4( "next");
+ Skip_L4( "videoClusters");
+ Skip_L4( "audioClusters");
+ Element_Begin1("id");
+ Skip_C8( "code");
+ Skip_L4( "minFrame");
+ Skip_L4( "start");
+ Skip_L4( "duration");
+ Skip_L4( "tcOffset");
+ BS_Begin_LE();
+ Skip_T1(4, "Format");
+ Skip_T1(7, "GOP (N)");
+ Skip_T1(3, "GOP (M)");
+ Skip_T1(8, "Bit rate");
+ Skip_TB( "VBI present");
+ Skip_TB( "Aspect Ratio");
+ BS_End_LE();
+ Skip_L1( "reserved");
+ Skip_L4( "base");
+ Skip_L4( "prev");
+ Skip_L4( "next");
+ Skip_L2( "recordDate");
+ Skip_L2( "killDate");
+ Skip_L1( "tc_type");
+ Skip_L1( "status");
+ Skip_L1( "disk");
+ Skip_String(26, "description");
+ Skip_String(16, "agency");
+ Skip_String( 6, "description");
+ Element_End0();
+ Skip_L1( "videoGain");
+ Skip_L1( "videoSetup");
+ Skip_L1( "chromaGain");
+ Skip_L1( "hueLSB");
+ Skip_L1( "reserved");
+ BS_Begin_LE();
+ Skip_T1(2, "hueMSB");
+ Skip_T1(4, "audioTracks");
+ Skip_TB( "writeProtected");
+ Skip_TB( "allocated");
+ Skip_TB( "sliding");
+ Skip_TB( "tcTranslate");
+ Skip_TB( "invisible");
+ Skip_TB( "macro");
+ Skip_TB( "alpha");
+ Skip_TB( "project");
+ Skip_TB( "purged");
+ Skip_TB( "reference");
+ Skip_TB( "looping");
+ Skip_TB( "notReadyToPlay");
+ Skip_TB( "notReadyToTransfer");
+ Skip_TB( "notReadyToArchive");
+ Skip_TB( "transferInProgress");
+ Skip_T2(11, "reserved");
+ BS_End_LE();
+ }
+ if (Element_Offset<End)
+ Skip_XX(End-Element_Offset, "Unknown");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Header_Meta()
+{
+ Element_Begin1("Extended fields area");
+
+ int64u Offset=0;
+ int64u Pos=0;
+
+ while (Offset<Header_Sizes[1])
+ {
+ int8u Size;
+ Get_L1 (Size, "Size");
+ if (Size)
+ {
+ switch (Pos)
+ {
+ case 0 : //Record Date/Time
+ {
+ Skip_XX(Size, "Record Date/Time");
+ }
+ break;
+ case 1 : //Library
+ {
+ Ztring Library;
+ Get_UTF8(Size, Library, "Library");
+ Fill(Stream_General, 0, General_Encoded_Library, Library);
+ }
+ break;
+ case 2 : //Source Handle
+ {
+ Skip_XX(Size, "Source Handle");
+ }
+ break;
+ case 3 : //UMID
+ {
+ Skip_XX(Size, "UMID");
+ }
+ break;
+ case 4 : //Video size / rate info
+ {
+ if (Size==0x10)
+ {
+ Element_Begin1("Video size / rate info");
+ BS_Begin_LE();
+ Element_Begin1("formatCode");
+ int8u formatCode=(int8u)-1;
+ for (int8u Pos=0; Pos<96; Pos++)
+ {
+ bool Temp;
+ Get_TB (Temp, "formatCode bit");
+ if (Temp)
+ {
+ if (formatCode==(int8u)-1)
+ formatCode=Pos;
+ else
+ formatCode=(int8u)-2; //problem
+ }
+ }
+ if (formatCode<96)
+ {
+ int8u frameRateCode=formatCode%8;
+ #if MEDIAINFO_TRACE
+ int8u temp=formatCode/8;
+ int8u scanType=temp%2;
+ int8u verticalsizeCode=temp/2;
+ Element_Info(verticalsizeCode);
+ Element_Info(scanType);
+ #endif //MEDIAINFO_TRACE
+ if (frameRateCode<16-1)
+ {
+ FrameRate=Mpegv_frame_rate[frameRateCode+1];
+ if (Version==0)
+ TimeStamp_Rate=FrameRate*2; //Time stamp is in fields
+ Element_Info3(FrameRate, 3, " fps");
+ }
+ }
+ Element_End0();
+ Skip_TB( "field");
+ Skip_TB( "interlaced");
+ Skip_TB( "pulldown");
+ Skip_TB( "chroma 420");
+ Skip_TB( "chroma 422");
+ Skip_TB( "chroma 311");
+ Skip_TB( "PAR 1:1");
+ Skip_TB( "PAR 4:3");
+ Skip_T4(23, "Zero");
+ BS_End_LE();
+ Element_End0();
+ }
+ else
+ Skip_XX(Size, "Video size / rate info");
+ }
+ break;
+ case 5 : //Source Video Info
+ {
+ Skip_XX(Size, "Source Video Info");
+ }
+ break;
+ case 6 : //GUID
+ {
+ Skip_XX(Size, "GUID");
+ }
+ break;
+ case 7 : //Channel?
+ {
+ Ztring Channel;
+ Get_UTF16L(Size, Channel, "Channel?");
+ Fill(Stream_General, 0, General_ServiceName, Channel);
+ }
+ break;
+ case 8 : //Department
+ {
+ Skip_UTF16L(Size, "Department");
+ }
+ break;
+ case 12 : //Title
+ {
+ Ztring Title;
+ Get_UTF16L(Size, Title, "Title");
+ Fill(Stream_General, 0, General_Title, Title);
+ }
+ break;
+ case 13 : //Extended Agency
+ {
+ Ztring Title;
+ Get_UTF16L(Size, Title, "Extended Agency");
+ Fill(Stream_General, 0, General_Title, Title); //Note: not sure
+ }
+ break;
+ case 14 : //User-definable Field
+ case 15 : //User-definable Field
+ case 16 : //User-definable Field
+ case 17 : //User-definable Field
+ {
+ Ztring Comment;
+ Get_UTF16L(Size, Comment, "User-definable Field");
+ Fill(Stream_General, 0, General_Comment, Comment);
+ }
+ break;
+ case 20 : //Modified Timestamp
+ {
+ Skip_XX(Size, "Modified Timestamp");
+ }
+ break;
+ default : Skip_XX(Size, "Data");
+ }
+ }
+ Offset+=1+Size;
+ Pos++;
+ }
+
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Audio()
+{
+ Element_Name("Audio");
+
+ #if MEDIAINFO_SEEK
+ if (FrameRate==0 && Audios_Header.TimeStamp_End-Audios_Header.TimeStamp_Begin!=0)
+ FrameRate=TimeStamp_Rate/(Audios_Header.TimeStamp_End-Audios_Header.TimeStamp_Begin);
+ #endif //MEDIAINFO_SEEK
+
+ Audio_Sizes_Pos=0;
+ Element_ThisIsAList();
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Audio_Stream(size_t Pos)
+{
+ Element_Begin1("Stream");
+
+ #if MEDIAINFO_DEMUX
+ #if MEDIAINFO_SEEK
+ if (SeekRequest==(int64u)-1)
+ #endif //MEDIAINFO_SEEK
+ {
+ Element_Code=0x0200+Pos;
+ Frame_Count_NotParsedIncluded=float64_int64s(((float64)(Audios_Header.TimeStamp_End-Audios_Header.Duration))/TimeStamp_Rate*FrameRate);
+ if (SampleSize==20 && Config->Demux_PCM_20bitTo16bit_Get())
+ {
+ //Removing bits 3-0 (Little endian)
+ int8u* SixteenBit=new int8u[(size_t)Audio_Sizes[Pos]];
+ size_t SixteenBit_Pos=0;
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+ size_t Buffer_Max=Buffer_Offset+(size_t)(Element_Offset+Audio_Sizes[Pos]);
+
+ while (Buffer_Pos+5<=Buffer_Max)
+ {
+ int64u Temp=LittleEndian2int40u(Buffer+Buffer_Pos);
+ Temp=((Temp&0xFFFF000000LL)>>8)|((Temp&0xFFFF0LL)>>4);
+ int32s2LittleEndian(SixteenBit+SixteenBit_Pos, (int32s)Temp);
+ SixteenBit_Pos+=4;
+ Buffer_Pos+=5;
+ }
+
+ Demux(SixteenBit, SixteenBit_Pos, ContentType_MainStream);
+ }
+ else
+ Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)Audio_Sizes[Pos], ContentType_MainStream);
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ Skip_XX(Audio_Sizes[Pos], Audio_Sizes.size()==2?"PCM":"Unknown format");
+
+ if (Pos>=Audios.size())
+ Audios.resize(Pos+1);
+ if (Audios[Pos].Parser==NULL)
+ {
+ //Trying to detect if this is PCM
+ int64u BitRate=float64_int64s(Audio_Sizes[Pos]*TimeStamp_Rate*8/(Audios_Header.TimeStamp_End-Audios_Header.TimeStamp_Begin));
+ Audios[Pos].BytesPerFrame=Audio_Sizes[Pos];
+
+ Audios[Pos].Parser=new File__Analyze;
+ Open_Buffer_Init(Audios[Pos].Parser);
+ Audios[Pos].Parser->Accept();
+ Audios[Pos].Parser->Stream_Prepare(Stream_Audio);
+ Audios[Pos].Parser->Fill(Stream_Audio, StreamPos_Last, Audio_BitRate, BitRate);
+ Audios[Pos].Parser->Fill(Stream_Audio, 0, Audio_BitRate_Mode, "CBR");
+ Audios[Pos].Parser->Fill(Stream_Audio, StreamPos_Last, Audio_Format, "PCM");
+ Audios[Pos].Parser->Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, 48000);
+ Audios[Pos].Parser->Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 1);
+ Audios[Pos].Parser->Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, SampleSize);
+ Audios[Pos].Parser->Fill();
+ }
+
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Video()
+{
+ Element_Name("Video");
+
+ #if MEDIAINFO_SEEK
+ if (FrameRate==0 && Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin!=0)
+ FrameRate=TimeStamp_Rate/(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin);
+ #endif //MEDIAINFO_SEEK
+
+ Video_Sizes_Pos=0;
+ Element_ThisIsAList();
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Video_Stream(size_t Pos)
+{
+ if (LookingForLastFrame)
+ {
+ Skip_XX(Element_Size, "Data");
+ return;
+ }
+
+ Element_Begin1("Stream");
+
+ #if MEDIAINFO_DEMUX
+ #if MEDIAINFO_SEEK
+ if (SeekRequest==(int64u)-1)
+ #endif //MEDIAINFO_SEEK
+ {
+ Element_Code=0x0100+Pos;
+ Frame_Count_NotParsedIncluded=float64_int64s(((float64)(Videos_Header.TimeStamp_End-Videos_Header.Duration))/TimeStamp_Rate*FrameRate);
+ Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)Video_Sizes[Pos], ContentType_MainStream);
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ if (Pos>=Videos.size())
+ Videos.resize(Pos+1);
+
+ switch (Pos)
+ {
+ case 1 : Video_Stream_1(); break;
+ case 2 : Video_Stream_2(); break;
+ default: ;
+ }
+
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (Pos==2)
+ {
+ Frame_Count++;
+ if (Frame_Count>6 && Stream_Count==0 && !Status[IsFilled]) //5 video frames for 1 Audio frame
+ {
+ Fill("LXF");
+ if (MediaInfoLib::Config.ParseSpeed_Get()<1)
+ {
+ LookingForLastFrame=true;
+ if (3*(File_Offset+Buffer_Offset)<=File_Size)
+ {
+ GoToFromEnd((File_Offset+Buffer_Offset)*2);
+ Open_Buffer_Unsynch();
+ }
+ }
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Video_Stream_1()
+{
+ Videos[1].BytesPerFrame=Video_Sizes[1];
+
+ int8u Lines_Allocated, Lines_Used, FieldNumber;
+ Get_L1 (Lines_Allocated, "Lines allocated");
+ Get_L1 (Lines_Used, "Lines used");
+ Get_L1 (FieldNumber, "Field number");
+
+ #if defined(MEDIAINFO_CDP_YES)
+ if (Videos[1].Parser==NULL)
+ {
+ Videos[1].Parser=new File_Ancillary;
+ ((File_Ancillary*)Videos[1].Parser)->InDecodingOrder=true;
+ ((File_Ancillary*)Videos[1].Parser)->WithChecksum=true;
+ Videos[1].Parser->MustSynchronize=true;
+ Open_Buffer_Init(Videos[1].Parser);
+ Stream_Count++;
+ }
+ Videos[1].Parser->FrameInfo=FrameInfo;
+ Open_Buffer_Continue(Videos[1].Parser);
+ if (Videos[1].Parser->Status[IsFilled])
+ {
+ if (Stream_Count>0)
+ Stream_Count--;
+ }
+ #else
+ Skip_XX(Video_Sizes[1], "VBI data");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Video_Stream_2()
+{
+ switch (VideoFormat)
+ {
+ case 0x01 :
+ case 0x02 :
+ case 0x03 :
+ case 0x09 :
+ Video_Stream_2_Mpegv();
+ break;
+ case 0x04 :
+ case 0x05 :
+ case 0x06 :
+ Video_Stream_2_DvDif();
+ break;
+ case 0x0A :
+ case 0x0B :
+ case 0x0C :
+ case 0x0D :
+ Video_Stream_2_Avc();
+ break;
+ default :
+ Skip_XX(Element_Size, "Unknown");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Video_Stream_2_Mpegv()
+{
+ #if defined(MEDIAINFO_MPEGV_YES)
+ if (Videos[2].Parser==NULL)
+ {
+ Videos[2].Parser=new File_Mpegv;
+ ((File_Mpegv*)Videos[2].Parser)->FrameIsAlwaysComplete=true;
+ Open_Buffer_Init(Videos[2].Parser);
+ Stream_Count++;
+ }
+ Open_Buffer_Continue(Videos[2].Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)Video_Sizes[2]);
+ if (Videos[2].Parser->Status[IsFilled])
+ {
+ if (Stream_Count>0)
+ Stream_Count--;
+ }
+ #else
+ Skip_XX(Video_Sizes[1], "MPEG Video");
+
+ if (Videos[2].Parser==NULL)
+ {
+ if (FrameRate==0 && Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin)
+ FrameRate=((float64)1)*TimeStamp_Rate/(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin);
+
+ Videos[2].Parser=new File__Analyze;
+ Open_Buffer_Init(Videos[2].Parser);
+ Videos[2].Parser->Stream_Prepare(Stream_Video);
+ Videos[2].Parser->Fill(Stream_Video, 0, Video_Format, "MPEG Video");
+ if (FrameRate)
+ Videos[2].Parser->Fill(Stream_Video, 0, Video_FrameRate, FrameRate);
+ }
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Video_Stream_2_DvDif()
+{
+ #if defined(MEDIAINFO_DVDIF_YES)
+ if (Videos[2].Parser==NULL)
+ {
+ Videos[2].Parser=new File_DvDif;
+ ((File_DvDif*)Videos[2].Parser)->IgnoreAudio=true;
+ Open_Buffer_Init(Videos[2].Parser);
+ Stream_Count++;
+ }
+ Open_Buffer_Continue(Videos[2].Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)Video_Sizes[2]);
+ if (Videos[2].Parser->Status[IsFilled])
+ {
+ if (Stream_Count>0)
+ Stream_Count--;
+ }
+ #else
+ Skip_XX(Video_Sizes[1], "DV");
+
+ if (Videos[2].Parser==NULL)
+ {
+ int64u BitRate=float64_int64s(((float64)Video_Sizes[1])*TimeStamp_Rate*8/(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin));
+ if (FrameRate==0 && Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin)
+ FrameRate=((float64)1)*TimeStamp_Rate/(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin);
+
+ Videos[2].Parser=new File__Analyze;
+ Open_Buffer_Init(Videos[2].Parser);
+ Videos[2].Parser->Accept();
+ Videos[2].Parser->Stream_Prepare(Stream_Video);
+ Videos[2].Parser->Fill(Stream_Video, 0, Video_Format, "DV");
+ Videos[2].Parser->Fill(Stream_Video, 0, Video_BitRate, BitRate);
+ Videos[2].Parser->Fill(Stream_Video, 0, Video_BitRate_Mode, "CBR");
+ if (FrameRate)
+ Videos[2].Parser->Fill(Stream_Video, 0, Video_FrameRate, FrameRate);
+ Videos[2].Parser->Fill();
+ }
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Lxf::Video_Stream_2_Avc()
+{
+ #if defined(MEDIAINFO_AVC_YES)
+ if (Videos[2].Parser==NULL)
+ {
+ Videos[2].Parser=new File_Avc;
+ ((File_Avc*)Videos[2].Parser)->FrameIsAlwaysComplete=true;
+ Open_Buffer_Init(Videos[2].Parser);
+ Stream_Count++;
+ }
+ Open_Buffer_Continue(Videos[2].Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)Video_Sizes[2]);
+ if (Videos[2].Parser->Status[IsFilled])
+ {
+ if (Stream_Count>0)
+ Stream_Count--;
+ }
+ #else
+ Skip_XX(Video_Sizes[1], "AVC");
+
+ if (Videos[2].Parser==NULL)
+ {
+ if (FrameRate==0 && Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin)
+ FrameRate=((float64)1)*TimeStamp_Rate/(Videos_Header.TimeStamp_End-Videos_Header.TimeStamp_Begin);
+
+ Videos[2].Parser=new File__Analyze;
+ Open_Buffer_Init(Videos[2].Parser);
+ Videos[2].Parser->Stream_Prepare(Stream_Video);
+ Videos[2].Parser->Fill(Stream_Video, 0, Video_Format, "AVC");
+ if (FrameRate)
+ Videos[2].Parser->Fill(Stream_Video, 0, Video_FrameRate, FrameRate);
+ }
+ #endif
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_LXF_*
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Lxf.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Lxf.h
new file mode 100644
index 000000000..8514d1012
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Lxf.h
@@ -0,0 +1,155 @@
+// File_Lxf - Info for LXF files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Lxf files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_LxfH
+#define MediaInfo_File_LxfH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Lxf
+//***************************************************************************
+
+class File_Lxf : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Lxf();
+
+protected :
+ //Streams management
+ void Streams_Fill ();
+ void Streams_Fill_PerStream (File__Analyze* Parser, size_t Container_StreamKind, size_t Parser_Pos);
+ void Streams_Finish ();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+
+ //Buffer - Global
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Per element
+ bool Header_Begin ();
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Header();
+ void Header_Info();
+ void Header_Meta();
+ void Audio();
+ void Audio_Stream(size_t Pos);
+ void Video();
+ void Video_Stream(size_t Pos);
+ void Video_Stream_1();
+ void Video_Stream_2();
+ void Video_Stream_2_Mpegv();
+ void Video_Stream_2_DvDif();
+ void Video_Stream_2_Avc();
+
+ //Streams
+ struct stream
+ {
+ File__Analyze* Parser;
+ int64u BytesPerFrame;
+
+ stream()
+ {
+ Parser=NULL;
+ BytesPerFrame=(int64u)-1;
+ }
+ };
+ std::vector<stream> Videos;
+ std::vector<stream> Audios;
+ struct stream_header
+ {
+ int64u TimeStamp_Begin;
+ int64u TimeStamp_End;
+ int64u Duration;
+ int8u PictureType;
+
+ stream_header()
+ {
+ TimeStamp_Begin=(int64u)-1;
+ TimeStamp_End=(int64u)-1;
+ Duration=(int64u)-1;
+ PictureType=(int8u)-1;
+ }
+ stream_header(int64u TimeStamp_Begin_, int64u TimeStamp_End_, int64u Duration_, int8u PictureType_)
+ {
+ TimeStamp_Begin=TimeStamp_Begin_;
+ TimeStamp_End=TimeStamp_End_;
+ Duration=Duration_;
+ PictureType=PictureType_;
+ }
+ };
+ stream_header Videos_Header;
+ stream_header Audios_Header;
+
+ //Temp
+ bool LookingForLastFrame;
+ int64u Stream_Count;
+ int64u Info_General_StreamSize;
+ std::vector<int64u> Header_Sizes;
+ std::vector<int64u> Audio_Sizes;
+ size_t Audio_Sizes_Pos;
+ std::vector<int64u> Video_Sizes;
+ size_t Video_Sizes_Pos;
+ int8u SampleSize;
+ int8u VideoFormat;
+ int32u Version;
+
+ //Hints
+ size_t* File_Buffer_Size_Hint_Pointer;
+
+ //Seek
+ typedef std::map<int64u, stream_header> time_offsets;
+ time_offsets TimeOffsets;
+ #if MEDIAINFO_SEEK
+ int64u SeekRequest_Divider;
+ int64u SeekRequest;
+ #endif //MEDIAINFO_SEEK
+ float64 FrameRate;
+ float64 TimeStamp_Rate;
+ bool Duration_Detected;
+ int64u LastAudio_BufferOffset;
+ stream_header LastAudio_TimeOffset;
+};
+
+} //NameSpace
+
+#endif
+
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mk.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mk.cpp
new file mode 100644
index 000000000..519372eca
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mk.cpp
@@ -0,0 +1,3432 @@
+// File_Mk - Info for Matroska files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MK_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Mk.h"
+#if defined(MEDIAINFO_OGG_YES)
+ #include "MediaInfo/Multiple/File_Ogg.h"
+#endif
+#if defined(MEDIAINFO_RM_YES)
+ #include "MediaInfo/Multiple/File_Rm.h"
+#endif
+#if defined(MEDIAINFO_MPEG4V_YES)
+ #include "MediaInfo/Video/File_Mpeg4v.h"
+#endif
+#if defined(MEDIAINFO_AVC_YES)
+ #include "MediaInfo/Video/File_Avc.h"
+#endif
+#if defined(MEDIAINFO_VC1_YES)
+ #include "MediaInfo/Video/File_Vc1.h"
+#endif
+#if defined(MEDIAINFO_DIRAC_YES)
+ #include "MediaInfo/Video/File_Dirac.h"
+#endif
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_VP8_YES)
+ #include "MediaInfo/Video/File_Vp8.h"
+#endif
+#if defined(MEDIAINFO_AAC_YES)
+ #include "MediaInfo/Audio/File_Aac.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_DTS_YES)
+ #include "MediaInfo/Audio/File_Dts.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if defined(MEDIAINFO_FLAC_YES)
+ #include "MediaInfo/Audio/File_Flac.h"
+#endif
+#if defined(MEDIAINFO_WVPK_YES)
+ #include "MediaInfo/Audio/File_Wvpk.h"
+#endif
+#if defined(MEDIAINFO_TTA_YES)
+ #include "MediaInfo/Audio/File_Tta.h"
+#endif
+#if defined(MEDIAINFO_PCM_YES)
+ #include "MediaInfo/Audio/File_Pcm.h"
+#endif
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#include <cstring>
+#include <algorithm>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Mk_ContentCompAlgo(int64u Algo)
+{
+ switch (Algo)
+ {
+ case 0x00 : return "zlib";
+ case 0x01 : return "bzlib";
+ case 0x02 : return "lzo1x";
+ case 0x03 : return "Header stripping";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mk_StereoMode(int64u StereoMode)
+{
+ switch (StereoMode)
+ {
+ case 0x00 : return ""; //Mono (default)
+ case 0x01 : return "Side by Side (left eye first)";
+ case 0x02 : return "Top-Bottom (right eye first)";
+ case 0x03 : return "Top-Bottom (left eye first)";
+ case 0x04 : return "Checkboard (right eye first)";
+ case 0x05 : return "Checkboard (left eye first)";
+ case 0x06 : return "Row Interleaved (right eye first)";
+ case 0x07 : return "Row Interleaved (left eye first)";
+ case 0x08 : return "Column Interleaved (right eye first)";
+ case 0x09 : return "Column Interleaved (left eye first)";
+ case 0x0A : return "Anaglyph (cyan/red)";
+ case 0x0B : return "Side by Side (right eye first)";
+ case 0x0C : return "Anaglyph (green/magenta)";
+ case 0x0D : return "Both Eyes laced in one block (left eye first)";
+ case 0x0E : return "Both Eyes laced in one block (right eye first)";
+ default : return "Unknown";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mk_StereoMode_v2(int64u StereoMode)
+{
+ switch (StereoMode)
+ {
+ case 0x00 : return ""; //Mono (default)
+ case 0x01 : return "Right Eye";
+ case 0x02 : return "Left Eye";
+ case 0x03 : return "Both Eye";
+ default : return "Unknown";
+ }
+}
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+extern std::string ExtensibleWave_ChannelMask (int32u ChannelMask);
+
+//---------------------------------------------------------------------------
+extern std::string ExtensibleWave_ChannelMask2 (int32u ChannelMask);
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Mk::File_Mk()
+:File__Analyze()
+{
+ //Configuration
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Matroska;
+ StreamIDs_Width[0]=16;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ #endif //MEDIAINFO_DEMUX
+ DataMustAlwaysBeComplete=false;
+
+ //Temp
+ Format_Version=0;
+ TimecodeScale=1000000; //Default value
+ Duration=0;
+ Cluster_AlreadyParsed=false;
+
+ //Helpers
+ CodecPrivate=NULL;
+}
+
+//---------------------------------------------------------------------------
+File_Mk::~File_Mk()
+{
+ delete[] CodecPrivate; //CodecPrivate=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mk::Streams_Finish()
+{
+ if (Duration!=0 && TimecodeScale!=0)
+ Fill(Stream_General, 0, General_Duration, Duration*int64u_float64(TimecodeScale)/1000000.0, 0);
+ for (std::map<int64u, stream>::iterator Temp=Stream.begin(); Temp!=Stream.end(); Temp++)
+ {
+ if (Temp->second.DisplayAspectRatio!=0)
+ {
+ Fill(Stream_Video, Temp->second.StreamPos, Video_DisplayAspectRatio, Temp->second.DisplayAspectRatio, 3, true);
+ int64u Width=Retrieve(Stream_Video, Temp->second.StreamPos, Video_Width).To_int64u();
+ int64u Height=Retrieve(Stream_Video, Temp->second.StreamPos, Video_Height).To_int64u();
+ if (Width)
+ Fill(Stream_Video, Temp->second.StreamPos, Video_PixelAspectRatio, Temp->second.DisplayAspectRatio*Height/Width, 3, true);
+ }
+
+ if (Temp->second.Parser)
+ {
+ StreamKind_Last=Temp->second.StreamKind;
+ StreamPos_Last=Temp->second.StreamPos;
+
+ //Delay
+ if (Temp->second.TimeCode_Start!=(int64u)-1 && TimecodeScale)
+ {
+ //From TimeCode
+ float64 Delay=Temp->second.TimeCode_Start*int64u_float64(TimecodeScale)/1000000.0;
+
+ //From stream format
+ if (StreamKind_Last==Stream_Audio && Count_Get(Stream_Video)==1 && Temp->second.Parser->Count_Get(Stream_General)>0)
+ {
+ if (Temp->second.Parser->Buffer_TotalBytes_FirstSynched==0)
+ ;
+ else if (Temp->second.AvgBytesPerSec!=0)
+ Delay+=((float64)Temp->second.Parser->Buffer_TotalBytes_FirstSynched)*1000/Temp->second.AvgBytesPerSec;
+ else if (Temp->second.Parser->Retrieve(Stream_Audio, 0, Audio_BitRate).To_int64u()!=0)
+ Delay+=((float64)Temp->second.Parser->Buffer_TotalBytes_FirstSynched)*1000/Temp->second.Parser->Retrieve(Stream_Audio, 0, Audio_BitRate).To_int64u();
+ else if (Temp->second.Parser->Retrieve(Stream_Audio, 0, Audio_BitRate_Nominal).To_int64u()!=0)
+ Delay+=((float64)Temp->second.Parser->Buffer_TotalBytes_FirstSynched)*1000/Temp->second.Parser->Retrieve(Stream_Audio, 0, Audio_BitRate_Nominal).To_int64u();
+ }
+
+ //Filling
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay), Delay, 0, true);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Source), "Container");
+ }
+
+ Ztring Duration_Temp, Codec_Temp;
+ Duration_Temp=Retrieve(StreamKind_Last, Temp->second.StreamPos, Fill_Parameter(StreamKind_Last, Generic_Duration)); //Duration from stream is sometimes false
+ Codec_Temp=Retrieve(StreamKind_Last, Temp->second.StreamPos, Fill_Parameter(StreamKind_Last, Generic_Codec)); //We want to keep the 4CC
+
+ if (Config_ParseSpeed<=1.0)
+ {
+ Fill(Temp->second.Parser);
+ Temp->second.Parser->Open_Buffer_Unsynch();
+ }
+
+ Finish(Temp->second.Parser);
+ Merge(*Temp->second.Parser, Temp->second.StreamKind, 0, Temp->second.StreamPos);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), Duration_Temp, true);
+ if (Temp->second.StreamKind==Stream_Video && !Codec_Temp.empty())
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), Codec_Temp, true);
+
+ //Special case: AAC
+ if (StreamKind_Last==Stream_Audio
+ && (Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("AAC")
+ || Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("MPEG Audio")
+ || Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("Vorbis")))
+ Clear(Stream_Audio, StreamPos_Last, Audio_BitDepth); //Resolution is not valid for AAC / MPEG Audio / Vorbis
+
+ //Video specific
+ if (StreamKind_Last==Stream_Video)
+ {
+ //FrameRate
+ if (Temp->second.TimeCodes.size()>1)
+ {
+ //Trying to detect VFR
+ std::vector<int64s> FrameRate_Between;
+ std::sort(Temp->second.TimeCodes.begin(), Temp->second.TimeCodes.end()); //This is PTS, no DTS --> Some frames are out of order
+ for (size_t Pos=1; Pos<Temp->second.TimeCodes.size(); Pos++)
+ FrameRate_Between.push_back(Temp->second.TimeCodes[Pos]-Temp->second.TimeCodes[Pos-1]);
+ if (FrameRate_Between.size()>31)
+ FrameRate_Between.resize(31); //We peek 40 frames, and remove the last ones, because this is PTS, no DTS --> Some frames are out of order
+ std::sort(FrameRate_Between.begin(), FrameRate_Between.end());
+ if (FrameRate_Between[0]*0.9<FrameRate_Between[FrameRate_Between.size()-1]
+ && FrameRate_Between[0]*1.1>FrameRate_Between[FrameRate_Between.size()-1])
+ {
+ float Time=0;
+ if (Temp->second.TimeCodes.size()>30)
+ Time=(float)(Temp->second.TimeCodes[30]-Temp->second.TimeCodes[0])/30; //30 frames for handling 30 fps rounding problems
+ if (Time)
+ {
+ float32 FrameRate_FromCluster=1000000000/Time/TimecodeScale;
+ if (!Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate).empty())
+ {
+ float32 FrameRate_FromTrack=Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate).To_float32();
+ if (FrameRate_FromCluster*1.01<FrameRate_FromTrack*0.99
+ || FrameRate_FromCluster*0.99>FrameRate_FromTrack*1.01)
+ Clear(Stream_Video, StreamPos_Last, Video_FrameRate); //There is a problem
+ }
+ else
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, FrameRate_FromCluster);
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Mode, "CFR");
+ }
+ }
+ }
+ else
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Mode, "VFR");
+ if (Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate).To_float32()==1000.0)
+ Clear(Stream_Video, StreamPos_Last, Video_FrameRate); //Some files on the net have a frame rate of 1000, it is not possible to be sure this is the real frame rate.
+ }
+ }
+ }
+ }
+
+ if (Temp->second.FrameRate!=0 && Retrieve(Stream_Video, Temp->second.StreamPos, Video_FrameRate).empty())
+ Fill(Stream_Video, Temp->second.StreamPos, Video_FrameRate, Temp->second.FrameRate, 3);
+
+ //Flags
+ Fill(Temp->second.StreamKind, Temp->second.StreamPos, "Default", Temp->second.Default?"Yes":"No");
+ Fill(Temp->second.StreamKind, Temp->second.StreamPos, "Forced", Temp->second.Forced?"Yes":"No");
+ }
+
+ //Chapters
+ if (TimecodeScale)
+ {
+ for (EditionEntries_Pos=0; EditionEntries_Pos<EditionEntries.size(); EditionEntries_Pos++)
+ {
+ Stream_Prepare(Stream_Menu);
+ Fill(Stream_Menu, StreamPos_Last, Menu_Chapters_Pos_Begin, Count_Get(Stream_Menu, StreamPos_Last), 10, true);
+ for (ChapterAtoms_Pos=0; ChapterAtoms_Pos<EditionEntries[EditionEntries_Pos].ChapterAtoms.size(); ChapterAtoms_Pos++)
+ {
+ if (EditionEntries[EditionEntries_Pos].ChapterAtoms[ChapterAtoms_Pos].ChapterTimeStart!=(int64u)-1)
+ {
+ Ztring Text;
+ for (ChapterDisplays_Pos=0; ChapterDisplays_Pos<EditionEntries[EditionEntries_Pos].ChapterAtoms[ChapterAtoms_Pos].ChapterDisplays.size(); ChapterDisplays_Pos++)
+ {
+ Ztring PerLanguage;
+ if (!EditionEntries[EditionEntries_Pos].ChapterAtoms[ChapterAtoms_Pos].ChapterDisplays[ChapterDisplays_Pos].ChapLanguage.empty())
+ PerLanguage=MediaInfoLib::Config.Iso639_1_Get(EditionEntries[EditionEntries_Pos].ChapterAtoms[ChapterAtoms_Pos].ChapterDisplays[ChapterDisplays_Pos].ChapLanguage)+_T(':');
+ PerLanguage+=EditionEntries[EditionEntries_Pos].ChapterAtoms[ChapterAtoms_Pos].ChapterDisplays[ChapterDisplays_Pos].ChapString;
+ Text+=PerLanguage+_T(" - ");
+ }
+ if (Text.size())
+ Text.resize(Text.size()-3);
+ Fill(Stream_Menu, StreamPos_Last, Ztring().Duration_From_Milliseconds(EditionEntries[EditionEntries_Pos].ChapterAtoms[ChapterAtoms_Pos].ChapterTimeStart/1000000).To_UTF8().c_str(), Text);
+ }
+ }
+ Fill(Stream_Menu, StreamPos_Last, Menu_Chapters_Pos_End, Count_Get(Stream_Menu, StreamPos_Last), 10, true);
+ }
+ }
+
+ //Attachments
+ for (size_t Pos=0; Pos<AttachedFiles.size(); Pos++)
+ {
+ if (Ztring(AttachedFiles[Pos]).MakeLowerCase().find(_T("cover"))==string::npos)
+ Fill(Stream_General, 0, "Attachment", AttachedFiles[Pos]);
+ else
+ Fill(Stream_General, 0, "Cover", AttachedFiles[Pos]);
+ }
+
+ //Purge what is not needed anymore
+ if (!File_Name.empty()) //Only if this is not a buffer, with buffer we can have more data
+ Stream.clear();
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mk::Header_Parse()
+{
+ //Test of zero padding
+ int8u Null;
+ Peek_B1(Null);
+ if (Null==0x00)
+ {
+ if (Buffer_Offset_Temp==0)
+ Buffer_Offset_Temp=Buffer_Offset+1;
+
+ while (Buffer_Offset_Temp<Buffer_Size)
+ {
+ if (Buffer[Buffer_Offset_Temp])
+ break;
+ Buffer_Offset_Temp++;
+ }
+ if (Buffer_Offset_Temp>=Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ Header_Fill_Code((int32u)-1); //Should be (int64u)-1 but Borland C++ does not like this
+ Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset);
+ Buffer_Offset_Temp=0;
+
+ return;
+ }
+
+ //Parsing
+ int64u Name, Size;
+ Get_EB (Name, "Name");
+ Get_EB (Size, "Size");
+
+ //Filling
+ Header_Fill_Code(Name, Ztring().From_Number(Name, 16));
+ Header_Fill_Size(Element_Offset+Size);
+}
+
+//---------------------------------------------------------------------------
+namespace Elements
+{
+ //Common
+ const int64u Zero=(int32u)-1; //Should be (int64u)-1 but Borland C++ does not like this
+ const int64u CRC32=0x3F;
+ const int64u Void=0x6C;
+
+ //EBML
+ const int64u Ebml=0xA45DFA3;
+ const int64u Ebml_Version=0x286;
+ const int64u Ebml_ReadVersion=0x2F7;
+ const int64u Ebml_MaxIDLength=0x2F2;
+ const int64u Ebml_MaxSizeLength=0x2F3;
+ const int64u Ebml_DocType=0x282;
+ const int64u Ebml_DocTypeVersion=0x287;
+ const int64u Ebml_DocTypeReadVersion=0x285;
+
+ //Segment
+ const int64u Segment=0x8538067;
+ const int64u Segment_Attachements=0x0941A469;
+ const int64u Segment_Attachements_AttachedFile=0x21A7;
+ const int64u Segment_Attachements_AttachedFile_FileData=0x065C;
+ const int64u Segment_Attachements_AttachedFile_FileDescription=0x067E;
+ const int64u Segment_Attachements_AttachedFile_FileName=0x066E;
+ const int64u Segment_Attachements_AttachedFile_FileMimeType=0x0660;
+ const int64u Segment_Attachements_AttachedFile_FileReferral=0x0675;
+ const int64u Segment_Attachements_AttachedFile_FileUID=0x06AE;
+ const int64u Segment_Chapters=0x43A770;
+ const int64u Segment_Chapters_EditionEntry=0x05B9;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom=0x36;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess=0x2944;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCodecID=0x2955;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand=0x2911;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand_ChapProcessData=0x2933;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand_ChapProcessTime=0x2922;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessPrivate=0x050D;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay=0x00;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapCountry=0x037E;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapLanguage=0x037C;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapString=0x05;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterFlagEnabled=0x0598;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterFlagHidden=0x18;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterPhysicalEquiv=0x23C3;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterSegmentEditionUID=0x2EBC;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterSegmentUID=0x2E67;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterTimeStart=0x11;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterTimeEnd=0x12;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterTrack=0x0F;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterTrack_ChapterTrackNumber=0x09;
+ const int64u Segment_Chapters_EditionEntry_ChapterAtom_ChapterUID=0x33C4;
+ const int64u Segment_Chapters_EditionEntry_EditionFlagDefault=0x05DB;
+ const int64u Segment_Chapters_EditionEntry_EditionFlagHidden=0x05BD;
+ const int64u Segment_Chapters_EditionEntry_EditionFlagOrdered=0x05DD;
+ const int64u Segment_Chapters_EditionEntry_EditionUID=0x05BC;
+ const int64u Segment_Cluster=0xF43B675;
+ const int64u Segment_Cluster_BlockGroup=0x20;
+ const int64u Segment_Cluster_BlockGroup_Block=0x21;
+ const int64u Segment_Cluster_BlockGroup_BlockAdditions=0x35A1;
+ const int64u Segment_Cluster_BlockGroup_BlockAdditions_BlockMore=0x26;
+ const int64u Segment_Cluster_BlockGroup_BlockAdditions_BlockMore_BlockAddID=0x6E;
+ const int64u Segment_Cluster_BlockGroup_BlockAdditions_BlockMore_BlockAdditional=0x25;
+ const int64u Segment_Cluster_BlockGroup_BlockDuration=0x1B;
+ const int64u Segment_Cluster_BlockGroup_ReferenceBlock=0x7B;
+ const int64u Segment_Cluster_BlockGroup_ReferencePriority=0x7A;
+ const int64u Segment_Cluster_BlockGroup_Slices=0xE;
+ const int64u Segment_Cluster_BlockGroup_Slices_TimeSlice=0x68;
+ const int64u Segment_Cluster_BlockGroup_Slices_TimeSlice_Duration=0x4F;
+ const int64u Segment_Cluster_BlockGroup_Slices_TimeSlice_LaceNumber=0x4C;
+ const int64u Segment_Cluster_Position=0x27;
+ const int64u Segment_Cluster_PrevSize=0x2B;
+ const int64u Segment_Cluster_SilentTracks=0x1854;
+ const int64u Segment_Cluster_SilentTracks_SilentTrackNumber=0x18D7;
+ const int64u Segment_Cluster_SimpleBlock=0x23;
+ const int64u Segment_Cluster_Timecode=0x67;
+ const int64u Segment_Cues=0xC53BB6B;
+ const int64u Segment_Cues_CuePoint=0x3B;
+ const int64u Segment_Cues_CuePoint_CueTime=0x33;
+ const int64u Segment_Cues_CuePoint_CueTrackPositions=0x37;
+ const int64u Segment_Cues_CuePoint_CueTrackPositions_CueTrack=0x77;
+ const int64u Segment_Cues_CuePoint_CueTrackPositions_CueClusterPosition=0x71;
+ const int64u Segment_Cues_CuePoint_CueTrackPositions_CueBlockNumber=0x1378;
+ const int64u Segment_Info=0x549A966;
+ const int64u Segment_Info_ChapterTranslate=0x2924;
+ const int64u Segment_Info_ChapterTranslate_ChapterTranslateCodec=0x29BF;
+ const int64u Segment_Info_ChapterTranslate_ChapterTranslateEditionUID=0x29FC;
+ const int64u Segment_Info_ChapterTranslate_ChapterTranslateID=0x29A5;
+ const int64u Segment_Info_DateUTC=0x461;
+ const int64u Segment_Info_Duration=0x489;
+ const int64u Segment_Info_MuxingApp=0xD80;
+ const int64u Segment_Info_NextFilename=0x1E83BB;
+ const int64u Segment_Info_NextUID=0x1EB923;
+ const int64u Segment_Info_PrevFilename=0x1C83AB;
+ const int64u Segment_Info_PrevUID=0x1CB923;
+ const int64u Segment_Info_SegmentFamily=0x444;
+ const int64u Segment_Info_SegmentFilename=0x3384;
+ const int64u Segment_Info_SegmentUID=0x33A4;
+ const int64u Segment_Info_TimecodeScale=0xAD7B1;
+ const int64u Segment_Info_Title=0x3BA9;
+ const int64u Segment_Info_WritingApp=0x1741;
+ const int64u Segment_SeekHead=0x14D9B74;
+ const int64u Segment_SeekHead_Seek=0xDBB;
+ const int64u Segment_SeekHead_Seek_SeekID=0x13AB;
+ const int64u Segment_SeekHead_Seek_SeekPosition=0x13AC;
+ const int64u Segment_Tags=0x0254C367;
+ const int64u Segment_Tags_Tag=0x3373;
+ const int64u Segment_Tags_Tag_SimpleTag=0x27C8;
+ const int64u Segment_Tags_Tag_SimpleTag_TagBinary=0x485;
+ const int64u Segment_Tags_Tag_SimpleTag_TagDefault=0x484;
+ const int64u Segment_Tags_Tag_SimpleTag_TagLanguage=0x47A;
+ const int64u Segment_Tags_Tag_SimpleTag_TagName=0x5A3;
+ const int64u Segment_Tags_Tag_SimpleTag_TagString=0x487;
+ const int64u Segment_Tags_Tag_Targets=0x23C0;
+ const int64u Segment_Tags_Tag_Targets_AttachmentUID=0x23C6;
+ const int64u Segment_Tags_Tag_Targets_ChapterUID=0x23C4;
+ const int64u Segment_Tags_Tag_Targets_EditionUID=0x23C9;
+ const int64u Segment_Tags_Tag_Targets_TargetType=0x23CA;
+ const int64u Segment_Tags_Tag_Targets_TargetTypeValue=0x28CA;
+ const int64u Segment_Tags_Tag_Targets_TrackUID=0x23C5;
+ const int64u Segment_Tracks=0x654AE6B;
+ const int64u Segment_Tracks_TrackEntry=0x2E;
+ const int64u Segment_Tracks_TrackEntry_AttachmentLink=0x3446;
+ const int64u Segment_Tracks_TrackEntry_Audio=0x61;
+ const int64u Segment_Tracks_TrackEntry_Audio_BitDepth=0x2264;
+ const int64u Segment_Tracks_TrackEntry_Audio_Channels=0x1F;
+ const int64u Segment_Tracks_TrackEntry_Audio_OutputSamplingFrequency=0x38B5;
+ const int64u Segment_Tracks_TrackEntry_Audio_SamplingFrequency=0x35;
+ const int64u Segment_Tracks_TrackEntry_CodecDecodeAll=0x2A;
+ const int64u Segment_Tracks_TrackEntry_CodecID=0x6;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings=0x2D80;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding=0x2240;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Order=0x1031;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Scope=0x1032;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Type=0x1033;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression=0x1034;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression_ContentCompAlgo=0x0254;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression_ContentCompSettings=0x0255;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption=0x1035;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentEncAlgo=0x07E1;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentEncKeyID=0x07E2;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSignature=0x07E3;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSigKeyID=0x07E4;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSigAlgo=0x07E5;
+ const int64u Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSigHashAlgo=0x07E6;
+ const int64u Segment_Tracks_TrackEntry_CodecName=0x58688;
+ const int64u Segment_Tracks_TrackEntry_CodecPrivate=0x23A2;
+ const int64u Segment_Tracks_TrackEntry_DefaultDuration=0x3E383;
+ const int64u Segment_Tracks_TrackEntry_FlagDefault=0x8;
+ const int64u Segment_Tracks_TrackEntry_FlagEnabled=0x39;
+ const int64u Segment_Tracks_TrackEntry_FlagForced=0x15AA;
+ const int64u Segment_Tracks_TrackEntry_FlagLacing=0x1C;
+ const int64u Segment_Tracks_TrackEntry_Language=0x2B59C;
+ const int64u Segment_Tracks_TrackEntry_MaxBlockAdditionID=0x15EE;
+ const int64u Segment_Tracks_TrackEntry_MaxCache=0x2DF8;
+ const int64u Segment_Tracks_TrackEntry_MinCache=0x2DE7;
+ const int64u Segment_Tracks_TrackEntry_Name=0x136E;
+ const int64u Segment_Tracks_TrackEntry_TrackNumber=0x57;
+ const int64u Segment_Tracks_TrackEntry_TrackTimecodeScale=0x3314F;
+ const int64u Segment_Tracks_TrackEntry_TrackType=0x3;
+ const int64u Segment_Tracks_TrackEntry_TrackUID=0x33C5;
+ const int64u Segment_Tracks_TrackEntry_Video=0x60;
+ const int64u Segment_Tracks_TrackEntry_Video_AspectRatioType=0x14B3;
+ const int64u Segment_Tracks_TrackEntry_Video_ColourSpace=0xEB524;
+ const int64u Segment_Tracks_TrackEntry_Video_DisplayHeight=0x14BA;
+ const int64u Segment_Tracks_TrackEntry_Video_DisplayUnit=0x14B2;
+ const int64u Segment_Tracks_TrackEntry_Video_DisplayWidth=0x14B0;
+ const int64u Segment_Tracks_TrackEntry_Video_FlagInterlaced=0x1A;
+ const int64u Segment_Tracks_TrackEntry_Video_FrameRate=0x383E3;
+ const int64u Segment_Tracks_TrackEntry_Video_PixelCropBottom=0x14AA;
+ const int64u Segment_Tracks_TrackEntry_Video_PixelCropLeft=0x14CC;
+ const int64u Segment_Tracks_TrackEntry_Video_PixelCropRight=0x14DD;
+ const int64u Segment_Tracks_TrackEntry_Video_PixelCropTop=0x14BB;
+ const int64u Segment_Tracks_TrackEntry_Video_PixelHeight=0x3A;
+ const int64u Segment_Tracks_TrackEntry_Video_PixelWidth=0x30;
+ const int64u Segment_Tracks_TrackEntry_Video_StereoMode=0x13B8;
+ const int64u Segment_Tracks_TrackEntry_Video_StereoModeBuggy=0x13B9;
+ const int64u Segment_Tracks_TrackEntry_TrackOverlay=0x2FAB;
+ const int64u Segment_Tracks_TrackEntry_TrackTranslate=0x2624;
+ const int64u Segment_Tracks_TrackEntry_TrackTranslate_Codec=0x26BF;
+ const int64u Segment_Tracks_TrackEntry_TrackTranslate_EditionUID=0x26FC;
+ const int64u Segment_Tracks_TrackEntry_TrackTranslate_TrackID=0x26A5;
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Data_Parse()
+{
+ #define LIS2(_ATOM, _NAME) \
+ case Elements::_ATOM : \
+ if (Level==Element_Level) \
+ { \
+ Element_Name(_NAME); \
+ _ATOM(); \
+ Element_ThisIsAList(); \
+ } \
+
+ #define ATO2(_ATOM, _NAME) \
+ case Elements::_ATOM : \
+ if (Level==Element_Level) \
+ { \
+ if (Element_IsComplete_Get()) \
+ { \
+ Element_Name(_NAME); \
+ _ATOM(); \
+ } \
+ else \
+ { \
+ Element_WaitForMoreData(); \
+ return; \
+ } \
+ } \
+ break; \
+
+ #define ATOM_END_MK \
+ ATOM(Zero) \
+ ATOM(CRC32) \
+ ATOM(Void) \
+ ATOM_END
+
+ //Parsing
+ DATA_BEGIN
+ LIST(Ebml)
+ ATOM_BEGIN
+ ATOM(Ebml_Version)
+ ATOM(Ebml_ReadVersion)
+ ATOM(Ebml_MaxIDLength)
+ ATOM(Ebml_MaxSizeLength)
+ ATOM(Ebml_DocType)
+ ATOM(Ebml_DocTypeVersion)
+ ATOM(Ebml_DocTypeReadVersion)
+ ATOM_END_MK
+ LIST(Segment)
+ ATOM_BEGIN
+ LIST(Segment_Attachements)
+ ATOM_BEGIN
+ LIST(Segment_Attachements_AttachedFile)
+ ATOM_BEGIN
+ LIST_SKIP(Segment_Attachements_AttachedFile_FileData) //This is ATOM, but some ATOMs are too big
+ ATOM(Segment_Attachements_AttachedFile_FileDescription)
+ ATOM(Segment_Attachements_AttachedFile_FileName)
+ ATOM(Segment_Attachements_AttachedFile_FileMimeType)
+ ATOM(Segment_Attachements_AttachedFile_FileReferral)
+ ATOM(Segment_Attachements_AttachedFile_FileUID)
+ ATOM_END_MK
+ ATOM_END_MK
+ LIST(Segment_Chapters)
+ ATOM_BEGIN
+ LIST(Segment_Chapters_EditionEntry)
+ ATOM_BEGIN
+ LIST(Segment_Chapters_EditionEntry_ChapterAtom)
+ ATOM_BEGIN
+ LIST(Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess)
+ ATOM_BEGIN
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCodecID)
+ LIST(Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand)
+ ATOM_BEGIN
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand_ChapProcessData)
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand_ChapProcessTime)
+ ATOM_END_MK
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessPrivate)
+ ATOM_END_MK
+ LIST(Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay)
+ ATOM_BEGIN
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapCountry)
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapLanguage)
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapString)
+ ATOM_END_MK
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterFlagEnabled)
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterFlagHidden)
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterPhysicalEquiv)
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterSegmentEditionUID)
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterSegmentUID)
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterTimeEnd)
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterTimeStart)
+ LIST(Segment_Chapters_EditionEntry_ChapterAtom_ChapterTrack)
+ ATOM_BEGIN
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterTrack_ChapterTrackNumber)
+ ATOM_END_MK
+ ATOM(Segment_Chapters_EditionEntry_ChapterAtom_ChapterUID)
+ ATOM_END_MK
+ ATOM(Segment_Chapters_EditionEntry_EditionFlagDefault)
+ ATOM(Segment_Chapters_EditionEntry_EditionFlagHidden)
+ ATOM(Segment_Chapters_EditionEntry_EditionFlagOrdered)
+ ATOM(Segment_Chapters_EditionEntry_EditionUID)
+ ATOM_END_MK
+ ATOM_END_MK
+ LIST(Segment_Cluster)
+ ATOM_BEGIN
+ LIST(Segment_Cluster_BlockGroup)
+ ATOM_BEGIN
+ ATOM(Segment_Cluster_BlockGroup_Block)
+ LIST(Segment_Cluster_BlockGroup_BlockAdditions)
+ ATOM_BEGIN
+ LIST(Segment_Cluster_BlockGroup_BlockAdditions_BlockMore)
+ ATOM_BEGIN
+ ATOM(Segment_Cluster_BlockGroup_BlockAdditions_BlockMore_BlockAddID)
+ ATOM(Segment_Cluster_BlockGroup_BlockAdditions_BlockMore_BlockAdditional)
+ ATOM_END_MK
+ ATOM_END_MK
+ ATOM(Segment_Cluster_BlockGroup_BlockDuration)
+ ATOM(Segment_Cluster_BlockGroup_ReferenceBlock)
+ ATOM(Segment_Cluster_BlockGroup_ReferencePriority)
+ LIST(Segment_Cluster_BlockGroup_Slices)
+ ATOM_BEGIN
+ LIST(Segment_Cluster_BlockGroup_Slices_TimeSlice)
+ ATOM_BEGIN
+ ATOM(Segment_Cluster_BlockGroup_Slices_TimeSlice_Duration)
+ ATOM(Segment_Cluster_BlockGroup_Slices_TimeSlice_LaceNumber)
+ ATOM_END_MK
+ ATOM_END_MK
+ ATOM_END_MK
+ ATOM(Segment_Cluster_Position)
+ ATOM(Segment_Cluster_PrevSize)
+ LIST(Segment_Cluster_SilentTracks)
+ ATOM_BEGIN
+ ATOM(Segment_Cluster_SilentTracks_SilentTrackNumber)
+ ATOM_END_MK
+ ATOM(Segment_Cluster_SimpleBlock)
+ ATOM(Segment_Cluster_Timecode)
+ ATOM_END_MK
+ LIST(Segment_Cues)
+ ATOM_BEGIN
+ LIST(Segment_Cues_CuePoint)
+ ATOM_BEGIN
+ ATOM(Segment_Cues_CuePoint_CueTime)
+ LIST(Segment_Cues_CuePoint_CueTrackPositions)
+ ATOM_BEGIN
+ ATOM(Segment_Cues_CuePoint_CueTrackPositions_CueTrack)
+ ATOM(Segment_Cues_CuePoint_CueTrackPositions_CueClusterPosition)
+ ATOM(Segment_Cues_CuePoint_CueTrackPositions_CueBlockNumber)
+ ATOM_END_MK
+ ATOM_END_MK
+ ATOM_END_MK
+ LIST(Segment_Info)
+ ATOM_BEGIN
+ LIST(Segment_Info_ChapterTranslate)
+ ATOM_BEGIN
+ ATOM(Segment_Info_ChapterTranslate_ChapterTranslateCodec)
+ ATOM(Segment_Info_ChapterTranslate_ChapterTranslateEditionUID)
+ ATOM(Segment_Info_ChapterTranslate_ChapterTranslateID)
+ ATOM_END_MK
+ ATOM(Segment_Info_DateUTC)
+ ATOM(Segment_Info_Duration)
+ ATOM(Segment_Info_MuxingApp)
+ ATOM(Segment_Info_NextFilename)
+ ATOM(Segment_Info_NextUID)
+ ATOM(Segment_Info_PrevFilename)
+ ATOM(Segment_Info_PrevUID)
+ ATOM(Segment_Info_SegmentFamily)
+ ATOM(Segment_Info_SegmentFilename)
+ ATOM(Segment_Info_SegmentUID)
+ ATOM(Segment_Info_TimecodeScale)
+ ATOM(Segment_Info_Title)
+ ATOM(Segment_Info_WritingApp)
+ ATOM_END_MK
+ LIST(Segment_SeekHead)
+ ATOM_BEGIN
+ LIST(Segment_SeekHead_Seek)
+ ATOM_BEGIN
+ ATOM(Segment_SeekHead_Seek_SeekID)
+ ATOM(Segment_SeekHead_Seek_SeekPosition)
+ ATOM_END_MK
+ ATOM_END_MK
+ LIST(Segment_Tags)
+ ATOM_BEGIN
+ LIST(Segment_Tags_Tag)
+ ATOM_BEGIN
+ LIST(Segment_Tags_Tag_SimpleTag)
+ ATOM_BEGIN
+ LIST(Segment_Tags_Tag_SimpleTag)
+ ATOM_BEGIN
+ LIST(Segment_Tags_Tag_SimpleTag)
+ ATOM_BEGIN
+ ATOM(Segment_Tags_Tag_SimpleTag_TagBinary)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagDefault)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagLanguage)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagName)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagString)
+ ATOM_END_MK
+ ATOM(Segment_Tags_Tag_SimpleTag_TagBinary)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagDefault)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagLanguage)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagName)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagString)
+ ATOM_END_MK
+ ATOM(Segment_Tags_Tag_SimpleTag_TagBinary)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagDefault)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagLanguage)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagName)
+ ATOM(Segment_Tags_Tag_SimpleTag_TagString)
+ ATOM_END_MK
+ LIST(Segment_Tags_Tag_Targets)
+ ATOM_BEGIN
+ ATOM(Segment_Tags_Tag_Targets_AttachmentUID)
+ ATOM(Segment_Tags_Tag_Targets_ChapterUID)
+ ATOM(Segment_Tags_Tag_Targets_EditionUID)
+ ATOM(Segment_Tags_Tag_Targets_TargetType)
+ ATOM(Segment_Tags_Tag_Targets_TargetTypeValue)
+ ATOM(Segment_Tags_Tag_Targets_TrackUID)
+ ATOM_END_MK
+ ATOM_END_MK
+ ATOM_END_MK
+ LIST(Segment_Tracks)
+ ATOM_BEGIN
+ LIST(Segment_Tracks_TrackEntry)
+ ATOM_BEGIN
+ ATOM(Segment_Tracks_TrackEntry_AttachmentLink)
+ LIST(Segment_Tracks_TrackEntry_Audio)
+ ATOM_BEGIN
+ ATOM(Segment_Tracks_TrackEntry_Audio_BitDepth)
+ ATOM(Segment_Tracks_TrackEntry_Audio_Channels)
+ ATOM(Segment_Tracks_TrackEntry_Audio_OutputSamplingFrequency)
+ ATOM(Segment_Tracks_TrackEntry_Audio_SamplingFrequency)
+ ATOM_END_MK
+ ATOM(Segment_Tracks_TrackEntry_CodecDecodeAll)
+ ATOM(Segment_Tracks_TrackEntry_CodecID)
+ LIS2(Segment_Tracks_TrackEntry_ContentEncodings, "ContentEncodings")
+ ATOM_BEGIN
+ LIS2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding, "ContentEncoding")
+ ATOM_BEGIN
+ ATO2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Order, "Order")
+ ATO2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Scope, "Scope")
+ ATO2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Type, "Type")
+ LIS2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression, "Compression")
+ ATOM_BEGIN
+ ATO2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression_ContentCompAlgo, "Algo")
+ ATO2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression_ContentCompSettings, "Settings")
+ ATOM_END_MK
+ LIS2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption, "Encryption")
+ ATOM_BEGIN
+ ATO2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentEncAlgo, "Algo")
+ ATO2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentEncKeyID, "KeyID")
+ ATO2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSignature, "Signature")
+ ATO2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSigKeyID, "SigKeyID")
+ ATO2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSigAlgo, "SigAlgo")
+ ATO2(Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSigHashAlgo, "SigHashAlgo")
+ ATOM_END_MK
+ ATOM_END_MK
+ ATOM_END_MK
+ ATOM(Segment_Tracks_TrackEntry_CodecName)
+ ATOM(Segment_Tracks_TrackEntry_CodecPrivate)
+ ATOM(Segment_Tracks_TrackEntry_DefaultDuration)
+ ATOM(Segment_Tracks_TrackEntry_FlagDefault)
+ ATOM(Segment_Tracks_TrackEntry_FlagEnabled)
+ ATOM(Segment_Tracks_TrackEntry_FlagForced)
+ ATOM(Segment_Tracks_TrackEntry_FlagLacing)
+ ATOM(Segment_Tracks_TrackEntry_Language)
+ ATOM(Segment_Tracks_TrackEntry_MaxBlockAdditionID)
+ ATOM(Segment_Tracks_TrackEntry_MaxCache)
+ ATOM(Segment_Tracks_TrackEntry_MinCache)
+ ATOM(Segment_Tracks_TrackEntry_Name)
+ ATOM(Segment_Tracks_TrackEntry_TrackNumber)
+ ATOM(Segment_Tracks_TrackEntry_TrackTimecodeScale)
+ ATOM(Segment_Tracks_TrackEntry_TrackType)
+ ATOM(Segment_Tracks_TrackEntry_TrackUID)
+ LIST(Segment_Tracks_TrackEntry_Video)
+ ATOM_BEGIN
+ ATOM(Segment_Tracks_TrackEntry_Video_AspectRatioType)
+ ATOM(Segment_Tracks_TrackEntry_Video_ColourSpace)
+ ATOM(Segment_Tracks_TrackEntry_Video_DisplayHeight)
+ ATOM(Segment_Tracks_TrackEntry_Video_DisplayUnit)
+ ATOM(Segment_Tracks_TrackEntry_Video_DisplayWidth)
+ ATOM(Segment_Tracks_TrackEntry_Video_FlagInterlaced)
+ ATOM(Segment_Tracks_TrackEntry_Video_FrameRate)
+ ATOM(Segment_Tracks_TrackEntry_Video_PixelCropBottom)
+ ATOM(Segment_Tracks_TrackEntry_Video_PixelCropLeft)
+ ATOM(Segment_Tracks_TrackEntry_Video_PixelCropRight)
+ ATOM(Segment_Tracks_TrackEntry_Video_PixelCropTop)
+ ATOM(Segment_Tracks_TrackEntry_Video_PixelHeight)
+ ATOM(Segment_Tracks_TrackEntry_Video_PixelWidth)
+ ATOM(Segment_Tracks_TrackEntry_Video_StereoMode)
+ ATOM_END_MK
+ ATOM(Segment_Tracks_TrackEntry_TrackOverlay)
+ LIST(Segment_Tracks_TrackEntry_TrackTranslate)
+ ATOM_BEGIN
+ ATOM(Segment_Tracks_TrackEntry_TrackTranslate_Codec)
+ ATOM(Segment_Tracks_TrackEntry_TrackTranslate_EditionUID)
+ ATOM(Segment_Tracks_TrackEntry_TrackTranslate_TrackID)
+ ATOM_END_MK
+ ATOM_END_MK
+ ATOM_END_MK
+ ATOM_END_MK
+ DATA_END_DEFAULT
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mk::Zero()
+{
+ Element_Name("ZeroPadding");
+
+ Skip_XX(Element_Size, "Padding");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::CRC32()
+{
+ Element_Name("CRC32");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Void()
+{
+ Element_Name("Void");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Ebml()
+{
+ Element_Name("Ebml");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Ebml_Version()
+{
+ Element_Name("Version");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Ebml_ReadVersion()
+{
+ Element_Name("ReadVersion");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Ebml_MaxIDLength()
+{
+ Element_Name("MaxIDLength");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Ebml_MaxSizeLength()
+{
+ Element_Name("MaxSizeLength");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Ebml_DocType()
+{
+ Element_Name("DocType");
+
+ //Parsing
+ Ztring Data;
+ Get_Local(Element_Size, Data, "Data"); Element_Info1(Data);
+
+ //Filling
+ FILLING_BEGIN();
+ if (Data==_T("matroska"))
+ {
+ Accept("Matroska");
+ Fill(Stream_General, 0, General_Format, "Matroska");
+ }
+ else if (Data==_T("webm"))
+ {
+ Accept("Matroska");
+ Fill(Stream_General, 0, General_Format, "WebM");
+ }
+ else
+ {
+ Reject("Matroska");
+ return;
+ }
+
+ Buffer_MaximumSize=8*1024*1024;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Ebml_DocTypeVersion()
+{
+ Element_Name("DocTypeVersion");
+
+ //Parsing
+ Format_Version=UInteger_Get();
+
+ //Filling
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_Format_Version, _T("Version ")+Ztring::ToZtring(Format_Version));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Ebml_DocTypeReadVersion()
+{
+ Element_Name("DocTypeReadVersion");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ //Filling
+ FILLING_BEGIN();
+ if (UInteger!=Format_Version)
+ Fill(Stream_General, 0, General_Format_Version, _T("Version ")+Ztring::ToZtring(UInteger)); //Adding compatible version for info about legacy decoders
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment()
+{
+ Element_Name("Segment");
+
+ Segment_Offset_Begin=File_Offset+Buffer_Offset;
+ Segment_Offset_End=File_Offset+Buffer_Offset+Element_TotalSize_Get();
+}
+
+void File_Mk::Segment_Attachements()
+{
+ Element_Name("Attachements");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Attachements_AttachedFile()
+{
+ Element_Name("AttachedFile");
+
+ AttachedFiles.resize(AttachedFiles.size()+1);
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Attachements_AttachedFile_FileData()
+{
+ Element_Name("FileData");
+
+ //Parsing
+ Skip_XX(Element_TotalSize_Get(), "Data");
+
+ FILLING_BEGIN();
+ if (AttachedFiles[AttachedFiles.size()-1].empty())
+ AttachedFiles[AttachedFiles.size()-1]=_T("Yes");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Attachements_AttachedFile_FileDescription()
+{
+ Element_Name("FileDescription");
+
+ //Parsing
+ Ztring Data=Local_Get();
+
+ FILLING_BEGIN();
+ if (!Data.empty())
+ AttachedFiles[AttachedFiles.size()-1]=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Attachements_AttachedFile_FileName()
+{
+ Element_Name("FileName");
+
+ //Parsing
+ UTF8_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Attachements_AttachedFile_FileMimeType()
+{
+ Element_Name("FileMimeType");
+
+ //Parsing
+ Local_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Attachements_AttachedFile_FileReferral()
+{
+ Element_Name("FileReferral");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Attachements_AttachedFile_FileUID()
+{
+ Element_Name("FileUID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters()
+{
+ Element_Name("Chapters");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry()
+{
+ Element_Name("EditionEntry");
+
+ //Filling
+ EditionEntries_Pos=EditionEntries.size();
+ EditionEntries.resize(EditionEntries_Pos+1);
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom()
+{
+ Element_Name("ChapterAtom");
+
+ //Filling
+ ChapterAtoms_Pos=EditionEntries[EditionEntries_Pos].ChapterAtoms.size();
+ EditionEntries[EditionEntries_Pos].ChapterAtoms.resize(ChapterAtoms_Pos+1);
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess()
+{
+ Element_Name("ChapProcess");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCodecID()
+{
+ Element_Name("ChapProcessCodecID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand()
+{
+ Element_Name("ChapProcessCommand");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand_ChapProcessData()
+{
+ Element_Name("ChapProcessData");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand_ChapProcessTime()
+{
+ Element_Name("ChapProcessTime");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessPrivate()
+{
+ Element_Name("ChapProcessPrivate");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay()
+{
+ Element_Name("ChapterDisplay");
+
+ //Filling
+ ChapterDisplays_Pos=EditionEntries[EditionEntries_Pos].ChapterAtoms[ChapterAtoms_Pos].ChapterDisplays.size();
+ EditionEntries[EditionEntries_Pos].ChapterAtoms[ChapterAtoms_Pos].ChapterDisplays.resize(ChapterDisplays_Pos+1);
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapCountry()
+{
+ Element_Name("ChapCountry");
+
+ //Parsing
+ Local_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapLanguage()
+{
+ Element_Name("ChapLanguage");
+
+ //Parsing
+ Ztring Data=Local_Get();
+
+ FILLING_BEGIN();
+ EditionEntries[EditionEntries_Pos].ChapterAtoms[ChapterAtoms_Pos].ChapterDisplays[ChapterDisplays_Pos].ChapLanguage=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapString()
+{
+ Element_Name("ChapString");
+
+ //Parsing
+ Ztring Data=UTF8_Get();
+
+ FILLING_BEGIN();
+ EditionEntries[EditionEntries_Pos].ChapterAtoms[ChapterAtoms_Pos].ChapterDisplays[ChapterDisplays_Pos].ChapString=Data;
+ //if (TimecodeScale!=0 && ChapterTimeStart!=(int64u)-1)
+ // Fill(StreamKind_Last, StreamPos_Last, Ztring::ToZtring(Chapter_Pos).To_Local().c_str(), Ztring().Duration_From_Milliseconds(ChapterTimeStart/TimecodeScale)+_T(" - ")+ChapterString, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterFlagHidden()
+{
+ Element_Name("ChapterFlagHidden");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterFlagEnabled()
+{
+ Element_Name("ChapterFlagEnabled");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterPhysicalEquiv()
+{
+ Element_Name("ChapterPhysicalEquiv");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterSegmentEditionUID()
+{
+ Element_Name("ChapterSegmentEditionUID");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterSegmentUID()
+{
+ Element_Name("ChapterSegmentUID");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterTimeEnd()
+{
+ Element_Name("ChapterTimeEnd");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterTimeStart()
+{
+ Element_Name("ChapterTimeStart");
+
+ //Parsing
+ int64u Data=UInteger_Get();
+
+ FILLING_BEGIN();
+ EditionEntries[EditionEntries_Pos].ChapterAtoms[ChapterAtoms_Pos].ChapterTimeStart=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterTrack()
+{
+ Element_Name("ChapterTrack");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterTrack_ChapterTrackNumber()
+{
+ Element_Name("ChapterTrackNumber");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_ChapterAtom_ChapterUID()
+{
+ Element_Name("ChapterUID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_EditionFlagDefault()
+{
+ Element_Name("EditionFlagDefault");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_EditionFlagHidden()
+{
+ Element_Name("EditionFlagHidden");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_EditionFlagOrdered()
+{
+ Element_Name("EditionFlagOrdered");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Chapters_EditionEntry_EditionUID()
+{
+ Element_Name("EditionUID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster()
+{
+ Element_Name("Cluster");
+
+ //For each stream
+ std::map<int64u, stream>::iterator Temp=Stream.begin();
+ if (!Cluster_AlreadyParsed)
+ {
+ Stream_Count=0;
+ while (Temp!=Stream.end())
+ {
+ if (Temp->second.Parser)
+ Temp->second.Searching_Payload=true;
+ if (Temp->second.StreamKind==Stream_Video || Temp->second.StreamKind==Stream_Audio)
+ Temp->second.Searching_TimeStamp_Start=true;
+ if (Temp->second.StreamKind==Stream_Video)
+ Temp->second.Searching_TimeStamps=true;
+ if (Temp->second.Searching_Payload
+ || Temp->second.Searching_TimeStamp_Start
+ || Temp->second.Searching_TimeStamps)
+ Stream_Count++;
+
+ //Specific cases
+ if (Retrieve(Temp->second.StreamKind, Temp->second.StreamPos, Audio_CodecID).find(_T("A_AAC/"))==0)
+ ((File_Aac*)Stream[Temp->first].Parser)->Mode=File_Aac::Mode_raw_data_block; //In case AudioSpecificConfig is not present
+
+ Temp++;
+ }
+
+ //We must parse moov?
+ if (Stream_Count==0)
+ {
+ //Jumping
+ std::sort(Segment_Seeks.begin(), Segment_Seeks.end());
+ for (size_t Pos=0; Pos<Segment_Seeks.size(); Pos++)
+ if (Segment_Seeks[Pos]>File_Offset+Buffer_Offset+Element_Size)
+ {
+ GoTo(Segment_Seeks[Pos]);
+ break;
+ }
+ if (File_GoTo==(int64u)-1)
+ GoTo(Segment_Offset_End);
+ return;
+ }
+ }
+ Cluster_AlreadyParsed=true;
+ Segment_Cluster_TimeCode_Value=0; //Default
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup()
+{
+ Element_Name("BlockGroup");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_Block()
+{
+ Element_Name("Block");
+
+ //Parsing
+ int64u TrackNumber;
+ Get_EB (TrackNumber, "TrackNumber");
+
+ //Finished?
+ Stream[TrackNumber].PacketCount++;
+ if (!Stream[TrackNumber].Searching_Payload && !Stream[TrackNumber].Searching_TimeStamps && !Stream[TrackNumber].Searching_TimeStamp_Start)
+ {
+ Element_DoNotShow();
+ return;
+ }
+
+ //Parsing
+ int16u TimeCode;
+ Get_B2 (TimeCode, "TimeCode");
+
+ FILLING_BEGIN();
+ if (Stream[TrackNumber].Searching_TimeStamp_Start)
+ {
+ FILLING_BEGIN();
+ Stream[TrackNumber].TimeCode_Start=Segment_Cluster_TimeCode_Value+TimeCode;
+ Stream[TrackNumber].Searching_TimeStamp_Start=false;
+ FILLING_END();
+ }
+ if (Stream[TrackNumber].Searching_TimeStamps)
+ {
+ Stream[TrackNumber].TimeCodes.push_back(Segment_Cluster_TimeCode_Value+TimeCode);
+ if (Stream[TrackNumber].TimeCodes.size()>40)
+ Stream[TrackNumber].Searching_TimeStamps=false;
+ }
+ FILLING_END();
+
+ if (Stream[TrackNumber].Searching_Payload)
+ {
+ std::vector<int64u> Laces;
+ int32u Lacing;
+ Element_Begin1("Flags");
+ BS_Begin();
+ Skip_BS(1, "KeyFrame");
+ Skip_BS(3, "Reserved");
+ Skip_BS(1, "Invisible");
+ Get_BS (2, Lacing, "Lacing");
+ Skip_BS(1, "Discardable");
+ BS_End();
+ Element_End0();
+ if (Lacing>0)
+ {
+ Element_Begin1("Lacing");
+ int8u FrameCountMinus1;
+ Get_B1(FrameCountMinus1, "Frame count minus 1");
+ switch (Lacing)
+ {
+ case 1 : //Xiph lacing
+ {
+ int64u Element_Offset_Virtual=0;
+ for (int8u Pos=0; Pos<FrameCountMinus1; Pos++)
+ {
+ int32u Size=0;
+ int8u Size8;
+ do
+ {
+ Get_B1 (Size8, "Size");
+ Size+=Size8;
+ }
+ while (Size8==0xFF);
+ Param_Info1(Size);
+ Element_Offset_Virtual+=Size;
+ Laces.push_back(Size);
+ }
+ Laces.push_back(Element_Size-Element_Offset-Element_Offset_Virtual); //last lace
+ }
+ break;
+ case 2 : //Fixed-size lacing - No more data
+ {
+ int64u Size=(Element_Size-Element_Offset)/(FrameCountMinus1+1);
+ Laces.resize(FrameCountMinus1+1, Size);
+ }
+ break;
+ case 3 : //EBML lacing
+ {
+ int64u Element_Offset_Virtual=0, Size;
+ Get_EB (Size, "Size");
+ Laces.push_back(Size);
+ Element_Offset_Virtual+=Size;
+ for (int8u Pos=1; Pos<FrameCountMinus1; Pos++)
+ {
+ int64s Diff;
+ Get_ES (Diff, "Difference");
+ Size+=Diff; Param_Info1(Size);
+ Element_Offset_Virtual+=Size;
+ Laces.push_back(Size);
+ }
+ Laces.push_back(Element_Size-Element_Offset-Element_Offset_Virtual); Param_Info1(Size); //last lace
+ }
+ break;
+ default : ; //Should never be here
+ }
+ Element_End0();
+ }
+ else
+ Laces.push_back(Element_Size-Element_Offset);
+
+ FILLING_BEGIN();
+ //Parsing
+ for (size_t Pos=0; Pos<Laces.size(); Pos++)
+ {
+ //Content compression
+ if (Stream[TrackNumber].ContentCompAlgo!=(int32u)-1 && Stream[TrackNumber].ContentCompAlgo!=3)
+ Stream[TrackNumber].Searching_Payload=false; //Unsupported
+
+ //Integrity test
+ if (Element_Offset+Laces[Pos]>Element_Size)
+ Stream[TrackNumber].Searching_Payload=false; //There is a problem
+
+ if (Stream[TrackNumber].Searching_Payload)
+ {
+ //Content compression
+ if (Stream[TrackNumber].ContentCompAlgo==3) //Header Stripping
+ {
+ Element_Offset-=(size_t)Stream[TrackNumber].ContentCompSettings_Buffer_Size; //This is an extra array, not in the stream
+ Open_Buffer_Continue(Stream[TrackNumber].Parser, Stream[TrackNumber].ContentCompSettings_Buffer, (size_t)Stream[TrackNumber].ContentCompSettings_Buffer_Size);
+ Element_Offset+=(size_t)Stream[TrackNumber].ContentCompSettings_Buffer_Size;
+ Demux(Stream[TrackNumber].ContentCompSettings_Buffer, (size_t)Stream[TrackNumber].ContentCompSettings_Buffer_Size, ContentType_MainStream);
+ }
+
+ //Parsing
+ Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset), ContentType_MainStream);
+ Open_Buffer_Continue(Stream[TrackNumber].Parser, (size_t)Laces[Pos]);
+ if (Stream[TrackNumber].Parser->Status[IsFilled]
+ || Stream[TrackNumber].Parser->Status[IsFinished]
+ || Stream[TrackNumber].PacketCount>=300)
+ Stream[TrackNumber].Searching_Payload=false;
+ }
+ else
+ Skip_XX(Laces[Pos], "Data");
+ }
+
+ //Positionning
+ Element_Offset=Element_Size;
+ FILLING_END();
+ }
+ else
+ {
+ Skip_XX(Element_Size-Element_Offset, "Data");
+ }
+
+ //Filling
+ if (!Stream[TrackNumber].Searching_Payload && !Stream[TrackNumber].Searching_TimeStamps && !Stream[TrackNumber].Searching_TimeStamp_Start)
+ Stream_Count--;
+ if (Stream_Count==0)
+ {
+ //Jumping
+ std::sort(Segment_Seeks.begin(), Segment_Seeks.end());
+ for (size_t Pos=0; Pos<Segment_Seeks.size(); Pos++)
+ if (Segment_Seeks[Pos]>File_Offset+Buffer_Offset+Element_Size)
+ {
+ GoTo(Segment_Seeks[Pos]);
+ break;
+ }
+ if (File_GoTo==(int64u)-1)
+ GoTo(Segment_Offset_End);
+ }
+
+ Element_Show(); //For debug
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_BlockAdditions()
+{
+ Element_Name("BlockAdditions");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_BlockAdditions_BlockMore()
+{
+ Element_Name("BlockMore");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_BlockAdditions_BlockMore_BlockAddID()
+{
+ Element_Name("BlockAddID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_BlockAdditions_BlockMore_BlockAdditional()
+{
+ Element_Name("BlockAdditional");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_BlockDuration()
+{
+ Element_Name("BlockDuration");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_ReferenceBlock()
+{
+ Element_Name("ReferenceBlock");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_ReferencePriority()
+{
+ Element_Name("ReferencePriority");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_Slices()
+{
+ Element_Name("Slices");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_Slices_TimeSlice()
+{
+ Element_Name("TimeSlice");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_Slices_TimeSlice_Duration()
+{
+ Element_Name("Duration");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_BlockGroup_Slices_TimeSlice_LaceNumber()
+{
+ Element_Name("LaceNumber");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_Position()
+{
+ Element_Name("Position");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_PrevSize()
+{
+ Element_Name("PrevSize");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_SilentTracks()
+{
+ Element_Name("SilentTracks");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_SilentTracks_SilentTrackNumber()
+{
+ Element_Name("SilentTrackNumber");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_SimpleBlock()
+{
+ Segment_Cluster_BlockGroup_Block();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cluster_Timecode()
+{
+ Element_Name("Timecode");
+
+ //Parsing
+ Segment_Cluster_TimeCode_Value=UInteger_Get();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cues()
+{
+ Element_Name("Cues");
+
+ //Skipping Cues, we don't need of them
+ Skip_XX(Element_TotalSize_Get(), "Cues data, skipping");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cues_CuePoint()
+{
+ Element_Name("CuePoint");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cues_CuePoint_CueTime()
+{
+ Element_Name("CueTime");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cues_CuePoint_CueTrackPositions()
+{
+ Element_Name("CueTrackPositions");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cues_CuePoint_CueTrackPositions_CueTrack()
+{
+ Element_Name("CueTrack");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cues_CuePoint_CueTrackPositions_CueClusterPosition()
+{
+ Element_Name("CueClusterPosition");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Cues_CuePoint_CueTrackPositions_CueBlockNumber()
+{
+ Element_Name("CueBlockNumber");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info()
+{
+ Element_Name("Info");
+
+ if (Cluster_AlreadyParsed)
+ Skip_XX(Element_TotalSize_Get(), "Alreadys parsed, skipping");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_ChapterTranslate()
+{
+ Element_Name("ChapterTranslate");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_ChapterTranslate_ChapterTranslateCodec()
+{
+ Element_Name("ChapterTranslateCodec");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_ChapterTranslate_ChapterTranslateEditionUID()
+{
+ Element_Name("ChapterTranslateEditionUID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_ChapterTranslate_ChapterTranslateID()
+{
+ Element_Name("ChapterTranslateID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_DateUTC()
+{
+ Element_Name("DateUTC");
+
+ //Parsing
+ int64u Data;
+ Get_B8(Data, "Data"); Element_Info1(Data/1000000000+978307200); //From Beginning of the millenium, in nanoseconds
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, "Encoded_Date", Ztring().Date_From_Seconds_1970((int32u)(Data/1000000000+978307200))); //978307200s between beginning of the millenium and 1970
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_Duration()
+{
+ Element_Name("Duration");
+
+ //Parsing
+ float64 Float=Float_Get();
+
+ FILLING_BEGIN();
+ Duration=Float;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_MuxingApp()
+{
+ Element_Name("MuxingApp");
+
+ //Parsing
+ Ztring Data=UTF8_Get();
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, "Encoded_Library", Data);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_NextFilename()
+{
+ Element_Name("NextFilename");
+
+ //Parsing
+ UTF8_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_NextUID()
+{
+ Element_Name("NextUID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_PrevFilename()
+{
+ Element_Name("PrevFilename");
+
+ //Parsing
+ UTF8_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_PrevUID()
+{
+ Element_Name("PrevUID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_SegmentFamily()
+{
+ Element_Name("SegmentFamily");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_SegmentFilename()
+{
+ Element_Name("SegmentFilename");
+
+ //Parsing
+ UTF8_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_SegmentUID()
+{
+ Element_Name("SegmentUID");
+
+ //Parsing
+ int128u Data;
+ Data=UInteger16_Get();
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_UniqueID, Ztring().From_Local(Data.toString(10)));
+ Fill(Stream_General, 0, General_UniqueID_String, Ztring().From_Local(Data.toString(10))+_T(" (0x")+Ztring().From_Local(Data.toString(16))+_T(')'));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_TimecodeScale()
+{
+ Element_Name("TimecodeScale");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ FILLING_BEGIN();
+ TimecodeScale=UInteger;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_Title()
+{
+ Element_Name("Title");
+
+ //Parsing
+ Ztring Data=UTF8_Get();
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, "Title", Data);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Info_WritingApp()
+{
+ Element_Name("WritingApp");
+
+ //Parsing
+ Ztring Data=UTF8_Get();
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, "Encoded_Application", Data);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_SeekHead()
+{
+ Element_Name("SeekHead");
+
+ Segment_Seeks.clear();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_SeekHead_Seek()
+{
+ Element_Name("Seek");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_SeekHead_Seek_SeekID()
+{
+ Element_Name("SeekID");
+
+ //Parsing
+ int64u Data;
+ Get_EB (Data, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_SeekHead_Seek_SeekPosition()
+{
+ Element_Name("SeekPosition");
+
+ //Parsing
+ int64u Data=UInteger_Get();
+
+ Segment_Seeks.push_back(Segment_Offset_Begin+Data);
+ Element_Info1(Ztring::ToZtring(Segment_Offset_Begin+Data, 16));
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags()
+{
+ Element_Name("Tags");
+
+ Segment_Tag_SimpleTag_TagNames.clear();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag()
+{
+ Element_Name("Tag");
+
+ Segment_Tag_TrackUID=(int64u)-1;
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_SimpleTag()
+{
+ Element_Name("SimpleTag");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_SimpleTag_TagBinary()
+{
+ Element_Name("TagBinary");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_SimpleTag_TagDefault()
+{
+ Element_Name("TagDefault");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_SimpleTag_TagLanguage()
+{
+ Element_Name("TagLanguage");
+
+ //Parsing
+ Ztring Data;
+ Get_Local(Element_Size, Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ //Fill(StreamKind_Last, StreamPos_Last, "Language", Data);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_SimpleTag_TagName()
+{
+ Element_Name("TagName");
+
+ //Parsing
+ Ztring TagName=UTF8_Get();
+
+ Segment_Tag_SimpleTag_TagNames.resize(Element_Level-5); //5 is the first level of a tag
+ Segment_Tag_SimpleTag_TagNames.push_back(TagName);
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_SimpleTag_TagString()
+{
+ Element_Name("TagString");
+
+ //Parsing
+ Ztring TagString;
+ TagString=UTF8_Get();
+
+ if (Segment_Tag_SimpleTag_TagNames.empty())
+ return;
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("BITSPS")) return; //Useless
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("BPS")) return; //Useless
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("COMPATIBLE_BRANDS")) return; //QuickTime techinical info, useless
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("CREATION_TIME")) {Segment_Tag_SimpleTag_TagNames[0]=_T("Encoded_Date"); TagString.insert(0, _T("UTC "));}
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("DATE_DIGITIZED")) {Segment_Tag_SimpleTag_TagNames[0]=_T("Mastered_Date"); TagString.insert(0, _T("UTC "));}
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("ENCODED_BY")) Segment_Tag_SimpleTag_TagNames[0]=_T("EncodedBy");
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("ENCODER")) Segment_Tag_SimpleTag_TagNames[0]=_T("Encoded_Library");
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("FPS")) return; //Useless
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("LANGUAGE")) Segment_Tag_SimpleTag_TagNames[0]=_T("Language");
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("MAJOR_BRAND")) return; //QuickTime techinical info, useless
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("MINOR_VERSION")) return; //QuickTime techinical info, useless
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("ORIGINAL_MEDIA_TYPE")) Segment_Tag_SimpleTag_TagNames[0]=_T("OriginalSourceForm");
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("STEREO_MODE")) return; //Useless
+ if (Segment_Tag_SimpleTag_TagNames[0]==_T("TERMS_OF_USE")) Segment_Tag_SimpleTag_TagNames[0]=_T("TermsOfUse");
+ for (size_t Pos=1; Pos<Segment_Tag_SimpleTag_TagNames.size(); Pos++)
+ {
+ if (Segment_Tag_SimpleTag_TagNames[Pos]==_T("BARCODE")) Segment_Tag_SimpleTag_TagNames[Pos]=_T("BarCode");
+ if (Segment_Tag_SimpleTag_TagNames[Pos]==_T("COMMENT")) Segment_Tag_SimpleTag_TagNames[Pos]=_T("Comment");
+ if (Segment_Tag_SimpleTag_TagNames[Pos]==_T("URL")) Segment_Tag_SimpleTag_TagNames[Pos]=_T("Url");
+ }
+
+ Ztring TagName;
+ for (size_t Pos=0; Pos<Segment_Tag_SimpleTag_TagNames.size(); Pos++)
+ {
+ TagName+=Segment_Tag_SimpleTag_TagNames[Pos];
+ if (Pos+1<Segment_Tag_SimpleTag_TagNames.size())
+ TagName+=_T('/');
+ }
+
+ StreamKind_Last=Stream_General;
+ StreamPos_Last=0;
+ if (Segment_Tag_TrackUID!=(int64u)-1 && Segment_Tag_TrackUID!=0)//0: Specs say this is for all tracks, but I prefer to wait for a sample in order to see how it is used in the reality
+ {
+ Ztring ID=Ztring::ToZtring(Segment_Tag_TrackUID);
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Count_Get((stream_t)StreamKind); StreamPos++)
+ if (Retrieve((stream_t)StreamKind, StreamPos, General_ID)==ID)
+ {
+ StreamKind_Last=(stream_t)StreamKind;
+ StreamPos_Last=StreamPos;
+ }
+ }
+
+ Fill(StreamKind_Last, StreamPos_Last, TagName.To_Local().c_str(), TagString, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_Targets()
+{
+ Element_Name("Targets");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_Targets_AttachmentUID()
+{
+ Element_Name("AttachmentUID");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_Targets_ChapterUID()
+{
+ Element_Name("ChapterUID");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_Targets_EditionUID()
+{
+ Element_Name("EditionUID");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_Targets_TargetType()
+{
+ Element_Name("TargetType");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_Targets_TargetTypeValue()
+{
+ Element_Name("TargetTypeValue");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tags_Tag_Targets_TrackUID()
+{
+ Element_Name("TrackUID");
+
+ //Parsing
+ Segment_Tag_TrackUID=UInteger_Get();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks()
+{
+ Element_Name("Tracks");
+
+ if (Cluster_AlreadyParsed)
+ Skip_XX(Element_TotalSize_Get(), "Alreadys parsed, skipping");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry()
+{
+ Element_Name("TrackEntry");
+
+ //Clearing
+ CodecID.clear();
+ InfoCodecID_Format_Type=InfoCodecID_Format_Matroska;
+ TrackType=(int64u)-1;
+ TrackNumber=(int64u)-1;
+ TrackDefaultDuration=0;
+ TrackVideoDisplayWidth=0;
+ TrackVideoDisplayHeight=0;
+ AvgBytesPerSec=0;
+
+ //Preparing
+ Stream_Prepare(Stream_Max);
+
+ //Default values
+ Fill_Flush();
+ Fill(StreamKind_Last, StreamPos_Last, "Language", "eng");
+ Fill(StreamKind_Last, StreamPos_Last, "StreamOrder", Stream.size());
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_AttachmentLink()
+{
+ Element_Name("AttachmentLink");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Audio()
+{
+ Element_Name("Audio");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Audio_BitDepth()
+{
+ Element_Name("BitDepth");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ FILLING_BEGIN();
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", UInteger, 10, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Audio_Channels()
+{
+ Element_Name("Channels");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ FILLING_BEGIN();
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, UInteger, 10, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Audio_OutputSamplingFrequency()
+{
+ Element_Name("OutputSamplingFrequency");
+
+ //Parsing
+ float64 Float=Float_Get();
+
+ FILLING_BEGIN();
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, Float, 0, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Audio_SamplingFrequency()
+{
+ Element_Name("SamplingFrequency");
+
+ //Parsing
+ float64 Float=Float_Get();
+
+ FILLING_BEGIN();
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, Float, 0, true);
+ if (Retrieve(Stream_Audio, StreamPos_Last, Audio_CodecID).find(_T("A_AAC/"))==0)
+ ((File_Aac*)Stream[TrackNumber].Parser)->AudioSpecificConfig_OutOfBand((int32u)float64_int64s(Float));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_CodecDecodeAll()
+{
+ Element_Name("CodecDecodeAll");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_CodecID()
+{
+ Element_Name("CodecID");
+
+ //Parsing
+ Ztring Data;
+ Get_Local(Element_Size, Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ CodecID=Data;
+ CodecID_Manage();
+ CodecPrivate_Manage();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression()
+{
+ FILLING_BEGIN();
+ Stream[TrackNumber].ContentCompAlgo=0; //0 is default
+ Fill(StreamKind_Last, StreamPos_Last, "MuxingMode", Mk_ContentCompAlgo(0), Unlimited, true, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression_ContentCompAlgo()
+{
+ //Parsing
+ int64u Algo=UInteger_Get(); Param_Info1(Mk_ContentCompAlgo(Algo));
+
+ FILLING_BEGIN();
+ Stream[TrackNumber].ContentCompAlgo=Algo;
+ Fill(StreamKind_Last, StreamPos_Last, "MuxingMode", Mk_ContentCompAlgo(Algo), Unlimited, true, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression_ContentCompSettings()
+{
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+
+ FILLING_BEGIN();
+ Stream[TrackNumber].ContentCompSettings_Buffer=new int8u[(size_t)Element_Size];
+ std::memcpy(Stream[TrackNumber].ContentCompSettings_Buffer, Buffer+Buffer_Offset, (size_t)Element_Size);
+ Stream[TrackNumber].ContentCompSettings_Buffer_Size=(size_t)Element_Size;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_CodecName()
+{
+ Element_Name("CodecName");
+
+ //Parsing
+ UTF8_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_CodecPrivate()
+{
+ Element_Name("CodecPrivate");
+
+ //Creating the parser
+ if (Stream.find(TrackNumber)==Stream.end() || Stream[TrackNumber].Parser==NULL)
+ {
+ if (Stream.find(TrackNumber)==Stream.end() || Retrieve(Stream[TrackNumber].StreamKind, Stream[TrackNumber].StreamPos, "CodecID").empty())
+ {
+ //Codec not already known, saving CodecPrivate
+ if (CodecPrivate)
+ delete[] CodecPrivate; //CodecPrivate=NULL.
+ CodecPrivate_Size=(size_t)Element_Size;
+ CodecPrivate=new int8u[(size_t)Element_Size];
+ std::memcpy(CodecPrivate, Buffer+Buffer_Offset, (size_t)Element_Size);
+ return;
+ }
+
+ if (Stream[TrackNumber].StreamKind==Stream_Audio && Retrieve(Stream_Audio, Stream[TrackNumber].StreamPos, Audio_CodecID)==_T("A_MS/ACM"))
+ Segment_Tracks_TrackEntry_CodecPrivate_auds();
+ else if (Stream[TrackNumber].StreamKind==Stream_Video && Retrieve(Stream_Video, Stream[TrackNumber].StreamPos, Video_CodecID)==_T("V_MS/VFW/FOURCC"))
+ Segment_Tracks_TrackEntry_CodecPrivate_vids();
+ else if (Element_Size>0)
+ Skip_XX(Element_Size, "Unknown");
+ return;
+ }
+
+ //Parsing
+ Open_Buffer_Continue(Stream[TrackNumber].Parser);
+
+ //Filling
+ if (Stream[TrackNumber].Parser->Status[IsFinished]) //Can be finnished here...
+ {
+ Stream[TrackNumber].Searching_Payload=false;
+ Stream_Count--;
+ }
+
+ //In case of problem
+ Element_Show();
+}
+
+//--------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_CodecPrivate_auds()
+{
+ Element_Info1("Copy of auds");
+
+ //Parsing
+ int32u SamplesPerSec;
+ int16u FormatTag, Channels, BitsPerSample;
+ Get_L2 (FormatTag, "FormatTag");
+ Get_L2 (Channels, "Channels");
+ Get_L4 (SamplesPerSec, "SamplesPerSec");
+ Get_L4 (AvgBytesPerSec, "AvgBytesPerSec");
+ Skip_L2( "BlockAlign");
+ Get_L2 (BitsPerSample, "BitsPerSample");
+
+ //Filling
+ FILLING_BEGIN()
+ InfoCodecID_Format_Type=InfoCodecID_Format_Riff;
+ CodecID.From_Number(FormatTag, 16);
+ CodecID_Fill(CodecID, Stream_Audio, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, CodecID, true); //May be replaced by codec parser
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec_CC, CodecID);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels!=5?Channels:6, 10, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, SamplesPerSec, 10, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate, AvgBytesPerSec*8, 10, true);
+ if (BitsPerSample)
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, BitsPerSample);
+
+ CodecID_Manage();
+ if (TrackNumber!=(int64u)-1)
+ Stream[TrackNumber].AvgBytesPerSec=AvgBytesPerSec;
+ FILLING_END();
+
+ //Options
+ if (Element_Offset+2>Element_Size)
+ return; //No options
+
+ //Parsing
+ int16u Option_Size;
+ Get_L2 (Option_Size, "cbSize");
+
+ //Filling
+ if (Option_Size>0)
+ {
+ if (FormatTag==0xFFFE) //Extensible Wave
+ Segment_Tracks_TrackEntry_CodecPrivate_auds_ExtensibleWave();
+ else Skip_XX(Option_Size, "Unknown");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_CodecPrivate_auds_ExtensibleWave()
+{
+ //Parsing
+ int128u SubFormat;
+ int32u ChannelMask;
+ Skip_L2( "ValidBitsPerSample / SamplesPerBlock");
+ Get_L4 (ChannelMask, "ChannelMask");
+ Get_GUID(SubFormat, "SubFormat");
+
+ FILLING_BEGIN();
+ if ((SubFormat.hi&0xFFFFFFFFFFFF0000LL)==0x0010000000000000LL && SubFormat.lo==0x800000AA00389B71LL)
+ {
+ CodecID_Fill(Ztring().From_Number((int16u)SubFormat.hi, 16), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Audio, StreamPos_Last, Audio_CodecID, Ztring().From_GUID(SubFormat), true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, MediaInfoLib::Config.Codec_Get(Ztring().From_Number((int16u)SubFormat.hi, 16)), true);
+
+ //Creating the parser
+ #if defined(MEDIAINFO_PCM_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Riff, Ztring().From_Number((int16u)SubFormat.hi, 16))==_T("PCM"))
+ {
+ //Creating the parser
+ File_Pcm MI;
+ MI.Codec=Ztring().From_Number((int16u)SubFormat.hi, 16);
+
+ //Parsing
+ Open_Buffer_Init(&MI);
+ Open_Buffer_Continue(&MI, 0);
+
+ //Filling
+ Finish(&MI);
+ Merge(MI, StreamKind_Last, 0, StreamPos_Last);
+ }
+ #endif
+ }
+ else
+ {
+ CodecID_Fill(Ztring().From_GUID(SubFormat), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Riff);
+ }
+ Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions, ExtensibleWave_ChannelMask(ChannelMask));
+ Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions_String2, ExtensibleWave_ChannelMask2(ChannelMask));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_CodecPrivate_vids()
+{
+ Element_Info1("Copy of vids");
+
+ //Parsing
+ int32u Width, Height, Compression;
+ int16u Resolution;
+ Skip_L4( "Size");
+ Get_L4 (Width, "Width");
+ Get_L4 (Height, "Height");
+ Skip_L2( "Planes");
+ Get_L2 (Resolution, "BitCount");
+ Get_C4 (Compression, "Compression");
+ Skip_L4( "SizeImage");
+ Skip_L4( "XPelsPerMeter");
+ Skip_L4( "YPelsPerMeter");
+ Skip_L4( "ClrUsed");
+ Skip_L4( "ClrImportant");
+
+ FILLING_BEGIN()
+ Ztring Codec;
+ if (((Compression&0x000000FF)>=0x00000020 && (Compression&0x000000FF)<=0x0000007E
+ && (Compression&0x0000FF00)>=0x00002000 && (Compression&0x0000FF00)<=0x00007E00
+ && (Compression&0x00FF0000)>=0x00200000 && (Compression&0x00FF0000)<=0x007E0000
+ && (Compression&0xFF000000)>=0x20000000 && (Compression&0xFF000000)<=0x7E000000)
+ || Compression==0x00000000
+ ) //Sometimes this value is wrong, we have to test this
+ {
+ //Filling
+ InfoCodecID_Format_Type=InfoCodecID_Format_Riff;
+ CodecID.From_CC4(Compression);
+ if (Compression==0x00000000)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Format, "RGB", Unlimited, true, true);
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, "RGB", Unlimited, true, true); //Raw RGB, not handled by automatic codec mapping
+ }
+ else
+ {
+ CodecID_Fill(CodecID, Stream_Video, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, CodecID, true); //FormatTag, may be replaced by codec parser
+ Fill(Stream_Video, StreamPos_Last, Video_Codec_CC, CodecID); //FormatTag
+ }
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Width, 10, true);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Height, 10, true);
+ if (Resolution==32 && Compression==0x74736363) //tscc
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", 8);
+ else if (Compression==0x44495633) //DIV3
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", 8);
+ else if (Compression==0x44585342) //DXSB
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", Resolution);
+ else if (Resolution>16 && MediaInfoLib::Config.CodecID_Get(StreamKind_Last, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_ColorSpace).find(_T("RGBA"))!=std::string::npos) //RGB codecs
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", Resolution/4);
+ else if (Compression==0x00000000 //RGB
+ || MediaInfoLib::Config.CodecID_Get(StreamKind_Last, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_ColorSpace).find(_T("RGB"))!=std::string::npos) //RGB codecs
+ {
+ if (Resolution==32)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "RGBA", Unlimited, true, true);
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", Resolution/4); //With Alpha
+ }
+ else
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", Resolution<=16?8:(Resolution/3)); //indexed or normal
+ }
+ else if (Compression==0x56503632 //VP62
+ || MediaInfoLib::Config.CodecID_Get(StreamKind_Last, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_Format)==_T("H.263") //H.263
+ || MediaInfoLib::Config.CodecID_Get(StreamKind_Last, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_Format)==_T("VC-1")) //VC-1
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", Resolution/3);
+ }
+
+ //Creating the parser
+ CodecID_Manage();
+
+ FILLING_END()
+
+ if (Data_Remain())
+ {
+ Element_Begin1("Private data");
+ if (Stream[TrackNumber].Parser)
+ Open_Buffer_Continue(Stream[TrackNumber].Parser);
+ else
+ Skip_XX(Data_Remain(), "Unknown");
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_DefaultDuration()
+{
+ Element_Name("DefaultDuration");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ FILLING_BEGIN();
+ TrackDefaultDuration=UInteger;
+ //FrameRate
+ if (TrackDefaultDuration && StreamKind_Last==Stream_Video)
+ {
+ float64 FrameRate=1000000000.0/TrackDefaultDuration;
+ if (FrameRate>=23.975 && FrameRate<=23.977)
+ FrameRate=23.976; //One example was seen with 23.975
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, FrameRate, 3, true);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_FlagDefault()
+{
+ Element_Name("FlagDefault");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ FILLING_BEGIN();
+ Stream[TrackNumber].Default=UInteger?true:false;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_FlagEnabled()
+{
+ Element_Name("FlagEnabled");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_FlagForced()
+{
+ Element_Name("FlagForced");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ FILLING_BEGIN();
+ Stream[TrackNumber].Forced=UInteger?true:false;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_FlagLacing()
+{
+ Element_Name("FlagLacing");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Language()
+{
+ Element_Name("Language");
+
+ //Parsing
+ Ztring Data;
+ Get_Local(Element_Size, Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Fill(StreamKind_Last, StreamPos_Last, "Language", Data, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_MaxBlockAdditionID()
+{
+ Element_Name("MaxBlockAdditionID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_MaxCache()
+{
+ Element_Name("MaxCache");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_MinCache()
+{
+ Element_Name("MinCache");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Name()
+{
+ Element_Name("Name");
+
+ //Parsing
+ Ztring Data;
+ Get_UTF8(Element_Size, Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Fill(StreamKind_Last, StreamPos_Last, "Title", Data);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_TrackNumber()
+{
+ Element_Name("TrackNumber");
+
+ //Parsing
+ TrackNumber=UInteger_Get();
+
+ FILLING_BEGIN();
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, TrackNumber);
+ if (StreamKind_Last!=Stream_Max)
+ {
+ Stream[TrackNumber].StreamKind=StreamKind_Last;
+ Stream[TrackNumber].StreamPos=StreamPos_Last;
+ }
+ if (TrackVideoDisplayWidth && TrackVideoDisplayHeight)
+ Stream[TrackNumber].DisplayAspectRatio=((float)TrackVideoDisplayWidth)/(float)TrackVideoDisplayHeight;
+ if (AvgBytesPerSec)
+ Stream[TrackNumber].AvgBytesPerSec=AvgBytesPerSec;
+
+ CodecID_Manage();
+ CodecPrivate_Manage();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_TrackTimecodeScale()
+{
+ Element_Name("TrackTimecodeScale");
+
+ Float_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_TrackType()
+{
+ Element_Name("TrackType");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ //Filling
+ FILLING_BEGIN();
+ TrackType=UInteger;
+ switch(UInteger)
+ {
+ case 0x01 :
+ Stream_Prepare(Stream_Video);
+ //FrameRate
+ if (TrackDefaultDuration)
+ {
+ float64 FrameRate=1000000000.0/TrackDefaultDuration;
+ if (FrameRate>=23.975 && FrameRate<=23.977)
+ FrameRate=23.976; //One example was seen with 23.975
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, FrameRate, 3, true);
+ }
+ break;
+ case 0x02 :
+ Stream_Prepare(Stream_Audio);
+ break;
+ case 0x11 :
+ Stream_Prepare(Stream_Text );
+ break;
+ default : ;
+ }
+
+ if (TrackNumber!=(int64u)-1 && StreamKind_Last!=Stream_Max)
+ {
+ Stream[TrackNumber].StreamKind=StreamKind_Last;
+ Stream[TrackNumber].StreamPos=StreamPos_Last;
+ }
+
+ CodecID_Manage();
+ CodecPrivate_Manage();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_TrackUID()
+{
+ Element_Name("TrackUID");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ //Filling
+ FILLING_BEGIN();
+ Fill(StreamKind_Last, StreamPos_Last, General_UniqueID, UInteger);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video()
+{
+ Element_Name("Video");
+
+ //Preparing
+ TrackVideoDisplayWidth=0;
+ TrackVideoDisplayHeight=0;
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_AspectRatioType()
+{
+ Element_Name("AspectRatioType");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_ColourSpace()
+{
+ Element_Name("ColourSpace");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_DisplayHeight()
+{
+ Element_Name("DisplayHeight");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ //Filling
+ FILLING_BEGIN();
+ TrackVideoDisplayHeight=UInteger;
+ if (TrackNumber!=(int64u)-1 && TrackVideoDisplayWidth && TrackVideoDisplayHeight)
+ Stream[TrackNumber].DisplayAspectRatio=((float)TrackVideoDisplayWidth)/(float)TrackVideoDisplayHeight;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_DisplayUnit()
+{
+ Element_Name("DisplayUnit");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_DisplayWidth()
+{
+ Element_Name("DisplayWidth");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ //Filling
+ FILLING_BEGIN();
+ TrackVideoDisplayWidth=UInteger;
+ if (TrackNumber!=(int64u)-1 && TrackVideoDisplayWidth && TrackVideoDisplayHeight)
+ Stream[TrackNumber].DisplayAspectRatio=((float)TrackVideoDisplayWidth)/(float)TrackVideoDisplayHeight;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_FlagInterlaced()
+{
+ Element_Name("FlagInterlaced");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_FrameRate()
+{
+ Element_Name("FrameRate");
+
+ //Parsing
+ float64 Value=Float_Get();
+
+ //Filling
+ FILLING_BEGIN();
+ Stream[TrackNumber].FrameRate=Value;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_PixelCropBottom()
+{
+ Element_Name("PixelCropBottom");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_PixelCropLeft()
+{
+ Element_Name("PixelCropLeft");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_PixelCropRight()
+{
+ Element_Name("PixelCropRight");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_PixelCropTop()
+{
+ Element_Name("PixelCropTop");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_PixelHeight()
+{
+ Element_Name("PixelHeight");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ //Filling
+ FILLING_BEGIN();
+ Fill(Stream_Video, StreamPos_Last, Video_Height, UInteger, 10, true);
+ if (!TrackVideoDisplayHeight)
+ TrackVideoDisplayHeight=UInteger; //Default value of DisplayHeight is PixelHeight
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_PixelWidth()
+{
+ Element_Name("PixelWidth");
+
+ //Parsing
+ int64u UInteger=UInteger_Get();
+
+ //Filling
+ FILLING_BEGIN();
+ Fill(Stream_Video, StreamPos_Last, Video_Width, UInteger, 10, true);
+ if (!TrackVideoDisplayWidth)
+ TrackVideoDisplayWidth=UInteger; //Default value of DisplayWidth is PixelWidth
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_Video_StereoMode()
+{
+ Element_Name("StereoMode");
+
+ //Parsing
+ int64u UInteger=UInteger_Get(); Element_Info1(Format_Version==2?Mk_StereoMode_v2(UInteger):Mk_StereoMode(UInteger));
+
+ //Filling
+ FILLING_BEGIN();
+ Fill(Stream_Video, StreamPos_Last, Video_MultiView_Count, 2); //Matroska seems to be limited to 2 views
+ Fill(Stream_Video, StreamPos_Last, Video_MultiView_Layout, Format_Version==2?Mk_StereoMode_v2(UInteger):Mk_StereoMode(UInteger));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_TrackOverlay()
+{
+ Element_Name("TrackOverlay");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_TrackTranslate()
+{
+ Element_Name("TrackTranslate");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_TrackTranslate_Codec()
+{
+ Element_Name("Codec");
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_TrackTranslate_EditionUID()
+{
+ Element_Name("EditionUID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Segment_Tracks_TrackEntry_TrackTranslate_TrackID()
+{
+ Element_Name("TrackID");
+
+ //Parsing
+ UInteger_Info();
+}
+
+//***************************************************************************
+// Data
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mk::UInteger_Info()
+{
+ switch (Element_Size)
+ {
+ case 1 :
+ {
+ Info_B1(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 2 :
+ {
+ Info_B2(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 3 :
+ {
+ Info_B3(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 4 :
+ {
+ Info_B4(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 5 :
+ {
+ Info_B5(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 6 :
+ {
+ Info_B6(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 7 :
+ {
+ Info_B7(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 8 :
+ {
+ Info_B8(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 16:
+ {
+ Info_B16(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ default : Skip_XX(Element_Size, "Data");
+ }
+}
+
+//---------------------------------------------------------------------------
+int64u File_Mk::UInteger_Get()
+{
+ switch (Element_Size)
+ {
+ case 1 :
+ {
+ int8u Data;
+ Get_B1 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 2 :
+ {
+ int16u Data;
+ Get_B2 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 3 :
+ {
+ int32u Data;
+ Get_B3 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 4 :
+ {
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 5 :
+ {
+ int64u Data;
+ Get_B5 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 6 :
+ {
+ int64u Data;
+ Get_B6 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 7 :
+ {
+ int64u Data;
+ Get_B7 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 8 :
+ {
+ int64u Data;
+ Get_B8 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ default : Skip_XX(Element_Size, "Data");
+ return 0;
+ }
+}
+
+//---------------------------------------------------------------------------
+int128u File_Mk::UInteger16_Get()
+{
+ switch (Element_Size)
+ {
+ case 1 :
+ {
+ int8u Data;
+ Get_B1 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 2 :
+ {
+ int16u Data;
+ Get_B2 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 3 :
+ {
+ int32u Data;
+ Get_B3 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 4 :
+ {
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 5 :
+ {
+ int64u Data;
+ Get_B5 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 6 :
+ {
+ int64u Data;
+ Get_B6 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 7 :
+ {
+ int64u Data;
+ Get_B7 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 8 :
+ {
+ int64u Data;
+ Get_B8 (Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 16:
+ {
+ int128u Data;
+ Get_B16(Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ default : Skip_XX(Element_Size, "Data");
+ return 0;
+ }
+}
+
+//---------------------------------------------------------------------------
+float64 File_Mk::Float_Get()
+{
+ switch (Element_Size)
+ {
+ case 4 :
+ {
+ float32 Data;
+ Get_BF4(Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ case 8 :
+ {
+ float64 Data;
+ Get_BF8(Data, "Data"); Element_Info1(Data);
+ return Data;
+ }
+ default : Skip_XX(Element_Size, "Data");
+ return 0.0;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Float_Info()
+{
+ switch (Element_Size)
+ {
+ case 4 :
+ {
+ Info_BF4(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ case 8 :
+ {
+ Info_BF8(Data, "Data"); Element_Info1(Data);
+ return;
+ }
+ default : Skip_XX(Element_Size, "Data");
+ return;
+ }
+}
+
+//---------------------------------------------------------------------------
+Ztring File_Mk::UTF8_Get()
+{
+ Ztring Data;
+ Get_UTF8(Element_Size, Data, "Data"); Element_Info1(Data);
+ return Data;
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::UTF8_Info()
+{
+ Info_UTF8(Element_Size, Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+Ztring File_Mk::Local_Get()
+{
+ Ztring Data;
+ Get_Local(Element_Size, Data, "Data"); Element_Info1(Data);
+ return Data;
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::Local_Info()
+{
+ Info_Local(Element_Size, Data, "Data"); Element_Info1(Data);
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mk::CodecID_Manage()
+{
+ if (TrackType==(int64u)-1 || TrackNumber==(int64u)-1 || CodecID.empty() || Stream[TrackNumber].Parser)
+ return; //Not ready (or not needed)
+
+ if (Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_CodecID)).empty())
+ {
+ CodecID_Fill(CodecID, StreamKind_Last, StreamPos_Last, InfoCodecID_Format_Matroska);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), CodecID);
+ }
+
+ //Creating the parser
+ const Ztring &Format=MediaInfoLib::Config.CodecID_Get(StreamKind_Last, InfoCodecID_Format_Type, CodecID, InfoCodecID_Format);
+ if (0);
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ else if (Format==_T("MPEG-4 Visual"))
+ {
+ Stream[TrackNumber].Parser=new File_Mpeg4v;
+ ((File_Mpeg4v*)Stream[TrackNumber].Parser)->FrameIsAlwaysComplete=true;
+ ((File_Mpeg4v*)Stream[TrackNumber].Parser)->Frame_Count_Valid=1;
+ }
+ #endif
+ #if defined(MEDIAINFO_AVC_YES)
+ else if (Format==_T("AVC"))
+ {
+ Stream[TrackNumber].Parser=new File_Avc;
+ ((File_Avc*)Stream[TrackNumber].Parser)->FrameIsAlwaysComplete=true;
+ if (InfoCodecID_Format_Type==InfoCodecID_Format_Matroska)
+ {
+ ((File_Avc*)Stream[TrackNumber].Parser)->MustSynchronize=false;
+ ((File_Avc*)Stream[TrackNumber].Parser)->MustParse_SPS_PPS=true;
+ ((File_Avc*)Stream[TrackNumber].Parser)->SizedBlocks=true;
+ }
+ }
+ #endif
+ #if defined(MEDIAINFO_VC1_YES)
+ else if (Format==_T("VC-1"))
+ {
+ Stream[TrackNumber].Parser=new File_Vc1;
+ ((File_Vc1*)Stream[TrackNumber].Parser)->FrameIsAlwaysComplete=true;
+ ((File_Vc1*)Stream[TrackNumber].Parser)->Frame_Count_Valid=1;
+ }
+ #endif
+ #if defined(MEDIAINFO_DIRAC_YES)
+ else if (Format==_T("Dirac"))
+ {
+ Stream[TrackNumber].Parser=new File_Dirac;
+ ((File_Dirac*)Stream[TrackNumber].Parser)->Frame_Count_Valid=1;
+ }
+ #endif
+ #if defined(MEDIAINFO_MPEGV_YES)
+ else if (Format==_T("MPEG Video"))
+ {
+ Stream[TrackNumber].Parser=new File_Mpegv;
+ ((File_Mpegv*)Stream[TrackNumber].Parser)->FrameIsAlwaysComplete=true;
+ ((File_Mpegv*)Stream[TrackNumber].Parser)->Frame_Count_Valid=1;
+ }
+ #endif
+ #if defined(MEDIAINFO_VP8_YES)
+ else if (Format==_T("VP8"))
+ {
+ Stream[TrackNumber].Parser=new File_Vp8;
+ }
+ #endif
+ #if defined(MEDIAINFO_OGG_YES)
+ else if (Format==_T("Theora") || Format==_T("Vorbis"))
+ {
+ Stream[TrackNumber].Parser=new File_Ogg;
+ Stream[TrackNumber].Parser->MustSynchronize=false;
+ ((File_Ogg*)Stream[TrackNumber].Parser)->XiphLacing=true;
+ }
+ #endif
+ #if defined(MEDIAINFO_RM_YES)
+ else if (CodecID.find(_T("V_REAL/"))==0)
+ {
+ Stream[TrackNumber].Parser=new File_Rm;
+ ((File_Rm*)Stream[TrackNumber].Parser)->FromMKV_StreamType=Stream_Video;
+ }
+ #endif
+ #if defined(MEDIAINFO_AC3_YES)
+ else if (Format==_T("AC-3") || Format==_T("E-AC-3") || Format==_T("TrueHD"))
+ {
+ Stream[TrackNumber].Parser=new File_Ac3;
+ ((File_Ac3*)Stream[TrackNumber].Parser)->Frame_Count_Valid=2;
+ }
+ #endif
+ #if defined(MEDIAINFO_DTS_YES)
+ else if (Format==_T("DTS"))
+ {
+ Stream[TrackNumber].Parser=new File_Dts;
+ ((File_Dts*)Stream[TrackNumber].Parser)->Frame_Count_Valid=2;
+ }
+ #endif
+ #if defined(MEDIAINFO_AAC_YES)
+ else if (CodecID==(_T("A_AAC")))
+ {
+ Stream[TrackNumber].Parser=new File_Aac;
+ ((File_Aac*)Stream[TrackNumber].Parser)->Mode=File_Aac::Mode_AudioSpecificConfig;
+ }
+ #endif
+ #if defined(MEDIAINFO_AAC_YES)
+ else if (CodecID.find(_T("A_AAC/"))==0)
+ {
+ Ztring Profile;
+ int8u audioObjectType=0, Version=0, SBR=2, PS=2;
+ if (CodecID==_T("A_AAC/MPEG2/MAIN")) {Version=2; Profile=_T("Main"); audioObjectType=1;}
+ else if (CodecID==_T("A_AAC/MPEG2/LC")) {Version=2; Profile=_T("LC"); audioObjectType=2; SBR=0;}
+ else if (CodecID==_T("A_AAC/MPEG2/LC/SBR")) {Version=2; Profile=_T("HE-AAC / LC"); audioObjectType=2; SBR=1;}
+ else if (CodecID==_T("A_AAC/MPEG2/SSR")) {Version=2; Profile=_T("SSR"); audioObjectType=3;}
+ else if (CodecID==_T("A_AAC/MPEG4/MAIN")) {Version=4; Profile=_T("Main"); audioObjectType=1;}
+ else if (CodecID==_T("A_AAC/MPEG4/LC")) {Version=4; Profile=_T("LC"); audioObjectType=2; SBR=0;}
+ else if (CodecID==_T("A_AAC/MPEG4/LC/SBR")) {Version=4; Profile=_T("HE-AAC / LC"); audioObjectType=2; SBR=1; PS=0;}
+ else if (CodecID==_T("A_AAC/MPEG4/LC/SBR/PS")){Version=4; Profile=_T("HE-AACv2 / HE-AAC / LC"); audioObjectType=2; SBR=1; PS=1;}
+ else if (CodecID==_T("A_AAC/MPEG4/SSR")) {Version=4; Profile=_T("SSR"); audioObjectType=3;}
+ else if (CodecID==_T("A_AAC/MPEG4/LTP")) {Version=4; Profile=_T("LTP"); audioObjectType=4;}
+ else if (CodecID==_T("raac")) { Profile=_T("LC"); audioObjectType=2;}
+ else if (CodecID==_T("racp")) { Profile=_T("HE-AAC / LC"); audioObjectType=2; SBR=1; PS=0;}
+
+ if (Version>0)
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Version, Version==2?"Version 2":"Version 4");
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, Profile);
+ if (SBR!=2)
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Settings_SBR, SBR?"Yes":"No");
+ if (PS!=2)
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Settings_PS, PS?"Yes":"No");
+ int32u sampling_frequency=Retrieve(Stream_Audio, StreamPos_Last, Audio_SamplingRate).To_int32u();
+
+ Stream[TrackNumber].Parser=new File_Aac;
+ ((File_Aac*)Stream[TrackNumber].Parser)->Mode=File_Aac::Mode_AudioSpecificConfig;
+ ((File_Aac*)Stream[TrackNumber].Parser)->AudioSpecificConfig_OutOfBand(sampling_frequency, audioObjectType, SBR==1?true:false, PS==1?true:false, SBR==1?true:false, PS==1?true:false);
+ }
+ #endif
+ #if defined(MEDIAINFO_AAC_YES)
+ else if (Format==(_T("AAC")))
+ {
+ Stream[TrackNumber].Parser=new File_Aac;
+ ((File_Aac*)Stream[TrackNumber].Parser)->Mode=File_Aac::Mode_ADTS;
+ }
+ #endif
+ #if defined(MEDIAINFO_MPEGA_YES)
+ else if (Format==_T("MPEG Audio"))
+ {
+ Stream[TrackNumber].Parser=new File_Mpega;
+ }
+ #endif
+ #if defined(MEDIAINFO_FLAC_YES)
+ else if (Format==_T("Flac"))
+ {
+ Stream[TrackNumber].Parser=new File_Flac;
+ }
+ #endif
+ #if defined(MEDIAINFO_WVPK_YES)
+ else if (Format==_T("WavPack"))
+ {
+ Stream[TrackNumber].Parser=new File_Wvpk;
+ ((File_Wvpk*)Stream[TrackNumber].Parser)->FromMKV=true;
+ }
+ #endif
+ #if defined(MEDIAINFO_TTA_YES)
+ else if (Format==_T("TTA"))
+ {
+ //Stream[TrackNumber].Parser=new File_Tta; //Parser is not needed, because header is useless and dropped (the parser analyses only the header)
+ }
+ #endif
+ #if defined(MEDIAINFO_PCM_YES)
+ else if (Format==_T("PCM"))
+ {
+ Stream[TrackNumber].Parser=new File_Pcm;
+ ((File_Pcm*)Stream[TrackNumber].Parser)->Codec=CodecID;
+ }
+ #endif
+ #if defined(MEDIAINFO_RM_YES)
+ else if (CodecID.find(_T("A_REAL/"))==0)
+ {
+ Stream[TrackNumber].Parser=new File_Rm;
+ ((File_Rm*)Stream[TrackNumber].Parser)->FromMKV_StreamType=Stream_Audio;
+ }
+ #endif
+ Open_Buffer_Init(Stream[TrackNumber].Parser);
+
+ CodecID.clear();
+}
+
+//---------------------------------------------------------------------------
+void File_Mk::CodecPrivate_Manage()
+{
+ if (CodecPrivate==NULL || TrackNumber==(int64u)-1 || TrackType==(int64u)-1)
+ return; //Not ready (or not needed)
+
+ //Codec Private is already here, so we can parse it now
+ const int8u* Buffer_Save=Buffer;
+ size_t Buffer_Offset_Save=Buffer_Offset;
+ size_t Buffer_Size_Save=Buffer_Size;
+ int64u Element_Size_Save=Element_Size;
+ Buffer=CodecPrivate;
+ Buffer_Offset=0;
+ Buffer_Size=CodecPrivate_Size;
+ Element_Offset=0;
+ Element_Size=Buffer_Size;
+ Segment_Tracks_TrackEntry_CodecPrivate();
+ Buffer=Buffer_Save;
+ Buffer_Offset=Buffer_Offset_Save;
+ Buffer_Size=Buffer_Size_Save;
+ Element_Size=Element_Size_Save;
+ Element_Offset=Element_Size_Save;
+ delete[] CodecPrivate; CodecPrivate=NULL;
+ CodecPrivate_Size=0;
+ Element_Name("(Multiple info)");
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_MK_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mk.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mk.h
new file mode 100644
index 000000000..31eb1d9b7
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mk.h
@@ -0,0 +1,354 @@
+// File_Mk - Info for Matroska Video/Audio files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Matroska files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_MatroskaH
+#define MediaInfo_File_MatroskaH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Classe File_Matroska
+//***************************************************************************
+
+class File_Mk : public File__Analyze
+{
+protected :
+ //Streams management
+ void Streams_Finish();
+
+public :
+ File_Mk();
+ ~File_Mk();
+
+private :
+ //Buffer
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Zero();
+ void CRC32();
+ void Void();
+ void Ebml();
+ void Ebml_Version();
+ void Ebml_ReadVersion();
+ void Ebml_MaxIDLength();
+ void Ebml_MaxSizeLength();
+ void Ebml_DocType();
+ void Ebml_DocTypeVersion();
+ void Ebml_DocTypeReadVersion();
+ void Segment();
+ void Segment_Attachements();
+ void Segment_Attachements_AttachedFile();
+ void Segment_Attachements_AttachedFile_FileData();
+ void Segment_Attachements_AttachedFile_FileDescription();
+ void Segment_Attachements_AttachedFile_FileName();
+ void Segment_Attachements_AttachedFile_FileMimeType();
+ void Segment_Attachements_AttachedFile_FileReferral();
+ void Segment_Attachements_AttachedFile_FileUID();
+ void Segment_Chapters();
+ void Segment_Chapters_EditionEntry();
+ void Segment_Chapters_EditionEntry_ChapterAtom();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCodecID();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand_ChapProcessData();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessCommand_ChapProcessTime();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapProcess_ChapProcessPrivate();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapCountry();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapLanguage();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterDisplay_ChapString();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterFlagHidden();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterFlagEnabled();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterPhysicalEquiv();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterSegmentEditionUID();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterSegmentUID();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterTimeEnd();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterTimeStart();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterTrack();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterTrack_ChapterTrackNumber();
+ void Segment_Chapters_EditionEntry_ChapterAtom_ChapterUID();
+ void Segment_Chapters_EditionEntry_EditionFlagDefault();
+ void Segment_Chapters_EditionEntry_EditionFlagHidden();
+ void Segment_Chapters_EditionEntry_EditionFlagOrdered();
+ void Segment_Chapters_EditionEntry_EditionUID();
+ void Segment_Cluster();
+ void Segment_Cluster_BlockGroup();
+ void Segment_Cluster_BlockGroup_Block();
+ void Segment_Cluster_BlockGroup_BlockAdditions();
+ void Segment_Cluster_BlockGroup_BlockAdditions_BlockMore();
+ void Segment_Cluster_BlockGroup_BlockAdditions_BlockMore_BlockAddID();
+ void Segment_Cluster_BlockGroup_BlockAdditions_BlockMore_BlockAdditional();
+ void Segment_Cluster_BlockGroup_BlockDuration();
+ void Segment_Cluster_BlockGroup_ReferenceBlock();
+ void Segment_Cluster_BlockGroup_ReferencePriority();
+ void Segment_Cluster_BlockGroup_Slices();
+ void Segment_Cluster_BlockGroup_Slices_TimeSlice();
+ void Segment_Cluster_BlockGroup_Slices_TimeSlice_Duration();
+ void Segment_Cluster_BlockGroup_Slices_TimeSlice_LaceNumber();
+ void Segment_Cluster_Position();
+ void Segment_Cluster_PrevSize();
+ void Segment_Cluster_SilentTracks();
+ void Segment_Cluster_SilentTracks_SilentTrackNumber();
+ void Segment_Cluster_SimpleBlock();
+ void Segment_Cluster_Timecode();
+ void Segment_Cues();
+ void Segment_Cues_CuePoint();
+ void Segment_Cues_CuePoint_CueTime();
+ void Segment_Cues_CuePoint_CueTrackPositions();
+ void Segment_Cues_CuePoint_CueTrackPositions_CueTrack();
+ void Segment_Cues_CuePoint_CueTrackPositions_CueClusterPosition();
+ void Segment_Cues_CuePoint_CueTrackPositions_CueBlockNumber();
+ void Segment_Info();
+ void Segment_Info_ChapterTranslate();
+ void Segment_Info_ChapterTranslate_ChapterTranslateCodec();
+ void Segment_Info_ChapterTranslate_ChapterTranslateEditionUID();
+ void Segment_Info_ChapterTranslate_ChapterTranslateID();
+ void Segment_Info_DateUTC();
+ void Segment_Info_Duration();
+ void Segment_Info_MuxingApp();
+ void Segment_Info_NextFilename();
+ void Segment_Info_NextUID();
+ void Segment_Info_PrevFilename();
+ void Segment_Info_PrevUID();
+ void Segment_Info_SegmentFamily();
+ void Segment_Info_SegmentFilename();
+ void Segment_Info_SegmentUID();
+ void Segment_Info_TimecodeScale();
+ void Segment_Info_Title();
+ void Segment_Info_WritingApp();
+ void Segment_SeekHead();
+ void Segment_SeekHead_Seek();
+ void Segment_SeekHead_Seek_SeekID();
+ void Segment_SeekHead_Seek_SeekPosition();
+ void Segment_Tags();
+ void Segment_Tags_Tag();
+ void Segment_Tags_Tag_SimpleTag();
+ void Segment_Tags_Tag_SimpleTag_TagBinary();
+ void Segment_Tags_Tag_SimpleTag_TagDefault();
+ void Segment_Tags_Tag_SimpleTag_TagLanguage();
+ void Segment_Tags_Tag_SimpleTag_TagName();
+ void Segment_Tags_Tag_SimpleTag_TagString();
+ void Segment_Tags_Tag_Targets();
+ void Segment_Tags_Tag_Targets_AttachmentUID();
+ void Segment_Tags_Tag_Targets_ChapterUID();
+ void Segment_Tags_Tag_Targets_EditionUID();
+ void Segment_Tags_Tag_Targets_TargetType();
+ void Segment_Tags_Tag_Targets_TargetTypeValue();
+ void Segment_Tags_Tag_Targets_TrackUID();
+ void Segment_Tracks();
+ void Segment_Tracks_TrackEntry();
+ void Segment_Tracks_TrackEntry_AttachmentLink();
+ void Segment_Tracks_TrackEntry_Audio();
+ void Segment_Tracks_TrackEntry_Audio_BitDepth();
+ void Segment_Tracks_TrackEntry_Audio_Channels();
+ void Segment_Tracks_TrackEntry_Audio_OutputSamplingFrequency();
+ void Segment_Tracks_TrackEntry_Audio_SamplingFrequency();
+ void Segment_Tracks_TrackEntry_CodecDecodeAll();
+ void Segment_Tracks_TrackEntry_CodecID();
+ void Segment_Tracks_TrackEntry_ContentEncodings() {};
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding() {};
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Order() {UInteger_Info();};
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Scope() {UInteger_Info();};
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Type() {UInteger_Info();};
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression();
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression_ContentCompAlgo();
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Compression_ContentCompSettings();
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption() {};
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentEncAlgo() {UInteger_Info();};
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentEncKeyID() {Skip_XX(Element_Size, "Data");};
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSignature() {Skip_XX(Element_Size, "Data");};
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSigKeyID() {Skip_XX(Element_Size, "Data");};
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSigAlgo() {UInteger_Info();};
+ void Segment_Tracks_TrackEntry_ContentEncodings_ContentEncoding_Encryption_ContentSigHashAlgo() {UInteger_Info();};
+ void Segment_Tracks_TrackEntry_CodecName();
+ void Segment_Tracks_TrackEntry_CodecPrivate();
+ void Segment_Tracks_TrackEntry_CodecPrivate_auds();
+ void Segment_Tracks_TrackEntry_CodecPrivate_auds_ExtensibleWave();
+ void Segment_Tracks_TrackEntry_CodecPrivate_vids();
+ void Segment_Tracks_TrackEntry_DefaultDuration();
+ void Segment_Tracks_TrackEntry_FlagDefault();
+ void Segment_Tracks_TrackEntry_FlagEnabled();
+ void Segment_Tracks_TrackEntry_FlagForced();
+ void Segment_Tracks_TrackEntry_FlagLacing();
+ void Segment_Tracks_TrackEntry_Language();
+ void Segment_Tracks_TrackEntry_MaxBlockAdditionID();
+ void Segment_Tracks_TrackEntry_MaxCache();
+ void Segment_Tracks_TrackEntry_MinCache();
+ void Segment_Tracks_TrackEntry_Name();
+ void Segment_Tracks_TrackEntry_TrackNumber();
+ void Segment_Tracks_TrackEntry_TrackTimecodeScale();
+ void Segment_Tracks_TrackEntry_TrackType();
+ void Segment_Tracks_TrackEntry_TrackUID();
+ void Segment_Tracks_TrackEntry_Video();
+ void Segment_Tracks_TrackEntry_Video_AspectRatioType();
+ void Segment_Tracks_TrackEntry_Video_ColourSpace();
+ void Segment_Tracks_TrackEntry_Video_DisplayHeight();
+ void Segment_Tracks_TrackEntry_Video_DisplayUnit();
+ void Segment_Tracks_TrackEntry_Video_DisplayWidth();
+ void Segment_Tracks_TrackEntry_Video_FlagInterlaced();
+ void Segment_Tracks_TrackEntry_Video_FrameRate();
+ void Segment_Tracks_TrackEntry_Video_PixelCropBottom();
+ void Segment_Tracks_TrackEntry_Video_PixelCropLeft();
+ void Segment_Tracks_TrackEntry_Video_PixelCropRight();
+ void Segment_Tracks_TrackEntry_Video_PixelCropTop();
+ void Segment_Tracks_TrackEntry_Video_PixelHeight();
+ void Segment_Tracks_TrackEntry_Video_PixelWidth();
+ void Segment_Tracks_TrackEntry_Video_StereoMode();
+ void Segment_Tracks_TrackEntry_Video_StereoModeBuggy() {Segment_Tracks_TrackEntry_Video_StereoMode();}
+ void Segment_Tracks_TrackEntry_TrackOverlay();
+ void Segment_Tracks_TrackEntry_TrackTranslate();
+ void Segment_Tracks_TrackEntry_TrackTranslate_Codec();
+ void Segment_Tracks_TrackEntry_TrackTranslate_EditionUID();
+ void Segment_Tracks_TrackEntry_TrackTranslate_TrackID();
+
+ struct stream
+ {
+ std::vector<int64u> TimeCodes;
+ int64u TimeCode_Start;
+ File__Analyze* Parser;
+ stream_t StreamKind;
+ size_t StreamPos;
+ size_t PacketCount;
+ int32u AvgBytesPerSec; //Only used by x_MS/* codecIDs
+ float32 DisplayAspectRatio;
+ float64 FrameRate;
+ bool Searching_Payload;
+ bool Searching_TimeStamps;
+ bool Searching_TimeStamp_Start;
+ bool Default;
+ bool Forced;
+ int64u ContentCompAlgo;
+ size_t ContentCompSettings_Buffer_Size;
+ int8u* ContentCompSettings_Buffer;
+ std::map<std::string, Ztring> Infos;
+
+ stream()
+ {
+ TimeCode_Start=(int64u)-1;
+ Parser=NULL;
+ StreamKind=Stream_Max;
+ StreamPos=0;
+ PacketCount=0;
+ AvgBytesPerSec=0;
+ DisplayAspectRatio=0;
+ FrameRate=0;
+ Searching_Payload=false;
+ Searching_TimeStamps=false;
+ Searching_TimeStamp_Start=false;
+ Default=true;
+ Forced=false;
+ ContentCompAlgo=(int32u)-1;
+ ContentCompSettings_Buffer_Size=0;
+ ContentCompSettings_Buffer=NULL;
+ }
+
+ ~stream()
+ {
+ delete Parser; //Parser=NULL;
+ delete ContentCompSettings_Buffer; //ContentCompSettings_Buffer=NULL;
+ }
+ };
+ std::map<int64u, stream> Stream;
+ size_t Stream_Count;
+
+ //Data
+ int64u UInteger_Get();
+ int128u UInteger16_Get();
+ void UInteger_Info();
+
+ float64 Float_Get();
+ void Float_Info();
+
+ Ztring UTF8_Get();
+ void UTF8_Info();
+
+ Ztring Local_Get();
+ void Local_Info();
+
+ //Temp - TrackEntry
+ int8u* CodecPrivate;
+ size_t CodecPrivate_Size;
+ void CodecPrivate_Manage();
+ Ztring CodecID;
+ infocodecid_format_t InfoCodecID_Format_Type;
+ void CodecID_Manage();
+ int64u TrackType;
+
+ //Temp
+ std::vector<Ztring> AttachedFiles;
+ int64u Format_Version;
+ int64u TimecodeScale;
+ float64 Duration;
+ int64u TrackNumber;
+ int64u TrackDefaultDuration;
+ int64u TrackVideoDisplayWidth;
+ int64u TrackVideoDisplayHeight;
+ int32u AvgBytesPerSec;
+ int64u Segment_Cluster_TimeCode_Value;
+ bool Cluster_AlreadyParsed;
+
+ //Chapters
+ struct chapterdisplay
+ {
+ Ztring ChapLanguage;
+ Ztring ChapString;
+ };
+ struct chapteratom
+ {
+ int64u ChapterTimeStart;
+ std::vector<chapterdisplay> ChapterDisplays;
+
+ chapteratom()
+ {
+ ChapterTimeStart=(int64u)-1;
+ }
+ };
+ struct editionentry
+ {
+ std::vector<chapteratom> ChapterAtoms;
+ };
+ std::vector<editionentry> EditionEntries;
+ size_t EditionEntries_Pos;
+ size_t ChapterAtoms_Pos;
+ size_t ChapterDisplays_Pos;
+ int64u Segment_Offset_Begin;
+ int64u Segment_Offset_End;
+ std::vector<int64u> Segment_Seeks;
+ int64u Segment_Tag_TrackUID;
+ std::vector<Ztring> Segment_Tag_SimpleTag_TagNames;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4.cpp
new file mode 100644
index 000000000..1c530ad43
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4.cpp
@@ -0,0 +1,1596 @@
+// File_Mpeg4 - Info for MPEG-4 files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Main part
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_MPEG4_YES
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Mpeg4.h"
+#include "MediaInfo/Multiple/File_Mpeg4_Descriptors.h"
+#if defined(MEDIAINFO_MPEGPS_YES)
+ #include "MediaInfo/Multiple/File_MpegPs.h"
+#endif
+#include "ZenLib/FileName.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#ifdef MEDIAINFO_REFERENCES_YES
+ #include "MediaInfo/Multiple/File__ReferenceFilesHelper.h"
+#endif //MEDIAINFO_REFERENCES_YES
+#include "ZenLib/Format/Http/Http_Utils.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Const
+//***************************************************************************
+
+namespace Elements
+{
+ const int64u free=0x66726565;
+ const int64u mdat=0x6D646174;
+ const int64u moov_meta______=0x2D2D2D2D;
+ const int64u moov_meta___ART=0xA9415254;
+ const int64u moov_meta___alb=0xA9616C62;
+ const int64u moov_meta___aut=0xA9617574;
+ const int64u moov_meta___cmt=0xA9636D74;
+ const int64u moov_meta___cpy=0xA9637079;
+ const int64u moov_meta___day=0xA9646179;
+ const int64u moov_meta___des=0xA9646573;
+ const int64u moov_meta___dir=0xA9646972;
+ const int64u moov_meta___dis=0xA9646973;
+ const int64u moov_meta___edl=0xA965646C;
+ const int64u moov_meta___enc=0xA9656E63;
+ const int64u moov_meta___fmt=0xA9666D74;
+ const int64u moov_meta___gen=0xA967656E;
+ const int64u moov_meta___grp=0xA9677270;
+ const int64u moov_meta___hos=0xA9686F73;
+ const int64u moov_meta___inf=0xA9696E66;
+ const int64u moov_meta___key=0xA96B6579;
+ const int64u moov_meta___mak=0xA96D616B;
+ const int64u moov_meta___mod=0xA96D6F64;
+ const int64u moov_meta___nam=0xA96E616D;
+ const int64u moov_meta___prd=0xA9707264;
+ const int64u moov_meta___PRD=0xA9505244;
+ const int64u moov_meta___prf=0xA9707266;
+ const int64u moov_meta___req=0xA9726571;
+ const int64u moov_meta___src=0xA9737263;
+ const int64u moov_meta___swr=0xA9737772;
+ const int64u moov_meta___too=0xA9746F6F;
+ const int64u moov_meta___wrn=0xA977726E;
+ const int64u moov_meta___wrt=0xA9777274;
+ const int64u moov_meta__aART=0x61415254;
+ const int64u moov_meta__albm=0x616C626D;
+ const int64u moov_meta__auth=0x61757468;
+ const int64u moov_meta__cpil=0x6370696C;
+ const int64u moov_meta__cprt=0x63707274;
+ const int64u moov_meta__covr=0x636F7672;
+ const int64u moov_meta__disk=0x6469736B;
+ const int64u moov_meta__dscp=0x64736370;
+ const int64u moov_meta__gnre=0x676E7265;
+ const int64u moov_meta__name=0x6E616D65;
+ const int64u moov_meta__perf=0x70657266;
+ const int64u moov_meta__pgap=0x70676170;
+ const int64u moov_meta__titl=0x7469746C;
+ const int64u moov_meta__tool=0x746F6F6C;
+ const int64u moov_meta__trkn=0x74726B6E;
+ const int64u moov_meta__tmpo=0x746D706F;
+ const int64u moov_meta__year=0x79656172;
+ const int64u skip=0x736B6970;
+ const int64u wide=0x77696465;
+}
+
+//---------------------------------------------------------------------------
+Ztring Mpeg4_Encoded_Library(int32u Vendor)
+{
+ switch (Vendor)
+ {
+ case 0x33495658 : return _T("3ivX"); //3IVX
+ case 0x6170706C : return _T("Apple QuickTime"); //appl
+ case 0x6E696B6F : return _T("Nikon"); //niko
+ case 0x6F6C796D : return _T("Olympus"); //olym
+ case 0x6F6D6E65 : return _T("Omneon"); //omne
+ default: return Ztring().From_CC4(Vendor);
+ }
+}
+
+//---------------------------------------------------------------------------
+Ztring Mpeg4_Language_Apple(int16u Language)
+{
+ switch (Language)
+ {
+ case 0 : return _T("en");
+ case 1 : return _T("fr");
+ case 2 : return _T("de");
+ case 6 : return _T("es");
+ default: return Ztring::ToZtring(Language);
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Mpeg4::File_Mpeg4()
+:File__Analyze()
+{
+ //Configuration
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Mpeg4;
+ StreamIDs_Width[0]=8;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ #endif //MEDIAINFO_DEMUX
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(0); //Container1
+ #endif //MEDIAINFO_TRACE
+
+ DataMustAlwaysBeComplete=false;
+
+ //Temp
+ mdat_MustParse=false;
+ TimeScale=1;
+ Vendor=0x00000000;
+ FirstMdatPos=(int64u)-1;
+ LastMdatPos=0;
+ FirstMoovPos=(int64u)-1;
+ MajorBrand=0x00000000;
+ IsSecondPass=false;
+ IsParsing_mdat=false;
+ IsFragmented=false;
+ moov_trak_tkhd_TrackID=(int32u)-1;
+ ReferenceFiles=NULL;
+ mdat_Pos_NormalParsing=false;
+ #if MEDIAINFO_NEXTPACKET
+ ReferenceFiles_IsParsing=false;
+ #endif //MEDIAINFO_NEXTPACKET
+ #if MEDIAINFO_DEMUX
+ TimeCode_FrameOffset=0;
+ TimeCode_DtsOffset=0;
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+File_Mpeg4::~File_Mpeg4()
+{
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::Streams_Accept()
+{
+ if (!IsSub && MajorBrand==0x6A703220) //"jp2 "
+ {
+ Streams_Accept_TestContinuousFileNames();
+
+ Stream_Prepare((Config->File_Names.size()>1 || Config->File_IsReferenced_Get())?Stream_Video:Stream_Image);
+ if (StreamKind_Last==Stream_Video)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameCount, Config->File_Names.size());
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::Streams_Finish()
+{
+ #if defined(MEDIAINFO_REFERENCES_YES) && MEDIAINFO_NEXTPACKET
+ //Locators only
+ if (ReferenceFiles_IsParsing)
+ {
+ ReferenceFiles->ParseReferences();
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return;
+ #endif //MEDIAINFO_DEMUX
+
+ Streams_Finish_CommercialNames();
+ return;
+ }
+ #endif //defined(MEDIAINFO_REFERENCES_YES) && MEDIAINFO_NEXTPACKET
+
+ //Final Cut EIA-608 format
+ if (Retrieve(Stream_General, 0, General_Format)==_T("Final Cut EIA-608"))
+ {
+ for (streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); Stream++)
+ {
+ if (Stream->second.Parser->Count_Get(Stream_Text))
+ {
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, StreamPos_Last, Text_ID, Stream->first==1?"608-1":"608-2");
+ Fill(Stream_Text, StreamPos_Last, "MuxingMode", _T("Final Cut"), Unlimited);
+ Merge(*Stream->second.Parser, Stream_Text, 0, StreamPos_Last);
+ }
+ }
+
+ return;
+ }
+
+ Fill_Flush();
+ int64u File_Size_Total=File_Size;
+
+ //TimeCode
+ for (streams::iterator Temp=Streams.begin(); Temp!=Streams.end(); Temp++)
+ if (Temp->second.TimeCode)
+ TimeCode_Associate(Temp->first);
+
+ //For each stream
+ streams::iterator Temp=Streams.begin();
+ while (Temp!=Streams.end())
+ {
+ //Preparing
+ StreamKind_Last=Temp->second.StreamKind;
+ StreamPos_Last=Temp->second.StreamPos;
+
+ //if (Temp->second.stsz_StreamSize)
+ // Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_StreamSize), Temp->second.stsz_StreamSize);
+
+ //Edit lists coherencies
+ if (Temp->second.edts.size()>1 && Temp->second.edts[0].Duration==Temp->second.tkhd_Duration)
+ {
+ bool Duplicates=true;
+ for (size_t Pos=1; Pos<Temp->second.edts.size(); Pos++)
+ if (Temp->second.edts[Pos-1].Delay!=Temp->second.edts[Pos].Delay || Temp->second.edts[Pos-1].Duration!=Temp->second.edts[Pos].Duration || Temp->second.edts[Pos-1].Rate!=Temp->second.edts[Pos].Rate)
+ Duplicates=false;
+ if (Duplicates)
+ Temp->second.edts.resize(1);
+ }
+
+ //Edit Lists
+ float64 Delay=0;
+ switch (Temp->second.edts.size())
+ {
+ case 0 :
+ break;
+ case 1 :
+ if (Temp->second.edts[0].Duration==Temp->second.tkhd_Duration && Temp->second.edts[0].Rate==0x00010000)
+ Delay=Temp->second.edts[0].Delay;
+ break;
+ case 2 :
+ if (Temp->second.edts[0].Delay==(int32u)-1 && Temp->second.edts[0].Duration+Temp->second.edts[1].Duration==Temp->second.tkhd_Duration && Temp->second.edts[0].Rate==0x00010000 && Temp->second.edts[1].Rate==0x00010000)
+ {
+ Delay=Temp->second.edts[0].Duration;
+ Temp->second.tkhd_Duration-=Temp->second.edts[0].Duration;
+ }
+ break;
+ default:
+ break; //TODO: handle more complex Edit Lists
+ }
+ Delay/=TimeScale; //In seconds
+ Delay+=Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay)).To_float64()/1000; //TODO: use TimeCode value directly instead of the rounded value
+ if (!Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Source)).empty() && Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Source))!=_T("Container"))
+ {
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Original), Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay)));
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Original_Source), Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Source)));
+ }
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay), Delay*1000, 0, true);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Source), "Container", Unlimited, true, true);
+
+ //Fragments
+ if (IsFragmented)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), Temp->second.stts_Duration/((float)Temp->second.mdhd_TimeScale)*1000, 0, true);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_FrameCount), Temp->second.stts_FrameCount, 10, true);
+ }
+
+ //Duration/StreamSize
+ if (TimeScale && Temp->second.TimeCode==NULL && Temp->second.mdhd_TimeScale)
+ {
+ Ztring Duration_stts_FirstFrame, Duration_stts_LastFrame;
+ if (Temp->second.stts_Duration_FirstFrame)
+ Duration_stts_FirstFrame.From_Number(((float32)(((int32s)Temp->second.stts_Duration_FirstFrame)-((int32s)Temp->second.stts[1].SampleDuration)))*1000/Temp->second.mdhd_TimeScale, 0); //The duration of the frame minus 1 normal frame duration
+ if (Temp->second.stts_Duration_LastFrame)
+ Duration_stts_LastFrame.From_Number(((float32)(((int32s)Temp->second.stts_Duration_LastFrame)-((int32s)Temp->second.stts[Temp->second.stts_Duration_FirstFrame?1:0].SampleDuration)))*1000/Temp->second.mdhd_TimeScale, 0); //The duration of the frame minus 1 normal frame duration
+
+ float32 Duration_tkhd_H=((float32)(Temp->second.tkhd_Duration+1))/TimeScale;
+ float32 Duration_tkhd_L=((float32)(Temp->second.tkhd_Duration-1))/TimeScale;
+ float32 Duration_stts=((float32)Temp->second.stts_Duration)/Temp->second.mdhd_TimeScale;
+ if (!IsFragmented && Duration_stts && !(Duration_stts>=Duration_tkhd_L && Duration_stts<=Duration_tkhd_H))
+ {
+ //There is a difference between media/stts atom and track atom
+ Fill(StreamKind_Last, StreamPos_Last, "Source_Duration", Duration_stts*1000, 0);
+ Fill(StreamKind_Last, StreamPos_Last, "Source_Duration_FirstFrame", Duration_stts_FirstFrame);
+ Fill(StreamKind_Last, StreamPos_Last, "Source_Duration_LastFrame", Duration_stts_LastFrame);
+ if (Temp->second.stts.size()!=1 || Temp->second.mdhd_TimeScale<100 || Temp->second.stts[0].SampleDuration!=1) //TODO: test PCM
+ if (Temp->second.stts_FrameCount)
+ Fill(StreamKind_Last, StreamPos_Last, "Source_FrameCount", Temp->second.stts_FrameCount);
+ if (Temp->second.stsz_StreamSize)
+ Fill(StreamKind_Last, StreamPos_Last, "Source_StreamSize", Temp->second.stsz_StreamSize);
+
+ //Calculating new properties based on track duration
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), ((float32)Temp->second.tkhd_Duration)/TimeScale*1000, 0, true);
+ //Fill(StreamKind_Last, StreamPos_Last, "Duration_FirstFrame", Duration_stts_FirstFrame);
+ Clear(StreamKind_Last, StreamPos_Last, "Duration_LastFrame"); //TODO
+
+ int64u FrameCount;
+ if (Temp->second.stts_Min && Temp->second.stts_Min==Temp->second.stts_Max)
+ FrameCount=float64_int64s(((float64)Temp->second.tkhd_Duration)/TimeScale*Temp->second.mdhd_TimeScale/Temp->second.stts_Min);
+ else
+ {
+ FrameCount=0;
+ int64u Ticks_Max=float64_int64s(((float64)Temp->second.tkhd_Duration)/TimeScale*Temp->second.mdhd_TimeScale);
+ int64u Ticks=0;
+ for (size_t stts_Pos=0; stts_Pos<Temp->second.stts.size(); stts_Pos++)
+ {
+ int64u Ticks_Complete=Temp->second.stts[stts_Pos].SampleCount*Temp->second.stts[stts_Pos].SampleDuration;
+ if (Ticks+Ticks_Complete>=Ticks_Max)
+ {
+ if (Temp->second.stts[stts_Pos].SampleDuration)
+ FrameCount+=float64_int64s(((float64)(Ticks_Max-Ticks))/Temp->second.stts[stts_Pos].SampleDuration);
+ break;
+ }
+ Ticks+=Ticks_Complete;
+ FrameCount+=Temp->second.stts[stts_Pos].SampleCount;
+ }
+ }
+ if (Temp->second.stts.size()!=1 || Temp->second.mdhd_TimeScale<100 || Temp->second.stts[0].SampleDuration!=1) //TODO: test PCM
+ Fill(StreamKind_Last, StreamPos_Last, "FrameCount", FrameCount, 10, true);
+
+ if (Temp->second.stsz_Total.empty())
+ Fill(StreamKind_Last, StreamPos_Last, "StreamSize", FrameCount*Temp->second.stsz_Sample_Size*Temp->second.stsz_Sample_Multiplier);
+ else if (FrameCount<=Temp->second.stsz_Total.size())
+ {
+ int64u StreamSize=0;
+ for (size_t stsz_Pos=0; stsz_Pos<FrameCount; stsz_Pos++)
+ StreamSize+=Temp->second.stsz_Total[stsz_Pos];
+ bool HasEncodedBitRate=!Retrieve(StreamKind_Last, StreamPos_Last, "BitRate_Encoded").empty();
+ Fill(StreamKind_Last, StreamPos_Last, HasEncodedBitRate?"StreamSize_Encoded":"StreamSize", StreamSize);
+ }
+ }
+ else
+ {
+ //Normal
+ if (Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration)).empty())
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), Duration_stts*1000, 0);
+ Fill(StreamKind_Last, StreamPos_Last, "Duration_FirstFrame", Duration_stts_FirstFrame);
+ Fill(StreamKind_Last, StreamPos_Last, "Duration_LastFrame", Duration_stts_LastFrame);
+ if (Temp->second.stts.size()!=1 || Temp->second.mdhd_TimeScale<100 || Temp->second.stts[0].SampleDuration!=1) //TODO: test PCM
+ if (Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_FrameCount)).empty() && Temp->second.stts_FrameCount)
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_FrameCount), Temp->second.stts_FrameCount);
+ bool HasPadding=(Temp->second.Parser && !Temp->second.Parser->Retrieve(StreamKind_Last, StreamPos_Last, "BitRate_Encoded").empty()) || (Temp->second.Parser && Temp->second.Parser->Buffer_TotalBytes && ((float32)Temp->second.Parser->Buffer_PaddingBytes)/Temp->second.Parser->Buffer_TotalBytes>0.02);
+ if (Temp->second.stsz_StreamSize)
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, HasPadding?Generic_StreamSize_Encoded:Generic_StreamSize), Temp->second.stsz_StreamSize);
+ }
+ }
+
+ if (StreamKind_Last==Stream_Video && Temp->second.TimeCode==NULL)
+ {
+ if (Temp->second.mdhd_TimeScale && Temp->second.stts_Min && Temp->second.stts_Max)
+ {
+ if (Temp->second.stts_Min==0 || Temp->second.stts_Max==0 || (Temp->second.stts_Min!=Temp->second.stts_Max && ((float)Temp->second.mdhd_TimeScale)/Temp->second.stts_Min-((float)Temp->second.mdhd_TimeScale)/Temp->second.stts_Max>=0.001))
+ {
+ if (Temp->second.stts_Max)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Minimum, ((float)Temp->second.mdhd_TimeScale)/Temp->second.stts_Max, 3, true);
+ if (Temp->second.stts_Min)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Maximum, ((float)Temp->second.mdhd_TimeScale)/Temp->second.stts_Min, 3, true);
+ if (Temp->second.stts_Duration)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, ((float)Temp->second.stts_FrameCount)/Temp->second.stts_Duration*Temp->second.mdhd_TimeScale, 3, true);
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Mode, "VFR", Unlimited, true, true);
+ }
+ else
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, ((float)Temp->second.mdhd_TimeScale)/Temp->second.stts_Max, 3, true);
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Mode, "CFR", Unlimited, true, true);
+ }
+ }
+ }
+
+ //Coherency
+ if (!IsFragmented && Temp->second.stts_Duration!=Temp->second.mdhd_Duration && Temp->second.mdhd_TimeScale)
+ {
+ //There is a difference between media/mdhd atom and track atom
+ Fill(StreamKind_Last, StreamPos_Last, "mdhd_Duration", ((float32)Temp->second.mdhd_Duration)/Temp->second.mdhd_TimeScale*1000, 0);
+ }
+
+ //Parser specific
+ if (Temp->second.Parser)
+ {
+ if (Config_ParseSpeed<=1.0)
+ {
+ Fill(Temp->second.Parser);
+ Temp->second.Parser->Open_Buffer_Unsynch();
+ }
+
+ //Finalizing and Merging
+ Finish(Temp->second.Parser);
+ if (StreamKind_Last==Stream_General)
+ {
+ //Special case for TimeCode without link
+ for (std::map<int32u, stream>::iterator Target=Streams.begin(); Target!=Streams.end(); Target++)
+ if (Target->second.StreamKind!=Stream_General)
+ Merge(*Temp->second.Parser, Target->second.StreamKind, 0, Target->second.StreamPos);
+ }
+ else
+ {
+ //Hacks - Before
+ Ztring FrameRate_Temp, FrameRate_Mode_Temp, Duration_Temp, Delay_Temp;
+ if (StreamKind_Last==Stream_Video)
+ {
+ if (Temp->second.Parser && Retrieve(Stream_Video, 0, Video_CodecID_Hint)==_T("DVCPRO HD"))
+ {
+ Temp->second.Parser->Clear(Stream_Video, 0, Video_FrameRate);
+ Temp->second.Parser->Clear(Stream_Video, 0, Video_Width);
+ Temp->second.Parser->Clear(Stream_Video, 0, Video_Height);
+ Temp->second.Parser->Clear(Stream_Video, 0, Video_DisplayAspectRatio);
+ Temp->second.Parser->Clear(Stream_Video, 0, Video_PixelAspectRatio);
+ }
+
+ FrameRate_Temp=Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate);
+ FrameRate_Mode_Temp=Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate_Mode);
+ Duration_Temp=Retrieve(Stream_Video, StreamPos_Last, Video_Duration);
+ Delay_Temp=Retrieve(Stream_Video, StreamPos_Last, Video_Delay);
+
+ //Special case: DV 1080i and MPEG-4 header is lying (saying this is 1920 pixel wide, but this is 1440 pixel wide)
+ if (Temp->second.Parser->Get(Stream_Video, 0, Video_Format)==_T("DV") && Retrieve(Stream_Video, StreamKind_Last, Video_Width)==_T("1080"))
+ Clear(Stream_Video, StreamKind_Last, Video_Width);
+ }
+
+ //Special case - Multiple sub-streams in a stream
+ if ((Temp->second.Parser->Retrieve(Stream_General, 0, General_Format)==_T("ChannelGrouping") && Temp->second.Parser->Count_Get(Stream_Audio))
+ || Temp->second.Parser->Retrieve(Stream_General, 0, General_Format)==_T("Final Cut EIA-608")
+ || Temp->second.Parser->Retrieve(Stream_General, 0, General_Format)==_T("Final Cut CDP"))
+ {
+ //Before
+ Clear(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_StreamSize));
+ if (StreamKind_Last==Stream_Audio)
+ {
+ Clear(Stream_Audio, StreamPos_Last, Audio_Format_Settings_Sign);
+ }
+ ZtringList StreamSave; StreamSave.Write((*File__Analyze::Stream)[StreamKind_Last][StreamPos_Last].Read());
+ ZtringListList StreamMoreSave; StreamMoreSave.Write((*Stream_More)[StreamKind_Last][StreamPos_Last].Read());
+
+ //Erasing former streams data
+ stream_t NewKind=StreamKind_Last;
+ size_t NewPos1;
+ Ztring ID;
+ if (Temp->second.Parser->Retrieve(Stream_General, 0, General_Format)==_T("ChannelGrouping"))
+ {
+ //Channel coupling, removing the 2 corresponding streams
+ NewPos1=(StreamPos_Last/2)*2;
+ size_t NewPos2=NewPos1+1;
+ ID=Retrieve(StreamKind_Last, NewPos1, General_ID)+_T(" / ")+Retrieve(StreamKind_Last, NewPos2, General_ID);
+
+ Stream_Erase(NewKind, NewPos2);
+ Stream_Erase(NewKind, NewPos1);
+
+ streams::iterator NextStream=Temp;
+ NextStream++;
+ size_t NewAudio_Count=Temp->second.Parser->Count_Get(Stream_Audio);
+ while (NextStream!=Streams.end())
+ {
+ if (NextStream->second.StreamKind==Stream_Audio)
+ {
+ NextStream->second.StreamPos-=2;
+ NextStream->second.StreamPos+=NewAudio_Count;
+ }
+ NextStream++;
+ }
+ }
+ else
+ {
+ //One channel
+ NewPos1=StreamPos_Last;
+ ID=Retrieve(StreamKind_Last, NewPos1, General_ID);
+ Stream_Erase(StreamKind_Last, StreamPos_Last);
+ }
+
+ //After
+ size_t New_Count=Temp->second.Parser->Count_Get(NewKind);
+ for (size_t StreamPos=0; StreamPos<New_Count; StreamPos++)
+ {
+ Stream_Prepare(NewKind, NewPos1+StreamPos);
+ Merge(*Temp->second.Parser, StreamKind_Last, StreamPos, StreamPos_Last);
+ Ztring Parser_ID=Retrieve(StreamKind_Last, StreamPos_Last, General_ID);
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, ID+_T("-")+Parser_ID, true);
+ for (size_t Pos=0; Pos<StreamSave.size(); Pos++)
+ if (Retrieve(StreamKind_Last, StreamPos_Last, Pos).empty())
+ Fill(StreamKind_Last, StreamPos_Last, Pos, StreamSave[Pos]);
+ for (size_t Pos=0; Pos<StreamMoreSave.size(); Pos++)
+ Fill(StreamKind_Last, StreamPos_Last, StreamMoreSave(Pos, 0).To_Local().c_str(), StreamMoreSave(Pos, 1));
+ }
+ }
+ else
+ {
+ //Temp->second.Parser->Clear(StreamKind_Last, StreamPos_Last, "Delay"); //DV TimeCode is removed
+ Merge(*Temp->second.Parser, StreamKind_Last, 0, StreamPos_Last);
+ }
+
+ //Hacks - After
+ if (StreamKind_Last==Stream_Video)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Duration, Duration_Temp, true);
+ if (!FrameRate_Temp.empty() && FrameRate_Temp!=Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate))
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, FrameRate_Temp, true);
+ if (!FrameRate_Mode_Temp.empty() && FrameRate_Mode_Temp!=Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate_Mode))
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Mode, FrameRate_Mode_Temp, true);
+
+ //Special case for TimeCode and DV multiple audio
+ if (!Delay_Temp.empty() && Delay_Temp!=Retrieve(Stream_Video, StreamPos_Last, Video_Delay))
+ {
+ for (size_t Pos=0; Pos<Count_Get(Stream_Audio); Pos++)
+ if (Retrieve(Stream_Audio, Pos, "MuxingMode_MoreInfo")==_T("Muxed in Video #1"))
+ {
+ //Fill(Stream_Audio, Pos, Audio_Delay_Original, Retrieve(Stream_Audio, Pos, Audio_Delay));
+ Fill(Stream_Audio, Pos, Audio_Delay, Retrieve(Stream_Video, StreamPos_Last, Video_Delay), true);
+ Fill(Stream_Audio, Pos, Audio_Delay_Settings, Retrieve(Stream_Video, StreamPos_Last, Video_Delay_Settings), true);
+ Fill(Stream_Audio, Pos, Audio_Delay_Source, Retrieve(Stream_Video, StreamPos_Last, Video_Delay_Source), true);
+ Fill(Stream_Audio, Pos, Audio_Delay_Original, Retrieve(Stream_Video, StreamPos_Last, Video_Delay_Original), true);
+ Fill(Stream_Audio, Pos, Audio_Delay_Original_Settings, Retrieve(Stream_Video, StreamPos_Last, Video_Delay_Original_Settings), true);
+ Fill(Stream_Audio, Pos, Audio_Delay_Original_Source, Retrieve(Stream_Video, StreamPos_Last, Video_Delay_Original_Source), true);
+ }
+ for (size_t Pos=0; Pos<Count_Get(Stream_Text); Pos++)
+ if (Retrieve(Stream_Text, Pos, "MuxingMode_MoreInfo")==_T("Muxed in Video #1"))
+ {
+ //Fill(Stream_Text, Pos, Text_Delay_Original, Retrieve(Stream_Text, Pos, Text_Delay));
+ Fill(Stream_Text, Pos, Text_Delay, Retrieve(Stream_Video, StreamPos_Last, Video_Delay), true);
+ Fill(Stream_Text, Pos, Text_Delay_Settings, Retrieve(Stream_Video, StreamPos_Last, Video_Delay_Settings), true);
+ Fill(Stream_Text, Pos, Text_Delay_Source, Retrieve(Stream_Video, StreamPos_Last, Video_Delay_Source), true);
+ Fill(Stream_Text, Pos, Text_Delay_Original, Retrieve(Stream_Video, StreamPos_Last, Video_Delay_Original), true);
+ Fill(Stream_Text, Pos, Text_Delay_Original_Settings, Retrieve(Stream_Video, StreamPos_Last, Video_Delay_Original_Settings), true);
+ Fill(Stream_Text, Pos, Text_Delay_Original_Source, Retrieve(Stream_Video, StreamPos_Last, Video_Delay_Original_Source), true);
+ }
+ }
+ }
+
+ //TimeCode specific
+ if (StreamKind_Last==Stream_Video && Retrieve(Stream_Menu, StreamPos_Last, Menu_Format)==_T("TimeCode"))
+ {
+ Clear(Stream_Menu, StreamPos_Last, "Duration");
+ Clear(Stream_Menu, StreamPos_Last, "StreamSize");
+ }
+
+ //Special case: AAC
+ if (StreamKind_Last==Stream_Audio
+ && (Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("AAC")
+ || Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("MPEG Audio")
+ || Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("Vorbis")))
+ Clear(Stream_Audio, StreamPos_Last, Audio_BitDepth); //Resolution is not valid for AAC / MPEG Audio / Vorbis
+
+ //Special case: DV with Audio or/and Text in the video stream
+ if (StreamKind_Last==Stream_Video && Temp->second.Parser && (Temp->second.Parser->Count_Get(Stream_Audio) || Temp->second.Parser->Count_Get(Stream_Text)))
+ {
+ //Video and Audio are together
+ size_t Audio_Count=Temp->second.Parser->Count_Get(Stream_Audio);
+ for (size_t Audio_Pos=0; Audio_Pos<Audio_Count; Audio_Pos++)
+ {
+ Fill_Flush();
+ Stream_Prepare(Stream_Audio);
+ size_t Pos=Count_Get(Stream_Audio)-1;
+ Merge(*Temp->second.Parser, Stream_Audio, Audio_Pos, StreamPos_Last);
+ if (Retrieve(Stream_Audio, Pos, Audio_MuxingMode).empty())
+ Fill(Stream_Audio, Pos, Audio_MuxingMode, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Format), true);
+ else
+ Fill(Stream_Audio, Pos, Audio_MuxingMode, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Format)+_T(" / ")+Retrieve(Stream_Audio, Pos, Audio_MuxingMode), true);
+ Fill(Stream_Audio, Pos, Audio_MuxingMode_MoreInfo, _T("Muxed in Video #")+Ztring().From_Number(Temp->second.StreamPos+1));
+ Fill(Stream_Audio, Pos, Audio_Duration, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Duration));
+ Fill(Stream_Audio, Pos, Audio_StreamSize_Encoded, 0); //Included in the DV stream size
+ Ztring ID=Retrieve(Stream_Audio, Pos, Audio_ID);
+ Fill(Stream_Audio, Pos, Audio_ID, Retrieve(Stream_Video, Temp->second.StreamPos, Video_ID)+_T("-")+ID, true);
+ Fill(Stream_Audio, Pos, "Source", Retrieve(Stream_Video, Temp->second.StreamPos, "Source"));
+ Fill(Stream_Audio, Pos, "Source_Info", Retrieve(Stream_Video, Temp->second.StreamPos, "Source_Info"));
+ }
+
+ //Video and Text are together
+ size_t Text_Count=Temp->second.Parser->Count_Get(Stream_Text);
+ for (size_t Text_Pos=0; Text_Pos<Text_Count; Text_Pos++)
+ {
+ Fill_Flush();
+ Stream_Prepare(Stream_Text);
+ size_t Pos=Count_Get(Stream_Text)-1;
+ Merge(*Temp->second.Parser, Stream_Text, Text_Pos, StreamPos_Last);
+ if (Retrieve(Stream_Text, Pos, Text_MuxingMode).empty())
+ Fill(Stream_Text, Pos, Text_MuxingMode, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Format), true);
+ else
+ Fill(Stream_Text, Pos, Text_MuxingMode, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Format)+_T(" / ")+Retrieve(Stream_Text, Pos, Text_MuxingMode), true);
+ Fill(Stream_Text, Pos, Text_MuxingMode_MoreInfo, _T("Muxed in Video #")+Ztring().From_Number(Temp->second.StreamPos+1));
+ Fill(Stream_Text, Pos, Text_Duration, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Duration));
+ Fill(Stream_Text, Pos, Text_StreamSize_Encoded, 0); //Included in the DV stream size
+ Ztring ID=Retrieve(Stream_Text, Pos, Text_ID);
+ Fill(Stream_Text, Pos, Text_ID, Retrieve(Stream_Video, Temp->second.StreamPos, Video_ID)+_T("-")+ID, true);
+ Fill(Stream_Text, Pos, "Source", Retrieve(Stream_Video, Temp->second.StreamPos, "Source"));
+ Fill(Stream_Text, Pos, "Source_Info", Retrieve(Stream_Video, Temp->second.StreamPos, "Source_Info"));
+ }
+
+ StreamKind_Last=Temp->second.StreamKind;
+ StreamPos_Last=Temp->second.StreamPos;
+ }
+ }
+ }
+
+ //External file name specific
+ if (Temp->second.MI && Temp->second.MI->Info)
+ {
+ //Preparing
+ StreamKind_Last=Temp->second.StreamKind;
+ StreamPos_Last=Temp->second.StreamPos;
+
+ //Hacks - Before
+ Ztring CodecID=Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_CodecID));
+ Ztring Source=Retrieve(StreamKind_Last, StreamPos_Last, "Source");
+ Ztring Source_Info=Retrieve(StreamKind_Last, StreamPos_Last, "Source_Info");
+
+ Merge(*Temp->second.MI->Info, Temp->second.StreamKind, 0, Temp->second.StreamPos);
+ File_Size_Total+=Ztring(Temp->second.MI->Get(Stream_General, 0, General_FileSize)).To_int64u();
+
+ //Hacks - After
+ if (CodecID!=Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_CodecID)))
+ {
+ if (!CodecID.empty())
+ CodecID+=_T(" / ");
+ CodecID+=Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_CodecID));
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_CodecID), CodecID, true);
+ }
+ if (Source!=Retrieve(StreamKind_Last, StreamPos_Last, "Source"))
+ {
+ Ztring Source_Original=Retrieve(StreamKind_Last, StreamPos_Last, "Source");
+ Ztring Source_Original_Info=Retrieve(StreamKind_Last, StreamPos_Last, "Source_Info");
+ Fill(StreamKind_Last, StreamPos_Last, "Source", Source, true);
+ Fill(StreamKind_Last, StreamPos_Last, "Source_Info", Source_Info, true);
+ Fill(StreamKind_Last, StreamPos_Last, "Source_Original", Source_Original, true);
+ Fill(StreamKind_Last, StreamPos_Last, "Source_Original_Info", Source_Original_Info, true);
+ }
+
+ //Muxing Mode
+ Fill(StreamKind_Last, StreamPos_Last, "MuxingMode", Temp->second.MI->Get(Stream_General, 0, General_Format));
+
+ //Special case: DV with Audio or/and Text in the video stream
+ if (StreamKind_Last==Stream_Video && Temp->second.MI->Info && (Temp->second.MI->Info->Count_Get(Stream_Audio) || Temp->second.MI->Info->Count_Get(Stream_Text)))
+ {
+ //Video and Audio are together
+ size_t Audio_Count=Temp->second.MI->Info->Count_Get(Stream_Audio);
+ for (size_t Audio_Pos=0; Audio_Pos<Audio_Count; Audio_Pos++)
+ {
+ Fill_Flush();
+ Stream_Prepare(Stream_Audio);
+ size_t Pos=Count_Get(Stream_Audio)-1;
+ Merge(*Temp->second.MI->Info, Stream_Audio, Audio_Pos, StreamPos_Last);
+ if (Retrieve(Stream_Audio, Pos, Audio_MuxingMode).empty())
+ Fill(Stream_Audio, Pos, Audio_MuxingMode, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Format), true);
+ else
+ Fill(Stream_Audio, Pos, Audio_MuxingMode, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Format)+_T(" / ")+Retrieve(Stream_Audio, Pos, Audio_MuxingMode), true);
+ Fill(Stream_Audio, Pos, Audio_MuxingMode_MoreInfo, _T("Muxed in Video #")+Ztring().From_Number(Temp->second.StreamPos+1));
+ Fill(Stream_Audio, Pos, Audio_Duration, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Duration), true);
+ Fill(Stream_Audio, Pos, Audio_StreamSize_Encoded, 0); //Included in the DV stream size
+ Ztring ID=Retrieve(Stream_Audio, Pos, Audio_ID);
+ Fill(Stream_Audio, Pos, Audio_ID, Retrieve(Stream_Video, Temp->second.StreamPos, Video_ID)+_T("-")+ID, true);
+ Fill(Stream_Audio, Pos, "Source", Retrieve(Stream_Video, Temp->second.StreamPos, "Source"));
+ Fill(Stream_Audio, Pos, "Source_Info", Retrieve(Stream_Video, Temp->second.StreamPos, "Source_Info"));
+ }
+
+ //Video and Text are together
+ size_t Text_Count=Temp->second.MI->Info->Count_Get(Stream_Text);
+ for (size_t Text_Pos=0; Text_Pos<Text_Count; Text_Pos++)
+ {
+ Fill_Flush();
+ Stream_Prepare(Stream_Text);
+ size_t Pos=Count_Get(Stream_Text)-1;
+ Merge(*Temp->second.MI->Info, Stream_Text, Text_Pos, StreamPos_Last);
+ if (Retrieve(Stream_Text, Pos, Text_MuxingMode).empty())
+ Fill(Stream_Text, Pos, Text_MuxingMode, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Format), true);
+ else
+ Fill(Stream_Text, Pos, Text_MuxingMode, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Format)+_T(" / ")+Retrieve(Stream_Text, Pos, Text_MuxingMode), true);
+ Fill(Stream_Text, Pos, Text_MuxingMode_MoreInfo, _T("Muxed in Video #")+Ztring().From_Number(Temp->second.StreamPos+1));
+ Fill(Stream_Text, Pos, Text_Duration, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Duration));
+ Fill(Stream_Text, Pos, Text_StreamSize_Encoded, 0); //Included in the DV stream size
+ Ztring ID=Retrieve(Stream_Text, Pos, Text_ID);
+ Fill(Stream_Text, Pos, Text_ID, Retrieve(Stream_Video, Temp->second.StreamPos, Video_ID)+_T("-")+ID, true);
+ Fill(Stream_Text, Pos, "Source", Retrieve(Stream_Video, Temp->second.StreamPos, "Source"));
+ Fill(Stream_Text, Pos, "Source_Info", Retrieve(Stream_Video, Temp->second.StreamPos, "Source_Info"));
+ }
+ }
+ }
+
+ //Aperture size
+ if (Temp->second.CleanAperture_Width)
+ {
+ Ztring CleanAperture_Width=Ztring().From_Number(Temp->second.CleanAperture_Width, 0);
+ Ztring CleanAperture_Height=Ztring().From_Number(Temp->second.CleanAperture_Height, 0);
+ if (CleanAperture_Width!=Retrieve(Stream_Video, StreamPos_Last, Video_Width))
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Width_Original, Retrieve(Stream_Video, StreamPos_Last, Video_Width), true);
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Temp->second.CleanAperture_Width, 0, true);
+ }
+ if (CleanAperture_Height!=Retrieve(Stream_Video, StreamPos_Last, Video_Height))
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Height_Original, Retrieve(Stream_Video, StreamPos_Last, Video_Height), true);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Temp->second.CleanAperture_Height, 0, true);
+ }
+ if (Temp->second.CleanAperture_PixelAspectRatio)
+ {
+ Clear(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio);
+ Clear(Stream_Video, StreamPos_Last, Video_PixelAspectRatio);
+ Fill(Stream_Video, StreamPos_Last, Video_PixelAspectRatio, Temp->second.CleanAperture_PixelAspectRatio, 3, true);
+ if (Retrieve(Stream_Video, StreamPos_Last, Video_PixelAspectRatio)==Retrieve(Stream_Video, StreamPos_Last, Video_PixelAspectRatio_Original))
+ Clear(Stream_Video, StreamPos_Last, Video_PixelAspectRatio_Original);
+ if (Retrieve(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio)==Retrieve(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio_Original))
+ {
+ Clear(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio_Original);
+ Clear(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio_Original_String);
+ }
+ }
+ }
+
+ Temp++;
+ }
+ if (Vendor!=0x00000000 && Vendor!=0xFFFFFFFF)
+ {
+ Ztring VendorS=Mpeg4_Encoded_Library(Vendor);
+ if (!Vendor_Version.empty())
+ {
+ VendorS+=_T(' ');
+ VendorS+=Vendor_Version;
+ }
+ Fill(Stream_General, 0, General_Encoded_Library, VendorS);
+ Fill(Stream_General, 0, General_Encoded_Library_Name, Mpeg4_Encoded_Library(Vendor));
+ Fill(Stream_General, 0, General_Encoded_Library_Version, Vendor_Version);
+ }
+
+ if (File_Size_Total!=File_Size)
+ Fill(Stream_General, 0, General_FileSize, File_Size_Total, 10, true);
+ if (Count_Get(Stream_Video)==0 && Count_Get(Stream_Image)==0 && Count_Get(Stream_Audio)>0)
+ Fill(Stream_General, 0, General_InternetMediaType, "audio/mp4", Unlimited, true, true);
+
+ //Parsing reference files
+ #ifdef MEDIAINFO_REFERENCES_YES
+ for (streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); Stream++)
+ if (!Stream->second.File_Name.empty())
+ {
+ if (ReferenceFiles==NULL)
+ ReferenceFiles=new File__ReferenceFilesHelper(this, Config);
+
+ File__ReferenceFilesHelper::reference ReferenceFile;
+ ReferenceFile.FileNames.push_back(Stream->second.File_Name);
+ ReferenceFile.StreamKind=Stream->second.StreamKind;
+ ReferenceFile.StreamPos=Stream->second.StreamPos;
+ ReferenceFile.StreamID=Retrieve(Stream->second.StreamKind, Stream->second.StreamPos, General_ID).To_int64u();
+ if (Stream->second.StreamKind==Stream_Video)
+ {
+ ReferenceFile.FrameRate=Retrieve(Stream_Video, Stream->second.StreamPos, Video_FrameRate).To_float64();
+
+ #ifdef MEDIAINFO_IBI_YES
+ for (size_t stss_Pos=0; stss_Pos<Stream->second.stss.size(); stss_Pos++)
+ {
+ int64u Value=Stream->second.stss[stss_Pos];
+
+ //Searching the corresponding stco
+ std::vector<stream::stsc_struct>::iterator Stsc=Stream->second.stsc.begin();
+ int64u SamplePos=0;
+ for (; Stsc!=Stream->second.stsc.end(); Stsc++)
+ {
+ std::vector<stream::stsc_struct>::iterator Stsc_Next=Stsc; Stsc_Next++;
+ int64u CountOfSamples=((Stsc_Next==Stream->second.stsc.end()?Stream->second.stco.size():Stsc_Next->FirstChunk)-Stsc->FirstChunk)*Stsc->SamplesPerChunk;
+ if (Stsc_Next!=Stream->second.stsc.end() && Value>=SamplePos+CountOfSamples)
+ SamplePos+=CountOfSamples;
+ else
+ {
+ int64u CountOfChunks=(Value-SamplePos)/Stsc->SamplesPerChunk;
+ size_t stco_Pos=(size_t)(Stsc->FirstChunk-1+CountOfChunks); //-1 because first chunk is number 1
+ if (stco_Pos<Stream->second.stco.size())
+ {
+ stream::stts_durations::iterator stts_Duration=Stream->second.stts_Durations.begin()+Stream->second.stts_Durations_Pos;
+ ibi::stream::info IbiInfo;
+ IbiInfo.StreamOffset=Stream->second.stco[stco_Pos];
+ IbiInfo.FrameNumber=Value;
+ IbiInfo.Dts=TimeCode_DtsOffset+(stts_Duration->DTS_Begin+(((int64u)stts_Duration->SampleDuration)*(Value-stts_Duration->Pos_Begin)))*1000000000/Stream->second.mdhd_TimeScale;
+ ReferenceFile.IbiStream.Add(IbiInfo);
+ }
+ }
+ }
+ }
+ #endif //MEDIAINFO_IBI_YES
+
+ }
+ ReferenceFiles->References.push_back(ReferenceFile);
+ }
+
+ if (ReferenceFiles)
+ {
+ ReferenceFiles->ParseReferences();
+ #if MEDIAINFO_NEXTPACKET
+ if (Config->NextPacket_Get() && ReferenceFiles && !ReferenceFiles->References.empty())
+ {
+ ReferenceFiles_IsParsing=true;
+ return;
+ }
+ #endif //MEDIAINFO_NEXTPACKET
+ }
+ #endif //MEDIAINFO_REFERENCES_YES
+
+ //Commercial names
+ Streams_Finish_CommercialNames();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::Streams_Finish_CommercialNames()
+{
+ if (Count_Get(Stream_Video)==1)
+ {
+ Streams_Finish_StreamOnly();
+ if (Retrieve(Stream_Video, 0, Video_Format)==_T("DV") && Retrieve(Stream_Video, 0, Video_Format_Commercial)==_T("DVCPRO HD"))
+ {
+ int32u BitRate=Retrieve(Stream_Video, 0, Video_BitRate).To_int32u();
+ int32u BitRate_Max=Retrieve(Stream_Video, 0, Video_BitRate_Maximum).To_int32u();
+
+ if (BitRate_Max && BitRate>=BitRate_Max)
+ {
+ Clear(Stream_Video, 0, Video_BitRate_Maximum);
+ Fill(Stream_Video, 0, Video_BitRate, BitRate_Max, 10, true);
+ Fill(Stream_Video, 0, Video_BitRate_Mode, "CBR", Unlimited, true, true);
+ }
+ }
+ if (!Retrieve(Stream_Video, 0, Video_Format_Commercial_IfAny).empty())
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, Retrieve(Stream_Video, 0, Video_Format_Commercial_IfAny));
+ Fill(Stream_General, 0, General_Format_Commercial, Retrieve(Stream_General, 0, General_Format)+_T(' ')+Retrieve(Stream_Video, 0, Video_Format_Commercial_IfAny));
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)!=_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:0") && (Retrieve(Stream_Video, 0, Video_BitRate)==_T("18000000") || Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==_T("18000000") || Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==_T("18000000")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "XDCAM EX 18");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "XDCAM EX 18");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)!=_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:0") && (Retrieve(Stream_Video, 0, Video_BitRate)==_T("25000000") || Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==_T("25000000") || Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==_T("25000000")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "XDCAM EX 25");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "XDCAM EX 25");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)!=_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:0") && (Retrieve(Stream_Video, 0, Video_BitRate)==_T("35000000") || Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==_T("35000000") || Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==_T("35000000")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "XDCAM EX 35");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "XDCAM EX 35");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)!=_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:2") && (Retrieve(Stream_Video, 0, Video_BitRate)==_T("50000000") || Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==_T("50000000") || Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==_T("50000000")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "XDCAM HD422");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "XDCAM HD422");
+ }
+ }
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::Read_Buffer_Unsynched()
+{
+ if (!IsSub && MajorBrand==0x6A703220) //"jp2 "
+ return Read_Buffer_Unsynched_OneFramePerFile();
+
+ mdat_Pos_Temp=mdat_Pos.begin();
+ while (mdat_Pos_Temp!=mdat_Pos.end() && mdat_Pos_Temp->first<File_GoTo)
+ mdat_Pos_Temp++;
+ if (mdat_Pos_Temp!=mdat_Pos.end() && mdat_Pos_Temp->first>File_GoTo)
+ mdat_Pos_Temp--; //Previous frame
+ if (mdat_Pos_Temp!=mdat_Pos.end())
+ IsParsing_mdat=true;
+
+ for (std::map<int32u, stream>::iterator Stream=Streams.begin(); Stream!=Streams.end(); Stream++)
+ {
+ if (Stream->second.Parser)
+ Stream->second.Parser->Open_Buffer_Unsynch();
+ #if MEDIAINFO_SEEK
+ for (size_t stco_Pos=0; stco_Pos<Stream->second.stco.size(); stco_Pos++)
+ if (Stream->second.stco[stco_Pos]>=File_GoTo)
+ {
+ //Searching the corresponding frame position
+ std::vector<stream::stsc_struct>::iterator Stsc=Stream->second.stsc.begin();
+ int64u SamplePos=0;
+ for (; Stsc!=Stream->second.stsc.end(); Stsc++)
+ {
+ std::vector<stream::stsc_struct>::iterator Stsc_Next=Stsc; Stsc_Next++;
+ if (Stsc_Next!=Stream->second.stsc.end() && stco_Pos+1>=Stsc_Next->FirstChunk)
+ {
+ int64u CountOfSamples=(Stsc_Next->FirstChunk-Stsc->FirstChunk)*Stsc->SamplesPerChunk;
+ SamplePos+=CountOfSamples;
+ }
+ else
+ {
+ int64u CountOfSamples=(stco_Pos+1-Stsc->FirstChunk)*Stsc->SamplesPerChunk;
+ SamplePos+=CountOfSamples;
+
+ Stream->second.stts_FramePos=SamplePos;
+
+ //Searching the corresponding duration block position
+ for (stream::stts_durations::iterator Stts_Duration=Stream->second.stts_Durations.begin(); Stts_Duration!=Stream->second.stts_Durations.end(); Stts_Duration++)
+ if (SamplePos>=Stts_Duration->Pos_Begin && SamplePos<Stts_Duration->Pos_End)
+ {
+ Stream->second.stts_Durations_Pos=Stts_Duration-Stream->second.stts_Durations.begin();
+ break;
+ }
+
+ break;
+ }
+ }
+
+ break;
+ }
+ #endif //MEDIAINFO_SEEK
+ }
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_Mpeg4::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ if (ReferenceFiles)
+ return ReferenceFiles->Read_Buffer_Seek(Method, Value, ID);
+ if (!IsSub && MajorBrand==0x6A703220) //"jp2 "
+ return Read_Buffer_Seek_OneFramePerFile(Method, Value, ID);
+
+ //Parsing
+ switch (Method)
+ {
+ case 0 :
+ if (Value==0)
+ return Read_Buffer_Seek(3, 0, ID);
+
+ if (FirstMoovPos==(int64u)-1)
+ return 6; //Internal error
+
+ if (Value>=LastMdatPos)
+ {
+ GoTo(File_Size);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+
+ {
+ //Looking for video stream
+ std::map<int32u, stream>::iterator Stream;
+ for (Stream=Streams.begin(); Stream!=Streams.end(); Stream++)
+ if (Stream->second.StreamKind==Stream_Video)
+ break;
+ if (Stream==Streams.end())
+ for (Stream=Streams.begin(); Stream!=Streams.end(); Stream++)
+ if (Stream->second.StreamKind==Stream_Audio)
+ break;
+ if (Stream==Streams.end())
+ return 0; //Not supported
+
+ //Searching the corresponding chunk offset
+ std::vector<int64u>::iterator Stco=Stream->second.stco.begin();
+ if (Value<*Stco)
+ return Read_Buffer_Seek(3, 0, ID);
+
+ for (; Stco!=Stream->second.stco.end(); Stco++)
+ {
+ std::vector<int64u>::iterator Stco_Next=Stco; Stco_Next++;
+ if (Stco_Next!=Stream->second.stco.end() && Value>=*Stco && Value<*Stco_Next)
+ {
+ GoTo(*Stco);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ }
+
+ GoTo(File_Size);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ case 1 :
+ if (Value==0)
+ return Read_Buffer_Seek(3, 0, ID);
+
+ if (FirstMoovPos==(int64u)-1)
+ return 6; //Internal error
+
+ return Read_Buffer_Seek(0, FirstMdatPos+(LastMdatPos-FirstMdatPos)*Value/10000, ID);
+ case 2 : //Timestamp
+ {
+ //Looking for video stream
+ std::map<int32u, stream>::iterator Stream;
+ for (Stream=Streams.begin(); Stream!=Streams.end(); Stream++)
+ if (Stream->second.StreamKind==Stream_Video)
+ break;
+ if (Stream==Streams.end())
+ for (Stream=Streams.begin(); Stream!=Streams.end(); Stream++)
+ if (Stream->second.StreamKind==Stream_Audio)
+ break;
+ if (Stream==Streams.end())
+ return 0; //Not supported
+
+ //Searching the corresponding frame
+ Value=Value*Stream->second.mdhd_TimeScale/1000000000; //Transformed in mpeg4 ticks
+ if (Value>TimeCode_FrameOffset*Stream->second.stts_Duration/Stream->second.stts_FrameCount) //Removing Time Code offset
+ Value-=TimeCode_FrameOffset*Stream->second.stts_Duration/Stream->second.stts_FrameCount;
+ stream::stts_durations::iterator stts_Duration=Stream->second.stts_Durations.begin();
+ for (; stts_Duration!=Stream->second.stts_Durations.end(); stts_Duration++)
+ {
+ if (Value>=stts_Duration->DTS_Begin && Value<stts_Duration->DTS_End)
+ {
+ Value=stts_Duration->Pos_Begin+(Value-stts_Duration->DTS_Begin)/stts_Duration->SampleDuration;
+ break;
+ }
+ }
+ if (stts_Duration==Stream->second.stts_Durations.end())
+ return 2; //Invalid value
+ }
+ //No break;
+ case 3 : //FrameNumber
+ {
+ //Looking for video stream
+ std::map<int32u, stream>::iterator Stream;
+ for (Stream=Streams.begin(); Stream!=Streams.end(); Stream++)
+ if (Stream->second.StreamKind==Stream_Video)
+ break;
+ if (Stream==Streams.end())
+ for (Stream=Streams.begin(); Stream!=Streams.end(); Stream++)
+ if (Stream->second.StreamKind==Stream_Audio)
+ break;
+ if (Stream==Streams.end())
+ return 0; //Not supported
+
+ //Searching the I-Frame
+ if (!Stream->second.stss.empty())
+ {
+ for (size_t Pos=0; Pos<Stream->second.stss.size(); Pos++)
+ if (Value<=Stream->second.stss[Pos])
+ {
+ if (Pos && Value<Stream->second.stss[Pos])
+ Value=Stream->second.stss[Pos-1];
+ break;
+ }
+ }
+
+ //Searching the corresponding stco
+ std::vector<stream::stsc_struct>::iterator Stsc=Stream->second.stsc.begin();
+ int64u SamplePos=0;
+ for (; Stsc!=Stream->second.stsc.end(); Stsc++)
+ {
+ std::vector<stream::stsc_struct>::iterator Stsc_Next=Stsc; Stsc_Next++;
+ int64u CountOfSamples=((Stsc_Next==Stream->second.stsc.end()?Stream->second.stco.size():Stsc_Next->FirstChunk)-Stsc->FirstChunk)*Stsc->SamplesPerChunk;
+ if (Stsc_Next!=Stream->second.stsc.end() && Value>=SamplePos+CountOfSamples)
+ SamplePos+=CountOfSamples;
+ else
+ {
+ int64u CountOfChunks=(Value-SamplePos)/Stsc->SamplesPerChunk;
+ size_t stco_Pos=(size_t)(Stsc->FirstChunk-1+CountOfChunks); //-1 because first chunk is number 1
+ if (stco_Pos>Stream->second.stco.size())
+ return 2; //Invalid value
+ int64u Offset=Stream->second.stco[stco_Pos];
+
+ GoTo(Offset);
+ Open_Buffer_Unsynch();
+ return 1;
+ break;
+ }
+ }
+
+ return 2; //Invalid value
+ }
+ default : return 0;
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Mpeg4::Header_Begin()
+{
+ #if MEDIAINFO_DEMUX
+ //Handling of multiple frames in one block
+ if (IsParsing_mdat && Config->Demux_Unpacketize_Get())
+ {
+ Open_Buffer_Continue(Streams[(int32u)Element_Code].Parser, Buffer+Buffer_Offset, 0);
+ if (Config->Demux_EventWasSent)
+ return false;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ if (IsParsing_mdat && Element_Level==0)
+ Element_Begin0();
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::Header_Parse()
+{
+ //mdat
+ if (IsParsing_mdat)
+ {
+ //Positionning
+ if (File_Offset+Buffer_Offset<mdat_Pos_Temp->first)
+ {
+ if (File_Offset+Buffer_Size>mdat_Pos_Temp->first)
+ {
+ Buffer_Offset=(size_t)(File_Offset+Buffer_Size-mdat_Pos_Temp->first);
+ }
+ else
+ {
+ Buffer_Offset=Buffer_Size;
+ return;
+ }
+ }
+
+ //Filling
+ Header_Fill_Code(mdat_Pos_Temp->second.StreamID, Ztring::ToZtring(mdat_Pos_Temp->second.StreamID));
+ Header_Fill_Size(mdat_Pos_Temp->second.Size);
+ if (Buffer_Offset+mdat_Pos_Temp->second.Size<=Buffer_Size) //Only if we will not need it later (in case of partial data, this function will be called again for the same chunk)
+ {
+ mdat_Pos_Temp++;
+ while (mdat_Pos_Temp!=mdat_Pos.end())
+ {
+ if (mdat_Pos_NormalParsing && !Streams[mdat_Pos_Temp->second.StreamID].IsPriorityStream)
+ break;
+ if (!mdat_Pos_NormalParsing && Streams[mdat_Pos_Temp->second.StreamID].IsPriorityStream)
+ break;
+ mdat_Pos_Temp++;
+ }
+ }
+ else
+ Element_WaitForMoreData();
+ return;
+ }
+
+ //Parsing
+ int64u Size;
+ int32u Size_32, Name;
+ Get_B4 (Size_32, "Size");
+ if (Size_32==0 && (Element_Size==4 || Element_Size==8))
+ {
+ //Filling
+ Header_Fill_Code(0, "Junk");
+ Header_Fill_Size(4);
+ return;
+ }
+ Size=Size_32;
+ Get_C4 (Name, "Name");
+ if (Name==0x33647666) //3dvf
+ Name=0x6D6F6F76; //moov
+ if (Name==0x61766964) //avid
+ Name=0x6D646174; //mdat
+
+ if (Size<8)
+ {
+ //Special case: until the end of the atom
+ if (Size==0)
+ {
+ Size=Config->File_Current_Size-(File_Offset+Buffer_Offset);
+ if (Status[IsAccepted] && Element_Level==2 && Name==0x00000000) //First real level (Level 1 is atom, level 2 is header block)
+ {
+ Element_Offset=0;
+ Name=Elements::mdat;
+ }
+ }
+ //Special case: Big files, size is 64-bit
+ else if (Size==1)
+ {
+ //Reading Extended size
+ Get_B8 (Size, "Size (Extended)");
+ }
+ //Not in specs!
+ else
+ {
+ Size=Config->File_Current_Size-(File_Offset+Buffer_Offset);
+ }
+ }
+
+ //Specific case: file begin with "free" atom
+ if (!Status[IsAccepted]
+ && (Name==Elements::free
+ || Name==Elements::skip
+ || Name==Elements::wide))
+ {
+ Accept("MPEG-4");
+ Fill(Stream_General, 0, General_Format, "QuickTime");
+ }
+
+ //Filling
+ Header_Fill_Code(Name, Ztring().From_CC4(Name));
+ Header_Fill_Size(Size);
+}
+
+//---------------------------------------------------------------------------
+bool File_Mpeg4::BookMark_Needed()
+{
+ if (!mdat_MustParse)
+ return false;
+
+ //Handling of some wrong stsz and stsc atoms (ADPCM)
+ if (!IsSecondPass)
+ for (std::map<int32u, stream>::iterator Temp=Streams.begin(); Temp!=Streams.end(); Temp++)
+ if (Temp->second.StreamKind==Stream_Audio
+ && (Retrieve(Stream_Audio, Temp->second.StreamPos, Audio_CodecID)==_T("ima4")
+ || Retrieve(Stream_Audio, Temp->second.StreamPos, Audio_CodecID)==_T("11")))
+ {
+ Temp->second.stsz_StreamSize/=16;
+ Temp->second.stsz_StreamSize*=17;
+ float32 BitRate_Nominal=Retrieve(Stream_Audio, Temp->second.StreamPos, Audio_BitRate_Nominal).To_float32();
+ if (BitRate_Nominal)
+ {
+ BitRate_Nominal/=16;
+ BitRate_Nominal*=17;
+ Fill(Stream_Audio, Temp->second.StreamPos, Audio_BitRate_Nominal, BitRate_Nominal, 0, true);
+ }
+ int64u Channels=Retrieve(Stream_Audio, Temp->second.StreamPos, Audio_Channel_s_).To_int64u();
+ if (Channels!=2)
+ {
+ Temp->second.stsz_StreamSize/=2;
+ Temp->second.stsz_StreamSize*=Channels;
+ }
+ for (size_t Pos=0; Pos<Temp->second.stsc.size(); Pos++)
+ {
+ Temp->second.stsc[Pos].SamplesPerChunk/=16;
+ Temp->second.stsc[Pos].SamplesPerChunk*=17;
+ if (Channels!=2)
+ {
+ Temp->second.stsc[Pos].SamplesPerChunk/=2;
+ Temp->second.stsc[Pos].SamplesPerChunk*=(int32u)Channels;
+ }
+ }
+ }
+
+ //In case of second pass
+ if (mdat_Pos.empty())
+ {
+ //For each stream
+ for (std::map<int32u, stream>::iterator Temp=Streams.begin(); Temp!=Streams.end(); Temp++)
+ {
+ if (Temp->second.Parser && (!Temp->second.stsz.empty() || Temp->second.stsz_Sample_Size))
+ {
+ size_t stsc_Pos=0;
+ size_t stsz_Pos=0;
+ size_t Chunk_FrameCount=0;
+ int32u Chunk_Number=1;
+ int32u Sample_ByteSize=0;
+ if (Temp->second.StreamKind==Stream_Audio)
+ Sample_ByteSize=Retrieve(Stream_Audio, Temp->second.StreamPos, Audio_BitDepth).To_int32u()*Retrieve(Stream_Audio, Temp->second.StreamPos, Audio_Channel_s_).To_int32u()/8;
+
+ #if MEDIAINFO_DEMUX
+ stream::stts_durations Temp_stts_Durations;
+ #endif //MEDIAINFO_DEMUX
+ for (size_t stco_Pos=0; stco_Pos<Temp->second.stco.size(); stco_Pos++)
+ {
+ while (stsc_Pos+1<Temp->second.stsc.size() && Chunk_Number>=Temp->second.stsc[stsc_Pos+1].FirstChunk)
+ stsc_Pos++;
+
+ if (Temp->second.stsz_Sample_Size==0)
+ {
+ //Each sample has its own size
+ int64u Chunk_Offset=0;
+ for (size_t Pos=0; Pos<Temp->second.stsc[stsc_Pos].SamplesPerChunk; Pos++)
+ {
+ mdat_Pos[Temp->second.stco[stco_Pos]+Chunk_Offset].StreamID=Temp->first;
+ mdat_Pos[Temp->second.stco[stco_Pos]+Chunk_Offset].Size=Temp->second.stsz[stsz_Pos];
+ Chunk_Offset+=Temp->second.stsz[stsz_Pos];
+ stsz_Pos++;
+ if (stsz_Pos>=Temp->second.stsz.size())
+ break;
+ }
+ if (stsz_Pos>=Temp->second.stsz.size())
+ break;
+ }
+ else if (Temp->second.StreamKind==Stream_Audio && Temp->second.stsz_Sample_Size<=Sample_ByteSize && Temp->second.stsc[stsc_Pos].SamplesPerChunk*Temp->second.stsz_Sample_Size*Temp->second.stsz_Sample_Multiplier<0x1000000)
+ {
+ //Same size per sample, but granularity is too small
+ mdat_Pos[Temp->second.stco[stco_Pos]].StreamID=Temp->first;
+ mdat_Pos[Temp->second.stco[stco_Pos]].Size=Temp->second.stsc[stsc_Pos].SamplesPerChunk*Temp->second.stsz_Sample_Size*Temp->second.stsz_Sample_Multiplier;
+
+ #if MEDIAINFO_DEMUX
+ if (Temp_stts_Durations.empty() || Temp->second.stsc[stsc_Pos].SamplesPerChunk!=Temp_stts_Durations[Temp_stts_Durations.size()-1].SampleDuration)
+ {
+ stream::stts_duration stts_Duration;
+ stts_Duration.Pos_Begin=Temp_stts_Durations.empty()?0:Temp_stts_Durations[Temp_stts_Durations.size()-1].Pos_End;
+ stts_Duration.Pos_End=stts_Duration.Pos_Begin+1;
+ stts_Duration.SampleDuration=Temp->second.stsc[stsc_Pos].SamplesPerChunk;
+ stts_Duration.DTS_Begin=Temp_stts_Durations.empty()?0:Temp_stts_Durations[Temp_stts_Durations.size()-1].DTS_End;
+ stts_Duration.DTS_End=stts_Duration.DTS_Begin+stts_Duration.SampleDuration;
+ Temp_stts_Durations.push_back(stts_Duration);
+ //Temp->second.stsc[stsc_Pos].SamplesPerChunk=1;
+ }
+ else
+ {
+ Temp_stts_Durations[Temp_stts_Durations.size()-1].Pos_End++;
+ Temp_stts_Durations[Temp_stts_Durations.size()-1].DTS_End+=Temp_stts_Durations[Temp_stts_Durations.size()-1].SampleDuration;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+ else
+ {
+ //Same size per sample
+ int64u Chunk_Offset=0;
+ for (size_t Pos=0; Pos<Temp->second.stsc[stsc_Pos].SamplesPerChunk; Pos++)
+ {
+ mdat_Pos[Temp->second.stco[stco_Pos]+Chunk_Offset].StreamID=Temp->first;
+ mdat_Pos[Temp->second.stco[stco_Pos]+Chunk_Offset].Size=Temp->second.stsz_Sample_Size*Temp->second.stsz_Sample_Multiplier;
+ Chunk_Offset+=Temp->second.stsz_Sample_Size*Temp->second.stsz_Sample_Multiplier;
+ Chunk_FrameCount++;
+ }
+ if (Config_ParseSpeed<1.0 && Chunk_FrameCount>=300)
+ break;
+ }
+
+ Chunk_Number++;
+ }
+ Temp->second.Parser->Stream_BitRateFromContainer=Temp->second.stsz_StreamSize*8/(((float64)Temp->second.stts_Duration)/Temp->second.mdhd_TimeScale);
+ #if MEDIAINFO_DEMUX
+ if (!Temp_stts_Durations.empty())
+ {
+ Temp->second.stts_Durations=Temp_stts_Durations;
+ for (stsc_Pos=0; stsc_Pos<Temp->second.stsc.size(); stsc_Pos++)
+ Temp->second.stsc[stsc_Pos].SamplesPerChunk=1;
+ Temp->second.stts_FrameCount=Temp_stts_Durations[Temp_stts_Durations.size()-1].Pos_End;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+ }
+ mdat_Pos_Temp=mdat_Pos.begin();
+ }
+ if (mdat_Pos.empty())
+ return false;
+
+ IsParsing_mdat=false;
+ if (!mdat_Pos_ToParseInPriority_StreamIDs.empty())
+ {
+ //Hanlding StreamIDs to parse in priority (currently, only the first block of each stream is parsed in priority)
+ if (!Streams[mdat_Pos_ToParseInPriority_StreamIDs[0]].stco.empty())
+ {
+ mdat_pos::iterator Temp=mdat_Pos.find(Streams[mdat_Pos_ToParseInPriority_StreamIDs[0]].stco[0]);
+ if (Temp!=mdat_Pos.end() && Temp->first<File_Size) //Skipping data not in a truncated file
+ {
+ Element_Show();
+ while (Element_Level>0)
+ Element_End0();
+ Element_Begin1("Priority streams");
+
+ mdat_Pos_Temp=Temp;
+ GoTo(Temp->first);
+ IsParsing_mdat=true;
+ }
+ }
+ mdat_Pos_ToParseInPriority_StreamIDs.erase(mdat_Pos_ToParseInPriority_StreamIDs.begin());
+ }
+
+ if (File_GoTo==(int64u)-1 && !mdat_Pos_NormalParsing)
+ {
+ Element_Show();
+ while (Element_Level>0)
+ Element_End0();
+ Element_Begin1("Second pass");
+
+ mdat_Pos_Temp=mdat_Pos.begin();
+ GoTo(mdat_Pos_Temp->first);
+ IsParsing_mdat=true;
+ mdat_Pos_NormalParsing=true;
+ }
+
+ IsSecondPass=true;
+ return false; //We do not want to use the bookmark feature, only detect the end of the file
+}
+
+//---------------------------------------------------------------------------
+//Get language string from 2CC
+Ztring File_Mpeg4::Language_Get(int16u Language)
+{
+ if (Language==0x7FFF || Language==0xFFFF)
+ return Ztring();
+
+ if (Language<0x100)
+ return Mpeg4_Language_Apple(Language);
+
+ Ztring ToReturn;
+ ToReturn.append(1, (Char)((Language>>10&0x1F)+0x60));
+ ToReturn.append(1, (Char)((Language>> 5&0x1F)+0x60));
+ ToReturn.append(1, (Char)((Language>> 0&0x1F)+0x60));
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+//Get Metadata definition from 4CC
+File_Mpeg4::method File_Mpeg4::Metadata_Get(std::string &Parameter, int64u Meta)
+{
+ File_Mpeg4::method Method;
+ switch (Meta)
+ {
+ //http://atomicparsley.sourceforge.net/mpeg-4files.html
+ case Elements::moov_meta___ART : Parameter="Performer"; Method=Method_String; break;
+ case Elements::moov_meta___alb : Parameter="Album"; Method=Method_String; break;
+ case Elements::moov_meta___aut : Parameter="Performer"; Method=Method_String; break;
+ case Elements::moov_meta___cmt : Parameter="Comment"; Method=Method_String; break;
+ case Elements::moov_meta___cpy : Parameter="Copyright"; Method=Method_String; break;
+ case Elements::moov_meta___day : Parameter="Recorded_Date"; Method=Method_String; break;
+ case Elements::moov_meta___des : Parameter="Title/More"; Method=Method_String; break;
+ case Elements::moov_meta___dir : Parameter="Director"; Method=Method_String; break;
+ case Elements::moov_meta___dis : Parameter="TermsOfUse"; Method=Method_String; break;
+ case Elements::moov_meta___edl : Parameter="Tagged_Date"; Method=Method_String; break;
+ case Elements::moov_meta___enc : Parameter="Encoded_Application"; Method=Method_String; break;
+ case Elements::moov_meta___fmt : Parameter="Origin"; Method=Method_String; break;
+ case Elements::moov_meta___gen : Parameter="Genre"; Method=Method_String; break;
+ case Elements::moov_meta___grp : Parameter="Grouping"; Method=Method_String; break;
+ case Elements::moov_meta___hos : Parameter="HostComputer"; Method=Method_String; break;
+ case Elements::moov_meta___inf : Parameter="Title/More"; Method=Method_String; break;
+ case Elements::moov_meta___key : Parameter="Keywords"; Method=Method_String; break;
+ case Elements::moov_meta___mak : Parameter="Make"; Method=Method_String; break;
+ case Elements::moov_meta___mod : Parameter="Model"; Method=Method_String; break;
+ case Elements::moov_meta___nam : Parameter="Title"; Method=Method_String3; break;
+ case Elements::moov_meta___prd : Parameter="Producer"; Method=Method_String; break;
+ case Elements::moov_meta___PRD : Parameter="Product"; Method=Method_String; break;
+ case Elements::moov_meta___prf : Parameter="Performer"; Method=Method_String; break;
+ case Elements::moov_meta___req : Parameter="Comment"; Method=Method_String; break;
+ case Elements::moov_meta___src : Parameter="DistribtedBy"; Method=Method_String; break;
+ case Elements::moov_meta___swr : Parameter="Encoded_Application"; Method=Method_String; break;
+ case Elements::moov_meta___too : Parameter="Encoded_Application"; Method=Method_String; break;
+ case Elements::moov_meta___wrn : Parameter="Warning"; Method=Method_String; break;
+ case Elements::moov_meta___wrt : Parameter="Composer"; Method=Method_String; break;
+ case Elements::moov_meta__auth : Parameter="Performer"; Method=Method_String2; break;
+ case Elements::moov_meta__albm : Parameter="Album"; Method=Method_String2; break; //Has a optional track number after the NULL byte
+ case Elements::moov_meta__aART : Parameter="Album/Performer"; Method=Method_String2; break;
+ case Elements::moov_meta__cpil : Parameter="Compilation"; Method=Method_Binary; break;
+ case Elements::moov_meta__cprt : Parameter="Copyright"; Method=Method_String2; break;
+ case Elements::moov_meta__disk : Parameter="Part"; Method=Method_Binary; break;
+ case Elements::moov_meta__dscp : Parameter="Title/More"; Method=Method_String2; break;
+ case Elements::moov_meta__gnre : Parameter="Genre"; Method=Method_String2; break;
+ case Elements::moov_meta__name : Parameter="Title"; Method=Method_String; break;
+ case Elements::moov_meta__perf : Parameter="Performer"; Method=Method_String2; break;
+ case Elements::moov_meta__pgap : Parameter.clear(); Method=Method_None; break;
+ case Elements::moov_meta__titl : Parameter="Title"; Method=Method_String2; break;
+ case Elements::moov_meta__tool : Parameter="Encoded_Application"; Method=Method_String3; break;
+ case Elements::moov_meta__trkn : Parameter="Track"; Method=Method_Binary; break;
+ case Elements::moov_meta__year : Parameter="Recorded_Date"; Method=Method_String2; break;
+ case Elements::moov_meta__tmpo : Parameter="BPM"; Method=Method_Binary; break;
+ default :
+ {
+ Parameter.clear();
+ Parameter.append(1, (char)((Meta&0xFF000000)>>24));
+ Parameter.append(1, (char)((Meta&0x00FF0000)>>16));
+ Parameter.append(1, (char)((Meta&0x0000FF00)>> 8));
+ Parameter.append(1, (char)((Meta&0x000000FF)>> 0));
+ Method=Method_String;
+ }
+ }
+
+ Ztring Value;
+ Value.append(1, (Char)((Meta&0xFF000000)>>24)); //Can not use From_CC4 because there is sometimes the (C) character, not in Ansi 7-bit, so wrongly decoded on UTF-8 systems
+ Value.append(1, (Char)((Meta&0x00FF0000)>>16));
+ Value.append(1, (Char)((Meta&0x0000FF00)>> 8));
+ Value.append(1, (Char)((Meta&0x000000FF)>> 0));
+ if (MediaInfoLib::Config.CustomMapping_IsPresent(_T("MP4"), Value))
+ Parameter=MediaInfoLib::Config.CustomMapping_Get(_T("MP4"), Value).To_Local();
+
+ return Method;
+}
+
+//---------------------------------------------------------------------------
+//Get Metadata definition from string
+File_Mpeg4::method File_Mpeg4::Metadata_Get(std::string &Parameter, const std::string &Meta)
+{
+ if (Meta=="com.apple.quicktime.copyright") Parameter="Copyright";
+ else if (Meta=="com.apple.quicktime.displayname") Parameter="Title";
+ else if (Meta=="DATE") Parameter="Encoded_Date";
+ else if (Meta=="iTunNORM") Parameter="";
+ else if (Meta=="iTunes_CDDB_IDs") Parameter="";
+ else if (Meta=="iTunSMPB") Parameter="";
+ else if (Meta=="PERFORMER") Parameter="Performer";
+ else if (Meta=="PUBLISHER") Parameter="Publisher";
+ else Parameter=Meta;
+ return Method_String;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::Descriptors()
+{
+ //Preparing
+ File_Mpeg4_Descriptors MI;
+ MI.KindOfStream=StreamKind_Last;
+ MI.Parser_DoNotFreeIt=true;
+
+ int64u Elemen_Code_Save=Element_Code;
+ Element_Code=moov_trak_tkhd_TrackID; //Element_Code is use for stream identifier
+ Open_Buffer_Init(&MI);
+ Element_Code=Elemen_Code_Save;
+ mdat_MustParse=true; //Data is in MDAT
+
+ //Parsing
+ Open_Buffer_Continue(&MI);
+
+ //Filling
+ Finish(&MI);
+ Merge(MI, StreamKind_Last, 0, StreamPos_Last);
+
+ //Special case: AAC
+ if (StreamKind_Last==Stream_Audio
+ && (Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("AAC")
+ || Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("MPEG Audio")
+ || Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("Vorbis")))
+ Clear(Stream_Audio, StreamPos_Last, Audio_BitDepth); //Resolution is not valid for AAC / MPEG Audio / Vorbis
+
+ //Parser from Descriptor
+ if (MI.Parser)
+ {
+ if (Streams[moov_trak_tkhd_TrackID].Parser)
+ delete Streams[moov_trak_tkhd_TrackID].Parser; //Streams[moov_trak_tkhd_TrackID].Parser=NULL
+ Streams[moov_trak_tkhd_TrackID].Parser=MI.Parser;
+ mdat_MustParse=true;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::TimeCode_Associate(int32u TrackID)
+{
+ //Trying to detect time code attached to 1 video only but for all streams in reality
+ int32u TimeCode_TrackID=(int32u)-1;
+ bool TimeCode_TrackID_MoreThanOne=false;
+ for (std::map<int32u, stream>::iterator Strea=Streams.begin(); Strea!=Streams.end(); Strea++)
+ if (Strea->second.TimeCode_TrackID!=(int32u)-1)
+ {
+ if (TimeCode_TrackID==(int32u)-1)
+ TimeCode_TrackID=Strea->second.TimeCode_TrackID;
+ else
+ TimeCode_TrackID_MoreThanOne=true;
+ }
+ if (!TimeCode_TrackID_MoreThanOne && TimeCode_TrackID!=(int32u)-1)
+ for (std::map<int32u, stream>::iterator Strea=Streams.begin(); Strea!=Streams.end(); Strea++)
+ Strea->second.TimeCode_TrackID=TimeCode_TrackID; //For all tracks actually
+
+ //Is it general or for a specific stream?
+ bool IsGeneral=true;
+ for (std::map<int32u, stream>::iterator Strea=Streams.begin(); Strea!=Streams.end(); Strea++)
+ if (Strea->second.TimeCode_TrackID==TrackID)
+ IsGeneral=false;
+
+ //For each track in the file (but only the last one will be used!)
+ for (std::map<int32u, stream>::iterator Strea=Streams.begin(); Strea!=Streams.end(); Strea++)
+ if ((IsGeneral && Strea->second.StreamKind!=Stream_Max) || Strea->second.TimeCode_TrackID==TrackID)
+ {
+ if (Strea->second.StreamKind==Stream_Video)
+ {
+ Fill(Stream_Video, Strea->second.StreamPos, Video_Delay_Settings, Ztring(_T("DropFrame="))+(Streams[TrackID].TimeCode->DropFrame?_T("Yes"):_T("No")));
+ Fill(Stream_Video, Strea->second.StreamPos, Video_Delay_Settings, Ztring(_T("24HourMax="))+(Streams[TrackID].TimeCode->H24?_T("Yes"):_T("No")));
+ Fill(Stream_Video, Strea->second.StreamPos, Video_Delay_Settings, Ztring(_T("IsVisual="))+(Streams[TrackID].TimeCode_IsVisual?_T("Yes"):_T("No")));
+ }
+ Fill(Strea->second.StreamKind, Strea->second.StreamPos, "Delay", Streams[TrackID].Parser->Get(Stream_General, 0, "Delay"));
+ Fill(Strea->second.StreamKind, Strea->second.StreamPos, "Delay_Source", "Container");
+ }
+ }
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPEG4_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4.h
new file mode 100644
index 000000000..ca277a749
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4.h
@@ -0,0 +1,483 @@
+// File_Mpeg4 - Info for MPEG-4 files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Mpeg4H
+#define MediaInfo_File_Mpeg4H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include <map>
+class File_MpegPs;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class File__ReferenceFilesHelper;
+
+//***************************************************************************
+// Class File_Mpeg4
+//***************************************************************************
+
+class File_Mpeg4 : public File__Analyze
+{
+protected :
+ //Streams management
+ void Streams_Accept();
+ void Streams_Finish();
+ void Streams_Finish_CommercialNames ();
+
+public :
+ File_Mpeg4();
+ ~File_Mpeg4();
+
+private :
+ //Buffer - Global
+ void Read_Buffer_Unsynched();
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer
+ bool Header_Begin();
+ void Header_Parse();
+ void Data_Parse();
+ bool BookMark_Needed();
+
+ //Elements
+ void cdat();
+ void cdt2() {cdat();}
+ void free();
+ void ftyp();
+ void idat();
+ void idsc();
+ void jp2c();
+ void jp2h();
+ void jp2h_ihdr();
+ void jp2h_colr();
+ void mdat();
+ void mdat_xxxx();
+ void mdat_StreamJump();
+ void mfra();
+ void mfra_mfro();
+ void mfra_tfra();
+ void moof();
+ void moof_mfhd();
+ void moof_traf();
+ void moof_traf_sdtp();
+ void moof_traf_tfhd();
+ void moof_traf_trun();
+ void moov();
+ void moov_cmov();
+ void moov_cmov_cmvd();
+ void moov_cmov_cmvd_zlib();
+ void moov_cmov_dcom();
+ void moov_ctab();
+ void moov_iods();
+ void moov_meta();
+ void moov_meta_hdlr();
+ void moov_meta_bxml();
+ void moov_meta_keys();
+ void moov_meta_keys_mdta();
+ void moov_meta_ilst();
+ void moov_meta_ilst_xxxx();
+ void moov_meta_ilst_xxxx_data();
+ void moov_meta_ilst_xxxx_mean();
+ void moov_meta_ilst_xxxx_name();
+ void moov_meta_xml();
+ void moov_mvex();
+ void moov_mvex_mehd();
+ void moov_mvex_trex();
+ void moov_mvhd();
+ void moov_trak();
+ void moov_trak_edts();
+ void moov_trak_edts_elst();
+ void moov_trak_load();
+ void moov_trak_mdia();
+ void moov_trak_mdia_hdlr();
+ void moov_trak_mdia_imap();
+ void moov_trak_mdia_imap_sean();
+ void moov_trak_mdia_imap_sean___in();
+ void moov_trak_mdia_imap_sean___in___ty();
+ void moov_trak_mdia_imap_sean___in_dtst();
+ void moov_trak_mdia_imap_sean___in_obid();
+ void moov_trak_mdia_mdhd();
+ void moov_trak_mdia_minf();
+ void moov_trak_mdia_minf_code();
+ void moov_trak_mdia_minf_code_sean();
+ void moov_trak_mdia_minf_code_sean_RU_A();
+ void moov_trak_mdia_minf_dinf();
+ void moov_trak_mdia_minf_dinf_url_();
+ void moov_trak_mdia_minf_dinf_urn_();
+ void moov_trak_mdia_minf_dinf_dref();
+ void moov_trak_mdia_minf_dinf_dref_alis();
+ void moov_trak_mdia_minf_dinf_dref_rsrc();
+ void moov_trak_mdia_minf_gmhd();
+ void moov_trak_mdia_minf_gmhd_gmin();
+ void moov_trak_mdia_minf_gmhd_tmcd();
+ void moov_trak_mdia_minf_gmhd_tmcd_tcmi();
+ void moov_trak_mdia_minf_hint();
+ void moov_trak_mdia_minf_hdlr();
+ void moov_trak_mdia_minf_hmhd();
+ void moov_trak_mdia_minf_nmhd();
+ void moov_trak_mdia_minf_smhd();
+ void moov_trak_mdia_minf_vmhd();
+ void moov_trak_mdia_minf_stbl();
+ void moov_trak_mdia_minf_stbl_cslg();
+ void moov_trak_mdia_minf_stbl_co64();
+ void moov_trak_mdia_minf_stbl_ctts();
+ void moov_trak_mdia_minf_stbl_sdtp();
+ void moov_trak_mdia_minf_stbl_stco();
+ void moov_trak_mdia_minf_stbl_stdp();
+ void moov_trak_mdia_minf_stbl_stps();
+ void moov_trak_mdia_minf_stbl_stsc();
+ void moov_trak_mdia_minf_stbl_stsd();
+ void moov_trak_mdia_minf_stbl_stsd_text();
+ void moov_trak_mdia_minf_stbl_stsd_tmcd();
+ void moov_trak_mdia_minf_stbl_stsd_tmcd_name();
+ void moov_trak_mdia_minf_stbl_stsd_tx3g();
+ void moov_trak_mdia_minf_stbl_stsd_tx3g_ftab();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx();
+ void moov_trak_mdia_minf_stbl_stsd_xxxxSound();
+ void moov_trak_mdia_minf_stbl_stsd_xxxxStream();
+ void moov_trak_mdia_minf_stbl_stsd_xxxxText();
+ void moov_trak_mdia_minf_stbl_stsd_xxxxVideo();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_avcC();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_alac();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_bitr();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_btrt();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_chan();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_clap();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_colr();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_d263();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_dac3();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_dec3();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_ddts();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_damr();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_esds();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_fiel();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_glbl();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_idfm();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_jp2h() {jp2h();}
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_jp2h_colr() {jp2h_colr();}
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_jp2h_ihdr() {jp2h_ihdr();}
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_pasp();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_sinf();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_frma();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_imif();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_schm();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_schi();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_wave();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_wave_acbf();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_wave_enda();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_wave_frma();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_wave_samr();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_wave_srcq();
+ void moov_trak_mdia_minf_stbl_stsd_xxxx_wave_xxxx();
+ void moov_trak_mdia_minf_stbl_stsh();
+ void moov_trak_mdia_minf_stbl_stss();
+ void moov_trak_mdia_minf_stbl_stsz();
+ void moov_trak_mdia_minf_stbl_stts();
+ void moov_trak_mdia_minf_stbl_stts_Common(int32u SampleCount, int32u SampleDuration, int32u Pos=0, int32u NumberOfEntries=1);
+ void moov_trak_mdia_minf_stbl_stz2() {moov_trak_mdia_minf_stbl_stsz();}
+ void moov_trak_meta() {moov_meta();}
+ void moov_trak_meta_hdlr() {moov_meta_hdlr();}
+ void moov_trak_meta_bxml() {moov_meta_bxml();}
+ void moov_trak_meta_keys() {moov_meta_keys();}
+ void moov_trak_meta_keys_mdta() {moov_meta_keys_mdta();}
+ void moov_trak_meta_ilst() {moov_meta_ilst();}
+ void moov_trak_meta_ilst_xxxx() {moov_meta_ilst_xxxx();}
+ void moov_trak_meta_ilst_xxxx_data() {moov_meta_ilst_xxxx_data();}
+ void moov_trak_meta_ilst_xxxx_mean() {moov_meta_ilst_xxxx_mean();}
+ void moov_trak_meta_ilst_xxxx_name() {moov_meta_ilst_xxxx_name();}
+ void moov_trak_meta_xml() {moov_meta_xml();}
+ void moov_trak_tapt();
+ void moov_trak_tapt_clef();
+ void moov_trak_tapt_prof();
+ void moov_trak_tapt_enof();
+ void moov_trak_tkhd();
+ void moov_trak_tref();
+ void moov_trak_tref_dpnd();
+ void moov_trak_tref_ipir();
+ void moov_trak_tref_hint();
+ void moov_trak_tref_mpod();
+ void moov_trak_tref_ssrc();
+ void moov_trak_tref_sync();
+ void moov_trak_tref_tmcd();
+ void moov_udta();
+ void moov_udta_AllF();
+ void moov_udta_chpl();
+ void moov_udta_clsf();
+ void moov_udta_cprt();
+ void moov_udta_DcMD();
+ void moov_udta_DcMD_Cmbo();
+ void moov_udta_DcMD_DcME();
+ void moov_udta_DcMD_DcME_Keyw();
+ void moov_udta_DcMD_DcME_Mtmd();
+ void moov_udta_DcMD_DcME_Rate();
+ void moov_udta_FIEL();
+ void moov_udta_FXTC();
+ void moov_udta_hinf();
+ void moov_udta_hinv();
+ void moov_udta_hnti();
+ void moov_udta_hnti_rtp ();
+ void moov_udta_ID32();
+ void moov_udta_kywd();
+ void moov_udta_loci();
+ void moov_udta_LOOP();
+ void moov_udta_MCPS();
+ void moov_udta_meta();
+ void moov_udta_meta_hdlr();
+ void moov_udta_meta_ilst();
+ void moov_udta_meta_ilst_xxxx();
+ void moov_udta_meta_ilst_xxxx_data();
+ void moov_udta_meta_ilst_xxxx_mean();
+ void moov_udta_meta_ilst_xxxx_name();
+ void moov_udta_ndrm();
+ void moov_udta_nsav();
+ void moov_udta_rtng();
+ void moov_udta_ptv ();
+ void moov_udta_Sel0();
+ void moov_udta_tags();
+ void moov_udta_tags_meta();
+ void moov_udta_tags_tseg();
+ void moov_udta_tags_tseg_tshd();
+ void moov_udta_WLOC();
+ void moov_udta_XMP_();
+ void moov_udta_yrrc();
+ void moov_udta_xxxx();
+ void PICT();
+ void pckg();
+ void pnot();
+ void RDAO();
+ void RDAS();
+ void RDVO();
+ void RDVS();
+ void RED1();
+ void REDA();
+ void REDV();
+ void REOB();
+ void skip();
+ void wide();
+
+ //Helpers
+ bool Element_Level_Get();
+ bool Element_Name_Get();
+ bool Element_Size_Get();
+ Ztring Language_Get(int16u Language);
+ enum method
+ {
+ Method_None,
+ Method_String,
+ Method_String2,
+ Method_String3,
+ Method_Integer,
+ Method_Binary
+ };
+ method Metadata_Get(std::string &Parameter, int64u Meta);
+ method Metadata_Get(std::string &Parameter, const std::string &Meta);
+ void Descriptors();
+ void TimeCode_Associate(int32u TrackID);
+
+ //Temp
+ bool List;
+ bool mdat_MustParse;
+ int32u moov_cmov_dcom_Compressor;
+ int32u moov_meta_hdlr_Type;
+ std::string moov_meta_ilst_xxxx_name_Name;
+ size_t moov_trak_mdia_minf_stbl_stsd_Pos;
+ int32u moov_trak_tkhd_TrackID;
+ float32 moov_trak_tkhd_Width;
+ float32 moov_trak_tkhd_Height;
+ float32 moov_trak_tkhd_DisplayAspectRatio;
+ float32 moov_trak_tkhd_Rotation;
+ std::vector<std::string> moov_udta_meta_keys_List;
+ size_t moov_udta_meta_keys_ilst_Pos;
+ int32u TimeScale;
+ int32u Vendor;
+ Ztring Vendor_Version;
+ int64u FirstMdatPos;
+ int64u LastMdatPos; //This is the position of the byte after the last byte of mdat
+ int64u FirstMoovPos;
+ int64u moof_base_data_offset;
+ int64u moof_traf_base_data_offset;
+ int32u moof_traf_default_sample_duration;
+ int32u moof_traf_default_sample_size;
+ int32u MajorBrand;
+ bool IsSecondPass;
+ bool IsParsing_mdat;
+ bool IsFragmented;
+
+ //Data
+ struct stream
+ {
+ Ztring File_Name;
+ File__Analyze* Parser;
+ MediaInfo_Internal* MI;
+ struct timecode
+ {
+ int32u TimeScale;
+ int32u FrameDuration;
+ bool DropFrame;
+ bool H24;
+ bool NegativeTimes;
+ };
+ timecode* TimeCode;
+ stream_t StreamKind;
+ size_t StreamPos;
+ struct edts_struct
+ {
+ int32u Duration;
+ int32u Delay;
+ int32u Rate;
+ };
+ std::vector<edts_struct> edts;
+ std::vector<int64u> stco;
+ struct stsc_struct
+ {
+ int32u FirstChunk;
+ int32u SamplesPerChunk;
+ };
+ std::vector<stsc_struct> stsc;
+ std::vector<int64u> stsz;
+ std::vector<int64u> stsz_Total; //TODO: merge with stsz
+ int64u stsz_StreamSize; //TODO: merge with stsz
+ std::vector<int64u> stss; //Sync Sample, base=0
+ struct stts_struct
+ {
+ int32u SampleCount;
+ int32u SampleDuration;
+ };
+ std::vector<stts_struct> stts;
+ int64u stsz_Sample_Size;
+ int64u stsz_Sample_Multiplier;
+ int64u stsz_Sample_Count;
+ int64u tkhd_Duration;
+ int32u mdhd_TimeScale;
+ int64u mdhd_Duration;
+ int32u stts_Min;
+ int32u stts_Max;
+ int64u stts_FrameCount;
+ int64u stts_Duration;
+ int64u stts_Duration_FirstFrame;
+ int64u stts_Duration_LastFrame;
+ int64u stts_SampleDuration;
+ int32u mvex_trex_default_sample_duration;
+ int32u mvex_trex_default_sample_size;
+ int32u TimeCode_TrackID;
+ bool TimeCode_IsVisual;
+ bool IsPcmMono;
+ bool IsPriorityStream;
+ bool IsFilled;
+ float32 CleanAperture_Width;
+ float32 CleanAperture_Height;
+ float32 CleanAperture_PixelAspectRatio;
+ #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ int8u Demux_Level;
+
+ struct stts_duration
+ {
+ int64u Pos_Begin;
+ int64u Pos_End;
+ int64u DTS_Begin;
+ int64u DTS_End;
+ int32u SampleDuration;
+ };
+ typedef std::vector<stts_duration> stts_durations;
+ stts_durations stts_Durations;
+ size_t stts_Durations_Pos;
+ int64u stts_FramePos;
+ #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+
+ stream()
+ {
+ Parser=NULL;
+ MI=NULL;
+ TimeCode=NULL;
+ StreamKind=Stream_Max;
+ StreamPos=0;
+ stsz_StreamSize=0;
+ stsz_Sample_Size=0;
+ stsz_Sample_Multiplier=1;
+ stsz_Sample_Count=0;
+ tkhd_Duration=0;
+ mdhd_TimeScale=0;
+ mdhd_Duration=0;
+ stts_Min=(int32u)-1;
+ stts_Max=0;
+ stts_FrameCount=0;
+ stts_Duration=0;
+ stts_Duration_FirstFrame=0;
+ stts_Duration_LastFrame=0;
+ mvex_trex_default_sample_duration=0;
+ mvex_trex_default_sample_size=0;
+ TimeCode_TrackID=(int32u)-1;
+ TimeCode_IsVisual=false;
+ IsPcmMono=false;
+ IsPriorityStream=false;
+ IsFilled=false;
+ CleanAperture_Width=0;
+ CleanAperture_Height=0;
+ CleanAperture_PixelAspectRatio=0;
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ stts_Durations_Pos=0;
+ stts_FramePos=0;
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ ~stream()
+ {
+ delete Parser; //Parser=NULL;
+ delete MI; //MI=NULL;
+ delete TimeCode; //TimeCode=NULL;
+ }
+ };
+ typedef std::map<int32u, stream> streams;
+ streams Streams;
+ streams::iterator Stream;
+ File__ReferenceFilesHelper* ReferenceFiles;
+ #if MEDIAINFO_NEXTPACKET
+ bool ReferenceFiles_IsParsing;
+ #endif //MEDIAINFO_NEXTPACKET
+
+ //Positions
+ struct mdat_Pos_Type
+ {
+ int32u StreamID;
+ int64u Size;
+ };
+ typedef std::map<int64u, mdat_Pos_Type> mdat_pos;
+ mdat_pos mdat_Pos;
+ mdat_pos::iterator mdat_Pos_Temp;
+ std::vector<int32u> mdat_Pos_ToParseInPriority_StreamIDs;
+ bool mdat_Pos_NormalParsing;
+
+ #if MEDIAINFO_DEMUX
+ int64u TimeCode_FrameOffset;
+ int64u TimeCode_DtsOffset;
+ #endif //MEDIAINFO_DEMUX
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Descriptors.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Descriptors.cpp
new file mode 100644
index 000000000..95041f0b5
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Descriptors.cpp
@@ -0,0 +1,1008 @@
+// File_Mpeg4 - Info for MPEG-4 files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Descriptors part
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_MPEG4_YES
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Mpeg4_Descriptors.h"
+#include <cstring>
+#if defined(MEDIAINFO_OGG_YES)
+ #include "MediaInfo/Multiple/File_Ogg.h"
+#endif
+#if defined(MEDIAINFO_AVC_YES)
+ #include "MediaInfo/Video/File_Avc.h"
+#endif
+#if defined(MEDIAINFO_VC1_YES)
+ #include "MediaInfo/Video/File_Vc1.h"
+#endif
+#if defined(MEDIAINFO_DIRAC_YES)
+ #include "MediaInfo/Video/File_Dirac.h"
+#endif
+#if defined(MEDIAINFO_MPEG4V_YES)
+ #include "MediaInfo/Video/File_Mpeg4v.h"
+#endif
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_JPEG_YES)
+ #include "MediaInfo/Image/File_Jpeg.h"
+#endif
+#if defined(MEDIAINFO_PNG_YES)
+ #include "MediaInfo/Image/File_Png.h"
+#endif
+#if defined(MEDIAINFO_AAC_YES)
+ #include "MediaInfo/Audio/File_Aac.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_DTS_YES)
+ #include "MediaInfo/Audio/File_Dts.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if MEDIAINFO_DEMUX
+ #include "base64.h"
+#endif //MEDIAINFO_DEMUX
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_MPEG4V_YES
+ const char* Mpeg4v_Profile_Level(int32u Profile_Level);
+#endif //MEDIAINFO_MPEG4V_YES
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_Descriptors_Predefined(int8u ID)
+{
+ switch (ID)
+ {
+ case 0x00 : return "Custom";
+ case 0x01 : return "null SL packet header";
+ case 0x02 : return "Reserved for use in MP4 files";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_Descriptors_ObjectTypeIndication(int8u ID)
+{
+ switch (ID)
+ {
+ case 0x01 : return "Systems ISO/IEC 14496-1";
+ case 0x02 : return "Systems ISO/IEC 14496-1 (v2)";
+ case 0x03 : return "Interaction Stream";
+ case 0x05 : return "AFX Stream";
+ case 0x06 : return "Font Data Stream";
+ case 0x07 : return "Synthesized Texture Stream";
+ case 0x08 : return "Streaming Text Stream";
+ case 0x20 : return "Visual ISO/IEC 14496-2 (MPEG-4 Visual)";
+ case 0x21 : return "Visual ISO/IEC 14496-10 (AVC)";
+ case 0x22 : return "Parameter Sets for Visual ISO/IEC 14496-10 (AVC)";
+ case 0x24 : return "ALS"; //Not sure
+ case 0x2B : return "SAOC"; //Not sure
+ case 0x40 : return "Audio ISO/IEC 14496-3 (AAC)";
+ case 0x60 : return "Visual ISO/IEC 13818-2 Simple Profile (MPEG Video)";
+ case 0x61 : return "Visual ISO/IEC 13818-2 Main Profile (MPEG Video)";
+ case 0x62 : return "Visual ISO/IEC 13818-2 SNR Profile (MPEG Video)";
+ case 0x63 : return "Visual ISO/IEC 13818-2 Spatial Profile (MPEG Video)";
+ case 0x64 : return "Visual ISO/IEC 13818-2 High Profile (MPEG Video)";
+ case 0x65 : return "Visual ISO/IEC 13818-2 422 Profile (MPEG Video)";
+ case 0x66 : return "Audio ISO/IEC 13818-7 Main Profile (AAC)";
+ case 0x67 : return "Audio ISO/IEC 13818-7 Low Complexity Profile (AAC)";
+ case 0x68 : return "Audio ISO/IEC 13818-7 Scaleable Sampling Rate Profile (AAC)";
+ case 0x69 : return "Audio ISO/IEC 13818-3 (MPEG Audio)";
+ case 0x6A : return "Visual ISO/IEC 11172-2 (MPEG Video)";
+ case 0x6B : return "Audio ISO/IEC 11172-3 (MPEG Audio)";
+ case 0x6C : return "Visual ISO/IEC 10918-1 (JPEG)";
+ case 0x6D : return "PNG";
+ case 0xA0 : return "EVRC";
+ case 0xA1 : return "SMV";
+ case 0xA2 : return "3GPP2 Compact Multimedia Format (CMF)";
+ case 0xA3 : return "VC-1";
+ case 0xA4 : return "Dirac";
+ case 0xA5 : return "AC-3";
+ case 0xA6 : return "E-AC-3";
+ case 0xA9 : return "DTS";
+ case 0xAA : return "DTS-HD High Resolution";
+ case 0xAB : return "DTS-HD Master Audio";
+ case 0xAC : return "DTS-HD Express";
+ case 0xD1 : return "Private - EVRC";
+ case 0xD3 : return "Private - AC-3";
+ case 0xD4 : return "Private - DTS";
+ case 0xDD : return "Private - Ogg";
+ case 0xDE : return "Private - Ogg";
+ case 0xE1 : return "Private - QCELP";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_Descriptors_StreamType(int8u ID)
+{
+ switch (ID)
+ {
+ case 0x01 : return "ObjectDescriptorStream";
+ case 0x02 : return "ClockReferenceStream";
+ case 0x03 : return "SceneDescriptionStream";
+ case 0x04 : return "VisualStream";
+ case 0x05 : return "AudioStream";
+ case 0x06 : return "MPEG7Stream";
+ case 0x07 : return "IPMPStream";
+ case 0x08 : return "ObjectContentInfoStream";
+ case 0x09 : return "MPEGJStream";
+ case 0x0A : return "Interaction Stream";
+ case 0x0B : return "IPMPToolStream";
+ case 0x0C : return "FontDataStream";
+ case 0x0D : return "StreamingText";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_Descriptors_ODProfileLevelIndication(int8u /*ID*/)
+{
+ return "";
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_Descriptors_SceneProfileLevelIndication(int8u ID)
+{
+ switch (ID)
+ {
+ case 1 : return "Simple2D@L1";
+ case 2 : return "Simple2D@L2";
+ case 11 : return "Basic2D@L1";
+ case 12 : return "Core2D@L1";
+ case 13 : return "Core2D@L2";
+ case 14 : return "Advanced2D@L1";
+ case 15 : return "Advanced2D@L2";
+ case 16 : return "Advanced2D@L3";
+ case 17 : return "Main2D@L1";
+ case 18 : return "Main2D@L2";
+ case 19 : return "Main2D@L3";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_Descriptors_AudioProfileLevelIndication(int8u ID)
+{
+ switch (ID)
+ {
+ case 1 : return "Main@L1";
+ case 2 : return "Main@L2";
+ case 3 : return "Main@L3";
+ case 4 : return "Main@L4";
+ case 5 : return "Scalable@L1";
+ case 6 : return "Scalable@L2";
+ case 7 : return "Scalable@L3";
+ case 8 : return "Scalable@L4";
+ case 9 : return "Speech@L1";
+ case 10 : return "Speech@L2";
+ case 11 : return "Synthesis@L1";
+ case 12 : return "Synthesis@L2";
+ case 13 : return "Synthesis@L3";
+ case 14 : return "HighQualityAudio@L1";
+ case 15 : return "HighQualityAudio@L2";
+ case 16 : return "HighQualityAudio@L3";
+ case 17 : return "HighQualityAudio@L4";
+ case 18 : return "HighQualityAudio@L5";
+ case 19 : return "HighQualityAudio@L6";
+ case 20 : return "HighQualityAudio@L7";
+ case 21 : return "HighQualityAudio@L8";
+ case 22 : return "LowDelayAudio@L1";
+ case 23 : return "LowDelayAudio@L2";
+ case 24 : return "LowDelayAudio@L3";
+ case 25 : return "LowDelayAudio@L4";
+ case 26 : return "LowDelayAudio@L5";
+ case 27 : return "LowDelayAudio@L6";
+ case 28 : return "LowDelayAudio@L7";
+ case 29 : return "LowDelayAudio@L8";
+ case 30 : return "NaturalAudio@L1";
+ case 31 : return "NaturalAudio@L2";
+ case 32 : return "NaturalAudio@L3";
+ case 33 : return "NaturalAudio@L4";
+ case 34 : return "MobileAudioInternetworking@L1";
+ case 35 : return "MobileAudioInternetworking@L2";
+ case 36 : return "MobileAudioInternetworking@L3";
+ case 37 : return "MobileAudioInternetworking@L4";
+ case 38 : return "MobileAudioInternetworking@L5";
+ case 39 : return "MobileAudioInternetworking@L6";
+ case 40 : return "AAC@L1";
+ case 41 : return "AAC@L2";
+ case 42 : return "AAC@L4";
+ case 43 : return "AAC@L5";
+ case 44 : return "HighEfficiencyAAC@L2";
+ case 45 : return "HighEfficiencyAAC@L3";
+ case 46 : return "HighEfficiencyAAC@L4";
+ case 47 : return "HighEfficiencyAAC@L5";
+ case 59 : return "HighDefinitionAAC@L1";
+ case 60 : return "ALSSimple@L1";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+extern const char* Mpeg4v_Profile_Level(int32u Profile_Level);
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_Descriptors_GraphicsProfileLevelIndication(int8u ID)
+{
+ switch (ID)
+ {
+ case 1 : return "Simple2D@L1";
+ case 2 : return "Simple2D+Text@L1";
+ case 3 : return "Simple2D+Text@L2";
+ case 4 : return "Core2D@L1";
+ case 5 : return "Core2D@L2";
+ case 6 : return "Advanced2D@L1";
+ case 7 : return "Advanced2D@L2";
+ default : return "";
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Mpeg4_Descriptors::File_Mpeg4_Descriptors()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("MPEG-4 Descriptor");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Mpeg4_Desc;
+ StreamIDs_Width[0]=0;
+ #endif //MEDIAINFO_EVENTS
+ IsRawStream=true;
+
+ //In
+ KindOfStream=Stream_Max;
+ Parser_DoNotFreeIt=false;
+ SLConfig_DoNotFreeIt=false;
+
+ //Out
+ Parser=NULL;
+ ES_ID=0x0000;
+ SLConfig=NULL;
+
+ //Temp
+ ObjectTypeId=0x00;
+}
+
+//---------------------------------------------------------------------------
+File_Mpeg4_Descriptors::~File_Mpeg4_Descriptors()
+{
+ if (!Parser_DoNotFreeIt)
+ delete Parser;// Parser=NULL;
+ if (!SLConfig_DoNotFreeIt)
+ delete SLConfig;// SLConfig=NULL;
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Header_Parse()
+{
+ //Parsing
+ size_t Size=0;
+ int8u type, Size_ToAdd;
+ Get_B1(type, "type");
+ if (type==0)
+ {
+ Header_Fill_Code(0x00, "Padding");
+ Header_Fill_Size(1);
+ return;
+ }
+ do
+ {
+ Get_B1(Size_ToAdd, "size");
+ Size=(Size<<7) | (Size_ToAdd&0x7F);
+ }
+ while (Size_ToAdd&0x80);
+
+ //Filling
+ Header_Fill_Code(type, Ztring().From_CC1(type));
+ if (Element_Offset+Size>=Element_Size)
+ Size=(size_t)(Element_Size-Element_Offset); //Found one file with too big size but content is OK, cutting the block
+ Header_Fill_Size(Element_Offset+Size);
+}
+
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Data_Parse()
+{
+ //Preparing
+ Status[IsAccepted]=true;
+
+ #define ELEMENT_CASE(_NAME, _DETAIL) \
+ case 0x##_NAME : Element_Name(_DETAIL); Descriptor_##_NAME(); break;
+
+ //Parsing
+ switch (Element_Code)
+ {
+ ELEMENT_CASE(00, "Forbidden");
+ ELEMENT_CASE(01, "ObjectDescrTag");
+ ELEMENT_CASE(02, "InitialObjectDescrTag");
+ ELEMENT_CASE(03, "ES_DescrTag");
+ ELEMENT_CASE(04, "DecoderConfigDescrTag");
+ ELEMENT_CASE(05, "DecSpecificInfoTag");
+ ELEMENT_CASE(06, "SLConfigDescrTag");
+ ELEMENT_CASE(07, "ContentIdentDescrTag");
+ ELEMENT_CASE(08, "SupplContentIdentDescrTag");
+ ELEMENT_CASE(09, "IPI_DescrPointerTag");
+ ELEMENT_CASE(0A, "IPMP_DescrPointerTag");
+ ELEMENT_CASE(0B, "IPMP_DescrTag");
+ ELEMENT_CASE(0C, "QoS_DescrTag");
+ ELEMENT_CASE(0D, "RegistrationDescrTag");
+ ELEMENT_CASE(0E, "ES_ID_IncTag");
+ ELEMENT_CASE(0F, "ES_ID_RefTag");
+ ELEMENT_CASE(10, "MP4_IOD_Tag");
+ ELEMENT_CASE(11, "MP4_OD_Tag");
+ ELEMENT_CASE(12, "IPL_DescrPointerRefTag");
+ ELEMENT_CASE(13, "ExtendedProfileLevelDescrTag");
+ ELEMENT_CASE(14, "profileLevelIndicationIndexDescrTag");
+ ELEMENT_CASE(40, "ContentClassificationDescrTag");
+ ELEMENT_CASE(41, "KeyWordDescrTag");
+ ELEMENT_CASE(42, "RatingDescrTag");
+ ELEMENT_CASE(43, "LanguageDescrTag");
+ ELEMENT_CASE(44, "ShortTextualDescrTag");
+ ELEMENT_CASE(45, "ExpandedTextualDescrTag");
+ ELEMENT_CASE(46, "ContentCreatorNameDescrTag");
+ ELEMENT_CASE(47, "ContentCreationDateDescrTag");
+ ELEMENT_CASE(48, "OCICreatorNameDescrTag");
+ ELEMENT_CASE(49, "OCICreationDateDescrTag");
+ ELEMENT_CASE(4A, "SmpteCameraPositionDescrTag");
+ ELEMENT_CASE(4B, "SegmentDescrTag");
+ ELEMENT_CASE(4C, "MediaTimeDescrTag");
+ ELEMENT_CASE(60, "IPMP_ToolsListDescrTag");
+ ELEMENT_CASE(61, "IPMP_ToolTag");
+ ELEMENT_CASE(62, "FLEXmuxTimingDescrTag");
+ ELEMENT_CASE(63, "FLEXmuxCodeTableDescrTag");
+ ELEMENT_CASE(64, "ExtSLConfigDescrTag");
+ ELEMENT_CASE(65, "FLEXmuxBufferSizeDescrTag");
+ ELEMENT_CASE(66, "FLEXmuxIdentDescrTag");
+ ELEMENT_CASE(67, "DependencyPointerTag");
+ ELEMENT_CASE(68, "DependencyMarkerTag");
+ ELEMENT_CASE(69, "FLEXmuxChannelDescrTag");
+ default: if (Element_Code>=0xC0)
+ Element_Name("user private");
+ else
+ Element_Name("unknown");
+ Skip_XX(Element_Size, "Data");
+ break;
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Descriptor_01()
+{
+ //Parsing
+ bool URL_Flag;
+ BS_Begin();
+ Skip_S2(10, "ObjectDescriptorID");
+ Get_SB ( URL_Flag, "URL_Flag");
+ Skip_SB( "includeInlineProfileLevelFlag");
+ Skip_S1( 4, "reserved");
+ BS_End();
+ if (URL_Flag)
+ {
+ int8u URLlength;
+ Get_B1 (URLlength, "URLlength");
+ Skip_UTF8(URLlength, "URLstring");
+ }
+ if (Element_Code==0x02 || Element_Code==0x10)
+ {
+ Info_B1(ODProfileLevel, "ODProfileLevelIndication"); Param_Info1(Mpeg4_Descriptors_ODProfileLevelIndication(ODProfileLevel));
+ Info_B1(SceneProfileLevel, "sceneProfileLevelIndication"); Param_Info1(Mpeg4_Descriptors_SceneProfileLevelIndication(SceneProfileLevel));
+ Info_B1(AudioProfileLevel, "audioProfileLevelIndication"); Param_Info1(Mpeg4_Descriptors_AudioProfileLevelIndication(AudioProfileLevel));
+ Info_B1(VisualProfileLevel, "visualProfileLevelIndication"); Param_Info1(Mpeg4v_Profile_Level(VisualProfileLevel));
+ Info_B1(GraphicsProfileLevel, "graphicsProfileLevelIndication"); Param_Info1(Mpeg4_Descriptors_GraphicsProfileLevelIndication(GraphicsProfileLevel));
+ }
+
+ FILLING_BEGIN();
+ Element_ThisIsAList();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Descriptor_03()
+{
+ //Parsing
+ bool streamDependenceFlag, URL_Flag, OCRstreamFlag;
+ Get_B2 (ES_ID, "ES_ID");
+ BS_Begin();
+ Get_SB ( streamDependenceFlag, "streamDependenceFlag");
+ Get_SB ( URL_Flag, "URL_Flag");
+ Get_SB ( OCRstreamFlag, "OCRstreamFlag");
+ Skip_S1(5, "streamPriority");
+ BS_End();
+ if (streamDependenceFlag)
+ Skip_B2( "dependsOn_ES_ID");
+ if (URL_Flag)
+ {
+ int8u URLlength;
+ Get_B1 (URLlength, "URLlength");
+ Skip_UTF8(URLlength, "URLstring");
+ }
+ if (OCRstreamFlag)
+ Skip_B2( "OCR_ES_Id");
+
+ FILLING_BEGIN();
+ Element_ThisIsAList();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Descriptor_04()
+{
+ //Parsing
+ int32u bufferSizeDB, MaxBitrate, AvgBitrate;
+ int8u streamType;
+ Get_B1 (ObjectTypeId, "objectTypeIndication"); Param_Info1(Mpeg4_Descriptors_ObjectTypeIndication(ObjectTypeId));
+ BS_Begin();
+ Get_S1 (6, streamType, "streamType"); Param_Info1(Mpeg4_Descriptors_StreamType(streamType));
+ Skip_SB( "upStream");
+ Skip_SB( "reserved");
+ BS_End();
+ Get_B3 (bufferSizeDB, "bufferSizeDB");
+ Get_B4 (MaxBitrate, "maxBitrate");
+ Get_B4 (AvgBitrate, "avgBitrate");
+
+ FILLING_BEGIN();
+ if (KindOfStream==Stream_Max)
+ switch (ObjectTypeId)
+ {
+ case 0x20 :
+ case 0x21 :
+ case 0x60 :
+ case 0x61 :
+ case 0x62 :
+ case 0x63 :
+ case 0x64 :
+ case 0x65 :
+ case 0x6A :
+ case 0x6C :
+ case 0x6D :
+ case 0x6E :
+ case 0xA3 :
+ case 0xA4 :
+ KindOfStream=Stream_Video; break;
+ case 0x40 :
+ case 0x66 :
+ case 0x67 :
+ case 0x68 :
+ case 0x69 :
+ case 0x6B :
+ case 0xA0 :
+ case 0xA1 :
+ case 0xA5 :
+ case 0xA6 :
+ case 0xA9 :
+ case 0xAA :
+ case 0xAB :
+ case 0xAC :
+ case 0xD1 :
+ case 0xD3 :
+ case 0xD4 :
+ case 0xE1 :
+ KindOfStream=Stream_Audio; break;
+ case 0x08 :
+ KindOfStream=Stream_Text; break;
+ default: ;
+ }
+ if (Count_Get(KindOfStream)==0)
+ Stream_Prepare(KindOfStream);
+ switch (ObjectTypeId)
+ {
+ case 0x01 : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "System", Error, false, true); break;
+ case 0x02 : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "System Core", Error, false, true); break;
+ //case 0x03 Interaction Stream
+ //case 0x05 AFX
+ //case 0x06 Font Data
+ //case 0x07 Synthesized Texture Stream
+ case 0x08 : Fill(Stream_Text , StreamPos_Last, Text_Format, "Streaming Text", Error, false, true); break;
+ case 0x20 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG-4 Visual", Error, false, true); break;
+ case 0x21 : Fill(Stream_Video , StreamPos_Last, Video_Format, "AVC", Error, false, true); break;
+ //case 0x22 Parameter Sets for AVC
+ case 0x40 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "AAC", Error, false, true); break; //MPEG-4 AAC
+ case 0x60 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "Simple" , Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Error, false, true); break; //MPEG-2V Simple
+ case 0x61 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "Main" , Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Error, false, true); break; //MPEG-2V Main
+ case 0x62 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "SNR" , Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Error, false, true); break; //MPEG-2V SNR
+ case 0x63 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "Spatial", Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Error, false, true); break; //MPEG-2V Spatial
+ case 0x64 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "High" , Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Error, false, true); break; //MPEG-2V High
+ case 0x65 : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, "4:2:2" , Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 2", Error, false, true); break; //MPEG-2V 4:2:2
+ case 0x66 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "AAC", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "Main", Error, false, true); break; //MPEG-2 AAC Main
+ case 0x67 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "AAC", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "LC", Error, false, true); break; //MPEG-2 AAC LC
+ case 0x68 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "AAC", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "SSR", Error, false, true); break; //MPEG-2 AAC SSR
+ case 0x69 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "MPEG Audio", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Version, "Version 2", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "Layer 3", Error, false, true); break;
+ case 0x6A : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Error, false, true); Fill(Stream_Video, StreamPos_Last, Video_Format_Version, "Version 1", Error, false, true); break;
+ case 0x6B : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "MPEG Audio", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Version, "Version 1", Error, false, true); break;
+ case 0x6C : Fill(Stream_Video , StreamPos_Last, Video_Format, "JPEG", Error, false, true); break;
+ case 0x6D : Fill(Stream_Video , StreamPos_Last, Video_Format, "PNG", Error, false, true); break;
+ case 0x6E : Fill(Stream_Video , StreamPos_Last, Video_Format, "MPEG Video", Error, false, true); break;
+ case 0xA0 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "EVRC", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, 8000, 10, true); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 1, 10, true); break;
+ case 0xA1 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "SMV", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, 8000, 10, true); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 1, 10, true); break;
+ case 0xA2 : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "3GPP2", Error, false, true); break;
+ case 0xA3 : Fill(Stream_Video , StreamPos_Last, Video_Format, "VC-1", Error, false, true); break;
+ case 0xA4 : Fill(Stream_Video , StreamPos_Last, Video_Format, "Dirac", Error, false, true); break;
+ case 0xA5 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "AC-3", Error, false, true); break;
+ case 0xA6 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "E-AC-3", Error, false, true); break;
+ case 0xA9 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "DTS", Error, false, true); break;
+ case 0xAA : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "DTS", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "HRA", Error, false, true); break; // DTS-HD High Resolution
+ case 0xAB : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "DTS", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "MA", Error, false, true); break; // DTS-HD Master Audio
+ case 0xAC : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "DTS", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, "Express", Error, false, true); break; // DTS Express a.k.a. LBR
+ case 0xD1 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "EVRC", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, 8000, 10, true); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 1, 10, true); break;
+ case 0xD3 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "AC-3", Error, false, true); break;
+ case 0xD4 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "DTS", Error, false, true); break;
+ case 0xDD : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "Ogg", Error, false, true); break;
+ case 0xDE : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "Ogg", Error, false, true); break;
+ case 0xE1 : Fill(Stream_Audio , StreamPos_Last, Audio_Format, "QCELP", Error, false, true); Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, 8000, 10, true); Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, 1, 10, true); break;
+ default: ;
+ }
+ switch (ObjectTypeId)
+ {
+ case 0x01 : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), "System", Error, false, true); break;
+ case 0x02 : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), "System Core", Error, false, true); break;
+ case 0x20 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-4V", Error, false, true); break;
+ case 0x21 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "H264", Error, false, true); break;
+ case 0x40 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AAC", Error, false, true); break; //MPEG-4 AAC
+ case 0x60 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Error, false, true); break; //MPEG-2V Simple
+ case 0x61 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Error, false, true); break; //MPEG-2V Main
+ case 0x62 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Error, false, true); break; //MPEG-2V SNR
+ case 0x63 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Error, false, true); break; //MPEG-2V Spatial
+ case 0x64 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Error, false, true); break; //MPEG-2V High
+ case 0x65 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-2V", Error, false, true); break; //MPEG-2V 4:2:2
+ case 0x66 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AAC", Error, false, true); break; //MPEG-2 AAC Main
+ case 0x67 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AAC", Error, false, true); break; //MPEG-2 AAC LC
+ case 0x68 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AAC", Error, false, true); break; //MPEG-2 AAC SSR
+ case 0x69 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "MPEG-2A L3", Error, false, true); break;
+ case 0x6A : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-1V", Error, false, true); break;
+ case 0x6B : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "MPEG-1A", Error, false, true); break;
+ case 0x6C : Fill(Stream_Video , StreamPos_Last, Video_Codec, "JPEG", Error, false, true); break;
+ case 0x6D : Fill(Stream_Video , StreamPos_Last, Video_Codec, "PNG", Error, false, true); break;
+ case 0x6E : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-4V", Error, false, true); break;
+ case 0xA0 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "EVRC", Error, false, true); break;
+ case 0xA1 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "SMV", Error, false, true); break;
+ case 0xA2 : Fill(Stream_Video , StreamPos_Last, Video_Codec, "MPEG-4V", Error, false, true); break;
+ case 0xA3 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "VC-1", Error, false, true); break;
+ case 0xA4 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "Dirac", Error, false, true); break;
+ case 0xA5 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AC3", Error, false, true); break;
+ case 0xA6 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AC3+", Error, false, true); break;
+ case 0xA9 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "DTS", Error, false, true); break;
+ case 0xAA :
+ case 0xAB : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "DTS-HD", Error, false, true); break;
+ case 0xAC : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "DTS Express", Error, false, true); break;
+ case 0xD1 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "EVRC", Error, false, true); break;
+ case 0xD3 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "AC3", Error, false, true); break;
+ case 0xD4 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "DTS", Error, false, true); break;
+ case 0xDD : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), "Ogg", Error, false, true); break;
+ case 0xDE : Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), "Ogg", Error, false, true); break;
+ case 0xE1 : Fill(Stream_Audio , StreamPos_Last, Audio_Codec, "QCELP", Error, false, true); break;
+ default: ;
+ }
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_CodecID), ObjectTypeId, 16, true);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec_CC), ObjectTypeId, 16, true);
+
+ //Bitrate mode
+ if (AvgBitrate>0
+ && !(bufferSizeDB==AvgBitrate && bufferSizeDB==MaxBitrate && bufferSizeDB==0x1000)) //Some buggy data were found
+ {
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate_Nominal), AvgBitrate);
+ if (MaxBitrate<=AvgBitrate*1.005)
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate_Mode), "CBR");
+ else
+ {
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate_Mode), "VBR");
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate_Maximum), MaxBitrate);
+ }
+ }
+
+ //Creating parser
+ delete Parser; Parser=NULL;
+ switch (ObjectTypeId)
+ {
+ case 0x01 : switch (streamType)
+ {
+ case 0x01 : Parser=new File_Mpeg4_Descriptors; break;
+ default : ;
+ }
+ break;
+ case 0x20 : //MPEG-4 Visual
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ Parser=new File_Mpeg4v;
+ ((File_Mpeg4v*)Parser)->Frame_Count_Valid=1;
+ ((File_Mpeg4v*)Parser)->FrameIsAlwaysComplete=true;
+ #endif
+ break;
+ case 0x21 : //AVC
+ #if defined(MEDIAINFO_AVC_YES)
+ Parser=new File_Avc;
+ ((File_Avc*)Parser)->MustParse_SPS_PPS=true;
+ ((File_Avc*)Parser)->MustSynchronize=false;
+ ((File_Avc*)Parser)->SizedBlocks=true;
+ #endif
+ break;
+ case 0x40 : //MPEG-4 AAC
+ case 0x66 :
+ case 0x67 :
+ case 0x68 : //MPEG-2 AAC
+ #if defined(MEDIAINFO_AAC_YES)
+ Parser=new File_Aac;
+ ((File_Aac*)Parser)->Mode=File_Aac::Mode_AudioSpecificConfig;
+ ((File_Aac*)Parser)->FrameIsAlwaysComplete=true;
+ #endif
+ break;
+ case 0x60 :
+ case 0x61 :
+ case 0x62 :
+ case 0x63 :
+ case 0x64 :
+ case 0x65 :
+ case 0x6A : //MPEG Video
+ #if defined(MEDIAINFO_MPEGV_YES)
+ Parser=new File_Mpegv;
+ ((File_Mpegv*)Parser)->FrameIsAlwaysComplete=true;
+ #endif
+ break;
+ case 0x69 :
+ case 0x6B : //MPEG Audio
+ #if defined(MEDIAINFO_MPEGA_YES)
+ Parser=new File_Mpega;
+ #endif
+ break;
+ case 0x6C : //JPEG
+ #if defined(MEDIAINFO_JPEG_YES)
+ Parser=new File_Jpeg;
+ ((File_Jpeg*)Parser)->StreamKind=Stream_Video;
+ #endif
+ break;
+ case 0x6D : //PNG
+ #if defined(MEDIAINFO_PNG_YES)
+ Parser=new File_Png;
+ #endif
+ break;
+ case 0xA3 : //VC-1
+ #if defined(MEDIAINFO_VC1_YES)
+ Parser=new File_Vc1;
+ #endif
+ break;
+ case 0xA4 : //Dirac
+ #if defined(MEDIAINFO_DIRAC_YES)
+ Parser=new File_Dirac;
+ #endif
+ break;
+ case 0xA5 : //AC-3
+ case 0xA6 : //E-AC-3
+ case 0xD3 : //AC-3
+ #if defined(MEDIAINFO_AC3_YES)
+ Parser=new File_Ac3;
+ #endif
+ break;
+ case 0xA9 : //DTS
+ case 0xAA : //DTS HRA
+ case 0xAB : //DTS MA
+ case 0xAC : //DTS Express
+ case 0xD4 : //DTS
+ #if defined(MEDIAINFO_DTS_YES)
+ Parser=new File_Dts;
+ #endif
+ break;
+ case 0xDD :
+ case 0xDE : //OGG
+ #if defined(MEDIAINFO_OGG_YES)
+ Parser=new File_Ogg;
+ Parser->MustSynchronize=false;
+ ((File_Ogg*)Parser)->SizedBlocks=true;
+ #endif
+ break;
+ default: ;
+ }
+
+ Element_Code=(int64u)-1;
+ Open_Buffer_Init(Parser);
+
+ Element_ThisIsAList();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Descriptor_05()
+{
+ if (ObjectTypeId==0x00 && Parser==NULL) //If no ObjectTypeId detected
+ {
+ switch (KindOfStream)
+ {
+ case Stream_Video :
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ delete Parser; Parser=new File_Mpeg4v;
+ ((File_Mpeg4v*)Parser)->FrameIsAlwaysComplete=true;
+ #endif
+ break;
+ case Stream_Audio :
+ #if defined(MEDIAINFO_AAC_YES)
+ delete Parser; Parser=new File_Aac;
+ ((File_Aac*)Parser)->Mode=File_Aac::Mode_AudioSpecificConfig;
+ #endif
+ break;
+ default: ;
+ }
+
+ Element_Code=(int64u)-1;
+ Open_Buffer_Init(Parser);
+ }
+
+ if (Parser==NULL)
+ {
+ Skip_XX(Element_Size, "Unknown");
+ return;
+ }
+
+ //Parser configuration before the parsing
+ switch (ObjectTypeId)
+ {
+ case 0x60 :
+ case 0x61 :
+ case 0x62 :
+ case 0x63 :
+ case 0x64 :
+ case 0x65 :
+ case 0x6A : //MPEG Video
+ #if defined(MEDIAINFO_MPEGV_YES)
+ ((File_Mpegv*)Parser)->TimeCodeIsNotTrustable=true;
+ #endif
+ break;
+ default: ;
+ }
+
+ //Parsing
+ Open_Buffer_Continue(Parser);
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ switch (Config->Demux_InitData_Get())
+ {
+ case 0 : //In demux event
+ Demux_Level=2; //Container
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_Header);
+ break;
+ case 1 : //In field
+ {
+ std::string Data_Raw((const char*)(Buffer+Buffer_Offset), (size_t)Element_Size);
+ std::string Data_Base64(Base64::encode(Data_Raw));
+ Parser->Fill(KindOfStream, 0, "Demux_InitBytes", Data_Base64);
+ }
+ break;
+ default : ;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ //Parser configuration after the parsing
+ switch (ObjectTypeId)
+ {
+ case 0x60 :
+ case 0x61 :
+ case 0x62 :
+ case 0x63 :
+ case 0x64 :
+ case 0x65 :
+ case 0x6A : //MPEG Video
+ #if defined(MEDIAINFO_MPEGV_YES)
+ ((File_Mpegv*)Parser)->TimeCodeIsNotTrustable=false;
+ #endif
+ break;
+ default: ;
+ }
+
+ //Positionning
+ Element_Offset=Element_Size;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Descriptor_06()
+{
+ delete SLConfig; SLConfig=new slconfig;
+
+ //Parsing
+ int8u predefined;
+ Get_B1 (predefined, "predefined"); Param_Info1(Mpeg4_Descriptors_Predefined(predefined));
+ switch (predefined)
+ {
+ case 0x00 :
+ {
+ BS_Begin();
+ Get_SB (SLConfig->useAccessUnitStartFlag, "useAccessUnitStartFlag");
+ Get_SB (SLConfig->useAccessUnitEndFlag, "useAccessUnitEndFlag");
+ Get_SB (SLConfig->useRandomAccessPointFlag, "useRandomAccessPointFlag");
+ Get_SB (SLConfig->hasRandomAccessUnitsOnlyFlag, "hasRandomAccessUnitsOnlyFlag");
+ Get_SB (SLConfig->usePaddingFlag, "usePaddingFlag");
+ Get_SB (SLConfig->useTimeStampsFlag, "useTimeStampsFlag");
+ Get_SB (SLConfig->useIdleFlag, "useIdleFlag");
+ Get_SB (SLConfig->durationFlag, "durationFlag");
+ BS_End();
+ Get_B4 (SLConfig->timeStampResolution, "timeStampResolution");
+ Get_B4( SLConfig->OCRResolution, "OCRResolution");
+ Get_B1 (SLConfig->timeStampLength, "timeStampLength");
+ Get_B1 (SLConfig->OCRLength, "OCRLength");
+ Get_B1 (SLConfig->AU_Length, "AU_Length");
+ Get_B1 (SLConfig->instantBitrateLength, "instantBitrateLength");
+ BS_Begin();
+ Get_S1 (4, SLConfig->degradationPriorityLength, "degradationPriorityLength");
+ Get_S1 (5, SLConfig->AU_seqNumLength, "AU_seqNumLength");
+ Get_S1 (5, SLConfig->packetSeqNumLength, "packetSeqNumLength");
+ Skip_S1(2, "reserved");
+ BS_End();
+ }
+ break;
+ case 0x01 :
+ SLConfig->useAccessUnitStartFlag =false;
+ SLConfig->useAccessUnitEndFlag =false;
+ SLConfig->useRandomAccessPointFlag =false;
+ SLConfig->hasRandomAccessUnitsOnlyFlag =false;
+ SLConfig->usePaddingFlag =false;
+ SLConfig->useTimeStampsFlag =false;
+ SLConfig->useIdleFlag =false;
+ SLConfig->durationFlag =false; //-
+ SLConfig->timeStampResolution =1000;
+ SLConfig->OCRResolution =0; //-
+ SLConfig->timeStampLength =32;
+ SLConfig->OCRLength =0; //-
+ SLConfig->AU_Length =0;
+ SLConfig->instantBitrateLength =0; //-
+ SLConfig->degradationPriorityLength =0;
+ SLConfig->AU_seqNumLength =0;
+ SLConfig->packetSeqNumLength =0;
+ break;
+ case 0x02 :
+ SLConfig->useAccessUnitStartFlag =false;
+ SLConfig->useAccessUnitEndFlag =false;
+ SLConfig->useRandomAccessPointFlag =false;
+ SLConfig->hasRandomAccessUnitsOnlyFlag =false;
+ SLConfig->usePaddingFlag =false;
+ SLConfig->useTimeStampsFlag =true;
+ SLConfig->useIdleFlag =false;
+ SLConfig->durationFlag =false;
+ SLConfig->timeStampResolution =0; //-
+ SLConfig->OCRResolution =0; //-
+ SLConfig->timeStampLength =0;
+ SLConfig->OCRLength =0;
+ SLConfig->AU_Length =0;
+ SLConfig->instantBitrateLength =0;
+ SLConfig->degradationPriorityLength =0;
+ SLConfig->AU_seqNumLength =0;
+ SLConfig->packetSeqNumLength =0;
+ break;
+ default :
+ SLConfig->useAccessUnitStartFlag =false;
+ SLConfig->useAccessUnitEndFlag =false;
+ SLConfig->useRandomAccessPointFlag =false;
+ SLConfig->hasRandomAccessUnitsOnlyFlag =false;
+ SLConfig->usePaddingFlag =false;
+ SLConfig->useTimeStampsFlag =false;
+ SLConfig->useIdleFlag =false;
+ SLConfig->durationFlag =false;
+ SLConfig->timeStampResolution =0;
+ SLConfig->OCRResolution =0;
+ SLConfig->timeStampLength =0;
+ SLConfig->AU_Length =0;
+ SLConfig->instantBitrateLength =0;
+ SLConfig->degradationPriorityLength =0;
+ SLConfig->AU_seqNumLength =0;
+ SLConfig->packetSeqNumLength =0;
+ }
+ if (SLConfig->durationFlag)
+ {
+ Get_B4 (SLConfig->timeScale, "timeScale");
+ Get_B2 (SLConfig->accessUnitDuration, "accessUnitDuration");
+ Get_B2 (SLConfig->compositionUnitDuration, "compositionUnitDuration");
+ }
+ else
+ {
+ SLConfig->timeScale =0; //-
+ SLConfig->accessUnitDuration =0; //-
+ SLConfig->compositionUnitDuration =0; //-
+ }
+ if (!SLConfig->useTimeStampsFlag)
+ {
+ BS_Begin();
+ Get_S8 (SLConfig->timeStampLength, SLConfig->startDecodingTimeStamp, "startDecodingTimeStamp");
+ Get_S8 (SLConfig->timeStampLength, SLConfig->startCompositionTimeStamp, "startCompositionTimeStamp");
+ BS_End();
+ }
+ else
+ {
+ SLConfig->startDecodingTimeStamp =0; //-
+ SLConfig->startCompositionTimeStamp =0; //-
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Descriptor_09()
+{
+ //Parsing
+ Skip_B2( "IPI_ES_Id");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Descriptor_0E()
+{
+ //Parsing
+ Skip_B4( "Track_ID"); //ID of the track to use
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Descriptor_0F()
+{
+ //Parsing
+ Skip_B2( "ref_index"); //track ref. index of the track to use
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Descriptor_10()
+{
+ Descriptor_02();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_Descriptors::Descriptor_11()
+{
+ Descriptor_01();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPEG4_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Descriptors.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Descriptors.h
new file mode 100644
index 000000000..a67a0ae13
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Descriptors.h
@@ -0,0 +1,144 @@
+// File_Mpeg4_Descriptors - Info for MPEG files
+// Copyright (C) 2007-2007 Jerome Martinez, Zen@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MPEG-4 files, Descriptors
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Mpeg4_DescriptorsH
+#define MediaInfo_Mpeg4_DescriptorsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Mpeg4_Descriptors
+//***************************************************************************
+
+class File_Mpeg4_Descriptors : public File__Analyze
+{
+public :
+ //In
+ stream_t KindOfStream;
+ bool Parser_DoNotFreeIt; //If you want to keep the Parser
+ bool SLConfig_DoNotFreeIt; //If you want to keep the SLConfig
+
+ //Out
+ File__Analyze* Parser;
+ int16u ES_ID;
+
+ struct slconfig
+ {
+ bool useAccessUnitStartFlag;
+ bool useAccessUnitEndFlag;
+ bool useRandomAccessPointFlag;
+ bool hasRandomAccessUnitsOnlyFlag;
+ bool usePaddingFlag;
+ bool useTimeStampsFlag;
+ bool useIdleFlag;
+ bool durationFlag;
+ int32u timeStampResolution;
+ int32u OCRResolution;
+ int8u timeStampLength;
+ int8u OCRLength;
+ int8u AU_Length;
+ int8u instantBitrateLength;
+ int8u degradationPriorityLength;
+ int8u AU_seqNumLength;
+ int8u packetSeqNumLength;
+
+ int32u timeScale;
+ int16u accessUnitDuration;
+ int16u compositionUnitDuration;
+
+ int64u startDecodingTimeStamp;
+ int64u startCompositionTimeStamp;
+ };
+
+ slconfig* SLConfig;
+
+public :
+ //Constructor/Destructor
+ File_Mpeg4_Descriptors();
+ ~File_Mpeg4_Descriptors();
+
+private :
+ //Buffer
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Descriptor_00() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_01();
+ void Descriptor_02() {Descriptor_01();}
+ void Descriptor_03();
+ void Descriptor_04();
+ void Descriptor_05();
+ void Descriptor_06();
+ void Descriptor_07() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_08() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_09();
+ void Descriptor_0A() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_0B() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_0C() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_0D() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_0E();
+ void Descriptor_0F();
+ void Descriptor_10();
+ void Descriptor_11();
+ void Descriptor_12() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_13() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_14() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_40() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_41() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_42() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_43() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_44() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_45() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_46() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_47() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_48() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_49() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_4A() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_4B() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_4C() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_60() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_61() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_62() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_63() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_64() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_65() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_66() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_67() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_68() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_69() {Skip_XX(Element_Size, "Data");};
+
+ //Temp
+ int8u ObjectTypeId;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Elements.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Elements.cpp
new file mode 100644
index 000000000..8e07fb138
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_Elements.cpp
@@ -0,0 +1,6050 @@
+// File_Mpeg4 - Info for MPEG-4 files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR . See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Elements part
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_MPEG4_YES
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Mpeg4.h"
+#if defined(MEDIAINFO_DVDIF_YES)
+ #include "MediaInfo/Multiple/File_DvDif.h"
+#endif
+#if defined(MEDIAINFO_MXF_YES)
+ #include "MediaInfo/Multiple/File_Mxf.h"
+#endif
+#if defined(MEDIAINFO_AVC_YES)
+ #include "MediaInfo/Video/File_Avc.h"
+#endif
+#if defined(MEDIAINFO_H263_YES)
+ #include "MediaInfo/Video/File_H263.h"
+#endif
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_VC1_YES)
+ #include "MediaInfo/Video/File_Vc1.h"
+#endif
+#if defined(MEDIAINFO_VC3_YES)
+ #include "MediaInfo/Video/File_Vc3.h"
+#endif
+#if defined(MEDIAINFO_AAC_YES)
+ #include "MediaInfo/Audio/File_Aac.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_AES3_YES)
+ #include "MediaInfo/Audio/File_ChannelGrouping.h"
+#endif
+#if defined(MEDIAINFO_AMR_YES)
+ #include "MediaInfo/Audio/File_Amr.h"
+#endif
+#if defined(MEDIAINFO_ADPCM_YES)
+ #include "MediaInfo/Audio/File_Adpcm.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if defined(MEDIAINFO_PCM_YES)
+ #include "MediaInfo/Audio/File_Pcm.h"
+#endif
+#if defined(MEDIAINFO_CDP_YES)
+ #include "MediaInfo/Text/File_Cdp.h"
+#endif
+#if defined(MEDIAINFO_EIA608_YES)
+ #include "MediaInfo/Text/File_Eia608.h"
+#endif
+#if defined(MEDIAINFO_JPEG_YES)
+ #include "MediaInfo/Image/File_Jpeg.h"
+#endif
+#include "MediaInfo/Multiple/File_Mpeg4_TimeCode.h"
+#include "ZenLib/FileName.h"
+#include "base64.h"
+#include <cmath>
+#include <zlib.h>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_Meta_Kind(int32u Kind)
+{
+ switch (Kind)
+ {
+ case 0x00 : return "Binary";
+ case 0x01 : return "UTF8";
+ case 0x02 : return "UTF16";
+ case 0x03 : return "Mac String";
+ case 0x0E : return "Jpeg";
+ case 0x15 : return "Signed Integer"; //the size of the integer is derived from the container size
+ case 0x16 : return "Float 32";
+ case 0x17 : return "Float 64";
+ default : return "Unknown";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_TypeModifierName(int32u TypeModifierName)
+{
+ switch (TypeModifierName)
+ {
+ case 0x01 : return "Matrix";
+ case 0x02 : return "Clip";
+ case 0x03 : return "Volume";
+ case 0x04 : return "Audio balance";
+ case 0x05 : return "Graphic mode";
+ case 0x06 : return "Matrix object";
+ case 0x07 : return "Graphics mode object";
+ case 0x76696465 : return "Image type";
+ default : return "Unknown";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_sample_depends_on[]=
+{
+ "",
+ "this sample does depend on others (not an I picture)",
+ "this sample does not depend on others (I picture)",
+ "reserved",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_sample_is_depended_on[]=
+{
+ "",
+ "other samples depend on this one (not disposable)",
+ "no other sample depends on this one (disposable)",
+ "reserved",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_sample_has_redundancy[]=
+{
+ "",
+ "there is redundant coding in this sample",
+ "there is no redundant coding in this sample",
+ "reserved",
+};
+
+//---------------------------------------------------------------------------
+Ztring Mpeg4_Vendor(int32u Vendor)
+{
+ switch (Vendor)
+ {
+ case 0x46464D50 : return _T("FFMpeg");
+ case 0x4D4F544F : return _T("Motorola");
+ case 0x50484C50 : return _T("Philips");
+ case 0x6170706C : return _T("Apple");
+ case 0x6E6F6B69 : return _T("Nokia");
+ case 0x6D6F746F : return _T("Motorola");
+ default : return Ztring().From_CC4(Vendor);
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_chan(int16u Ordering)
+{
+ //Source: http://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/CACoreAudioReference/CoreAudioTypes/CompositePage.html
+ //Arbitrary decision (0° = Front):
+ //Front = 0°-80°
+ //Side = 80°-120°
+ //Rear = 120°-180°
+ switch(Ordering)
+ {
+ case 100 : return "Front: C";
+ case 101 : return "Front: L R";
+ case 102 : return "Front: L R (Headphones)"; //With headphones
+ case 103 : return "Front: L R (Matrix)"; //With matrix
+ case 104 : return "Front: C S";
+ case 105 : return "Front: X Y";
+ case 106 : return "Front: L R (Binaural)";
+ case 107 : return "Front: W X Y Z";
+ case 108 : return "Front: L R, Side: L R";
+ case 109 : return "Front: L C R, Rear: L R";
+ case 110 : return "Front: L C R, Rear: L C R";
+ case 111 : return "Front: L C R, Side: L R, Rear: L C R";
+ case 112 : return "Front: L R, TopFront: L R, Rear: L R, TopRear: L R";
+ case 113 : return "Front: L C R";
+ case 114 : return "Front: L C R";
+ case 115 : return "Front: L C R, Rear: C";
+ case 116 : return "Front: L C R, Rear: C";
+ case 117 : return "Front: L C R, Side: L R";
+ case 118 : return "Front: L C R, Side: L R";
+ case 119 : return "Front: L C R, Side: L R";
+ case 120 : return "Front: L C R, Side: L R";
+ case 121 : return "Front: L C R, Side: L R, LFE";
+ case 122 : return "Front: L C R, Side: L R, LFE";
+ case 123 : return "Front: L C R, Side: L R, LFE";
+ case 124 : return "Front: L C R, Side: L R, LFE";
+ case 125 : return "Front: L C R, Side: L C R";
+ case 126 : return "Front: L Lc C Rc R, Side: L R";
+ case 127 : return "Front: L Lc Rc R, Side: L R, LFE";
+ case 128 : return "Front: L C R, Side: L R, Rear: L R, LFE";
+ case 129 : return "Front: L C R, Side: L R, Rear: L R, LFE";
+ case 130 : return "Front: L C R, Side: L R, LFE / L R (Matrix)";
+ case 131 : return "Front: L R, Rear: C";
+ case 132 : return "Front: L R, Side: L R";
+ case 133 : return "Front: L R, LFE";
+ case 134 : return "Front: L R, Rear: C, LFE";
+ case 135 : return "Front: L C R, Side: L R, LFE";
+ case 136 : return "Front: L C R, LFE";
+ case 137 : return "Front: L C R, Rear: C, LFE";
+ case 138 : return "Front: L R, Rear: L R, LFE";
+ case 139 : return "Front: L C R, Rear: L R, LFE";
+ case 140 : return "Front: L C R, Side: L R, Rear: L R";
+ case 141 : return "Front: L C R, Side: L R, Rear: C";
+ case 142 : return "Front: L C R, Side: L R, Rear: C, LFE";
+ case 143 : return "Front: L C R, Side: L R, Rear: L R";
+ case 144 : return "Front: L C R, Side: L R, Rear: L C R";
+ case 145 : return "Front: Lw L C R Rw, TopFront: L C R, Side: L R, Rear: L C Cd R, LFE: L R"; //d=direct, all must be confirmed
+ case 146 : return "Front: Lw L Lc C Rc R Rw, TopFront: L C R, Side: L R, Rear: L C Cd R, LFE: L R, HI, VI, Haptic"; //d=direct, all must be confirmed
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_chan_Layout(int16u Ordering)
+{
+ //Source: http://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/CACoreAudioReference/CoreAudioTypes/CompositePage.html
+ // L - left
+ // R - right
+ // C - center
+ // Ls - left surround
+ // Rs - right surround
+ // Cs - center surround
+ // Rls - rear left surround
+ // Rrs - rear right surround
+ // Lw - left wide
+ // Rw - right wide
+ // Lsd - left surround direct
+ // Rsd - right surround direct
+ // Lc - left center
+ // Rc - right center
+ // Ts - top surround
+ // Vhl - vertical height left
+ // Vhc - vertical height center
+ // Vhr - vertical height right
+ // Lt - left matrix total. for matrix encoded stereo.
+ // Rt - right matrix total. for matrix encoded stereo.
+ switch(Ordering)
+ {
+ case 100 : return "C";
+ case 101 : return "L R";
+ case 102 : return "L R"; //With headphones
+ case 103 : return "Lt Rt"; //L R with matrix
+ case 104 : return "M S";
+ case 105 : return "X Y";
+ case 106 : return "L R";
+ case 107 : return "W X Y Z";
+ case 108 : return "L R Ls Rs";
+ case 109 : return "L R Lrs Rrs C";
+ case 110 : return "L R Lrs Rrs C Cs";
+ case 111 : return "L R Lrs Rrs C Crs, Ls, Rs";
+ case 112 : return "L R Lrs Rrs Vhl Vhr, Vhlrs, Vhrrs";
+ case 113 : return "L R C";
+ case 114 : return "C L R";
+ case 115 : return "L R C Cs";
+ case 116 : return "C L R Cs";
+ case 117 : return "L R C Ls Rs";
+ case 118 : return "L R Ls Rs C";
+ case 119 : return "L C R Ls Rs";
+ case 120 : return "C L R Ls Rs";
+ case 121 : return "L R C LFE Ls Rs";
+ case 122 : return "L R Ls Rs C LFE";
+ case 123 : return "L C R Ls Rs LFE";
+ case 124 : return "C L R Ls Rs LFE";
+ case 125 : return "L R C LFE Ls Rs Cs";
+ case 126 : return "L R C LFE Ls Rs Lc Rc";
+ case 127 : return "C Lc Rc L R Ls Rs LFE";
+ case 128 : return "L R C LFE Ls R Rls Rrs";
+ case 129 : return "L R Ls Rs C LFE Lc Rc";
+ case 130 : return "L R C LFE Ls Rs Lt Rt";
+ case 131 : return "L R Cs";
+ case 132 : return "L R Ls Rs";
+ case 133 : return "L R LFE";
+ case 134 : return "L R LFE Cs";
+ case 135 : return "L R LFE Ls Rs";
+ case 136 : return "L R C LFE";
+ case 137 : return "L R C LFE Cs";
+ case 138 : return "L R Ls Rs LFE";
+ case 139 : return "L R Ls Rs C Cs";
+ case 140 : return "L R Ls Rs C Rls Rrs";
+ case 141 : return "C L R Ls Rs Cs ";
+ case 142 : return "C L R Ls Rs Cs LFE";
+ case 143 : return "C L R Ls Rs Rls Rrs";
+ case 144 : return "C L R Ls Rs Rls Rrs Cs";
+ case 145 : return "L R C Vhc Lsd Rsd Ls Rs Vhl Vhr Lw Rw Csd Cs LFE1 LFE2";
+ case 146 : return "L R C Vhc Lsd Rsd Ls Rs Vhl Vhr Lw Rw Csd Cs LFE1 LFE2 Lc Rc HI VI Haptic";
+ case 147 : return "";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+std::string Mpeg4_chan_ChannelDescription (int32u ChannelLabels)
+{
+ std::string Text;
+ if ((ChannelLabels&0x000E)!=0x0000)
+ Text+="Front:";
+ if (ChannelLabels&0x0002)
+ Text+=" L";
+ if (ChannelLabels&0x0008)
+ Text+=" C";
+ if (ChannelLabels&0x0004)
+ Text+=" R";
+
+ if ((ChannelLabels&0x0C00)!=0x0000)
+ Text+=", Side:";
+ if (ChannelLabels&0x0400)
+ Text+=" L";
+ if (ChannelLabels&0x0800)
+ Text+=" R";
+
+ if ((ChannelLabels&0x0260)!=0x0000)
+ Text+=", Back:";
+ if (ChannelLabels&0x0020)
+ Text+=" L";
+ if (ChannelLabels&0x0200)
+ Text+=" C";
+ if (ChannelLabels&0x0040)
+ Text+=" R";
+
+ if ((ChannelLabels&0x0010)!=0x0000)
+ Text+=", LFE";
+
+ return Text;
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_chan_ChannelDescription_Layout (int32u ChannelLabel)
+{
+ switch(ChannelLabel)
+ {
+ case 1 : return "L";
+ case 2 : return "R";
+ case 3 : return "C";
+ case 4 : return "LFE";
+ case 5 : return "Ls";
+ case 6 : return "Rs";
+ case 7 : return "Lc";
+ case 8 : return "Rc";
+ case 9 : return "Cs";
+ case 10 : return "Lsd";
+ case 11 : return "Rsd";
+ case 12 : return "Tcs";
+ case 13 : return "Vhl";
+ case 14 : return "Vhc";
+ case 15 : return "Vhr";
+ case 16 : return "Trs";
+ case 17 : return "Trs";
+ case 18 : return "Trs";
+ case 33 : return "Lrs";
+ case 34 : return "Rrs";
+ case 35 : return "Lw";
+ case 36 : return "Rw";
+ case 37 : return "LFE2";
+ case 38 : return "Lt";
+ case 39 : return "Rt";
+ case 200 : return "W";
+ case 201 : return "X";
+ case 202 : return "Y";
+ case 203 : return "Z";
+ case 204 : return "M";
+ case 205 : return "S";
+ case 206 : return "X";
+ case 207 : return "Y";
+ default : return "?";
+ }
+}
+
+//---------------------------------------------------------------------------
+std::string Mpeg4_chan_ChannelBitmap (int32u ChannelBitmap)
+{
+ std::string Text;
+ if ((ChannelBitmap&0x0007)!=0x0000)
+ Text+="Front:";
+ if (ChannelBitmap&0x0001)
+ Text+=" L";
+ if (ChannelBitmap&0x0004)
+ Text+=" C";
+ if (ChannelBitmap&0x0002)
+ Text+=" R";
+
+ if ((ChannelBitmap&0x0600)!=0x0000)
+ Text+=", Side:";
+ if (ChannelBitmap&0x0200)
+ Text+=" L";
+ if (ChannelBitmap&0x0400)
+ Text+=" R";
+
+ if ((ChannelBitmap&0x0130)!=0x0000)
+ Text+=", Back:";
+ if (ChannelBitmap&0x0010)
+ Text+=" L";
+ if (ChannelBitmap&0x0100)
+ Text+=" C";
+ if (ChannelBitmap&0x0020)
+ Text+=" R";
+
+ if ((ChannelBitmap&0x0008)!=0x0000)
+ Text+=", LFE";
+
+ return Text;
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_chan_ChannelBitmap_Layout (int32u ChannelBitmap)
+{
+ switch(ChannelBitmap)
+ {
+ case 0 : return "L"; // Left
+ case 1 : return "R"; // Right
+ case 2 : return "C"; // Center
+ case 3 : return "LFE"; // LFEScreen
+ case 4 : return "Ls"; // LeftSurround / Back Left
+ case 5 : return "Rs"; // RightSurround / Back Right
+ case 6 : return "?"; // LeftCenter
+ case 7 : return "?"; // RightCenter
+ case 8 : return "Cs"; // CenterSurround / Back Center
+ case 9 : return "Lsd"; // LeftSurroundDirect / Side Left
+ case 10 : return "Rsd"; // RightSurroundDirect / Side Right
+ case 11 : return "?"; // TopCenterSurround
+ case 12 : return "?"; // VerticalHeightLeft / Top Front Left
+ case 13 : return "?"; // VerticalHeightCenter / Top Front Center
+ case 14 : return "?"; // VerticalHeightRight / Top Front Right"
+ case 15 : return "?"; // TopBackLeft
+ case 16 : return "?"; // TopBackCenter
+ case 17 : return "?"; // TopBackRight
+ default : return "?";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_jp2h_METH(int8u METH)
+{
+ switch (METH)
+ {
+ case 0x01 : return "Enumerated colourspace";
+ case 0x02 : return "Restricted ICC profile";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_jp2h_EnumCS(int32u EnumCS)
+{
+ switch (EnumCS)
+ {
+ case 0x10 : return "RGB"; //sRGB
+ case 0x11 : return "Grey";
+ case 0x12 : return "YUV"; //sYUV
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_colour_primaries(int16u colour_primaries)
+{
+ switch (colour_primaries)
+ {
+ case 1 : return "BT.709-2, SMPTE 274M, SMPTE 296M"; //white x = 0.3127 y = 0.3290 / red x=0.640 y = 0.330 / green x = 0.300 y = 0.600 / blue x = 0.150 y = 0.060
+ case 5 : return "SMPTE RP145, SMPTE 170M, SMPTE 240M, SMPTE 274M, SMPTE 293M"; //white x = 0.3127 y = 0.3290 / red x = 0.64 y = 0.33 / green x = 0.29 y = 0.60 / blue x = 0.15 y = 0.06
+ case 6 : return "BT.709-2, SMPTE 274M, SMPTE 296M"; //white x = 0.3127 y = 0.3290 / red x = 0.630 y = 0.340 / green x = 0.310 y = 0.595 / blue x = 0.155 y = 0.070 (weird... Not same as 1)
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_transfer_characteristics(int16u transfer_characteristics)
+{
+ switch (transfer_characteristics)
+ {
+ case 1 : return "BT.709-2, SMPTE 170M, SMPTE 274M, SMPTE 293M, SMPTE 296M";
+ case 7 : return "SMPTE 240M, SMPTE 274M";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_matrix_coefficients(int16u matrix_coefficients)
+{
+ switch (matrix_coefficients)
+ {
+ case 1 : return "BT.709-2, SMPTE 274M, SMPTE 296M";
+ case 6 : return "BT.470-4 System B, BT.470-4 System G, BT.601-4, SMPTE 170M, SMPTE 293M";
+ case 7 : return "SMPTE 240M, SMPTE 274M";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+// DTS
+#if defined(MEDIAINFO_DTS_YES)
+ extern const char* DTS_ChannelPositions[16];
+ extern const char* DTS_ChannelPositions2[16];
+ extern std::string DTS_HD_SpeakerActivityMask (int16u SpeakerActivityMask);
+ extern std::string DTS_HD_SpeakerActivityMask2 (int16u SpeakerActivityMask);
+#endif //defined(MEDIAINFO_DTS_YES)
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+namespace Elements
+{
+ const int64u cdat=0x63646174;
+ const int64u cdt2=0x63647432;
+ const int64u free=0x66726565;
+ const int64u ftyp=0x66747970;
+ const int64u ftyp_qt=0x71742020;
+ const int64u ftyp_isom=0x69736F6D;
+ const int64u ftyp_caqv=0x63617176;
+ const int64u idat=0x69646174;
+ const int64u idsc=0x69647363;
+ const int64u jp2c=0x6A703263;
+ const int64u jp2h=0x6A703268;
+ const int64u jp2h_ihdr=0x69686472;
+ const int64u jp2h_colr=0x636F6C72;
+ const int64u mdat=0x6D646174;
+ const int64u mfra=0x6D667261;
+ const int64u mfra_mfro=0x6D66726F;
+ const int64u mfra_tfra=0x74667261;
+ const int64u moof=0x6D6F6F66;
+ const int64u moof_mfhd=0x6D666864;
+ const int64u moof_traf=0x74726166;
+ const int64u moof_traf_sdtp=0x73647470;
+ const int64u moof_traf_tfhd=0x74666864;
+ const int64u moof_traf_trun=0x7472756E;
+ const int64u moov=0x6D6F6F76;
+ const int64u moov_cmov=0x636D6F76;
+ const int64u moov_cmov_cmvd=0x636D7664;
+ const int64u moov_cmov_dcom=0x64636F6D;
+ const int64u moov_cmov_dcom_zlib=0x7A6C6962;
+ const int64u moov_ctab=0x63746162;
+ const int64u moov_iods=0x696F6473;
+ const int64u moov_meta=0x6D657461;
+ const int64u moov_meta______=0x2D2D2D2D;
+ const int64u moov_meta___day=0xA9646179;
+ const int64u moov_meta__disk=0x6469736B;
+ const int64u moov_meta__trkn=0x74726B6E;
+ const int64u moov_meta__trng=0x74726E67;
+ const int64u moov_meta__covr=0x636F7672;
+ const int64u moov_meta__gnre=0x676E7265;
+ const int64u moov_meta_bxml=0x62786D6C;
+ const int64u moov_meta_hdlr=0x68646C72;
+ const int64u moov_meta_hdlr_mdir=0x6D646972;
+ const int64u moov_meta_hdlr_mdta=0x6D647461;
+ const int64u moov_meta_hdlr_mp7b=0x6D703762;
+ const int64u moov_meta_hdlr_mp7t=0x6D703774;
+ const int64u moov_meta_keys=0x6B657973;
+ const int64u moov_meta_keys_mdta=0x6D647461;
+ const int64u moov_meta_ilst=0x696C7374;
+ const int64u moov_meta_ilst_xxxx_data=0x64617461;
+ const int64u moov_meta_ilst_xxxx_mean=0x6D65616E;
+ const int64u moov_meta_ilst_xxxx_name=0x6E616D65;
+ const int64u moov_meta_xml=0x786D6C20;
+ const int64u moov_mvex=0x6D766578;
+ const int64u moov_mvex_mehd=0x6D656864;
+ const int64u moov_mvex_trex=0x74726578;
+ const int64u moov_mvhd=0x6D766864;
+ const int64u moov_trak=0x7472616B;
+ const int64u moov_trak_edts=0x65647473;
+ const int64u moov_trak_edts_elst=0x656C7374;
+ const int64u moov_trak_load=0x6C6F6164;
+ const int64u moov_trak_mdia=0x6D646961;
+ const int64u moov_trak_mdia_hdlr=0x68646C72;
+ const int64u moov_trak_mdia_hdlr_clcp=0x636C6370;
+ const int64u moov_trak_mdia_hdlr_MPEG=0x4D504547;
+ const int64u moov_trak_mdia_hdlr_sbtl=0x7362746C;
+ const int64u moov_trak_mdia_hdlr_soun=0x736F756E;
+ const int64u moov_trak_mdia_hdlr_subp=0x73756270;
+ const int64u moov_trak_mdia_hdlr_text=0x74657874;
+ const int64u moov_trak_mdia_hdlr_vide=0x76696465;
+ const int64u moov_trak_mdia_imap=0x696D6170;
+ const int64u moov_trak_mdia_imap_sean=0x7365616E;
+ const int64u moov_trak_mdia_imap_sean___in=0x0000696E;
+ const int64u moov_trak_mdia_imap_sean___in___ty=0x00007479;
+ const int64u moov_trak_mdia_imap_sean___in_dtst=0x64747374;
+ const int64u moov_trak_mdia_imap_sean___in_obid=0x6F626964;
+ const int64u moov_trak_mdia_mdhd=0x6D646864;
+ const int64u moov_trak_mdia_minf=0x6D696E66;
+ const int64u moov_trak_mdia_minf_code=0x636F6465;
+ const int64u moov_trak_mdia_minf_code_sean=0x7365616E;
+ const int64u moov_trak_mdia_minf_code_sean_RU_A=0x52552A41;
+ const int64u moov_trak_mdia_minf_dinf=0x64696E66;
+ const int64u moov_trak_mdia_minf_dinf_url_=0x75726C20;
+ const int64u moov_trak_mdia_minf_dinf_urn_=0x75726E20;
+ const int64u moov_trak_mdia_minf_dinf_dref=0x64726566;
+ const int64u moov_trak_mdia_minf_dinf_dref_alis=0x616C6973;
+ const int64u moov_trak_mdia_minf_dinf_dref_rsrc=0x72737263;
+ const int64u moov_trak_mdia_minf_dinf_dref_url_=0x75726C20;
+ const int64u moov_trak_mdia_minf_dinf_derf_urn_=0x75726E20;
+ const int64u moov_trak_mdia_minf_gmhd=0x676D6864;
+ const int64u moov_trak_mdia_minf_gmhd_gmin=0x676D696E;
+ const int64u moov_trak_mdia_minf_gmhd_tmcd=0x746D6364;
+ const int64u moov_trak_mdia_minf_gmhd_tmcd_tcmi=0x74636D69;
+ const int64u moov_trak_mdia_minf_hint=0x68696E74;
+ const int64u moov_trak_mdia_minf_hdlr=0x68646C72;
+ const int64u moov_trak_mdia_minf_hmhd=0x686D6864;
+ const int64u moov_trak_mdia_minf_nmhd=0x6E6D6864;
+ const int64u moov_trak_mdia_minf_smhd=0x736D6864;
+ const int64u moov_trak_mdia_minf_stbl=0x7374626C;
+ const int64u moov_trak_mdia_minf_stbl_co64=0x636F3634;
+ const int64u moov_trak_mdia_minf_stbl_cslg=0x63736C67;
+ const int64u moov_trak_mdia_minf_stbl_ctts=0x63747473;
+ const int64u moov_trak_mdia_minf_stbl_sdtp=0x73647470;
+ const int64u moov_trak_mdia_minf_stbl_stco=0x7374636F;
+ const int64u moov_trak_mdia_minf_stbl_stdp=0x73746470;
+ const int64u moov_trak_mdia_minf_stbl_stps=0x73747073;
+ const int64u moov_trak_mdia_minf_stbl_stsc=0x73747363;
+ const int64u moov_trak_mdia_minf_stbl_stsd=0x73747364;
+ const int64u moov_trak_mdia_minf_stbl_stsd_alac=0x616C6163;
+ const int64u moov_trak_mdia_minf_stbl_stsd_mp4a=0x6D703461;
+ const int64u moov_trak_mdia_minf_stbl_stsd_mp4s=0x6D703473;
+ const int64u moov_trak_mdia_minf_stbl_stsd_mp4v=0x6D703476;
+ const int64u moov_trak_mdia_minf_stbl_stsd_text=0x74657874;
+ const int64u moov_trak_mdia_minf_stbl_stsd_tmcd=0x746D6364;
+ const int64u moov_trak_mdia_minf_stbl_stsd_tmcd_name=0x6E616D65;
+ const int64u moov_trak_mdia_minf_stbl_stsd_tx3g=0x74783367;
+ const int64u moov_trak_mdia_minf_stbl_stsd_tx3g_ftab=0x66746162;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_alac=0x616C6163;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_avcC=0x61766343;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_bitr=0x62697472;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_btrt=0x62747274;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_clap=0x636C6170;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_chan=0x6368616E;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_colr=0x636F6C72;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_d263=0x64323633;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_dac3=0x64616333;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_dec3=0x64656333;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_ddts=0x64647473;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_damr=0x64616D72;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_esds=0x65736473;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_fiel=0x6669656C;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_glbl=0x676C626C;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_idfm=0x6964666D;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_atom=0x61746F6D;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_qtat=0x71746174;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_fxat=0x66786174;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_priv=0x70726976;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_subs=0x73756273;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_cspc=0x63737063;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_jp2h=0x6A703268;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_jp2h_colr=0x636F6C72;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_jp2h_ihdr=0x69686472;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_pasp=0x70617370;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_sinf=0x73696E66;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_frma=0x66726D61;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_imif=0x696D6966;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_schi=0x73636869;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_schm=0x7363686D;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_wave=0x77617665;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_wave_acbf=0x61636266;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_wave_enda=0x656E6461;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_wave_frma=0x66726D61;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_wave_samr=0x73616D72;
+ const int64u moov_trak_mdia_minf_stbl_stsd_xxxx_wave_srcq=0x73726371;
+ const int64u moov_trak_mdia_minf_stbl_stsh=0x73747368;
+ const int64u moov_trak_mdia_minf_stbl_stss=0x73747373;
+ const int64u moov_trak_mdia_minf_stbl_stsz=0x7374737A;
+ const int64u moov_trak_mdia_minf_stbl_stts=0x73747473;
+ const int64u moov_trak_mdia_minf_stbl_stz2=0x73747A32;
+ const int64u moov_trak_mdia_minf_vmhd=0x766D6864;
+ const int64u moov_trak_meta=0x6D657461;
+ const int64u moov_trak_meta______=0x2D2D2D2D;
+ const int64u moov_trak_meta___day=0xA9646179;
+ const int64u moov_trak_meta__disk=0x6469736B;
+ const int64u moov_trak_meta__trkn=0x74726B6E;
+ const int64u moov_trak_meta__trng=0x74726E67;
+ const int64u moov_trak_meta__covr=0x636F7672;
+ const int64u moov_trak_meta__gnre=0x676E7265;
+ const int64u moov_trak_meta_bxml=0x62786D6C;
+ const int64u moov_trak_meta_hdlr=0x68646C72;
+ const int64u moov_trak_meta_hdlr_mdir=0x6D646972;
+ const int64u moov_trak_meta_hdlr_mdta=0x6D647461;
+ const int64u moov_trak_meta_hdlr_mp7b=0x6D703762;
+ const int64u moov_trak_meta_hdlr_mp7t=0x6D703774;
+ const int64u moov_trak_meta_keys=0x6B657973;
+ const int64u moov_trak_meta_keys_mdta=0x6D647461;
+ const int64u moov_trak_meta_ilst=0x696C7374;
+ const int64u moov_trak_meta_ilst_xxxx_data=0x64617461;
+ const int64u moov_trak_meta_ilst_xxxx_mean=0x6D65616E;
+ const int64u moov_trak_meta_ilst_xxxx_name=0x6E616D65;
+ const int64u moov_trak_meta_xml=0x786D6C20;
+ const int64u moov_trak_tapt=0x74617074;
+ const int64u moov_trak_tapt_clef=0x636C6566;
+ const int64u moov_trak_tapt_enof=0x656E6F66;
+ const int64u moov_trak_tapt_prof=0x70726F66;
+ const int64u moov_trak_tkhd=0x746B6864;
+ const int64u moov_trak_tref=0x74726566;
+ const int64u moov_trak_tref_dpnd=0x64706E64;
+ const int64u moov_trak_tref_ipir=0x69706972;
+ const int64u moov_trak_tref_hint=0x68696E74;
+ const int64u moov_trak_tref_mpod=0x6D706F64;
+ const int64u moov_trak_tref_ssrc=0x73737263;
+ const int64u moov_trak_tref_sync=0x73796E63;
+ const int64u moov_trak_tref_tmcd=0x746D6364;
+ const int64u moov_udta=0x75647461;
+ const int64u moov_udta_AllF=0x416C6C46;
+ const int64u moov_udta_chpl=0x6368706C;
+ const int64u moov_udta_clsf=0x636C7366;
+ const int64u moov_udta_DcMD=0x44634D44;
+ const int64u moov_udta_DcMD_Cmbo=0x436D626F;
+ const int64u moov_udta_DcMD_DcME=0x44634D45;
+ const int64u moov_udta_DcMD_DcME_Keyw=0x4B657977;
+ const int64u moov_udta_DcMD_DcME_Mtmd=0x4D746D64;
+ const int64u moov_udta_DcMD_DcME_Rate=0x52617465;
+ const int64u moov_udta_FIEL=0x4649454C;
+ const int64u moov_udta_FXTC=0x46585443;
+ const int64u moov_udta_hinf=0x68696E66;
+ const int64u moov_udta_hinv=0x68696E76;
+ const int64u moov_udta_hnti=0x686E7469;
+ const int64u moov_udta_hnti_rtp=0x72747020;
+ const int64u moov_udta_ID32=0x49443332;
+ const int64u moov_udta_kywd=0x6B797764;
+ const int64u moov_udta_loci=0x6C6F6369;
+ const int64u moov_udta_LOOP=0x4C4F4F50;
+ const int64u moov_udta_MCPS=0x4D435053;
+ const int64u moov_udta_meta=0x6D657461;
+ const int64u moov_udta_meta_hdlr=0x68646C72;
+ const int64u moov_udta_meta_ilst=0x696C7374;
+ const int64u moov_udta_meta_ilst_xxxx_data=0x64617461;
+ const int64u moov_udta_meta_ilst_xxxx_mean=0x6D65616E;
+ const int64u moov_udta_meta_ilst_xxxx_name=0x6E616D65;
+ const int64u moov_udta_ndrm=0x6E64726D;
+ const int64u moov_udta_nsav=0x6E736176;
+ const int64u moov_udta_ptv =0x70747620;
+ const int64u moov_udta_rtng=0x72746E67;
+ const int64u moov_udta_Sel0=0x53656C30;
+ const int64u moov_udta_tags=0x74616773;
+ const int64u moov_udta_tags_meta=0x6D657461;
+ const int64u moov_udta_tags_tseg=0x74736567;
+ const int64u moov_udta_tags_tseg_tshd=0x74736864;
+ const int64u moov_udta_WLOC=0x574C4F43;
+ const int64u moov_udta_XMP_=0x584D505F;
+ const int64u moov_udta_yrrc=0x79727263;
+ const int64u PICT=0x50494354;
+ const int64u pckg=0x70636B67;
+ const int64u pnot=0x706E6F74;
+ const int64u RDAO=0x5244414F;
+ const int64u RDAS=0x52444153;
+ const int64u RDVO=0x5244564F;
+ const int64u RDVS=0x52445653;
+ const int64u RED1=0x52454431;
+ const int64u REDA=0x52454441;
+ const int64u REDV=0x52454456;
+ const int64u REOB=0x52454F42;
+ const int64u skip=0x736B6970;
+ const int64u wide=0x77696465;
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg4_Description(int32u Description)
+{
+ switch (Description)
+ {
+ case Elements::moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_atom : return "Classic atom structure";
+ case Elements::moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_qtat : return "QT atom structure";
+ case Elements::moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_fxat : return "Effect";
+ case Elements::moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_priv : return "Private";
+ case Elements::moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_subs : return "Substitute if main codec not available";
+ case Elements::moov_trak_mdia_minf_stbl_stsd_xxxx_idfm_cspc : return "Native pixel format";
+ default : return "Unknown";
+ }
+}
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::Data_Parse()
+{
+ //mdat
+ if (IsParsing_mdat)
+ {
+ mdat_xxxx();
+ return;
+ }
+
+ //Parsing
+ DATA_BEGIN
+ ATOM(cdat)
+ ATOM(cdt2)
+ LIST_SKIP(free)
+ ATOM(ftyp)
+ ATOM(idat)
+ ATOM(idsc)
+ ATOM(jp2c)
+ LIST(jp2h)
+ ATOM_BEGIN
+ ATOM(jp2h_colr)
+ ATOM(jp2h_ihdr)
+ ATOM_END
+ LIST(mdat)
+ ATOM_DEFAULT_ALONE(mdat_xxxx)
+ LIST(mfra)
+ ATOM_BEGIN
+ ATOM(mfra_mfro)
+ ATOM(mfra_tfra)
+ ATOM_END
+ LIST(moof)
+ ATOM_BEGIN
+ ATOM(moof_mfhd)
+ LIST(moof_traf)
+ ATOM_BEGIN
+ ATOM(moof_traf_sdtp)
+ ATOM(moof_traf_tfhd)
+ ATOM(moof_traf_trun)
+ ATOM_END
+ ATOM_END
+ LIST(moov)
+ ATOM_BEGIN
+ LIST(moov_cmov)
+ ATOM_BEGIN
+ ATOM(moov_cmov_dcom)
+ ATOM(moov_cmov_cmvd)
+ ATOM_END
+ ATOM(moov_ctab)
+ ATOM(moov_iods)
+ LIST(moov_meta)
+ ATOM_BEGIN
+ ATOM(moov_meta_bxml)
+ LIST(moov_meta_keys)
+ ATOM_BEGIN
+ ATOM(moov_meta_keys_mdta)
+ ATOM_END
+ ATOM(moov_meta_hdlr)
+ LIST(moov_meta_ilst)
+ LIST_DEFAULT_ALONE_BEGIN (moov_meta_ilst_xxxx)
+ ATOM_BEGIN
+ ATOM (moov_meta_ilst_xxxx_data)
+ ATOM (moov_meta_ilst_xxxx_mean)
+ ATOM (moov_meta_ilst_xxxx_name)
+ ATOM_END
+ LIST_DEFAULT_ALONE_END
+ ATOM(moov_meta_xml)
+ ATOM_END
+ LIST(moov_mvex)
+ ATOM_BEGIN
+ ATOM(moov_mvex_mehd)
+ ATOM(moov_mvex_trex)
+ ATOM_END
+ ATOM(moov_mvhd)
+ LIST(moov_trak)
+ ATOM_BEGIN
+ LIST(moov_trak_edts)
+ ATOM_BEGIN
+ ATOM(moov_trak_edts_elst)
+ ATOM_END
+ ATOM(moov_trak_load)
+ LIST(moov_trak_mdia)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_hdlr)
+ LIST(moov_trak_mdia_imap)
+ ATOM_BEGIN
+ LIST(moov_trak_mdia_imap_sean)
+ ATOM_BEGIN
+ LIST(moov_trak_mdia_imap_sean___in)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_imap_sean___in___ty)
+ ATOM(moov_trak_mdia_imap_sean___in_dtst)
+ ATOM(moov_trak_mdia_imap_sean___in_obid)
+ ATOM_END
+ ATOM_END
+ ATOM_END
+ ATOM(moov_trak_mdia_mdhd)
+ LIST(moov_trak_mdia_minf)
+ ATOM_BEGIN
+ LIST(moov_trak_mdia_minf_code)
+ ATOM_BEGIN
+ LIST(moov_trak_mdia_minf_code_sean)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_code_sean_RU_A)
+ ATOM_END
+ ATOM_END
+ LIST(moov_trak_mdia_minf_dinf)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_dinf_url_)
+ ATOM(moov_trak_mdia_minf_dinf_urn_)
+ LIST(moov_trak_mdia_minf_dinf_dref)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_dinf_dref_alis)
+ ATOM(moov_trak_mdia_minf_dinf_dref_rsrc)
+ ATOM(moov_trak_mdia_minf_dinf_url_)
+ ATOM(moov_trak_mdia_minf_dinf_urn_)
+ ATOM_END
+ ATOM_END
+ ATOM(moov_trak_mdia_minf_hdlr)
+ LIST(moov_trak_mdia_minf_gmhd)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_gmhd_gmin)
+ LIST(moov_trak_mdia_minf_gmhd_tmcd)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_gmhd_tmcd_tcmi)
+ ATOM_END
+ ATOM_END
+ ATOM(moov_trak_mdia_minf_hint)
+ ATOM(moov_trak_mdia_minf_hmhd)
+ ATOM(moov_trak_mdia_minf_nmhd)
+ ATOM(moov_trak_mdia_minf_smhd)
+ LIST(moov_trak_mdia_minf_stbl)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_stbl_co64)
+ ATOM(moov_trak_mdia_minf_stbl_cslg)
+ ATOM(moov_trak_mdia_minf_stbl_ctts)
+ ATOM(moov_trak_mdia_minf_stbl_sdtp)
+ ATOM(moov_trak_mdia_minf_stbl_stco)
+ ATOM(moov_trak_mdia_minf_stbl_stdp)
+ ATOM(moov_trak_mdia_minf_stbl_stps)
+ ATOM(moov_trak_mdia_minf_stbl_stsc)
+ LIST(moov_trak_mdia_minf_stbl_stsd)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_stbl_stsd_text)
+ LIST(moov_trak_mdia_minf_stbl_stsd_tmcd)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_stbl_stsd_tmcd_name)
+ ATOM_END
+ LIST(moov_trak_mdia_minf_stbl_stsd_tx3g)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_stbl_stsd_tx3g_ftab)
+ ATOM_END
+ LIST_DEFAULT(moov_trak_mdia_minf_stbl_stsd_xxxx)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_alac)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_avcC)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_bitr)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_btrt)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_chan)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_clap)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_colr)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_d263)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_dac3)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_dec3)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_ddts)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_damr)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_esds)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_fiel)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_glbl)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_idfm)
+ LIST(moov_trak_mdia_minf_stbl_stsd_xxxx_jp2h)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_jp2h_colr)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_jp2h_ihdr)
+ ATOM_END
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_pasp)
+ LIST(moov_trak_mdia_minf_stbl_stsd_xxxx_sinf)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_frma)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_imif)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_schi)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_schm)
+ ATOM_END
+ LIST(moov_trak_mdia_minf_stbl_stsd_xxxx_wave)
+ ATOM_BEGIN
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_esds)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_wave_acbf)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_wave_enda)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_wave_frma)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_wave_samr)
+ ATOM(moov_trak_mdia_minf_stbl_stsd_xxxx_wave_srcq)
+ ATOM_DEFAULT(moov_trak_mdia_minf_stbl_stsd_xxxx_wave_xxxx)
+ ATOM_END_DEFAULT
+ ATOM_END
+ ATOM_END_DEFAULT
+ ATOM(moov_trak_mdia_minf_stbl_stsh)
+ ATOM(moov_trak_mdia_minf_stbl_stss)
+ ATOM(moov_trak_mdia_minf_stbl_stsz)
+ ATOM(moov_trak_mdia_minf_stbl_stts)
+ ATOM(moov_trak_mdia_minf_stbl_stz2)
+ ATOM_END
+ ATOM(moov_trak_mdia_minf_vmhd)
+ ATOM_END
+ ATOM_END
+ /* Need additional tests
+ LIST(moov_trak_meta)
+ ATOM_BEGIN
+ ATOM(moov_trak_meta_bxml)
+ LIST(moov_trak_meta_keys)
+ ATOM_BEGIN
+ ATOM(moov_trak_meta_keys_mdta)
+ ATOM_END
+ ATOM(moov_trak_meta_hdlr)
+ LIST(moov_trak_meta_ilst)
+ ATOM_BEGIN
+ LIST_DEFAULT (moov_trak_meta_ilst_xxxx)
+ ATOM_BEGIN
+ ATOM (moov_trak_meta_ilst_xxxx_data)
+ ATOM (moov_trak_meta_ilst_xxxx_mean)
+ ATOM (moov_trak_meta_ilst_xxxx_name)
+ ATOM_END
+ ATOM_END_DEFAULT
+ ATOM(moov_trak_meta_xml)
+ ATOM_END
+ */
+ LIST(moov_trak_tapt)
+ ATOM_BEGIN
+ ATOM(moov_trak_tapt_clef)
+ ATOM(moov_trak_tapt_prof)
+ ATOM(moov_trak_tapt_enof)
+ ATOM_END
+ ATOM(moov_trak_tkhd)
+ LIST(moov_trak_tref)
+ ATOM_BEGIN
+ ATOM(moov_trak_tref_dpnd)
+ ATOM(moov_trak_tref_ipir)
+ ATOM(moov_trak_tref_hint)
+ ATOM(moov_trak_tref_mpod)
+ ATOM(moov_trak_tref_ssrc)
+ ATOM(moov_trak_tref_sync)
+ ATOM(moov_trak_tref_tmcd)
+ ATOM_END
+ ATOM_END
+ LIST(moov_udta)
+ ATOM_BEGIN
+ ATOM(moov_udta_AllF)
+ ATOM(moov_udta_chpl)
+ ATOM(moov_udta_clsf)
+ LIST(moov_udta_DcMD)
+ ATOM_BEGIN
+ ATOM(moov_udta_DcMD_Cmbo)
+ LIST(moov_udta_DcMD_DcME)
+ ATOM_BEGIN
+ ATOM(moov_udta_DcMD_DcME_Keyw)
+ ATOM(moov_udta_DcMD_DcME_Mtmd)
+ ATOM(moov_udta_DcMD_DcME_Rate)
+ ATOM_END
+ ATOM_END
+ ATOM(moov_udta_FIEL)
+ ATOM(moov_udta_FXTC)
+ ATOM(moov_udta_hinf)
+ ATOM(moov_udta_hinv)
+ LIST(moov_udta_hnti)
+ ATOM_BEGIN
+ ATOM(moov_udta_hnti_rtp)
+ ATOM_END
+ ATOM(moov_udta_ID32)
+ ATOM(moov_udta_kywd)
+ ATOM(moov_udta_loci)
+ ATOM(moov_udta_LOOP)
+ ATOM(moov_udta_MCPS)
+ LIST(moov_udta_meta)
+ ATOM_BEGIN
+ ATOM(moov_udta_meta_hdlr)
+ LIST(moov_udta_meta_ilst)
+ LIST_DEFAULT_ALONE_BEGIN (moov_udta_meta_ilst_xxxx)
+ ATOM_BEGIN
+ ATOM (moov_udta_meta_ilst_xxxx_data);
+ ATOM (moov_udta_meta_ilst_xxxx_mean);
+ ATOM (moov_udta_meta_ilst_xxxx_name);
+ ATOM_END
+ LIST_DEFAULT_ALONE_END
+ ATOM_END
+ ATOM(moov_udta_ndrm)
+ ATOM(moov_udta_nsav)
+ ATOM(moov_udta_ptv )
+ ATOM(moov_udta_rtng)
+ ATOM(moov_udta_Sel0)
+ LIST(moov_udta_tags)
+ ATOM_BEGIN
+ ATOM(moov_udta_tags_meta)
+ LIST(moov_udta_tags_tseg)
+ ATOM_BEGIN
+ ATOM(moov_udta_tags_tseg_tshd);
+ ATOM_END
+ ATOM_END
+ ATOM(moov_udta_WLOC)
+ ATOM(moov_udta_XMP_)
+ ATOM(moov_udta_yrrc)
+ ATOM_DEFAULT (moov_udta_xxxx); //User data
+ ATOM_END_DEFAULT
+ ATOM_END
+ ATOM(PICT)
+ ATOM(RDAO)
+ ATOM(RDAS)
+ ATOM(RDVO)
+ ATOM(RDVS)
+ ATOM(RED1)
+ ATOM(REDA)
+ ATOM(REDV)
+ ATOM(REOB)
+ ATOM(pckg)
+ ATOM(pnot)
+ LIST_SKIP(skip)
+ LIST_SKIP(wide)
+ DATA_END
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+#define NAME_VERSION_FLAG(ELEMENT_NAME) \
+ Element_Name(ELEMENT_NAME); \
+ int32u Flags; \
+ int8u Version; \
+ { \
+ Get_B1(Version, "Version"); \
+ Get_B3(Flags, "Flags"); \
+ } \
+
+#define INTEGRITY_VERSION(_VERSION) \
+ if (Version>_VERSION) \
+ { \
+ Skip_XX(Element_Size-Element_Offset, "Unknown data"); \
+ return; \
+ } \
+
+#define INTEGRITY(TOVALIDATE, ERRORTEXT) \
+ if (!(TOVALIDATE)) \
+ { \
+ Trusted_IsNot(ERRORTEXT); \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE1(ELEMENT_SIZE0) \
+ INTEGRITY_VERSION(0); \
+ if (Element_Size!=ELEMENT_SIZE0+4) \
+ { \
+ Trusted_IsNot("Size is wrong"); \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE2(ELEMENT_SIZE0, ELEMENT_SIZE1) \
+ INTEGRITY_VERSION(1); \
+ if (Version==0 && Element_Size!=ELEMENT_SIZE0 \
+ || Version==1 && Element_Size!=ELEMENT_SIZE1) \
+ { \
+ Trusted_IsNot("Size is wrong"); \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE_ATLEAST1(ELEMENT_SIZE0) \
+ INTEGRITY_VERSION(0); \
+ if (Version==0 && Element_Size<ELEMENT_SIZE0) \
+ { \
+ Trusted_IsNot("Size is wrong"); \
+ return; \
+ } \
+
+#define INTEGRITY_SIZE_ATLEAST2(ELEMENT_SIZE0, ELEMENT_SIZE1) \
+ INTEGRITY_VERSION(1); \
+ if (Version==0 && Element_Size<ELEMENT_SIZE0 \
+ || Version==1 && Element_Size<ELEMENT_SIZE1) \
+ { \
+ Trusted_IsNot("Size is wrong"); \
+ return; \
+ } \
+
+#define Get_B_DEPENDOFVERSION(_INFO, _NAME) \
+ { \
+ if (Version==0) \
+ { \
+ int32u Info; \
+ Get_B4(Info, _NAME); \
+ _INFO=Info; \
+ } \
+ else \
+ Get_B8(_INFO, _NAME); \
+ } \
+
+#define Get_DATE1904_DEPENDOFVERSION(_INFO, _NAME) \
+ { \
+ if (Version==0) \
+ { \
+ int32u Temp; \
+ Get_B4(Temp, _NAME); \
+ _INFO.Date_From_Seconds_1904(Temp); \
+ } \
+ else \
+ { \
+ int64u Temp; \
+ Get_B8(Temp, _NAME); \
+ _INFO.Date_From_Seconds_1904(Temp); \
+ } \
+ Param_Info1(_INFO); \
+ } \
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::cdat()
+{
+ Element_Code=Element_Code==Elements::cdat?1:2;
+
+ if (!Status[IsAccepted])
+ {
+ Accept("EIA-608");
+ Fill(Stream_General, 0, General_Format, "Final Cut EIA-608", Unlimited, true, true);
+ }
+ #ifdef MEDIAINFO_EIA608_YES
+ if (Streams[(int32u)Element_Code].Parser==NULL)
+ {
+ Streams[(int32u)Element_Code].Parser=new File_Eia608();
+ Open_Buffer_Init(Streams[(int32u)Element_Code].Parser);
+ }
+ #endif //MEDIAINFO_EIA608_YES
+
+ Element_Name(Element_Code==1?"EIA-608-1":"EIA-608-2");
+
+ #if MEDIAINFO_DEMUX
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ Streams[(int32u)Element_Code].Parser->FrameInfo=FrameInfo;
+ #endif //MEDIAINFO_DEMUX
+ Open_Buffer_Continue(Streams[(int32u)Element_Code].Parser);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::free()
+{
+ Element_Name("Free space");
+
+ //Parsing
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ Param("Data", Ztring("(")+Ztring::ToZtring(Element_TotalSize_Get())+Ztring(" bytes)"));
+ #endif //MEDIAINFO_TRACE
+ Element_Offset=Element_TotalSize_Get(); //Not using Skip_XX() because we want to skip data we don't have, and Skip_XX() does a test on size of buffer
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::ftyp()
+{
+ Element_Name("File Type");
+
+ if (Count_Get(Stream_General))
+ {
+ Skip_XX(Element_Size, "Duplicate ftyp");
+ return;
+ }
+
+ //Parsing
+ std::vector<int32u> ftyps;
+ Get_C4 (MajorBrand, "MajorBrand");
+ ftyps.push_back(MajorBrand);
+ Skip_B4( "MajorBrandVersion");
+ while (Element_Offset<Element_Size)
+ {
+ int32u CompatibleBrand;
+ Get_C4 (CompatibleBrand, "CompatibleBrand");
+ ftyps.push_back(CompatibleBrand);
+ }
+
+ FILLING_BEGIN();
+ Accept("MPEG-4");
+
+ Fill(Stream_General, 0, General_Format, "MPEG-4");
+ for (size_t Pos=0; Pos<ftyps.size(); Pos++)
+ switch (ftyps[Pos])
+ {
+ case Elements::ftyp_caqv : Fill(StreamKind_Last, StreamPos_Last, "Encoded_Application", "Casio Digital Camera"); break;
+ default : ;
+ }
+ CodecID_Fill(Ztring().From_CC4(MajorBrand), Stream_General, 0, InfoCodecID_Format_Mpeg4);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::idat()
+{
+ Element_Name("QTI");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+
+ FILLING_BEGIN();
+ Accept("QTI");
+
+ Fill(Stream_General, 0, General_Format, "MPEG-4");
+ CodecID_Fill(_T("QTI"), Stream_General, 0, InfoCodecID_Format_Mpeg4);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::idsc()
+{
+ Element_Name("QTI");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+
+ FILLING_BEGIN();
+ Accept("QTI");
+
+ Fill(Stream_General, 0, General_Format, "MPEG-4");
+ CodecID_Fill(_T("QTI"), Stream_General, 0, InfoCodecID_Format_Mpeg4);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::jp2c()
+{
+ Element_Name("JPEG 2000 content");
+
+ #if defined(MEDIAINFO_JPEG_YES)
+ //Creating the parser
+ File_Jpeg MI;
+ if (IsSub || Config->File_Names.size()>1) //If contained in another container or several files, this is a video stream
+ MI.StreamKind=Stream_Video;
+ Open_Buffer_Init(&MI);
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ #if MEDIAINFO_EVENTS
+ StreamIDs_Width[0]=0;
+ #endif //MEDIAINFO_EVENTS
+ if (Frame_Count_NotParsedIncluded==(int64u)-1)
+ Frame_Count_NotParsedIncluded=0;
+ if (Config->Demux_Rate_Get())
+ {
+ FrameInfo.DTS=float64_int64s(Frame_Count_NotParsedIncluded*1000000000/Config->Demux_Rate_Get());
+ FrameInfo.PTS=FrameInfo.DTS;
+ FrameInfo.DUR=float64_int64s(1000000000/Config->Demux_Rate_Get());
+ }
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ //Parsing
+ Open_Buffer_Continue(&MI);
+
+ //Filling
+ if (Frame_Count==0)
+ {
+ Accept("MPEG-4");
+
+ Fill(Stream_General, 0, General_Format, "JPEG 2000", Unlimited, true, true);
+ Fill(Stream_General, 0, General_Format_Profile, "MPEG-4");
+
+ Finish(&MI);
+ Merge(MI, MI.StreamKind, 0, 0);
+
+ Fill("MPEG-4");
+ if (Config->File_Names.size()>1)
+ {
+ int64u OverHead=Config->File_Sizes[0]-Element_Size;
+ Fill(Stream_Video, 0, Video_StreamSize, File_Size-Config->File_Names.size()*OverHead, 10, true);
+ }
+ if (Config_ParseSpeed<1.0)
+ Finish("MPEG-4");
+ }
+ Frame_Count++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ #endif
+
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::jp2h()
+{
+ Element_Name("JPEG-2000 header");
+
+ FILLING_BEGIN();
+ Buffer_MaximumSize=16*1024*1024; //If we are here, this is really a MPEG-4 file with JPEG-2000 image, and some atoms are very bigs...
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::jp2h_colr()
+{
+ Element_Name("Color");
+
+ //Parsing
+ int8u METH;
+ Get_B1 (METH, "METH - Specification method"); Param_Info1(Mpeg4_jp2h_METH(METH));
+ Skip_B1( "PREC - Precedence");
+ Skip_B1( "APPROX - Colourspace approximation");
+ switch (METH)
+ {
+ case 0x01 : {
+ int32u EnumCS;
+ Get_B4 (EnumCS, "EnumCS - Enumerated colourspace"); Param_Info1(Mpeg4_jp2h_EnumCS(EnumCS));
+ Fill(StreamKind_Last, 0, "ColorSpace", Mpeg4_jp2h_EnumCS(EnumCS));
+ }
+ break;
+ case 0x02 : Skip_XX(Element_Size-Element_Offset, "PROFILE");
+ break;
+ default : Skip_XX(Element_Size-Element_Offset, "Unknown");
+ return;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::jp2h_ihdr()
+{
+ Element_Name("Header");
+
+ //Parsing
+ Skip_B4( "Height");
+ Skip_B4( "Width");
+ Skip_B2( "NC - Number of components");
+ BS_Begin();
+ Skip_SB( "BPC - Bits per component (Sign)");
+ Skip_S1(7, "BPC - Bits per component (Value)");
+ BS_End();
+ Skip_B1( "C - Compression type");
+ Skip_B1( "UnkC - Colourspace Unknown");
+ Skip_B1( "IPR - Intellectual Property");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::mdat()
+{
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(8); //Streams
+ #endif //MEDIAINFO_TRACE
+ #if MEDIAINFO_DEMUX
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ Config->Demux_EventWasSent=true;
+ #endif //MEDIAINFO_DEMUX
+
+ if (!Status[IsAccepted])
+ {
+ Data_Accept("MPEG-4");
+
+ Fill(Stream_General, 0, General_Format, "QuickTime");
+ }
+ Element_Name("Data");
+
+ //Sizes
+ if (Retrieve(Stream_General, 0, General_HeaderSize).empty())
+ {
+ Fill(Stream_General, 0, General_HeaderSize, File_Offset+Buffer_Offset-Header_Size);
+ Fill(Stream_General, 0, General_DataSize, Element_TotalSize_Get()+Header_Size);
+ if (File_Size!=(int64u)-1 && File_Offset+Buffer_Offset+Element_TotalSize_Get()<=File_Size)
+ Fill(Stream_General, 0, General_FooterSize, File_Size-(File_Offset+Buffer_Offset+Element_TotalSize_Get()));
+ Fill(Stream_General, 0, General_IsStreamable, FirstMoovPos==(int64u)-1?"No":"Yes");
+ }
+
+ //Trace
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(0); //Container1
+ #endif //MEDIAINFO_TRACE
+
+ if (IsSecondPass && !mdat_Pos.empty() && mdat_Pos.begin()->first<File_Offset+Buffer_Offset+Element_TotalSize_Get())
+ {
+ //Next piece of data
+ IsParsing_mdat=true;
+ mdat_StreamJump();
+
+ return; //Only if have something in this mdat
+ }
+
+ //In case of mdat is before moov
+ if (FirstMdatPos==(int64u)-1)
+ {
+ Buffer_Offset-=(size_t)Header_Size;
+ Element_Level--;
+ BookMark_Set(); //Remembering this place, for stream parsing in phase 2
+ Element_Level++;
+ Buffer_Offset+=(size_t)Header_Size;
+
+ FirstMdatPos=File_Offset+Buffer_Offset-Header_Size;
+ }
+ if (File_Offset+Buffer_Offset>LastMdatPos)
+ LastMdatPos=File_Offset+Buffer_Offset+Element_TotalSize_Get();
+
+ //Parsing
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ Param("Data", Ztring("(")+Ztring::ToZtring(Element_TotalSize_Get())+Ztring(" bytes)"));
+ #endif //MEDIAINFO_TRACE
+ Element_Offset=Element_TotalSize_Get(); //Not using Skip_XX() because we want to skip data we don't have, and Skip_XX() does a test on size of buffer
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::mdat_xxxx()
+{
+ if (!Element_IsComplete_Get())
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ std::map<int32u, stream>::iterator Stream=Streams.find((int32u)Element_Code);
+ if (Stream==Streams.end())
+ return;
+ #if MEDIAINFO_DEMUX
+ if (Streams[(int32u)Element_Code].StreamKind!=Stream_Menu && Streams[(int32u)Element_Code].StreamKind!=Stream_Max)
+ {
+ //DTS
+ Frame_Count_NotParsedIncluded=Stream->second.stts_FramePos;
+ if (Stream->second.stts_Durations_Pos<Stream->second.stts_Durations.size())
+ {
+ stream::stts_durations::iterator stts_Duration=Stream->second.stts_Durations.begin()+Stream->second.stts_Durations_Pos;
+ FrameInfo.DTS=TimeCode_DtsOffset+(stts_Duration->DTS_Begin+(((int64u)stts_Duration->SampleDuration)*(Frame_Count_NotParsedIncluded-stts_Duration->Pos_Begin)))*1000000000/Stream->second.mdhd_TimeScale;
+ FrameInfo.DUR=((int64u)stts_Duration->SampleDuration)*1000000000/Stream->second.mdhd_TimeScale;
+ Streams[(int32u)Element_Code].stts_FramePos++;
+ if (Stream->second.stts_FramePos>=stts_Duration->Pos_End)
+ Stream->second.stts_Durations_Pos++;
+ if (!Stream->second.stss.empty())
+ {
+ Demux_random_access=false;
+ for (size_t Pos=0; Pos<Stream->second.stss.size(); Pos++)
+ if (Stream->second.stss[Pos]==Frame_Count_NotParsedIncluded)
+ {
+ Demux_random_access=true;
+ break;
+ }
+ }
+ else
+ Demux_random_access=true;
+ }
+ else
+ {
+ FrameInfo.DTS=(int64u)-1;
+ FrameInfo.DUR=(int64u)-1;
+ Streams[(int32u)Element_Code].stts_FramePos++;
+ }
+
+ Demux_Level=Streams[(int32u)Element_Code].Demux_Level;
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ if (Stream->second.Parser)
+ {
+ #if MEDIAINFO_DEMUX
+ Stream->second.Parser->FrameInfo=FrameInfo;
+ #endif //MEDIAINFO_DEMUX
+
+ Open_Buffer_Continue(Stream->second.Parser);
+ Element_Offset=Element_Size;
+ Element_Show();
+
+ #if MEDIAINFO_DEMUX
+ if (!Stream->second.IsFilled && Stream->second.Parser->Status[IsFilled])
+ {
+ if (Stream->second.StreamKind==Stream_Menu) //If this is a TimeCode track
+ {
+ if (((File_Mpeg4_TimeCode*)Stream->second.Parser)->Pos!=(int32u)-1)
+ {
+ for (std::map<int32u, stream>::iterator StreamTemp=Streams.begin(); StreamTemp!=Streams.end(); StreamTemp++)
+ if (StreamTemp->second.TimeCode_TrackID==Stream->first)
+ {
+ TimeCode_FrameOffset=((File_Mpeg4_TimeCode*)Stream->second.Parser)->Pos;
+ TimeCode_DtsOffset=float64_int64s(((float64)TimeCode_FrameOffset)*1000000000*Stream->second.TimeCode->FrameDuration/Stream->second.TimeCode->TimeScale);
+ }
+ }
+ }
+
+ Stream->second.IsFilled=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+ else
+ Skip_XX(Element_Size, "Data");
+
+ //Next piece of data
+ Element_Show();
+ mdat_StreamJump();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::mdat_StreamJump()
+{
+ //Finding right file offset
+ int64u ToJump=File_Size;
+ /*if (!mdat_Pos_ToParseInPriority_StreamIDs.empty())
+ {
+ //Hanlding StreamIDs to pars in priority
+ if (!Streams[mdat_Pos_ToParseInPriority_StreamIDs[0]].stco.empty())
+ ToJump=Streams[mdat_Pos_ToParseInPriority_StreamIDs[0]].stco[0];
+ //if (<File_Offset+Buffer_Offset+Element_TotalSize_Get(Element_Level-1)) //If in this element, else
+ mdat_Pos_ToParseInPriority_StreamIDs.erase(mdat_Pos_ToParseInPriority_StreamIDs.begin());
+ }
+ else*/ if (mdat_Pos_Temp!=mdat_Pos.end())
+ ToJump=mdat_Pos_Temp->first;
+ if (ToJump>File_Size)
+ ToJump=File_Size;
+ /*if (ToJump>=File_Offset+Buffer_Offset+Element_TotalSize_Get(Element_Level-1)) //We want always Element mdat
+ {
+ if (!Status[IsAccepted])
+ Data_Accept("MPEG-4");
+ Data_GoTo(File_Offset+Buffer_Offset+Element_TotalSize_Get(Element_Level-1), "MPEG-4"); //Not in this chunk
+ Element_Show();
+ IsParsing_mdat=false;
+ }
+ else*/ if (ToJump!=File_Offset+Buffer_Offset+Element_Size)
+ {
+ if (!Status[IsAccepted])
+ Data_Accept("MPEG-4");
+ Data_GoTo(ToJump, "MPEG-4"); //Not just after
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::mfra()
+{
+ Element_Name("Movie Fragment Random Access");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::mfra_mfro()
+{
+ NAME_VERSION_FLAG("Movie Fragment Random Access Offset");
+
+ //Parsing
+ Skip_B4( "size");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::mfra_tfra()
+{
+ NAME_VERSION_FLAG("Track Fragment Random Access");
+
+ //Parsing
+ int32u number_of_entry;
+ int8u length_size_of_traf_num, length_size_of_trun_num, length_size_of_sample_num;
+ Skip_B4( "track_ID");
+ BS_Begin();
+ Skip_S1(26, "reserved");
+ Get_S1 (2, length_size_of_traf_num, "length_size_of_traf_num");
+ Get_S1 (2, length_size_of_trun_num, "length_size_of_trun_num");
+ Get_S1 (2, length_size_of_sample_num, "length_size_of_sample_num");
+ BS_End();
+ Get_B4(number_of_entry, "number_of_entry");
+ for(int32u Pos=0; Pos<number_of_entry; Pos++)
+ {
+ Element_Begin1("entry");
+ int64u time, moof_offset;
+ Get_B_DEPENDOFVERSION(time, "time");
+ Get_B_DEPENDOFVERSION(moof_offset, "moof_offset");
+ switch (length_size_of_traf_num)
+ {
+ case 0 : Skip_B1( "traf_number"); break;
+ case 1 : Skip_B2( "traf_number"); break;
+ case 2 : Skip_B3( "traf_number"); break;
+ case 3 : Skip_B4( "traf_number"); break;
+ default: ;
+ }
+ switch (length_size_of_trun_num)
+ {
+ case 0 : Skip_B1( "trun_num"); break;
+ case 1 : Skip_B2( "trun_num"); break;
+ case 2 : Skip_B3( "trun_num"); break;
+ case 3 : Skip_B4( "trun_num"); break;
+ default: ;
+ }
+ switch (length_size_of_sample_num)
+ {
+ case 0 : Skip_B1( "sample_num"); break;
+ case 1 : Skip_B2( "sample_num"); break;
+ case 2 : Skip_B3( "sample_num"); break;
+ case 3 : Skip_B4( "sample_num"); break;
+ default: ;
+ }
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moof()
+{
+ Element_Name("Movie Fragment");
+
+ if (IsSecondPass)
+ {
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ Param("Data", Ztring("(")+Ztring::ToZtring(Element_TotalSize_Get())+Ztring(" bytes)"));
+ #endif //MEDIAINFO_TRACE
+ Element_Offset=Element_TotalSize_Get(); //Not using Skip_XX() because we want to skip data we don't have, and Skip_XX() does a test on size of buffer
+ return;
+ }
+
+ IsFragmented=true;
+ moof_base_data_offset=File_Offset+Buffer_Offset-Header_Size;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moof_mfhd()
+{
+ NAME_VERSION_FLAG("Movie Fragment Header");
+
+ //Parsing
+ Skip_B4( "sequence_number");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moof_traf()
+{
+ Element_Name("Track Fragment");
+
+ //Filling
+ moof_traf_base_data_offset=(int64u)-1;
+ Stream=Streams.begin(); //Using first track in case there is no track header
+ moof_traf_default_sample_duration=Stream->second.mvex_trex_default_sample_duration;
+ moof_traf_default_sample_size=Stream->second.mvex_trex_default_sample_size;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moof_traf_sdtp()
+{
+ NAME_VERSION_FLAG("Independent and Disposable Samples");
+
+ //Parsing
+ //for (int32u Pos=0; Pos<sample_count; Pos++) //sample_count should be taken from stsz or stz2
+ while (Element_Offset<Element_Size)
+ {
+ Element_Begin1("sample");
+ BS_Begin();
+ Skip_S1(2, "reserved");
+ Info_S1(2, sample_depends_on, "sample_depends_on"); Param_Info1(Mpeg4_sample_depends_on[sample_depends_on]);
+ Info_S1(2, sample_is_depended_on, "sample_is_depended_on"); Param_Info1(Mpeg4_sample_is_depended_on[sample_is_depended_on]);
+ Info_S1(2, sample_has_redundancy, "sample_has_redundancy"); Param_Info1(Mpeg4_sample_has_redundancy[sample_has_redundancy]);
+ BS_End();
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moof_traf_tfhd()
+{
+ NAME_VERSION_FLAG("Track Fragment Header");
+
+ //Parsing
+ bool base_data_offset_present, sample_description_index_present, default_sample_duration_present, default_sample_size_present, default_sample_flags_present;
+ Get_Flags (Flags, 0, base_data_offset_present, "base-data-offset-present");
+ Get_Flags (Flags, 1, sample_description_index_present, "sample-description-index-present");
+ Get_Flags (Flags, 3, default_sample_duration_present, "default-sample-duration-present");
+ Get_Flags (Flags, 4, default_sample_size_present, "default-sample-size-present");
+ Get_Flags (Flags, 5, default_sample_flags_present, "default-sample-flags-present");
+ Skip_Flags(Flags, 16, "duration-is-empty");
+ Get_B4 (moov_trak_tkhd_TrackID, "track_ID");
+ if (base_data_offset_present)
+ Get_B8 (moof_traf_base_data_offset, "base_data_offset");
+ if (sample_description_index_present)
+ Skip_B4( "sample_description_index");
+ if (default_sample_duration_present)
+ Get_B4 (moof_traf_default_sample_duration, "default_sample_duration");
+ if (default_sample_size_present)
+ Get_B4 (moof_traf_default_sample_size, "default_sample_size");
+ if (default_sample_flags_present)
+ Skip_B4( "default_sample_flags");
+
+ FILLING_BEGIN();
+ Stream=Streams.find(moov_trak_tkhd_TrackID);
+ if (Stream==Streams.end())
+ Stream=Streams.begin();
+ moof_traf_default_sample_duration=Stream->second.mvex_trex_default_sample_duration;
+ moof_traf_default_sample_size=Stream->second.mvex_trex_default_sample_size;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moof_traf_trun()
+{
+ NAME_VERSION_FLAG("Track Fragment Run");
+
+ //Parsing
+ int32u sample_count;
+ bool data_offset_present, first_sample_flags_present, sample_duration_present, sample_size_present, sample_flags_present, sample_composition_time_offset_present;
+ Get_Flags (Flags, 0, data_offset_present, "data-offset-present");
+ Get_Flags (Flags, 2, first_sample_flags_present, "first-sample-flags-present");
+ Get_Flags (Flags, 8, sample_duration_present, "sample-duration-present");
+ Get_Flags (Flags, 9, sample_size_present, "sample-size-present");
+ Get_Flags (Flags, 10, sample_flags_present, "sample-flags-present");
+ Get_Flags (Flags, 11, sample_composition_time_offset_present, "sample-composition-time-offsets-present");
+ Get_B4 (sample_count, "sample_count");
+ int64u data_offset_Final=moof_traf_base_data_offset!=(int64u)-1?moof_traf_base_data_offset:moof_base_data_offset;
+ if (data_offset_present)
+ {
+ int32u data_offset;
+ Get_B4 (data_offset, "data_offset");
+ data_offset_Final+=data_offset;
+ }
+
+ //Filling
+ Stream->second.stco.push_back(data_offset_Final);
+ stream::stsc_struct Stsc;
+ if (Stream->second.stsc.empty())
+ Stsc.FirstChunk=1;
+ else
+ Stsc.FirstChunk=Stream->second.stsc[Stream->second.stsc.size()-1].FirstChunk+1;
+ Stsc.SamplesPerChunk=sample_count;
+ Stream->second.stsc.push_back(Stsc);
+ if (!sample_duration_present)
+ moov_trak_mdia_minf_stbl_stts_Common(sample_count, moof_traf_default_sample_duration);
+ if (!sample_size_present)
+ Stream->second.stsz.resize(Stream->second.stsz.size()+sample_count, moof_traf_default_sample_size);
+
+ if (first_sample_flags_present)
+ Skip_B4( "first_sample_flags");
+ for (int32u Pos=0; Pos<sample_count; Pos++)
+ {
+ Element_Begin1("sample");
+ if (sample_duration_present)
+ {
+ int32u sample_duration;
+ Get_B4 (sample_duration, "sample_duration");
+
+ moov_trak_mdia_minf_stbl_stts_Common(1, sample_duration);
+ }
+ if (sample_size_present)
+ {
+ int32u sample_size;
+ Get_B4 (sample_size, "sample_size");
+
+ //Filling
+ Stream->second.stsz_StreamSize+=sample_size;
+ Stream->second.stsz_Total.push_back(sample_size);
+ if (Stream->second.stsz.size()<300 || MediaInfoLib::Config.ParseSpeed_Get()==1.00)
+ Stream->second.stsz.push_back(sample_size);
+ }
+ if (sample_flags_present)
+ Skip_B4( "sample_flags");
+ if (sample_composition_time_offset_present)
+ Skip_B4( "sample_composition_time_offset");
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov()
+{
+ if (!Status[IsAccepted])
+ {
+ Data_Accept("MPEG-4");
+
+ Fill(Stream_General, 0, General_Format, "QuickTime"); //If there is no ftyp atom, this is an old Quictime file
+ }
+ Element_Name("File header");
+
+ if (IsSecondPass || FirstMoovPos!=(int64u)-1) //Currently, the 1 moov atom is used
+ {
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ Param("Data", Ztring("(")+Ztring::ToZtring(Element_TotalSize_Get())+Ztring(" bytes)"));
+ #endif //MEDIAINFO_TRACE
+ Element_Offset=Element_TotalSize_Get(); //Not using Skip_XX() because we want to skip data we don't have, and Skip_XX() does a test on size of buffer
+ return;
+ }
+
+ if (FirstMoovPos==(int64u)-1)
+ FirstMoovPos=File_Offset+Buffer_Offset-Header_Size;
+ /*
+ else
+ {
+ //In case of more than 1 moov atom, the last one is used (previous ones are trashed)
+ Streams.clear();
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
+ while (Count_Get((stream_t)StreamKind))
+ Stream_Erase((stream_t)StreamKind, Count_Get((stream_t)StreamKind)-1);
+ }
+ */
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_cmov()
+{
+ Element_Name("Compressed file header");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_cmov_cmvd()
+{
+ Element_Name("Data");
+
+ switch (moov_cmov_dcom_Compressor)
+ {
+ case Elements::moov_cmov_dcom_zlib : moov_cmov_cmvd_zlib(); break;
+ default: Skip_XX(Element_Size, "Data");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_cmov_cmvd_zlib()
+{
+ Element_Name("Zlib");
+
+ //Parsing
+ int32u Dest_Size32;
+ Get_B4(Dest_Size32, "Destination size");
+
+ FILLING_BEGIN();
+ //Sizes
+ unsigned long Source_Size=(unsigned long)(Element_Size-Element_Offset);
+ unsigned long Dest_Size=Dest_Size32;
+
+ //Uncompressing
+ int8u* Dest=new int8u[Dest_Size];
+ if (uncompress((Bytef*)Dest, &Dest_Size, (const Bytef*)Buffer+Buffer_Offset+4, Source_Size)<0)
+ {
+ Skip_XX(Element_Size, "Problem during the decompression");
+ delete[] Dest; //Dest=NULL;
+ return;
+ }
+
+ //Exiting this element
+ Skip_XX(Element_Size-Element_Offset, "Will be parsed");
+
+ //Configuring level
+ std::vector<int64u> Element_Sizes_Sav;
+ size_t Element_Level_Sav=Element_Level;
+ while(Element_Level)
+ {
+ Element_Sizes_Sav.push_back(Element_TotalSize_Get());
+ Element_End0();
+ }
+
+ //Configuring buffer
+ const int8u* Buffer_Sav=Buffer;
+ size_t Buffer_Size_Sav=Buffer_Size;
+ int8u* Buffer_Temp_Sav=Buffer_Temp;
+ size_t Buffer_Temp_Size_Sav=Buffer_Temp_Size;
+ size_t Buffer_Offset_Sav=Buffer_Offset;
+ size_t Buffer_Offset_Temp_Sav=Buffer_Offset_Temp;
+ Buffer=NULL;
+ Buffer_Size=0;
+ Buffer_Temp=NULL;
+ Buffer_Temp_Size=0;
+ Buffer_Offset=0;
+ Buffer_Offset_Temp=0;
+
+ //Configuring file size
+ int64u File_Offset_Sav=File_Offset;
+ int64u File_Size_Sav=File_Size;
+ if (File_Size<File_Offset+Buffer_Offset+Element_Offset+Dest_Size)
+ File_Size=File_Offset+Buffer_Offset+Element_Offset+Dest_Size;
+ Element_Level++;
+ Header_Fill_Size(File_Size);
+ Element_Level--;
+
+ //Configuring some status info
+ FirstMoovPos=(int64u)-1;
+
+ //Parsing
+ Open_Buffer_Continue(Dest, Dest_Size);
+ delete[] Dest; //Dest=NULL;
+
+ //Resetting file info
+ File_Offset=File_Offset_Sav;
+ File_Size=File_Size_Sav;
+
+ //Resetting buffer
+ Buffer=Buffer_Sav;
+ Buffer_Size=Buffer_Size_Sav;
+ Buffer_Temp=Buffer_Temp_Sav;
+ Buffer_Temp_Size=Buffer_Temp_Size_Sav;
+ Buffer_Offset=Buffer_Offset_Sav;
+ Buffer_Offset_Temp=Buffer_Offset_Temp_Sav;
+
+ //Configuring level
+ while(Element_Level)
+ Element_End0();
+ Element_Level++;
+ Header_Fill_Size(File_Size);
+ Element_Level--;
+ while(Element_Level<Element_Level_Sav)
+ {
+ Element_Begin0();
+ Element_Begin0();
+ Header_Fill_Size(Element_Sizes_Sav[0]);
+ Element_End0();
+ }
+
+ //Filling
+ Fill(Stream_General, 0, General_Format_Settings, "Compressed header");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_ctab()
+{
+ Element_Name("Color Table");
+
+ //Parsing
+ int16u Size;
+ Skip_B4( "Color table seed");
+ Skip_B2( "Color table flags");
+ Get_B2 (Size, "Color table size");
+ for (int16u Pos=0; Pos<=Size; Pos++)
+ {
+ Skip_B2( "Zero");
+ Skip_B2( "Red");
+ Skip_B2( "Green");
+ Skip_B2( "Blue");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_cmov_dcom()
+{
+ Element_Name("Data compressor name");
+
+ //Parsing
+ Get_C4 (moov_cmov_dcom_Compressor, "Value");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_iods()
+{
+ NAME_VERSION_FLAG("Initial object descriptor");
+ INTEGRITY_VERSION(0);
+
+ FILLING_BEGIN();
+ Descriptors();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_meta()
+{
+ Element_Name("Metadata");
+
+ //Filling
+ moov_meta_hdlr_Type=0;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_meta_bxml()
+{
+ NAME_VERSION_FLAG("Binary XML"); //ISO/IEC 14496-12
+ INTEGRITY(moov_meta_hdlr_Type==Elements::moov_meta_hdlr_mp7b, "Bad meta type");
+
+ //Parsing
+ Skip_XX(Element_Size-Element_Offset, "Binary XML dump");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_meta_hdlr()
+{
+ NAME_VERSION_FLAG("Metadata Header"); //ISO/IEC 14496-12 handler
+
+ //Parsing
+ Skip_C4( "Type (Quicktime)"); //Filled if Quicktime
+ Get_C4 (moov_meta_hdlr_Type, "Metadata type");
+ if (Element_Offset+12<=Element_Size)
+ {
+ Skip_C4( "Manufacturer");
+ Skip_B4( "Component reserved flags"); //Filled if Quicktime
+ Skip_B4( "Component reserved flags mask"); //Filled if Quicktime
+ if (Element_Offset<Element_Size)
+ Skip_Local(Element_Size-Element_Offset, "Component type name");
+ }
+ else if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_meta_keys()
+{
+ NAME_VERSION_FLAG("Keys");
+ INTEGRITY(moov_meta_hdlr_Type==Elements::moov_meta_hdlr_mdta, "Bad meta type");
+
+ //Parsing
+ Skip_B4( "Count");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_meta_keys_mdta()
+{
+ Element_Name("Name");
+ INTEGRITY(moov_meta_hdlr_Type==Elements::moov_meta_hdlr_mdta, "Bad meta type");
+
+ //Parsing
+ std::string Value;
+ Get_String(Element_Size, Value, "Value");
+
+ //Filling
+ moov_udta_meta_keys_List.push_back(Value);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_meta_ilst()
+{
+ Element_Name("List");
+
+ //Filling
+ moov_udta_meta_keys_ilst_Pos=0;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_meta_ilst_xxxx()
+{
+ Element_Name("Element");
+
+ //Filling
+ moov_meta_ilst_xxxx_name_Name.clear(); //useful if metadata type = "mdir"
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_meta_ilst_xxxx_data()
+{
+ Element_Name("Data");
+
+ //Parsing
+ int32u Kind, Language;
+ Ztring Value;
+ Get_B4(Kind, "Kind"); Param_Info1(Mpeg4_Meta_Kind(Kind));
+
+ //Error detection
+ switch (Element_Code_Get(Element_Level-1))
+ {
+ case Elements::moov_meta__disk :
+ case Elements::moov_meta__trkn :
+ if (Kind)
+ {
+ //Not normal
+ Kind=0x00;
+ }
+ default : ;
+ }
+
+ switch (Kind)
+ {
+ case 0x00 : //Binary
+ Get_B4(Language, "Language");
+ switch (Element_Code_Get(Element_Level-1))
+ {
+ case Elements::moov_meta__disk :
+ {
+ //Parsing
+ int16u Position, Total;
+ Skip_B2( "Reserved");
+ Get_B2(Position, "Position");
+ Get_B2(Total, "Total");
+ if (Element_Offset+2<=Element_Size)
+ Skip_B2( "Reserved"); //Sometimes there are 2 more bytes, unknown
+
+ //Filling
+ if (Position)
+ Fill(Stream_General, 0, General_Part_Position, Position, 10, true);
+ if (Total)
+ Fill(Stream_General, 0, General_Part_Position_Total, Total, 10, true);
+ }
+ return;
+ case Elements::moov_meta__trkn :
+ {
+ //Parsing
+ int16u Position, Total;
+ Skip_B2( "Reserved");
+ Get_B2(Position, "Position");
+ Get_B2(Total, "Total");
+ if (Element_Offset+2<=Element_Size)
+ Skip_B2( "Reserved"); //Sometimes there are 2 more bytes, unknown
+
+ //Filling
+ if (Position)
+ Fill(Stream_General, 0, General_Track_Position, Position, 10, true);
+ if (Total)
+ Fill(Stream_General, 0, General_Track_Position_Total, Total, 10, true);
+ }
+ return;
+ case Elements::moov_meta__covr :
+ {
+ std::string Data_Raw((const char*)(Buffer+(size_t)(Buffer_Offset+Element_Offset)), (size_t)(Element_Size-Element_Offset));
+ std::string Data_Base64(Base64::encode(Data_Raw));
+ Skip_XX(Element_Size-Element_Offset, "Data");
+
+ //Filling
+ Fill(Stream_General, 0, General_Cover_Data, Data_Base64);
+ Fill(Stream_General, 0, General_Cover, "Yes");
+ }
+ return;
+ case Elements::moov_meta__gnre :
+ {
+ if (Element_Size-Element_Offset==2)
+ {
+ int16u Genre;
+ Get_B2(Genre, "Genre");
+
+ //Filling
+ if (Genre)
+ Fill(Stream_General, 0, General_Genre, Genre-1);
+ }
+ else
+ Skip_XX(Element_Size-Element_Offset,"Data");
+ }
+ return;
+ default:
+ Skip_XX(Element_Size-Element_Offset,"To decode!");
+ Value=_T("(Binary)");
+ }
+ break;
+ case 0x01 : //UTF-8
+ Get_B4(Language, "Language");
+ switch (Element_Code_Get(Element_Level-1))
+ {
+ case Elements::moov_meta___day :
+ {
+ std::string ValueS;
+ Get_String(Element_Size-Element_Offset, ValueS, "Value");
+ Value.Date_From_String(ValueS.c_str(), ValueS.size());
+ }
+ break;
+ default:
+ Get_UTF8(Element_Size-Element_Offset, Value, "Value");
+ }
+ break;
+ case 0x02 : //UTF-16
+ Value=_T("UTF-16 encoding not yet supported");
+ break;
+ case 0x03 : //Mac String
+ Get_B4(Language, "Language"); //To confirm
+ Get_Local(Element_Size-Element_Offset, Value, "Value");
+ break;
+ case 0x0D : //JPEG
+ Get_B4(Language, "Language");
+ switch (Element_Code_Get(Element_Level-1))
+ {
+ case Elements::moov_meta__covr :
+ {
+ std::string Data_Raw((const char*)(Buffer+(size_t)(Buffer_Offset+Element_Offset)), (size_t)(Element_Size-Element_Offset));
+ std::string Data_Base64(Base64::encode(Data_Raw));
+ Skip_XX(Element_Size-Element_Offset, "Data");
+
+ //Filling
+ Fill(Stream_General, 0, General_Cover_Data, Data_Base64);
+ Fill(Stream_General, 0, General_Cover, "Yes");
+ }
+ return;
+ default:
+ Value=_T("(Binary)");
+ }
+ break;
+ case 0x0E : //PNG
+ Get_B4(Language, "Language");
+ switch (Element_Code_Get(Element_Level-1))
+ {
+ case Elements::moov_meta__covr :
+ {
+ std::string Data_Raw((const char*)(Buffer+(size_t)(Buffer_Offset+Element_Offset)), (size_t)(Element_Size-Element_Offset));
+ std::string Data_Base64(Base64::encode(Data_Raw));
+ Skip_XX(Element_Size-Element_Offset, "Data");
+
+ //Filling
+ Fill(Stream_General, 0, General_Cover_Data, Data_Base64);
+ Fill(Stream_General, 0, General_Cover, "Yes");
+ }
+ return;
+ default:
+ Value=_T("(Binary)");
+ }
+ break;
+ case 0x15 : //Signed Integer
+ {
+ Get_B4(Language, "Language");
+ switch (Element_Size-Element_Offset)
+ {
+ case 1 : {int8u ValueI; Get_B1(ValueI, "Value"); Value.From_Number((int8s) ValueI);}; break;
+ case 2 : {int16u ValueI; Get_B2(ValueI, "Value"); Value.From_Number((int16s)ValueI);}; break;
+ case 4 : {int32u ValueI; Get_B4(ValueI, "Value"); Value.From_Number((int32s)ValueI);}; break;
+ case 8 : {int64u ValueI; Get_B8(ValueI, "Value"); Value.From_Number((int64s)ValueI);}; break;
+ default : Value=_T("Unknown kind of integer value!");
+ }
+ }
+ break;
+ case 0x16 : //Float 32
+ Skip_XX(4, "To decode!");
+ //Value=_T("Float32 encoding not yet supported");
+ break;
+ case 0x17 : //Float 64
+ Skip_XX(8, "To decode!");
+ //Value=_T("Float64 encoding not yet supported");
+ break;
+ default: Value=_T("Unknown kind of value!");
+ }
+
+ switch (moov_meta_hdlr_Type)
+ {
+ case Elements::moov_meta_hdlr_mdir :
+ {
+ FILLING_BEGIN();
+ std::string Parameter;
+ if (Element_Code_Get(Element_Level-1)==Elements::moov_meta______)
+ Metadata_Get(Parameter, moov_meta_ilst_xxxx_name_Name);
+ else
+ Metadata_Get(Parameter, Element_Code_Get(Element_Level-1));
+ if (Parameter=="Encoded_Application")
+ {
+ if (Value.find(_T("Nero AAC codec"))==0)
+ {
+ ZtringList List; List.Separator_Set(0, _T(" / "));
+ List.Write(Value);
+ Element_Info1(Parameter.c_str());
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Name, List(0), true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Version, List(1), true);
+ Parameter.clear(); //Set as already filled
+ }
+ }
+ if (Parameter=="cdec")
+ {
+ if (Value.find(_T("ndaudio "))==0)
+ {
+ ZtringList List; List.Separator_Set(0, _T(" / "));
+ List.Write(Value);
+ Element_Info1(Parameter.c_str());
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Name, "Nero AAC codec", Unlimited, true, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Name, List(0).substr(8, string::npos), true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Settings, List(1), true);
+ Parameter.clear(); //Set as already filled
+ }
+ }
+ if (Parameter=="Compilation")
+ {
+ if (Value==_T("1"))
+ Value=_T("Yes");
+ else
+ Value.clear(); //This is usually set to 0 even if the user did not explicitely indicated something (default)
+ }
+ if (Parameter=="BPM")
+ {
+ if (Value==_T("0"))
+ Value.clear();
+ }
+ if (!Parameter.empty())
+ {
+ Element_Info1(Parameter.c_str());
+ Fill(Stream_General, 0, Parameter.c_str(), Value, true);
+ }
+ FILLING_END();
+ }
+ break;
+ case Elements::moov_meta_hdlr_mdta :
+ if(!moov_udta_meta_keys_List.empty())
+ {
+ FILLING_BEGIN();
+ std::string Parameter;
+ Metadata_Get(Parameter, moov_udta_meta_keys_List[moov_udta_meta_keys_ilst_Pos<moov_udta_meta_keys_List.size()?moov_udta_meta_keys_ilst_Pos:moov_udta_meta_keys_List.size()-1]);
+ if (Parameter=="com.apple.quicktime.version")
+ Vendor_Version=Value.SubString(_T(""), _T(" "));
+ else if (Parameter=="com.apple.quicktime.player.version")
+ Vendor_Version=Value.SubString(_T(""), _T(" "));
+ else if (Parameter=="com.apple.quicktime.comment")
+ Fill(Stream_General, 0, General_Comment, Value, true);
+ else if (Parameter=="com.apple.quicktime.description")
+ Fill(Stream_General, 0, General_Description, Value, true);
+ else if (Parameter=="com.apple.finalcutstudio.media.uuid")
+ Fill(Stream_General, 0, "Media/UUID", Value);
+ else if (Parameter=="com.apple.finalcutstudio.media.history.uuid")
+ Fill(Stream_General, 0, "Media/History/UUID", Value);
+ else if (!Parameter.empty())
+ Fill(Stream_General, 0, Parameter.c_str(), Value, true);
+ FILLING_END();
+ moov_udta_meta_keys_ilst_Pos++;
+ }
+ else
+ Param2("Keys atom is missing!", 0);
+
+ case Elements::moov_udta_meta :
+ {
+ FILLING_BEGIN();
+ std::string Parameter;
+ Metadata_Get(Parameter, (int32u)Element_Code_Get(Element_Level-1));
+ if (!Parameter.empty())
+ Fill(Stream_General, 0, Parameter.c_str(), Value, true);
+ FILLING_END();
+ }
+ default: ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_meta_ilst_xxxx_mean()
+{
+ Element_Name("Mean");
+
+ //Parsing
+ Skip_B4( "Unknown");
+ Skip_Local(Element_Size-Element_Offset, "Value");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_meta_ilst_xxxx_name()
+{
+ Element_Name("Name");
+
+ //Parsing
+ Skip_B4( "Unknown");
+ Get_String(Element_Size-Element_Offset, moov_meta_ilst_xxxx_name_Name, "Value");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_meta_xml()
+{
+ NAME_VERSION_FLAG("XML"); //ISO/IEC 14496-12
+ INTEGRITY(moov_meta_hdlr_Type==Elements::moov_meta_hdlr_mp7t, "Bad meta type");
+
+ //Parsing
+ Skip_XX(Element_Size-Element_Offset, "XML dump");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_mvex()
+{
+ Element_Name("Movie Extends");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_mvex_mehd()
+{
+ NAME_VERSION_FLAG("Movie Extends Header");
+
+ //Parsing
+ int64u fragment_duration;
+ Get_B_DEPENDOFVERSION(fragment_duration, "fragment_duration");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_mvex_trex()
+{
+ NAME_VERSION_FLAG("Movie Extends Defaults");
+
+ //Parsing
+ int32u default_sample_duration;
+ int32u default_sample_size;
+ Get_B4 (moov_trak_tkhd_TrackID, "track_ID");
+ Skip_B4( "default_sample_description_index");
+ Get_B4 (default_sample_duration, "default_sample_duration");
+ Get_B4 (default_sample_size, "default_sample_size");
+ Element_Begin1("default_sample_flags");
+ BS_Begin();
+ Skip_S1(6, "reserved");
+ Skip_S1(2, "sample_depends_on");
+ Skip_S1(2, "sample_is_depended_on");
+ Skip_S1(2, "sample_has_redundancy");
+ Skip_S1(3, "sample_padding_value");
+ Skip_SB( "sample_is_difference_sample");
+ BS_End();
+ Skip_B2( "sample_degradation_priority");
+ Element_End0();
+
+ FILLING_BEGIN()
+ Streams[moov_trak_tkhd_TrackID].mvex_trex_default_sample_duration=default_sample_duration;
+ Streams[moov_trak_tkhd_TrackID].mvex_trex_default_sample_size=default_sample_size;
+ FILLING_END()
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_mvhd()
+{
+ NAME_VERSION_FLAG("Movie header");
+
+ //Parsing
+ Ztring Date_Created, Date_Modified;
+ int64u Duration;
+ float32 a, b, u, c, d, v, x, y, w;
+ int32u Rate;
+ int16u Volume;
+ Get_DATE1904_DEPENDOFVERSION(Date_Created, "Creation time");
+ Get_DATE1904_DEPENDOFVERSION(Date_Modified, "Modification time");
+ Get_B4(TimeScale, "Time scale"); Param_Info1(Ztring::ToZtring(TimeScale)+_T(" Hz"));
+ Get_B_DEPENDOFVERSION(Duration, "Duration"); Param_Info1(Ztring::ToZtring((int64u)Duration*1000/TimeScale)+_T(" ms"));
+ Get_B4 (Rate, "Preferred rate"); Param_Info1(Ztring::ToZtring(((float32)Rate)/0x10000));
+ Get_B2 (Volume, "Preferred volume"); Param_Info1(Ztring::ToZtring(((float32)Volume)/0x100));
+ Skip_XX(10, "Reserved");
+ Element_Begin1("Matrix structure");
+ Get_BFP4(16, a, "a (width scale)");
+ Get_BFP4(16, b, "b (width rotate)");
+ Get_BFP4( 2, u, "u (width angle)");
+ Get_BFP4(16, c, "c (height rotate)");
+ Get_BFP4(16, d, "d (height scale)");
+ Get_BFP4( 2, v, "v (height angle)");
+ Get_BFP4(16, x, "x (position left)");
+ Get_BFP4(16, y, "y (position top)");
+ Get_BFP4( 2, w, "w (divider)");
+ Element_End0();
+ Skip_B4( "Preview time");
+ Skip_B4( "Preview duration");
+ Skip_B4( "Poster time");
+ Skip_B4( "Selection time");
+ Skip_B4( "Selection duration");
+ Skip_B4( "Current time");
+ Skip_B4( "Next track ID");
+
+ FILLING_BEGIN();
+ if (TimeScale)
+ {
+ //int32u Duration=(int32u)(((float)Duration)/TimeScale*1000);
+ //Fill("Duration", Duration);
+ }
+ if (Date_Created.find(_T('\r'))!=std::string::npos)
+ Date_Created.resize(Date_Created.find(_T('\r')));
+ if (Date_Created.find(_T('\n'))!=std::string::npos)
+ Date_Created.resize(Date_Created.find(_T('\n')));
+ Fill(StreamKind_Last, StreamPos_Last, "Encoded_Date", Date_Created);
+ if (Date_Modified.find(_T('\r'))!=std::string::npos)
+ Date_Modified.resize(Date_Modified.find(_T('\r')));
+ if (Date_Modified.find(_T('\n'))!=std::string::npos)
+ Date_Modified.resize(Date_Modified.find(_T('\n')));
+ Fill(StreamKind_Last, StreamPos_Last, "Tagged_Date", Date_Modified);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak()
+{
+ Element_Name("Track");
+
+ FILLING_BEGIN();
+ Fill_Flush();
+ moov_trak_tkhd_TrackID=(int32u)-1;
+ moov_trak_tkhd_Width=0;
+ moov_trak_tkhd_Height=0;
+ moov_trak_tkhd_DisplayAspectRatio=0;
+ moov_trak_tkhd_Rotation=0;
+ Stream_Prepare(Stream_Max); //clear filling
+ Streams.erase((int32u)-1);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_edts()
+{
+ Element_Name("Edit");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_edts_elst()
+{
+ NAME_VERSION_FLAG("Edit List");
+
+ //Parsing
+ int32u Count;
+ Get_B4 (Count, "Number of entries");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ stream::edts_struct edts;
+ Element_Begin1("Entry");
+ Get_B4 (edts.Duration, "Track duration"); Param_Info2((int64u)edts.Duration*1000/TimeScale, " ms");
+ Get_B4 (edts.Delay, "Media time"); Param_Info2C((edts.Delay!=(int32u)-1), (int64u)edts.Delay*1000/TimeScale, " ms");
+ Get_B4 (edts.Rate, "Media rate"); Param_Info1(((float)edts.Rate)/0x10000);
+ Element_End0();
+
+ Streams[moov_trak_tkhd_TrackID].edts.push_back(edts);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_load()
+{
+ Element_Name("Preload");
+
+ //Parsing
+ Info_B4(PreloadTime, "Preload time"); Param_Info2(PreloadTime*1000/TimeScale, " ms");
+ Info_B4(PreloadFlags, "Flags");
+ Skip_Flags(PreloadFlags, 0, "PreloadAlways");
+ Skip_Flags(PreloadFlags, 1, "TrackEnabledPreload");
+ Info_B4(HintFlags, "Hint flags");
+ Skip_Flags(HintFlags, 2, "KeepInBuffer");
+ Skip_Flags(HintFlags, 8, "HighQuality");
+ Skip_Flags(HintFlags, 20, "SingleFieldPlayback");
+ Skip_Flags(HintFlags, 26, "DeinterlaceFields");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia()
+{
+ Element_Name("Media");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_hdlr()
+{
+ NAME_VERSION_FLAG("Handler Reference");
+
+ //Parsing
+ Ztring Title;
+ int32u SubType, Manufacturer;
+ int8u Size;
+ Skip_C4( "Component type");
+ Get_C4 (SubType, "Component subtype");
+ Get_C4 (Manufacturer, "Component manufacturer");
+ Skip_B4( "Component flags");
+ Skip_B4( "Component flags mask");
+ if (Element_Offset<Element_Size)
+ {
+ Peek_B1(Size);
+ if (Element_Offset+1+Size==Element_Size)
+ {
+ Skip_B1( "Component name size");
+ Get_Local(Size, Title, "Component name");
+ }
+ else
+ {
+ std::string TitleS;
+ Get_String(Element_Size-Element_Offset, TitleS, "Component name");
+ Title.From_UTF8(TitleS.c_str());
+ if (Title.empty())
+ Title.From_Local(TitleS.c_str()); //Trying Local...
+ }
+ if (Title.find(_T("Handler"))!=std::string::npos || Title.find(_T("vide"))!=std::string::npos || Title.find(_T("soun"))!=std::string::npos)
+ Title.clear(); //This is not a Title
+ }
+
+ FILLING_BEGIN();
+ if (!Title.empty()) Fill(StreamKind_Last, StreamPos_Last, "Title", Title);
+ switch (SubType)
+ {
+ case Elements::moov_trak_mdia_hdlr_clcp :
+ if (StreamKind_Last!=Stream_Text)
+ {
+ Stream_Prepare(Stream_Text);
+ }
+ break;
+ case Elements::moov_trak_mdia_hdlr_soun :
+ if (StreamKind_Last!=Stream_Audio)
+ {
+ Stream_Prepare(Stream_Audio);
+ }
+ break;
+ case Elements::moov_trak_mdia_hdlr_vide :
+ if (StreamKind_Last!=Stream_Video)
+ {
+ Stream_Prepare(Stream_Video);
+ }
+ break;
+ case Elements::moov_trak_mdia_hdlr_text :
+ case Elements::moov_trak_mdia_hdlr_sbtl :
+ if (StreamKind_Last!=Stream_Text)
+ {
+ Stream_Prepare(Stream_Text);
+ if (SubType!=Elements::moov_trak_mdia_hdlr_text)
+ Fill(Stream_Text, StreamPos_Last, Text_MuxingMode, Ztring().From_CC4(SubType));
+ }
+ break;
+ case Elements::moov_trak_mdia_hdlr_subp :
+ if (StreamKind_Last!=Stream_Text)
+ {
+ Stream_Prepare(Stream_Text);
+ CodecID_Fill(_T("subp"), Stream_Text, StreamPos_Last, InfoCodecID_Format_Mpeg4);
+ Fill(StreamKind_Last, StreamPos_Last, Text_Codec, "subp");
+ }
+ break;
+ case Elements::moov_trak_mdia_hdlr_MPEG :
+ mdat_MustParse=true; //Data is in MDAT
+ break;
+ default: ;
+ }
+ if (Manufacturer!=0x00000000)
+ {
+ if (Vendor==0x00000000)
+ Vendor=Manufacturer;
+ else if (Vendor!=Manufacturer)
+ Vendor=0xFFFFFFFF; //Two names, this is two much
+ }
+
+ Streams[moov_trak_tkhd_TrackID].StreamKind=StreamKind_Last;
+ Streams[moov_trak_tkhd_TrackID].StreamPos=StreamPos_Last;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_imap()
+{
+ Element_Name("Non-primary source input map");
+
+ //Parsing
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_imap_sean()
+{
+ //Parsing
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_imap_sean___in()
+{
+ Element_Name("Input");
+
+ //Parsing
+ Skip_B4( "Atom ID");
+ Skip_B2( "Zero");
+ Skip_B2( "Number of internal atoms");
+ Skip_B4( "Zero");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_imap_sean___in___ty()
+{
+ Element_Name("Input type");
+
+ //Parsing
+ Info_B4(TypeModifierName, "Type modifier name"); Param_Info1(Mpeg4_TypeModifierName(TypeModifierName));
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_imap_sean___in_dtst()
+{
+ //Parsing
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+ Skip_C4( "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_imap_sean___in_obid()
+{
+ Element_Name("Object ID");
+
+ //Parsing
+ Skip_B4( "Object ID");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_mdhd()
+{
+ NAME_VERSION_FLAG("Media Header");
+
+ //Parsing
+ Ztring Date_Created, Date_Modified;
+ int64u Duration;
+ int32u TimeScale;
+ int16u Language;
+ Get_DATE1904_DEPENDOFVERSION(Date_Created, "Creation time");
+ Get_DATE1904_DEPENDOFVERSION(Date_Modified, "Modification time");
+ Get_B4(TimeScale, "Time scale");
+ Get_B_DEPENDOFVERSION(Duration, "Duration"); Param_Info2(Duration*1000/TimeScale, " ms"); Element_Info2(Duration*1000/TimeScale, " ms");
+ Get_B2 (Language, "Language"); Param_Info1(Language_Get(Language));
+ Skip_B2( "Quality");
+
+ FILLING_BEGIN();
+ Fill(StreamKind_Last, StreamPos_Last, "Language", Language_Get(Language));
+ Streams[moov_trak_tkhd_TrackID].mdhd_Duration=Duration;
+ Streams[moov_trak_tkhd_TrackID].mdhd_TimeScale=TimeScale;
+
+ //Coherency tests
+ if (Streams[moov_trak_tkhd_TrackID].tkhd_Duration*1.01>=Duration*0.99 && Streams[moov_trak_tkhd_TrackID].tkhd_Duration*0.99<=Duration*1.01 && TimeScale && File_Mpeg4::TimeScale!=TimeScale)
+ {
+ float64 Ratio=((float64)TimeScale)/((float64)File_Mpeg4::TimeScale);
+ Streams[moov_trak_tkhd_TrackID].tkhd_Duration=float64_int64s(Streams[moov_trak_tkhd_TrackID].tkhd_Duration/Ratio);
+ Clear(StreamKind_Last, StreamPos_Last, "Duration_Source");
+ Fill(StreamKind_Last, StreamPos_Last, "Duration", float64_int64s(((float64)Streams[moov_trak_tkhd_TrackID].tkhd_Duration)*1000/((float64)File_Mpeg4::TimeScale)), 10, true);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf()
+{
+ Element_Name("Media Information");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_code()
+{
+ Element_Name("code (found in Avid?)");
+
+ //Parsing
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_code_sean()
+{
+ Element_Name("sean (found in Avid?)");
+
+ //Parsing
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_code_sean_RU_A()
+{
+ Element_Name("RU*A (found in Avid?)");
+
+ //Parsing
+ Ztring Path;
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+ Get_Local(Element_Size-Element_Offset, Path, "Path?");
+
+ FILLING_BEGIN();
+ Streams[moov_trak_tkhd_TrackID].File_Name=Path;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_dinf()
+{
+ Element_Name("Data Information");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_dinf_url_()
+{
+ NAME_VERSION_FLAG("Data Location");
+
+ //Parsing
+ Skip_Local(Element_Size-Element_Offset, "location");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_dinf_urn_()
+{
+ NAME_VERSION_FLAG("Data Name");
+
+ //Parsing
+ Skip_Local(Element_Size-Element_Offset, "name TODO location after null string");
+ //Skip_Local(Element_Size, location);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_dinf_dref()
+{
+ NAME_VERSION_FLAG("Data Reference");
+
+ //Parsing
+ Skip_B4( "entry_count");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_dinf_dref_alis()
+{
+ NAME_VERSION_FLAG("Alias"); //bit 0 = external/internal data
+
+ //Often empty
+ bool IsInternal;
+ Get_Flags (Flags, 0, IsInternal, "IsInternal");
+ if (IsInternal)
+ return; //Internal stream, no alias
+
+ //Parsing
+ Ztring file_name_string, volume_name_string, Directory_Name;
+ int16u record_size, record_version, alias_kind;
+ int8u volume_name_string_length, file_name_string_length;
+ Element_Begin1("Mac OS Alias Record");
+ Skip_B4( "user type name/app creator code");
+ Get_B2 (record_size, "record size");
+ Get_B2 (record_version, "record version");
+ if (record_version!=2)
+ {
+ Skip_XX(Element_Size-Element_Offset, "unknown");
+ return;
+ }
+ int64u End=Element_Offset-8+record_size;
+ Get_B2 (alias_kind, "alias kind"); Param_Info1(alias_kind?"directory":"file");
+ Get_B1 (volume_name_string_length, "volume name string length");
+ if (volume_name_string_length>27)
+ volume_name_string_length=27;
+ Get_Local(volume_name_string_length, volume_name_string, "volume name string");
+ if (volume_name_string_length<27)
+ Skip_XX(27-volume_name_string_length, "volume name string padding");
+ Skip_B4( "volume created mac local date"); //seconds since beginning 1904 to 2040
+ Skip_B2( "file system type");
+ Skip_B2( "drive type");
+ Skip_B4( "parent directory ID");
+ Get_B1 (file_name_string_length, "file name string length");
+ if (file_name_string_length>99)
+ file_name_string_length=99;
+ Get_Local(file_name_string_length, file_name_string, "file name string");
+ if (file_name_string_length<63)
+ Skip_XX(63-file_name_string_length, "file name string padding");
+ if (file_name_string_length<=63)
+ Skip_B4( "file number");
+ else if (file_name_string_length<67)
+ Skip_XX(67-file_name_string_length, "file name string padding (hack)");
+ if (file_name_string_length<=67)
+ Skip_B4( "file created mac local date");
+ else if (file_name_string_length<71)
+ Skip_XX(71-file_name_string_length, "file name string padding (hack)");
+ if (file_name_string_length<=71)
+ Skip_B4( "file type name");
+ else if (file_name_string_length<75)
+ Skip_XX(75-file_name_string_length, "file name string padding (hack)");
+ if (file_name_string_length<=75)
+ Skip_B4( "file creator name");
+ else if (file_name_string_length<79)
+ Skip_XX(79-file_name_string_length, "file name string padding (hack)");
+ if (file_name_string_length<=79)
+ Skip_B2( "next level up from alias");
+ else if (file_name_string_length<81)
+ Skip_XX(81-file_name_string_length, "file name string padding (hack)");
+ if (file_name_string_length<=81)
+ Skip_B2( "next level down to target");
+ else if (file_name_string_length<83)
+ Skip_XX(83-file_name_string_length, "file name string padding (hack)");
+ if (file_name_string_length<=83)
+ Skip_B4( "volume attributes");
+ else if (file_name_string_length<87)
+ Skip_XX(87-file_name_string_length, "file name string padding (hack)");
+ if (file_name_string_length<=87)
+ Skip_B2( "volume file system ID");
+ else if (file_name_string_length<89)
+ Skip_XX(89-file_name_string_length, "file name string padding (hack)");
+ if (file_name_string_length<=89)
+ Skip_XX(10, "Reserved");
+ else if (file_name_string_length<99)
+ Skip_XX(99-file_name_string_length, "file name string padding (hack)");
+ while(Element_Offset<End)
+ {
+ Trusted++;
+ int16u type, size;
+ Get_B2 (type, "type");
+ Get_B2 (size, "size");
+ switch (type)
+ {
+ case 0x0000 :
+ Get_Local(size, Directory_Name, "Directory Name");
+ break;
+ case 0x0002 :
+ Skip_Local(size, "Absolute Path");
+ break;
+ case 0xFFFF :
+ Skip_XX(End-Element_Offset, "Padding");
+ break;
+ default :
+ Skip_Local(size, "Unknown");
+ }
+ if (size%2)
+ Skip_B1( "Padding");
+ }
+ Element_End0();
+
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Padding");
+
+ FILLING_BEGIN();
+ if (Streams[moov_trak_tkhd_TrackID].File_Name.empty()) //Priority to "code" version
+ {
+ if (!Directory_Name.empty())
+ {
+ Streams[moov_trak_tkhd_TrackID].File_Name+=Directory_Name;
+ Streams[moov_trak_tkhd_TrackID].File_Name+=ZenLib::PathSeparator;
+ }
+ Streams[moov_trak_tkhd_TrackID].File_Name+=file_name_string;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_dinf_dref_rsrc()
+{
+ Element_Name("Resource alias");
+
+ //Parsing
+ Skip_B4( "Flags"); //bit 0 = external/internal data
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_gmhd()
+{
+ Element_Name("Generic Media Header");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_gmhd_gmin()
+{
+ NAME_VERSION_FLAG("Generic Media Info");
+
+ //Parsing
+ Skip_B2( "Graphics mode");
+ Skip_B2( "Opcolor (red)");
+ Skip_B2( "Opcolor (green)");
+ Skip_B2( "Opcolor (blue)");
+ Skip_B2( "Balance");
+ Skip_B2( "Reserved");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_gmhd_tmcd()
+{
+ Element_Name("TimeCode");
+
+ //Filling
+ Stream_Prepare(Stream_Menu);
+ Fill(Stream_Menu, StreamPos_Last, Menu_Format, "TimeCode");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_gmhd_tmcd_tcmi()
+{
+ NAME_VERSION_FLAG("TimeCode Media Information");
+
+ //Parsing
+ int8u FontNameSize;
+ bool IsVisual;
+ Get_Flags (Flags, 0, IsVisual, "IsVisual");
+ Skip_B2( "Text font");
+ Info_B2(TextFace, "Text face");
+ Skip_Flags(TextFace, 0, "Bold");
+ Skip_Flags(TextFace, 1, "Italic");
+ Skip_Flags(TextFace, 2, "Underline");
+ Skip_Flags(TextFace, 3, "Outline");
+ Skip_Flags(TextFace, 4, "Shadow");
+ Skip_Flags(TextFace, 5, "Condense");
+ Skip_Flags(TextFace, 6, "Extend");
+ if (Element_Size>=25 && 25+Buffer[Buffer_Offset+24]==Element_Size)
+ Skip_BFP4(16, "Text size"); //Non-Standard, but found in several files
+ else
+ Skip_B2( "Text size");
+ Skip_B2( "Text color (red)");
+ Skip_B2( "Text color (green)");
+ Skip_B2( "Text color (blue)");
+ Skip_B2( "Background color (red)");
+ Skip_B2( "Background color (green)");
+ Skip_B2( "Background color (blue)");
+ Get_B1 (FontNameSize, "Font name size");
+ Skip_Local(FontNameSize, "Font name");
+
+ FILLING_BEGIN();
+ Streams[moov_trak_tkhd_TrackID].TimeCode_IsVisual=IsVisual;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_hint()
+{
+ NAME_VERSION_FLAG("Hint");
+
+ //Parsing
+ Skip_B2( "Maximum packet delivery unit");
+ Skip_B2( "Average packet delivery unit");
+ Skip_B4( "Maximum bit rate");
+ Skip_B4( "Average bit rate");
+ Skip_B4( "Reserved");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_hdlr()
+{
+ moov_trak_mdia_hdlr();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_hmhd()
+{
+ NAME_VERSION_FLAG("Hint Media Header");
+
+ //Parsing
+ Skip_B2( "maxPDUsize");
+ Skip_B2( "avgPDUsize");
+ Skip_B4( "maxbitrate");
+ Skip_B4( "avgbitrate");
+ Skip_B4( "reserved");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_nmhd()
+{
+ NAME_VERSION_FLAG("Null Media Header");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_smhd()
+{
+ NAME_VERSION_FLAG("Sound Media Header");
+
+ //Parsing
+ Skip_B2( "Audio balance");
+ Skip_B2( "Reserved");
+
+ FILLING_BEGIN();
+ if (StreamKind_Last!=Stream_Audio)
+ Stream_Prepare(Stream_Audio);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_vmhd()
+{
+ NAME_VERSION_FLAG("Video Media Header")
+
+ //Parsing
+ Skip_B2( "Graphic mode");
+ Skip_B2( "Graphic mode color R");
+ Skip_B2( "Graphic mode color G");
+ Skip_B2( "Graphic mode color B");
+
+ FILLING_BEGIN();
+ if (StreamKind_Last!=Stream_Video)
+ {
+ Stream_Prepare(Stream_Video);
+ Streams[moov_trak_tkhd_TrackID].StreamKind=Stream_Video;
+ Streams[moov_trak_tkhd_TrackID].StreamPos=StreamPos_Last;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl()
+{
+ Element_Name("Sample Table");
+
+ FILLING_BEGIN();
+ Buffer_MaximumSize=16*1024*1024; //If we are here, this is really a MPEG-4 file, and some atoms are very bigs...
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_co64()
+{
+ NAME_VERSION_FLAG("Chunk offset");
+
+ int64u Offset;
+ int32u Count;
+ Get_B4 (Count, "Number of entries");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ //Too much slow
+ /*
+ Get_B8 (Offset, "Offset");
+ */
+
+ //Faster
+ if (Element_Offset+8>Element_Size)
+ break; //Problem
+ Offset=BigEndian2int64u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=8;
+
+ if (Pos<300 || MediaInfoLib::Config.ParseSpeed_Get()==1.00)
+ Streams[moov_trak_tkhd_TrackID].stco.push_back(Offset);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_cslg()
+{
+ Element_Name("Composition Shift Least Greatest");
+
+ //Parsing
+ Skip_XX(Element_Size, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_ctts()
+{
+ NAME_VERSION_FLAG("Composition Time To Sample");
+
+ //Parsing
+ int32u entry_count;
+ Get_B4 (entry_count, "entry_count");
+
+ //Currently no usage
+ //for (int32u Pos=0; Pos<entry_count; Pos++)
+ {
+ //int32u sample_count, sample_offset;
+
+ //Too much slow
+ /*
+ Get_B4 (sample_count, "sample_count");
+ Get_B4 (sample_offset, "sample_offset");
+ */
+
+ //Faster
+ /*
+ if (Element_Offset+8>Element_Size)
+ break; //Problem
+ sample_count =BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset );
+ sample_offset=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset+4);
+ Element_Offset+=8;
+ */
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_sdtp()
+{
+ Element_Name("Sample Dependency");
+
+ //Parsing
+ Skip_XX(Element_Size, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stco()
+{
+ NAME_VERSION_FLAG("Chunk offset");
+
+ int32u Count, Offset;
+ Get_B4 (Count, "Number of entries");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ //Too much slow
+ /*
+ Get_B4 (Offset, "Offset");
+ */
+
+ //Faster
+ if (Element_Offset+4>Element_Size)
+ break; //Problem
+ Offset=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=4;
+
+ if (Pos<300 || MediaInfoLib::Config.ParseSpeed_Get()==1.00)
+ Streams[moov_trak_tkhd_TrackID].stco.push_back(Offset);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stdp()
+{
+ Element_Name("Degradation Priority");
+
+ //Parsing
+ int32u sample_count;
+ Get_B4 (sample_count, "sample-count");
+
+ for (int32u Pos=0; Pos<sample_count; Pos++)
+ {
+ Skip_B2( "priority");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stps()
+{
+ NAME_VERSION_FLAG("Partial Sync Sample");
+
+ //Parsing
+ int32u sample_count;
+ Get_B4 (sample_count, "sample-count");
+
+ int32u Offset=1; //By default, begin at 1
+ for (int32u Pos=0; Pos<sample_count; Pos++)
+ {
+ int32u sample_number;
+
+ //Too much slow
+ Get_B4 (sample_number, "sample-number");
+
+ //Faster
+/*
+ if (Element_Offset+4>Element_Size)
+ break; //Problem
+ sample_number=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=4;
+*/
+
+ if (Streams[moov_trak_tkhd_TrackID].stss.empty() && sample_number==0)
+ Offset=0;
+ Streams[moov_trak_tkhd_TrackID].stss.push_back(sample_number-Offset);
+ }
+
+ //Bit rate mode is based on only 1 frame bit rate computing, not valid for P and B frames
+ //TODO: compute Bit rate mode from stps
+ Clear(StreamKind_Last, StreamPos_Last, "BitRate_Mode");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsc()
+{
+ NAME_VERSION_FLAG("Sample To Chunk");
+
+ //Parsing
+ int32u Count;
+ stream::stsc_struct Stsc;
+ Get_B4 (Count, "Number of entries");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ //Too much slow
+ /*
+ Element_Begin1("Entry", 12);
+ int32u SampleDescriptionId;
+ Get_B4 (Stsc.FirstChunk, "First chunk");
+ Get_B4 (Stsc.SamplesPerChunk, "Samples per chunk");
+ Get_B4 (SampleDescriptionId, "Sample description ID");
+ Element_Info1(Stsc.FirstChunk);
+ Element_Info1(Stsc.SamplesPerChunk);
+ Element_Info1(SampleDescriptionId);
+ Element_End0();
+ Streams[moov_trak_tkhd_TrackID].stsc.push_back(Stsc);
+ */
+
+ //Faster
+ if (Pos<300 || MediaInfoLib::Config.ParseSpeed_Get()==1.00)
+ {
+ if (Element_Offset+12>Element_Size)
+ break; //Problem
+ Stsc.FirstChunk =BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset );
+ Stsc.SamplesPerChunk=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset+4);
+ Element_Offset+=12;
+
+ Streams[moov_trak_tkhd_TrackID].stsc.push_back(Stsc);
+ }
+ else
+ Element_Offset=Element_Size; //No need
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd()
+{
+ NAME_VERSION_FLAG("Sample Description");
+
+ //Parsing
+ Skip_B4( "Count");
+
+ //Filling
+ moov_trak_mdia_minf_stbl_stsd_Pos=0;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_text()
+{
+ Element_Name("Text (Apple)");
+
+ //Parsing
+ int8u TextName_Size;
+ Skip_B4( "Reserved");
+ Skip_B2( "Reserved");
+ Skip_B2( "Data reference index");
+ Info_B4(Flags, "Display flags");
+ Skip_Flags(Flags, 1, "Don't auto scale");
+ Skip_Flags(Flags, 3, "Use movie background color");
+ Skip_Flags(Flags, 5, "Scroll in");
+ Skip_Flags(Flags, 6, "Scroll out");
+ Skip_Flags(Flags, 7, "Horizontal scroll");
+ Skip_Flags(Flags, 8, "Reverse scroll");
+ Skip_Flags(Flags, 9, "Continuous scroll");
+ Skip_Flags(Flags, 12, "Drop shadow");
+ Skip_Flags(Flags, 13, "Anti-alias");
+ Skip_Flags(Flags, 14, "Key text");
+ Skip_B4( "Text justification");
+ Skip_B2( "Background color (Red)");
+ Skip_B2( "Background color (Green)");
+ Skip_B2( "Background color (Blue)");
+ Element_Begin1("Default text box");
+ Skip_B2( "top");
+ Skip_B2( "left");
+ Skip_B2( "bottom");
+ Skip_B2( "right");
+ Element_End0();
+ Skip_B8( "Reserved");
+ Skip_B2( "Font number");
+ Info_B2(FontFace, "Font face");
+ Skip_Flags(FontFace, 0, "Bold");
+ Skip_Flags(FontFace, 1, "Italic");
+ Skip_Flags(FontFace, 2, "Underline");
+ Skip_Flags(FontFace, 3, "Outline");
+ Skip_Flags(FontFace, 4, "Shadow");
+ Skip_Flags(FontFace, 5, "Condense");
+ Skip_Flags(FontFace, 6, "Extend");
+ Skip_B1( "Reserved");
+ Skip_B1( "Reserved"); //Specs say 16-bits, but not in coherency with my test sample
+ Skip_B2( "Foreground color (Red)");
+ Skip_B2( "Foreground color (Green)");
+ Skip_B2( "Foreground color (Blue)");
+ Get_B1 (TextName_Size, "Text name size");
+ Skip_Local(TextName_Size, "Text name");
+
+ FILLING_BEGIN();
+ CodecID_Fill(_T("text"), Stream_Text, StreamPos_Last, InfoCodecID_Format_Mpeg4);
+ Fill(StreamKind_Last, StreamPos_Last, Text_Codec, "text", Unlimited, true, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_tmcd()
+{
+ Element_Name("TimeCode");
+
+ //Parsing
+ stream::timecode *tc=new stream::timecode();
+ int32u TimeCodeFlags;
+ Skip_B4( "Reserved");
+ Skip_B2( "Reserved");
+ Skip_B2( "Data reference index");
+ Skip_B4( "Reserved");
+ Get_B4 (TimeCodeFlags, "Flags (timecode)");
+ Get_Flags (TimeCodeFlags, 0, tc->DropFrame, "Drop frame");
+ Get_Flags (TimeCodeFlags, 1, tc->H24, "24 hour max ");
+ Get_Flags (TimeCodeFlags, 2, tc->NegativeTimes, "Negative times OK");
+ Skip_Flags(TimeCodeFlags, 3, "Counter");
+ Get_B4 (tc->TimeScale, "Time scale");
+ Get_B4 (tc->FrameDuration, "Frame duration");
+ Skip_B1( "Number of frames");
+ if (Element_Size==Element_Offset+3 || (Element_Size>=Element_Offset+7 && Element_Size>=Element_Offset+7+BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset+3)))
+ Skip_B3( "Reserved");
+ else
+ Skip_B1( "Reserved"); //Non-standard but several files are like that
+
+ FILLING_BEGIN();
+ //Bug in one file
+ if (tc->TimeScale==25 && tc->FrameDuration==100)
+ tc->TimeScale=2500;
+
+ //Filling
+ Streams[moov_trak_tkhd_TrackID].TimeCode=tc;
+
+ //Preparing TimeCode parser
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Mpeg4_TimeCode;
+ Open_Buffer_Init(Streams[moov_trak_tkhd_TrackID].Parser);
+ mdat_MustParse=true; //Data is in MDAT
+ mdat_Pos_ToParseInPriority_StreamIDs.push_back(moov_trak_tkhd_TrackID);
+ Streams[moov_trak_tkhd_TrackID].IsPriorityStream=true;
+ ((File_Mpeg4_TimeCode*)Streams[moov_trak_tkhd_TrackID].Parser)->FrameRate=tc->FrameDuration?(((float64)tc->TimeScale)/tc->FrameDuration):0;
+ if (!tc->DropFrame)
+ ((File_Mpeg4_TimeCode*)Streams[moov_trak_tkhd_TrackID].Parser)->FrameRate=(float64)float64_int64s(((File_Mpeg4_TimeCode*)Streams[moov_trak_tkhd_TrackID].Parser)->FrameRate); //If DropFrame flag is not set, must use the integer value of frame rate even if frame rate is not an integral number
+ ((File_Mpeg4_TimeCode*)Streams[moov_trak_tkhd_TrackID].Parser)->NegativeTimes=tc->NegativeTimes;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_tmcd_name()
+{
+ Element_Name("Name (TimeCode)");
+
+ //Parsing
+ Ztring Value;
+ int16u Size, Language;
+ Get_B2(Size, "Size");
+ Get_B2(Language, "Language"); Param_Info1(Language_Get(Language));
+ if (Size)
+ {
+ int8u Junk;
+ Peek_B1(Junk);
+ if (Junk<0x20)
+ {
+ Skip_B1( "Junk");
+ Size--;
+ }
+ }
+ Get_Local(Size, Value, "Value");
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_OriginalSourceMedium, Value);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_tx3g()
+{
+ Element_Name("Text");
+
+ //Parsing
+ Skip_B4( "Reserved");
+ Skip_B2( "Reserved");
+ Skip_B2( "Data reference index");
+ Info_B4(Flags, "displayFlags");
+ Skip_Flags(Flags, 5, "Scroll in");
+ Skip_Flags(Flags, 6, "Scroll out");
+ Skip_Flags(Flags, 7, "Horizontal scroll");
+ Skip_Flags(Flags, 8, "Reverse scroll");
+ Skip_Flags(Flags, 10, "Continuous karaoke");
+ Skip_Flags(Flags, 17, "write text vertically");
+ Skip_Flags(Flags, 18, "fill text region");
+ Skip_B1( "horizontal-justification");
+ Skip_B1( "vertical-justification");
+ Skip_B1( "background-color-rgba (red)");
+ Skip_B1( "background-color-rgba (green)");
+ Skip_B1( "background-color-rgba (blue)");
+ Skip_B1( "background-color-rgba (alpha)");
+ Element_Begin1("default-text-box");
+ if (Element_Size>42 && CC4(Buffer+Buffer_Offset+38)==Elements::moov_trak_mdia_minf_stbl_stsd_tx3g_ftab)
+ {
+ Skip_B1( "top"); //Specs say 16-bits, but not in coherency with a test sample
+ Skip_B1( "left"); //Specs say 16-bits, but not in coherency with a test sample
+ Skip_B1( "bottom"); //Specs say 16-bits, but not in coherency with a test sample
+ Skip_B1( "right"); //Specs say 16-bits, but not in coherency with a test sample
+ }
+ else
+ {
+ Skip_B2( "top");
+ Skip_B2( "left");
+ Skip_B2( "bottom");
+ Skip_B2( "right");
+ }
+ Element_End0();
+ Element_Begin1("default-style");
+ Skip_B2( "startChar");
+ Skip_B2( "endChar");
+ Skip_B2( "font-ID");
+ Skip_B1( "face-style-flags");
+ Skip_B1( "font-size");
+ Skip_B1( "text-color-rgba (red)");
+ Skip_B1( "text-color-rgba (green)");
+ Skip_B1( "text-color-rgba (blue)");
+ Skip_B1( "text-color-rgba (alpha)");
+ Element_End0();
+
+ FILLING_BEGIN();
+ CodecID_Fill(_T("tx3g"), Stream_Text, StreamPos_Last, InfoCodecID_Format_Mpeg4);
+ Fill(StreamKind_Last, StreamPos_Last, Text_Codec, "tx3g", Unlimited, true, true);
+
+ #if MEDIAINFO_DEMUX
+ if (Streams[moov_trak_tkhd_TrackID].Parser==NULL && Config_Demux)
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File__Analyze; //Only for activating Demux
+
+ int64u Elemen_Code_Save=Element_Code;
+ Element_Code=moov_trak_tkhd_TrackID; //Element_Code is use for stream identifier
+ Open_Buffer_Init(Streams[moov_trak_tkhd_TrackID].Parser);
+ Element_Code=Elemen_Code_Save;
+ mdat_MustParse=true; //Data is in MDAT
+ }
+ #endif //MEDIAINFO_DEMUX
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_tx3g_ftab()
+{
+ Element_Name("Font table");
+
+ //Found strange data in one file, but no specs about this
+ if (Element_Size==0x17-8 && (BigEndian2int16u(Buffer+Buffer_Offset)!=1 || BigEndian2int16u(Buffer+Buffer_Offset+4)!=0x17-8-5))
+ {
+ Skip_XX(Element_Size, "Unknown");
+ return;
+ }
+
+ //Parsing
+ int16u entry_count;
+ Get_B2 (entry_count, "entry-count");
+
+ for (int16u Pos=0; Pos<entry_count; Pos++)
+ {
+ int8u FontName_Length;
+ Skip_B2( "font-ID");
+ Get_B1 (FontName_Length, "font-name-length");
+ Skip_Local(FontName_Length, "font-name");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx()
+{
+ //Parsing
+ Skip_B6( "Reserved");
+ Skip_B2( "Data reference index");
+
+ if (StreamKind_Last==Stream_Max)
+ switch (Element_Code)
+ {
+ case Elements::moov_trak_mdia_minf_stbl_stsd_mp4a : Stream_Prepare(Stream_Audio); break;
+ case Elements::moov_trak_mdia_minf_stbl_stsd_mp4v : Stream_Prepare(Stream_Video); break;
+ default : ;
+ }
+
+ switch (StreamKind_Last)
+ {
+ case Stream_Video : moov_trak_mdia_minf_stbl_stsd_xxxxVideo(); break;
+ case Stream_Audio : moov_trak_mdia_minf_stbl_stsd_xxxxSound(); break;
+ case Stream_Text : moov_trak_mdia_minf_stbl_stsd_xxxxText (); break;
+ default :
+ switch (Element_Code)
+ {
+ case Elements::moov_trak_mdia_minf_stbl_stsd_mp4s : moov_trak_mdia_minf_stbl_stsd_xxxxStream(); break;
+ default : Skip_XX(Element_TotalSize_Get(), "Unknown");
+ }
+ }
+
+ FILLING_BEGIN();
+ if (Streams[moov_trak_tkhd_TrackID].Parser && !Retrieve(StreamKind_Last, StreamPos_Last, "Encryption").empty())
+ {
+ Finish(Streams[moov_trak_tkhd_TrackID].Parser);
+ }
+ moov_trak_mdia_minf_stbl_stsd_Pos++;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxxSound()
+{
+ Element_Name("Audio");
+
+ int32u SampleRate, Channels, SampleSize;
+ int16u Version, ID;
+ Get_B2 (Version, "Version");
+ Skip_B2( "Revision level");
+ Skip_C4( "Vendor");
+ if (Version<2) // Version 0 or 1
+ {
+ int16u Channels16, SampleSize16, SampleRate16;
+ Get_B2 (Channels16, "Number of channels");
+ Get_B2 (SampleSize16, "Sample size");
+ Get_B2 (ID, "Compression ID");
+ Skip_B2( "Packet size");
+ Get_B2 (SampleRate16, "Sample rate"); Param_Info2(SampleRate16, " Hz");
+ Skip_B2( "Reserved");
+ if (Version>=1)
+ {
+ Skip_B4( "Samples per packet");
+ Skip_B4( "Bytes per packet");
+ Skip_B4( "Bytes per frame");
+ Skip_B4( "Bytes per sample");
+ }
+ Channels=Channels16;
+ SampleSize=SampleSize16;
+ SampleRate=SampleRate16;
+ }
+ else if (Version==2)
+ {
+ float64 SampleRateF64;
+ Skip_B2( "Reserved (0x0003)");
+ Skip_B2( "Reserved (0x0010)");
+ Skip_B2( "Reserved (0xFFFE)");
+ Skip_B2( "Reserved (0x0000)");
+ Skip_B4( "Reserved (0x00010000)");
+ Skip_B4( "Size of Struct");
+ Get_BF8(SampleRateF64, "Sample rate");
+ Get_B4 (Channels, "Number of channels");
+ Skip_B4( "Reserved (0x7F000000)");
+ Get_B4 (SampleSize, "Sample size");
+ Skip_B4( "Flags");
+ Skip_B4( "Bytes per packet");
+ Skip_B4( "Frames per packet");
+
+ SampleRate=(int32u)SampleRateF64;
+ }
+ else
+ {
+ Skip_XX(Element_Size, "Unknown");
+ return;
+ }
+
+ //Bug found in one file: sample size is 16 with a 24-bit CodecID ("in24")
+ if (Element_Code==0x696E3234 && SampleSize==16)
+ SampleSize=24; //Correcting the header
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ //samr bug viewed in some files: channels and Sampling rate are wrong
+ if (Element_Code==0x73616D72) //"samr"
+ {
+ SampleRate=8000;
+ Channels=1;
+ }
+
+ //lpcm puts "1" in the SampleRate field and Timescale is the real sample size
+ if (Element_Code==0x6C70636D && SampleRate==1) //"lpcm"
+ {
+ SampleRate=Streams[moov_trak_tkhd_TrackID].mdhd_TimeScale;
+ }
+
+ std::string Codec;
+ Codec.append(1, (char)((Element_Code&0xFF000000)>>24));
+ Codec.append(1, (char)((Element_Code&0x00FF0000)>>16));
+ if (Codec!="ms") //Normal
+ {
+ Codec.append(1, (char)((Element_Code&0x0000FF00)>> 8));
+ Codec.append(1, (char)((Element_Code&0x000000FF)>> 0));
+ if (Codec!="mp4a") //mp4a is for Mpeg4 system
+ CodecID_Fill(Ztring(Codec.c_str()), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Mpeg4);
+ if (Codec!="raw ")
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Codec, false, true);
+ else
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, "PCM", Error, false, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec_CC, Codec, false, true);
+ if (Codec=="drms")
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encryption, "iTunes");
+ if (Codec=="enca")
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encryption, "Encrypted");
+ }
+ else //Microsoft 2CC
+ {
+ int64u CodecI= ((Element_Code&0x0000FF00ULL)>> 8)
+ + ((Element_Code&0x000000FFULL)>> 0); //FormatTag
+ Codec=Ztring().From_Number(CodecI, 16).To_Local();
+ CodecID_Fill(Ztring::ToZtring(CodecI, 16), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Codec, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec_CC, Codec, true);
+ }
+ #if defined(MEDIAINFO_AAC_YES)
+ if (Version==2 && Element_Code==Elements::moov_trak_mdia_minf_stbl_stsd_mp4a) //This is not normal, but I don't know where is audioObjectType, default to 2 (AAC LC)
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Aac;
+ ((File_Aac*)Streams[moov_trak_tkhd_TrackID].Parser)->AudioSpecificConfig_OutOfBand(SampleRate, 2);
+ ((File_Aac*)Streams[moov_trak_tkhd_TrackID].Parser)->Mode=File_Aac::Mode_raw_data_block;
+ ((File_Aac*)Streams[moov_trak_tkhd_TrackID].Parser)->FrameIsAlwaysComplete=true;
+ }
+ #endif
+ #if defined(MEDIAINFO_AMR_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Mpeg4, Ztring(Codec.c_str()), InfoCodecID_Format)==_T("AMR"))
+ {
+ //Creating the parser
+ File_Amr MI;
+ MI.Codec=Ztring().From_Local(Codec.c_str());
+ Open_Buffer_Init(&MI);
+
+ //Parsing
+ Open_Buffer_Continue(&MI, 0);
+
+ //Filling
+ Finish(&MI);
+ Merge(MI, StreamKind_Last, 0, StreamPos_Last);
+ }
+ #endif
+ #if defined(MEDIAINFO_ADPCM_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Mpeg4, Ztring(Codec.c_str()), InfoCodecID_Format)==_T("ADPCM"))
+ {
+ //Creating the parser
+ File_Adpcm MI;
+ MI.Codec=Ztring().From_Local(Codec.c_str());
+ Open_Buffer_Init(&MI);
+
+ //Parsing
+ Open_Buffer_Continue(&MI, 0);
+
+ //Filling
+ Finish(&MI);
+ Merge(MI, StreamKind_Last, 0, StreamPos_Last);
+ }
+ #endif
+ #if defined(MEDIAINFO_PCM_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Mpeg4, Ztring(Codec.c_str()), InfoCodecID_Format)==_T("PCM"))
+ {
+ //Info of stream size
+ Streams[moov_trak_tkhd_TrackID].stsz_Sample_Multiplier=Channels*SampleSize/8;
+
+ //Creating the parser
+ File_Pcm MI;
+ MI.Codec=Ztring().From_Local(Codec.c_str());
+ Open_Buffer_Init(&MI);
+
+ //Parsing
+ Open_Buffer_Continue(&MI, 0);
+
+ //Filling
+ Finish(&MI);
+ Merge(MI, StreamKind_Last, 0, StreamPos_Last);
+
+ //Creating the parser
+ if ((Channels==1 && (StreamPos_Last%2)==0)
+ || (Streams.find(moov_trak_tkhd_TrackID-1)!=Streams.end() && Streams[moov_trak_tkhd_TrackID-1].IsPcmMono))
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_ChannelGrouping;
+ if (StreamPos_Last%2)
+ {
+ ((File_ChannelGrouping*)Streams[moov_trak_tkhd_TrackID].Parser)->Channel_Pos=1;
+ ((File_ChannelGrouping*)Streams[moov_trak_tkhd_TrackID].Parser)->Common=((File_ChannelGrouping*)Streams[moov_trak_tkhd_TrackID-1].Parser)->Common;
+ ((File_ChannelGrouping*)Streams[moov_trak_tkhd_TrackID].Parser)->StreamID=moov_trak_tkhd_TrackID-1;
+ Element_Code=moov_trak_tkhd_TrackID-1;
+ }
+ else
+ {
+ ((File_ChannelGrouping*)Streams[moov_trak_tkhd_TrackID].Parser)->Channel_Pos=0;
+ ((File_ChannelGrouping*)Streams[moov_trak_tkhd_TrackID].Parser)->SampleRate=SampleRate;
+ Streams[moov_trak_tkhd_TrackID].IsPcmMono=true;
+ }
+ ((File_ChannelGrouping*)Streams[moov_trak_tkhd_TrackID].Parser)->Channel_Total=2;
+ ((File_ChannelGrouping*)Streams[moov_trak_tkhd_TrackID].Parser)->ByteDepth=3;
+
+ #if MEDIAINFO_DEMUX
+ Streams[moov_trak_tkhd_TrackID].Demux_Level=Config->Demux_Unpacketize_Get()?0:4; //Intermediate
+ #endif //MEDIAINFO_DEMUX
+ }
+ }
+ #endif
+ #if defined(MEDIAINFO_MPEGA_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Mpeg4, Ztring(Codec.c_str()), InfoCodecID_Format)==_T("MPEG Audio"))
+ {
+ //Creating the parser
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Mpega;
+ }
+ #endif
+ if (Element_Code==0x6F776D61) //"owma"
+ {
+ Skip_XX(Element_Size-Element_Offset, "WMA Pro data");
+ }
+
+ #if MEDIAINFO_DEMUX
+ if (Streams[moov_trak_tkhd_TrackID].Parser==NULL && Config_Demux)
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File__Analyze; //Only for activating Demux
+ }
+ #endif //MEDIAINFO_DEMUX
+ if (Streams[moov_trak_tkhd_TrackID].Parser)
+ {
+ int64u Elemen_Code_Save=Element_Code;
+ Element_Code=moov_trak_tkhd_TrackID; //Element_Code is use for stream identifier
+ Open_Buffer_Init(Streams[moov_trak_tkhd_TrackID].Parser);
+ Element_Code=Elemen_Code_Save;
+ mdat_MustParse=true; //Data is in MDAT
+ }
+
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels, 10, true);
+ if (SampleSize!=0 && Element_Code!=0x6D703461 && (Element_Code&0xFFFF0000)!=0x6D730000 && Retrieve(Stream_Audio, StreamPos_Last, Audio_BitDepth).empty()) //if not mp4a, and not ms*
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, SampleSize, 10, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, SampleRate);
+
+ //Sometimes, more Atoms in this atoms
+ if (Element_Offset+8<Element_Size)
+ Element_ThisIsAList();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxxStream()
+{
+ Element_Name("Stream"); //Defined in ISO-IEC 14496-14
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ //Sometimes, more Atoms in this atoms
+ if (Element_Offset+8<Element_Size)
+ Element_ThisIsAList();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxxText()
+{
+ Element_Name("Text");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ Ztring CodecID; CodecID.From_CC4((int32u)Element_Code);
+ CodecID_Fill(CodecID, Stream_Text, StreamPos_Last, InfoCodecID_Format_Mpeg4);
+
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Text, InfoCodecID_Format_Mpeg4, CodecID, InfoCodecID_Format)==_T("EIA-608"))
+ {
+ //Creating the parser
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Mpeg4;
+ }
+ #if defined(MEDIAINFO_CDP_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Text, InfoCodecID_Format_Mpeg4, CodecID, InfoCodecID_Format)==_T("EIA-708"))
+ {
+ //Creating the parser
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Cdp;
+ ((File_Cdp*)Streams[moov_trak_tkhd_TrackID].Parser)->WithAppleHeader=true;
+ ((File_Cdp*)Streams[moov_trak_tkhd_TrackID].Parser)->AspectRatio=((float)16)/9; //TODO: this is hardcoded, must adapt it to the real video aspect ratio
+ }
+ #endif
+ #if MEDIAINFO_DEMUX
+ if (Streams[moov_trak_tkhd_TrackID].Parser==NULL && Config_Demux)
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File__Analyze; //Only for activating Demux
+ }
+ #endif //MEDIAINFO_DEMUX
+ if (Streams[moov_trak_tkhd_TrackID].Parser)
+ {
+ int64u Elemen_Code_Save=Element_Code;
+ Element_Code=moov_trak_tkhd_TrackID; //Element_Code is use for stream identifier
+ Open_Buffer_Init(Streams[moov_trak_tkhd_TrackID].Parser);
+ Element_Code=Elemen_Code_Save;
+ mdat_MustParse=true; //Data is in MDAT
+ }
+
+ //Sometimes, more Atoms in this atoms
+ if (Element_Offset+8<Element_Size)
+ Element_ThisIsAList();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxxVideo()
+{
+ Element_Name("Video");
+
+ int16u Width, Height, ColorTableID;
+ int8u CompressorName_Size;
+ Skip_B2( "Version");
+ Skip_B2( "Revision level");
+ Skip_C4( "Vendor");
+ Skip_B4( "Temporal quality");
+ Skip_B4( "Spatial quality");
+ Get_B2 (Width, "Width");
+ Get_B2 (Height, "Height");
+ Skip_B4( "Horizontal resolution");
+ Skip_B4( "Vertical resolution");
+ Skip_B4( "Data size");
+ Skip_B2( "Frame count");
+ Peek_B1(CompressorName_Size);
+ if (CompressorName_Size<32)
+ {
+ //This is pascal string
+ Skip_B1( "Compressor name size");
+ Skip_Local(CompressorName_Size, "Compressor name");
+ Skip_XX(32-1-CompressorName_Size, "Padding");
+ }
+ else
+ //this is hard-coded 32-byte string
+ Skip_Local(32, "Compressor name");
+ Skip_B2( "Depth");
+ Get_B2 (ColorTableID, "Color table ID");
+ if (ColorTableID==0 && Width && Height) //In one file, if Zero-filled, Color table is not present
+ Skip_XX(32, "Color Table");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ std::string Codec;
+ Codec.append(1, (char)((Element_Code&0xFF000000)>>24));
+ Codec.append(1, (char)((Element_Code&0x00FF0000)>>16));
+ Codec.append(1, (char)((Element_Code&0x0000FF00)>> 8));
+ Codec.append(1, (char)((Element_Code&0x000000FF)>> 0));
+ if (Codec!="mp4v") //mp4v is for Mpeg4 system
+ CodecID_Fill(Ztring(Codec.c_str()), Stream_Video, StreamPos_Last, InfoCodecID_Format_Mpeg4);
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, Codec, false, true);
+ Fill(Stream_Video, StreamPos_Last, Video_Codec_CC, Codec, false, true);
+ if (Codec=="drms")
+ Fill(Stream_Video, StreamPos_Last, Video_Encryption, "iTunes");
+ if (Codec=="encv")
+ Fill(Stream_Video, StreamPos_Last, Video_Encryption, "Encrypted");
+ if (Width)
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Width, 10, true);
+ if (Height)
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Height, 10, true);
+ if (moov_trak_tkhd_DisplayAspectRatio && Height && moov_trak_tkhd_DisplayAspectRatio!=((float32)Width)/Height)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, moov_trak_tkhd_DisplayAspectRatio, 3, true);
+ Fill(Stream_Video, StreamPos_Last, Video_PixelAspectRatio, moov_trak_tkhd_DisplayAspectRatio/Width*Height, 3, true);
+ }
+ Fill(Stream_Video, StreamPos_Last, Video_Rotation, moov_trak_tkhd_Rotation, 3);
+ if (moov_trak_tkhd_Rotation)
+ Fill(Stream_Video, StreamPos_Last, Video_Rotation_String, Ztring::ToZtring(moov_trak_tkhd_Rotation, 0)+_T("\xB0")); //degree sign
+
+ //Specific cases
+ if (Streams[moov_trak_tkhd_TrackID].Parser==NULL)
+ {
+ #if defined(MEDIAINFO_DVDIF_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring(Codec.c_str()), InfoCodecID_Format)==_T("DV"))
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_DvDif;
+ }
+ #endif
+ #if defined(MEDIAINFO_MXF_YES)
+ if (Element_Code==0x6D78336E || Element_Code==0x6D783370 || Element_Code==0x6D78356E || Element_Code==0x6D783570) //mx3n, mx3p, mx5n, mx5p
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_MuxingMode, "MXF");
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Mxf;
+
+ #if MEDIAINFO_DEMUX
+ Streams[moov_trak_tkhd_TrackID].Demux_Level=4; //Intermediate
+ #endif //MEDIAINFO_DEMUX
+ }
+ #endif
+ #if defined(MEDIAINFO_AVC_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==_T("AVC"))
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Avc;
+ ((File_Avc*)Streams[moov_trak_tkhd_TrackID].Parser)->FrameIsAlwaysComplete=true;
+ }
+ #endif
+ #if defined(MEDIAINFO_H263_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==_T("H.263"))
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_H263;
+ ((File_H263*)Streams[moov_trak_tkhd_TrackID].Parser)->FrameIsAlwaysComplete=true;
+ }
+ #endif
+ #if defined(MEDIAINFO_MPEGV_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==_T("MPEG Video") && Element_Code!=0x6D78336E && Element_Code!=0x6D783370 && Element_Code!=0x6D78356E && Element_Code!=0x6D783570) //mx3n, mx3p, mx5n, mx5p
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Mpegv;
+ ((File_Mpegv*)Streams[moov_trak_tkhd_TrackID].Parser)->FrameIsAlwaysComplete=true;
+ }
+ #endif
+ #if defined(MEDIAINFO_VC1_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==_T("VC-1"))
+ {
+ File_Vc1 MI;
+ MI.FrameIsAlwaysComplete=true;
+ Open_Buffer_Init(&MI);
+ Open_Buffer_Continue(&MI);
+ Element_Offset=Element_Size;
+ Finish(&MI);
+ Merge(MI, Stream_Video, 0, StreamPos_Last);
+ }
+ #endif
+ #if defined(MEDIAINFO_VC3_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring().From_CC4((int32u)Element_Code), InfoCodecID_Format)==_T("VC-3"))
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Vc3;
+ }
+ #endif
+ #if defined(MEDIAINFO_JPEG_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring(Codec.c_str()), InfoCodecID_Format)==_T("JPEG"))
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Jpeg;
+ ((File_Jpeg*)Streams[moov_trak_tkhd_TrackID].Parser)->StreamKind=Stream_Video;
+ }
+ #endif
+ #if defined(MEDIAINFO_MPEG4_YES)
+ if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Mpeg4, Ztring(Codec.c_str()), InfoCodecID_Format)==_T("JPEG 2000"))
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Mpeg4;
+
+ #if MEDIAINFO_DEMUX
+ Streams[moov_trak_tkhd_TrackID].Demux_Level=4; //Intermediate
+ #endif //MEDIAINFO_DEMUX
+ }
+ #endif
+
+ #if MEDIAINFO_DEMUX
+ if (Streams[moov_trak_tkhd_TrackID].Parser==NULL && Config_Demux)
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File__Analyze; //Only for activating Demux
+ }
+ #endif //MEDIAINFO_DEMUX
+ if (Streams[moov_trak_tkhd_TrackID].Parser)
+ {
+ int64u Elemen_Code_Save=Element_Code;
+ Element_Code=moov_trak_tkhd_TrackID; //Element_Code is use for stream identifier
+ Open_Buffer_Init(Streams[moov_trak_tkhd_TrackID].Parser);
+ Element_Code=Elemen_Code_Save;
+ mdat_MustParse=true; //Data is in MDAT
+ }
+ }
+
+ //Descriptors or a list (we can see both!)
+ if (Element_Offset+8<=Element_Size
+ && ((CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+0)>='A' && CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+0)<='z') || (CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+0)>='0' && CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+0)<='9'))
+ && ((CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+1)>='A' && CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+1)<='z') || (CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+1)>='0' && CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+1)<='9'))
+ && ((CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+2)>='A' && CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+2)<='z') || (CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+2)>='0' && CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+2)<='9'))
+ && ((CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+3)>='A' && CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+3)<='z') || (CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+3)>='0' && CC1(Buffer+Buffer_Offset+(size_t)Element_Offset+4+3)<='9')))
+ Element_ThisIsAList();
+ else if (Element_Offset<Element_Size)
+ Descriptors();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Source: http://wiki.multimedia.cx/index.php?title=Apple_Lossless_Audio_Coding
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_alac()
+{
+ Element_Name("ALAC");
+
+ //Parsing
+ int32u bitrate, samplerate;
+ int8u sample_size, channels;
+ Skip_B4( "?");
+ Skip_B4( "max sample per frame");
+ Skip_B1( "?");
+ Get_B1 (sample_size, "sample size");
+ Skip_B1( "rice history mult");
+ Skip_B1( "rice initial history");
+ Skip_B1( "rice kmodifier");
+ Get_B1 (channels, "channels");
+ Skip_B1( "?");
+ Skip_B1( "?");
+ Skip_B4( "max coded frame size");
+ Get_B4 (bitrate, "bitrate");
+ Get_B4 (samplerate, "samplerate");
+
+ FILLING_BEGIN_PRECISE();
+ if (sample_size)
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, sample_size, 10, true);
+ if (channels)
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, channels, 10, true);
+ if (bitrate)
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate_Nominal, bitrate, 10, true);
+ if (samplerate)
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, samplerate, 10, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_avcC()
+{
+ Element_Name("AVC decode");
+
+ //Parsing
+ int8u Version;
+ Get_B1 (Version, "Version");
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ {
+ Skip_XX(Element_Size, "Data not analyzed");
+ return; //Handling only the first description
+ }
+ else if (Version==1)
+ {
+ #ifdef MEDIAINFO_AVC_YES
+ if (Streams[moov_trak_tkhd_TrackID].Parser) //Removing any previous parser (in case of multiple streams in one track, or dummy parser for demux)
+ delete Streams[moov_trak_tkhd_TrackID].Parser; //Streams[moov_trak_tkhd_TrackID].Parser=NULL;
+
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Avc;
+ ((File_Avc*)Streams[moov_trak_tkhd_TrackID].Parser)->FrameIsAlwaysComplete=true;
+ #if MEDIAINFO_DEMUX
+ Element_Code=moov_trak_tkhd_TrackID;
+ #endif //MEDIAINFO_DEMUX
+ Open_Buffer_Init(Streams[moov_trak_tkhd_TrackID].Parser);
+ ((File_Avc*)Streams[moov_trak_tkhd_TrackID].Parser)->MustParse_SPS_PPS=true;
+ Streams[moov_trak_tkhd_TrackID].Parser->MustSynchronize=false;
+ mdat_MustParse=true; //Data is in MDAT
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ switch (Config->Demux_InitData_Get())
+ {
+ case 0 : //In demux event
+ Demux_Level=2; //Container
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_Header);
+ break;
+ case 1 : //In field
+ {
+ std::string Data_Raw((const char*)(Buffer+Buffer_Offset), (size_t)Element_Size);
+ std::string Data_Base64(Base64::encode(Data_Raw));
+ Fill(Stream_Video, StreamPos_Last, "Demux_InitBytes", Data_Base64);
+ }
+ break;
+ default : ;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ //Parsing
+ Open_Buffer_Continue(Streams[moov_trak_tkhd_TrackID].Parser);
+
+ ((File_Avc*)Streams[moov_trak_tkhd_TrackID].Parser)->SizedBlocks=true; //Now this is SizeBlocks
+ #else
+ Skip_XX(Element_Size, "AVC Data");
+ #endif
+ }
+ else
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_bitr()
+{
+ Element_Name("BitRate");
+
+ //Parsing
+ int32u Avg_Bitrate, Max_Bitrate;
+ Get_B4 (Avg_Bitrate, "Avg_Bitrate");
+ Get_B4 (Max_Bitrate, "Max_Bitrate");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ if (Avg_Bitrate)
+ Fill(StreamKind_Last, StreamPos_Last, "BitRate", Avg_Bitrate);
+ if (Max_Bitrate)
+ Fill(StreamKind_Last, StreamPos_Last, "BitRate_Maximum", Max_Bitrate);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_btrt()
+{
+ Element_Name("BitRate");
+
+ //Parsing
+ int32u maxBitrate, avgBitrate;
+ Skip_B4( "bufferSizeDB");
+ Get_B4 (maxBitrate, "maxBitrate");
+ Get_B4 (avgBitrate, "avgBitrate");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ //if (avgBitrate)
+ // Fill(StreamKind_Last, StreamPos_Last, "BitRate", avgBitrate); //Not trustable enough, and we have precise bitrate from stream size with
+ if (maxBitrate)
+ Fill(StreamKind_Last, StreamPos_Last, "BitRate_Maximum", maxBitrate);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_chan()
+{
+ NAME_VERSION_FLAG("Channels");
+
+ //Parsing
+ //From http://developer.apple.com/mac/library/documentation/MusicAudio/Reference/CAFSpec/CAF_spec/CAF_spec.html#//apple_ref/doc/uid/TP40001862-CH210-DontLinkElementID_25
+ std::string ChannelDescription_Layout;
+ int32u ChannelLayoutTag, ChannelBitmap, NumberChannelDescriptions, ChannelLabels=0;
+ bool ChannelLabels_Valid=true;
+ Get_B4 (ChannelLayoutTag, "ChannelLayoutTag");
+ Get_B4 (ChannelBitmap, "ChannelBitmap");
+ Get_B4 (NumberChannelDescriptions, "NumberChannelDescriptions");
+ if (ChannelLayoutTag==0) //UseChannelDescriptions
+ {
+ for (int32u Pos=0; Pos<NumberChannelDescriptions; Pos++)
+ {
+ int32u ChannelLabel;
+ Get_B4 (ChannelLabel, "ChannelLabel");
+ if (ChannelLabel<32)
+ ChannelLabels|=(1<<ChannelLabel);
+ else
+ ChannelLabels_Valid=false;
+ ChannelDescription_Layout+=Mpeg4_chan_ChannelDescription_Layout(ChannelLabel);
+ ChannelDescription_Layout+=_T(' ');
+ Skip_B4( "ChannelFlags");
+ Skip_BF4( "Coordinates (0)");
+ Skip_BF4( "Coordinates (1)");
+ Skip_BF4( "Coordinates (2)");
+ }
+ if (!ChannelDescription_Layout.empty())
+ ChannelDescription_Layout.resize(ChannelDescription_Layout.size()-1);
+ }
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ if (ChannelLayoutTag==0) //UseChannelDescriptions
+ {
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, NumberChannelDescriptions, 10, true);
+ if (ChannelLabels_Valid)
+ Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions, Mpeg4_chan_ChannelDescription(ChannelLabels), true, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_ChannelLayout, ChannelDescription_Layout.c_str(), Unlimited, true, true);
+ }
+ else if (ChannelLayoutTag==0x10000) //UseChannelBitmap
+ {
+ int8u Channels=0;
+ for (size_t Bit=0; Bit<18; Bit++)
+ if (ChannelBitmap&(1<<Bit))
+ {
+ Channels++;
+ ChannelDescription_Layout+=Mpeg4_chan_ChannelBitmap_Layout((int32u)(Bit+1));
+ ChannelDescription_Layout+=_T(' ');
+ }
+ if (Channels)
+ {
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels, 10, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions, Mpeg4_chan_ChannelBitmap(ChannelBitmap), true, true);
+ if (!ChannelDescription_Layout.empty())
+ {
+ ChannelDescription_Layout.resize(ChannelDescription_Layout.size()-1);
+ Fill(Stream_Audio, StreamPos_Last, Audio_ChannelLayout, ChannelDescription_Layout.c_str(), Unlimited, true, true);
+ }
+ }
+ }
+ else if (ChannelLayoutTag>0x10000)
+ {
+ int16u Channels=ChannelLayoutTag&0x0000FFFF;
+ int16u Ordering=(ChannelLayoutTag&0xFFFF0000)>>16;
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels, 10, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions, Mpeg4_chan(Ordering), Unlimited, true, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_ChannelLayout, Mpeg4_chan_Layout(Ordering));
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_clap()
+{
+ Element_Name("Clean Aperture");
+
+ //Parsing
+ int32u apertureWidth_N, apertureWidth_D, apertureHeight_N, apertureHeight_D;
+ Get_B4 (apertureWidth_N, "apertureWidth_N");
+ Get_B4 (apertureWidth_D, "apertureWidth_D");
+ Get_B4 (apertureHeight_N, "apertureHeight_N");
+ Get_B4 (apertureHeight_D, "apertureHeight_D");
+ Skip_B4( "horizOff_N");
+ Skip_B4( "horizOff_D");
+ Skip_B4( "vertOff_N");
+ Skip_B4( "vertOff_D");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ Streams[moov_trak_tkhd_TrackID].CleanAperture_Width=((float)apertureWidth_N)/apertureWidth_D;
+ Streams[moov_trak_tkhd_TrackID].CleanAperture_Height=((float)apertureHeight_N)/apertureHeight_D;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_colr()
+{
+ Element_Name("Color Parameter");
+
+ //Parsing
+ int16u colour_primaries, transfer_characteristics, matrix_coefficients;
+ Skip_C4( "Color parameter type");
+ Get_B2 (colour_primaries, "Primaries index"); Param_Info1(Mpeg4_colour_primaries(colour_primaries));
+ Get_B2 (transfer_characteristics, "Transfer function index"); Param_Info1(Mpeg4_transfer_characteristics(transfer_characteristics));
+ Get_B2 (matrix_coefficients, "Matrix index"); Param_Info1(Mpeg4_matrix_coefficients(matrix_coefficients));
+
+ FILLING_BEGIN();
+ Fill(Stream_Video, StreamPos_Last, "colour_primaries", Mpeg4_colour_primaries(colour_primaries));
+ Fill(Stream_Video, StreamPos_Last, "transfer_characteristics", Mpeg4_transfer_characteristics(transfer_characteristics));
+ Fill(Stream_Video, StreamPos_Last, "matrix_coefficients", Mpeg4_matrix_coefficients(matrix_coefficients));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_d263()
+{
+ Element_Name("H263SpecificBox");
+
+ //Parsing
+ int32u Vendor;
+ int8u Version, H263_Level, H263_Profile;
+ Get_C4 (Vendor, "Encoder vendor");
+ Get_B1 (Version, "Encoder version");
+ Get_B1 (H263_Level, "H263_Level");
+ Get_B1 (H263_Profile, "H263_Profile");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ Ztring ProfileLevel;
+ switch (H263_Profile)
+ {
+ case 0x00 : ProfileLevel=_T("BaseLine"); break;
+ default : ProfileLevel.From_Number(H263_Profile);
+ }
+ ProfileLevel+=_T('@');
+ ProfileLevel+=Ztring::ToZtring(((float32)H263_Level)/10, 1);
+ Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, ProfileLevel);
+ Fill(Stream_Video, StreamPos_Last, Video_Encoded_Library_Name, Mpeg4_Vendor(Vendor));
+ Fill(Stream_Video, StreamPos_Last, Video_Encoded_Library_Version, Version);
+ Fill(Stream_Video, StreamPos_Last, Video_Encoded_Library, Retrieve(Stream_Video, StreamPos_Last, Video_Encoded_Library_Name)+_T(' ')+Ztring::ToZtring(Version));
+ Ztring Encoded_Library_String=Retrieve(Stream_Video, StreamPos_Last, Video_Encoded_Library_Name)+(Version?(_T(" Revision ")+Ztring::ToZtring(Version)):Ztring());
+ Fill(Stream_Video, StreamPos_Last, Video_Encoded_Library_String, Encoded_Library_String, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_dac3()
+{
+ Element_Name("AC-3");
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, "", Unlimited, true, true); //Remove the value (is always wrong in the stsd atom)
+
+ //Parsing
+ if (Retrieve(Stream_Audio, StreamPos_Last, Audio_CodecID)==_T("sac3"))
+ {
+ Element_Info1("Nero specific");
+ int8u Version;
+ Get_B1 (Version, "Version");
+ if (Version==1)
+ {
+ int8u bsid;
+ Get_B1 (bsid, "bsid");
+ Skip_XX(Element_Size-Element_Offset, "unknown");
+ #ifdef MEDIAINFO_AC3_YES
+ if (Streams[moov_trak_tkhd_TrackID].Parser==NULL)
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Ac3;
+ Open_Buffer_Init(Streams[moov_trak_tkhd_TrackID].Parser);
+ ((File_Ac3*)Streams[moov_trak_tkhd_TrackID].Parser)->Frame_Count_Valid=2;
+ mdat_MustParse=true; //Data is in MDAT
+ }
+ #else
+ if (bsid<=0x08)
+ Fill(Stream_Audio, StreamKind_Last, Audio_Format, "AC-3");
+ if (bsid>0x0A && bsid<=0x10)
+ Fill(Stream_Audio, StreamKind_Last, Audio_Format, "E-AC-3");
+ #endif
+ return;
+ }
+ else
+ {
+ Skip_XX(Element_Size, "Data");
+ return;
+ }
+ }
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ #ifdef MEDIAINFO_AC3_YES
+ if (Streams[moov_trak_tkhd_TrackID].Parser==NULL)
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Ac3;
+ Open_Buffer_Init(Streams[moov_trak_tkhd_TrackID].Parser);
+ ((File_Ac3*)Streams[moov_trak_tkhd_TrackID].Parser)->Frame_Count_Valid=2;
+ ((File_Ac3*)Streams[moov_trak_tkhd_TrackID].Parser)->MustParse_dac3=true;
+ mdat_MustParse=true; //Data is in MDAT
+
+ //Parsing
+ Open_Buffer_Continue(Streams[moov_trak_tkhd_TrackID].Parser);
+ }
+ #else
+ Skip_XX(Element_Size, "AC-3 Data");
+
+ Fill(Stream_Audio, StreamKind_Last, Audio_Format, "AC-3");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_dec3()
+{
+ Element_Name("E-AC-3");
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, "", Unlimited, true, true); //Remove the value (is always wrong in the stsd atom)
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ {
+ return; //Handling only the first description
+ }
+
+ #ifdef MEDIAINFO_AC3_YES
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ {
+ Skip_XX(Element_Size, "Data not analyzed");
+ return; //Handling only the first description
+ }
+
+ if (Streams[moov_trak_tkhd_TrackID].Parser==NULL)
+ {
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Ac3;
+ Open_Buffer_Init(Streams[moov_trak_tkhd_TrackID].Parser);
+ ((File_Ac3*)Streams[moov_trak_tkhd_TrackID].Parser)->Frame_Count_Valid=2;
+ ((File_Ac3*)Streams[moov_trak_tkhd_TrackID].Parser)->MustParse_dec3=true;
+ mdat_MustParse=true; //Data is in MDAT
+
+ //Parsing
+ Open_Buffer_Continue(Streams[moov_trak_tkhd_TrackID].Parser);
+ }
+ #else
+ Skip_XX(Element_Size, "E-AC-3 Data");
+
+ Fill(Stream_Audio, StreamKind_Last, Audio_Format, "E-AC-3");
+ Fill(Stream_Audio, StreamKind_Last, Audio_Format, "", Unlimited, true, true); //Remove the value (is always wrong in the stsd atom)
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_ddts()
+{
+ //Comments about the new CodecIDs having this atom:
+ //dtsc: DTS Core only
+ //dtse: DTS Express, not having DTS Core
+ //dtsh: DTS Core + DTS Lossless (MA), mixed
+ //dtsl: DTS Lossless (MA), not having DTS Core
+
+ int32u DTSSamplingFrequency, maxBitrate, avgBitrate;
+ int16u ChannelLayout;
+ int8u CoreLayout;
+
+ //Parsing
+ Get_B4 (DTSSamplingFrequency, "DTSSamplingFrequency");
+ Get_B4 (maxBitrate, "maxBitrate");
+ Get_B4 (avgBitrate, "avgBitrate");
+ Skip_B1( "pcmSampleDepth"); // 16 or 24 bits
+ BS_Begin();
+ Skip_S1(2, "FrameDuration"); // 0 = 512, 1 = 1024, 2 = 2048, 3 = 4096
+ Skip_S1(5, "StreamConstruction");
+ Skip_SB( "CoreLFEPresent"); // 0 = none, 1 = LFE exists
+ Get_S1 (6, CoreLayout, "CoreLayout");
+ Skip_S2(14, "CoreSize");
+ Skip_SB( "StereoDownmix"); // 0 = none, 1 = downmix present
+ Skip_S1 (3, "RepresentationType");
+ Get_S2 (16, ChannelLayout, "ChannelLayout");
+ Skip_SB( "MultiAssetFlag"); // 0 = none, 1 = multiple asset
+ Skip_SB( "LBRDurationMod"); // 0 = ignore, 1 = Special LBR duration modifier
+ Skip_S1(6, "reserved");
+ BS_End();
+
+ FILLING_BEGIN();
+ /*
+ //Disabled until we have a sample file
+ if (DTSSamplingFrequency)
+ Fill(StreamKind_Last, StreamPos_Last, Audio_SamplingRate, DTSSamplingFrequency, 10, true); //This is the maximum sampling frequency
+ if (avgBitrate)
+ Fill(StreamKind_Last, StreamPos_Last, Audio_BitRate, avgBitrate);
+ if (maxBitrate)
+ Fill(StreamKind_Last, StreamPos_Last, Audio_BitRate_Maximum, maxBitrate);
+ #if defined(MEDIAINFO_DTS_YES)
+ if (ChannelLayout)
+ {
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, DTS_HD_SpeakerActivityMask(ChannelLayout).c_str());
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, DTS_HD_SpeakerActivityMask2(ChannelLayout).c_str());
+ }
+ if (CoreLayout && CoreLayout<16)
+ {
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, DTS_ChannelPositions[CoreLayout]);
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, DTS_ChannelPositions2[CoreLayout]);
+ }
+ #endif //defined(MEDIAINFO_DTS_YES)
+ */
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_damr()
+{
+ Element_Name("AMR decode config");
+
+ //Parsing
+ int32u Vendor;
+ int8u Version;
+ Get_C4 (Vendor, "Encoder vendor");
+ Get_B1 (Version, "Encoder version");
+ Skip_B2( "Packet modes");
+ Skip_B1( "Number of packet mode changes");
+ Skip_B1( "Samples per packet");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Name, Mpeg4_Vendor(Vendor));
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Version, Version);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library, Retrieve(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Name)+_T(' ')+Ztring::ToZtring(Version));
+ Ztring Encoded_Library_String=Retrieve(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Name)+(Version?(_T(" Revision ")+Ztring::ToZtring(Version)):Ztring());
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_String, Encoded_Library_String, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_esds()
+{
+ NAME_VERSION_FLAG("ES Descriptor");
+ INTEGRITY_VERSION(0);
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ Descriptors();
+ if (Streams[moov_trak_tkhd_TrackID].Parser && !Retrieve(StreamKind_Last, StreamPos_Last, "Encryption").empty())
+ {
+ Finish(Streams[moov_trak_tkhd_TrackID].Parser);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_fiel()
+{
+ //Source: http://developer.apple.com/quicktime/icefloe/dispatch019.html#fiel
+ Element_Name("Field/Frame Information");
+
+ //Parsing
+ int8u fields, detail;
+ Get_B1 (fields, "fields");
+ Get_B1 (detail, "detail");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ switch(fields)
+ {
+ case 0x01 : Fill(Stream_Video, StreamPos_Last, Video_ScanType, "Progressive", Unlimited, true, true); break;
+ case 0x02 : Fill(Stream_Video, StreamPos_Last, Video_ScanType, "Interlaced", Unlimited, true, true);
+ switch(detail)
+ {
+ case 1 : // Split fields, TFF
+ case 9 : // Interleaved fields, TFF
+ Fill(Stream_Video, StreamPos_Last, Video_ScanOrder, "TFF", Unlimited, true, true);
+ break;
+ case 6 : // Split fields, BFF
+ case 14 : // Interleaved fields, BFF
+ Fill(Stream_Video, StreamPos_Last, Video_ScanOrder, "BFF", Unlimited, true, true);
+ break;
+ default : ;
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_glbl()
+{
+ Element_Name("Global");
+
+ if (Retrieve(Stream_Video, StreamPos_Last, Video_MuxingMode)==_T("MXF"))
+ {
+ Clear(Stream_Video, StreamPos_Last, Video_MuxingMode);
+ delete Streams[moov_trak_tkhd_TrackID].Parser;
+ #if defined(MEDIAINFO_MPEGV_YES)
+ Streams[moov_trak_tkhd_TrackID].Parser=new File_Mpegv;
+ #else //defined(MEDIAINFO_MPEGV_YES)
+ Streams[moov_trak_tkhd_TrackID].Parser=NULL;
+ #endif //defined(MEDIAINFO_MPEGV_YES)
+
+ //Re-init
+ if (Streams[moov_trak_tkhd_TrackID].Parser)
+ {
+ int64u Elemen_Code_Save=Element_Code;
+ Element_Code=moov_trak_tkhd_TrackID; //Element_Code is use for stream identifier
+ Open_Buffer_Init(Streams[moov_trak_tkhd_TrackID].Parser);
+ Element_Code=Elemen_Code_Save;
+ mdat_MustParse=true; //Data is in MDAT
+ }
+ }
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ //Parsing
+ Open_Buffer_Continue(Streams[moov_trak_tkhd_TrackID].Parser);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_idfm()
+{
+ Element_Name("Description");
+
+ Info_C4(Description, "Description"); Param_Info1(Mpeg4_Description(Description));
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_pasp()
+{
+ Element_Name("Pixel Aspect Ratio");
+
+ //Parsing
+ int32u hSpacing, vSpacing;
+ Get_B4 (hSpacing, "hSpacing");
+ Get_B4 (vSpacing, "vSpacing");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ if (vSpacing)
+ {
+ float32 PixelAspectRatio=(float32)hSpacing/vSpacing;
+ Clear(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio);
+ Fill(Stream_Video, StreamPos_Last, Video_PixelAspectRatio, PixelAspectRatio, 3, true);
+ Streams[moov_trak_tkhd_TrackID].CleanAperture_PixelAspectRatio=PixelAspectRatio; //This is the PAR of the clean aperture
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_sinf()
+{
+ Element_Name("Protection scheme information box");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_frma()
+{
+ Element_Name("Original format box");
+
+ //Parsing
+ std::string Codec;
+ Get_String(4, Codec, "data_format");
+
+ FILLING_BEGIN();
+ CodecID_Fill(Ztring(Codec.c_str()), Stream_Video, StreamPos_Last, InfoCodecID_Format_Mpeg4);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_imif()
+{
+ NAME_VERSION_FLAG("IPMP Information box");
+
+ //Parsing
+ Descriptors();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_schi()
+{
+ Element_Name("scheme information box");
+
+ //Parsing
+ Skip_XX(Element_Size, "scheme_specific_data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_sinf_schm()
+{
+ NAME_VERSION_FLAG("scheme type box");
+
+ //Parsing
+ Skip_C4( "scheme_type");
+ Skip_B4( "scheme_version");
+ if (Flags&0x000001)
+ Skip_UTF8(Element_Size-Element_Offset, "scheme_uri");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_wave()
+{
+ Element_Name("Wave");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_wave_acbf()
+{
+ Element_Name("Audio Bitrate Control Mode");
+
+ //Parsing
+ Skip_B4( "Bit Rate Control Mode");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_wave_enda()
+{
+ //Parsing
+ int16u Endianness;
+ Get_B2 (Endianness, "Endianness");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ if (Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("PCM"))
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Settings_Endianness, Endianness?"Little":"Big", Unlimited, true, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_wave_frma()
+{
+ Element_Name("Data format");
+
+ //Parsing
+ int16u Codec_Peek;
+ Peek_B2(Codec_Peek);
+ if (Codec_Peek==0x6D73) //"ms", Microsoft 2CC
+ {
+ int16u CodecMS;
+ Skip_C2( "Codec_MS");
+ Get_B2 (CodecMS, "CC2");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ CodecID_Fill(Ztring::ToZtring(CodecMS, 16), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, CodecMS, 16, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec_CC, CodecMS, 16, true);
+ FILLING_END();
+ }
+ else
+ {
+ int32u Codec;
+ Get_C4(Codec, "Codec");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ FILLING_BEGIN();
+ if (Codec!=0x6D703461) //"mp4a"
+ CodecID_Fill(Ztring().From_CC4(Codec), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Mpeg4);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Ztring().From_CC4(Codec), true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec_CC, Ztring().From_CC4(Codec), true);
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_wave_samr()
+{
+ Element_Name("AMR decode config");
+
+ //Parsing
+ int32u Vendor;
+ int8u Version;
+ Get_C4 (Vendor, "Encoder vendor");
+ Get_B1 (Version, "Encoder version");
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+
+ if (moov_trak_mdia_minf_stbl_stsd_Pos>1)
+ return; //Handling only the first description
+
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Name, Mpeg4_Vendor(Vendor));
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Version, Version);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library, Retrieve(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Name)+_T(' ')+Ztring::ToZtring(Version));
+ Ztring Encoded_Library_String=Retrieve(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_Name)+(Version?(_T("Revision")+Ztring::ToZtring(Version)):Ztring());
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encoded_Library_String, Encoded_Library_String, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_wave_srcq()
+{
+ Element_Name("Source Quality");
+
+ //Parsing
+ Skip_B4( "Source Quality");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsd_xxxx_wave_xxxx()
+{
+ if ((Element_Code&0x6D730000)!=0x6D730000)
+ return; //Only msxx format is known
+
+ Element_Name("Microsoft Audio");
+
+ //Parsing
+ int32u SamplesPerSec, AvgBytesPerSec;
+ int16u FormatTag, Channels, BitsPerSample;
+ Get_L2 (FormatTag, "FormatTag");
+ Get_L2 (Channels, "Channels");
+ Get_L4 (SamplesPerSec, "SamplesPerSec");
+ Get_L4 (AvgBytesPerSec, "AvgBytesPerSec");
+ Skip_L2( "BlockAlign");
+ Get_L2 (BitsPerSample, "BitsPerSample");
+
+ FILLING_BEGIN();
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels!=5?Channels:6, 10, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, SamplesPerSec, 10, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate_Nominal, AvgBytesPerSec*8, 10, true);
+ FILLING_END();
+
+ //Options
+ if (Element_Offset+2>Element_Size)
+ return; //No options
+
+ //Parsing
+ int16u Option_Size;
+ Get_L2 (Option_Size, "cbSize");
+
+ //Filling
+ if (Option_Size>0)
+ {
+ Skip_XX(Option_Size, "Unknown");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsh()
+{
+ Element_Name("Shadow Sync Sample");
+
+ //Parsing
+ int32u entry_count;
+ Get_B4 (entry_count, "entry-count");
+
+ for (int32u Pos=0; Pos<entry_count; Pos++)
+ {
+ Skip_B4( "shadowed-sample-number");
+ Skip_B4( "sync-sample-number");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stss()
+{
+ NAME_VERSION_FLAG("Sync Sample");
+
+ Streams[moov_trak_tkhd_TrackID].stss.clear();
+
+ //Parsing
+ int32u entry_count;
+ Get_B4 (entry_count, "entry-count");
+
+ int32u Offset=1; //By default, begin at 1
+ for (int32u Pos=0; Pos<entry_count; Pos++)
+ {
+ int32u sample_number;
+
+ //Too much slow
+ Get_B4 (sample_number, "sample-number");
+
+/*
+ //Faster
+ if (Element_Offset+4>Element_Size)
+ break; //Problem
+ sample_number=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset);
+ Element_Offset+=4;
+*/
+
+ if (Streams[moov_trak_tkhd_TrackID].stss.empty() && sample_number==0)
+ Offset=0;
+ Streams[moov_trak_tkhd_TrackID].stss.push_back(sample_number-Offset);
+ }
+
+ //Bit rate mode is based on only 1 frame bit rate computing, not valid for P and B frames
+ //TODO: compute Bit rate mode from stss
+ Clear(StreamKind_Last, StreamPos_Last, "BitRate_Mode");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stsz()
+{
+ NAME_VERSION_FLAG("Sample Size")
+
+ Stream=Streams.find(moov_trak_tkhd_TrackID);
+ int32u Sample_Size, Sample_Count;
+ int8u FieldSize;
+ if (Element_Code==Elements::moov_trak_mdia_minf_stbl_stsz)
+ {
+ Get_B4 (Sample_Size, "Sample Size");
+ FieldSize=32;
+ }
+ else
+ {
+ Skip_B3( "Reserved");
+ Get_B1 (FieldSize, "Field size");
+ Sample_Size=0;
+ }
+ Get_B4 (Sample_Count, "Number of entries");
+
+ if (Sample_Size>0)
+ {
+ //Detecting wrong stream size with some PCM streams
+ if (StreamKind_Last==Stream_Audio)
+ {
+ const Ztring &Codec=Retrieve(Stream_Audio, StreamPos_Last, Audio_CodecID);
+ if (Codec==_T("raw ")
+ || MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Mpeg4, Codec).find(_T("PCM"))==0
+ || MediaInfoLib::Config.Codec_Get(Codec, InfoCodec_KindofCodec).find(_T("PCM"))==0)
+ {
+ int64u Duration=Retrieve(StreamKind_Last, StreamPos_Last, Audio_Duration).To_int64u();
+ int64u Resolution=Retrieve(StreamKind_Last, StreamPos_Last, Audio_BitDepth).To_int64u();
+ int64u SamplingRate=Retrieve(StreamKind_Last, StreamPos_Last, Audio_SamplingRate).To_int64u();
+ int64u Channels=Retrieve(StreamKind_Last, StreamPos_Last, Audio_Channel_s_).To_int64u();
+ int64u Stream_Size_Theory=Duration*Resolution*SamplingRate*Channels/8/1000;
+ int64u Stream_Size_Real=Sample_Size; Stream_Size_Real*=Sample_Count;
+ for (int64u Multiplier=1; Multiplier<=32; Multiplier++)
+ if (Stream_Size_Real*Multiplier>Stream_Size_Theory*0.995 && Stream_Size_Real*Multiplier<Stream_Size_Theory*1.005)
+ {
+ Streams[moov_trak_tkhd_TrackID].stsz_Sample_Multiplier=Multiplier;
+ break;
+ }
+ }
+ }
+
+ Stream->second.stsz_StreamSize=Sample_Size; Stream->second.stsz_StreamSize*=Sample_Count;
+ if (Sample_Size==1)
+ Stream->second.stsz_StreamSize*=Streams[moov_trak_tkhd_TrackID].stsz_Sample_Multiplier;
+ else
+ Stream->second.stsz_Sample_Multiplier=1; //Sampe_Size is correct, no need of stsz_Sample_Multiplier
+
+ Stream->second.stsz_Sample_Size=Sample_Size;
+ Stream->second.stsz_Sample_Count=Sample_Count;
+
+ if (Sample_Count>1 && Retrieve(StreamKind_Last, StreamPos_Last, "BitRate_Mode").empty())
+ Fill(StreamKind_Last, StreamPos_Last, "BitRate_Mode", "CBR");
+
+ }
+ else
+ {
+ int32u Size;
+ int32u Size_Min=(int32u)-1, Size_Max=0;
+ /*
+ if (FieldSize==4)
+ BS_Begin(); //Too much slow
+ */
+ for (int32u Pos=0; Pos<Sample_Count; Pos++)
+ {
+ //Too much slow
+ /*
+ switch(FieldSize)
+ {
+ case 4 : Get_S4 (4, Size, "Size"); break;
+ case 8 : {int8u Size1; Get_B1 (Size1, "Size"); Size=Size1;} break;
+ case 16 : {int16u Size2; Get_B2 (Size2, "Size"); Size=Size2;} break;
+ case 32 : {int32u Size4; Get_B4 (Size4, "Size"); Size=Size4;} break;
+ default : return;
+ }
+ */
+
+ //Faster
+ if (Element_Offset+4>Element_Size)
+ break; //Problem
+ switch(FieldSize)
+ {
+ case 4 : if (Sample_Count%2)
+ Size=Buffer[Buffer_Offset+(size_t)Element_Offset]&0x0F;
+ else
+ {
+ Size=Buffer[Buffer_Offset+(size_t)Element_Offset]>>4;
+ Element_Offset++;
+ }
+ break;
+ case 8 : Size=BigEndian2int8u (Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset++; break;
+ case 16 : Size=BigEndian2int16u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset+=2; break;
+ case 32 : Size=BigEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset); Element_Offset+=4; break;
+ default : return;
+ }
+
+ Stream->second.stsz_StreamSize+=Size;
+ Stream->second.stsz_Total.push_back(Size);
+ if (Size<Size_Min)
+ Size_Min=Size;
+ if (Size>Size_Max)
+ Size_Max=Size;
+ if (Pos<300 || MediaInfoLib::Config.ParseSpeed_Get()==1.00)
+ Stream->second.stsz.push_back(Size);
+ }
+ /*
+ if (FieldSize==4)
+ BS_End(); //Too much slow
+ */
+
+ if (Stream->second.stss.empty() && Retrieve(StreamKind_Last, StreamPos_Last, "BitRate_Mode").empty())
+ {
+ if (Size_Min*(1.005+0.005)<Size_Max)
+ Fill(StreamKind_Last, StreamPos_Last, "BitRate_Mode", "VBR");
+ else
+ Fill(StreamKind_Last, StreamPos_Last, "BitRate_Mode", "CBR");
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stts()
+{
+ NAME_VERSION_FLAG("Time to Sample");
+
+ //Parsing
+ int32u NumberOfEntries;
+ Get_B4(NumberOfEntries, "Number of entries");
+
+ Stream=Streams.find(moov_trak_tkhd_TrackID);
+ Stream->second.stts_Min=(int32u)-1;
+ Stream->second.stts_Max=0;
+ Stream->second.stts_FrameCount=0;
+ #ifdef MEDIAINFO_DVDIF_ANALYZE_YES
+ std::map<int32u, int64u> Duration_FrameCount; //key is duration
+ int64u Duration_FrameCount_Max=0;
+ int32u Duration_FrameCount_Max_Duration=0;
+ if (StreamKind_Last==Stream_Video && Retrieve(Stream_Video, StreamPos_Last, "Format")==_T("DV") && Streams[moov_trak_tkhd_TrackID].Parser && ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parser)->Mpeg4_stts==NULL)
+ ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parser)->Mpeg4_stts=new File_DvDif::stts;
+ #endif //MEDIAINFO_DVDIF_ANALYZE_YES
+
+ #if MEDIAINFO_DEMUX
+ Streams[moov_trak_tkhd_TrackID].stts_Durations.clear();
+ #endif //MEDIAINFO_DEMUX
+
+ for (int32u Pos=0; Pos<NumberOfEntries; Pos++)
+ {
+ int32u SampleCount, SampleDuration;
+ Get_B4(SampleCount, "Sample Count");
+ Get_B4(SampleDuration, "Sample Duration");
+
+ moov_trak_mdia_minf_stbl_stts_Common(SampleCount, SampleDuration, Pos, NumberOfEntries);
+
+ #ifdef MEDIAINFO_DVDIF_ANALYZE_YES
+ if (StreamKind_Last==Stream_Video && Retrieve(Stream_Video, StreamPos_Last, "Format")==_T("DV"))
+ {
+ File_DvDif::stts_part DV_stts_Part;
+ DV_stts_Part.Pos_Begin=Stream->second.stts_FrameCount-SampleCount;
+ DV_stts_Part.Pos_End=Stream->second.stts_FrameCount;
+ DV_stts_Part.Duration=SampleDuration;
+ ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parser)->Mpeg4_stts->push_back(DV_stts_Part);
+
+ Duration_FrameCount[SampleDuration]+=Stream->second.stts_FrameCount;
+ if (Duration_FrameCount_Max<=Duration_FrameCount[SampleDuration])
+ {
+ Duration_FrameCount_Max=Duration_FrameCount[SampleDuration];
+ Duration_FrameCount_Max_Duration=SampleDuration;
+ }
+ }
+ #endif //MEDIAINFO_DVDIF_ANALYZE_YES
+ }
+
+ FILLING_BEGIN();
+ if (StreamKind_Last==Stream_Video)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_FrameCount, Stream->second.stts_FrameCount);
+
+ #ifdef MEDIAINFO_DVDIF_ANALYZE_YES
+ if (StreamKind_Last==Stream_Video && Retrieve(Stream_Video, StreamPos_Last, "Format")==_T("DV"))
+ {
+ //Clean up the "normal" value
+ for (size_t Pos=0; Pos<((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parser)->Mpeg4_stts->size(); Pos++)
+ {
+ if (((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parser)->Mpeg4_stts->at(Pos).Duration==Duration_FrameCount_Max_Duration)
+ {
+ ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parser)->Mpeg4_stts->erase(((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parser)->Mpeg4_stts->begin()+Pos);
+ Pos--;
+ }
+ }
+
+ if (((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parser)->Mpeg4_stts->empty())
+ {delete ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parser)->Mpeg4_stts; ((File_DvDif*)Streams[moov_trak_tkhd_TrackID].Parser)->Mpeg4_stts=NULL;}
+ }
+ #endif //MEDIAINFO_DVDIF_ANALYZE_YES
+ }
+ FILLING_END();
+}
+
+void File_Mpeg4::moov_trak_mdia_minf_stbl_stts_Common(int32u SampleCount, int32u SampleDuration, int32u Pos, int32u NumberOfEntries)
+{
+ FILLING_BEGIN();
+ stream::stts_struct Stts;
+ Stts.SampleCount=SampleCount;
+ Stts.SampleDuration=SampleDuration;
+ Stream->second.stts.push_back(Stts);
+ if (Pos==1 && NumberOfEntries>=2 && NumberOfEntries<=3 && Stream->second.stts_FrameCount==1 && Stts.SampleDuration!=Stream->second.stts_Max && Stream->second.mdhd_TimeScale)
+ {
+ Stream->second.stts_Duration_FirstFrame=Stream->second.stts[0].SampleDuration;
+ Stream->second.stts_Min=Stts.SampleDuration;
+ Stream->second.stts_Max=Stts.SampleDuration;
+ }
+ if (NumberOfEntries>=2 && NumberOfEntries<=3 && Pos+1==NumberOfEntries && Stts.SampleCount==1 && Stream->second.stts_Min==Stream->second.stts_Max && Stts.SampleDuration!=Stream->second.stts_Max && Stream->second.mdhd_TimeScale)
+ {
+ Stream->second.stts_Duration_LastFrame=Stts.SampleDuration;
+ }
+ else
+ {
+ if (Stts.SampleDuration<Stream->second.stts_Min) Stream->second.stts_Min=Stts.SampleDuration;
+ if (Stts.SampleDuration>Stream->second.stts_Max) Stream->second.stts_Max=Stts.SampleDuration;
+ }
+ Stream->second.stts_FrameCount+=Stts.SampleCount;
+ Stream->second.stts_Duration+=Stts.SampleCount*Stts.SampleDuration;
+
+ #if MEDIAINFO_DEMUX
+ stream::stts_duration stts_Duration;
+ stts_Duration.Pos_Begin=Stream->second.stts_FrameCount-Stts.SampleCount;
+ stts_Duration.Pos_End=Stream->second.stts_FrameCount;
+ stts_Duration.SampleDuration=Stts.SampleDuration;
+ if (Streams[moov_trak_tkhd_TrackID].stts_Durations.empty())
+ stts_Duration.DTS_Begin=0;
+ else
+ {
+ stream::stts_durations::iterator Previous=Streams[moov_trak_tkhd_TrackID].stts_Durations.end(); Previous--;
+ stts_Duration.DTS_Begin=Previous->DTS_End;
+ }
+ stts_Duration.DTS_End=stts_Duration.DTS_Begin+Stts.SampleCount*Stts.SampleDuration;
+ Streams[moov_trak_tkhd_TrackID].stts_Durations.push_back(stts_Duration);
+ #endif //MEDIAINFO_DEMUX
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tapt()
+{
+ Element_Name("Aperture Mode Dimensions");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tapt_clef()
+{
+ NAME_VERSION_FLAG("Clean Aperture Dimensions");
+
+ //Parsing
+ Skip_B4( "cleanApertureWidth"); //BFP4, but how many bits?
+ Skip_B4( "cleanApertureHeight"); //BFP4, but how many bits?
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tapt_prof()
+{
+ NAME_VERSION_FLAG("Production Aperture Dimensions");
+
+ //Parsing
+ Skip_B4( "productionApertureWidth"); //BFP4, but how many bits?
+ Skip_B4( "productionApertureHeight"); //BFP4, but how many bits?
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tapt_enof()
+{
+ NAME_VERSION_FLAG("Encoded Pixels Dimensions");
+
+ //Parsing
+ Skip_B4( "encodedApertureWidth"); //BFP4, but how many bits?
+ Skip_B4( "encodedApertureHeight"); //BFP4, but how many bits?
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tkhd()
+{
+ NAME_VERSION_FLAG("Track Header")
+
+ //Parsing
+ Ztring Date_Created, Date_Modified;
+ float32 a, b, u, c, d, v, x, y, w;
+ int64u Duration;
+ int16u Volume;
+ Skip_Flags(Flags, 0, "Track Enabled");
+ Skip_Flags(Flags, 1, "Track in Movie");
+ Skip_Flags(Flags, 2, "Track in Preview");
+ Skip_Flags(Flags, 3, "Track in Poster");
+ Get_DATE1904_DEPENDOFVERSION(Date_Created, "Creation time");
+ Get_DATE1904_DEPENDOFVERSION(Date_Modified, "Modification time");
+ Get_B4 (moov_trak_tkhd_TrackID, "Track ID"); Element_Info1(moov_trak_tkhd_TrackID);
+ Skip_B4( "Reserved");
+ Get_B_DEPENDOFVERSION(Duration, "Duration"); Param_Info2(Duration*1000/TimeScale, " ms"); Element_Info2(Duration*1000/TimeScale, " ms");
+ Skip_B4( "Reserved");
+ Skip_B4( "Reserved");
+ Skip_B2( "Layer");
+ Skip_B2( "Alternate group");
+ Get_B2 (Volume, "Volume"); Param_Info1(Ztring::ToZtring(((float)Volume)/256));
+ Skip_B2( "Reserved");
+ Element_Begin1("Matrix structure");
+ Get_BFP4(16, a, "a (width scale)");
+ Get_BFP4(16, b, "b (width rotate)");
+ Get_BFP4( 2, u, "u (width angle)");
+ Get_BFP4(16, c, "c (height rotate)");
+ Get_BFP4(16, d, "d (height scale)");
+ Get_BFP4( 2, v, "v (height angle)");
+ Get_BFP4(16, x, "x (position left)");
+ Get_BFP4(16, y, "y (position top)");
+ Get_BFP4( 2, w, "w (divider)");
+ Element_End0();
+ Get_BFP4(16, moov_trak_tkhd_Width, "Track width");
+ Get_BFP4(16, moov_trak_tkhd_Height, "Track height");
+
+ FILLING_BEGIN();
+ //Case of header is after main part
+ std::map<int32u, stream>::iterator Temp=Streams.find((int32u)-1);
+ if (Temp!=Streams.end())
+ {
+ Streams[moov_trak_tkhd_TrackID]=Temp->second;
+ Temp->second.Parser=NULL; //It is a copy, we don't want that the destructor deletes the Parser
+ Streams.erase(Temp);
+ }
+
+ Fill(StreamKind_Last, StreamPos_Last, "Duration", float64_int64s(((float64)Duration)*1000/TimeScale));
+ Fill(StreamKind_Last, StreamPos_Last, "Encoded_Date", Date_Created);
+ Fill(StreamKind_Last, StreamPos_Last, "Tagged_Date", Date_Modified);
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, moov_trak_tkhd_TrackID, 10, true);
+ Streams[moov_trak_tkhd_TrackID].tkhd_Duration=Duration;
+ if (moov_trak_tkhd_Height*d)
+ moov_trak_tkhd_DisplayAspectRatio=(moov_trak_tkhd_Width*a)/(moov_trak_tkhd_Height*d);
+ moov_trak_tkhd_Rotation=(float32)(std::atan2(b, a)*180.0/3.14159);
+ if (moov_trak_tkhd_Rotation<0)
+ moov_trak_tkhd_Rotation+=360;
+
+ #if MEDIAINFO_EVENTS
+ if (StreamIDs_Size>1 && Config->File_ID_OnlyRoot_Get())
+ StreamIDs_Width[StreamIDs_Size-1]=Streams.size()<=1?0:8; //If referenced file and more than 1 stream, referenced ID is discarded, else referenced ID is used
+ #endif //MEDIAINFO_EVENTS
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tref()
+{
+ Element_Name("Track Reference");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tref_dpnd()
+{
+ Element_Name("MPEG-4 dependency");
+
+ //Parsing
+ while (Element_Offset<Element_Size)
+ Skip_B4( "track-ID");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tref_ipir()
+{
+ Element_Name("IPI declarations");
+
+ //Parsing
+ while (Element_Offset<Element_Size)
+ Skip_B4( "track-ID");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tref_hint()
+{
+ Element_Name("original media");
+
+ //Parsing
+ while (Element_Offset<Element_Size)
+ Skip_B4( "track-ID");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tref_mpod()
+{
+ Element_Name("included elementary stream");
+
+ //Parsing
+ while (Element_Offset<Element_Size)
+ Skip_B4( "track-ID");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tref_ssrc()
+{
+ Element_Name("non-primary source (used in other track)");
+
+ //Parsing
+ while (Element_Offset<Element_Size)
+ Skip_B4( "track-ID");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tref_sync()
+{
+ Element_Name("synchronization source");
+
+ //Parsing
+ while (Element_Offset<Element_Size)
+ Skip_B4( "track-ID");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_trak_tref_tmcd()
+{
+ Element_Name("TimeCode");
+
+ //Parsing
+ int32u TrackID;
+ Get_B4(TrackID, "track-ID");
+
+ FILLING_BEGIN();
+ Streams[moov_trak_tkhd_TrackID].TimeCode_TrackID=TrackID;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta()
+{
+ Element_Name("User Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_AllF()
+{
+ Element_Name("AllF");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_chpl()
+{
+ Element_Name("Chapters");
+
+ //Parsing
+ Ztring Value;
+ std::string ValueS;
+ int64u Time;
+ int8u Size;
+ size_t Pos=0;
+ Stream_Prepare(Stream_Menu);
+ Skip_B8( "Unknown");
+ Skip_B1( "Chapter Count");
+ Fill(Stream_Menu, StreamPos_Last, Menu_Chapters_Pos_Begin, Count_Get(Stream_Menu, StreamPos_Last), 10, true);
+ while (Element_Offset<Element_Size)
+ {
+ Get_B8 (Time, "Time");
+ Get_B1 (Size, "Text size");
+ Get_String(Size, ValueS, "Value");
+ Value.From_UTF8(ValueS.c_str());
+ if (Value.empty())
+ Value.From_Local(ValueS.c_str()); //Trying Local...
+
+ FILLING_BEGIN();
+ Fill(Stream_Menu, StreamPos_Last, Ztring().Duration_From_Milliseconds(Time/10000).To_Local().c_str(), Value);
+ FILLING_END();
+
+ //Next
+ Pos++;
+ }
+ Fill(Stream_Menu, StreamPos_Last, Menu_Chapters_Pos_End, Count_Get(Stream_Menu, StreamPos_Last), 10, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_clsf()
+{
+ NAME_VERSION_FLAG("Classification"); //3GP
+
+ //Parsing
+ Ztring ClassificationInfo;
+ int32u ClassificationEntity;
+ int16u Language, ClassificationTable;
+ Get_C4(ClassificationEntity, "ClassificationEntity");
+ Get_C2(ClassificationTable, "ClassificationTable");
+ Get_B2(Language, "Language");
+ bool Utf8=true;
+ if (Element_Offset+2<=Element_Size)
+ {
+ int16u Utf16;
+ Peek_B2(Utf16);
+ if (Utf16==0xFEFF)
+ Utf8=false;
+ }
+ if (Utf8)
+ Get_UTF8(Element_Size-Element_Offset, ClassificationInfo, "ClassificationInfo");
+ else
+ Get_UTF16(Element_Size-Element_Offset, ClassificationInfo, "ClassificationInfo");
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, "Classification", Ztring().From_CC4(ClassificationTable));
+ Fill(Stream_General, 0, "Classification_Reason", ClassificationInfo);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_DcMD()
+{
+ Element_Name("Kodak MetaData");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_DcMD_Cmbo()
+{
+ Element_Name("Camera byte order");
+
+ //Parsing
+ Skip_C2( "EXIF byte order");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_DcMD_DcME()
+{
+ Element_Name("DcME?");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_DcMD_DcME_Keyw()
+{
+ Element_Name("Keywords?");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_DcMD_DcME_Mtmd()
+{
+ Element_Name("Metadata?");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_DcMD_DcME_Rate()
+{
+ Element_Name("Rate?");
+
+ //Parsing
+ Skip_B2( "Zero");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_FIEL()
+{
+ Element_Name("FIEL?");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_FXTC()
+{
+ Element_Name("Adobe After Effects?");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_hinf()
+{
+ Element_Name("Hint Format");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_hinv()
+{
+ Element_Name("Hint Version");
+
+ //Parsing
+ Skip_Local(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_hnti()
+{
+ Element_Name("Hint Info");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_hnti_rtp()
+{
+ Element_Name("Real Time");
+
+ //Parsing
+ Skip_Local(Element_Size, "Value");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_ID32()
+{
+ NAME_VERSION_FLAG("ID3v2"); //3GP
+
+ //Parsing
+ int16u Language;
+ Get_B2(Language, "Language");
+ Skip_XX(Element_Size-Element_Offset, "ID3v2data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_kywd()
+{
+ NAME_VERSION_FLAG("Keywords"); //3GP
+
+ //Parsing
+ int16u Language;
+ int8u KeywordCnt;
+ Get_B2(Language, "Language");
+ Get_B1(KeywordCnt, "KeywordCnt");
+ for (int8u Pos=0; Pos<KeywordCnt; Pos++)
+ {
+ Ztring KeywordInfo;
+ int8u KeywordSize;
+ Get_B1(KeywordSize, "KeywordSize");
+ bool Utf8=true;
+ if (Element_Offset+2<=Element_Size)
+ {
+ int16u Utf16;
+ Peek_B2(Utf16);
+ if (Utf16==0xFEFF)
+ Utf8=false;
+ }
+ if (Utf8)
+ Get_UTF8(KeywordSize, KeywordInfo, "KeywordInfo");
+ else
+ Get_UTF16(KeywordSize, KeywordInfo, "KeywordInfo");
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, "Keywords", KeywordInfo);
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_loci()
+{
+ NAME_VERSION_FLAG("Location Information"); //3GP
+
+ //Parsing
+ Skip_XX(Element_Size-Element_Offset, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_LOOP()
+{
+ Element_Name("LOOP");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_MCPS()
+{
+ Element_Name("Mechanical Copyright Protection Society?");
+
+ //Parsing
+ Ztring Encoder;
+ Get_Local(Element_Size, Encoder, "Value");
+
+ //Filling
+ //Fill(Stream_General, 0, General_Encoded_Library, Encoder);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_meta()
+{
+ NAME_VERSION_FLAG("Metadata");
+ INTEGRITY_VERSION(0);
+
+ //Filling
+ moov_meta_hdlr_Type=Elements::moov_udta_meta;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_meta_hdlr()
+{
+ moov_meta_hdlr();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_meta_ilst()
+{
+ moov_meta_ilst();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_meta_ilst_xxxx()
+{
+ moov_meta_ilst_xxxx();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_meta_ilst_xxxx_data()
+{
+ moov_meta_ilst_xxxx_data();
+}
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_meta_ilst_xxxx_mean()
+{
+ moov_meta_ilst_xxxx_mean();
+}
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_meta_ilst_xxxx_name()
+{
+ moov_meta_ilst_xxxx_name();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_ndrm()
+{
+ //Parsing
+ Skip_XX(Element_Size, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_nsav()
+{
+ Element_Name("No Save");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_ptv()
+{
+ Element_Name("Print To Video");
+
+ //Parsing
+ Skip_B2( "Display size");
+ Skip_B2( "Reserved");
+ Skip_B2( "Reserved");
+ Skip_B1( "Slide show");
+ Skip_B1( "Play on open");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_rtng()
+{
+ NAME_VERSION_FLAG("Rating"); //3GP
+
+ //Parsing
+ Ztring RatingInfo;
+ int32u RatingEntity, RatingCriteria;
+ int16u Language;
+ Get_C4(RatingEntity, "RatingEntity");
+ Get_C4(RatingCriteria, "RatingCriteria");
+ Get_B2(Language, "Language");
+ bool Utf8=true;
+ if (Element_Offset+2<=Element_Size)
+ {
+ int16u Utf16;
+ Peek_B2(Utf16);
+ if (Utf16==0xFEFF)
+ Utf8=false;
+ }
+ if (Utf8)
+ Get_UTF8(Element_Size-Element_Offset, RatingInfo, "RatingInfo");
+ else
+ Get_UTF16(Element_Size-Element_Offset, RatingInfo, "RatingInfo");
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_LawRating, Ztring().From_CC4(RatingCriteria));
+ Fill(Stream_General, 0, General_LawRating_Reason, RatingInfo);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_Sel0()
+{
+ Element_Name("Sel0");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_tags()
+{
+ Element_Name("Tags");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_tags_meta()
+{
+ Element_Name("Metadata");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_tags_tseg()
+{
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_tags_tseg_tshd()
+{
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_WLOC()
+{
+ Element_Name("WLOC");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_XMP_()
+{
+ Element_Name("eXtensible Metadata Platform");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_yrrc()
+{
+ NAME_VERSION_FLAG("Recording Year"); //3GP
+
+ //Parsing
+ int16u RecordingYear;
+ Get_B2 (RecordingYear, "RecordingYear");
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_Released_Date, RecordingYear);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::moov_udta_xxxx()
+{
+ //Getting the method
+ std::string Parameter;
+ method Method=Metadata_Get(Parameter, Element_Code);
+ Element_Info1(Parameter.c_str());
+
+ switch (Method)
+ {
+ case Method_None :
+ {
+ Element_Name("Unknown");
+ }
+ break;
+ case Method_Binary :
+ {
+ Element_Name("Binary");
+ Skip_XX(Element_Size, "Unknown");
+ return;
+ }
+ break;
+ case Method_String :
+ {
+ Element_Name("Text");
+
+ //Parsing
+ Ztring Value;
+ int32u Size32=0;
+ int16u Size16=0, Language;
+ bool IsText=true;
+ if (Element_Size<=4)
+ IsText=false;
+ else
+ {
+ Peek_B4(Size32);
+ if (4+(int64u)Size32>Element_Size)
+ {
+ Size32=0;
+ Peek_B2(Size16);
+ if (4+(int64u)Size16>Element_Size)
+ IsText=false;
+ }
+ }
+ if (!IsText)
+ {
+ Skip_XX(Element_Size, "Unknown");
+ return;
+ }
+
+ while(Element_Offset<Element_Size)
+ {
+ if (Size32)
+ {
+ Get_Local(Size32, Value, "Value");
+ Get_B4 (Size32, "Size");
+ }
+ else
+ {
+ Get_B2 (Size16, "Size");
+ Get_B2 (Language, "Language"); Param_Info1(Language_Get(Language));
+ Get_Local(Size16, Value, "Value");
+ }
+
+ FILLING_BEGIN();
+ if (Retrieve(Stream_General, 0, Parameter.c_str()).empty())
+ Fill(Stream_General, 0, Parameter.c_str(), Value);
+ FILLING_END();
+
+ if (Element_Offset+1==Element_Size)
+ {
+ int8u Null;
+ Peek_B1(Null);
+ if (Null==0x00)
+ Skip_B1( "NULL");
+ }
+ if (Element_Offset+4<=Element_Size && Size32)
+ {
+ int32u Null;
+ Peek_B4(Null);
+ if (Null==0x00000000)
+ Skip_XX(Element_Size-Element_Offset,"Padding");
+ }
+ if (Element_Offset+2<=Element_Size && Size16)
+ {
+ int16u Null;
+ Peek_B2(Null);
+ if (Null==0x0000)
+ Skip_XX(Element_Size-Element_Offset,"Padding");
+ }
+ }
+ }
+ break;
+ case Method_String2 :
+ {
+ NAME_VERSION_FLAG("Text");
+
+ //Parsing
+ Ztring Value;
+ int16u Language;
+ while(Element_Offset<Element_Size)
+ {
+ Get_B2(Language, "Language"); Param_Info1(Language_Get(Language));
+ bool Utf8=true;
+ if (Element_Offset+2<=Element_Size)
+ {
+ int16u Utf16;
+ Peek_B2(Utf16);
+ if (Utf16==0xFEFF)
+ Utf8=false;
+ }
+ if (Utf8)
+ Get_UTF8(Element_Size-Element_Offset, Value, "Value");
+ else
+ Get_UTF16(Element_Size-Element_Offset, Value, "Value");
+
+ FILLING_BEGIN();
+ if (Retrieve(Stream_General, 0, Parameter.c_str()).empty())
+ Fill(Stream_General, 0, Parameter.c_str(), Value);
+ FILLING_END();
+ }
+ }
+ break;
+ case Method_String3 :
+ {
+ NAME_VERSION_FLAG("Text");
+
+ //Parsing
+ Ztring Value;
+ while(Element_Offset<Element_Size)
+ {
+ Get_UTF8(Element_Size-Element_Offset, Value,"Value");
+
+ FILLING_BEGIN();
+ if (Retrieve(Stream_General, 0, Parameter.c_str()).empty())
+ Fill(Stream_General, 0, Parameter.c_str(), Value);
+ FILLING_END();
+ }
+ }
+ break;
+ case Method_Integer :
+ {
+ Element_Name("Integer");
+
+ //Parsing
+ Skip_XX(4, "Value");
+ }
+ break;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::PICT()
+{
+ Element_Name("QuickDraw picture");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::pckg()
+{
+ Element_Name("QTCA");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+
+ FILLING_BEGIN();
+ Accept("QTCA");
+
+ Fill(Stream_General, 0, General_Format, "MPEG-4");
+ CodecID_Fill(_T("QTCA"), Stream_General, 0, InfoCodecID_Format_Mpeg4);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::pnot()
+{
+ Element_Name("Preview");
+
+ //Parsing
+ Info_B4(Date_Modified, "Modification date"); Param_Info1(Ztring().Date_From_Seconds_1904(Date_Modified));
+ Skip_B2( "Version number");
+ Skip_C4( "Atom type");
+ Skip_B2( "Atom index");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::RDAO()
+{
+ Element_Name("Audio O?");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::RDAS()
+{
+ Element_Name("Audio S?");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::RDVO()
+{
+ Element_Name("Video O?");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::RDVS()
+{
+ Element_Name("Video S?");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::RED1()
+{
+ Element_Name("RED Header");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+
+ FILLING_BEGIN();
+ Accept("R3D");
+
+ Fill(Stream_General, 0, General_Format, "R3D");
+ //Source: http://peter.schlaile.de/redcode/
+
+ Finish();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::REDA()
+{
+ Element_Name("RED Audio");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+
+ Finish();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::REDV()
+{
+ Element_Name("RED Video");
+
+ //Parsing
+ /*
+ if (Streams[1].Parser==0)
+ {
+ Streams[1].Parser=new File_Mpeg4();
+ Open_Buffer_Init(Streams[1].Parser);
+ }
+ */
+
+ //Parsing
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+ Skip_B4( "Unknown");
+ Skip_C4( "CodecID");
+ Skip_B4( "Unknown");
+ //Open_Buffer_Continue(Streams[1].Parser);
+ Skip_XX(Element_Size-Element_Offset, "Data");
+
+ Finish();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::REOB()
+{
+ Element_Name("OB?");
+
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::skip()
+{
+ Element_Name("Skip");
+
+ //Parsing
+ Skip_XX(Element_Size, "Free");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4::wide()
+{
+ Element_Name("Wide");
+
+ //Parsing
+ Skip_XX(Element_Size, "Free");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPEG4_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_TimeCode.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_TimeCode.cpp
new file mode 100644
index 000000000..8a71358a3
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_TimeCode.cpp
@@ -0,0 +1,99 @@
+// File_Mpeg4_TimeCode - Info for MPEG-4 TimeCode files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEG4_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Mpeg4_TimeCode.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Mpeg4_TimeCode::File_Mpeg4_TimeCode()
+:File__Analyze()
+{
+ //Out
+ Pos=(int32u)-1;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_TimeCode::Streams_Fill()
+{
+ if (Pos!=(int32u)-1 && FrameRate)
+ {
+ Fill(Stream_General, 0, "Delay", Pos*1000/FrameRate, 0);
+ }
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg4_TimeCode::Read_Buffer_Continue()
+{
+ //Parsing
+ int32u Position=0;
+ while (Element_Offset<Element_Size)
+ {
+ Get_B4 (Position, "Position");
+ if (Pos==(int32u)-1) //First time code
+ {
+ Pos=Position;
+ if (NegativeTimes)
+ Pos=(int32s)Position;
+ }
+ }
+
+ FILLING_BEGIN();
+ if (!Status[IsAccepted])
+ {
+ Accept("TimeCode");
+ Fill("TimeCode");
+ }
+ FILLING_END();
+}
+
+}
+
+#endif //MEDIAINFO_MPEG4_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_TimeCode.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_TimeCode.h
new file mode 100644
index 000000000..da2d7cae6
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg4_TimeCode.h
@@ -0,0 +1,59 @@
+// File_Mpeg4_TimeCode - Info for MPEG-4 TimeCode files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Mpeg4_TimeCodeH
+#define MediaInfo_File_Mpeg4_TimeCodeH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Mpeg4_TimeCode
+//***************************************************************************
+
+class File_Mpeg4_TimeCode : public File__Analyze
+{
+public :
+ //In
+ float64 FrameRate;
+ bool NegativeTimes;
+
+ //Out
+ int64s Pos;
+
+ //Constructor/Destructor
+ File_Mpeg4_TimeCode();
+
+protected :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - Global
+ void Read_Buffer_Continue();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegPs.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegPs.cpp
new file mode 100644
index 000000000..f6d6a1d5e
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegPs.cpp
@@ -0,0 +1,4506 @@
+// File_MpegPs - Info for MPEG files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEGPS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_MpegPs.h"
+#include "MediaInfo/Multiple/File_Mpeg_Psi.h"
+#if defined(MEDIAINFO_AVC_YES)
+ #include "MediaInfo/Video/File_Avc.h"
+#endif
+#if defined(MEDIAINFO_MPEG4V_YES)
+ #include "MediaInfo/Video/File_Mpeg4v.h"
+#endif
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_VC1_YES)
+ #include "MediaInfo/Video/File_Vc1.h"
+#endif
+#if defined(MEDIAINFO_AVSV_YES)
+ #include "MediaInfo/Video/File_AvsV.h"
+#endif
+#if defined(MEDIAINFO_DIRAC_YES)
+ #include "MediaInfo/Video/File_Dirac.h"
+#endif
+#if defined(MEDIAINFO_AAC_YES)
+ #include "MediaInfo/Audio/File_Aac.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_DTS_YES)
+ #include "MediaInfo/Audio/File_Dts.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if defined(MEDIAINFO_PCM_YES)
+ #include "MediaInfo/Audio/File_Pcm.h"
+#endif
+#if defined(MEDIAINFO_AES3_YES)
+ #include "MediaInfo/Audio/File_Aes3.h"
+#endif
+#if defined(MEDIAINFO_PS2A_YES)
+ #include "MediaInfo/Audio/File_Ps2Audio.h"
+#endif
+#if defined(MEDIAINFO_RLE_YES)
+ #include "MediaInfo/Image/File_Rle.h"
+#endif
+#if defined(MEDIAINFO_DVBSUBTITLE_YES)
+ #include "MediaInfo/Text/File_DvbSubtitle.h"
+#endif
+#if defined(MEDIAINFO_PGS_YES)
+ #include "MediaInfo/Text/File_Pgs.h"
+#endif
+#if defined(MEDIAINFO_TELETEXT_YES)
+ #include "MediaInfo/Text/File_Teletext.h"
+#endif
+#include "MediaInfo/File_Unknown.h"
+#include <ZenLib/Utils.h>
+#include <algorithm>
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+ #include "MediaInfo/MediaInfo_Events_Internal.h"
+#endif //MEDIAINFO_EVENTS
+#if MEDIAINFO_IBI
+ #if MEDIAINFO_SEEK
+ #include "MediaInfo/Multiple/File_Ibi.h"
+ #endif //MEDIAINFO_SEEK
+ #include "MediaInfo/Multiple/File_Ibi_Creation.h"
+#endif //MEDIAINFO_IBI
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* MpegPs_System_Fixed[]=
+{
+ "CBR",
+ "VBR",
+};
+
+//---------------------------------------------------------------------------
+const char* MpegPs_stream_id(int8u Element_Name)
+{
+ if (Element_Name>=0xC0
+ && Element_Name<=0xDF) return "MPEG Audio";
+ else if (Element_Name>=0xE0
+ && Element_Name<=0xEF) return "MPEG Video";
+ else if (Element_Name==0xB8) return "For all MPEG Audio streams";
+ else if (Element_Name==0xB9) return "For all MPEG Video streams";
+ else if (Element_Name==0xBD) return "Private 1";
+ else if (Element_Name==0xBF) return "Private 2";
+ else if (Element_Name==0xFD) return "Private HD";
+ else return "";
+}
+
+//---------------------------------------------------------------------------
+const char* MpegPs_Codec(int8u Element_Name)
+{
+ if (Element_Name>=0xC0
+ && Element_Name<=0xDF) return "MPEG-A";
+ else if (Element_Name>=0xE0
+ && Element_Name<=0xEF) return "MPEG-V";
+ else return "";
+}
+
+//---------------------------------------------------------------------------
+int32u MpegPs_Default_stream_type(int8u Element_Name, int8u Mpeg_Version)
+{
+ if (Element_Name>=0xC0
+ && Element_Name<=0xDF) return Mpeg_Version==0x02?0x04:0x03;
+ else if (Element_Name>=0xE0
+ && Element_Name<=0xEF) return Mpeg_Version==0x02?0x02:0x01;
+ else return 0x00;
+}
+
+//---------------------------------------------------------------------------
+const char* MpegPs_trick_mode_control_values[8]=
+{
+ "Fast forward",
+ "Slow motion",
+ "Freeze frame",
+ "Fast reverse",
+ "Slow reverse",
+ "Reserved",
+ "Reserved",
+ "Reserved"
+};
+
+//---------------------------------------------------------------------------
+const char* MpegPs_stream_id_extension(int8u stream_id_extension)
+{
+ switch (stream_id_extension)
+ {
+ case 0x00 : return "IPMP Control Information Streams"; //ISO/IEC 13818-11
+ case 0x01 : return "IPMP Streams"; //ISO/IEC 13818-11
+ default :
+ if (stream_id_extension>=0x02
+ && stream_id_extension<=0x11) return "ISO/IEC 14496-17 text Streams";
+ else if (stream_id_extension>=0x12
+ && stream_id_extension<=0x21) return "ISO/IEC 23002-3 auxiliary video data Streams";
+ else if (stream_id_extension>=0x55
+ && stream_id_extension<=0x5F) return "VC-1";
+ else if (stream_id_extension>=0x60
+ && stream_id_extension<=0x6F) return "Dirac";
+ else if (stream_id_extension==0x71) return "Audio";
+ else if (stream_id_extension==0x72) return "Audio Ext";
+ else if (stream_id_extension==0x76) return "Audio";
+ else if (stream_id_extension>=0x75
+ && stream_id_extension<=0x7F) return "VC-1";
+ else return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+extern const char* Mpeg_Psi_stream_type_Format(int8u stream_type, int32u format_identifier);
+extern const char* Mpeg_Psi_stream_type_Codec(int8u stream_type, int32u format_identifier);
+extern stream_t Mpeg_Psi_stream_type_StreamKind(int32u stream_type, int32u format_identifier);
+extern const char* Mpeg_Psi_stream_type_Info(int8u stream_type, int32u format_identifier);
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_MpegPs::File_MpegPs()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("MpegPs");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_MpegPs;
+ StreamIDs_Width[0]=2;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ #endif //MEDIAINFO_DEMUX
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(0); //Container1
+ #endif //MEDIAINFO_TRACE
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+ Buffer_TotalBytes_Fill_Max=(int64u)-1; //Disabling this feature for this format, this is done in the parser
+ Trusted_Multiplier=2;
+
+ //In
+ FromTS=false;
+ FromTS_stream_type=0x00; //No info
+ FromTS_program_format_identifier=0x00000000; //No info
+ FromTS_format_identifier=0x00000000; //No info
+ FromTS_descriptor_tag=0x00; //No info
+ MPEG_Version=0; //No info
+ Searching_TimeStamp_Start=true;
+ #ifdef MEDIAINFO_MPEG4_YES
+ ParserFromTs=NULL;
+ SLConfig=NULL;
+ #endif
+ #if MEDIAINFO_DEMUX
+ SubStream_Demux=NULL;
+ Demux_StreamIsBeingParsed_type=(int8u)-1;
+ #endif //MEDIAINFO_DEMUX
+
+ //Out
+ HasTimeStamps=false;
+
+ //Temp
+ SizeToAnalyze=8*1024*1024;
+ video_stream_Unlimited=false;
+ Buffer_DataSizeToParse=0;
+ #if MEDIAINFO_SEEK
+ Seek_Value=(int64u)-1;
+ Seek_ID=(int64u)-1;
+ Duration_Detected=false;
+ #endif //MEDIAINFO_SEEK
+
+ //From packets
+ program_mux_rate=(int32u)-1;
+
+ BookMark_Set(); //for stream parsing in phase 2
+}
+
+//---------------------------------------------------------------------------
+File_MpegPs::~File_MpegPs()
+{
+ #if MEDIAINFO_DEMUX
+ if (FromTS_stream_type==0x20) //If SubStream, this object owns the demux handler
+ delete SubStream_Demux; //SubStream_Demux=NULL;
+ #endif //MEDIAINFO_DEMUX
+ #ifdef MEDIAINFO_MPEG4_YES
+ delete ParserFromTs; //ParserFromTs=NULL;
+ delete SLConfig; //SLConfig=NULL;
+ #endif
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpegPs::Streams_Fill()
+{
+ //For each Streams
+ for (size_t StreamID=0; StreamID<0x100; StreamID++)
+ Streams_Fill_PerStream(StreamID, Streams[StreamID], KindOfStream_Main);
+
+ //For each private Streams
+ for (size_t StreamID=0; StreamID<0x100; StreamID++)
+ Streams_Fill_PerStream(StreamID, Streams_Private1[StreamID], KindOfStream_Private);
+
+ //For each extension Streams
+ for (size_t StreamID=0; StreamID<0x100; StreamID++)
+ {
+ Streams_Fill_PerStream(StreamID, Streams_Extension[StreamID], KindOfStream_Extension);
+
+ //Special cases
+ if ((StreamID==0x71 || StreamID==0x76) && !Streams_Extension[StreamID].Parsers.empty() && Streams_Extension[0x72].StreamIsRegistred) //DTS-HD and TrueHD
+ {
+ Fill(Stream_Audio, StreamPos_Last, Audio_MuxingMode, "Stream extension");
+ if (!IsSub)
+ Fill(Stream_Audio, StreamPos_Last, Audio_MuxingMode_MoreInfo, "HD part is in stream extension 114 (0x72)");
+ }
+ }
+
+ //Tags in MPEG Video
+ if (Count_Get(Stream_Video)>0)
+ Fill(Stream_General, 0, General_Encoded_Library, Retrieve(Stream_Video, 0, Video_Encoded_Library));
+
+ //Special case: Video PTS
+ if (video_stream_PTS.size()>=2+4*2+1*2 && Retrieve(Stream_Video, 0, Video_FrameRate).To_float64()>30.000) //TODO: Parser all kind of files
+ {
+ sort(video_stream_PTS.begin(), video_stream_PTS.end());
+ video_stream_PTS.erase(video_stream_PTS.begin(), video_stream_PTS.begin()+4); //Removing first frames, they may lack of B/P frames
+ video_stream_PTS.resize(video_stream_PTS.size()-4); //Removing last frames, they may lack of B/P frames
+
+ //Trying to detect container FPS
+ std::vector<int64u> video_stream_PTS_Between;
+ for (size_t Pos=1; Pos<video_stream_PTS.size(); Pos++)
+ video_stream_PTS_Between.push_back(video_stream_PTS[Pos]-video_stream_PTS[Pos-1]);
+ std::sort(video_stream_PTS_Between.begin(), video_stream_PTS_Between.end());
+ video_stream_PTS_Between.erase(video_stream_PTS_Between.begin(), video_stream_PTS_Between.begin()+1); //Removing first timec, they may be wrong value due to missing frame
+ video_stream_PTS_Between.resize(video_stream_PTS_Between.size()-1); //Removing last frames, they may be wrong value due to missing frame
+ if (video_stream_PTS_Between[0]*0.9<video_stream_PTS_Between[video_stream_PTS_Between.size()-1]
+ && video_stream_PTS_Between[0]*1.1>video_stream_PTS_Between[video_stream_PTS_Between.size()-1])
+ {
+ float64 Time=(float)(video_stream_PTS[video_stream_PTS.size()-1]-video_stream_PTS[0])/(video_stream_PTS.size()-1)/90;
+ if (Time)
+ {
+ float64 FrameRate_Container=1000/Time;
+ if (Retrieve(Stream_Video, 0, Video_ScanType)==_T("Interlaced"))
+ FrameRate_Container/=2; //PTS is per field
+ float64 FrameRate_Original=Retrieve(Stream_Video, 0, Video_FrameRate).To_float64();
+ if (!(FrameRate_Original>=FrameRate_Container*0.9 && FrameRate_Original<=FrameRate_Container*1.1)
+ && !(FrameRate_Container>=FrameRate_Original*0.9 && FrameRate_Container<=FrameRate_Original*1.1))
+ {
+ Clear(Stream_Video, 0, Video_FrameRate); //Or automatic filling thinks current FrameRate is the container FrameRate (usaly Conatainer FrameRate is filled first, not here)
+ Fill(Stream_Video, 0, Video_FrameRate, FrameRate_Container, 3, true);
+ if (FrameRate_Original)
+ Fill(Stream_Video, 0, Video_FrameRate_Original, FrameRate_Original);
+ }
+ }
+ }
+ }
+
+ if (Count_Get(Stream_Video)==1 && Retrieve(Stream_Video, 0, Video_Format_Version)==_T("Version 1"))
+ Fill(Stream_General, 0, General_InternetMediaType, "video/mpeg", Unlimited, true, true);
+}
+
+//---------------------------------------------------------------------------
+void File_MpegPs::Streams_Fill_PerStream(size_t StreamID, ps_stream &Temp, kindofstream KindOfStream)
+{
+ //By the parser
+ StreamKind_Last=Stream_Max;
+ size_t Count=0;
+ if (!Temp.Parsers.empty() && Temp.Parsers[0] && Temp.Parsers[0]->Status[IsAccepted])
+ {
+ Fill(Temp.Parsers[0]);
+
+ if (Temp.Parsers[0]->Count_Get(Stream_Video) && Temp.Parsers[0]->Count_Get(Stream_Text))
+ {
+ //Special case: Video and Text are together
+ Stream_Prepare(Stream_Video);
+ Count=Merge(*Temp.Parsers[0], Stream_Video, 0, StreamPos_Last);
+ }
+ else
+ Count=Merge(*Temp.Parsers[0]);
+ }
+
+ //By the TS stream_type
+ if (StreamKind_Last==Stream_Max)
+ {
+ //Disabling stream_private_1 if needed (will be done by Streams_Private1 object)
+ if (Temp.stream_type!=0 && StreamID==0xBD)
+ {
+ bool StreamIsDetected=false;
+ for (size_t Pos=0; Pos<Streams_Private1.size(); Pos++)
+ if (!Streams_Private1[Pos].Parsers.empty() && Streams_Private1[Pos].Parsers[0])
+ StreamIsDetected=true;
+ if (StreamIsDetected)
+ Temp.stream_type=0;
+ }
+
+ if (Temp.stream_type!=0)
+ {
+ Stream_Prepare(Mpeg_Psi_stream_type_StreamKind(Temp.stream_type, 0x00000000));
+ Count=1;
+ }
+ }
+
+ //By StreamIsRegistred
+ if (StreamKind_Last==Stream_Max)
+ {
+ if (Temp.StreamIsRegistred>16)
+ {
+ if (StreamID>=0xC0 && StreamID<=0xDF)
+ {
+ Stream_Prepare(Stream_Audio);
+ Count=1;
+ }
+ if (StreamID>=0xE0 && StreamID<=0xEF)
+ {
+ Stream_Prepare(Stream_Video);
+ Count=1;
+ }
+ }
+ }
+
+ #ifdef MEDIAINFO_MPEG4_YES
+ if (StreamKind_Last==Stream_Audio && SLConfig)
+ Fill(Stream_Audio, StreamPos_Last, Audio_MuxingMode, "SL");
+ #endif //MEDIAINFO_MPEG4_YES
+
+ //More info
+ for (size_t StreamPos=Count_Get(StreamKind_Last)-Count; StreamPos<Count_Get(StreamKind_Last); StreamPos++)
+ {
+ ///Saving StreamKind and Stream_Pos
+ Temp.StreamKind=StreamKind_Last;
+ Temp.StreamPos=Count_Get(StreamKind_Last)-Count;
+
+ //Common
+ if (Retrieve(StreamKind_Last, StreamPos, General_ID).empty())
+ {
+ if (KindOfStream==KindOfStream_Main)
+ {
+ Fill(StreamKind_Last, StreamPos, General_ID, StreamID);
+ Ztring ID_String; ID_String.From_Number(StreamID); ID_String+=_T(" (0x"); ID_String+=Ztring::ToZtring(StreamID, 16); ID_String+=_T(")");
+ Fill(StreamKind_Last, StreamPos, General_ID_String, ID_String, true); //TODO: merge with Decimal_Hexa in file_MpegTs
+ }
+ else if (KindOfStream==KindOfStream_Private)
+ {
+ Ztring ID=_T("189");
+ if (StreamID)
+ ID+=_T("-")+Ztring::ToZtring(StreamID);
+ Fill(StreamKind_Last, StreamPos, General_ID, ID, true);
+ Ztring ID_String=_T("189 (0xBD)");
+ if (StreamID)
+ ID_String+=_T("-")+Ztring::ToZtring(StreamID)+_T(" (0x")+Ztring::ToZtring(StreamID, 16)+_T(")");
+ Fill(StreamKind_Last, StreamPos, General_ID_String, ID_String, true); //TODO: merge with Decimal_Hexa in file_MpegTs
+ if (StreamID)
+ Fill(StreamKind_Last, StreamPos, "MuxingMode", "DVD-Video", Unlimited, true, true);
+ }
+ else if (KindOfStream==KindOfStream_Extension)
+ {
+ Ztring ID=_T("253");
+ if (StreamID)
+ ID+=_T("-")+Ztring::ToZtring(StreamID);
+ Fill(StreamKind_Last, StreamPos, General_ID, ID, true);
+ Ztring ID_String=_T("253 (0xFD)");
+ if (StreamID)
+ ID_String+=_T("-")+Ztring::ToZtring(StreamID)+_T(" (0x")+Ztring::ToZtring(StreamID, 16)+_T(")");
+ Fill(StreamKind_Last, StreamPos, General_ID_String, ID_String, true); //TODO: merge with Decimal_Hexa in file_MpegTs
+ }
+ }
+ if (Retrieve(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Format)).empty() && Temp.stream_type!=0)
+ Fill(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Format), Mpeg_Psi_stream_type_Format(Temp.stream_type, 0x0000));
+ if (Retrieve(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Codec)).empty() && Temp.stream_type!=0)
+ Fill(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Codec), Mpeg_Psi_stream_type_Codec(Temp.stream_type, 0x0000));
+
+ if (Temp.TimeStamp_Start.PTS.TimeStamp!=(int64u)-1)
+ {
+ Fill(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Delay_Original), Retrieve(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Delay)), true);
+ Clear(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Delay));
+ Fill(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Delay_Original_Source), Retrieve(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Delay_Source)), true);
+ Clear(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Delay_Source));
+ Fill(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Delay_Original_Settings), Retrieve(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Delay_Settings)), true);
+ Clear(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Delay_Settings));
+
+ Fill(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Delay), ((float64)Temp.TimeStamp_Start.PTS.TimeStamp)/90, 3, true);
+ Fill(StreamKind_Last, StreamPos, Fill_Parameter(StreamKind_Last, Generic_Delay_Source), "Container");
+ }
+
+ //Bitrate calculation
+ if (FrameInfo.PTS!=(int64u)-1 && (StreamKind_Last==Stream_Video || StreamKind_Last==Stream_Audio))
+ {
+ int64u BitRate=Retrieve(StreamKind_Last, StreamPos, "BitRate").To_int64u();
+ if (BitRate==0)
+ BitRate=Retrieve(StreamKind_Last, StreamPos, "BitRate_Nominal").To_int64u();
+ if (BitRate==0)
+ FrameInfo.PTS=(int64u)-1;
+ else
+ FrameInfo.PTS+=BitRate; //Saving global BitRate
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_MpegPs::Streams_Finish()
+{
+ if (Streams.empty())
+ return; //Parsing already done. ToDo: real time
+
+ FrameInfo.PTS=0; //Will be used for BitRate calculation
+ FrameInfo.DTS=0; //Will be used for Duration calculation
+
+ //For each Streams
+ for (size_t StreamID=0; StreamID<0x100; StreamID++)
+ Streams_Finish_PerStream(StreamID, Streams[StreamID], KindOfStream_Main);
+
+ //For each private Streams
+ for (size_t StreamID=0; StreamID<0x100; StreamID++)
+ Streams_Finish_PerStream(StreamID, Streams_Private1[StreamID], KindOfStream_Private);
+
+ //For each extesnion Streams
+ for (size_t StreamID=0; StreamID<0x100; StreamID++)
+ Streams_Finish_PerStream(StreamID, Streams_Extension[StreamID], KindOfStream_Extension);
+
+ //Bitrate coherancy
+ if (!IsSub && FrameInfo.PTS>0 && FrameInfo.PTS!=(int64u)-1 && FrameInfo.DTS!=0 && File_Size!=(int64u)-1)
+ {
+ int64u BitRate_FromDuration=File_Size*8000*90/FrameInfo.DTS;
+ int64u BitRate_FromBitRates=FrameInfo.PTS;
+
+ if (BitRate_FromDuration>=BitRate_FromBitRates*3
+ || BitRate_FromDuration<=BitRate_FromBitRates/20)
+ {
+ //Clearing durations
+ for (size_t StreamKind=0; StreamKind<=Stream_Text; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Count_Get((stream_t)StreamKind); StreamPos++)
+ Clear((stream_t)StreamKind, StreamPos, (stream_t)Fill_Parameter((stream_t)StreamKind, Generic_Duration));
+ if (Count_Get(Stream_Video)==1)
+ Clear(Stream_Video, 0, Video_Duration);
+ }
+ }
+
+ #if MEDIAINFO_IBI
+ if (Config_Ibi_Create)
+ {
+ ibi Ibi_Temp;
+ for (ibi::streams::iterator IbiStream_Temp=Ibi.Streams.begin(); IbiStream_Temp!=Ibi.Streams.end(); IbiStream_Temp++)
+ Ibi_Temp.Streams[IbiStream_Temp->first]=new ibi::stream(*IbiStream_Temp->second);
+
+ for (ibi::streams::iterator IbiStream_Temp=Ibi_Temp.Streams.begin(); IbiStream_Temp!=Ibi_Temp.Streams.end(); IbiStream_Temp++)
+ {
+ if (IbiStream_Temp->second && IbiStream_Temp->second->DtsFrequencyNumerator==1000000000 && IbiStream_Temp->second->DtsFrequencyDenominator==1)
+ {
+ bool IsOk=true;
+ for (size_t Pos=0; Pos<IbiStream_Temp->second->Infos.size(); Pos++)
+ if (!IbiStream_Temp->second->Infos[Pos].IsContinuous && Pos+1!=IbiStream_Temp->second->Infos.size())
+ IsOk=false;
+ if (IsOk) //Only is all items are continuous (partial IBI not yet supported)
+ {
+ IbiStream_Temp->second->DtsFrequencyNumerator=90000;
+ for (size_t Pos=0; Pos<IbiStream_Temp->second->Infos.size(); Pos++)
+ {
+ int64u Temp=IbiStream_Temp->second->Infos[Pos].Dts*90/1000000;
+ IbiStream_Temp->second->Infos[Pos].Dts=Temp;
+ }
+ }
+ }
+ }
+
+ //IBI Creation
+ File_Ibi_Creation IbiCreation(Ibi_Temp);
+ Ztring IbiText=IbiCreation.Finish();
+ if (!IbiText.empty())
+ Fill(Stream_General, 0, "IBI", IbiText, true);
+ }
+ #endif //MEDIAINFO_IBI
+}
+
+//---------------------------------------------------------------------------
+void File_MpegPs::Streams_Finish_PerStream(size_t StreamID, ps_stream &Temp, kindofstream KindOfStream)
+{
+ //By the parser
+ if (Temp.StreamKind==Stream_Max && !Temp.Parsers.empty() && Temp.Parsers[0])
+ Streams_Fill_PerStream(StreamID, Temp, KindOfStream);
+
+ //Init
+ if (Temp.StreamKind==Stream_Max)
+ return;
+ StreamKind_Last=Temp.StreamKind;
+ StreamPos_Last=Temp.StreamPos;
+
+ //By the parser
+ if (!Temp.Parsers.empty() && Temp.Parsers[0])
+ {
+ if (!Temp.Parsers[0]->Status[IsFinished])
+ {
+ Temp.Parsers[0]->ShouldContinueParsing=false;
+ int64u File_Size_Temp=File_Size;
+ File_Size=File_Offset+Buffer_Offset+Element_Offset;
+ Open_Buffer_Continue(Temp.Parsers[0], Buffer, 0);
+ File_Size=File_Size_Temp;
+ Finish(Temp.Parsers[0]);
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return;
+ #endif //MEDIAINFO_DEMUX
+ }
+ Ztring ID=Retrieve(StreamKind_Last, StreamPos_Last, General_ID);
+ Ztring ID_String=Retrieve(StreamKind_Last, StreamPos_Last, General_ID_String);
+ Merge(*Temp.Parsers[0], StreamKind_Last, 0, StreamPos_Last);
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, ID, true);
+ Fill(StreamKind_Last, StreamPos_Last, General_ID_String, ID_String, true);
+
+ //Special cases
+ if (Temp.Parsers[0]->Count_Get(Stream_Video) && Temp.Parsers[0]->Count_Get(Stream_Text))
+ {
+ //Video and Text are together
+ size_t Text_Count=Temp.Parsers[0]->Count_Get(Stream_Text);
+ for (size_t Parser_Pos=0; Parser_Pos<Text_Count; Parser_Pos++)
+ {
+ Ztring ID=Retrieve(Stream_Video, Temp.StreamPos, Video_ID)+_T("-")+Temp.Parsers[0]->Retrieve(Stream_Text, Parser_Pos, Text_ID);
+ StreamPos_Last=(size_t)-1;
+ for (size_t Pos=0; Pos<Count_Get(Stream_Text); Pos++)
+ if (Retrieve(Stream_Text, Pos, Text_ID)==ID && Retrieve(Stream_Video, Temp.StreamPos, "MuxingMode")==Temp.Parsers[0]->Retrieve(Stream_Text, Parser_Pos, "MuxingMode"))
+ {
+ StreamPos_Last=Pos;
+ break;
+ }
+ if (StreamPos_Last==(size_t)-1)
+ Stream_Prepare(Stream_Text, StreamPos_Last);
+ Merge(*Temp.Parsers[0], Stream_Text, Parser_Pos, StreamPos_Last);
+
+ if (!IsSub)
+ Fill(Stream_Text, StreamPos_Last, "MuxingMode_MoreInfo", _T("Muxed in Video #")+Ztring().From_Number(Temp.StreamPos+1));
+ Fill(Stream_Text, StreamPos_Last, Text_ID, ID, true);
+ Fill(Stream_Text, StreamPos_Last, Text_ID_String, Retrieve(Stream_Video, Temp.StreamPos, Video_ID_String)+_T("-")+Temp.Parsers[0]->Retrieve(Stream_Text, Parser_Pos, Text_ID), true);
+ Fill(Stream_Text, StreamPos_Last, Text_Delay, Retrieve(Stream_Video, Temp.StreamPos, Video_Delay), true);
+ }
+
+ StreamKind_Last=Temp.StreamKind;
+ StreamPos_Last=Temp.StreamPos;
+ }
+ }
+
+ //Duration if it is missing from the parser
+ if (Temp.StreamKind!=Stream_Max && Retrieve(Temp.StreamKind, Temp.StreamPos, Fill_Parameter(Temp.StreamKind, Generic_Duration)).empty())
+ {
+ StreamKind_Last=Temp.StreamKind;
+ StreamPos_Last=Temp.StreamPos;
+
+ int64u Start=(int64u)-1, End=(int64u)-1;
+ if (Temp.TimeStamp_Start.DTS.TimeStamp!=(int64u)-1 && Temp.TimeStamp_End.DTS.TimeStamp!=(int64u)-1)
+ {
+ Start=Temp.TimeStamp_Start.DTS.TimeStamp;
+ End=Temp.TimeStamp_End.DTS.TimeStamp;
+ }
+ else if (Temp.TimeStamp_Start.PTS.TimeStamp!=(int64u)-1 && Temp.TimeStamp_End.PTS.TimeStamp!=(int64u)-1)
+ {
+ Start=Temp.TimeStamp_Start.PTS.TimeStamp;
+ End=Temp.TimeStamp_End.PTS.TimeStamp;
+ }
+ if (Start!=(int64u)-1 && End!=(int64u)-1)
+ {
+ //TimeStamp
+ if (End<Start)
+ End+=0x200000000LL; //33 bits, cyclic
+ int64u Duration=End-Start;
+ if (File_Size!=(int64u)-1 && File_Size>1024*1024*16 && End>=0x200000000LL)
+ {
+ //Testing coherancy
+ if (Duration/90>16*3600*1000)
+ Duration=0; //Disabling it
+ }
+ if (Duration)
+ {
+ if (StreamKind_Last==Stream_Video)
+ {
+ float64 FrameRate=Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate).To_float64();
+ if (FrameRate!=0)
+ Duration+=Ztring::ToZtring(90*1000/FrameRate, 0).To_int64u(); //We imagine that there is one frame in it
+ }
+ if (Duration)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), Duration/90, 10, true);
+ if (Duration>FrameInfo.DTS)
+ FrameInfo.DTS=Duration; //Saving maximum Duration
+ }
+ }
+ }
+ }
+
+ //Bitrate calculation
+ if (FrameInfo.PTS!=(int64u)-1 && (StreamKind_Last==Stream_Video || StreamKind_Last==Stream_Audio))
+ {
+ int64u BitRate=Retrieve(StreamKind_Last, StreamPos_Last, "BitRate").To_int64u();
+ if (BitRate==0)
+ BitRate=Retrieve(StreamKind_Last, StreamPos_Last, "BitRate_Nominal").To_int64u();
+ if (BitRate==0)
+ FrameInfo.PTS=(int64u)-1;
+ else
+ FrameInfo.PTS+=BitRate; //Saving global BitRate
+ }
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_MpegPs::Synchronize()
+{
+ //Synchronizing
+ while (Buffer_Offset+4<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x01
+ || Buffer[Buffer_Offset+3]< 0xB9))
+ {
+ Buffer_Offset+=2;
+ while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Buffer_Offset+=2;
+ if (Buffer_Offset>=Buffer_Size || Buffer[Buffer_Offset-1]==0x00)
+ Buffer_Offset--;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+4==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x01
+ || Buffer[Buffer_Offset+3]< 0xB9))
+ Buffer_Offset++;
+ if (Buffer_Offset+3==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x01))
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00))
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && Buffer[Buffer_Offset ]!=0x00)
+ Buffer_Offset++;
+
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ //Synched is OK
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_MpegPs::Synched_Test()
+{
+ //Trailing 0xFF
+ while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]==0xFF)
+ Buffer_Offset++;
+
+ //Trailing 0x00
+ while(Buffer_Offset+3<=Buffer_Size
+ && Buffer[Buffer_Offset+2]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset ]==0x00)
+ Buffer_Offset++;
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x01)
+ Synched=false;
+
+ //Quick search
+ if (Synched && !Header_Parser_QuickSearch())
+ return false;
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_MpegPs::Synched_Init()
+{
+ //private_stream_1 specific
+ private_stream_1_ID=0x00;
+ private_stream_1_Offset=0;
+ private_stream_1_IsDvdVideo=false;
+
+ //Count
+ video_stream_Count=(int8u)-1;
+ audio_stream_Count=(int8u)-1;
+ private_stream_1_Count=(int8u)-1;
+ private_stream_2_Count=(int8u)-1;
+ extension_stream_Count=(int8u)-1;
+ SL_packetized_stream_Count=(int8u)-1;
+
+ //From packets
+ program_mux_rate=0;
+
+ //Default values
+ Streams.resize(0x100);
+ Streams_Private1.resize(0x100);
+ Streams_Extension.resize(0x100);
+ Streams[0xBA].Searching_Payload=true;
+
+ //Temp
+ stream_id_extension=0x55; //Default is set to VC-1, should never happens, but happens sometimes
+
+ //Case of extraction from MPEG-TS files
+ if (File_Offset==0 && Buffer_Size>=4 && ((CC4(Buffer)&0xFFFFFFF0)==0x000001E0 || (CC4(Buffer)&0xFFFFFFE0)==0x000001C0 || CC4(Buffer)==0x000001BD || CC4(Buffer)==0x000001FA || CC4(Buffer)==0x000001FD))
+ {
+ FromTS=true; //We want to anlyze this kind of file
+ MPEG_Version=2; //By default, MPEG-TS is version 2
+ Streams[Buffer[3]].Searching_Payload=true; //Activating the Streams
+ }
+
+ //TS specific
+ if (FromTS)
+ {
+ Streams[0xBD].Searching_Payload=true; //private_stream_1
+ Streams[0xBD].Searching_TimeStamp_Start=true; //private_stream_1
+ Streams[0xBD].Searching_TimeStamp_End=true; //private_stream_1
+ Streams[0xBF].Searching_Payload=true; //private_stream_2
+ Streams[0xBF].Searching_TimeStamp_Start=true; //private_stream_2
+ Streams[0xBF].Searching_TimeStamp_End=true; //private_stream_2
+ for (int8u Pos=0xC0; Pos<=0xEF; Pos++)
+ {
+ Streams[Pos].Searching_Payload=true; //audio_stream or video_stream
+ Streams[Pos].Searching_TimeStamp_Start=true; //audio_stream or video_stream
+ Streams[Pos].Searching_TimeStamp_End=true; //audio_stream or video_stream
+ }
+ Streams[0xFA].Searching_Payload=true; //LATM
+ Streams[0xFA].Searching_TimeStamp_Start=true; //LATM
+ Streams[0xFA].Searching_TimeStamp_End=true; //LATM
+ Streams[0xFD].Searching_Payload=true; //extension_stream
+ Streams[0xFD].Searching_TimeStamp_Start=true; //extension_stream
+ Streams[0xFD].Searching_TimeStamp_End=true; //extension_stream
+ }
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpegPs::Read_Buffer_Init()
+{
+ #if MEDIAINFO_DEMUX
+ Demux_UnpacketizeContainer=Config->Demux_Unpacketize_Get();
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_MpegPs::Read_Buffer_Unsynched()
+{
+ Searching_TimeStamp_Start=false;
+
+ if (Streams.empty())
+ return;
+
+ //No need anymore of this Streams
+ Streams[0xBB].Searching_Payload=false; //system_start
+
+ //Reactivating interessant PS streams
+ for (size_t StreamID=0; StreamID<0x100; StreamID++)
+ {
+ //End timestamp is out of date
+ Streams[StreamID].TimeStamp_End.PTS.File_Pos=(int64u)-1;
+ Streams[StreamID].TimeStamp_End.DTS.File_Pos=(int64u)-1;
+ Streams[StreamID].TimeStamp_End.PTS.TimeStamp=(int64u)-1;
+ Streams[StreamID].TimeStamp_End.DTS.TimeStamp=(int64u)-1;
+ Streams[StreamID].Searching_TimeStamp_Start=false;
+ for (size_t Pos=0; Pos<Streams[StreamID].Parsers.size(); Pos++)
+ if (Streams[StreamID].Parsers[Pos])
+ {
+ #if MEDIAINFO_SEEK
+ if (IsSub)
+ Streams[StreamID].Parsers[Pos]->Unsynch_Frame_Count=Frame_Count_NotParsedIncluded;
+ #endif //MEDIAINFO_SEEK
+ Streams[StreamID].Parsers[Pos]->Open_Buffer_Unsynch();
+ }
+ Streams_Private1[StreamID].TimeStamp_End.PTS.File_Pos=(int64u)-1;
+ Streams_Private1[StreamID].TimeStamp_End.DTS.File_Pos=(int64u)-1;
+ Streams_Private1[StreamID].TimeStamp_End.PTS.TimeStamp=(int64u)-1;
+ Streams_Private1[StreamID].TimeStamp_End.DTS.TimeStamp=(int64u)-1;
+ Streams_Private1[StreamID].Searching_TimeStamp_Start=false;
+ for (size_t Pos=0; Pos<Streams_Private1[StreamID].Parsers.size(); Pos++)
+ if (Streams_Private1[StreamID].Parsers[Pos])
+ {
+ #if MEDIAINFO_SEEK
+ Streams_Private1[StreamID].Parsers[Pos]->Unsynch_Frame_Count=Unsynch_Frame_Count;
+ #endif //MEDIAINFO_SEEK
+ Streams_Private1[StreamID].Parsers[Pos]->Open_Buffer_Unsynch();
+ }
+ Streams_Extension[StreamID].TimeStamp_End.PTS.File_Pos=(int64u)-1;
+ Streams_Extension[StreamID].TimeStamp_End.DTS.File_Pos=(int64u)-1;
+ Streams_Extension[StreamID].TimeStamp_End.PTS.TimeStamp=(int64u)-1;
+ Streams_Extension[StreamID].TimeStamp_End.DTS.TimeStamp=(int64u)-1;
+ Streams_Extension[StreamID].Searching_TimeStamp_Start=false;
+ for (size_t Pos=0; Pos<Streams_Extension[StreamID].Parsers.size(); Pos++)
+ if (Streams_Extension[StreamID].Parsers[Pos])
+ {
+ #if MEDIAINFO_SEEK
+ Streams_Extension[StreamID].Parsers[Pos]->Unsynch_Frame_Count=Unsynch_Frame_Count;
+ #endif //MEDIAINFO_SEEK
+ Streams_Extension[StreamID].Parsers[Pos]->Open_Buffer_Unsynch();
+ }
+ }
+ #if MEDIAINFO_SEEK
+ Unsynch_Frame_Count=(int64u)-1; //We do not use it
+ #endif //MEDIAINFO_SEEK
+ video_stream_Unlimited=false;
+ Buffer_DataSizeToParse=0;
+ PES_FirstByte_IsAvailable=false;
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_MpegPs::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ //Reset
+ Seek_Value=(int64u)-1;
+ Seek_ID=(int64u)-1;
+
+ //Init
+ if (!Duration_Detected)
+ {
+ //External IBI
+ std::string IbiFile=Config->Ibi_Get();
+ if (!IbiFile.empty())
+ {
+ Ibi.Streams.clear(); //TODO: support IBI data from different inputs
+
+ File_Ibi MI;
+ Open_Buffer_Init(&MI, IbiFile.size());
+ MI.Ibi=&Ibi;
+ MI.Open_Buffer_Continue((const int8u*)IbiFile.c_str(), IbiFile.size());
+ }
+ //Creating base IBI from a quick analysis of the file
+ else
+ {
+ MediaInfo_Internal MI;
+ MI.Option(_T("File_KeepInfo"), _T("1"));
+ Ztring ParseSpeed_Save=MI.Option(_T("ParseSpeed_Get"), _T(""));
+ Ztring Demux_Save=MI.Option(_T("Demux_Get"), _T(""));
+ MI.Option(_T("ParseSpeed"), _T("0"));
+ MI.Option(_T("Demux"), Ztring());
+ size_t MiOpenResult=MI.Open(File_Name);
+ MI.Option(_T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
+ MI.Option(_T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
+ if (!MiOpenResult)
+ return 0;
+ for (ibi::streams::iterator IbiStream_Temp=((File_MpegPs*)MI.Info)->Ibi.Streams.begin(); IbiStream_Temp!=((File_MpegPs*)MI.Info)->Ibi.Streams.end(); IbiStream_Temp++)
+ {
+ if (Ibi.Streams[IbiStream_Temp->first]==NULL)
+ Ibi.Streams[IbiStream_Temp->first]=new ibi::stream(*IbiStream_Temp->second);
+ Ibi.Streams[IbiStream_Temp->first]->Unsynch();
+ for (size_t Pos=0; Pos<IbiStream_Temp->second->Infos.size(); Pos++)
+ {
+ Ibi.Streams[IbiStream_Temp->first]->Add(IbiStream_Temp->second->Infos[Pos]);
+ if (!IbiStream_Temp->second->Infos[Pos].IsContinuous)
+ Ibi.Streams[IbiStream_Temp->first]->Unsynch();
+ }
+ Ibi.Streams[IbiStream_Temp->first]->Unsynch();
+ }
+ if (Ibi.Streams.empty())
+ return 4; //Problem during IBI file parsing
+ }
+
+ Duration_Detected=true;
+ }
+
+ //Parsing
+ switch (Method)
+ {
+ case 0 :
+ GoTo(Value);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 1 :
+ GoTo(File_Size*Value/10000);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 2 : //Timestamp
+ #if MEDIAINFO_IBI
+ {
+ ibi::streams::iterator IbiStream_Temp;
+ if (ID==(int64u)-1)
+ IbiStream_Temp=Ibi.Streams.begin();
+ else
+ IbiStream_Temp=Ibi.Streams.find(ID);
+ if (IbiStream_Temp==Ibi.Streams.end() || IbiStream_Temp->second->Infos.empty())
+ return 5; //Invalid ID
+
+ if (!(IbiStream_Temp->second->DtsFrequencyNumerator==1000000000 && IbiStream_Temp->second->DtsFrequencyDenominator==1))
+ {
+ float64 ValueF=(float64)Value;
+ ValueF/=1000000000; //Value is in ns
+ ValueF/=IbiStream_Temp->second->DtsFrequencyDenominator;
+ ValueF*=IbiStream_Temp->second->DtsFrequencyNumerator;
+ Value=float64_int64s(ValueF);
+ }
+
+ for (size_t Pos=0; Pos<IbiStream_Temp->second->Infos.size(); Pos++)
+ {
+ if (Value<=IbiStream_Temp->second->Infos[Pos].Dts)
+ {
+ if (Value<IbiStream_Temp->second->Infos[Pos].Dts && Pos)
+ Pos--;
+
+ //Checking continuity of Ibi
+ if (!IbiStream_Temp->second->Infos[Pos].IsContinuous && Pos+1<IbiStream_Temp->second->Infos.size())
+ {
+ Config->Demux_IsSeeking=true;
+ Seek_Value=Value;
+ Seek_Value_Maximal=IbiStream_Temp->second->Infos[Pos+1].StreamOffset;
+ Seek_ID=IbiStream_Temp->first;
+ GoTo((IbiStream_Temp->second->Infos[Pos].StreamOffset+IbiStream_Temp->second->Infos[Pos+1].StreamOffset)/2);
+ Open_Buffer_Unsynch();
+
+ return 1;
+ }
+
+ Config->Demux_IsSeeking=false;
+ if (!Streams[(size_t)IbiStream_Temp->first].Parsers.empty())
+ for (size_t Parser_Pos=0; Parser_Pos<Streams[(size_t)IbiStream_Temp->first].Parsers.size(); Parser_Pos++)
+ Streams[(size_t)IbiStream_Temp->first].Parsers[Parser_Pos]->Unsynch_Frame_Count=IbiStream_Temp->second->Infos[Pos].FrameNumber;
+ else
+ Unsynch_Frame_Counts[(int16u)IbiStream_Temp->first]=IbiStream_Temp->second->Infos[Pos].FrameNumber;
+
+ GoTo(IbiStream_Temp->second->Infos[Pos].StreamOffset);
+ Open_Buffer_Unsynch();
+
+ return 1;
+ }
+ }
+
+ return 2; //Invalid value
+ }
+ #else //MEDIAINFO_IBI
+ return (size_t)-2; //Not supported / IBI disabled
+ #endif //MEDIAINFO_IBI
+ case 3 : //FrameNumber
+ #if MEDIAINFO_IBI
+ {
+ ibi::streams::iterator IbiStream_Temp;
+ if (ID==(int64u)-1)
+ IbiStream_Temp=Ibi.Streams.begin();
+ else
+ IbiStream_Temp=Ibi.Streams.find(ID);
+ if (IbiStream_Temp==Ibi.Streams.end() || IbiStream_Temp->second->Infos.empty())
+ return 5; //Invalid ID
+
+ for (size_t Pos=0; Pos<IbiStream_Temp->second->Infos.size(); Pos++)
+ {
+ if (Value<=IbiStream_Temp->second->Infos[Pos].FrameNumber)
+ {
+ if (Value<IbiStream_Temp->second->Infos[Pos].FrameNumber && Pos)
+ Pos--;
+
+ if (!Streams[(size_t)IbiStream_Temp->first].Parsers.empty())
+ for (size_t Parser_Pos=0; Parser_Pos<Streams[(size_t)IbiStream_Temp->first].Parsers.size(); Parser_Pos++)
+ Streams[(size_t)IbiStream_Temp->first].Parsers[Parser_Pos]->Unsynch_Frame_Count=IbiStream_Temp->second->Infos[Pos].FrameNumber;
+ else
+ Unsynch_Frame_Counts[(int16u)IbiStream_Temp->first]=IbiStream_Temp->second->Infos[Pos].FrameNumber;
+
+ GoTo(IbiStream_Temp->second->Infos[Pos].StreamOffset);
+ Open_Buffer_Unsynch();
+
+ return 1;
+ }
+ }
+
+ return 2; //Invalid value
+ }
+ #else //MEDIAINFO_IBI
+ return (size_t)-2; //Not supported / IBI disabled
+ #endif //MEDIAINFO_IBI
+ default : return (size_t)-1; //Not supported
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//---------------------------------------------------------------------------
+void File_MpegPs::Read_Buffer_Continue()
+{
+ #if MEDIAINFO_DEMUX
+ if (Demux_StreamIsBeingParsed_type!=(int8u)-1)
+ {
+ switch (Demux_StreamIsBeingParsed_type) //TODO: transform the switch() case to a enum with a vector of streams
+ {
+ case 0 : Open_Buffer_Continue(Streams[Demux_StreamIsBeingParsed_stream_id].Parsers[0], Buffer, 0);
+ if (IsSub && Streams[Demux_StreamIsBeingParsed_stream_id].Parsers[0]->Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded=Streams[Demux_StreamIsBeingParsed_stream_id].Parsers[0]->Frame_Count_NotParsedIncluded;
+ break;
+ case 1 : Open_Buffer_Continue(Streams_Private1[Demux_StreamIsBeingParsed_stream_id].Parsers[0], Buffer, 0);
+ if (IsSub && Streams_Private1[Demux_StreamIsBeingParsed_stream_id].Parsers[0]->Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded=Streams_Private1[Demux_StreamIsBeingParsed_stream_id].Parsers[0]->Frame_Count_NotParsedIncluded;
+ break;
+ case 2 : Open_Buffer_Continue(Streams_Extension[Demux_StreamIsBeingParsed_stream_id].Parsers[0], Buffer, 0);
+ if (IsSub && Streams_Extension[Demux_StreamIsBeingParsed_stream_id].Parsers[0]->Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded=Streams_Extension[Demux_StreamIsBeingParsed_stream_id].Parsers[0]->Frame_Count_NotParsedIncluded;
+ break;
+ default: ;
+ }
+ if (Config->Demux_EventWasSent)
+ return;
+ Demux_StreamIsBeingParsed_type=(int8u)-1;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ if (!IsSub)
+ {
+ if (Config_ParseSpeed>=1.0)
+ Config->State_Set(((float)Buffer_TotalBytes)/File_Size);
+ else if (Buffer_TotalBytes>2*SizeToAnalyze)
+ Config->State_Set((float)0.99); //Nearly the end
+ else
+ Config->State_Set(((float)Buffer_TotalBytes)/(2*SizeToAnalyze));
+ }
+
+ if (Buffer_DataSizeToParse)
+ {
+ if (Buffer_Size<=Buffer_DataSizeToParse)
+ {
+ Element_Size=Buffer_Size; //All the buffer is used
+ Buffer_DataSizeToParse-=(int16u)Buffer_Size;
+ }
+ else
+ {
+ Element_Size=Buffer_DataSizeToParse;
+ Buffer_DataSizeToParse=0;
+ }
+
+ Element_Begin0();
+ Data_Parse();
+ Element_Offset=Element_Size;
+ Element_End0();
+ }
+
+ //Video unlimited specific, we didn't wait for the end (because this is... unlimited)
+ if (video_stream_Unlimited)
+ {
+ PES_FirstByte_IsAvailable=true;
+ PES_FirstByte_Value=false;
+
+ //Look for next Sync word
+ size_t Buffer_Offset_Temp=0;
+ while (Buffer_Offset_Temp+4<=Buffer_Size
+ && (Buffer[Buffer_Offset_Temp ]!=0x00
+ || Buffer[Buffer_Offset_Temp+1]!=0x00
+ || Buffer[Buffer_Offset_Temp+2]!=0x01
+ || Buffer[Buffer_Offset_Temp+3]< 0xB9))
+ {
+ Buffer_Offset_Temp+=2;
+ while(Buffer_Offset_Temp<Buffer_Size && Buffer[Buffer_Offset_Temp]!=0x00)
+ Buffer_Offset_Temp+=2;
+ if (Buffer_Offset_Temp>=Buffer_Size || Buffer[Buffer_Offset_Temp-1]==0x00)
+ Buffer_Offset_Temp--;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset_Temp+4==Buffer_Size && (Buffer[Buffer_Offset_Temp ]!=0x00
+ || Buffer[Buffer_Offset_Temp+1]!=0x00
+ || Buffer[Buffer_Offset_Temp+2]!=0x01))
+ Buffer_Offset_Temp++;
+ if (Buffer_Offset_Temp+3==Buffer_Size && (Buffer[Buffer_Offset_Temp ]!=0x00
+ || Buffer[Buffer_Offset_Temp+1]!=0x00
+ || Buffer[Buffer_Offset_Temp+2]!=0x01))
+ Buffer_Offset_Temp++;
+ if (Buffer_Offset_Temp+2==Buffer_Size && (Buffer[Buffer_Offset_Temp ]!=0x00
+ || Buffer[Buffer_Offset_Temp+1]!=0x00))
+ Buffer_Offset_Temp++;
+ if (Buffer_Offset_Temp+1==Buffer_Size && Buffer[Buffer_Offset_Temp ]!=0x00)
+ Buffer_Offset_Temp++;
+
+ if (Buffer_Offset_Temp==Buffer_Size)
+ {
+ Element_Size=Buffer_Size; //All the buffer is used
+ }
+ else
+ {
+ Element_Size=Buffer_Offset_Temp;
+ if (Buffer_Offset_Temp+4<=Buffer_Size)
+ video_stream_Unlimited=false;
+ else
+ Element_IsWaitingForMoreData(); //We don't know if the next bytes are a stream_id or data
+ }
+
+ Element_Begin0();
+ Data_Parse();
+ Element_Offset=Element_Size;
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_MpegPs::Read_Buffer_AfterParsing()
+{
+ if (!Status[IsFilled])
+ {
+ //In case of problem with some streams
+ if (Buffer_TotalBytes>Buffer_TotalBytes_FirstSynched+SizeToAnalyze)
+ {
+ if (!Status[IsAccepted])
+ {
+ Reject("MPEG-PS");
+ return;
+ }
+
+ video_stream_Count=0;
+ audio_stream_Count=0;
+ private_stream_1_Count=0;
+ private_stream_2_Count=false;
+ extension_stream_Count=0;
+ SL_packetized_stream_Count=false;
+ }
+
+ //Jumping only if needed
+ if (Streams.empty() || video_stream_Count || audio_stream_Count || private_stream_1_Count || private_stream_2_Count || extension_stream_Count || SL_packetized_stream_Count)
+ return;
+
+ //Jumping if needed
+ if (!Status[IsAccepted])
+ {
+ Accept("MPEG-PS");
+ if (!IsSub)
+ Fill(Stream_General, 0, General_Format, "MPEG-PS");
+ }
+ Fill("MPEG-PS");
+ if (!ShouldContinueParsing && File_Offset+Buffer_Size+SizeToAnalyze<File_Size && Config_ParseSpeed<1.0)
+ {
+ //Jumping
+ GoToFromEnd(SizeToAnalyze, "MPEG-PS");
+ Open_Buffer_Unsynch();
+ }
+ }
+}
+
+//***************************************************************************
+// Buffer - Par element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpegPs::Header_Parse()
+{
+ PES_FirstByte_IsAvailable=true;
+ PES_FirstByte_Value=true;
+
+ //Reinit
+ FrameInfo.PTS=(int64u)-1;
+ FrameInfo.DTS=(int64u)-1;
+
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ //Parsing
+ Skip_B3( "synchro");
+ Get_B1 (stream_id, "stream_id");
+ }
+ else
+ {
+ #endif //MEDIAINFO_TRACE
+ //Parsing
+ stream_id=Buffer[Buffer_Offset+3];
+ Element_Offset+=4;
+ #if MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_TRACE
+
+ if (stream_id!=0xB9 && stream_id!=0xBA) //MPEG_program_end or pack_start have no PES
+ {
+ if (!Header_Parse_PES_packet(stream_id))
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ }
+ else if (!Header_Parse_Fill_Size()) //MPEG_program_end or pack_start specific
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ Header_Fill_Code(stream_id);
+}
+
+//---------------------------------------------------------------------------
+bool File_MpegPs::Header_Parse_Fill_Size()
+{
+ //Look for next Sync word
+ if (Buffer_Offset_Temp==0) //Buffer_Offset_Temp is not 0 if Header_Parse_Fill_Size() has already parsed first frames
+ Buffer_Offset_Temp=Buffer_Offset+4;
+ while (Buffer_Offset_Temp+4<=Buffer_Size
+ && (Buffer[Buffer_Offset_Temp ]!=0x00
+ || Buffer[Buffer_Offset_Temp+1]!=0x00
+ || Buffer[Buffer_Offset_Temp+2]!=0x01
+ || Buffer[Buffer_Offset_Temp+3]< 0xB9))
+ {
+ Buffer_Offset_Temp+=2;
+ while(Buffer_Offset_Temp<Buffer_Size && Buffer[Buffer_Offset_Temp]!=0x00)
+ Buffer_Offset_Temp+=2;
+ if (Buffer_Offset_Temp>=Buffer_Size || Buffer[Buffer_Offset_Temp-1]==0x00)
+ Buffer_Offset_Temp--;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset_Temp+4==Buffer_Size && (Buffer[Buffer_Offset_Temp ]!=0x00
+ || Buffer[Buffer_Offset_Temp+1]!=0x00
+ || Buffer[Buffer_Offset_Temp+2]!=0x01))
+ Buffer_Offset_Temp++;
+ if (Buffer_Offset_Temp+3==Buffer_Size && (Buffer[Buffer_Offset_Temp ]!=0x00
+ || Buffer[Buffer_Offset_Temp+1]!=0x00
+ || Buffer[Buffer_Offset_Temp+2]!=0x01))
+ Buffer_Offset_Temp++;
+ if (Buffer_Offset_Temp+2==Buffer_Size && (Buffer[Buffer_Offset_Temp ]!=0x00
+ || Buffer[Buffer_Offset_Temp+1]!=0x00))
+ Buffer_Offset_Temp++;
+ if (Buffer_Offset_Temp+1==Buffer_Size && Buffer[Buffer_Offset_Temp ]!=0x00)
+ Buffer_Offset_Temp++;
+
+ if (Buffer_Offset_Temp+4>Buffer_Size)
+ {
+ if (File_Offset+Buffer_Size>=File_Size)
+ Buffer_Offset_Temp=Buffer_Size; //We are sure that the next bytes are a start
+ else
+ return false;
+ }
+
+ //OK, we continue
+ Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset);
+ Buffer_Offset_Temp=0;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_MpegPs::Header_Parse_PES_packet(int8u stream_id)
+{
+ //Parsing
+ int16u PES_packet_length;
+ Get_B2 (PES_packet_length, "PES_packet_length");
+ if (PES_packet_length && File_Offset+Buffer_Offset+6+PES_packet_length>=File_Size)
+ PES_packet_length=(int16u)(File_Size-(File_Offset+Buffer_Offset+6));
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer && Buffer_Offset+6+PES_packet_length>Buffer_Size)
+ return false;
+ #endif //MEDIAINFO_DEMUX
+
+ //Parsing
+ switch (stream_id)
+ {
+ //Header is only Size
+ case 0xBB : //system_header_start
+ case 0xBC : //program_stream_map
+ case 0xBE : //padding_stream
+ case 0xBF : //private_stream_2
+ case 0xF0 : //ECM
+ case 0xF1 : //EMM
+ case 0xF2 : //DSMCC Streams
+ case 0xF8 : //ITU-T Rec. H .222.1 type E
+ case 0xFF : //Program Streams directory
+ break;
+
+ //Element with PES Header
+ default :
+ switch (MPEG_Version)
+ {
+ case 1 : Header_Parse_PES_packet_MPEG1(stream_id); break;
+ case 2 : Header_Parse_PES_packet_MPEG2(stream_id); break;
+ default : ; //We don't know what to parse...
+ }
+ }
+
+ //Video unlimited specific
+ if (PES_packet_length==0 || File_Offset+Buffer_Size>=File_Size)
+ {
+ if (!Header_Parse_Fill_Size())
+ {
+ //Return directly if we must unpack the elementary stream;
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer)
+ return false;
+ #endif //MEDIAINFO_DEMUX
+
+ //Next PS packet is not found, we will use all the buffer
+ Header_Fill_Size(Buffer_Size-Buffer_Offset); //All the buffer is used
+ video_stream_Unlimited=true;
+ Buffer_Offset_Temp=0; //We use the buffer
+ }
+ }
+ else
+ //Filling
+ Header_Fill_Size(6+PES_packet_length);
+
+ //Can be cut in small chunks
+ if (Element_IsWaitingForMoreData())
+ return false;
+ if (PES_packet_length!=0 && Element_Offset<Element_Size && (size_t)(6+PES_packet_length)>Buffer_Size-Buffer_Offset
+ && ((stream_id&0xE0)==0xC0 || (stream_id&0xF0)==0xE0))
+ {
+ //Return directly if we must unpack the elementary stream;
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer)
+ return false;
+ #endif //MEDIAINFO_DEMUX
+
+ Header_Fill_Size(Buffer_Size-Buffer_Offset); //All the buffer is used
+ Buffer_DataSizeToParse=6+PES_packet_length-(int16u)(Buffer_Size-Buffer_Offset);
+ Buffer_Offset_Temp=0; //We use the buffer
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+// Packet header data - MPEG-1
+void File_MpegPs::Header_Parse_PES_packet_MPEG1(int8u stream_id)
+{
+ int8u stuffing_byte;
+ do
+ {
+ Peek_B1(stuffing_byte);
+ if (stuffing_byte==0xFF)
+ Skip_B1( "stuffing_byte");
+ }
+ while(stuffing_byte==0xFF);
+
+ if ((stuffing_byte&0xC0)==0x40)
+ {
+ BS_Begin();
+ Mark_0();
+ Mark_1();
+ Skip_SB( "STD_buffer_scale");
+ Skip_S2(13, "STD_buffer_size");
+ BS_End();
+ Peek_B1(stuffing_byte);
+ }
+ if ((stuffing_byte&0xF0)==0x20)
+ {
+ int16u PTS_29, PTS_14;
+ int8u PTS_32;
+ Element_Begin1("PTS");
+ BS_Begin();
+ Mark_0();
+ Mark_0();
+ Mark_1();
+ Mark_0();
+ Get_S1 ( 3, PTS_32, "PTS_32");
+ Mark_1_NoTrustError(); //Found 0 in one file
+ Get_S2 (15, PTS_29, "PTS_29");
+ Mark_1();
+ Get_S2 (15, PTS_14, "PTS_14");
+ Mark_1();
+ BS_End();
+
+ //Filling
+ FrameInfo.PTS=(((int64u)PTS_32)<<30)
+ | (((int64u)PTS_29)<<15)
+ | (((int64u)PTS_14));
+ if (Streams[stream_id].Searching_TimeStamp_End && stream_id!=0xBD && stream_id!=0xFD) //0xBD and 0xFD can contain multiple streams, TimeStamp management is in Streams management
+ {
+ if (Streams[stream_id].TimeStamp_End.PTS.TimeStamp==(int64u)-1)
+ Streams[stream_id].TimeStamp_End.PTS.TimeStamp=FrameInfo.PTS;
+ while (FrameInfo.PTS+0x100000000LL<Streams[stream_id].TimeStamp_End.PTS.TimeStamp)
+ FrameInfo.PTS+=0x200000000LL;
+ Streams[stream_id].TimeStamp_End.PTS.File_Pos=File_Offset+Buffer_Offset;
+ Streams[stream_id].TimeStamp_End.PTS.TimeStamp=FrameInfo.PTS;
+ }
+ if (Searching_TimeStamp_Start && Streams[stream_id].Searching_TimeStamp_Start && stream_id!=0xBD && stream_id!=0xFD) //0xBD and 0xFD can contain multiple streams, TimeStamp management is in Streams management
+ {
+ Streams[stream_id].TimeStamp_Start.PTS.TimeStamp=FrameInfo.PTS;
+ Streams[stream_id].Searching_TimeStamp_Start=false;
+ }
+ Element_Info_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/90));
+ FrameInfo.DTS=FrameInfo.PTS=FrameInfo.PTS*1000000/90; //In ns
+ HasTimeStamps=true;
+ Element_End0();
+ }
+ else if ((stuffing_byte&0xF0)==0x30)
+ {
+ int16u PTS_29, PTS_14, DTS_29, DTS_14;
+ int8u PTS_32, DTS_32;
+ Element_Begin1("PTS");
+ BS_Begin();
+ Mark_0();
+ Mark_0();
+ Mark_1();
+ Mark_1();
+ Get_S1 ( 3, PTS_32, "PTS_32");
+ Mark_1_NoTrustError(); //Found 0 in one file
+ Get_S2 (15, PTS_29, "PTS_29");
+ Mark_1();
+ Get_S2 (15, PTS_14, "PTS_14");
+ Mark_1();
+ BS_End();
+
+ //Filling
+ FrameInfo.PTS=(((int64u)PTS_32)<<30)
+ | (((int64u)PTS_29)<<15)
+ | (((int64u)PTS_14));
+ if (Streams[stream_id].Searching_TimeStamp_End)
+ {
+ if (Streams[stream_id].TimeStamp_End.PTS.TimeStamp==(int64u)-1)
+ Streams[stream_id].TimeStamp_End.PTS.TimeStamp=FrameInfo.PTS;
+ while (FrameInfo.PTS+0x100000000LL<Streams[stream_id].TimeStamp_End.PTS.TimeStamp)
+ FrameInfo.PTS+=0x200000000LL;
+ Streams[stream_id].TimeStamp_End.PTS.File_Pos=File_Offset+Buffer_Offset;
+ Streams[stream_id].TimeStamp_End.PTS.TimeStamp=FrameInfo.PTS;
+ }
+ if (Searching_TimeStamp_Start && Streams[stream_id].Searching_TimeStamp_Start)
+ {
+ Streams[stream_id].TimeStamp_Start.PTS.TimeStamp=FrameInfo.PTS;
+ }
+ Element_Info_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/90));
+ FrameInfo.PTS=FrameInfo.PTS*1000000/90; //In ns
+ Element_End0();
+
+ Element_Begin1("DTS");
+ BS_Begin();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_1_NoTrustError(); //Is "0" in one sample
+ Get_S1 ( 3, DTS_32, "DTS_32");
+ Mark_1();
+ Get_S2 (15, DTS_29, "DTS_29");
+ Mark_1();
+ Get_S2 (15, DTS_14, "DTS_14");
+ Mark_1();
+ BS_End();
+
+ //Filling
+ FrameInfo.DTS=(((int64u)DTS_32)<<30)
+ | (((int64u)DTS_29)<<15)
+ | (((int64u)DTS_14));
+ if (Streams[stream_id].Searching_TimeStamp_End)
+ {
+ if (Streams[stream_id].TimeStamp_End.DTS.TimeStamp==(int64u)-1)
+ Streams[stream_id].TimeStamp_End.DTS.TimeStamp=FrameInfo.DTS;
+ while (FrameInfo.DTS+0x100000000LL<Streams[stream_id].TimeStamp_End.DTS.TimeStamp)
+ FrameInfo.DTS+=0x200000000LL;
+ Streams[stream_id].TimeStamp_End.DTS.File_Pos=File_Offset+Buffer_Offset;
+ Streams[stream_id].TimeStamp_End.DTS.TimeStamp=FrameInfo.DTS;
+ }
+ if (Searching_TimeStamp_Start && Streams[stream_id].Searching_TimeStamp_Start)
+ {
+ Streams[stream_id].TimeStamp_Start.DTS.TimeStamp=FrameInfo.DTS;
+ Streams[stream_id].Searching_TimeStamp_Start=false;
+ }
+ Element_Info_From_Milliseconds(float64_int64s(((float64)FrameInfo.DTS)/90));
+ FrameInfo.DTS=FrameInfo.DTS*1000000/90; //In ns
+ Element_End0();
+ }
+ else
+ {
+ BS_Begin();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ BS_End();
+
+ if (!FromTS)
+ PES_FirstByte_Value=false;
+ }
+}
+
+//---------------------------------------------------------------------------
+// Packet header data - MPEG-2
+void File_MpegPs::Header_Parse_PES_packet_MPEG2(int8u stream_id)
+{
+ //Parsing
+ int8u PTS_DTS_flags, PES_header_data_length;
+ bool ESCR_flag, ES_rate_flag, DSM_trick_mode_flag, additional_copy_info_flag, PES_CRC_flag, PES_extension_flag;
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ BS_Begin();
+ Mark_1_NoTrustError();
+ Mark_0_NoTrustError();
+ Skip_S1(2, "PES_scrambling_control");
+ Skip_SB( "PES_priority");
+ Skip_SB( "data_alignment_indicator");
+ Skip_SB( "copyright");
+ Skip_SB( "original_or_copy");
+ Get_S1 (2, PTS_DTS_flags, "PTS_DTS_flags");
+ Get_SB (ESCR_flag, "ESCR_flag");
+ Get_SB (ES_rate_flag, "ES_rate_flag");
+ Get_SB (DSM_trick_mode_flag, "DSM_trick_mode_flag");
+ Get_SB (additional_copy_info_flag, "additional_copy_info_flag");
+ Get_SB (PES_CRC_flag, "PES_CRC_flag");
+ Get_SB (PES_extension_flag, "PES_extension_flag");
+ BS_End();
+ Get_B1 (PES_header_data_length, "PES_header_data_length");
+ }
+ else
+ {
+ #endif //MEDIAINFO_TRACE
+ if (Element_Offset+3>=Element_Size)
+ {
+ Trusted_IsNot("");
+ return;
+ }
+ size_t Buffer_Pos_Flags=Buffer_Offset+(size_t)Element_Offset;
+ if ((Buffer[Buffer_Pos_Flags]&0xC0)!=0x80) //bit 6 and 7 are 01
+ {
+ Element_DoNotTrust(""); //Mark bits are wrong
+ return;
+ }
+ Buffer_Pos_Flags++;
+ PTS_DTS_flags =Buffer[Buffer_Pos_Flags]>>6;
+ ESCR_flag =Buffer[Buffer_Pos_Flags]&0x20?true:false;
+ ES_rate_flag =Buffer[Buffer_Pos_Flags]&0x10?true:false;
+ DSM_trick_mode_flag =Buffer[Buffer_Pos_Flags]&0x08?true:false;
+ additional_copy_info_flag =Buffer[Buffer_Pos_Flags]&0x04?true:false;
+ PES_CRC_flag =Buffer[Buffer_Pos_Flags]&0x02?true:false;
+ PES_extension_flag =Buffer[Buffer_Pos_Flags]&0x01?true:false;
+ Buffer_Pos_Flags++;
+ PES_header_data_length =Buffer[Buffer_Pos_Flags];
+ Element_Offset+=3;
+ #if MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_TRACE
+ int64u Element_Pos_After_Data=Element_Offset+PES_header_data_length;
+ if (Element_Pos_After_Data>Element_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ //Options
+ if (PTS_DTS_flags==0x2)
+ {
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ int16u PTS_29, PTS_14;
+ int8u PTS_32;
+ Element_Begin1("PTS_DTS_flags");
+ Element_Begin1("PTS");
+ BS_Begin();
+ Mark_0();
+ Mark_0();
+ Mark_1_NoTrustError(); //Is "0" in one sample
+ Mark_0_NoTrustError(); //Is "1" in one sample
+ Get_S1 ( 3, PTS_32, "PTS_32");
+ Mark_1();
+ Get_S2 (15, PTS_29, "PTS_29");
+ Mark_1();
+ Get_S2 (15, PTS_14, "PTS_14");
+ Mark_1();
+ BS_End();
+ FrameInfo.PTS=(((int64u)PTS_32)<<30)
+ | (((int64u)PTS_29)<<15)
+ | (((int64u)PTS_14));
+ Element_Info_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/90));
+ Element_End0();
+ Element_End0();
+ }
+ else
+ {
+ #endif //MEDIAINFO_TRACE
+ if (Element_Offset+5>Element_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+ if ((Buffer[Buffer_Pos ]&0xC1)!=0x01 //bit 5 and 4 are not tested because of one sample with wrong mark bits
+ || (Buffer[Buffer_Pos+2]&0x01)!=0x01
+ || (Buffer[Buffer_Pos+4]&0x01)!=0x01)
+ {
+ Element_DoNotTrust(""); //Mark bits are wrong
+ return;
+ }
+ FrameInfo.PTS= ((((int64u)Buffer[Buffer_Pos ]&0x0E))<<29)
+ | ( ((int64u)Buffer[Buffer_Pos+1] )<<22)|((((int64u)Buffer[Buffer_Pos+2]&0xFE))<<14)
+ | ( ((int64u)Buffer[Buffer_Pos+3] )<< 7)|((((int64u)Buffer[Buffer_Pos+4]&0xFE))>> 1);
+ Element_Offset+=5;
+ #if MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_TRACE
+
+ //Filling
+ if (Streams[stream_id].Searching_TimeStamp_End)
+ {
+ if (Streams[stream_id].TimeStamp_End.PTS.TimeStamp==(int64u)-1)
+ Streams[stream_id].TimeStamp_End.PTS.TimeStamp=FrameInfo.PTS;
+ while (FrameInfo.PTS+0x100000000LL<Streams[stream_id].TimeStamp_End.PTS.TimeStamp)
+ FrameInfo.PTS+=0x200000000LL;
+ Streams[stream_id].TimeStamp_End.PTS.File_Pos=File_Offset+Buffer_Offset;
+ Streams[stream_id].TimeStamp_End.PTS.TimeStamp=FrameInfo.PTS;
+ }
+ if (Searching_TimeStamp_Start && Streams[stream_id].Searching_TimeStamp_Start)
+ {
+ Streams[stream_id].TimeStamp_Start.PTS.TimeStamp=FrameInfo.PTS;
+ Streams[stream_id].Searching_TimeStamp_Start=false;
+ }
+ FrameInfo.DTS=FrameInfo.PTS=FrameInfo.PTS*1000000/90; //In ns
+ HasTimeStamps=true;
+ }
+ else if (PTS_DTS_flags==0x3)
+ {
+ size_t Buffer_Pos;
+ #if MEDIAINFO_TRACE
+ int16u PTS_29, PTS_14, DTS_29, DTS_14;
+ int8u PTS_32, DTS_32;
+ if (Trace_Activated)
+ {
+ Element_Begin1("PTS_DTS_flags");
+ Element_Begin1("PTS");
+ BS_Begin();
+ Mark_0();
+ Mark_0();
+ Mark_1_NoTrustError(); //Is "0" in one sample
+ Mark_0_NoTrustError(); //Is "1" in one sample
+ Get_S1 ( 3, PTS_32, "PTS_32");
+ Mark_1();
+ Get_S2 (15, PTS_29, "PTS_29");
+ Mark_1();
+ Get_S2 (15, PTS_14, "PTS_14");
+ Mark_1();
+ BS_End();
+ FrameInfo.PTS=(((int64u)PTS_32)<<30)
+ | (((int64u)PTS_29)<<15)
+ | (((int64u)PTS_14));
+ Element_Info_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/90));
+ Element_End0();
+ }
+ else
+ {
+ #endif //MEDIAINFO_TRACE
+ if (Element_Offset+5>Element_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+ if ((Buffer[Buffer_Pos ]&0xC1)!=0x01 //bit 5 and 4 are not tested because of one sample with wrong mark bits
+ || (Buffer[Buffer_Pos+2]&0x01)!=0x01
+ || (Buffer[Buffer_Pos+4]&0x01)!=0x01)
+ {
+ Element_DoNotTrust(""); //Mark bits are wrong
+ return;
+ }
+ FrameInfo.PTS= ((((int64u)Buffer[Buffer_Pos ]&0x0E))<<29)
+ | ( ((int64u)Buffer[Buffer_Pos+1] )<<22)|((((int64u)Buffer[Buffer_Pos+2]&0xFE))<<14)
+ | ( ((int64u)Buffer[Buffer_Pos+3] )<< 7)|((((int64u)Buffer[Buffer_Pos+4]&0xFE))>> 1);
+ Element_Offset+=5;
+ #if MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_TRACE
+
+ //Filling
+ if (Streams[stream_id].Searching_TimeStamp_End)
+ {
+ if (Streams[stream_id].TimeStamp_End.PTS.TimeStamp==(int64u)-1)
+ Streams[stream_id].TimeStamp_End.PTS.TimeStamp=FrameInfo.PTS;
+ while (FrameInfo.PTS+0x100000000LL<Streams[stream_id].TimeStamp_End.PTS.TimeStamp)
+ FrameInfo.PTS+=0x200000000LL;
+ Streams[stream_id].TimeStamp_End.PTS.File_Pos=File_Offset+Buffer_Offset;
+ Streams[stream_id].TimeStamp_End.PTS.TimeStamp=FrameInfo.PTS;
+ }
+ if (Searching_TimeStamp_Start && Streams[stream_id].Searching_TimeStamp_Start)
+ {
+ Streams[stream_id].TimeStamp_Start.PTS.TimeStamp=FrameInfo.PTS;
+ //Streams[stream_id].Searching_TimeStamp_Start=false; //Done with DTS
+ }
+ FrameInfo.PTS=FrameInfo.PTS*1000000/90; //In ns
+
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ Element_Begin1("DTS");
+ BS_Begin();
+ Mark_0();
+ Mark_0();
+ Mark_1_NoTrustError(); //Is "0" in one sample
+ Mark_0_NoTrustError(); //Is "1" in one sample
+ Get_S1 ( 3, DTS_32, "DTS_32");
+ Mark_1();
+ Get_S2 (15, DTS_29, "DTS_29");
+ Mark_1();
+ Get_S2 (15, DTS_14, "DTS_14");
+ Mark_1();
+ BS_End();
+ FrameInfo.DTS=(((int64u)DTS_32)<<30)
+ | (((int64u)DTS_29)<<15)
+ | (((int64u)DTS_14));
+ Element_Info_From_Milliseconds(float64_int64s(((float64)FrameInfo.DTS)/90));
+ Element_End0();
+ Element_End0();
+ }
+ else
+ {
+ #endif //MEDIAINFO_TRACE
+ if (Element_Offset+5>Element_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+ if ((Buffer[Buffer_Pos ]&0xC1)!=0x01 //bit 5 and 4 are not tested because of one sample with wrong mark bits
+ || (Buffer[Buffer_Pos+2]&0x01)!=0x01
+ || (Buffer[Buffer_Pos+4]&0x01)!=0x01)
+ {
+ Element_DoNotTrust(""); //Mark bits are wrong
+ return;
+ }
+ FrameInfo.DTS= ((((int64u)Buffer[Buffer_Pos ]&0x0E))<<29)
+ | ( ((int64u)Buffer[Buffer_Pos+1] )<<22)|((((int64u)Buffer[Buffer_Pos+2]&0xFE))<<14)
+ | ( ((int64u)Buffer[Buffer_Pos+3] )<< 7)|((((int64u)Buffer[Buffer_Pos+4]&0xFE))>> 1);
+ Element_Offset+=5;
+ #if MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_TRACE
+
+ //Filling
+ if (Streams[stream_id].Searching_TimeStamp_End)
+ {
+ if (Streams[stream_id].TimeStamp_End.DTS.TimeStamp==(int64u)-1)
+ Streams[stream_id].TimeStamp_End.DTS.TimeStamp=FrameInfo.DTS;
+ while (FrameInfo.DTS+0x100000000LL<Streams[stream_id].TimeStamp_End.DTS.TimeStamp)
+ FrameInfo.DTS+=0x200000000LL;
+ Streams[stream_id].TimeStamp_End.DTS.File_Pos=File_Offset+Buffer_Offset;
+ Streams[stream_id].TimeStamp_End.DTS.TimeStamp=FrameInfo.DTS;
+ }
+ if (Searching_TimeStamp_Start && Streams[stream_id].Searching_TimeStamp_Start)
+ {
+ Streams[stream_id].TimeStamp_Start.DTS.TimeStamp=FrameInfo.DTS;
+ Streams[stream_id].Searching_TimeStamp_Start=false;
+ }
+ FrameInfo.DTS=FrameInfo.DTS*1000000/90; //In ns
+ HasTimeStamps=true;
+ }
+ else if (!FromTS)
+ PES_FirstByte_Value=false;
+ if (ESCR_flag && Element_Offset<Element_Pos_After_Data)
+ {
+ Element_Begin1("ESCR_flag");
+ BS_Begin();
+ int16u ESCR_29, ESCR_14, ESCR_extension;
+ int8u ESCR_32;
+ Skip_S1( 2, "reserved");
+ Get_S1 ( 3, ESCR_32, "PTS_32");
+ Mark_1();
+ Get_S2 (15, ESCR_29, "PTS_29");
+ Mark_1();
+ Get_S2 (15, ESCR_14, "PTS_14");
+ Mark_1();
+ Get_S2 (15, ESCR_extension, "ESCR_extension");
+ Mark_1();
+ BS_End();
+ Element_End0();
+ }
+ if (ES_rate_flag && Element_Offset<Element_Pos_After_Data)
+ {
+ Element_Begin1("ES_rate_flag");
+ BS_Begin();
+ int32u ES_rate;
+ Mark_1();
+ Get_S3 (22, ES_rate, "ES_rate");
+ Mark_1();
+ BS_End();
+ Element_End0();
+ }
+ if (DSM_trick_mode_flag && Element_Offset<Element_Pos_After_Data)
+ {
+ Element_Begin1("DSM_trick_mode_flag");
+ BS_Begin();
+ int8u trick_mode_control;
+ Get_S1 (3, trick_mode_control, "trick_mode_control"); Param_Info1(MpegPs_trick_mode_control_values[trick_mode_control]);
+ switch (trick_mode_control)
+ {
+ case 0 :{ //fast_forward
+ Skip_S1(2, "field_id");
+ Skip_SB( "intra_slice_refresh");
+ Skip_S1(2, "frequency_truncation");
+ }
+ break;
+ case 1 :{ //slow_motion
+ int8u rep_cntrl;
+ Get_S1 (5, rep_cntrl, "rep_cntrl");
+ }
+ break;
+ case 2 :{ //freeze_frame
+ Skip_S1(2, "field_id");
+ Skip_S1(3, "reserved");
+ }
+ break;
+ case 3 :{ //fast_reverse
+ Skip_S1(2, "field_id");
+ Skip_SB( "intra_slice_refresh");
+ Skip_S1(2, "frequency_truncation");
+ }
+ break;
+ case 4 :{ //slow_reverse
+ int8u rep_cntrl;
+ Get_S1 (5, rep_cntrl, "rep_cntrl");
+ }
+ break;
+ default:{
+ Skip_S1(5, "reserved");
+ }
+ }
+ BS_End();
+ Element_End0();
+ }
+ if (additional_copy_info_flag && Element_Offset<Element_Pos_After_Data)
+ {
+ Element_Begin1("additional_copy_info_flag");
+ BS_Begin();
+ Mark_1();
+ Skip_S1(7, "additional_copy_info");
+ BS_End();
+ Element_End0();
+ }
+ if (PES_CRC_flag && Element_Offset<Element_Pos_After_Data)
+ {
+ Element_Begin1("PES_CRC_flag");
+ Skip_B2( "previous_PES_packet_CRC");
+ Element_End0();
+ }
+ bool PES_private_data_flag=false, pack_header_field_flag=false, program_packet_sequence_counter_flag=false, p_STD_buffer_flag=false, PES_extension_flag_2=false; //Need it for DCA event
+ if (PES_extension_flag && Element_Offset<Element_Pos_After_Data)
+ {
+ Element_Begin1("PES_extension_flag");
+ BS_Begin();
+ Get_SB (PES_private_data_flag, "PES_private_data_flag");
+ Get_SB (pack_header_field_flag, "pack_header_field_flag");
+ Get_SB (program_packet_sequence_counter_flag, "program_packet_sequence_counter_flag");
+ Get_SB (p_STD_buffer_flag, "P-STD_buffer_flag");
+ Skip_S1(3, "reserved");
+ Get_SB (PES_extension_flag_2, "PES_extension_flag_2");
+ BS_End();
+
+ //Integrity test
+ if (Element_Offset+(PES_private_data_flag?16:0)+(pack_header_field_flag?1:0)+(program_packet_sequence_counter_flag?2:0)+(p_STD_buffer_flag?2:0)+(PES_extension_flag_2?2:0)>Element_Pos_After_Data)
+ {
+ //There is a problem
+ PES_private_data_flag=false;
+ pack_header_field_flag=false;
+ program_packet_sequence_counter_flag=false;
+ p_STD_buffer_flag=false;
+ PES_extension_flag_2=false;
+ }
+
+ if (PES_private_data_flag)
+ {
+ Element_Begin1("PES_private_data_flag");
+ Skip_B16( "PES_private_data");
+ Element_End0();
+ }
+ if (pack_header_field_flag)
+ {
+ Element_Begin1("pack_header_field_flag");
+ int8u pack_field_length;
+ Get_B1 (pack_field_length, "pack_field_length");
+ Skip_XX(pack_field_length, "pack_header");
+ Element_End0();
+ }
+ if (program_packet_sequence_counter_flag)
+ {
+ Element_Begin1("program_packet_sequence_counter_flag");
+ int8u program_packet_sequence_counter, original_stuff_length;
+ bool MPEG1_MPEG2_identifier;
+ BS_Begin();
+ Mark_1();
+ Get_S1 (7, program_packet_sequence_counter, "program_packet_sequence_counter");
+ Mark_1();
+ Get_SB ( MPEG1_MPEG2_identifier, "MPEG1_MPEG2_identifier");
+ Get_S1 (6, original_stuff_length, "original_stuff_length");
+ BS_End();
+ Element_End0();
+ }
+ if (p_STD_buffer_flag)
+ {
+ Element_Begin1("p_STD_buffer_flag");
+ bool P_STD_buffer_scale;
+ BS_Begin();
+ Mark_0();
+ Skip_SB( "Should be 1"); //But I saw a file with "0"
+ Get_SB ( P_STD_buffer_scale, "P-STD_buffer_scale");
+ Skip_S2(13, "P-STD_buffer_size");
+ BS_End();
+ Element_End0();
+ }
+ if (PES_extension_flag_2)
+ {
+ Element_Begin1("PES_extension_flag_2");
+ int8u PES_extension_field_length;
+ bool stream_id_extension_flag;
+ BS_Begin();
+ Mark_1();
+ Get_S1 (7, PES_extension_field_length, "PES_extension_field_length");
+ Get_SB (stream_id_extension_flag, "stream_id_extension_flag");
+ if (stream_id_extension_flag==0) //This should be limited to stream_id_extension_flag==0, but I found a file with stream_id_extension_flag=1 and a real code...
+ {
+ Get_S1 (7, stream_id_extension, "stream_id_extension"); Param_Info1(MpegPs_stream_id_extension(stream_id_extension));
+ }
+ BS_End();
+ if (PES_extension_field_length-1>0)
+ Skip_XX(PES_extension_field_length-1, "reserved");
+ Element_End0();
+ }
+ Element_End0();
+ }
+ if (Element_Pos_After_Data>Element_Offset)
+ Skip_XX(Element_Pos_After_Data-Element_Offset, "stuffing_bytes");
+}
+
+//---------------------------------------------------------------------------
+void File_MpegPs::Data_Parse()
+{
+ //Counting
+ Frame_Count++;
+
+ //Needed?
+ if (!Streams[stream_id].Searching_Payload)
+ {
+ Skip_XX(Element_Size, "data");
+ Element_DoNotShow();
+ return;
+ }
+
+ //From TS
+ if (FromTS && !Status[IsAccepted])
+ {
+ Data_Accept("MPEG-PS");
+ if (!IsSub)
+ Fill(Stream_General, 0, General_Format, "MPEG-PS");
+ }
+
+ //Parsing
+ switch (stream_id)
+ {
+ case 0xB9 : MPEG_program_end(); break;
+ case 0xBA : pack_start(); break;
+ case 0xBB : system_header_start(); break;
+ case 0xBC : program_stream_map(); break;
+ case 0xBD : private_stream_1(); break;
+ case 0xBE : padding_stream(); break;
+ case 0xBF : private_stream_2(); break;
+ case 0xF0 : Element_Name("ECM_Stream"); Skip_XX(Element_Size, "Data"); break;
+ case 0xF1 : Element_Name("EMM_Stream"); Skip_XX(Element_Size, "Data"); break;
+ case 0xF2 : Element_Name("DSMCC_stream"); Skip_XX(Element_Size, "Data"); break;
+ case 0xF3 : Element_Name("ISO/IEC_13522_stream"); Skip_XX(Element_Size, "Data"); break;
+ case 0xF4 : Element_Name("ITU-T Rec. H.222.1 type A"); Skip_XX(Element_Size, "Data"); break;
+ case 0xF5 : Element_Name("ITU-T Rec. H.222.1 type B"); Skip_XX(Element_Size, "Data"); break;
+ case 0xF6 : Element_Name("ITU-T Rec. H.222.1 type C"); Skip_XX(Element_Size, "Data"); break;
+ case 0xF7 : Element_Name("ITU-T Rec. H.222.1 type D"); Skip_XX(Element_Size, "Data"); break;
+ case 0xF8 : Element_Name("ITU-T Rec. H.222.1 type E"); Skip_XX(Element_Size, "Data"); break;
+ case 0xF9 : Element_Name("ancillary_stream"); Skip_XX(Element_Size, "Data"); break;
+ case 0xFA : SL_packetized_stream(); break;
+ case 0xFB : Element_Name("FlexMux_stream"); Skip_XX(Element_Size, "Data"); break;
+ case 0xFC : Element_Name("descriptive data stream"); Skip_XX(Element_Size, "Data"); break;
+ case 0xFD : extension_stream(); break;
+ case 0xFF : Element_Name("program_stream_directory"); Skip_XX(Element_Size, "Data"); break;
+ default:
+ if ((stream_id&0xE0)==0xC0) audio_stream();
+ else if ((stream_id&0xF0)==0xE0) video_stream();
+ else
+ Trusted_IsNot("Unattended element!");
+ }
+}
+
+//---------------------------------------------------------------------------
+//Jumping to the last DTS if needed
+bool File_MpegPs::BookMark_Needed()
+{
+ if (IsSub || Streams.empty() || Config_ParseSpeed>=1.0)
+ return false;
+
+ int64u ToJump=(int64u)-1;
+ for (size_t StreamID=0; StreamID<0x100; StreamID++)
+ {
+ //End timestamp is out of date
+ if (Streams[StreamID].TimeStamp_End.PTS.File_Pos!=(int64u)-1)
+ {
+ if (Streams[StreamID].TimeStamp_End.PTS.File_Pos<ToJump)
+ ToJump=Streams[StreamID].TimeStamp_End.PTS.File_Pos;
+ Streams[StreamID].Searching_Payload=true;
+ }
+ if (Streams[StreamID].TimeStamp_End.DTS.File_Pos!=(int64u)-1)
+ {
+ if (Streams[StreamID].TimeStamp_End.DTS.File_Pos<ToJump)
+ ToJump=Streams[StreamID].TimeStamp_End.DTS.File_Pos;
+ Streams[StreamID].Searching_Payload=true;
+ }
+ if (Streams_Private1[StreamID].TimeStamp_End.PTS.File_Pos!=(int64u)-1)
+ {
+ if (Streams_Private1[StreamID].TimeStamp_End.PTS.File_Pos<ToJump)
+ ToJump=Streams_Private1[StreamID].TimeStamp_End.PTS.File_Pos;
+ Streams_Private1[StreamID].Searching_Payload=true;
+ }
+ if (Streams_Private1[StreamID].TimeStamp_End.DTS.File_Pos!=(int64u)-1)
+ {
+ if (Streams_Private1[StreamID].TimeStamp_End.DTS.File_Pos<ToJump)
+ ToJump=Streams_Private1[StreamID].TimeStamp_End.DTS.File_Pos;
+ Streams_Private1[StreamID].Searching_Payload=true;
+ }
+ if (Streams_Extension[StreamID].TimeStamp_End.PTS.File_Pos!=(int64u)-1)
+ {
+ if (Streams_Extension[StreamID].TimeStamp_End.PTS.File_Pos<ToJump)
+ ToJump=Streams_Extension[StreamID].TimeStamp_End.PTS.File_Pos;
+ Streams_Extension[StreamID].Searching_Payload=true;
+ }
+ if (Streams_Extension[StreamID].TimeStamp_End.DTS.File_Pos!=(int64u)-1)
+ {
+ if (Streams_Extension[StreamID].TimeStamp_End.DTS.File_Pos<ToJump)
+ ToJump=Streams_Extension[StreamID].TimeStamp_End.DTS.File_Pos;
+ Streams_Extension[StreamID].Searching_Payload=true;
+ }
+ }
+
+ return false;
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Packet "B9"
+void File_MpegPs::MPEG_program_end()
+{
+ Element_Name("MPEG_program_end");
+
+ //Filling
+ Synched=false; //We don't know what can be after
+}
+
+//---------------------------------------------------------------------------
+// Packet "BA"
+void File_MpegPs::pack_start()
+{
+ Element_Name("pack_start");
+
+ //Parsing
+ int16u SysClock_29, SysClock_14;
+ int8u Version, SysClock_32;
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ //Parsing
+ BS_Begin();
+ Peek_S1( 2, Version);
+ }
+ else
+ {
+ #endif //MEDIAINFO_TRACE
+ //Parsing
+ Version=Buffer[Buffer_Pos]>>6;
+ #if MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_TRACE
+ if (Version==1)
+ {
+ //MPEG-2
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ //Parsing
+ int8u Padding;
+ Mark_0();
+ Mark_1();
+ Get_S1 ( 3, SysClock_32, "system_clock_reference_base32");
+ Mark_1();
+ Get_S2 (15, SysClock_29, "system_clock_reference_base29");
+ Mark_1();
+ Get_S2 (15, SysClock_14, "system_clock_reference_base14");
+
+ //Filling
+ Streams[0xBA].TimeStamp_End.PTS.TimeStamp=(((int64u)SysClock_32)<<30)
+ | (((int64u)SysClock_29)<<15)
+ | (((int64u)SysClock_14));
+ if (Searching_TimeStamp_Start && Streams[0xBA].Searching_TimeStamp_Start)
+ {
+ Streams[0xBA].TimeStamp_Start=Streams[0xBA].TimeStamp_End;
+ Streams[0xBA].Searching_TimeStamp_Start=false;
+ }
+ Param_Info_From_Milliseconds(Streams[0xBA].TimeStamp_End.PTS.TimeStamp/90);
+
+ Mark_1();
+ Skip_S2( 9, "system_clock_reference_extension");
+ Mark_1();
+ Get_S3 (22, program_mux_rate, "program_mux_rate"); Param_Info2(program_mux_rate*400, " bps");
+ Mark_1();
+ Mark_1();
+ Skip_S1( 5, "reserved");
+ Get_S1 ( 3, Padding, "pack_stuffing_length");
+ BS_End();
+ if (Padding>0)
+ Skip_XX(Padding, "padding");
+ }
+ else
+ {
+ #endif //MEDIAINFO_TRACE
+ //Parsing
+ Streams[0xBA].TimeStamp_End.PTS.TimeStamp=((Buffer[Buffer_Pos ]&0x38)<<30)
+ | ((Buffer[Buffer_Pos ]&0x03)<<28)
+ | ((Buffer[Buffer_Pos+1] )<<20)
+ | ((Buffer[Buffer_Pos+2]&0xF8)<<15)
+ | ((Buffer[Buffer_Pos+2]&0x03)<<13)
+ | ((Buffer[Buffer_Pos+3] )<< 5)
+ | ((Buffer[Buffer_Pos+4]&0xF8)>> 3);
+ if (!Status[IsAccepted])
+ {
+ program_mux_rate =((Buffer[Buffer_Pos+6] )<<14)
+ | ((Buffer[Buffer_Pos+7] )<< 6)
+ | ((Buffer[Buffer_Pos+8] )>> 2);
+ }
+ int8u Padding = Buffer[Buffer_Pos+9]&0x07;
+ Element_Offset=10+Padding;
+ #if MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_TRACE
+ }
+ else
+ {
+ BS_Begin();
+ Mark_0();
+ Mark_0();
+ Mark_1();
+ Mark_0();
+ Get_S1 ( 3, SysClock_32, "system_clock_reference_base32");
+ Mark_1();
+ Get_S2 (15, SysClock_29, "system_clock_reference_base29");
+ Mark_1();
+ Get_S2 (15, SysClock_14, "system_clock_reference_base14");
+
+ //Filling
+ Streams[0xBA].TimeStamp_End.PTS.TimeStamp=(((int64u)SysClock_32)<<30)
+ | (((int64u)SysClock_29)<<15)
+ | (((int64u)SysClock_14));
+ if (Searching_TimeStamp_Start && Streams[0xBA].Searching_TimeStamp_Start)
+ {
+ Streams[0xBA].TimeStamp_Start=Streams[0xBA].TimeStamp_End;
+ Streams[0xBA].Searching_TimeStamp_Start=false;
+ }
+ Param_Info_From_Milliseconds(Streams[0xBA].TimeStamp_End.PTS.TimeStamp/90);
+
+ Mark_1();
+ Mark_1();
+ Get_S3(22, program_mux_rate, "mux_rate"); Param_Info2(program_mux_rate*400, " bps");
+ Mark_1();
+ BS_End();
+ }
+
+
+ //Filling
+ FILLING_BEGIN_PRECISE();
+ if (!Status[IsAccepted])
+ {
+ Data_Accept("MPEG-PS");
+ if (!IsSub)
+ Fill(Stream_General, 0, General_Format, "MPEG-PS");
+
+ //Autorisation of other streams
+ Streams[0xB9].Searching_Payload=true; //MPEG_program_end
+ Streams[0xBB].Searching_Payload=true; //system_header_start
+ Streams[0xBD].Searching_Payload=true; //private_stream_1
+ Streams[0xBD].Searching_TimeStamp_Start=true; //private_stream_1
+ Streams[0xBD].Searching_TimeStamp_End=true; //private_stream_1
+ Streams[0xBF].Searching_Payload=true; //private_stream_2
+ Streams[0xFD].Searching_Payload=true; //private_stream_1 or video_stream
+ Streams[0xFD].Searching_TimeStamp_Start=true; //private_stream_1 or video_stream
+ Streams[0xFD].Searching_TimeStamp_End=true; //private_stream_1 or video_stream
+ for (int8u Pos=0xC0; Pos<=0xEF; Pos++)
+ {
+ Streams[Pos].Searching_Payload=true; //audio_stream or video_stream
+ Streams[Pos].Searching_TimeStamp_Start=true; //audio_stream or video_stream
+ Streams[Pos].Searching_TimeStamp_End=true; //audio_stream or video_stream
+ }
+
+ MPEG_Version=Version==1?2:1;
+
+ SizeToAnalyze=program_mux_rate*50*4*(MustExtendParsingDuration?4:1); //standard delay between TimeStamps is 0.7s, we try 4s to be sure
+ if (SizeToAnalyze>16*1024*1024)
+ SizeToAnalyze=16*1024*1024; //Not too much
+ if (SizeToAnalyze<2*1024*1024)
+ SizeToAnalyze=2*1024*1024; //Not too less
+ }
+
+ #if MEDIAINFO_IBI
+ if (!IsSub)
+ Ibi_SynchronizationOffset_Current=File_Offset+Buffer_Offset-Header_Size;
+ #endif //MEDIAINFO_IBI
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "BB"
+void File_MpegPs::system_header_start()
+{
+ Element_Name("system_header_start");
+
+ //If there is system_header_start, default value for private sections are false
+ private_stream_1_Count=0;
+ private_stream_2_Count=0;
+ SL_packetized_stream_Count=0;
+
+ //Parsing
+ int32u rate_bound;
+ int8u audio_bound, video_bound;
+ BS_Begin();
+ Mark_1();
+ Get_S3 (22, rate_bound, "rate_bound"); Param_Info2(rate_bound*400, " bps");
+ Mark_1();
+ Get_S1 ( 6, audio_bound, "audio_bound");
+ Info_SB( fixed_flag, "fixed_flag"); Param_Info1(MpegPs_System_Fixed[fixed_flag]);
+ Skip_SB( "CSPS_flag");
+ Skip_SB( "system_audio_lock_flag");
+ Skip_SB( "system_video_lock_flag");
+ Mark_1();
+ Get_S1 ( 5, video_bound, "video_bound");
+ Skip_SB( "packet_rate_restriction_flag");
+ Skip_S1( 7, "reserved_byte");
+ bool one=false;
+ if (Element_IsNotFinished())
+ Peek_SB(one);
+ while (one)
+ {
+ Element_Begin0();
+ int16u STD_buffer_size_bound;
+ int8u stream_id, stream_id_extension=0;
+ bool STD_buffer_bound_scale;
+ Get_S1 ( 8, stream_id, "stream_id"); Param_Info1(MpegPs_stream_id(stream_id));
+ Element_Name(Ztring().From_CC1(stream_id));
+ Element_Info1(MpegPs_stream_id(stream_id));
+ if (stream_id==0xB7)
+ {
+ Mark_1();
+ Mark_1();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Get_S1 (8, stream_id_extension, "stream_id_extension");
+ Mark_1();
+ Mark_0();
+ Mark_1();
+ Mark_1();
+ Mark_0();
+ Mark_1();
+ Mark_1();
+ Mark_0();
+ }
+ Mark_1();
+ Mark_1();
+ Get_SB ( STD_buffer_bound_scale, "STD_buffer_bound_scale");
+ Get_S2 (13, STD_buffer_size_bound, "STD_buffer_size_bound"); Param_Info1(Ztring::ToZtring(STD_buffer_size_bound*(STD_buffer_bound_scale?1024:128)) + _T(" bytes"));
+ Element_End0();
+
+ FILLING_BEGIN();
+ switch (stream_id)
+ {
+ case 0xBD : private_stream_1_Count=(int8u)-1; break;
+ case 0xBF : private_stream_2_Count=(int8u)-1; break;
+ case 0xFA : SL_packetized_stream_Count=(int8u)-1; break;
+ case 0xFD : extension_stream_Count=(int8u)-1; break;
+ default : ;
+ }
+ FILLING_END();
+
+ if (Element_IsNotFinished())
+ Peek_SB(one);
+ else
+ one=false;
+ }
+ BS_End();
+
+ //Filling
+ if (audio_stream_Count==(int8u)-1) //0xBB may be multipart
+ audio_stream_Count=0;
+ audio_stream_Count+=audio_bound;
+ if (video_stream_Count==(int8u)-1) //0xBB may be multipart
+ video_stream_Count=0;
+ video_stream_Count+=video_bound;
+ if (private_stream_1_Count>0 && program_mux_rate*50==SizeToAnalyze)
+ SizeToAnalyze*=32; //If there is a private section, this may be DVD, with late data --> 10s minimum
+ if (SizeToAnalyze>8*1024*1024)
+ SizeToAnalyze=8*1024*1024;
+
+ //Autorisation of other streams
+ if ((private_stream_1_Count>0 || audio_stream_Count>0) && video_stream_Count>0) //0xBB may be multipart
+ Streams[0xBB].Searching_Payload=false;
+ Streams[0xBC].Searching_Payload=true; //program_stream_map
+}
+
+//---------------------------------------------------------------------------
+// Packet "BC"
+void File_MpegPs::program_stream_map()
+{
+ Element_Name("program_stream_map");
+ MPEG_Version=2; //program_stream_map does NOT exist in MPEG-1 specs
+
+ File_Mpeg_Psi Parser;
+ Parser.From_TS=false;
+ Parser.Complete_Stream=new complete_stream;
+ Parser.Complete_Stream->Streams.resize(0x100);
+ for (size_t StreamID=0; StreamID<0x100; StreamID++)
+ Parser.Complete_Stream->Streams[StreamID]=new complete_stream::stream;
+ Open_Buffer_Init(&Parser);
+ Open_Buffer_Continue(&Parser);
+ Finish(&Parser);
+
+ FILLING_BEGIN();
+ //Time stamps
+ Streams[0xBC].TimeStamp_End=Streams[0xBA].TimeStamp_End;
+ if (Streams[0xBC].TimeStamp_Start.PTS.TimeStamp==(int64u)-1)
+ Streams[0xBC].TimeStamp_Start=Streams[0xBC].TimeStamp_End;
+
+ //Registering the streams
+ for (int8u Pos=0; Pos<0xFF; Pos++)
+ if (Parser.Complete_Stream->Streams[Pos]->stream_type!=(int8u)-1)
+ {
+ if (!Parser.Complete_Stream->Transport_Streams.empty() && !Parser.Complete_Stream->Transport_Streams.begin()->second.Programs.empty())
+ Streams[Pos].program_format_identifier=Parser.Complete_Stream->Transport_Streams.begin()->second.Programs.begin()->second.registration_format_identifier;
+ Streams[Pos].format_identifier=Parser.Complete_Stream->Streams[Pos]->registration_format_identifier;
+ Streams[Pos].stream_type=Parser.Complete_Stream->Streams[Pos]->stream_type;
+ }
+ else
+ {
+ }
+ FILLING_END();
+
+ delete Parser.Complete_Stream; //Parser.Complete_Stream=NULL;
+}
+
+//---------------------------------------------------------------------------
+// Packet "BD"
+void File_MpegPs::private_stream_1()
+{
+ Element_Name("private_stream_1");
+
+ if (!FromTS)
+ {
+ //From PS, trying DVD system
+ private_stream_1_ID=0;
+ private_stream_1_Offset=0;
+ if (!private_stream_1_Choose_DVD_ID())
+ {
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ return;
+ }
+ Element_Info1C(private_stream_1_ID, Ztring::ToZtring(private_stream_1_ID, 16));
+ }
+
+ if (!Streams_Private1[private_stream_1_ID].StreamIsRegistred)
+ {
+ //For TS streams, which does not have Start chunk
+ if (FromTS)
+ {
+ if (video_stream_Count==(int8u)-1 && audio_stream_Count==(int8u)-1)
+ {
+ video_stream_Count=0;
+ audio_stream_Count=0;
+ private_stream_1_Count=1;
+ private_stream_2_Count=0;
+ extension_stream_Count=0;
+ SL_packetized_stream_Count=0;
+ private_stream_1_ID=0;
+ private_stream_1_Offset=0;
+ Streams_Private1[private_stream_1_ID].stream_type=FromTS_stream_type;
+ }
+ else if (!IsSub)
+ {
+ //2 streams in the file, this can not be From TS, we have no idea of the count of streams
+ video_stream_Count=(int8u)-1;
+ audio_stream_Count=(int8u)-1;
+ private_stream_1_Count=(int8u)-1;
+ private_stream_2_Count=(int8u)-1;
+ extension_stream_Count=(int8u)-1;
+ SL_packetized_stream_Count=(int8u)-1;
+ FromTS=false;
+ }
+ }
+
+ //Registering
+ if (!Status[IsAccepted])
+ {
+ Data_Accept("MPEG-PS");
+ if (!IsSub)
+ Fill(Stream_General, 0, General_Format, "MPEG-PS");
+ }
+ Streams[stream_id].StreamIsRegistred++;
+ Streams_Private1[private_stream_1_ID].StreamIsRegistred++;
+ Streams_Private1[private_stream_1_ID].Searching_Payload=true;
+ Streams_Private1[private_stream_1_ID].Searching_TimeStamp_Start=true;
+ Streams_Private1[private_stream_1_ID].Searching_TimeStamp_End=true;
+
+ //New parsers
+ Streams_Private1[private_stream_1_ID].Parsers.push_back(private_stream_1_ChooseParser());
+ if (Streams_Private1[private_stream_1_ID].Parsers[Streams_Private1[private_stream_1_ID].Parsers.size()-1]==NULL)
+ {
+ Streams_Private1[private_stream_1_ID].Parsers.clear();
+ #if defined(MEDIAINFO_AC3_YES)
+ Streams_Private1[private_stream_1_ID].Parsers.push_back(ChooseParser_AC3());
+ #endif
+ #if defined(MEDIAINFO_DTS_YES)
+ Streams_Private1[private_stream_1_ID].Parsers.push_back(ChooseParser_DTS());
+ #endif
+ }
+ #if MEDIAINFO_EVENTS
+ if (private_stream_1_Offset)
+ {
+ //Multiple substreams in 1 stream
+ StreamIDs[StreamIDs_Size-1]=Element_Code;
+ Element_Code=private_stream_1_ID; //The upper level ID is filled by Element_Code in the common code
+ StreamIDs_Width[StreamIDs_Size]=2;
+ ParserIDs[StreamIDs_Size]=MediaInfo_Parser_MpegPs_Ext;
+ StreamIDs_Size++;
+ }
+ #endif //MEDIAINFO_EVENTS
+ for (size_t Pos=0; Pos<Streams_Private1[private_stream_1_ID].Parsers.size(); Pos++)
+ Open_Buffer_Init(Streams_Private1[private_stream_1_ID].Parsers[Pos]);
+ #if MEDIAINFO_EVENTS
+ if (private_stream_1_Offset)
+ {
+ StreamIDs_Size--;
+ Element_Code=StreamIDs[StreamIDs_Size-1];
+ }
+ #endif //MEDIAINFO_EVENTS
+ }
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ if (Streams_Private1[private_stream_1_ID].Searching_Payload)
+ {
+ if (private_stream_1_Offset)
+ {
+ //Multiple substreams in 1 stream
+ StreamIDs[StreamIDs_Size-1]=Element_Code;
+ Element_Code=private_stream_1_ID; //The upper level ID is filled by Element_Code in the common code
+ StreamIDs_Width[StreamIDs_Size]=2;
+ ParserIDs[StreamIDs_Size]=MediaInfo_Parser_MpegPs_Ext;
+ StreamIDs_Size++;
+ Demux(Buffer+Buffer_Offset+private_stream_1_Offset, (size_t)(Element_Size-private_stream_1_Offset), ContentType_MainStream);
+ StreamIDs_Size--;
+ Element_Code=StreamIDs[StreamIDs_Size-1];
+ }
+ else
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ //Parsing
+ if (Element_Offset<private_stream_1_Offset)
+ Skip_XX(private_stream_1_Offset-Element_Offset, "DVD-Video data");
+
+ #if MEDIAINFO_EVENTS
+ if (private_stream_1_Offset)
+ {
+ //Multiple substreams in 1 stream
+ StreamIDs[StreamIDs_Size-1]=Element_Code;
+ Element_Code=private_stream_1_ID; //The upper level ID is filled by Element_Code in the common code
+ StreamIDs_Width[StreamIDs_Size]=2;
+ ParserIDs[StreamIDs_Size]=MediaInfo_Parser_MpegPs_Ext;
+ StreamIDs_Size++;
+ }
+ #endif //MEDIAINFO_EVENTS
+ xxx_stream_Parse(Streams_Private1[private_stream_1_ID], private_stream_1_Count);
+ #if MEDIAINFO_EVENTS
+ if (private_stream_1_Offset)
+ {
+ StreamIDs_Size--;
+ Element_Code=StreamIDs[StreamIDs_Size-1];
+ }
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ {
+ Demux_StreamIsBeingParsed_type=1;
+ Demux_StreamIsBeingParsed_stream_id=private_stream_1_ID;
+ }
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+bool File_MpegPs::private_stream_1_Choose_DVD_ID()
+{
+ private_stream_1_IsDvdVideo=false;
+
+ if (Element_Size<4)
+ return false;
+
+ //Testing false-positives
+ if (CC2(Buffer+Buffer_Offset+(size_t)Element_Offset)==0x0B77)
+ return true;
+
+ //Parsing
+ int8u CodecID;
+ Get_B1 (CodecID, "CodecID");
+
+ //Testing
+ //Subtitles (CVD)
+ if (CodecID<=0x0F)
+ {
+ private_stream_1_IsDvdVideo=true;
+ private_stream_1_Offset=1;
+ }
+ //Subtitles (DVD)
+ else if (CodecID>=0x20 && CodecID<=0x3F)
+ {
+ private_stream_1_IsDvdVideo=true;
+ private_stream_1_Offset=1;
+ }
+ //Subtitles (SVCD)
+ else if (CodecID>=0x70 && CodecID<=0x7F)
+ {
+ private_stream_1_IsDvdVideo=true;
+ private_stream_1_Offset=1;
+ }
+ //AC-3 (OTA?)
+ else if (CodecID==0x80 && CC3(Buffer+Buffer_Offset+1)==0x000000)
+ {
+ private_stream_1_IsDvdVideo=true; //Not sure
+ private_stream_1_Offset=4;
+ }
+ //PCM
+ else if (CodecID>=0xA0 && CodecID<=0xAF && Element_Size>=7 && Buffer[Buffer_Offset+6]==0x80)
+ {
+ private_stream_1_IsDvdVideo=true;
+ private_stream_1_Offset=1;
+ }
+ //PS2-MPG
+ else if (CodecID==0xFF)
+ {
+ int16u StreamID;
+ int8u SubID;
+ Get_B1 (SubID, "CodecID (part 2)");
+ Get_B2 (StreamID, "Stream ID");
+
+ if ((SubID&0xFE)==0xA0) //0xFFA0 or 0xFFA1
+ {
+ //PS2-MPG PCM/ADPCM
+ private_stream_1_Offset=4;
+ private_stream_1_ID=(int8u)StreamID; //ID is maybe 2 byte long, but private_stream_1_ID is an int8u
+ return true;
+ }
+ else if (SubID==0x90) //0xFF90
+ {
+ //PS2-MPG AC-3 or subtitles
+ private_stream_1_Offset=4;
+ private_stream_1_ID=(int8u)StreamID; //ID is maybe 2 byte long, but private_stream_1_ID is an int8u
+ return true;
+ }
+ else
+ return false;
+ }
+ else
+ {
+ int16u Next;
+ int8u Count;
+ Get_B1 (Count, "Count of next frame headers");
+ Get_B2 (Next, "Next frame offset minus 1");
+
+ if (Count>0 && 4+(int64u)Next+4<=Element_Size)
+ {
+ //Subtitles (CVD)
+ // if (CodecID>=0x00 && CodecID<=0x0F)
+ // ; //Seems to not work with subtitles, to be confirmed
+ //Subtitles (DVD)
+ // if (CodecID>=0x20 && CodecID<=0x3F)
+ // ; //Seems to not work with subtitles, to be confirmed
+ //Subtitles (SVCD)
+ // if (CodecID>=0x70 && CodecID<=0x7F)
+ // ; //Seems to not work with subtitles, to be confirmed
+ //AC3
+ if (CodecID>=0x80 && CodecID<=0x87)
+ {
+ if (CC2(Buffer+Buffer_Offset+4+Next)!=0x0B77 && CC2(Buffer+Buffer_Offset+3+Next)!=0x0B77 && CC2(Buffer+Buffer_Offset+2+Next)!=0x0B77)
+ return false;
+ }
+ //DTS
+ else if (CodecID>=0x88 && CodecID<=0x8F)
+ {
+ if (CC4(Buffer+Buffer_Offset+4+Next)!=0x7FFE8001 && CC4(Buffer+Buffer_Offset+3+Next)!=0x7FFE8001 && CC4(Buffer+Buffer_Offset+2+Next)!=0x7FFE8001)
+ return false;
+ }
+ //DTS
+ else if (CodecID>=0x98 && CodecID<=0x9F)
+ {
+ if (CC4(Buffer+Buffer_Offset+4+Next)!=0x7FFE8001 && CC4(Buffer+Buffer_Offset+3+Next)!=0x7FFE8001 && CC4(Buffer+Buffer_Offset+2+Next)!=0x7FFE8001)
+ return false;
+ }
+ //PCM
+ //else if (CodecID>=0xA0 && CodecID<=0xAF)
+ // ;
+ //MLP
+ else if (CodecID>=0xB0 && CodecID<=0xBF)
+ {
+ if (CC2(Buffer+Buffer_Offset+4+Next)!=0x0B77 && CC2(Buffer+Buffer_Offset+3+Next)!=0x0B77 && CC2(Buffer+Buffer_Offset+2+Next)!=0x0B77)
+ return false;
+ }
+ //AC3+
+ else if (CodecID>=0xC0 && CodecID<=0xCF)
+ {
+ if (CC2(Buffer+Buffer_Offset+4+Next)!=0x0B77 && CC2(Buffer+Buffer_Offset+3+Next)!=0x0B77 && CC2(Buffer+Buffer_Offset+2+Next)!=0x0B77)
+ return false;
+ }
+ else
+ return false;
+
+ private_stream_1_IsDvdVideo=true;
+ private_stream_1_Offset=4;
+ }
+ }
+
+ //Filling
+ private_stream_1_ID=CodecID;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::private_stream_1_ChooseParser()
+{
+ if (FromTS || Streams[stream_id].program_format_identifier || Streams[stream_id].format_identifier || Streams[stream_id].descriptor_tag)
+ {
+ int32u format_identifier=FromTS?FromTS_format_identifier:Streams[stream_id].format_identifier;
+ if (format_identifier==0x42535344) //"BSSD"
+ {
+ return ChooseParser_AES3(); //AES3 (SMPTE 302M)
+ }
+ int32u stream_type=FromTS?FromTS_stream_type:Streams[stream_id].stream_type;
+ switch (stream_type)
+ {
+ case 0x03 :
+ case 0x04 : return ChooseParser_Mpega(); //MPEG Audio
+ case 0x0F : return ChooseParser_Adts(); //ADTS
+ case 0x11 : return ChooseParser_Latm(); //LATM
+ case 0x80 : return ChooseParser_PCM(); //PCM
+ case 0x81 :
+ case 0x83 :
+ case 0x84 :
+ case 0x87 :
+ case 0xA1 : return ChooseParser_AC3(); //AC3/AC3+
+ case 0x82 :
+ case 0x85 :
+ case 0x86 :
+ case 0xA2 : return ChooseParser_DTS(); //DTS
+ case 0x90 : return ChooseParser_PGS(); //PGS from Bluray
+ case 0xEA : return ChooseParser_NULL(); //VC1()
+ default :
+ {
+ int8u descriptor_tag=FromTS?FromTS_descriptor_tag:Streams[stream_id].descriptor_tag;
+ switch (descriptor_tag)
+ {
+ case 0x56 : return ChooseParser_Teletext(); //Teletext
+ case 0x59 : return ChooseParser_DvbSubtitle(); //DVB Subtiles
+ case 0x6A :
+ case 0x7A :
+ case 0x81 : return ChooseParser_AC3(); //AC3/AC3+
+ case 0x7B : return ChooseParser_DTS(); //DTS
+ case 0x7C : return ChooseParser_AAC(); //AAC
+ default : if (Element_Size>2 && CC2(Buffer+Buffer_Offset)==0x0B77)
+ return ChooseParser_AC3(); //AC3/AC3+
+ else if (Element_Size>4 && CC4(Buffer+Buffer_Offset)==0x7FFE8001)
+ return ChooseParser_DTS(); //DTS
+ else
+ return NULL;
+ }
+ }
+ }
+ }
+ else if (Element_Code==0xBD && private_stream_1_IsDvdVideo)
+ {
+ //Subtitles (CVD)
+ if (private_stream_1_ID<=0x0F)
+ return ChooseParser_RLE();
+ //Subtitles (DVD)
+ if (private_stream_1_ID>=0x20 && private_stream_1_ID<=0x3F)
+ return ChooseParser_RLE();
+ //Subtitles (SVCD)
+ if (private_stream_1_ID>=0x70 && private_stream_1_ID<=0x7F)
+ return ChooseParser_RLE();
+ //AC3
+ else if (private_stream_1_ID>=0x80 && private_stream_1_ID<=0x87)
+ return ChooseParser_AC3();
+ //DTS
+ else if (private_stream_1_ID>=0x88 && private_stream_1_ID<=0x8F)
+ return ChooseParser_DTS();
+ //SDDS
+ else if (private_stream_1_ID>=0x90 && private_stream_1_ID<=0x97)
+ return ChooseParser_DTS();
+ //DTS
+ else if (private_stream_1_ID>=0x98 && private_stream_1_ID<=0x9F)
+ return ChooseParser_DTS();
+ //PCM
+ else if (private_stream_1_ID>=0xA0 && private_stream_1_ID<=0xAF)
+ return ChooseParser_PCM();
+ //AC3+
+ else if (private_stream_1_ID>=0xC0 && private_stream_1_ID<=0xCF)
+ return ChooseParser_AC3();
+ else
+ return NULL;
+ }
+ else
+ {
+ if (Element_Size>2 && CC2(Buffer+Buffer_Offset)==0x0B77)
+ return ChooseParser_AC3(); //AC3/AC3+
+ else if (Element_Size>4 && CC4(Buffer+Buffer_Offset)==0x7FFE8001)
+ return ChooseParser_DTS(); //DTS
+ else if (Element_Size>2 && (CC2(Buffer+Buffer_Offset)&0xFFFE)==0xFFA0) //0xFFA0 or 0xFFA1
+ return ChooseParser_PS2(); //PS2-MPG PCM/ADPCM
+ else if (Element_Size>6 && CC2(Buffer+Buffer_Offset)==0xFF90 && CC2(Buffer+Buffer_Offset+4)==0x0B77)
+ return ChooseParser_AC3(); //PS2-MPG AC-3
+ else if (Element_Size>6 && CC2(Buffer+Buffer_Offset)==0xFF90 && CC2(Buffer+Buffer_Offset+4)==0x0000)
+ return ChooseParser_RLE(); //PS2-MPG Subtitles
+ else
+ return NULL;
+ }
+}
+
+//---------------------------------------------------------------------------
+const ZenLib::Char* File_MpegPs::private_stream_1_ChooseExtension()
+{
+ if (FromTS)
+ {
+ switch (private_stream_1_ID)
+ {
+ case 0x80 : return _T(".pcm"); //PCM
+ case 0x81 : return _T(".ac3"); //AC3
+ case 0x83 :
+ case 0x87 : return _T(".dd+"); //AC3+
+ case 0x86 : return _T(".dts"); //DTS
+ case 0xEA : return _T(".vc1"); //DTS
+ default : return _T(".raw");
+ }
+ }
+ else
+ {
+ //Subtitles
+ if (private_stream_1_ID>=0x20 && private_stream_1_ID<=0x3F)
+ return _T(".sub");
+ //AC3
+ else if (private_stream_1_ID>=0x80 && private_stream_1_ID<=0x87)
+ return _T(".ac3");
+ //DTS
+ else if (private_stream_1_ID>=0x88 && private_stream_1_ID<=0x8F)
+ return _T(".dts");
+ //SDDS
+ else if (private_stream_1_ID>=0x90 && private_stream_1_ID<=0x97)
+ return _T(".sdds");
+ //DTS
+ else if (private_stream_1_ID>=0x98 && private_stream_1_ID<=0x9F)
+ return _T(".dts");
+ //PCM
+ else if (private_stream_1_ID>=0xA0 && private_stream_1_ID<=0xAF)
+ return _T(".pcm");
+ //MLP
+ else if (private_stream_1_ID>=0xB0 && private_stream_1_ID<=0xBF)
+ return _T(".dd+");
+ //AC3+
+ else if (private_stream_1_ID>=0xC0 && private_stream_1_ID<=0xCF)
+ return _T(".dd+");
+ else
+ return _T(".raw");
+ }
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File_MpegPs::private_stream_1_Element_Info1()
+{
+ if (FromTS)
+ {
+ switch (private_stream_1_ID)
+ {
+ case 0x80 : Element_Info1("PCM"); return;
+ case 0x81 : Element_Info1("AC3"); return;
+ case 0x83 :
+ case 0x87 : Element_Info1("AC3+"); return;
+ case 0x86 : Element_Info1("DTS"); return;
+ case 0xEA : Element_Info1("VC1"); return;
+ default : return;
+ }
+ }
+ else
+ {
+ //Subtitles
+ if (private_stream_1_ID>=0x20 && private_stream_1_ID<=0x3F)
+ Element_Info1("RLE");
+ //AC3
+ else if (private_stream_1_ID>=0x80 && private_stream_1_ID<=0x87)
+ Element_Info1("AC3");
+ //DTS
+ else if (private_stream_1_ID>=0x88 && private_stream_1_ID<=0x8F)
+ Element_Info1("DTS");
+ //SDDS
+ else if (private_stream_1_ID>=0x90 && private_stream_1_ID<=0x97)
+ Element_Info1("SDDS");
+ //DTS
+ else if (private_stream_1_ID>=0x98 && private_stream_1_ID<=0x9F)
+ Element_Info1("DTS");
+ //PCM
+ else if (private_stream_1_ID>=0xA0 && private_stream_1_ID<=0xAF)
+ Element_Info1("LPCM");
+ //MLP
+ else if (private_stream_1_ID>=0xB0 && private_stream_1_ID<=0xBF)
+ Element_Info1("MLP");
+ //AC3+
+ else if (private_stream_1_ID>=0xC0 && private_stream_1_ID<=0xCF)
+ Element_Info1("AC3+");
+ //PS2
+ else if (private_stream_1_ID>=0xC0 && private_stream_1_ID<=0xCF)
+ Element_Info1("PS2");
+ }
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+// Packet "BE"
+void File_MpegPs::padding_stream()
+{
+ Element_Name("padding_stream");
+
+ Skip_XX(Element_Size, "stuffing_bytes");
+}
+
+//---------------------------------------------------------------------------
+// Packet "BF"
+void File_MpegPs::private_stream_2()
+{
+ Element_Name("private_stream_2");
+
+ //Filling
+ if (FromTS)
+ {
+ switch (FromTS_program_format_identifier)
+ {
+ case 0x54534856 : //TSHV
+ switch (FromTS_stream_type)
+ {
+ case 0xA0 : private_stream_2_TSHV_A0(); break;
+ case 0xA1 : private_stream_2_TSHV_A1(); break;
+ default : Skip_XX(Element_Size, "Unknown");
+ }
+ default : Skip_XX(Element_Size, "Unknown");
+ }
+
+ //Disabling the program
+ if (!Status[IsAccepted])
+ Data_Accept("MPEG-PS");
+ }
+ else //DVD?
+ {
+ Stream_Prepare(Stream_Menu);
+ Fill(Stream_Menu, StreamPos_Last, Menu_Format, "DVD-Video");
+ Fill(Stream_Menu, StreamPos_Last, Menu_Codec, "DVD-Video");
+
+ //Disabling this Stream
+ Streams[0xBF].Searching_Payload=false;
+ private_stream_2_Count=0;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_MpegPs::private_stream_2_TSHV_A0()
+{
+ Element_Name("DV A0");
+
+ //Parsing
+ Skip_XX(Element_Size, "Unknown");
+
+ //Filling
+ Data_Accept("MPEG-PS");
+ Finish("MPEG-PS");
+}
+
+//---------------------------------------------------------------------------
+void File_MpegPs::private_stream_2_TSHV_A1()
+{
+ Element_Name("DV A1");
+
+ //Parsing
+ int8u day, month, year, second, minute, hour;
+ Skip_XX(31, "Unknown");
+ BS_Begin();
+ Skip_S1(2, "Unknown");
+ Skip_S1(6, "timecode_frame");
+ Skip_S1(1, "Unknown");
+ Skip_S1(7, "timecode_second");
+ Skip_S1(1, "Unknown");
+ Skip_S1(7, "timecode_minute");
+ Skip_S1(2, "Unknown");
+ Skip_S1(6, "timecode_hour");
+ Skip_S1(8, "Unknown");
+ Skip_S1(2, "Unknown");
+ Get_S1 (6, day, "day");
+ Skip_S1(3, "Unknown");
+ Get_S1 (5, month, "month");
+ Get_S1 (8, year, "year");
+ Skip_S1(8, "Unknown");
+ Skip_S1(1, "Unknown");
+ Get_S1 (7, second, "second");
+ Skip_S1(1, "Unknown");
+ Get_S1 (7, minute, "minute");
+ Skip_S1(2, "Unknown");
+ Get_S1 (6, hour, "hour");
+ Skip_S1(2, "Unknown");
+ Skip_S1(1, "scene_start");
+ Skip_S1(5, "Unknown");
+ BS_End();
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+
+ FILLING_BEGIN();
+ Ztring Date_Time=Ztring().Date_From_Numbers(year/0x10*10+year%0x10, month/0x10*10+month%0x10, day/0x10*10+day%0x10, hour/0x10*10+hour%0x10, minute/0x10*10+minute%0x10, second/0x10*10+second%0x10);
+ if (Retrieve(Stream_General, 0, General_Encoded_Date).empty())
+ {
+ Fill(Stream_General, 0, General_Encoded_Date, Date_Time);
+ Fill(Stream_General, 0, General_Duration_Start, Date_Time);
+ }
+ Fill(Stream_General, 0, General_Duration_End, Date_Time, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_MpegPs::audio_stream()
+{
+ Element_Name("Audio");
+
+ if (!Streams[stream_id].StreamIsRegistred)
+ {
+ //For TS streams, which does not have Start chunk
+ if (FromTS)
+ {
+ if (video_stream_Count==(int8u)-1 && audio_stream_Count==(int8u)-1)
+ {
+ video_stream_Count=0;
+ audio_stream_Count=1;
+ private_stream_1_Count=0;
+ private_stream_2_Count=0;
+ extension_stream_Count=0;
+ SL_packetized_stream_Count=0;
+ Streams[stream_id].stream_type=FromTS_stream_type;
+ }
+ else if (!IsSub)
+ {
+ //2 streams in the file, this can not be From TS, we have no idea of the count of streams
+ video_stream_Count=(int8u)-1;
+ audio_stream_Count=(int8u)-1;
+ private_stream_1_Count=(int8u)-1;
+ private_stream_2_Count=(int8u)-1;
+ extension_stream_Count=(int8u)-1;
+ SL_packetized_stream_Count=(int8u)-1;
+ FromTS=false;
+ }
+ }
+
+ //If we have no Streams map --> Registering the Streams as MPEG Audio
+ if (Streams[stream_id].stream_type==0 && !FromTS)
+ {
+ if (MPEG_Version==2)
+ Streams[stream_id].stream_type=0x04; //MPEG-2 Audio
+ else
+ Streams[stream_id].stream_type=0x03; //MPEG-1 Audio
+ }
+
+ //Registering
+ if (!Status[IsAccepted])
+ {
+ Data_Accept("MPEG-PS");
+ if (!IsSub)
+ Fill(Stream_General, 0, General_Format, "MPEG-PS");
+ }
+ Streams[stream_id].StreamIsRegistred++;
+
+ //New parsers
+ Streams[stream_id].Parsers.push_back(private_stream_1_ChooseParser());
+ if (Streams[stream_id].Parsers[Streams[stream_id].Parsers.size()-1]==NULL)
+ {
+ Streams[stream_id].Parsers.clear();
+ #if defined(MEDIAINFO_MPEGA_YES)
+ Streams[stream_id].Parsers.push_back(ChooseParser_Mpega());
+ #endif
+ #if defined(MEDIAINFO_AC3_YES)
+ Streams[stream_id].Parsers.push_back(ChooseParser_AC3());
+ #endif
+ #if defined(MEDIAINFO_DTS_YES)
+ Streams[stream_id].Parsers.push_back(ChooseParser_DTS());
+ #endif
+ #if defined(MEDIAINFO_AAC_YES)
+ Streams[stream_id].Parsers.push_back(ChooseParser_Adts());
+ #endif
+ #if defined(MEDIAINFO_AAC_YES)
+ Streams[stream_id].Parsers.push_back(ChooseParser_Latm());
+ #endif
+ }
+ for (size_t Pos=0; Pos<Streams[stream_id].Parsers.size(); Pos++)
+ Open_Buffer_Init(Streams[stream_id].Parsers[Pos]);
+ }
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ if (Streams[stream_id].Parsers.empty() || !Streams[stream_id].Parsers[0]->Demux_UnpacketizeContainer)
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ //Parsing
+ xxx_stream_Parse(Streams[stream_id], audio_stream_Count);
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ {
+ Demux_StreamIsBeingParsed_type=0;
+ Demux_StreamIsBeingParsed_stream_id=stream_id;
+ }
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_MpegPs::video_stream()
+{
+ Element_Name("Video");
+
+ if (!Streams[stream_id].StreamIsRegistred)
+ {
+ //For TS streams, which does not have Start chunk
+ if (FromTS)
+ {
+ if (video_stream_Count==(int8u)-1 && audio_stream_Count==(int8u)-1)
+ {
+ video_stream_Count=1;
+ audio_stream_Count=0;
+ private_stream_1_Count=0;
+ private_stream_2_Count=0;
+ extension_stream_Count=0;
+ SL_packetized_stream_Count=0;
+ Streams[stream_id].stream_type=FromTS_stream_type;
+ }
+ else if (!IsSub)
+ {
+ //2 streams in the file, this can not be From TS, we have no idea of the count of streams
+ video_stream_Count=(int8u)-1;
+ audio_stream_Count=(int8u)-1;
+ private_stream_1_Count=(int8u)-1;
+ private_stream_2_Count=(int8u)-1;
+ extension_stream_Count=(int8u)-1;
+ SL_packetized_stream_Count=(int8u)-1;
+ FromTS=false;
+ }
+ }
+
+ //Registering
+ if (!Status[IsAccepted])
+ {
+ Data_Accept("MPEG-PS");
+ if (!IsSub)
+ Fill(Stream_General, 0, General_Format, "MPEG-PS");
+ }
+ Streams[stream_id].StreamIsRegistred++;
+
+ //New parsers
+ switch (Streams[stream_id].stream_type)
+ {
+ case 0x10 : Streams[stream_id].Parsers.push_back(ChooseParser_Mpeg4v()); break;
+ case 0x1B : Streams[stream_id].Parsers.push_back(ChooseParser_Avc() ); break;
+ case 0x01 :
+ case 0x02 :
+ case 0x80 : Streams[stream_id].Parsers.push_back(ChooseParser_Mpegv() ); break;
+ default :
+ #if defined(MEDIAINFO_MPEGV_YES)
+ Streams[stream_id].Parsers.push_back(ChooseParser_Mpegv());
+ #endif
+ #if defined(MEDIAINFO_AVC_YES)
+ Streams[stream_id].Parsers.push_back(ChooseParser_Avc());
+ #endif
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ Streams[stream_id].Parsers.push_back(ChooseParser_Mpeg4v());
+ #endif
+ #if defined(MEDIAINFO_AVSV_YES)
+ {
+ File_AvsV* Parser=new File_AvsV;
+ Streams[stream_id].Parsers.push_back(Parser);
+ }
+ #endif
+ }
+ for (size_t Pos=0; Pos<Streams[stream_id].Parsers.size(); Pos++)
+ {
+ Open_Buffer_Init(Streams[stream_id].Parsers[Pos]);
+ #if MEDIAINFO_IBI
+ if (FromTS)
+ Streams[stream_id].Parsers[Pos]->IbiStream=IbiStream;
+ else
+ {
+ if (Ibi.Streams[stream_id]==NULL)
+ Ibi.Streams[stream_id]=new ibi::stream;
+ Streams[stream_id].Parsers[Pos]->IbiStream=Ibi.Streams[stream_id];
+ }
+ #endif //MEDIAINFO_IBI
+ #if MEDIAINFO_SEEK
+ if (Unsynch_Frame_Counts.find(stream_id)!=Unsynch_Frame_Counts.end())
+ Streams[stream_id].Parsers[Pos]->Frame_Count_NotParsedIncluded=Unsynch_Frame_Counts[stream_id];
+ #endif //MEDIAINFO_SEEK
+ }
+ #if MEDIAINFO_SEEK
+ if (Unsynch_Frame_Counts.find(stream_id)!=Unsynch_Frame_Counts.end())
+ Unsynch_Frame_Counts.erase(stream_id);
+ #endif //MEDIAINFO_SEEK
+ }
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ if (!(FromTS_stream_type==0x20 && SubStream_Demux) && (Streams[stream_id].Parsers.empty() || !Streams[stream_id].Parsers[0]->Demux_UnpacketizeContainer))
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ //Parsing
+ xxx_stream_Parse(Streams[stream_id], video_stream_Count);
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ {
+ Demux_StreamIsBeingParsed_type=0;
+ Demux_StreamIsBeingParsed_stream_id=stream_id;
+ }
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+// Packet "FA"
+void File_MpegPs::SL_packetized_stream()
+{
+ Element_Name("SL-packetized_stream");
+
+ if (!Streams[stream_id].StreamIsRegistred)
+ {
+ //For TS streams, which does not have Start chunk
+ if (FromTS)
+ {
+ if (video_stream_Count==(int8u)-1 && audio_stream_Count==(int8u)-1)
+ {
+ video_stream_Count=0;
+ audio_stream_Count=0;
+ private_stream_1_Count=0;
+ private_stream_2_Count=0;
+ extension_stream_Count=0;
+ SL_packetized_stream_Count=1;
+ Streams[stream_id].stream_type=FromTS_stream_type;
+ }
+ else if (!IsSub)
+ {
+ //2 streams in the file, this can not be From TS, we have no idea of the count of streams
+ video_stream_Count=(int8u)-1;
+ audio_stream_Count=(int8u)-1;
+ private_stream_1_Count=(int8u)-1;
+ private_stream_2_Count=(int8u)-1;
+ extension_stream_Count=(int8u)-1;
+ SL_packetized_stream_Count=(int8u)-1;
+ FromTS=false;
+ }
+ }
+
+ //Registering
+ Streams[stream_id].StreamIsRegistred++;
+ if (!Status[IsAccepted])
+ Data_Accept("MPEG-PS");
+ Streams[stream_id].Searching_TimeStamp_Start=true;
+
+ //New parsers
+ #ifdef MEDIAINFO_MPEG4_YES
+ if (ParserFromTs)
+ {
+ Streams[stream_id].Parsers.push_back(ParserFromTs); ParserFromTs=NULL;
+ }
+ else
+ #endif
+ if (FromTS_stream_type)
+ switch (FromTS_stream_type)
+ {
+ case 0x0F :
+ Streams[stream_id].Parsers.push_back(ChooseParser_Adts());
+ break;
+
+ case 0x11 :
+ Streams[stream_id].Parsers.push_back(ChooseParser_Latm());
+ break;
+ default : ;
+ }
+ else
+ {
+ #if defined(MEDIAINFO_AAC_YES)
+ Streams[stream_id].Parsers.push_back(ChooseParser_Adts());
+ #endif
+ #if defined(MEDIAINFO_AAC_YES)
+ Streams[stream_id].Parsers.push_back(ChooseParser_Latm());
+ #endif
+ }
+ for (size_t Pos=0; Pos<Streams[stream_id].Parsers.size(); Pos++)
+ Open_Buffer_Init(Streams[stream_id].Parsers[Pos]);
+ }
+
+ //Parsing
+ #ifdef MEDIAINFO_MPEG4_YES
+ if (SLConfig) //SL
+ {
+ BS_Begin();
+ int8u paddingBits=0;
+ bool paddingFlag=false, idleFlag=false, DegPrioflag=false, OCRflag=false,
+ accessUnitStartFlag=false, accessUnitEndFlag=false,
+ decodingTimeStampFlag=false, compositionTimeStampFlag=false,
+ instantBitrateFlag=false;
+ if (SLConfig->useAccessUnitStartFlag)
+ Get_SB (accessUnitStartFlag, "accessUnitStartFlag");
+ if (SLConfig->useAccessUnitEndFlag)
+ Get_SB (accessUnitEndFlag, "accessUnitEndFlag");
+ if (SLConfig->OCRLength>0)
+ Get_SB (OCRflag, "OCRflag");
+ if (SLConfig->useIdleFlag)
+ Get_SB (idleFlag, "idleFlag");
+ if (SLConfig->usePaddingFlag)
+ Get_SB (paddingFlag, "paddingFlag");
+ if (paddingFlag)
+ Get_S1(3, paddingBits, "paddingBits");
+ if (!idleFlag && (!paddingFlag || paddingBits!=0))
+ {
+ if (SLConfig->packetSeqNumLength>0)
+ Skip_S2(SLConfig->packetSeqNumLength, "packetSequenceNumber");
+ if (SLConfig->degradationPriorityLength>0)
+ Get_SB (DegPrioflag, "DegPrioflag");
+ if (DegPrioflag)
+ Skip_S2(SLConfig->degradationPriorityLength, "degradationPriority");
+ if (OCRflag)
+ Skip_S8(SLConfig->OCRLength, "objectClockReference");
+ if (accessUnitStartFlag)
+ {
+ if (SLConfig->useRandomAccessPointFlag)
+ Skip_SB( "randomAccessPointFlag");
+ if (SLConfig->AU_seqNumLength >0)
+ Skip_S2(SLConfig->AU_seqNumLength, "AU_sequenceNumber");
+ if (SLConfig->useTimeStampsFlag)
+ {
+ Get_SB (decodingTimeStampFlag, "decodingTimeStampFlag");
+ Get_SB (compositionTimeStampFlag, "compositionTimeStampFlag");
+ }
+ if (SLConfig->instantBitrateLength>0)
+ Get_SB (instantBitrateFlag, "instantBitrateFlag");
+ if (decodingTimeStampFlag)
+ Skip_S2(SLConfig->timeStampLength, "decodingTimeStamp");
+ if (compositionTimeStampFlag)
+ Skip_S2(SLConfig->timeStampLength, "compositionTimeStamp");
+ if (SLConfig->AU_Length > 0)
+ Skip_S2(SLConfig->AU_Length, "accessUnitLength");
+ if (instantBitrateFlag)
+ Skip_S2(SLConfig->instantBitrateLength, "instantBitrate");
+ }
+ }
+ BS_End();
+ }
+ #else //MEDIAINFO_MPEG4_YES
+ Skip_XX(Element_Size, "LATM (not decoded)");
+ #endif //MEDIAINFO_MPEG4_YES
+
+ //Demux
+ /*
+ if (Config_Demux)
+ {
+ int8u A[7];
+ //TODO: Only for 24KHz stuff, should be modified... output is ADTS
+ A[0]=0xFF;
+ A[1]=0xF9;
+ A[2]=0x58;
+ A[3]=0x80;
+ A[4]=0x00;
+ A[5]=0x1F;
+ A[6]=0xFC;
+
+ int32u Size=(int32u)(Element_Size+7);
+ Size=Size<<13;
+ A[3]=A[3]|((int8u)(Size>>24));
+ A[4]=A[4]|((int8u)(Size>>16));
+ A[5]=A[5]|((int8u)(Size>>8));
+
+ //Demux
+ Demux(A, 7, ContentType_Header);
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ }
+ */
+ #if MEDIAINFO_DEMUX
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ //Parsing
+ xxx_stream_Parse(Streams[stream_id], SL_packetized_stream_Count);
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ {
+ Demux_StreamIsBeingParsed_type=0;
+ Demux_StreamIsBeingParsed_stream_id=stream_id;
+ }
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+// Packet "FD"
+void File_MpegPs::extension_stream()
+{
+ Element_Name("With Extension");
+ Element_Info1(MpegPs_stream_id_extension(stream_id_extension));
+
+ if (!Streams_Extension[stream_id_extension].StreamIsRegistred)
+ {
+ //For TS streams, which does not have Start chunk
+ if (FromTS)
+ {
+ if (video_stream_Count==(int8u)-1 && audio_stream_Count==(int8u)-1)
+ {
+ video_stream_Count=0;
+ audio_stream_Count=0;
+ private_stream_1_Count=0;
+ private_stream_2_Count=0;
+ extension_stream_Count=1;
+ SL_packetized_stream_Count=0;
+ Streams_Extension[stream_id_extension].stream_type=FromTS_stream_type;
+ }
+ else if (!IsSub)
+ {
+ //2 streams in the file, this can not be From TS, we have no idea of the count of streams
+ video_stream_Count=(int8u)-1;
+ audio_stream_Count=(int8u)-1;
+ private_stream_1_Count=(int8u)-1;
+ private_stream_2_Count=(int8u)-1;
+ extension_stream_Count=(int8u)-1;
+ SL_packetized_stream_Count=(int8u)-1;
+ FromTS=false;
+ }
+ }
+
+ //Registering
+ if (!Status[IsAccepted])
+ Data_Accept("MPEG-PS");
+ Streams[stream_id].StreamIsRegistred++;
+ Streams_Extension[stream_id_extension].StreamIsRegistred++;
+ Streams_Extension[stream_id_extension].Searching_Payload=true;
+ Streams_Extension[stream_id_extension].Searching_TimeStamp_Start=true;
+ Streams_Extension[stream_id_extension].Searching_TimeStamp_End=true;
+
+ //New parsers
+ if (Streams_Extension[stream_id_extension].stream_type && Streams_Extension[stream_id_extension].stream_type<0x80) //Standard
+ switch (Streams_Extension[stream_id_extension].stream_type)
+ {
+ case 0x0F : Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_Adts()); break;
+ default : ;
+ }
+ else
+ switch (FromTS_format_identifier)
+ {
+ case 0x41432D33 :
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_AC3());
+ break;
+ case 0x44545331 :
+ case 0x44545332 :
+ case 0x44545333 :
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_DTS());
+ break;
+ case 0x56432D31 :
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_VC1());
+ break;
+ case 0x64726163 :
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_Dirac());
+ break;
+ default :
+ switch (FromTS_program_format_identifier)
+ {
+ case 0x48444D56 : //HDMV (BluRay)
+ switch (Streams_Extension[stream_id_extension].stream_type)
+ {
+ case 0x81 :
+ case 0x83 :
+ case 0x84 :
+ case 0xA1 :
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_AC3());
+ break;
+ case 0x82 :
+ case 0x85 :
+ case 0x86 :
+ case 0xA2 :
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_DTS());
+ break;
+ case 0xEA :
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_VC1());
+ break;
+ default : ;
+ }
+ break;
+ default : ;
+ if (stream_id_extension==0x00)
+ {} //IPMP Control Information stream
+ else if (stream_id_extension==0x01)
+ {} //IPMP stream
+ else if (stream_id_extension<=0x0F)
+ {} //ISO/IEC 14496-17 text stream
+ else if (stream_id_extension<=0x0F)
+ {} //ISO/IEC 23002-3 auxiliary video stream
+ else if (stream_id_extension>=0x55 && stream_id_extension<=0x5F)
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_VC1());
+ else if (stream_id_extension>=0x60 && stream_id_extension<=0x6F)
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_Dirac());
+ else if (stream_id_extension==0x71 || stream_id_extension==0x72 || stream_id_extension==0x76)
+ {
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_DTS());
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_AC3());
+ }
+ else if (stream_id_extension==0x75 && stream_id_extension<=0x7F)
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_VC1());
+ }
+ }
+
+ if (Streams_Extension[stream_id_extension].Parsers.empty())
+ {
+ #if defined(MEDIAINFO_DIRAC_YES)
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_Dirac());
+ #endif
+ #if defined(MEDIAINFO_VC1_YES)
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_VC1());
+ #endif
+ #if defined(MEDIAINFO_AC3_YES)
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_AC3());
+ #endif
+ #if defined(MEDIAINFO_DTS_YES)
+ Streams_Extension[stream_id_extension].Parsers.push_back(ChooseParser_DTS());
+ #endif
+ }
+
+ //In case of HD part before Core part
+ switch (stream_id_extension)
+ {
+ case 0x71 :
+ case 0x76 :
+ for (size_t Pos=0; Pos<Streams_Extension[0x72].Parsers.size(); Pos++)
+ delete Streams_Extension[0x72].Parsers[Pos]; //Streams_Extension[0x72].Parsers[Pos]=NULL;
+ Streams_Extension[0x72].Parsers.clear();
+ break;
+ }
+
+ //Init
+ for (size_t Pos=0; Pos<Streams_Extension[stream_id_extension].Parsers.size(); Pos++)
+ Open_Buffer_Init(Streams_Extension[stream_id_extension].Parsers[Pos]);
+ }
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ if (Streams_Extension[stream_id_extension].Searching_Payload)
+ {
+ StreamIDs[StreamIDs_Size-1]=Element_Code;
+ if (stream_id_extension==0x72 && !(Streams_Extension[0x71].Parsers.empty() && Streams_Extension[0x76].Parsers.empty()))
+ {
+ if (!Streams_Extension[0x71].Parsers.empty())
+ Element_Code=0x71;
+ if (!Streams_Extension[0x76].Parsers.empty())
+ Element_Code=0x76;
+ }
+ else
+ Element_Code=stream_id_extension; //The upper level ID is filled by Element_Code in the common code
+ StreamIDs_Width[StreamIDs_Size]=2;
+ ParserIDs[StreamIDs_Size]=MediaInfo_Parser_MpegPs_Ext;
+ StreamIDs_Size++;
+ if (stream_id_extension==0x72 && !(Streams_Extension[0x71].Parsers.empty() && Streams_Extension[0x76].Parsers.empty()))
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_SubStream);
+ else
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ StreamIDs_Size--;
+ Element_Code=StreamIDs[StreamIDs_Size-1];
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ //Parsing
+ if (stream_id_extension==0x72 && !(Streams_Extension[0x71].Parsers.empty() && Streams_Extension[0x76].Parsers.empty()))
+ {
+ if (!Streams_Extension[0x71].Parsers.empty())
+ {
+ xxx_stream_Parse(Streams_Extension[0x71], extension_stream_Count);
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ {
+ Demux_StreamIsBeingParsed_type=2;
+ Demux_StreamIsBeingParsed_stream_id=0x71;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+ if (!Streams_Extension[0x76].Parsers.empty())
+ {
+ xxx_stream_Parse(Streams_Extension[0x76], extension_stream_Count);
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ {
+ Demux_StreamIsBeingParsed_type=2;
+ Demux_StreamIsBeingParsed_stream_id=0x76;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+ }
+ else
+ {
+ xxx_stream_Parse(Streams_Extension[stream_id_extension], extension_stream_Count);
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ {
+ Demux_StreamIsBeingParsed_type=2;
+ Demux_StreamIsBeingParsed_stream_id=stream_id_extension;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+}
+
+//---------------------------------------------------------------------------
+const ZenLib::Char* File_MpegPs::extension_stream_ChooseExtension()
+{
+ //AC3
+ if ((stream_id_extension>=0x55 && stream_id_extension<=0x5F)
+ || (stream_id_extension==0x75 && stream_id_extension<=0x7F))
+ return _T(".vc1");
+ //AC3+
+ else if (stream_id_extension>=0x60 && stream_id_extension<=0x6F)
+ return _T(".dirac");
+ else if (stream_id_extension==0x71)
+ return private_stream_1_ChooseExtension();
+ else
+ return _T(".raw");
+}
+
+//***************************************************************************
+// xxx_stream helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpegPs::xxx_stream_Parse(ps_stream &Temp, int8u &stream_Count)
+{
+ switch (stream_id)
+ {
+ case 0xBD :
+ case 0xFD :
+ //PTS
+ if (Streams[stream_id].TimeStamp_End.PTS.TimeStamp!=(int64u)-1)
+ {
+ if (Streams[stream_id].Searching_TimeStamp_End)
+ {
+ Temp.TimeStamp_End.PTS.File_Pos=File_Offset+Buffer_Offset;
+ Temp.TimeStamp_End.PTS.TimeStamp=Streams[stream_id].TimeStamp_End.PTS.TimeStamp;
+ }
+ if (Searching_TimeStamp_Start && Temp.Searching_TimeStamp_Start)
+ {
+ Temp.TimeStamp_Start.PTS.TimeStamp=Streams[stream_id].TimeStamp_End.PTS.TimeStamp;
+ Temp.Searching_TimeStamp_Start=false;
+ }
+ }
+
+ //DTS
+ if (Streams[stream_id].TimeStamp_End.DTS.TimeStamp!=(int64u)-1)
+ {
+ if (Streams[stream_id].Searching_TimeStamp_End)
+ {
+ Temp.TimeStamp_End.DTS.File_Pos=File_Offset+Buffer_Offset;
+ Temp.TimeStamp_End.DTS.TimeStamp=Streams[stream_id].TimeStamp_End.DTS.TimeStamp;
+ }
+ if (Searching_TimeStamp_Start && Streams[stream_id].TimeStamp_End.DTS.TimeStamp!=(int64u)-1 && Temp.Searching_TimeStamp_Start)
+ {
+ Temp.TimeStamp_Start.DTS.TimeStamp=Streams[stream_id].TimeStamp_End.DTS.TimeStamp;
+ Temp.Searching_TimeStamp_Start=false;
+ }
+ }
+ default : ;
+ }
+
+ //Needed?
+ if (Temp.Parsers.size()==1 && Temp.Parsers[0]->Status[IsFinished])
+ {
+ Skip_XX(Element_Size-Element_Offset, "data");
+ return;
+ }
+
+ #if MEDIAINFO_TRACE
+ if (stream_id==0xBD)
+ private_stream_1_Element_Info1();
+ #endif //MEDIAINFO_TRACE
+
+ for (size_t Pos=0; Pos<Temp.Parsers.size(); Pos++)
+ if (Temp.Parsers[Pos] && !Temp.Parsers[Pos]->Status[IsFinished])
+ {
+ //PTS/DTS
+ if (Temp.Parsers[Pos]->PTS_DTS_Needed)
+ {
+ if (FrameInfo.PCR!=(int64u)-1)
+ Temp.Parsers[Pos]->FrameInfo.PCR=FrameInfo.PCR;
+ if (FrameInfo.PTS!=(int64u)-1)
+ Temp.Parsers[Pos]->FrameInfo.PTS=FrameInfo.PTS;
+ if (FrameInfo.DTS!=(int64u)-1)
+ Temp.Parsers[Pos]->FrameInfo.DTS=FrameInfo.DTS;
+ }
+
+ #if MEDIAINFO_TRACE
+ if (Temp.Parsers.size()>1)
+ Element_Begin1("Test");
+ #endif //MEDIAINFO_TRACE
+ #if MEDIAINFO_IBI
+ Temp.Parsers[Pos]->Ibi_SynchronizationOffset_Current=Ibi_SynchronizationOffset_Current;
+ #endif //MEDIAINFO_IBI
+ Open_Buffer_Continue(Temp.Parsers[Pos], Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+ if (IsSub && Temp.Parsers[Pos]->Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded=Temp.Parsers[Pos]->Frame_Count_NotParsedIncluded;
+ if (!MustExtendParsingDuration && Temp.Parsers[Pos]->MustExtendParsingDuration)
+ {
+ SizeToAnalyze*=4; //Normally 4 seconds, now 16 seconds
+ MustExtendParsingDuration=true;
+ }
+ #if MEDIAINFO_TRACE
+ if (Temp.Parsers.size()>1)
+ Element_End0();
+ #endif //MEDIAINFO_TRACE
+
+ if (Temp.Parsers.size()>1)
+ {
+ if (!Temp.Parsers[Pos]->Status[IsAccepted] && Temp.Parsers[Pos]->Status[IsFinished])
+ {
+ delete *(Temp.Parsers.begin()+Pos);
+ Temp.Parsers.erase(Temp.Parsers.begin()+Pos);
+ Pos--;
+ }
+ else if (Temp.Parsers.size()>1 && Temp.Parsers[Pos]->Status[IsAccepted])
+ {
+ File__Analyze* Parser=Temp.Parsers[Pos];
+ for (size_t Pos2=0; Pos2<Temp.Parsers.size(); Pos2++)
+ {
+ if (Pos2!=Pos)
+ delete *(Temp.Parsers.begin()+Pos2);
+ }
+ Temp.Parsers.clear();
+ Temp.Parsers.push_back(Parser);
+ }
+ }
+
+ if (Temp.Parsers.size()==1 && !Temp.IsFilled && Temp.Parsers[0]->Status[IsFilled])
+ {
+ stream_Count--;
+ Temp.IsFilled=true;
+ }
+ }
+ //FrameInfo.PCR=(int64u)-1;
+ FrameInfo.DTS=(int64u)-1;
+ FrameInfo.PTS=(int64u)-1;
+ Element_Show();
+
+ #if MEDIAINFO_EVENTS
+ if (FrameInfo.DTS==(int64u)-1)
+ FrameInfo.DTS=FrameInfo.PTS;
+
+ //New PES
+ #if MEDIAINFO_DEMUX
+ if (PES_FirstByte_IsAvailable && PES_FirstByte_Value)
+ {
+ //Demux of substream data
+ if (FromTS_stream_type==0x1B && SubStream_Demux)
+ {
+ if (!SubStream_Demux->Buffers.empty() && !SubStream_Demux->Buffers.empty() && SubStream_Demux->Buffers[0] && SubStream_Demux->Buffers[0]->DTS<FrameInfo.DTS)
+ {
+ Demux(SubStream_Demux->Buffers[0]->Buffer, SubStream_Demux->Buffers[0]->Buffer_Size, ContentType_SubStream);
+ delete SubStream_Demux->Buffers[0]->Buffer; SubStream_Demux->Buffers[0]->Buffer=NULL;
+ SubStream_Demux->Buffers.erase(SubStream_Demux->Buffers.begin()); //Moving 2nd Buffer to 1st position
+ }
+ }
+ }
+
+ //Demux of SubStream
+ if (FromTS_stream_type==0x20 && SubStream_Demux)
+ {
+ //Searching an available slot
+ size_t Buffers_Pos;
+ if (SubStream_Demux->Buffers.empty() || SubStream_Demux->Buffers[SubStream_Demux->Buffers.size()-1]->DTS!=FrameInfo.DTS)
+ {
+ Buffers_Pos=SubStream_Demux->Buffers.size();
+ SubStream_Demux->Buffers.push_back(new demux::buffer);
+ }
+ else
+ {
+ Buffers_Pos=SubStream_Demux->Buffers.size()-1;
+ }
+
+ //Filling buffer
+ if (SubStream_Demux->Buffers[Buffers_Pos]->Buffer==NULL)
+ {
+ SubStream_Demux->Buffers[Buffers_Pos]->DTS=FrameInfo.DTS;
+ SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size_Max=128*1024;
+ SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size=0;
+ SubStream_Demux->Buffers[Buffers_Pos]->Buffer=new int8u[SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size_Max];
+ }
+ if (SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size_Max>SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size+(size_t)(Element_Size-Element_Offset) && SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size_Max<=16*1024*1024)
+ {
+ SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size_Max*=2;
+ int8u* Buffer_Demux=SubStream_Demux->Buffers[Buffers_Pos]->Buffer;
+ SubStream_Demux->Buffers[Buffers_Pos]->Buffer=new int8u[SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size_Max];
+ std::memcpy(SubStream_Demux->Buffers[Buffers_Pos]->Buffer, Buffer_Demux, SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size);
+ delete[] Buffer_Demux; //Buffer_Demux=NULL;
+ }
+ if (SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size+(size_t)(Element_Size-Element_Offset)<=SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size_Max)
+ {
+ std::memcpy(SubStream_Demux->Buffers[Buffers_Pos]->Buffer+SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+ SubStream_Demux->Buffers[Buffers_Pos]->Buffer_Size+=(size_t)(Element_Size-Element_Offset);
+ }
+ }
+ #endif //MEDIAINFO_DEMUX
+ #endif //MEDIAINFO_EVENTS
+
+ #if MEDIAINFO_SEEK
+ if (Seek_ID!=(int64u)-1)
+ {
+ if (Ibi.Streams[Seek_ID]->IsModified)
+ {
+ Read_Buffer_Seek(2, Seek_Value, Seek_ID);
+ }
+ else if (File_Offset+Buffer_Offset>=Seek_Value_Maximal)
+ {
+ //No intermediate seek point found, going to previous seek point
+ for (size_t Pos=1; Pos<Ibi.Streams[Seek_ID]->Infos.size(); Pos++)
+ if (Ibi.Streams[Seek_ID]->Infos[Pos].StreamOffset>=Seek_Value_Maximal)
+ {
+ if (Ibi.Streams[Seek_ID]->IsSynchronized)
+ {
+ //No intermediate point is possible
+ Ibi.Streams[Seek_ID]->Infos[Pos-1].IsContinuous=true;
+ Read_Buffer_Seek(2, Seek_Value, Seek_ID);
+ }
+ else
+ {
+ //Going to last known seek point
+ GoTo(Ibi.Streams[Seek_ID]->Infos[Pos-1].StreamOffset);
+ Open_Buffer_Unsynch();
+ }
+ break;
+ }
+ }
+ }
+ #endif //MEDIAINFO_SEEK
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_MpegPs::Header_Parser_QuickSearch()
+{
+ while ( Buffer_Offset+4<=Buffer_Size
+ && CC3(Buffer+Buffer_Offset)==0x000001)
+ {
+ //Getting stream_id
+ int8u stream_id=Buffer[Buffer_Offset+3];
+
+ //Trace config
+ #if MEDIAINFO_TRACE
+ if (Config_Trace_Level)
+ {
+ if (stream_id==0xC0 || stream_id==0xE0)
+ {
+ if (!Trace_Layers[8])
+ Trace_Layers_Update(8); //Stream
+ }
+ else
+ Trace_Layers_Update(IsSub?1:0);
+ }
+ #endif //MEDIAINFO_TRACE
+
+ //Searching start
+ if (Streams[stream_id].Searching_Payload)
+ {
+ if (stream_id!=0xBD || !private_stream_1_IsDvdVideo) //Not (private_stream_1 and IsDvdVideo)
+ return true;
+
+ //private_stream_1 and IsDvdVideo, looking for substream ID
+ if (Buffer_Offset+9>=Buffer_Size)
+ return false; //Need more data
+ size_t Data_Offset=Buffer[Buffer_Offset+8];
+ if (Buffer_Offset+9+Data_Offset>=Buffer_Size)
+ return false; //Need more data
+ int8u private_stream_1_ID=Buffer[Buffer_Offset+9+Data_Offset];
+ if (!Streams_Private1[private_stream_1_ID].StreamIsRegistred || Streams_Private1[private_stream_1_ID].Searching_Payload)
+ return true;
+ }
+
+ //Searching TimeStamp_End
+ if (Streams[stream_id].Searching_TimeStamp_End)
+ {
+ switch(stream_id)
+ {
+ //Element with no PES Header
+ case 0xB9 : //MPEG_program_end
+ case 0xBA : //pack_start
+ case 0xBB : //system_header_start
+ case 0xBC : //program_stream_map
+ case 0xBE : //padding_stream
+ case 0xBF : //private_stream_2
+ case 0xF0 : //ECM
+ case 0xF1 : //EMM
+ case 0xF2 : //DSMCC Streams
+ case 0xF8 : //ITU-T Rec. H .222.1 type E
+ case 0xFF : //Program Streams directory
+ break;
+
+ //Element with PES Header
+ default :
+ if (MPEG_Version==1)
+ {
+ size_t Buffer_Offset_Temp=Buffer_Offset+6;
+ while(Buffer_Offset_Temp<Buffer_Size && Buffer[Buffer_Offset_Temp]==0xFF)
+ {
+ Buffer_Offset_Temp++;
+ if (Buffer_Offset_Temp+1>=Buffer_Size)
+ return false; //Not enough data
+ }
+ if (Buffer_Offset_Temp+1>=Buffer_Size)
+ return false; //Not enough data
+ if (Buffer_Offset_Temp<Buffer_Size && (Buffer[Buffer_Offset_Temp]&0xF0)!=0x00)
+ return true; //With a PTS
+ }
+ if (MPEG_Version==2)
+ {
+ if (Buffer_Offset+8>Buffer_Size)
+ return false; //Not enough buffer
+ if ((Buffer[Buffer_Offset+7]&0xC0)!=0x00)
+ return true; //With a PTS
+ }
+ }
+ }
+
+ //Getting size
+ switch(stream_id)
+ {
+ //No size
+ case 0xB9 : //MPEG_program_end
+ case 0xBA : //pack_start
+ Buffer_Offset+=4;
+ while(Buffer_Offset+4<=Buffer_Size && !(CC3(Buffer+Buffer_Offset)==0x000001 && Buffer[Buffer_Offset+3]>=0xB9))
+ {
+ Buffer_Offset+=2;
+ while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Buffer_Offset+=2;
+ if (Buffer_Offset>=Buffer_Size || Buffer[Buffer_Offset-1]==0x00)
+ Buffer_Offset--;
+ }
+ //Parsing last bytes if needed
+ if (Buffer_Offset+4>Buffer_Size)
+ {
+ if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x000001)
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x0000)
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x00)
+ Buffer_Offset++;
+ }
+ break;
+
+ //Element with size
+ default :
+ if (Buffer_Offset+6>=Buffer_Size)
+ return false; //Not enough data
+ int16u Size=CC2(Buffer+Buffer_Offset+4);
+ if (Size>0)
+ {
+ Buffer_Offset+=6+Size;
+
+ //Trailing 0xFF
+ while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]==0xFF)
+ Buffer_Offset++;
+
+ //Trailing 0x00
+ while(Buffer_Offset+3<=Buffer_Size
+ && Buffer[Buffer_Offset+2]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset ]==0x00)
+ Buffer_Offset++;
+ }
+ else
+ {
+ Buffer_Offset+=6;
+ while(Buffer_Offset+4<=Buffer_Size && !(CC3(Buffer+Buffer_Offset)==0x000001 && Buffer[Buffer_Offset+3]>=0xB9))
+ Buffer_Offset++;
+ if (Buffer_Offset+4>Buffer_Size)
+ {
+ if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x000001)
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x0000)
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x00)
+ Buffer_Offset++;
+ }
+ }
+ }
+ }
+
+ if (Buffer_Offset+3==Buffer_Size)
+ return false; //Sync is OK, but stream_id is not available
+ if (Buffer_Offset+4<=Buffer_Size)
+ Trusted_IsNot("MPEG-PS, Synchronisation lost");
+ Synched=false;
+ return Synchronize();
+}
+
+//***************************************************************************
+// Parsers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_Mpegv()
+{
+ //Filling
+ #if defined(MEDIAINFO_MPEGV_YES)
+ File_Mpegv* Parser=new File_Mpegv;
+ Parser->MPEG_Version=MPEG_Version;
+ Parser->ShouldContinueParsing=true;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Format, "MPEG Video");
+ switch (FromTS_stream_type)
+ {
+ case 0x01 : Parser->Fill(Stream_Video, 0, Video_Codec, "MPEG-1V");
+ Parser->Fill(Stream_Video, 0, Video_Format_Version, "Version 1"); break;
+ case 0x02 : Parser->Fill(Stream_Video, 0, Video_Codec, "MPEG-2V");
+ Parser->Fill(Stream_Video, 0, Video_Format_Version, "Version 2"); break;
+ default : Parser->Fill(Stream_Video, 0, Video_Codec, "MPEG-V");
+ }
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_Mpeg4v()
+{
+ //Filling
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ File_Mpeg4v* Parser=new File_Mpeg4v;
+ Parser->Frame_Count_Valid=1;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Codec, "MPEG-4V");
+ Parser->Fill(Stream_Video, 0, Video_Format, "MPEG-4 Visual");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_Avc()
+{
+ //Filling
+ #if defined(MEDIAINFO_AVC_YES)
+ File_Avc* Parser=new File_Avc;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Codec, "AVC");
+ Parser->Fill(Stream_Video, 0, Video_Format, "AVC");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_VC1()
+{
+ //Filling
+ #if defined(MEDIAINFO_VC1_YES)
+ File_Vc1* Parser=new File_Vc1;
+ Parser->Frame_Count_Valid=30;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Codec, "VC-1");
+ Parser->Fill(Stream_Video, 0, Video_Format, "VC-1");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_Dirac()
+{
+ //Filling
+ #if defined(MEDIAINFO_DIRAC_YES)
+ File__Analyze* Parser=new File_Dirac;
+ ((File_Dirac*)Parser)->Frame_Count_Valid=1;
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Codec, "Dirac");
+ Parser->Fill(Stream_Video, 0, Video_Format, "Dirac");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_Mpega()
+{
+ //Filling
+ #if defined(MEDIAINFO_MPEGA_YES)
+ File_Mpega* Parser=new File_Mpega;
+ Parser->Frame_Count_Valid=1;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "MPEG Audio");
+ switch (FromTS_stream_type)
+ {
+ case 0x03 : Parser->Fill(Stream_Audio, 0, Audio_Codec, "MPEG-1A");
+ Parser->Fill(Stream_Audio, 0, Audio_Format_Version, "Version 1"); break;
+ case 0x04 : Parser->Fill(Stream_Audio, 0, Audio_Codec, "MPEG-2A");
+ Parser->Fill(Stream_Audio, 0, Audio_Format_Version, "Version 2"); break;
+ default : Parser->Fill(Stream_Audio, 0, Audio_Codec, "MPEG-A"); break;
+ }
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_Adts()
+{
+ //Filling
+ #if defined(MEDIAINFO_AAC_YES)
+ File_Aac* Parser=new File_Aac;
+ Parser->Mode=File_Aac::Mode_ADTS;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Codec, "AAC");
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "AAC");
+ Parser->Fill(Stream_Audio, 0, Audio_MuxingMode, "ADTS");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_Latm()
+{
+ //Filling
+ #if defined(MEDIAINFO_AAC_YES)
+ File_Aac* Parser=new File_Aac;
+ Parser->Mode=File_Aac::Mode_LATM;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Codec, "AAC");
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "AAC");
+ Parser->Fill(Stream_Audio, 0, Audio_MuxingMode, "LATM");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_AC3()
+{
+ //Filling
+ #if defined(MEDIAINFO_AC3_YES)
+ File_Ac3* Parser=new File_Ac3();
+ Parser->Frame_Count_Valid=2; //2 frames to be sure
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, private_stream_1_ID==0x83?"E-AC-3":"AC-3");
+ Parser->Fill(Stream_Audio, 0, Audio_Codec, private_stream_1_ID==0x83?"AC3+":"AC3");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_DTS()
+{
+ //Filling
+ #if defined(MEDIAINFO_DTS_YES)
+ File__Analyze* Parser=new File_Dts();
+ ((File_Dts*)Parser)->Frame_Count_Valid=2;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "DTS");
+ Parser->Fill(Stream_Audio, 0, Audio_Codec, "DTS");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_SDDS()
+{
+ //Filling
+ #if defined(MEDIAINFO_SDDS_YES)
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, StreamPos_Last, Audio_Format, "SDDS");
+ Parser->Fill(Stream_Audio, StreamPos_Last, Audio_Codec, "SDDS");
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "SDDS");
+ Parser->Fill(Stream_Audio, 0, Audio_Codec, "SDDS");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_AAC()
+{
+ //Filling
+ #if defined(MEDIAINFO_AAC_YES)
+ File_Aac* Parser=new File_Aac;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "AAC");
+ Parser->Fill(Stream_Audio, 0, Audio_Codec, "AAC");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_PCM()
+{
+ //Filling
+ #if defined(MEDIAINFO_PCM_YES)
+ File_Pcm* Parser=new File_Pcm();
+ Parser->IsRawPcm=false;
+ Ztring Codec;
+ switch (FromTS_stream_type)
+ {
+ case 0x80 : Codec=_T("M2TS"); break;
+ case 0x83 : Codec=_T("EVOB"); break;
+ default : Codec=_T("VOB");
+ }
+ ((File_Pcm*)Parser)->Codec=Codec;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ Parser->Fill(Stream_Audio, 0, Audio_Codec, "PCM");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_RLE()
+{
+ //Filling
+ #if defined(MEDIAINFO_RLE_YES)
+ File__Analyze* Parser=new File_Rle();
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Text);
+ Parser->Fill(Stream_Text, 0, Text_Format, "RLE");
+ Parser->Fill(Stream_Text, 0, Text_Codec, "RLE");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_DvbSubtitle()
+{
+ //Filling
+ #if defined(MEDIAINFO_DVBSUBTITLE_YES)
+ File__Analyze* Parser=new File_DvbSubtitle();
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Text);
+ Parser->Fill(Stream_Text, 0, Text_Format, "DVB Subtitle");
+ Parser->Fill(Stream_Text, 0, Text_Codec, "DVB Subtitle");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_Teletext()
+{
+ //Filling
+ #if defined(MEDIAINFO_TELETEXT_YES)
+ File__Analyze* Parser=new File_Teletext();
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Text);
+ Parser->Fill(Stream_Text, 0, Text_Format, "Teletext");
+ Parser->Fill(Stream_Text, 0, Text_Codec, "Teletext");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_PGS()
+{
+ //Filling
+ #if defined(MEDIAINFO_PGS_YES)
+ File__Analyze* Parser=new File_Pgs();
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Text);
+ Parser->Fill(Stream_Text, 0, Text_Format, "PGS");
+ Parser->Fill(Stream_Text, 0, Text_Codec, "PGS");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_AES3()
+{
+ //Filling
+ #if defined(MEDIAINFO_AES3_YES)
+ File_Aes3* Parser=new File_Aes3();
+ Parser->From_MpegPs=true;
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ {
+ Demux_UnpacketizeContainer=false; //No demux from this parser
+ Demux_Level=4; //Intermediate
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "AES3");
+ Parser->Fill(Stream_Audio, 0, Audio_Codec, "AES3");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_PS2()
+{
+ //Filling
+ #if defined(MEDIAINFO_PS2A_YES)
+ File__Analyze* Parser=new File_Ps2Audio();
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_MpegPs::ChooseParser_NULL()
+{
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ return Parser;
+}
+
+//***************************************************************************
+// Output_Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t File_MpegPs::Output_Buffer_Get (const String &Code)
+{
+ //Parsing Parsers
+ for (size_t Streams_Pos=0; Streams_Pos<Streams.size(); Streams_Pos++)
+ for (size_t Pos=0; Pos<Streams[Streams_Pos].Parsers.size(); Pos++)
+ if (Streams[Streams_Pos].Parsers[Pos])
+ if (size_t Size=Streams[Streams_Pos].Parsers[Pos]->Output_Buffer_Get(Code))
+ return Size;
+
+ return 0;
+}
+
+//---------------------------------------------------------------------------
+size_t File_MpegPs::Output_Buffer_Get (size_t Pos_)
+{
+ //Parsing Parsers
+ for (size_t Streams_Pos=0; Streams_Pos<Streams.size(); Streams_Pos++)
+ for (size_t Pos=0; Pos<Streams[Streams_Pos].Parsers.size(); Pos++)
+ if (Streams[Streams_Pos].Parsers[Pos])
+ if (size_t Size=Streams[Streams_Pos].Parsers[Pos]->Output_Buffer_Get(Pos_))
+ return Size;
+
+ return 0;
+}
+
+} //Namespace
+
+#endif //MEDIAINFO_MPEGPS_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegPs.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegPs.h
new file mode 100644
index 000000000..5cb645d55
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegPs.h
@@ -0,0 +1,305 @@
+// File_Mpeg - Info for MPEG files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MPEG files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_MpegPsH
+#define MediaInfo_MpegPsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Multiple/File_Mpeg4_Descriptors.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Mpeg
+//***************************************************************************
+
+class File_MpegPs : public File__Analyze
+{
+public :
+ //In
+ bool FromTS; //Indicate if stream comes from TS
+ int8u FromTS_stream_type; //ID from TS
+ int32u FromTS_program_format_identifier; //Registration from TS
+ int32u FromTS_format_identifier; //Registration from TS
+ int8u FromTS_descriptor_tag; //Descriptor from TS
+ int8u MPEG_Version; //MPEG Version (or automaticly detected)
+ bool Searching_TimeStamp_Start;
+ #ifdef MEDIAINFO_MPEG4_YES
+ File__Analyze* ParserFromTs;
+ File_Mpeg4_Descriptors::slconfig* SLConfig;
+ #endif
+ #if MEDIAINFO_DEMUX
+ struct demux
+ {
+ struct buffer
+ {
+ int64u DTS;
+ size_t Buffer_Size;
+ size_t Buffer_Size_Max;
+ int8u* Buffer;
+
+ buffer()
+ {
+ DTS=(int64u)-1;
+ Buffer_Size=0;
+ Buffer_Size_Max=0;
+ Buffer=NULL;
+ }
+
+ ~buffer()
+ {
+ delete[] Buffer;
+ }
+ };
+ std::vector<buffer*> Buffers;
+
+ demux()
+ {
+ }
+
+ ~demux()
+ {
+ for (size_t Pos=0; Pos<Buffers.size(); Pos++)
+ delete Buffers[Pos]; //Buffers[Pos]=NULL;
+ }
+ };
+ demux* SubStream_Demux;
+ int8u Demux_StreamIsBeingParsed_type;
+ int8u Demux_StreamIsBeingParsed_stream_id;
+ #endif //MEDIAINFO_DEMUX
+ #if MEDIAINFO_SEEK
+ int64u Unsynch_Frame_Count_Temp;
+ #endif //MEDIAINFO_SEEK
+
+ //Out
+ bool HasTimeStamps;
+
+ //Constructor/Destructor
+ File_MpegPs();
+ ~File_MpegPs();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin() {return FileHeader_Begin_0x000001();}
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+ void Synched_Init();
+
+ //Buffer - Global
+ void Read_Buffer_Init ();
+ void Read_Buffer_Unsynched();
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+ void Read_Buffer_Continue ();
+ void Read_Buffer_AfterParsing();
+
+ //Buffer - Per element
+ void Header_Parse();
+ bool Header_Parse_Fill_Size();
+ bool Header_Parse_PES_packet(int8u stream_id);
+ void Header_Parse_PES_packet_MPEG1(int8u stream_id);
+ void Header_Parse_PES_packet_MPEG2(int8u stream_id);
+ void Data_Parse();
+ bool BookMark_Needed();
+
+ //Packet
+ void MPEG_program_end(); //0xB9
+ void pack_start(); //0xBA
+ void system_header_start(); //0xBB
+ void program_stream_map(); //0xBC
+ void private_stream_1(); //0xBD
+ void padding_stream(); //0xBE
+ void private_stream_2(); //0xBF
+ void audio_stream(); //0xC0 --> 0xDF
+ void video_stream(); //0xE0 --> 0xEF
+ void SL_packetized_stream();//0xFA
+ void extension_stream(); //0xFD
+
+ //private_stream_1 specific
+ bool private_stream_1_Choose_DVD_ID();
+ File__Analyze* private_stream_1_ChooseParser();
+ const ZenLib::Char* private_stream_1_ChooseExtension();
+ #if MEDIAINFO_TRACE
+ void private_stream_1_Element_Info1();
+ #endif //MEDIAINFO_TRACE
+ int8u private_stream_1_ID;
+ size_t private_stream_1_Offset;
+ bool private_stream_1_IsDvdVideo;
+
+ //private_stream_2 specific
+ void private_stream_2_TSHV_A0();
+ void private_stream_2_TSHV_A1();
+
+ //extension_stream specific
+ const ZenLib::Char* extension_stream_ChooseExtension();
+
+ //Count
+ int8u video_stream_Count;
+ int8u audio_stream_Count;
+ int8u private_stream_1_Count;
+ int8u private_stream_2_Count;
+ int8u extension_stream_Count;
+ int8u SL_packetized_stream_Count;
+
+ //From packets
+ int32u program_mux_rate;
+
+ //PS
+ struct ps_stream
+ {
+ struct Mpeg_TimeStamp
+ {
+ struct Mpeg_TimeStamp_TS
+ {
+ int64u File_Pos;
+ int64u TimeStamp;
+
+ Mpeg_TimeStamp_TS()
+ {
+ File_Pos=(int64u)-1;
+ TimeStamp=(int64u)-1;
+ }
+ };
+
+ Mpeg_TimeStamp_TS PTS;
+ Mpeg_TimeStamp_TS DTS;
+ };
+
+ stream_t StreamKind;
+ size_t StreamPos;
+ int8u stream_type;
+ int32u program_format_identifier;
+ int32u format_identifier;
+ int8u descriptor_tag;
+ int8u DVD_Identifier;
+ std::vector<File__Analyze*> Parsers; //Sometimes, we need to do parallel tests
+ Mpeg_TimeStamp TimeStamp_Start;
+ Mpeg_TimeStamp TimeStamp_End;
+ size_t StreamIsRegistred;
+ bool Searching_Payload;
+ bool Searching_TimeStamp_Start;
+ bool Searching_TimeStamp_End;
+ bool IsFilled;
+
+ ps_stream()
+ {
+ StreamKind=Stream_Max;
+ StreamPos=0;
+ stream_type=0;
+ program_format_identifier=0x00000000; //No info
+ format_identifier=0x00000000; //No info
+ descriptor_tag=0x00; //No info
+ DVD_Identifier=0;
+ StreamIsRegistred=0;
+ Searching_Payload=false;
+ Searching_TimeStamp_Start=false;
+ Searching_TimeStamp_End=false;
+ IsFilled=false;
+ }
+
+ ~ps_stream()
+ {
+ for (size_t Pos=0; Pos<Parsers.size(); Pos++)
+ delete Parsers[Pos]; //Parsers[Pos]=NULL;
+ }
+ };
+ std::vector<ps_stream> Streams;
+ std::vector<ps_stream> Streams_Private1; //There can have multiple streams in one private stream
+ std::vector<ps_stream> Streams_Extension; //There can have multiple streams in one private stream
+ int8u stream_id;
+
+ //Temp
+ int64u SizeToAnalyze; //Total size of a chunk to analyse, it may be changed by the parser
+ int8u stream_id_extension;
+ bool video_stream_Unlimited;
+ int16u Buffer_DataSizeToParse;
+ std::vector<int64u> video_stream_PTS;
+
+ //Helpers
+ bool Header_Parser_QuickSearch();
+
+ //Parsers
+ File__Analyze* ChooseParser_Mpegv();
+ File__Analyze* ChooseParser_Mpeg4v();
+ File__Analyze* ChooseParser_Avc();
+ File__Analyze* ChooseParser_VC1();
+ File__Analyze* ChooseParser_Dirac();
+ File__Analyze* ChooseParser_Mpega();
+ File__Analyze* ChooseParser_Adts();
+ File__Analyze* ChooseParser_Latm();
+ File__Analyze* ChooseParser_AC3();
+ File__Analyze* ChooseParser_DTS();
+ File__Analyze* ChooseParser_SDDS();
+ File__Analyze* ChooseParser_AAC();
+ File__Analyze* ChooseParser_PCM();
+ File__Analyze* ChooseParser_AES3();
+ File__Analyze* ChooseParser_RLE();
+ File__Analyze* ChooseParser_DvbSubtitle();
+ File__Analyze* ChooseParser_PGS();
+ File__Analyze* ChooseParser_Teletext();
+ File__Analyze* ChooseParser_PS2();
+ File__Analyze* ChooseParser_NULL();
+
+ //File__Analyze helpers
+ enum kindofstream
+ {
+ KindOfStream_Main,
+ KindOfStream_Private,
+ KindOfStream_Extension,
+ };
+ void Streams_Fill_PerStream(size_t StreamID, ps_stream &Temp, kindofstream KindOfStream);
+ void Streams_Finish_PerStream(size_t StreamID, ps_stream &Temp, kindofstream KindOfStream);
+ void xxx_stream_Parse(ps_stream &Temp, int8u &stream_Count);
+
+ //Output buffer
+ size_t Output_Buffer_Get (const String &Value);
+ size_t Output_Buffer_Get (size_t Pos);
+
+ #if MEDIAINFO_SEEK
+ std::map<int16u, int64u> Unsynch_Frame_Counts;
+ int64u Seek_Value;
+ int64u Seek_Value_Maximal;
+ int64u Seek_ID;
+ bool Duration_Detected;
+ #endif //MEDIAINFO_SEEK
+ #if MEDIAINFO_SEEK && MEDIAINFO_IBI
+ ibi Ibi;
+ #endif //MEDIAINFO_SEEK && MEDIAINFO_IBI
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs.cpp
new file mode 100644
index 000000000..a42ec0abd
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs.cpp
@@ -0,0 +1,2499 @@
+// File_Mpegts - Info for MPEG Transport Stream files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEGTS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_MpegTs.h"
+#include "MediaInfo/Multiple/File_MpegPs.h"
+#include "MediaInfo/Multiple/File_Mpeg_Descriptors.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "MediaInfo/MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "ZenLib/File.h"
+#include <memory>
+#include <algorithm>
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+ #include "MediaInfo/MediaInfo_Events_Internal.h"
+#endif //MEDIAINFO_EVENTS
+#if MEDIAINFO_IBI
+ #if MEDIAINFO_SEEK
+ #include "MediaInfo/Multiple/File_Ibi.h"
+ #endif //MEDIAINFO_SEEK
+ #include "MediaInfo/Multiple/File_Ibi_Creation.h"
+#endif //MEDIAINFO_IBI
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+namespace Elements
+{
+ const int32u HDMV=0x48444D56; //BluRay
+}
+
+//***************************************************************************
+// Depends of configuration
+//***************************************************************************
+
+#if !defined(MEDIAINFO_BDAV_YES)
+ const size_t BDAV_Size=0;
+#endif
+#if !defined(MEDIAINFO_TSP_YES)
+ const size_t TSP_Size=0;
+#endif
+#if !defined(MEDIAINFO_BDAV_YES) && !defined(MEDIAINFO_TSP_YES)
+ const size_t TS_Size=188;
+#endif
+
+//***************************************************************************
+// Info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//From Mpeg_Psi
+extern const char* Mpeg_Descriptors_registration_format_identifier_Format(int32u format_identifier);
+extern stream_t Mpeg_Descriptors_registration_format_identifier_StreamKind(int32u format_identifier);
+
+extern const char* Mpeg_Psi_stream_type_Format(int8u stream_type, int32u format_identifier);
+extern const char* Mpeg_Psi_stream_type_Codec(int8u stream_type, int32u format_identifier);
+extern stream_t Mpeg_Psi_stream_type_StreamKind(int32u stream_type, int32u format_identifier);
+extern const char* Mpeg_Psi_stream_type_Info(int8u stream_type, int32u format_identifier);
+
+extern const char* Mpeg_Psi_table_id(int8u table_id);
+extern const char* Mpeg_Descriptors_stream_Format(int8u descriptor_tag, int32u format_identifier);
+extern const char* Mpeg_Descriptors_stream_Codec(int8u descriptor_tag, int32u format_identifier);
+extern stream_t Mpeg_Descriptors_stream_Kind(int8u descriptor_tag, int32u format_identifier);
+
+//---------------------------------------------------------------------------
+Ztring Decimal_Hexa(int64u Number)
+{
+ Ztring Temp;
+ Temp.From_Number(Number);
+ Temp+=_T(" (0x");
+ Temp+=Ztring::ToZtring(Number, 16);
+ Temp+=_T(")");
+ return Temp;
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_MpegTs::File_MpegTs()
+#if MEDIAINFO_DUPLICATE
+:File__Duplicate()
+#endif //MEDIAINFO_DUPLICATE
+{
+ //Configuration
+ ParserName=_T("MpegTs");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_MpegTs;
+ StreamIDs_Width[0]=4;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=4; //Intermediate
+ #endif //MEDIAINFO_DEMUX
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+ Buffer_TotalBytes_Fill_Max=(int64u)-1; //Disabling this feature for this format, this is done in the parser
+ Trusted_Multiplier=2;
+ #if MEDIAINFO_DEMUX
+ Demux_EventWasSent_Accept_Specific=true;
+ #endif //MEDIAINFO_DEMUX
+
+ //Internal config
+ #if defined(MEDIAINFO_BDAV_YES)
+ BDAV_Size=0; //No BDAV header
+ #endif
+ #if defined(MEDIAINFO_TSP_YES)
+ TSP_Size=0; //No TSP footer
+ #endif
+
+ //Data
+ MpegTs_JumpTo_Begin=MediaInfoLib::Config.MpegTs_MaximumOffset_Get();
+ MpegTs_JumpTo_End=32*1024*1024;
+ Searching_TimeStamp_Start=true;
+ Complete_Stream=NULL;
+ Begin_MaxDuration=Config_ParseSpeed>=0.8?(int64u)-1:MediaInfoLib::Config.MpegTs_MaximumScanDuration_Get()*27/1000;
+ ForceStreamDisplay=MediaInfoLib::Config.MpegTs_ForceStreamDisplay_Get();
+
+ #if MEDIAINFO_SEEK
+ Seek_Value=(int64u)-1;
+ Seek_ID=(int64u)-1;
+ InfiniteLoop_Detect=0;
+ Duration_Detected=false;
+ #endif //MEDIAINFO_SEEK
+}
+
+File_MpegTs::~File_MpegTs ()
+{
+ delete Complete_Stream; Complete_Stream=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Streams_Accept()
+{
+ Fill(Stream_General, 0, General_Format, BDAV_Size?"BDAV":(TSP_Size?"MPEG-TS 188+16":"MPEG-TS"), Unlimited, true, true);
+
+ #if MEDIAINFO_DEMUX
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ Config->Demux_EventWasSent=true;
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Streams_Fill ()
+{
+ Status[User_20]=true;
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Streams_Update()
+{
+ if (Status[User_19])
+ Streams_Update_Programs();
+
+ if (Status[User_18])
+ Streams_Update_EPG();
+
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ if (Status[User_16])
+ Streams_Update_Duration_Update();
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+
+ if (Status[User_17])
+ Streams_Update_Duration_End();
+
+ if (File_Name.empty() && Config_ParseSpeed>=1.0)
+ Fill(Stream_General, 0, General_FileSize, (File_Offset+Buffer_Offset!=File_Size)?Buffer_TotalBytes:File_Size, 10, true);
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Streams_Update_Programs()
+{
+ //Per stream
+ bool PerStream_AlwaysParse=ForceStreamDisplay;
+ if (!PerStream_AlwaysParse)
+ {
+ size_t Programs_Size=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.size();
+ PerStream_AlwaysParse=true;
+ if (Programs_Size<=2)
+ {
+ //Testing if it is a Blu-ray
+ for (complete_stream::transport_stream::programs::iterator Program=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.begin(); Program!=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.end(); Program++)
+ if (Program->first!=0x0000 && Program->second.registration_format_identifier!=Elements::HDMV)
+ {
+ PerStream_AlwaysParse=false;
+ break;
+ }
+ }
+ }
+ for (std::set<int16u>::iterator StreamID=Complete_Stream->PES_PIDs.begin(); StreamID!=Complete_Stream->PES_PIDs.end(); StreamID++)
+ if (PerStream_AlwaysParse || Complete_Stream->Streams[*StreamID]->IsUpdated_IsRegistered || Complete_Stream->Streams[*StreamID]->IsUpdated_Info)
+ {
+ Streams_Update_Programs_PerStream(*StreamID);
+ Complete_Stream->Streams[*StreamID]->IsUpdated_IsRegistered=false;
+ Complete_Stream->Streams[*StreamID]->IsUpdated_Info=false;
+ }
+
+ //Fill General
+ if (Complete_Stream->transport_stream_id_IsValid)
+ {
+ Fill(Stream_General, 0, General_ID, Complete_Stream->transport_stream_id, 10, true);
+ Fill(Stream_General, 0, General_ID_String, Decimal_Hexa(Complete_Stream->transport_stream_id), true);
+ }
+ if (!Complete_Stream->network_name.empty())
+ {
+ Fill(Stream_General, 0, General_NetworkName, Complete_Stream->network_name, true);
+ Complete_Stream->network_name.clear();
+ }
+ if (!Complete_Stream->original_network_name.empty())
+ {
+ Fill(Stream_General, 0, General_OriginalNetworkName, Complete_Stream->original_network_name, true);
+ Complete_Stream->original_network_name.clear();
+ }
+ Ztring Countries;
+ Ztring TimeZones;
+ for (std::map<Ztring, Ztring>::iterator TimeZone=Complete_Stream->TimeZones.begin(); TimeZone!=Complete_Stream->TimeZones.end(); TimeZone++)
+ {
+ Countries+=TimeZone->first+_T(" / ");
+ TimeZones+=TimeZone->second+_T(" / ");
+ }
+ if (!Countries.empty())
+ {
+ Countries.resize(Countries.size()-3);
+ Fill(Stream_General, 0, General_Country, Countries, true);
+ Complete_Stream->TimeZones.clear();
+ }
+ if (!TimeZones.empty())
+ {
+ TimeZones.resize(TimeZones.size()-3);
+ Fill(Stream_General, 0, General_TimeZone, TimeZones, true);
+ Complete_Stream->TimeZones.clear();
+ }
+ if (!Complete_Stream->Duration_Start.empty())
+ {
+ Fill(Stream_General, 0, General_Duration_Start, Complete_Stream->Duration_Start, true);
+ Complete_Stream->Duration_Start.clear();
+ }
+ complete_stream::transport_streams::iterator Transport_Stream=Complete_Stream->transport_stream_id_IsValid?Complete_Stream->Transport_Streams.find(Complete_Stream->transport_stream_id):Complete_Stream->Transport_Streams.end();
+ if (Transport_Stream!=Complete_Stream->Transport_Streams.end())
+ {
+ //TS info
+ for (std::map<std::string, ZenLib::Ztring>::iterator Info=Transport_Stream->second.Infos.begin(); Info!=Transport_Stream->second.Infos.end(); Info++)
+ Fill(Stream_General, 0, Info->first.c_str(), Info->second, true);
+ Transport_Stream->second.Infos.clear();
+
+ //Per source (ATSC)
+ if (Transport_Stream->second.source_id_IsValid)
+ {
+ std::map<Ztring, Ztring> EPGs;
+ complete_stream::sources::iterator Source=Complete_Stream->Sources.find(Transport_Stream->second.source_id);
+ if (Source!=Complete_Stream->Sources.end())
+ {
+ if (!Source->second.texts.empty())
+ {
+ Ztring Texts;
+ for (std::map<int16u, Ztring>::iterator text=Source->second.texts.begin(); text!=Source->second.texts.end(); text++)
+ Texts+=text->second+_T(" - ");
+ if (!Texts.empty())
+ Texts.resize(Texts.size()-3);
+ Fill(Stream_General, 0, General_ServiceProvider, Texts);
+ }
+ }
+ }
+
+ //Per program
+ for (complete_stream::transport_stream::programs::iterator Program=Transport_Stream->second.Programs.begin(); Program!=Transport_Stream->second.Programs.end(); Program++)
+ {
+ if (Program->second.IsParsed)
+ {
+ //Per pid
+ Ztring Languages, Codecs, Formats, StreamKinds, StreamPoss, elementary_PIDs, elementary_PIDs_String, Delay;
+ for (size_t Pos=0; Pos<Program->second.elementary_PIDs.size(); Pos++)
+ {
+ int16u elementary_PID=Program->second.elementary_PIDs[Pos];
+ if (((PerStream_AlwaysParse && Complete_Stream->Streams[elementary_PID]->StreamKind!=Stream_Max)
+ || Complete_Stream->Streams[elementary_PID]->IsRegistered)
+ && Retrieve(Stream_Menu, StreamPos_Last, "KLV_PID").To_int16u()!=elementary_PID)
+ {
+ Ztring Format=Retrieve(Complete_Stream->Streams[elementary_PID]->StreamKind, Complete_Stream->Streams[elementary_PID]->StreamPos, Fill_Parameter(Complete_Stream->Streams[elementary_PID]->StreamKind, Generic_Format));
+ Formats+=Format+_T(" / ");
+ Codecs+=Retrieve(Complete_Stream->Streams[elementary_PID]->StreamKind, Complete_Stream->Streams[elementary_PID]->StreamPos, Fill_Parameter(Complete_Stream->Streams[elementary_PID]->StreamKind, Generic_Codec))+_T(" / ");
+ if (Complete_Stream->Streams[elementary_PID]->StreamKind!=Stream_Max)
+ {
+ StreamKinds+=Ztring::ToZtring(Complete_Stream->Streams[elementary_PID]->StreamKind);
+ StreamPoss+=Ztring::ToZtring(Complete_Stream->Streams[elementary_PID]->StreamPos);
+ }
+ StreamKinds+=_T(" / ");
+ StreamPoss+=_T(" / ");
+ elementary_PIDs+=Ztring::ToZtring(elementary_PID)+_T(" / ");
+ Ztring Language=Retrieve(Complete_Stream->Streams[elementary_PID]->StreamKind, Complete_Stream->Streams[elementary_PID]->StreamPos, "Language/String");
+ Languages+=Language+_T(" / ");
+ Ztring List_String=Decimal_Hexa(elementary_PID);
+ List_String+=_T(" (");
+ List_String+=Format;
+ if (!Language.empty())
+ {
+ List_String+=_T(", ");
+ List_String+=Language;
+ }
+ List_String+=_T(")");
+ elementary_PIDs_String+=List_String+_T(" / ");
+
+ if (Complete_Stream->Streams[elementary_PID]->IsPCR)
+ {
+ Delay=Ztring::ToZtring(((float64)Complete_Stream->Streams[elementary_PID]->TimeStamp_Start)/27000, 6);
+ }
+ }
+ }
+
+ if (Program->second.Update_Needed_Info || Program->second.Update_Needed_IsRegistered || Program->second.Update_Needed_StreamCount || Program->second.Update_Needed_StreamPos)
+ {
+ if (!Transport_Stream->second.Programs.empty()
+ && (Transport_Stream->second.Programs.size()>1
+ || !Transport_Stream->second.Programs.begin()->second.Infos.empty()
+ || !Transport_Stream->second.Programs.begin()->second.DVB_EPG_Blocks.empty()
+ || (Transport_Stream->second.Programs.begin()->second.source_id_IsValid && Complete_Stream->Sources.find(Transport_Stream->second.Programs.begin()->second.source_id)!=Complete_Stream->Sources.end())
+ || Config->File_MpegTs_ForceMenu_Get()))
+ {
+ if (Program->second.StreamPos==(size_t)-1)
+ {
+ size_t StreamPos=(size_t)-1;
+ for (size_t program_number=0; program_number<Complete_Stream->program_number_Order.size(); program_number++)
+ if (Program->first<Complete_Stream->program_number_Order[program_number])
+ {
+ StreamPos=program_number;
+ for (size_t program_number2=program_number; program_number2<Complete_Stream->program_number_Order.size(); program_number2++)
+ Transport_Stream->second.Programs[Complete_Stream->program_number_Order[program_number2]].StreamPos++;
+ Complete_Stream->program_number_Order.insert(Complete_Stream->program_number_Order.begin()+program_number, Program->first);
+ break;
+ }
+ if (StreamPos==(size_t)-1)
+ {
+ Complete_Stream->program_number_Order.push_back(Program->first);
+ }
+
+ Stream_Prepare(Stream_Menu, StreamPos);
+ Program->second.StreamPos=StreamPos_Last;
+ }
+ else
+ StreamPos_Last=Program->second.StreamPos;
+ Fill(Stream_Menu, StreamPos_Last, Menu_ID, Program->second.pid, 10, true);
+ Fill(Stream_Menu, StreamPos_Last, Menu_ID_String, Decimal_Hexa(Program->second.pid), true);
+ Fill(Stream_Menu, StreamPos_Last, Menu_MenuID, Program->first, 10, true);
+ Fill(Stream_Menu, StreamPos_Last, Menu_MenuID_String, Decimal_Hexa(Program->first), true);
+ for (std::map<std::string, ZenLib::Ztring>::iterator Info=Program->second.Infos.begin(); Info!=Program->second.Infos.end(); Info++)
+ Fill(Stream_Menu, StreamPos_Last, Info->first.c_str(), Info->second, true);
+ Program->second.Infos.clear();
+
+ if (!Formats.empty())
+ Formats.resize(Formats.size()-3);
+ Fill(Stream_Menu, StreamPos_Last, Menu_Format, Formats, true);
+ if (!Codecs.empty())
+ Codecs.resize(Codecs.size()-3);
+ Fill(Stream_Menu, StreamPos_Last, Menu_Codec, Codecs, true);
+ if (!StreamKinds.empty())
+ StreamKinds.resize(StreamKinds.size()-3);
+ Fill(Stream_Menu, StreamPos_Last, Menu_List_StreamKind, StreamKinds, true);
+ if (!elementary_PIDs_String.empty())
+ elementary_PIDs_String.resize(elementary_PIDs_String.size()-3);
+ Fill(Stream_Menu, StreamPos_Last, Menu_List_String, elementary_PIDs_String, true);
+ if (!elementary_PIDs.empty())
+ elementary_PIDs.resize(elementary_PIDs.size()-3);
+ Fill(Stream_Menu, StreamPos_Last, Menu_List, elementary_PIDs, true);
+ if (!StreamPoss.empty())
+ StreamPoss.resize(StreamPoss.size()-3);
+ Fill(Stream_Menu, StreamPos_Last, Menu_List_StreamPos, StreamPoss, true);
+ if (!Languages.empty())
+ Languages.resize(Languages.size()-3);
+ Fill(Stream_Menu, StreamPos_Last, Menu_Language, Languages, true);
+ }
+ }
+
+ //Delay
+ if (Program->second.Update_Needed_IsRegistered)
+ {
+ switch (Count_Get(Stream_Menu))
+ {
+ case 0 : Fill(Stream_General, 0, General_Delay, Delay, true); break;
+ default: Fill(Stream_Menu, StreamPos_Last, Menu_Delay, Delay, true); break;
+ }
+ Program->second.Update_Needed_IsRegistered=false;
+ }
+ if (Count_Get(Stream_Menu)==2)
+ Clear(Stream_General, 0, General_Delay); //Not valid, multiple menus
+ }
+ }
+ }
+
+ //Commercial name
+ if (Count_Get(Stream_Video)==1
+ && Count_Get(Stream_Audio)==1
+ && Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video")
+ && Retrieve(Stream_Video, 0, Video_Format_Commercial_IfAny).find(_T("HDV"))==0
+ && Retrieve(Stream_Audio, 0, Audio_Format)==_T("MPEG Audio")
+ && Retrieve(Stream_Audio, 0, Audio_Format_Version)==_T("Version 1")
+ && Retrieve(Stream_Audio, 0, Audio_Format_Profile)==_T("Layer 2")
+ && Retrieve(Stream_Audio, 0, Audio_BitRate)==_T("384000"))
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, Retrieve(Stream_Video, 0, Video_Format_Commercial_IfAny));
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Streams_Update_Programs_PerStream(size_t StreamID)
+{
+ complete_stream::stream* Temp=Complete_Stream->Streams[StreamID];
+
+ //No direct handling of Sub streams;
+ if (Temp->stream_type==0x20 && Temp->SubStream_pid) //Stereoscopic is not alone
+ return;
+
+ //Merging from a previous merge
+ size_t Count;
+ if (Temp->StreamKind!=Stream_Max)
+ {
+ Count=1; //TODO: more than 1
+ Merge(*Temp->Parser, Temp->StreamKind, 0, Temp->StreamPos);
+ StreamKind_Last=Temp->StreamKind;
+ StreamPos_Last=Temp->StreamPos;
+ }
+ else
+ {
+ //By the parser
+ StreamKind_Last=Stream_Max;
+ Count=0;
+ if (Temp->Parser && Temp->Parser->Status[IsAccepted])
+ {
+ if (Temp->SubStream_pid!=0x0000) //With a substream
+ Fill(Complete_Stream->Streams[Temp->SubStream_pid]->Parser);
+ if (Temp->Parser->Count_Get(Stream_Video) && Temp->Parser->Count_Get(Stream_Text))
+ {
+ //Special case: Video and Text are together
+ Stream_Prepare(Stream_Video);
+ Count=Merge(*Temp->Parser, Stream_Video, 0, StreamPos_Last);
+ }
+ else
+ Count=Merge(*Temp->Parser);
+
+ //More from the FMC parser
+ if (Temp->FMC_ES_ID_IsValid)
+ {
+ complete_stream::transport_stream::iod_ess::iterator IOD_ES=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].IOD_ESs.find(Temp->FMC_ES_ID);
+ if (IOD_ES!=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].IOD_ESs.end() && IOD_ES->second.Parser)
+ {
+ Finish(IOD_ES->second.Parser);
+ Count=Merge(*IOD_ES->second.Parser, StreamKind_Last, StreamPos_Last, 0);
+ }
+ }
+
+ //LATM
+ complete_stream::transport_stream::iod_ess::iterator IOD_ES=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].IOD_ESs.find(Complete_Stream->Streams[StreamID]->FMC_ES_ID);
+ #ifdef MEDIAINFO_MPEG4_YES
+ if (IOD_ES!=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].IOD_ESs.end() && IOD_ES->second.SLConfig && Retrieve(Stream_Audio, StreamPos_Last, Audio_MuxingMode).empty())
+ Fill(Stream_Audio, StreamPos_Last, Audio_MuxingMode, "SL");
+ #endif
+ if (Complete_Stream->Streams[StreamID]->stream_type==0x11 && Retrieve(Stream_Audio, StreamPos_Last, Audio_MuxingMode).empty())
+ Fill(Stream_Audio, StreamPos_Last, Audio_MuxingMode, "LATM");
+ }
+
+ //By the descriptors
+ if (StreamKind_Last==Stream_Max && Complete_Stream->transport_stream_id_IsValid)
+ {
+ int32u format_identifier=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Temp->program_numbers[0]].registration_format_identifier;
+ if (Temp->IsRegistered
+ && Mpeg_Descriptors_registration_format_identifier_StreamKind(format_identifier)!=Stream_Max)
+ {
+ StreamKind_Last=Mpeg_Descriptors_registration_format_identifier_StreamKind(format_identifier);
+ Stream_Prepare(StreamKind_Last);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), Mpeg_Descriptors_registration_format_identifier_Format(format_identifier));
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), Mpeg_Descriptors_registration_format_identifier_Format(format_identifier));
+ Count=1;
+ }
+ }
+
+ //By the stream_type
+ if (StreamKind_Last==Stream_Max && Complete_Stream->transport_stream_id_IsValid)
+ {
+ int32u format_identifier=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Temp->program_numbers[0]].registration_format_identifier;
+ if (Mpeg_Psi_stream_type_StreamKind(Temp->stream_type, format_identifier)!=Stream_Max && (Temp->IsRegistered || ForceStreamDisplay || format_identifier==Elements::HDMV))
+ {
+ StreamKind_Last=Mpeg_Psi_stream_type_StreamKind(Temp->stream_type, format_identifier);
+ if (StreamKind_Last==Stream_General && Temp->Parser) //Only information, no streams
+ {
+ Merge (*Temp->Parser, Stream_General, 0, 0);
+ StreamKind_Last=Stream_Max;
+ }
+ Stream_Prepare(StreamKind_Last);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), Mpeg_Psi_stream_type_Format(Temp->stream_type, format_identifier));
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), Mpeg_Psi_stream_type_Codec(Temp->stream_type, format_identifier));
+ Count=1;
+ }
+ }
+
+ //By the StreamKind
+ if (StreamKind_Last==Stream_Max && Temp->StreamKind_FromDescriptor!=Stream_Max && (Temp->IsRegistered || ForceStreamDisplay || Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Temp->program_numbers[0]].registration_format_identifier==Elements::HDMV))
+ {
+ Stream_Prepare(Temp->StreamKind_FromDescriptor);
+ Count=1;
+ }
+ }
+
+ //More info
+ if (StreamKind_Last!=Stream_Max)
+ {
+ for (size_t StreamPos=StreamPos_Last+1-Count; StreamPos<=StreamPos_Last; StreamPos++)
+ {
+ Temp->StreamKind=StreamKind_Last;
+ Temp->StreamPos=StreamPos;
+
+ //Encryption
+ if (Temp->IsScrambled>16)
+ Fill(StreamKind_Last, StreamPos, "Encryption", "Encrypted");
+
+ //TS info
+ for (std::map<std::string, ZenLib::Ztring>::iterator Info=Temp->Infos.begin(); Info!=Temp->Infos.end(); Info++)
+ {
+ if (Retrieve(StreamKind_Last, StreamPos, Info->first.c_str()).empty())
+ Fill(StreamKind_Last, StreamPos, Info->first.c_str(), Info->second, true);
+ }
+ Temp->Infos.clear();
+
+ //Common
+ if (Temp->SubStream_pid!=0x0000) //Wit a substream
+ {
+ Ztring Format_Profile=Retrieve(Stream_Video, StreamPos, Video_Format_Profile);
+ Fill(Stream_Video, StreamPos, Video_ID, Ztring::ToZtring(Temp->SubStream_pid)+_T(" / ")+Ztring::ToZtring(StreamID), true);
+ Fill(Stream_Video, StreamPos, Video_ID_String, Decimal_Hexa(Temp->SubStream_pid)+_T(" / ")+Decimal_Hexa(StreamID), true);
+ if (!Format_Profile.empty() && Complete_Stream->Streams[Temp->SubStream_pid] && Complete_Stream->Streams[Temp->SubStream_pid]->Parser)
+ Fill(Stream_Video, StreamPos, Video_Format_Profile, Complete_Stream->Streams[Temp->SubStream_pid]->Parser->Retrieve(Stream_Video, 0, Video_Format_Profile)+_T(" / ")+Format_Profile, true);
+ }
+ else if (Count>1)
+ {
+ Ztring ID=Retrieve(StreamKind_Last, StreamPos, General_ID);
+ Ztring ID_String=Retrieve(StreamKind_Last, StreamPos, General_ID_String);
+ Fill(StreamKind_Last, StreamPos, General_ID, Ztring::ToZtring(StreamID)+_T('-')+ID, true);
+ Fill(StreamKind_Last, StreamPos, General_ID_String, Decimal_Hexa(StreamID)+_T('-')+ID_String, true);
+ }
+ else
+ {
+ Fill(StreamKind_Last, StreamPos, General_ID, StreamID, 10, true);
+ Fill(StreamKind_Last, StreamPos, General_ID_String, Decimal_Hexa(StreamID), true);
+ }
+ for (size_t Pos=0; Pos<Temp->program_numbers.size(); Pos++)
+ {
+ Fill(StreamKind_Last, StreamPos, General_MenuID, Temp->program_numbers[Pos], 10, Pos==0);
+ Fill(StreamKind_Last, StreamPos, General_MenuID_String, Decimal_Hexa(Temp->program_numbers[Pos]), Pos==0);
+ }
+
+ //Special cases
+ if (StreamKind_Last==Stream_Video && Temp->Parser && Temp->Parser->Count_Get(Stream_Text))
+ {
+ }
+ }
+
+ //Special cases
+ if (Temp->Parser && Temp->Parser->Count_Get(Stream_Video) && Temp->Parser->Count_Get(Stream_Text))
+ {
+ //Video and Text are together
+ size_t Text_Count=Temp->Parser->Count_Get(Stream_Text);
+ for (size_t Text_Pos=0; Text_Pos<Text_Count; Text_Pos++)
+ {
+ Ztring Parser_ID=Temp->Parser->Retrieve(Stream_Text, Text_Pos, Text_ID);
+ if (Parser_ID.find(_T('-'))!=string::npos)
+ Parser_ID.erase(Parser_ID.begin(), Parser_ID.begin()+Parser_ID.find(_T('-'))+1);
+ Ztring ID=Retrieve(Stream_Video, Temp->StreamPos, Video_ID)+_T('-')+Parser_ID;
+ Ztring ID_String=Retrieve(Stream_Video, Temp->StreamPos, Video_ID_String)+_T('-')+Parser_ID;
+ StreamPos_Last=(size_t)-1;
+ for (size_t Pos=0; Pos<Count_Get(Stream_Text); Pos++)
+ if (Retrieve(Stream_Text, Pos, Text_ID)==ID && Retrieve(Stream_Video, Pos, "MuxingMode")==Temp->Parser->Retrieve(Stream_Text, Text_Pos, "MuxingMode"))
+ {
+ StreamPos_Last=Pos;
+ break;
+ }
+ if (StreamPos_Last==(size_t)-1)
+ Stream_Prepare(Stream_Text, StreamPos_Last);
+ Merge(*Temp->Parser, Stream_Text, Text_Pos, StreamPos_Last);
+
+ if (!IsSub)
+ Fill(Stream_Text, StreamPos_Last, "MuxingMode_MoreInfo", _T("Muxed in Video #")+Ztring().From_Number(Temp->StreamPos+1), true);
+ Fill(Stream_Text, StreamPos_Last, Text_ID, ID, true);
+ Fill(Stream_Text, StreamPos_Last, Text_ID_String, ID_String, true);
+ Fill(Stream_Text, StreamPos_Last, Text_MenuID, Retrieve(Stream_Video, Temp->StreamPos, Video_MenuID), true);
+ Fill(Stream_Text, StreamPos_Last, Text_MenuID_String, Retrieve(Stream_Video, Temp->StreamPos, Video_MenuID_String), true);
+ Fill(Stream_Text, StreamPos_Last, Text_Duration, Retrieve(Stream_Video, Temp->StreamPos, Video_Duration), true);
+ Fill(Stream_Text, StreamPos_Last, Text_Delay, Retrieve(Stream_Video, Temp->StreamPos, Video_Delay), true);
+ Fill(Stream_Text, StreamPos_Last, Text_Delay_Source, Retrieve(Stream_Video, Temp->StreamPos, Video_Delay_Source), true);
+
+ if (Retrieve(Stream_Text, StreamPos_Last, Text_Format).find(_T("EIA-"))!=string::npos)
+ {
+ //Retrieving IDs
+ Ztring ID_Complete=Retrieve(Stream_Text, StreamPos_Last, Text_ID);
+ int16u ID_Video=ID_Complete.To_int16u();
+ int8u ID_Text=Ztring(ID_Complete.substr(ID_Complete.rfind(_T('-'))+1, string::npos)).To_int8u();
+ if (ID_Complete.find(_T("-608-"))!=string::npos) //CEA-608 caption
+ ID_Text+=128;
+
+ //ATSC EIT
+ for (size_t ProgramPos=0; ProgramPos<Complete_Stream->Streams[ID_Video]->program_numbers.size(); ProgramPos++)
+ {
+ if (Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[ID_Video]->program_numbers[ProgramPos]].source_id_IsValid)
+ {
+ int16u source_id=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[ID_Video]->program_numbers[ProgramPos]].source_id;
+ complete_stream::sources::iterator Source=Complete_Stream->Sources.find(source_id);
+ if (Source!=Complete_Stream->Sources.end())
+ {
+ bool IsFound=false;
+
+ for (complete_stream::source::atsc_epg_blocks::iterator ATSC_EPG_Block=Source->second.ATSC_EPG_Blocks.begin(); ATSC_EPG_Block!=Source->second.ATSC_EPG_Blocks.end(); ATSC_EPG_Block++)
+ {
+ for (complete_stream::source::atsc_epg_block::events::iterator Event=ATSC_EPG_Block->second.Events.begin(); Event!=ATSC_EPG_Block->second.Events.end(); Event++)
+ {
+ if (!Event->second.Languages[ID_Text].empty())
+ {
+ Fill(Stream_Text, StreamPos_Last, Text_Language, Event->second.Languages[ID_Text]);
+ IsFound=true;
+ break;
+ }
+ if (IsFound)
+ break;
+ }
+ if (IsFound)
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ StreamKind_Last=Temp->StreamKind;
+ StreamPos_Last=Temp->StreamPos;
+ }
+ }
+
+ //Teletext
+ if (StreamKind_Last==Stream_Max)
+ {
+ for (std::map<int16u, complete_stream::stream::teletext>::iterator Teletext=Temp->Teletexts.begin(); Teletext!=Temp->Teletexts.end(); Teletext++)
+ {
+ Stream_Prepare(Stream_Text);
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, Ztring::ToZtring(StreamID)+_T('-')+Ztring::ToZtring(Teletext->first), true);
+ Fill(StreamKind_Last, StreamPos_Last, General_ID_String, Decimal_Hexa(StreamID)+_T('-')+Ztring::ToZtring(Teletext->first), true);
+
+ for (size_t Pos=0; Pos<Temp->program_numbers.size(); Pos++)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, General_MenuID, Temp->program_numbers[Pos], 10, Pos==0);
+ Fill(StreamKind_Last, StreamPos_Last, General_MenuID_String, Decimal_Hexa(Temp->program_numbers[Pos]), Pos==0);
+ }
+
+ //TS info
+ for (std::map<std::string, ZenLib::Ztring>::iterator Info=Teletext->second.Infos.begin(); Info!=Teletext->second.Infos.end(); Info++)
+ {
+ if (Retrieve(StreamKind_Last, StreamPos_Last, Info->first.c_str()).empty())
+ Fill(StreamKind_Last, StreamPos_Last, Info->first.c_str(), Info->second);
+ }
+ Teletext->second.Infos.clear();
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Streams_Update_EPG()
+{
+ //EPG
+ complete_stream::transport_streams::iterator Transport_Stream=Complete_Stream->transport_stream_id_IsValid?Complete_Stream->Transport_Streams.find(Complete_Stream->transport_stream_id):Complete_Stream->Transport_Streams.end();
+ if (Transport_Stream==Complete_Stream->Transport_Streams.end())
+ return;
+
+ //Per source (ATSC)
+ if (Transport_Stream->second.source_id_IsValid)
+ {
+ complete_stream::sources::iterator Source=Complete_Stream->Sources.find(Transport_Stream->second.source_id);
+ if (Source!=Complete_Stream->Sources.end())
+ {
+ //EPG
+ std::map<Ztring, Ztring> EPGs;
+ for (complete_stream::source::atsc_epg_blocks::iterator ATSC_EPG_Block=Source->second.ATSC_EPG_Blocks.begin(); ATSC_EPG_Block!=Source->second.ATSC_EPG_Blocks.end(); ATSC_EPG_Block++)
+ for (complete_stream::source::atsc_epg_block::events::iterator Event=ATSC_EPG_Block->second.Events.begin(); Event!=ATSC_EPG_Block->second.Events.end(); Event++)
+ {
+ Ztring Texts;
+ for (std::map<int16u, Ztring>::iterator text=Event->second.texts.begin(); text!=Event->second.texts.end(); text++)
+ Texts+=text->second+_T(" - ");
+ if (!Texts.empty())
+ Texts.resize(Texts.size()-3);
+ EPGs[Ztring().Date_From_Seconds_1970(Event->second.start_time+315964800-Complete_Stream->GPS_UTC_offset)]=Event->second.title+_T(" / ")+Texts+_T(" / / / ")+Event->second.duration+_T(" / ");
+ }
+ if (!EPGs.empty())
+ {
+ //Trashing old EPG
+ size_t Begin=Retrieve(Stream_General, 0, General_EPG_Positions_Begin).To_int32u();
+ size_t End=Retrieve(Stream_General, 0, General_EPG_Positions_End).To_int32u();
+ if (Begin && End && Begin<End)
+ for (size_t Pos=End-1; Pos>=Begin; Pos--)
+ Clear(Stream_General, 0, Pos);
+
+ //Filling
+ Fill(Stream_General, 0, General_EPG_Positions_Begin, Count_Get(Stream_General, 0), 10, true);
+ for (std::map<Ztring, Ztring>::iterator EPG=EPGs.begin(); EPG!=EPGs.end(); EPG++)
+ Fill(Stream_General, 0, EPG->first.To_Local().c_str(), EPG->second, true);
+ Fill(Stream_General, 0, General_EPG_Positions_End, Count_Get(Stream_General, 0), 10, true);
+ }
+ }
+ }
+
+ //Per program
+ if (!Transport_Stream->second.Programs.empty()
+ && (Transport_Stream->second.Programs.size()>1
+ || !Transport_Stream->second.Programs.begin()->second.Infos.empty()
+ || !Transport_Stream->second.Programs.begin()->second.DVB_EPG_Blocks.empty()
+ || Complete_Stream->Sources.find(Transport_Stream->second.Programs.begin()->second.source_id)!=Complete_Stream->Sources.end()
+ || Config->File_MpegTs_ForceMenu_Get()))
+ for (complete_stream::transport_stream::programs::iterator Program=Transport_Stream->second.Programs.begin(); Program!=Transport_Stream->second.Programs.end(); Program++)
+ {
+ if (Program->second.IsParsed)
+ {
+ bool EPGs_IsUpdated=false;
+ std::map<Ztring, Ztring> EPGs;
+
+ //EPG - DVB
+ if (Program->second.DVB_EPG_Blocks_IsUpdated)
+ {
+ for (complete_stream::transport_stream::program::dvb_epg_blocks::iterator DVB_EPG_Block=Program->second.DVB_EPG_Blocks.begin(); DVB_EPG_Block!=Program->second.DVB_EPG_Blocks.end(); DVB_EPG_Block++)
+ for (complete_stream::transport_stream::program::dvb_epg_block::events::iterator Event=DVB_EPG_Block->second.Events.begin(); Event!=DVB_EPG_Block->second.Events.end(); Event++)
+ if (EPGs.find(Event->second.start_time)==EPGs.end() || DVB_EPG_Block->first==0x4E) //Does not exist or "DVB - event_information_section - actual_transport_stream : return present/following"
+ EPGs[Event->second.start_time]=Event->second.short_event.event_name+_T(" / ")+Event->second.short_event.text+_T(" / ")+Event->second.content+_T(" / / ")+Event->second.duration+_T(" / ")+Event->second.running_status;
+ Program->second.DVB_EPG_Blocks_IsUpdated=false;
+ EPGs_IsUpdated=true;
+ }
+
+ //EPG - ATSC
+ if (Program->second.source_id_IsValid)
+ {
+ complete_stream::sources::iterator Source=Complete_Stream->Sources.find(Program->second.source_id);
+ if (Source!=Complete_Stream->Sources.end())
+ {
+ if (!Source->second.texts.empty())
+ {
+ Ztring Texts;
+ for (std::map<int16u, Ztring>::iterator text=Source->second.texts.begin(); text!=Source->second.texts.end(); text++)
+ Texts+=text->second+_T(" - ");
+ if (!Texts.empty())
+ Texts.resize(Texts.size()-3);
+ if (Program->second.StreamPos==(size_t)-1)
+ {
+ Complete_Stream->program_number_Order.push_back(Program->first);
+ Stream_Prepare(Stream_Menu);
+ Program->second.StreamPos=StreamPos_Last;
+ }
+ Fill(Stream_Menu, Program->second.StreamPos, Menu_ServiceProvider, Texts, true);
+ }
+ if (Source->second.ATSC_EPG_Blocks_IsUpdated)
+ {
+ for (complete_stream::source::atsc_epg_blocks::iterator ATSC_EPG_Block=Source->second.ATSC_EPG_Blocks.begin(); ATSC_EPG_Block!=Source->second.ATSC_EPG_Blocks.end(); ATSC_EPG_Block++)
+ for (complete_stream::source::atsc_epg_block::events::iterator Event=ATSC_EPG_Block->second.Events.begin(); Event!=ATSC_EPG_Block->second.Events.end(); Event++)
+ if (Event->second.start_time!=(int32u)-1) //TODO: find the reason when start_time is not set
+ {
+ Ztring Texts;
+ for (std::map<int16u, Ztring>::iterator text=Event->second.texts.begin(); text!=Event->second.texts.end(); text++)
+ Texts+=text->second+_T(" - ");
+ if (!Texts.empty())
+ Texts.resize(Texts.size()-3);
+ EPGs[Ztring().Date_From_Seconds_1970(Event->second.start_time+315964800-Complete_Stream->GPS_UTC_offset)]=Event->second.title+_T(" / ")+Texts+_T(" / / / ")+Event->second.duration+_T(" / ");
+ }
+ Source->second.ATSC_EPG_Blocks_IsUpdated=false;
+ EPGs_IsUpdated=true;
+ }
+ }
+ }
+
+ //EPG - Filling
+ if (EPGs_IsUpdated)
+ {
+ if (Program->second.StreamPos==(size_t)-1)
+ {
+ Complete_Stream->program_number_Order.push_back(Program->first);
+ Stream_Prepare(Stream_Menu);
+ Program->second.StreamPos=StreamPos_Last;
+ }
+
+ Program->second.EPGs=EPGs;
+ Streams_Update_EPG_PerProgram(Program);
+ }
+ }
+ }
+
+ Complete_Stream->Sources_IsUpdated=false;
+ Complete_Stream->Programs_IsUpdated=false;
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Streams_Update_EPG_PerProgram(complete_stream::transport_stream::programs::iterator Program)
+{
+ size_t Chapters_Pos_Begin=Retrieve(Stream_Menu, Program->second.StreamPos, Menu_Chapters_Pos_Begin).To_int32u();
+ size_t Chapters_Pos_End=Retrieve(Stream_Menu, Program->second.StreamPos, Menu_Chapters_Pos_End).To_int32u();
+ if (Chapters_Pos_Begin && Chapters_Pos_End)
+ {
+ for (size_t Pos=Chapters_Pos_End-1; Pos>=Chapters_Pos_Begin; Pos--)
+ Clear(Stream_Menu, Program->second.StreamPos, Pos);
+ Clear(Stream_Menu, Program->second.StreamPos, Menu_Chapters_Pos_Begin);
+ Clear(Stream_Menu, Program->second.StreamPos, Menu_Chapters_Pos_End);
+ }
+ if (!Program->second.EPGs.empty())
+ {
+ Fill(Stream_Menu, Program->second.StreamPos, Menu_Chapters_Pos_Begin, Count_Get(Stream_Menu, Program->second.StreamPos), 10, true);
+ for (std::map<Ztring, Ztring>::iterator EPG=Program->second.EPGs.begin(); EPG!=Program->second.EPGs.end(); EPG++)
+ Fill(Stream_Menu, Program->second.StreamPos, EPG->first.To_UTF8().c_str(), EPG->second, true);
+ Fill(Stream_Menu, Program->second.StreamPos, Menu_Chapters_Pos_End, Count_Get(Stream_Menu, Program->second.StreamPos), 10, true);
+ }
+}
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_MPEGTS_PCR_YES
+void File_MpegTs::Streams_Update_Duration_Update()
+{
+ for (std::map<int16u, int16u>::iterator PCR_PID=Complete_Stream->PCR_PIDs.begin(); PCR_PID!=Complete_Stream->PCR_PIDs.end(); PCR_PID++)
+ {
+ complete_stream::streams::iterator Stream=Complete_Stream->Streams.begin()+PCR_PID->first;
+ if ((*Stream)->TimeStamp_End_IsUpdated)
+ {
+ if ((*Stream)->TimeStamp_End<0x100000000LL*300 && (*Stream)->TimeStamp_Start>0x100000000LL*300)
+ (*Stream)->TimeStamp_End+=0x200000000LL*300; //33 bits, cyclic
+ float64 Duration=((float64)((int64s)((*Stream)->TimeStamp_End-(*Stream)->TimeStamp_Start)))/27000;
+
+ Fill(Stream_General, 0, General_Duration, Duration, 6, true);
+ if (Duration)
+ Fill(Stream_General, 0, General_OverallBitRate, ((*Stream)->TimeStamp_End_Offset-(*Stream)->TimeStamp_Start_Offset)*8*1000/Duration, 0, true);
+
+ (*Stream)->TimeStamp_End_IsUpdated=false;
+ (*Stream)->IsPCR_Duration=Duration;
+
+ //Filling menu duration
+ if (Count_Get(Stream_Menu))
+ {
+ complete_stream::transport_streams::iterator Transport_Stream=Complete_Stream->transport_stream_id_IsValid?Complete_Stream->Transport_Streams.find(Complete_Stream->transport_stream_id):Complete_Stream->Transport_Streams.end();
+ if (Transport_Stream!=Complete_Stream->Transport_Streams.end())
+ {
+ //Per program
+ for (size_t Pos=0; Pos<(*Stream)->program_numbers.size(); Pos++)
+ {
+ int16u program_number=(*Stream)->program_numbers[Pos];
+ if (Transport_Stream->second.Programs[program_number].IsRegistered) //Only if the menu is already displayed
+ Fill(Stream_Menu, Transport_Stream->second.Programs[program_number].StreamPos, Menu_Duration, Duration, 6, true);
+ }
+ }
+ }
+ }
+ }
+}
+#endif //MEDIAINFO_MPEGTS_PCR_YES
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Streams_Update_Duration_End()
+{
+ //General
+ Fill(Stream_General, 0, General_Duration_End, Complete_Stream->Duration_End, true);
+
+ Complete_Stream->Duration_End_IsUpdated=false;
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Streams_Finish()
+{
+ //Per stream
+ for (size_t StreamID=0; StreamID<0x2000; StreamID++)
+ if (Complete_Stream->Streams[StreamID]->Parser)
+ {
+ if (!Complete_Stream->Streams[StreamID]->Parser->Status[IsFinished])
+ {
+ int64u File_Size_Temp=File_Size;
+ File_Size=File_Offset+Buffer_Offset+Element_Offset;
+ Open_Buffer_Continue(Complete_Stream->Streams[StreamID]->Parser, Buffer, 0);
+ File_Size=File_Size_Temp;
+ Finish(Complete_Stream->Streams[StreamID]->Parser);
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return;
+ #endif //MEDIAINFO_DEMUX
+ }
+ }
+
+ #if MEDIAINFO_DUPLICATE
+ File__Duplicate_Streams_Finish();
+ #endif //MEDIAINFO_DUPLICATE
+
+ #if MEDIAINFO_IBI
+ if (Config_Ibi_Create)
+ {
+ ibi Ibi_Temp;
+ for (ibi::streams::iterator IbiStream_Temp=Ibi.Streams.begin(); IbiStream_Temp!=Ibi.Streams.end(); IbiStream_Temp++)
+ Ibi_Temp.Streams[IbiStream_Temp->first]=new ibi::stream(*IbiStream_Temp->second);
+
+ for (ibi::streams::iterator IbiStream_Temp=Ibi_Temp.Streams.begin(); IbiStream_Temp!=Ibi_Temp.Streams.end(); IbiStream_Temp++)
+ {
+ if (IbiStream_Temp->second && IbiStream_Temp->second->DtsFrequencyNumerator==1000000000 && IbiStream_Temp->second->DtsFrequencyDenominator==1)
+ {
+ bool IsOk=true;
+ for (size_t Pos=0; Pos<IbiStream_Temp->second->Infos.size(); Pos++)
+ if (!IbiStream_Temp->second->Infos[Pos].IsContinuous && Pos+1!=IbiStream_Temp->second->Infos.size())
+ IsOk=false;
+ if (IsOk) //Only is all items are continuous (partial IBI not yet supported)
+ {
+ IbiStream_Temp->second->DtsFrequencyNumerator=90000;
+ for (size_t Pos=0; Pos<IbiStream_Temp->second->Infos.size(); Pos++)
+ {
+ int64u Temp=IbiStream_Temp->second->Infos[Pos].Dts*90/1000000;
+ IbiStream_Temp->second->Infos[Pos].Dts=Temp;
+ }
+ }
+ }
+ }
+
+ //IBI Creation
+ File_Ibi_Creation IbiCreation(Ibi_Temp);
+ Ztring IbiText=IbiCreation.Finish();
+ if (!IbiText.empty())
+ Fill(Stream_General, 0, "IBI", IbiText, true);
+ }
+ #endif //MEDIAINFO_IBI
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_MpegTs::Synchronize()
+{
+ //Synchronizing
+ while ( Buffer_Offset+188*7+BDAV_Size*8+TSP_Size*7+1<=Buffer_Size
+ && !(Buffer[Buffer_Offset+188*0+BDAV_Size*1+TSP_Size*0]==0x47
+ && Buffer[Buffer_Offset+188*1+BDAV_Size*2+TSP_Size*1]==0x47
+ && Buffer[Buffer_Offset+188*2+BDAV_Size*3+TSP_Size*2]==0x47
+ && Buffer[Buffer_Offset+188*3+BDAV_Size*4+TSP_Size*3]==0x47
+ && Buffer[Buffer_Offset+188*4+BDAV_Size*5+TSP_Size*4]==0x47
+ && Buffer[Buffer_Offset+188*5+BDAV_Size*6+TSP_Size*5]==0x47
+ && Buffer[Buffer_Offset+188*6+BDAV_Size*7+TSP_Size*6]==0x47
+ && Buffer[Buffer_Offset+188*7+BDAV_Size*8+TSP_Size*7]==0x47))
+ {
+ Buffer_Offset++;
+ while ( Buffer_Offset+BDAV_Size+1<=Buffer_Size
+ && Buffer[Buffer_Offset+BDAV_Size]!=0x47)
+ Buffer_Offset++;
+ }
+
+ if (Buffer_Offset+188*7+BDAV_Size*8+TSP_Size*7>=Buffer_Size)
+ return false;
+
+ //Synched is OK
+ if (!Status[IsAccepted])
+ {
+ Accept();
+ }
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_MpegTs::Synched_Test()
+{
+ while (Buffer_Offset+TS_Size<=Buffer_Size)
+ {
+ //Synchro testing
+ if (Buffer[Buffer_Offset+BDAV_Size]!=0x47)
+ {
+ Synched=false;
+ #if MEDIAINFO_DUPLICATE
+ if (File__Duplicate_Get())
+ Trusted++; //We don't want to stop parsing if duplication is requested, TS is not a lot stable, normal...
+ #endif //MEDIAINFO_DUPLICATE
+ return false;
+ }
+
+ //Getting pid
+ pid=(Buffer[Buffer_Offset+BDAV_Size+1]&0x1F)<<8
+ | Buffer[Buffer_Offset+BDAV_Size+2];
+
+ complete_stream::stream* Stream=Complete_Stream->Streams[pid];
+ if (Stream->Searching)
+ {
+ //Trace config
+ #if MEDIAINFO_TRACE
+ if (Config_Trace_Level)
+ {
+ if (Stream->Kind==complete_stream::stream::pes)
+ {
+ if (!Trace_Layers[8])
+ Trace_Layers_Update(8); //Stream
+ }
+ else
+ Trace_Layers_Update(IsSub?1:0);
+ }
+ #endif //MEDIAINFO_TRACE
+
+ payload_unit_start_indicator=(Buffer[Buffer_Offset+BDAV_Size+1]&0x40)!=0;
+ if (payload_unit_start_indicator)
+ {
+ //Searching start
+ if (Stream->Searching_Payload_Start) //payload_unit_start_indicator
+ {
+ if (Stream->Kind==complete_stream::stream::psi)
+ {
+ //Searching table_id
+ size_t Version_Pos=BDAV_Size
+ +4 //standart header
+ +((Buffer[Buffer_Offset+BDAV_Size+3]&0x20)?(1+Buffer[Buffer_Offset+BDAV_Size+4]):0); //adaptation_field_control (adaptation) --> adaptation_field_length
+ if (Version_Pos>=BDAV_Size+188)
+ return true; //There is a problem with this block, accelerated parsing disabled
+ Version_Pos+=1+Buffer[Buffer_Offset+Version_Pos]; //pointer_field
+ if (Version_Pos>=BDAV_Size+188)
+ return true; //There is a problem with this block, accelerated parsing disabled
+ int8u table_id=Buffer[Buffer_Offset+Version_Pos]; //table_id
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ Stream->Element_Info1=Mpeg_Psi_table_id(table_id);
+ #endif //MEDIAINFO_TRACE
+ if (table_id==0xCD) //specifc case for ATSC STT
+ {
+ if (Config_Trace_TimeSection_OnlyFirstOccurrence)
+ {
+ if (!TimeSection_FirstOccurrenceParsed)
+ TimeSection_FirstOccurrenceParsed=true;
+ #if MEDIAINFO_TRACE
+ else
+ {
+ Trace_Layers.reset(); //We do not want to display data about other occurences
+ Trace_Layers_Update();
+ }
+ #endif //MEDIAINFO_TRACE
+ }
+ return true; //Version has no meaning
+ }
+ #if MEDIAINFO_IBI
+ if (table_id==0x00)
+ Complete_Stream->Streams[pid]->Ibi_SynchronizationOffset_BeginOfFrame=File_Offset+Buffer_Offset;
+ if (table_id==0x02)
+ Complete_Stream->Streams[pid]->Ibi_SynchronizationOffset_BeginOfFrame=Complete_Stream->Streams[0x0000]->Ibi_SynchronizationOffset_BeginOfFrame;
+ #endif //MEDIAINFO_IBI
+ complete_stream::stream::table_ids::iterator Table_ID=Stream->Table_IDs.begin()+table_id;
+ if (*Table_ID)
+ {
+ //Searching table_id_extension, version_number, section_number
+ if (!(Buffer[Buffer_Offset+Version_Pos+1]&0x80)) //section_syntax_indicator
+ {
+ if (table_id==0x70 && Config_Trace_TimeSection_OnlyFirstOccurrence)
+ {
+ if (!TimeSection_FirstOccurrenceParsed)
+ TimeSection_FirstOccurrenceParsed=true;
+ #if MEDIAINFO_TRACE
+ else
+ {
+ Trace_Layers.reset(); //We do not want to display data about other occurences
+ Trace_Layers_Update();
+ }
+ #endif //MEDIAINFO_TRACE
+ }
+ return true; //No version
+ }
+ Version_Pos+=3; //Header size
+ if (Version_Pos+5>=BDAV_Size+188)
+ return true; //Not able to detect version (too far)
+ int16u table_id_extension=(Buffer[Buffer_Offset+Version_Pos]<<8)|Buffer[Buffer_Offset+Version_Pos+1];
+ int8u version_number=(Buffer[Buffer_Offset+Version_Pos+2]&0x3F)>>1;
+ int8u section_number=Buffer[Buffer_Offset+Version_Pos+3];
+ complete_stream::stream::table_id::table_id_extensions::iterator Table_ID_Extension=(*Table_ID)->Table_ID_Extensions.find(table_id_extension);
+ if (Table_ID_Extension==(*Table_ID)->Table_ID_Extensions.end())
+ {
+ if ((*Table_ID)->Table_ID_Extensions_CanAdd)
+ {
+ (*Table_ID)->Table_ID_Extensions[table_id_extension].version_number=version_number;
+ (*Table_ID)->Table_ID_Extensions[table_id_extension].Section_Numbers.resize(0x100);
+ (*Table_ID)->Table_ID_Extensions[table_id_extension].Section_Numbers[section_number]=true;
+ return true; //table_id_extension is not yet parsed
+ }
+ }
+ else if (Table_ID_Extension->second.version_number!=version_number)
+ {
+ if (Table_ID_Extension->second.version_number!=(int8u)-1 && Config_Trace_TimeSection_OnlyFirstOccurrence)
+ break;
+ Table_ID_Extension->second.version_number=version_number;
+ Table_ID_Extension->second.Section_Numbers.clear();
+ Table_ID_Extension->second.Section_Numbers.resize(0x100);
+ Table_ID_Extension->second.Section_Numbers[section_number]=true;
+ return true; //version is different
+ }
+ else if (!Table_ID_Extension->second.Section_Numbers[section_number])
+ {
+ Table_ID_Extension->second.Section_Numbers[section_number]=true;
+ return true; //section is not yet parsed
+ }
+ else if (table_id==0x02 && Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs_NotParsedCount)
+ {
+ //PMT is looping, so this is nearly sure that all PMT available in the stream are assigned
+ #ifdef MEDIAINFO_MPEGTS_ALLSTREAMS_YES
+ for (size_t pid=0x10; pid<0x1FFF; pid++) //Wanting 0x10-->0x2F (DVB), 0x1ABC (cea_osd), 0x1FF7-->0x1FFF (ATSC)
+ for (size_t Table_ID=0x00; Table_ID<0xFF; Table_ID++)
+ {
+ Complete_Stream->Streams[pid]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[pid]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[pid]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[pid]->Table_IDs[Table_ID]=new complete_stream::stream::table_id; //event_information_section - actual_transport_stream, schedule
+
+ if (Pos==0x001F)
+ Pos=0x1ABB; //Skipping normal data
+ if (Pos==0x01ABC)
+ Pos=0x1FF6; //Skipping normal data
+ }
+ #else //MEDIAINFO_MPEGTS_ALLSTREAMS_YES
+ if (Complete_Stream->Streams[0x0010]->Kind==complete_stream::stream::unknown)
+ {
+ Complete_Stream->Streams[0x0010]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x0010]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x0010]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x0010]->Table_IDs[0x40]=new complete_stream::stream::table_id; //network_information_section - actual_network
+ }
+ if (Complete_Stream->Streams[0x0011]->Kind==complete_stream::stream::unknown)
+ {
+ Complete_Stream->Streams[0x0011]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x0011]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x0011]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x0011]->Table_IDs[0x42]=new complete_stream::stream::table_id; //service_description_section - actual_transport_stream
+ }
+ if (Complete_Stream->Streams[0x0012]->Kind==complete_stream::stream::unknown)
+ {
+ Complete_Stream->Streams[0x0012]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x0012]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x0012]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x0012]->Table_IDs[0x4E]=new complete_stream::stream::table_id; //event_information_section - actual_transport_stream, present/following
+ for (size_t Table_ID=0x50; Table_ID<0x60; Table_ID++)
+ Complete_Stream->Streams[0x0012]->Table_IDs[Table_ID]=new complete_stream::stream::table_id; //event_information_section - actual_transport_stream, schedule
+ }
+ if (Complete_Stream->Streams[0x0014]->Kind==complete_stream::stream::unknown)
+ {
+ Complete_Stream->Streams[0x0014]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x0014]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x0014]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x0014]->Table_IDs[0x70]=new complete_stream::stream::table_id; //time_date_section
+ Complete_Stream->Streams[0x0014]->Table_IDs[0x73]=new complete_stream::stream::table_id; //time_offset_section
+ }
+ if (Complete_Stream->Streams[0x1FFB]->Kind==complete_stream::stream::unknown)
+ {
+ Complete_Stream->Streams[0x1FFB]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x1FFB]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x1FFB]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x1FFB]->Table_IDs[0xC7]=new complete_stream::stream::table_id; //Master Guide Table
+ Complete_Stream->Streams[0x1FFB]->Table_IDs[0xCD]=new complete_stream::stream::table_id; //System Time Table
+ }
+ #endif //MEDIAINFO_MPEGTS_ALLSTREAMS_YES
+ }
+ }
+ }
+ else
+ return true; //No version in this pid
+ }
+ }
+
+ //Searching continue and parser timestamp
+ if (Stream->Searching_Payload_Continue
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ || Stream->Searching_ParserTimeStamp_Start
+ || Stream->Searching_ParserTimeStamp_End
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ )
+ return true;
+
+ //Adaptation layer
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ if (( Stream->Searching_TimeStamp_Start
+ || Stream->Searching_TimeStamp_End)
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ && !Stream->Searching_ParserTimeStamp_End
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ )
+ {
+ if ((Buffer[Buffer_Offset+BDAV_Size+3]&0x20)==0x20) //adaptation_field_control (adaptation)
+ {
+ if (Buffer[Buffer_Offset+BDAV_Size+4]>=5) //adaptation_field_length
+ {
+ int8u pid_Adaptation_Info=Buffer[Buffer_Offset+BDAV_Size+5];
+ if (pid_Adaptation_Info&0x10) //PCR is present
+ {
+ int64u program_clock_reference=( (((int64u)Buffer[Buffer_Offset+BDAV_Size+6])<<25)
+ | (((int64u)Buffer[Buffer_Offset+BDAV_Size+7])<<17)
+ | (((int64u)Buffer[Buffer_Offset+BDAV_Size+8])<< 9)
+ | (((int64u)Buffer[Buffer_Offset+BDAV_Size+9])<< 1)
+ | (((int64u)Buffer[Buffer_Offset+BDAV_Size+10])>>7));
+ program_clock_reference*=300;
+ program_clock_reference+=( (((int64u)Buffer[Buffer_Offset+BDAV_Size+10]&0x01)<<8)
+ | (((int64u)Buffer[Buffer_Offset+BDAV_Size+11]) ));
+ if (Complete_Stream->Streams[pid]->Searching_TimeStamp_End
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ && (!Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_End
+ || Complete_Stream->Streams[pid]->IsPCR) //If PCR, we always want it.
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ )
+ {
+ Header_Parse_Events_Duration(program_clock_reference);
+ Complete_Stream->Streams[pid]->TimeStamp_End=program_clock_reference;
+ Complete_Stream->Streams[pid]->TimeStamp_End_IsUpdated=true;
+ Complete_Stream->Streams[pid]->TimeStamp_End_Offset=File_Offset+Buffer_Offset;
+ {
+ Status[IsUpdated]=true;
+ Status[User_16]=true;
+ }
+ }
+ if (Complete_Stream->Streams[pid]->Searching_TimeStamp_Start)
+ {
+ //This is the first PCR
+ Complete_Stream->Streams[pid]->TimeStamp_Start=program_clock_reference;
+ Complete_Stream->Streams[pid]->TimeStamp_Start_Offset=File_Offset+Buffer_Offset;
+ Complete_Stream->Streams[pid]->TimeStamp_End=program_clock_reference;
+ Complete_Stream->Streams[pid]->TimeStamp_End_IsUpdated=true;
+ Complete_Stream->Streams[pid]->TimeStamp_End_Offset=File_Offset+Buffer_Offset;
+ Complete_Stream->Streams[pid]->Searching_TimeStamp_Start_Set(false);
+ Complete_Stream->Streams[pid]->Searching_TimeStamp_End_Set(true);
+ Complete_Stream->Streams_With_StartTimeStampCount++;
+ {
+ Status[IsUpdated]=true;
+ Status[User_16]=true;
+ }
+ }
+
+ //Test if we can find the TS bitrate
+ if (!Complete_Stream->Streams[pid]->EndTimeStampMoreThanxSeconds && Complete_Stream->Streams[pid]->TimeStamp_Start!=(int64u)-1
+ && (File_Offset+Buffer_Offset-Buffer_TotalBytes_FirstSynched)*2<File_Size)
+ {
+ if (program_clock_reference<Complete_Stream->Streams[pid]->TimeStamp_Start)
+ program_clock_reference+=0x200000000LL*300; //33 bits, cyclic
+ if ((program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_Start)>Begin_MaxDuration)
+ {
+ Complete_Stream->Streams[pid]->EndTimeStampMoreThanxSeconds=true;
+ Complete_Stream->Streams_With_EndTimeStampMoreThanxSecondsCount++;
+ if (Complete_Stream->Streams_NotParsedCount
+ && Complete_Stream->Streams_With_StartTimeStampCount>0
+ && Complete_Stream->Streams_With_StartTimeStampCount==Complete_Stream->Streams_With_EndTimeStampMoreThanxSecondsCount)
+ {
+ //We are already parsing 16 seconds (for all PCRs), we don't hope to have more info
+ MpegTs_JumpTo_Begin=File_Offset+Buffer_Offset-Buffer_TotalBytes_FirstSynched;
+ MpegTs_JumpTo_End=MpegTs_JumpTo_Begin;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ }
+
+ #if MEDIAINFO_DUPLICATE
+ if (Stream->ShouldDuplicate)
+ {
+ Element_Size=TS_Size;
+ File__Duplicate_Write();
+ }
+ #endif //MEDIAINFO_DUPLICATE
+
+ Header_Parse_Events();
+
+ Buffer_Offset+=TS_Size;
+ }
+
+ return false; //Not enough data
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Synched_Init()
+{
+ //Config->File_Filter_Set(462);
+ //Default values
+ Complete_Stream=new complete_stream;
+ Complete_Stream->Streams.resize(0x2000);
+ for (size_t StreamID=0; StreamID<0x2000; StreamID++)
+ Complete_Stream->Streams[StreamID]=new complete_stream::stream;
+ Complete_Stream->Streams[0x0000]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x0000]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x0000]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x0000]->Table_IDs[0x00]=new complete_stream::stream::table_id; //program_association_section
+ Complete_Stream->Streams[0x0001]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x0001]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x0001]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x0001]->Table_IDs[0x01]=new complete_stream::stream::table_id; //conditional_access_section
+
+ //Temp
+ MpegTs_JumpTo_Begin=(File_Offset_FirstSynched==(int64u)-1?0:Buffer_TotalBytes_LastSynched)+MediaInfoLib::Config.MpegTs_MaximumOffset_Get();
+ MpegTs_JumpTo_End=32*1024*1024;
+ Buffer_TotalBytes_LastSynched=Buffer_TotalBytes_FirstSynched;
+ if (MpegTs_JumpTo_Begin==(int64u)-1 || MpegTs_JumpTo_Begin+MpegTs_JumpTo_End>=File_Size)
+ {
+ if (MpegTs_JumpTo_Begin+MpegTs_JumpTo_End>File_Size)
+ {
+ MpegTs_JumpTo_Begin=File_Size;
+ MpegTs_JumpTo_End=0;
+ }
+ else
+ MpegTs_JumpTo_Begin=File_Size-MpegTs_JumpTo_End;
+ }
+
+ //Config
+ Config_Trace_TimeSection_OnlyFirstOccurrence=MediaInfoLib::Config.Trace_TimeSection_OnlyFirstOccurrence_Get();
+ TimeSection_FirstOccurrenceParsed=false;
+
+ //Continue, again, for Duplicate and Filter
+ Option_Manage();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Read_Buffer_Unsynched()
+{
+ if (Complete_Stream==NULL || Complete_Stream->Streams.empty())
+ return;
+
+ for (size_t StreamID=0; StreamID<0x2000; StreamID++)//std::map<int64u, stream>::iterator Stream=Streams.begin(); Stream!=Streams.end(); Stream++)
+ {
+ //End timestamp is out of date
+ #if defined(MEDIAINFO_MPEGTS_PCR_YES) || defined(MEDIAINFO_MPEGTS_PESTIMESTAMP_YES)
+ Complete_Stream->Streams[StreamID]->Searching_TimeStamp_Start_Set(false); //No more searching start
+ Complete_Stream->Streams[StreamID]->TimeStamp_End=(int64u)-1;
+ Complete_Stream->Streams[StreamID]->TimeStamp_End_IsUpdated=false;
+ Complete_Stream->Streams[StreamID]->TimeStamp_End_Offset=(int64u)-1;
+ if (Complete_Stream->Streams[StreamID]->TimeStamp_Start!=(int64u)-1)
+ Complete_Stream->Streams[StreamID]->Searching_TimeStamp_End_Set(true); //Searching only for a start found
+ #endif //defined(MEDIAINFO_MPEGTS_PCR_YES) || defined(MEDIAINFO_MPEGTS_PESTIMESTAMP_YES)
+ if (Complete_Stream->Streams[StreamID]->Parser)
+ {
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ Complete_Stream->Streams[StreamID]->Searching_ParserTimeStamp_Start_Set(false); //No more searching start
+ if (((File_MpegPs*)Complete_Stream->Streams[StreamID]->Parser)->HasTimeStamps)
+ Complete_Stream->Streams[StreamID]->Searching_ParserTimeStamp_End_Set(true); //Searching only for a start found
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ Complete_Stream->Streams[StreamID]->Parser->Open_Buffer_Unsynch();
+ }
+ #if MEDIAINFO_IBI
+ Complete_Stream->Streams[StreamID]->Ibi_SynchronizationOffset_BeginOfFrame=(int64u)-1;
+ for (complete_stream::stream::table_ids::iterator TableID=Complete_Stream->Streams[StreamID]->Table_IDs.begin(); TableID!=Complete_Stream->Streams[StreamID]->Table_IDs.end(); TableID++)
+ if (*TableID)
+ for (complete_stream::stream::table_id::table_id_extensions::iterator TableIdExtension=(*TableID)->Table_ID_Extensions.begin(); TableIdExtension!=(*TableID)->Table_ID_Extensions.end(); TableIdExtension++)
+ TableIdExtension->second.version_number=(int8u)-1;
+ #endif //MEDIAINFO_IBI
+ }
+ Complete_Stream->Duration_End.clear();
+
+ //Clearing durations
+ Clear(Stream_General, 0, General_Duration);
+ Clear(Stream_General, 0, General_Duration_End);
+ for (size_t StreamPos=0; StreamPos<Count_Get(Stream_Menu); StreamPos++)
+ Clear(Stream_Menu, StreamPos, Menu_Duration);
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Read_Buffer_Continue()
+{
+ if (!IsSub)
+ {
+ if (Config_ParseSpeed>=1.0)
+ Config->State_Set(((float)Buffer_TotalBytes)/File_Size);
+ else if (Buffer_TotalBytes>MpegTs_JumpTo_Begin+MpegTs_JumpTo_End)
+ Config->State_Set((float)0.99); //Nearly the end
+ else
+ Config->State_Set(((float)Buffer_TotalBytes)/(MpegTs_JumpTo_Begin+MpegTs_JumpTo_End));
+ }
+
+ #if MEDIAINFO_DEMUX
+ if (Complete_Stream && pid<0x2000 && Complete_Stream->Streams[pid]->Kind==complete_stream::stream::pes && Complete_Stream->Streams[pid]->Parser && ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->Demux_StreamIsBeingParsed_type!=(int8u)-1)
+ {
+ Open_Buffer_Continue(Complete_Stream->Streams[pid]->Parser, Buffer, 0);
+ PES_Parse_Finish();
+ }
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Read_Buffer_AfterParsing()
+{
+ if (Complete_Stream==NULL)
+ return; //No synchronization yet
+
+ if (!Status[IsFilled])
+ {
+ //Test if parsing of headers is OK
+ if ((Complete_Stream->Streams_NotParsedCount==0 && (Complete_Stream->NoPatPmt || (Complete_Stream->transport_stream_id_IsValid && Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs_NotParsedCount==0)))
+ || (Buffer_TotalBytes-Buffer_TotalBytes_FirstSynched>=MpegTs_JumpTo_Begin && Config_ParseSpeed<0.8)
+ || File_Offset+Buffer_Size==File_Size)
+ {
+ //Test if PAT/PMT are missing (ofen in .trp files)
+ if (!Complete_Stream->transport_stream_id_IsValid
+ && !Complete_Stream->NoPatPmt)
+ {
+ //Activating all streams as PES
+ for (size_t StreamID=0; StreamID<0x2000; StreamID++)
+ {
+ delete Complete_Stream->Streams[StreamID]; Complete_Stream->Streams[StreamID]=new complete_stream::stream;
+ }
+ for (size_t StreamID=0x20; StreamID<0x1FFF; StreamID++)
+ {
+ Complete_Stream->Streams_NotParsedCount=(size_t)-1;
+ Complete_Stream->Streams[StreamID]->Kind=complete_stream::stream::pes;
+ Complete_Stream->Streams[StreamID]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[StreamID]->Searching_Payload_Continue_Set(false);
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ Complete_Stream->Streams[StreamID]->Element_Info1="PES";
+ #endif //MEDIAINFO_TRACE
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ Complete_Stream->Streams[StreamID]->Searching_TimeStamp_Start_Set(true);
+ Complete_Stream->Streams[StreamID]->Searching_TimeStamp_End_Set(false);
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ Complete_Stream->Streams[StreamID]->Searching_ParserTimeStamp_Start_Set(true);
+ Complete_Stream->Streams[StreamID]->Searching_ParserTimeStamp_End_Set(false);
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ }
+ Complete_Stream->NoPatPmt=true;
+ Fill(Stream_General, 0, General_Format_Profile, "No PAT/PMT");
+ Buffer_TotalBytes=0;
+ Buffer_TotalBytes_LastSynched=(int64u)-1;
+ Open_Buffer_Unsynch();
+ GoTo(0);
+ return;
+ }
+
+ //Filling
+ for (std::set<int16u>::iterator StreamID=Complete_Stream->PES_PIDs.begin(); StreamID!=Complete_Stream->PES_PIDs.end(); StreamID++)
+ {
+ if (Complete_Stream->Streams[*StreamID]->Parser)
+ {
+ Fill(Complete_Stream->Streams[*StreamID]->Parser);
+
+ Complete_Stream->Streams[*StreamID]->Parser->Status[IsUpdated]=false;
+ Complete_Stream->Streams[*StreamID]->IsUpdated_Info=true;
+ }
+
+ for (size_t Pos=0; Pos<Complete_Stream->Streams[*StreamID]->program_numbers.size(); Pos++)
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[*StreamID]->program_numbers[Pos]].Update_Needed_IsRegistered=true;
+ }
+ Complete_Stream->Streams_NotParsedCount=0;
+ Fill();
+
+ //Deactivating
+ if (Config->File_StopSubStreamAfterFilled_Get())
+ for (std::set<int16u>::iterator StreamID=Complete_Stream->PES_PIDs.begin(); StreamID!=Complete_Stream->PES_PIDs.end(); StreamID++)
+ {
+ Complete_Stream->Streams[*StreamID]->Searching_Payload_Start_Set(false);
+ Complete_Stream->Streams[*StreamID]->Searching_Payload_Continue_Set(false);
+ }
+
+ //Status
+ Status[IsUpdated]=true;
+ Status[User_19]=true;
+
+ //Jumping
+ if (Config_ParseSpeed<1.0 && Config->File_IsSeekable_Get() && File_Offset+Buffer_Size<File_Size-MpegTs_JumpTo_End && MpegTs_JumpTo_End)
+ {
+ #if !defined(MEDIAINFO_MPEGTS_PCR_YES) && !defined(MEDIAINFO_MPEGTS_PESTIMESTAMP_YES)
+ GoToFromEnd(47); //TODO: Should be changed later (when Finalize stuff will be split)
+ #else //!defined(MEDIAINFO_MPEGTS_PCR_YES) && !defined(MEDIAINFO_MPEGTS_PESTIMESTAMP_YES)
+ GoToFromEnd(MpegTs_JumpTo_End);
+ Searching_TimeStamp_Start=false;
+ #endif //!defined(MEDIAINFO_MPEGTS_PCR_YES) && !defined(MEDIAINFO_MPEGTS_PESTIMESTAMP_YES)
+ Open_Buffer_Unsynch();
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_MpegTs::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ //Reset
+ Seek_Value=(int64u)-1;
+ Seek_ID=(int64u)-1;
+ InfiniteLoop_Detect=0;
+ Config->Demux_IsSeeking=false;
+
+ //Init
+ if (!Duration_Detected)
+ {
+ //External IBI
+ std::string IbiFile=Config->Ibi_Get();
+ if (!IbiFile.empty())
+ {
+ Ibi.Streams.clear(); //TODO: support IBI data from different inputs
+
+ File_Ibi MI;
+ Open_Buffer_Init(&MI, IbiFile.size());
+ MI.Ibi=&Ibi;
+ MI.Open_Buffer_Continue((const int8u*)IbiFile.c_str(), IbiFile.size());
+ }
+ //Creating base IBI from a quick analysis of the file
+ else
+ {
+ MediaInfo_Internal MI;
+ MI.Option(_T("File_KeepInfo"), _T("1"));
+ Ztring ParseSpeed_Save=MI.Option(_T("ParseSpeed_Get"), _T(""));
+ Ztring Demux_Save=MI.Option(_T("Demux_Get"), _T(""));
+ MI.Option(_T("ParseSpeed"), _T("0"));
+ MI.Option(_T("Demux"), Ztring());
+ Ztring File_Names=Config->File_Names.Read();
+ MI.Option(_T("File_FileNameFormat"), _T("CSV"));
+ size_t MiOpenResult=MI.Open(File_Names);
+ MI.Option(_T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
+ MI.Option(_T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
+ if (!MiOpenResult)
+ return 0;
+ for (ibi::streams::iterator IbiStream_Temp=((File_MpegTs*)MI.Info)->Ibi.Streams.begin(); IbiStream_Temp!=((File_MpegTs*)MI.Info)->Ibi.Streams.end(); IbiStream_Temp++)
+ {
+ if (Ibi.Streams[IbiStream_Temp->first]==NULL)
+ Ibi.Streams[IbiStream_Temp->first]=new ibi::stream(*IbiStream_Temp->second);
+ Ibi.Streams[IbiStream_Temp->first]->Unsynch();
+ for (size_t Pos=0; Pos<IbiStream_Temp->second->Infos.size(); Pos++)
+ {
+ Ibi.Streams[IbiStream_Temp->first]->Add(IbiStream_Temp->second->Infos[Pos]);
+ if (!IbiStream_Temp->second->Infos[Pos].IsContinuous)
+ Ibi.Streams[IbiStream_Temp->first]->Unsynch();
+ }
+ Ibi.Streams[IbiStream_Temp->first]->Unsynch();
+ }
+ if (Ibi.Streams.empty())
+ return 4; //Problem during IBI file parsing
+ }
+
+ Duration_Detected=true;
+ }
+
+ //Parsing
+ switch (Method)
+ {
+ case 0 :
+ GoTo(Value);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 1 :
+ GoTo(File_Size*Value/10000);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 2 : //Timestamp
+ #if MEDIAINFO_IBI
+ {
+ ibi::streams::iterator IbiStream_Temp;
+ if (ID==(int64u)-1)
+ IbiStream_Temp=Ibi.Streams.begin();
+ else
+ IbiStream_Temp=Ibi.Streams.find(ID);
+ if (IbiStream_Temp==Ibi.Streams.end() || IbiStream_Temp->second->Infos.empty())
+ return 5; //Invalid ID
+
+ if (!(IbiStream_Temp->second->DtsFrequencyNumerator==1000000000 && IbiStream_Temp->second->DtsFrequencyDenominator==1))
+ {
+ float64 ValueF=(float64)Value;
+ ValueF/=1000000000; //Value is in ns
+ ValueF/=IbiStream_Temp->second->DtsFrequencyDenominator;
+ ValueF*=IbiStream_Temp->second->DtsFrequencyNumerator;
+ Value=float64_int64s(ValueF);
+ }
+
+ for (size_t Pos=0; Pos<IbiStream_Temp->second->Infos.size(); Pos++)
+ {
+ if (Value<=IbiStream_Temp->second->Infos[Pos].Dts)
+ {
+ if (Value<IbiStream_Temp->second->Infos[Pos].Dts && Pos)
+ Pos--;
+
+ //Checking continuity of Ibi
+ if (!IbiStream_Temp->second->Infos[Pos].IsContinuous && Pos+1<IbiStream_Temp->second->Infos.size() && InfiniteLoop_Detect<8) //With infinite loop detect
+ {
+ InfiniteLoop_Detect++;
+ Config->Demux_IsSeeking=true;
+ Seek_Value=Value;
+ Seek_Value_Maximal=IbiStream_Temp->second->Infos[Pos+1].StreamOffset;
+ Seek_ID=IbiStream_Temp->first;
+ GoTo((IbiStream_Temp->second->Infos[Pos].StreamOffset+IbiStream_Temp->second->Infos[Pos+1].StreamOffset)/2);
+ Open_Buffer_Unsynch();
+
+ return 1;
+ }
+
+ InfiniteLoop_Detect=0;
+ Config->Demux_IsSeeking=false;
+ if (Complete_Stream && Complete_Stream->Streams[(size_t)IbiStream_Temp->first] && Complete_Stream->Streams[(size_t)IbiStream_Temp->first]->Parser)
+ Complete_Stream->Streams[(size_t)IbiStream_Temp->first]->Parser->Unsynch_Frame_Count=IbiStream_Temp->second->Infos[Pos].FrameNumber;
+ else
+ Unsynch_Frame_Counts[(int16u)IbiStream_Temp->first]=IbiStream_Temp->second->Infos[Pos].FrameNumber;
+
+ GoTo(IbiStream_Temp->second->Infos[Pos].StreamOffset);
+ Open_Buffer_Unsynch();
+
+ return 1;
+ }
+ }
+
+ return 2; //Invalid value
+ }
+ #else //MEDIAINFO_IBI
+ return (size_t)-2; //Not supported / IBI disabled
+ #endif //MEDIAINFO_IBI
+ case 3 : //FrameNumber
+ #if MEDIAINFO_IBI
+ {
+ ibi::streams::iterator IbiStream_Temp;
+ if (ID==(int64u)-1)
+ IbiStream_Temp=Ibi.Streams.begin();
+ else
+ IbiStream_Temp=Ibi.Streams.find(ID);
+ if (IbiStream_Temp==Ibi.Streams.end() || IbiStream_Temp->second->Infos.empty())
+ return 5; //Invalid ID
+
+ for (size_t Pos=0; Pos<IbiStream_Temp->second->Infos.size(); Pos++)
+ {
+ if (Value<=IbiStream_Temp->second->Infos[Pos].FrameNumber)
+ {
+ if (Value<IbiStream_Temp->second->Infos[Pos].FrameNumber && Pos)
+ Pos--;
+
+ Config->Demux_IsSeeking=false;
+ if (Complete_Stream && Complete_Stream->Streams[(size_t)IbiStream_Temp->first] && Complete_Stream->Streams[(size_t)IbiStream_Temp->first]->Parser)
+ Complete_Stream->Streams[(size_t)IbiStream_Temp->first]->Parser->Unsynch_Frame_Count=IbiStream_Temp->second->Infos[Pos].FrameNumber;
+ else
+ Unsynch_Frame_Counts[(int16u)IbiStream_Temp->first]=IbiStream_Temp->second->Infos[Pos].FrameNumber;
+
+ GoTo(IbiStream_Temp->second->Infos[Pos].StreamOffset);
+ Open_Buffer_Unsynch();
+
+ return 1;
+ }
+ }
+
+ return 2; //Invalid value
+ }
+ #else //MEDIAINFO_IBI
+ return (size_t)-2; //Not supported / IBI disabled
+ #endif //MEDIAINFO_IBI
+ default : return (size_t)-1; //Not supported
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_MpegTs::FileHeader_Begin()
+{
+ if (Buffer_Size<8)
+ return false; //Wait for more data
+ if (CC8(Buffer+Buffer_Offset)==0x444C472056312E30LL)
+ {
+ Reject("MPEG-TS");
+ return true;
+ }
+
+ //Configuring
+ #if defined(MEDIAINFO_BDAV_YES) || defined(MEDIAINFO_TSP_YES)
+ TS_Size=188
+ #if defined(MEDIAINFO_BDAV_YES)
+ +BDAV_Size
+ #endif
+ #if defined(MEDIAINFO_TSP_YES)
+ +TSP_Size
+ #endif
+ ;
+ #endif
+
+ //Configuration
+ Option_Manage();
+
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Header_Parse()
+{
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ //Parsing
+ bool adaptation, payload;
+ if (BDAV_Size)
+ Skip_B4( "BDAV"); //BDAV supplement
+ Skip_B1( "sync_byte");
+ BS_Begin();
+ Skip_SB( "transport_error_indicator");
+ Get_SB ( payload_unit_start_indicator, "payload_unit_start_indicator");
+ Skip_SB( "transport_priority");
+ Get_S2 (13, pid, "pid");
+ Get_S1 ( 2, transport_scrambling_control, "transport_scrambling_control");
+ Get_SB ( adaptation, "adaptation_field_control (adaptation)");
+ Get_SB ( payload, "adaptation_field_control (payload)");
+ Skip_S1( 4, "continuity_counter");
+ BS_End();
+
+ //Info
+ /* Trace: used to display program number(s)
+ if (!Complete_Stream->Streams[pid]->program_numbers.empty())
+ {
+ Ztring Program_Numbers;
+ for (size_t Pos=0; Pos<Complete_Stream->Streams[pid]->program_numbers.size(); Pos++)
+ Program_Numbers+=Ztring::ToZtring_From_CC2(Complete_Stream->Streams[pid]->program_numbers[Pos])+_T('/');
+ if (!Program_Numbers.empty())
+ Program_Numbers.resize(Program_Numbers.size()-1);
+ Data_Info(Program_Numbers);
+ }
+ else
+ Data_Info(" ");
+ */
+ Data_Info(Complete_Stream->Streams[pid]->Element_Info1);
+
+ //Adaptation
+ if (adaptation)
+ Header_Parse_AdaptationField();
+ else
+ {
+ }
+
+ //Data
+ if (payload)
+ {
+ //Encryption
+ if (transport_scrambling_control>0)
+ Complete_Stream->Streams[pid]->IsScrambled++;
+ }
+ else if (Element_Offset<TS_Size)
+ Skip_XX(TS_Size-Element_Offset, "Junk");
+
+ //Filling
+ Header_Fill_Code(pid, _T("0x")+Ztring().From_CC2(pid));
+ Header_Fill_Size(TS_Size);
+
+ Header_Parse_Events();
+ }
+ else
+ {
+ #endif //MEDIAINFO_TRACE
+ //Parsing
+ payload_unit_start_indicator=(Buffer[Buffer_Offset+BDAV_Size+1]&0x40)!=0;
+ transport_scrambling_control= Buffer[Buffer_Offset+BDAV_Size+3]&0xC0;
+ bool adaptation= (Buffer[Buffer_Offset+BDAV_Size+3]&0x20)!=0;
+ bool payload= (Buffer[Buffer_Offset+BDAV_Size+3]&0x10)!=0;
+ Element_Offset+=BDAV_Size+4;
+
+ //Adaptation
+ if (adaptation)
+ Header_Parse_AdaptationField();
+ else
+ {
+ }
+
+ //Data
+ if (payload)
+ {
+ //Encryption
+ if (transport_scrambling_control>0)
+ Complete_Stream->Streams[pid]->IsScrambled++;
+ }
+
+ //Filling
+ /*Element[1].Next=File_Offset+Buffer_Offset+TS_Size; //*/Header_Fill_Size(TS_Size);
+ //Element[1].IsComplete=true; //Header_Fill_Size(TS_Size);
+
+ Header_Parse_Events();
+ #if MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_TRACE
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Header_Parse_AdaptationField()
+{
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ int64u Element_Pos_Save=Element_Offset;
+ Element_Begin1("adaptation_field");
+ int8u adaptation_field_length;
+ Get_B1 (adaptation_field_length, "adaptation_field_length");
+ if (adaptation_field_length>188-4-1) //TS size - header - adaptation_field_length
+ {
+ adaptation_field_length=188-4-1;
+ Skip_XX(188-4-1, "stuffing_bytes");
+ }
+ else if (adaptation_field_length>0)
+ {
+ bool PCR_flag, OPCR_flag, splicing_point_flag, transport_private_data_flag, adaptation_field_extension_flag;
+ BS_Begin();
+ Skip_SB( "discontinuity_indicator");
+ Skip_SB( "random_access_indicator");
+ Skip_SB( "elementary_stream_priority_indicator");
+ Get_SB ( PCR_flag, "PCR_flag");
+ Get_SB ( OPCR_flag, "OPCR_flag");
+ Get_SB ( splicing_point_flag, "splicing_point_flag");
+ Get_SB ( transport_private_data_flag, "transport_private_data_flag");
+ Get_SB ( adaptation_field_extension_flag, "adaptation_field_extension_flag");
+ BS_End();
+ if (PCR_flag)
+ {
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ BS_Begin();
+ int64u program_clock_reference_base;
+ int16u program_clock_reference_extension;
+ Get_S8 (33, program_clock_reference_base, "program_clock_reference_base"); Param_Info_From_Milliseconds(program_clock_reference_base/90);
+ Data_Info_From_Milliseconds(program_clock_reference_base/90);
+ Skip_S1( 6, "reserved");
+ Get_S2 ( 9, program_clock_reference_extension, "program_clock_reference_extension");
+ int64u program_clock_reference=program_clock_reference_base*300+program_clock_reference_extension;
+ Param_Info1(program_clock_reference);
+ BS_End();
+ if (Complete_Stream->Streams[pid]->Searching_TimeStamp_End
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ && (!Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_End
+ || Complete_Stream->Streams[pid]->IsPCR) //If PCR, we always want it.
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ )
+ {
+ Header_Parse_Events_Duration(program_clock_reference);
+ Complete_Stream->Streams[pid]->TimeStamp_End=program_clock_reference;
+ Complete_Stream->Streams[pid]->TimeStamp_End_IsUpdated=true;
+ Complete_Stream->Streams[pid]->TimeStamp_End_Offset=File_Offset+Buffer_Offset;
+ {
+ Status[IsUpdated]=true;
+ Status[User_16]=true;
+ }
+ }
+ if (Complete_Stream->Streams[pid]->Searching_TimeStamp_Start)
+ {
+ //This is the first PCR
+ Complete_Stream->Streams[pid]->TimeStamp_Start=program_clock_reference;
+ Complete_Stream->Streams[pid]->TimeStamp_Start_Offset=File_Offset+Buffer_Offset;
+ Complete_Stream->Streams[pid]->TimeStamp_End=program_clock_reference;
+ Complete_Stream->Streams[pid]->TimeStamp_End_IsUpdated=true;
+ Complete_Stream->Streams[pid]->TimeStamp_End_Offset=File_Offset+Buffer_Offset;
+ Complete_Stream->Streams[pid]->Searching_TimeStamp_Start_Set(false);
+ Complete_Stream->Streams[pid]->Searching_TimeStamp_End_Set(true);
+ Complete_Stream->Streams_With_StartTimeStampCount++;
+ {
+ Status[IsUpdated]=true;
+ Status[User_16]=true;
+ }
+ }
+
+ //Test if we can find the TS bitrate
+ if (!Complete_Stream->Streams[pid]->EndTimeStampMoreThanxSeconds && Complete_Stream->Streams[pid]->TimeStamp_Start!=(int64u)-1
+ && (File_Offset+Buffer_Offset-Buffer_TotalBytes_FirstSynched)*2<File_Size)
+ {
+ if (program_clock_reference<Complete_Stream->Streams[pid]->TimeStamp_Start)
+ program_clock_reference+=0x200000000LL*300; //33 bits, cyclic
+ if ((program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_Start)>Begin_MaxDuration)
+ {
+ Complete_Stream->Streams[pid]->EndTimeStampMoreThanxSeconds=true;
+ Complete_Stream->Streams_With_EndTimeStampMoreThanxSecondsCount++;
+ if (Complete_Stream->Streams_NotParsedCount
+ && Complete_Stream->Streams_With_StartTimeStampCount>0
+ && Complete_Stream->Streams_With_StartTimeStampCount==Complete_Stream->Streams_With_EndTimeStampMoreThanxSecondsCount)
+ {
+ //We are already parsing 16 seconds (for all PCRs), we don't hope to have more info
+ MpegTs_JumpTo_Begin=File_Offset+Buffer_Offset-Buffer_TotalBytes_FirstSynched;
+ MpegTs_JumpTo_End=MpegTs_JumpTo_Begin;
+ }
+ }
+ }
+ #else //MEDIAINFO_MPEGTS_PCR_YES
+ Skip_B6( "program_clock_reference");
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ }
+ if (OPCR_flag)
+ {
+ BS_Begin();
+ Skip_S8(33, "original_program_clock_reference_base");
+ Skip_S1( 6, "reserved");
+ Skip_S2( 9, "original_program_clock_reference_extension");
+ BS_End();
+ }
+ if (splicing_point_flag)
+ {
+ Skip_B1( "splice_countdown");
+ }
+ if (transport_private_data_flag)
+ {
+ int8u transport_private_data_length;
+ Get_B1 (transport_private_data_length, "transport_private_data_length");
+ if (Element_Offset+transport_private_data_length<=Element_Pos_Save+1+adaptation_field_length)
+ Skip_XX(transport_private_data_length, "transport_private_data");
+ else
+ Skip_XX(Element_Pos_Save+1+adaptation_field_length-Element_Offset, "problem");
+ }
+ if (adaptation_field_extension_flag)
+ {
+ int8u adaptation_field_extension_length;
+ Get_B1 (adaptation_field_extension_length, "adaptation_field_extension_length");
+ if (Element_Offset+adaptation_field_extension_length<=Element_Pos_Save+1+adaptation_field_length)
+ {
+ Element_Begin1("adaptation_field_extension");
+ int64u End=Element_Offset+adaptation_field_extension_length;
+ bool ltw_flag, piecewise_rate_flag, seamless_splice_flag;
+ BS_Begin();
+ Get_SB ( ltw_flag, "ltw_flag");
+ Get_SB ( piecewise_rate_flag, "piecewise_rate_flag");
+ Get_SB ( seamless_splice_flag, "seamless_splice_flag");
+ Skip_S1( 5, "reserved");
+ if (ltw_flag)
+ {
+ Skip_SB( "ltw_valid_flag");
+ Skip_S2(15, "ltw_offset");
+ }
+ if (piecewise_rate_flag)
+ {
+ Skip_S1( 2, "reserved");
+ Skip_S3(22, "piecewise_rate");
+ }
+ if (seamless_splice_flag)
+ {
+ Skip_S1( 4, "splice_type");
+ int16u DTS_29, DTS_14;
+ int8u DTS_32;
+ Element_Begin1("DTS");
+ Get_S1 ( 3, DTS_32, "DTS_32");
+ Mark_1();
+ Get_S2 (15, DTS_29, "DTS_29");
+ Mark_1();
+ Get_S2 (15, DTS_14, "DTS_14");
+ Mark_1();
+
+ //Filling
+ int64u DTS;
+ DTS=(((int64u)DTS_32)<<30)
+ | (((int64u)DTS_29)<<15)
+ | (((int64u)DTS_14));
+ Element_Info_From_Milliseconds(DTS/90);
+ Element_End0();
+ }
+ BS_End();
+ if (Element_Offset<End)
+ Skip_XX(End-Element_Offset, "reserved");
+ Element_End0();
+ }
+ else
+ Skip_XX(Element_Pos_Save+1+adaptation_field_length-Element_Offset, "problem");
+ }
+ }
+
+ if (Element_Offset<Element_Pos_Save+1+adaptation_field_length)
+ Skip_XX(Element_Pos_Save+1+adaptation_field_length-Element_Offset, "stuffing_bytes");
+ Element_End0();
+ }
+ else
+ {
+ #endif //MEDIAINFO_TRACE
+ int8u adaptation_field_length=Buffer[Buffer_Offset+BDAV_Size+4];
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ if (adaptation_field_length>188-4-1) //TS size - header - adaptation_field_length
+ adaptation_field_length=188-4-1;
+ else if (adaptation_field_length)
+ {
+ bool PCR_flag=(Buffer[Buffer_Offset+BDAV_Size+5]&0x10)!=0;
+ if (PCR_flag)
+ {
+ int64u program_clock_reference=( (((int64u)Buffer[Buffer_Offset+BDAV_Size+6])<<25)
+ | (((int64u)Buffer[Buffer_Offset+BDAV_Size+7])<<17)
+ | (((int64u)Buffer[Buffer_Offset+BDAV_Size+8])<< 9)
+ | (((int64u)Buffer[Buffer_Offset+BDAV_Size+9])<< 1)
+ | (((int64u)Buffer[Buffer_Offset+BDAV_Size+10])>>7));
+ program_clock_reference*=300;
+ program_clock_reference+=( (((int64u)Buffer[Buffer_Offset+BDAV_Size+10]&0x01)<<8)
+ | (((int64u)Buffer[Buffer_Offset+BDAV_Size+11]) ));
+ if (Complete_Stream->Streams[pid]->Searching_TimeStamp_End
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ && (!Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_End
+ || Complete_Stream->Streams[pid]->IsPCR) //If PCR, we always want it.
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ )
+ {
+ Header_Parse_Events_Duration(program_clock_reference);
+ Complete_Stream->Streams[pid]->TimeStamp_End=program_clock_reference;
+ Complete_Stream->Streams[pid]->TimeStamp_End_IsUpdated=true;
+ Complete_Stream->Streams[pid]->TimeStamp_End_Offset=File_Offset+Buffer_Offset;
+ {
+ Status[IsUpdated]=true;
+ Status[User_16]=true;
+ }
+ }
+ if (Complete_Stream->Streams[pid]->Searching_TimeStamp_Start)
+ {
+ //This is the first PCR
+ Complete_Stream->Streams[pid]->TimeStamp_Start=program_clock_reference;
+ Complete_Stream->Streams[pid]->TimeStamp_Start_Offset=File_Offset+Buffer_Offset;
+ Complete_Stream->Streams[pid]->TimeStamp_End=program_clock_reference;
+ Complete_Stream->Streams[pid]->TimeStamp_End_IsUpdated=true;
+ Complete_Stream->Streams[pid]->TimeStamp_End_Offset=File_Offset+Buffer_Offset;
+ Complete_Stream->Streams[pid]->Searching_TimeStamp_Start_Set(false);
+ Complete_Stream->Streams[pid]->Searching_TimeStamp_End_Set(true);
+ Complete_Stream->Streams_With_StartTimeStampCount++;
+ {
+ Status[IsUpdated]=true;
+ Status[User_16]=true;
+ }
+ }
+
+ //Test if we can find the TS bitrate
+ if (!Complete_Stream->Streams[pid]->EndTimeStampMoreThanxSeconds && Complete_Stream->Streams[pid]->TimeStamp_Start!=(int64u)-1
+ && (File_Offset+Buffer_Offset-Buffer_TotalBytes_FirstSynched)*2<File_Size)
+ {
+ if (program_clock_reference<Complete_Stream->Streams[pid]->TimeStamp_Start)
+ program_clock_reference+=0x200000000LL*300; //33 bits, cyclic
+ if ((program_clock_reference-Complete_Stream->Streams[pid]->TimeStamp_Start)>Begin_MaxDuration)
+ {
+ Complete_Stream->Streams[pid]->EndTimeStampMoreThanxSeconds=true;
+ Complete_Stream->Streams_With_EndTimeStampMoreThanxSecondsCount++;
+ if (Complete_Stream->Streams_NotParsedCount
+ && Complete_Stream->Streams_With_StartTimeStampCount>0
+ && Complete_Stream->Streams_With_StartTimeStampCount==Complete_Stream->Streams_With_EndTimeStampMoreThanxSecondsCount)
+ {
+ //We are already parsing 16 seconds (for all PCRs), we don't hope to have more info
+ MpegTs_JumpTo_Begin=File_Offset+Buffer_Offset-Buffer_TotalBytes_FirstSynched;
+ MpegTs_JumpTo_End=MpegTs_JumpTo_Begin;
+ }
+ }
+ }
+ }
+ }
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ Element_Offset+=1+adaptation_field_length;
+ #if MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_TRACE
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+void File_MpegTs::Header_Parse_Events()
+{
+}
+#endif //MEDIAINFO_EVENTS
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_EVENTS
+void File_MpegTs::Header_Parse_Events_Duration(int64u program_clock_reference)
+{
+}
+#endif //MEDIAINFO_EVENTS
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Data_Parse()
+{
+ //Counting
+ Frame_Count++;
+
+ //TSP specific
+ if (TSP_Size && Element_Size>TSP_Size)
+ Element_Size-=TSP_Size;
+
+ #if MEDIAINFO_DUPLICATE
+ if (Complete_Stream->Streams[pid]->ShouldDuplicate)
+ File__Duplicate_Write();
+ #endif //MEDIAINFO_DUPLICATE
+
+ //Parsing
+ if (!Complete_Stream->Streams[pid]->Searching_Payload_Start
+ && !Complete_Stream->Streams[pid]->Searching_Payload_Continue
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ && !Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_Start
+ && !Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_End
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ )
+ Skip_XX(Element_Size, "data");
+ else
+ switch (Complete_Stream->Streams[pid]->Kind)
+ {
+ case complete_stream::stream::pes : PES(); break;
+ case complete_stream::stream::psi : PSI(); break;
+ default: ;
+ }
+
+ //TSP specific
+ if (TSP_Size && Element_Size>TSP_Size)
+ {
+ Element_Size+=TSP_Size;
+ Skip_B4( "TSP"); //TSP supplement
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpegTs::PES()
+{
+ //Info
+ DETAILS_INFO(if (Complete_Stream->transport_stream_id_IsValid) Element_Info1(Mpeg_Psi_stream_type_Info(Complete_Stream->Streams[pid]->stream_type, Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[0]].registration_format_identifier));)
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ Element_Code=pid;
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ //Exists
+ if (!Complete_Stream->Streams[pid]->IsRegistered)
+ {
+ Complete_Stream->Streams[pid]->IsRegistered=true;
+ for (size_t Pos=0; Pos<Complete_Stream->Streams[pid]->program_numbers.size(); Pos++)
+ if (!Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[Pos]].IsRegistered)
+ {
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[Pos]].Update_Needed_IsRegistered=true;
+
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[Pos]].IsRegistered=true;
+ }
+
+ Complete_Stream->Streams[pid]->IsUpdated_IsRegistered=true;
+ Complete_Stream->PES_PIDs.insert(pid);
+
+ Status[IsUpdated]=true;
+ Status[User_19]=true;
+ }
+
+ //Case of encrypted streams
+ if (transport_scrambling_control)
+ {
+ if (!Complete_Stream->Streams[pid]->Searching_Payload_Continue)
+ Complete_Stream->Streams[pid]->Searching_Payload_Continue_Set(true); //In order to count the packets
+
+ if (Complete_Stream->Streams[pid]->IsScrambled>16)
+ {
+ //Don't need anymore
+ Complete_Stream->Streams[pid]->Searching_Payload_Start_Set(false);
+ Complete_Stream->Streams[pid]->Searching_Payload_Continue_Set(false);
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_Start_Set(false);
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ }
+ Skip_XX(Element_Size-Element_Offset, "Scrambled data");
+
+ return;
+ }
+ else if (Complete_Stream->Streams[pid]->IsScrambled)
+ Complete_Stream->Streams[pid]->IsScrambled--;
+
+ //Parser creation
+ if (Complete_Stream->Streams[pid]->Parser==NULL)
+ {
+ //Waiting for first payload_unit_start_indicator
+ if (!payload_unit_start_indicator)
+ {
+ Element_DoNotShow(); //We don't want to show this item because there is no interessant info
+ return; //This is not the start of the PES
+ }
+
+ //If unknown stream_type
+ if (Complete_Stream->transport_stream_id_IsValid
+ && Mpeg_Psi_stream_type_StreamKind(Complete_Stream->Streams[pid]->stream_type, Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[0]].registration_format_identifier)==Stream_Max
+ && Complete_Stream->Streams[pid]->stream_type!=0x06 //Exception for private data
+ && Complete_Stream->Streams[pid]->stream_type<=0x7F //Exception for private data
+ && Mpeg_Descriptors_registration_format_identifier_StreamKind(Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[0]].registration_format_identifier)==Stream_Max //From Descriptor
+ && Config->File_MpegTs_stream_type_Trust_Get())
+ {
+ Complete_Stream->Streams[pid]->Searching_Payload_Start_Set(false);
+ Complete_Stream->Streams[pid]->Searching_Payload_Continue_Set(false);
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_Start_Set(false);
+ Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_End_Set(false);
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ Complete_Stream->Streams[pid]->IsParsed=true;
+ Complete_Stream->Streams_NotParsedCount--;
+ return;
+ }
+
+ //Allocating an handle if needed
+ #if defined(MEDIAINFO_MPEGPS_YES)
+ Complete_Stream->Streams[pid]->Parser=new File_MpegPs;
+ #if MEDIAINFO_SEEK
+ if (Unsynch_Frame_Counts.find(pid)!=Unsynch_Frame_Counts.end())
+ {
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->Unsynch_Frame_Count_Temp=Unsynch_Frame_Counts[pid];
+ Unsynch_Frame_Counts.erase(pid);
+ }
+ #endif //MEDIAINFO_SEEK
+ #if MEDIAINFO_DEMUX
+ if (Config_Demux)
+ {
+ if (Complete_Stream->Streams[pid]->stream_type==0x20 && Complete_Stream->Streams[pid]->SubStream_pid)
+ {
+ //Creating the demux buffer
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->SubStream_Demux=new File_MpegPs::demux;
+ //If main parser is already created, associating the new demux buffer
+ if (Complete_Stream->Streams[Complete_Stream->Streams[pid]->SubStream_pid]->Parser)
+ ((File_MpegPs*)Complete_Stream->Streams[Complete_Stream->Streams[pid]->SubStream_pid]->Parser)->SubStream_Demux=((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->SubStream_Demux;
+ }
+ if (Complete_Stream->Streams[pid]->stream_type!=0x20 && Complete_Stream->Streams[pid]->SubStream_pid && (File_MpegPs*)Complete_Stream->Streams[Complete_Stream->Streams[pid]->SubStream_pid]->Parser)
+ {
+ //If SubStream parser is already created, associating the SubStream demux buffer
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->SubStream_Demux=((File_MpegPs*)Complete_Stream->Streams[Complete_Stream->Streams[pid]->SubStream_pid]->Parser)->SubStream_Demux;
+ }
+ }
+ #endif //MEDIAINFO_DEMUX
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ if (Searching_TimeStamp_Start)
+ Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_Start_Set(true);
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->Searching_TimeStamp_Start=Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_Start;
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->FromTS=true;
+ if (Config->File_MpegTs_stream_type_Trust_Get())
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->FromTS_stream_type=Complete_Stream->Streams[pid]->stream_type;
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->FromTS_descriptor_tag=Complete_Stream->Streams[pid]->descriptor_tag;
+ if (!Complete_Stream->Streams[pid]->program_numbers.empty())
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->FromTS_program_format_identifier=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[0]].registration_format_identifier;
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->FromTS_format_identifier=Complete_Stream->Streams[pid]->registration_format_identifier;
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->MPEG_Version=2;
+ complete_stream::transport_stream::iod_ess::iterator IOD_ES=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].IOD_ESs.find(Complete_Stream->Streams[pid]->FMC_ES_ID);
+ if (IOD_ES!=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].IOD_ESs.end())
+ {
+ #ifdef MEDIAINFO_MPEG4_YES
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->ParserFromTs=IOD_ES->second.Parser; IOD_ES->second.Parser=NULL;
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->SLConfig=IOD_ES->second.SLConfig; IOD_ES->second.SLConfig=NULL;
+ #endif
+ }
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ Complete_Stream->Streams[pid]->Parser->ShouldContinueParsing=true;
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ Complete_Stream->Streams[pid]->Searching_Payload_Continue_Set(true);
+ #else
+ //Filling
+ Streams[pid]->Parser=new File_Unknown();
+ #endif
+ #if MEDIAINFO_IBI
+ if (Ibi.Streams[pid]==NULL)
+ Ibi.Streams[pid]=new ibi::stream;
+ Complete_Stream->Streams[pid]->Parser->IbiStream=Ibi.Streams[pid];
+ #endif //MEDIAINFO_IBI
+ Open_Buffer_Init(Complete_Stream->Streams[pid]->Parser);
+ }
+
+ //If unsynched, waiting for first payload_unit_start_indicator
+ if (!Complete_Stream->Streams[pid]->Parser->Synched && !payload_unit_start_indicator)
+ {
+ Element_DoNotShow(); //We don't want to show this item because there is no interessant info
+ return; //This is not the start of the PES
+ }
+
+ //Parsing
+ if (Complete_Stream->Streams[pid]->IsPCR)
+ ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->FrameInfo.PCR=Complete_Stream->Streams[pid]->TimeStamp_End==(int64u)-1?(int64u)-1:Complete_Stream->Streams[pid]->TimeStamp_End*1000/27; //27 MHz
+ #if MEDIAINFO_IBI
+ if (Complete_Stream->transport_stream_id!=(int16u)-1 && !Complete_Stream->Streams[pid]->program_numbers.empty())
+ {
+ int16u Program_PID=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[0]].pid;
+ Complete_Stream->Streams[pid]->Parser->Ibi_SynchronizationOffset_Current=Complete_Stream->Streams[Program_PID]->Ibi_SynchronizationOffset_BeginOfFrame;
+ if (Complete_Stream->Streams[pid]->Parser->Ibi_SynchronizationOffset_Current==(int64u)-1)
+ return; //Not yet synchronized
+ }
+ else
+ Complete_Stream->Streams[pid]->Parser->Ibi_SynchronizationOffset_Current=File_Offset+Buffer_Offset-Header_Size;
+ #endif //MEDIAINFO_IBI
+
+ Open_Buffer_Continue(Complete_Stream->Streams[pid]->Parser);
+ PES_Parse_Finish();
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::PES_Parse_Finish()
+{
+ if (Complete_Stream->Streams[pid]->Parser->Status[IsUpdated])
+ {
+ Complete_Stream->Streams[pid]->Parser->Status[IsUpdated]=false;
+ Complete_Stream->Streams[pid]->IsUpdated_Info=true;
+ for (size_t Pos=0; Pos<Complete_Stream->Streams[pid]->program_numbers.size(); Pos++)
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[Pos]].Update_Needed_IsRegistered=true;
+
+ Status[IsUpdated]=true;
+ Status[User_19]=true;
+ }
+
+ #if defined(MEDIAINFO_MPEGPS_YES) && defined(MEDIAINFO_MPEGTS_PESTIMESTAMP_YES)
+ if (MpegTs_JumpTo_Begin+MpegTs_JumpTo_End>File_Size
+ && !Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_End
+ && ((File_MpegPs*)Complete_Stream->Streams[pid]->Parser)->HasTimeStamps)
+ {
+ Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_Start_Set(false);
+ Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_End_Set(true);
+ }
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+
+ //Need anymore?
+ if (Complete_Stream->Streams[pid]->Parser->Status[IsFilled]
+ || Complete_Stream->Streams[pid]->Parser->Status[IsFinished])
+ {
+ if ((Complete_Stream->Streams[pid]->Searching_Payload_Start || Complete_Stream->Streams[pid]->Searching_Payload_Continue) && Config_ParseSpeed<1 && MpegTs_JumpTo_End)
+ {
+ Complete_Stream->Streams[pid]->Searching_Payload_Start_Set(false);
+ Complete_Stream->Streams[pid]->Searching_Payload_Continue_Set(false);
+ if (Complete_Stream->Streams_NotParsedCount)
+ {
+ Complete_Stream->Streams[pid]->IsParsed=true;
+ Complete_Stream->Streams_NotParsedCount--;
+ }
+ }
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ if (Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_Start)
+ Complete_Stream->Streams[pid]->Searching_ParserTimeStamp_Start_Set(false);
+ #else //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ if (Config_ParseSpeed<1.0)
+ Finish(Complete_Stream->Streams[pid]->Parser);
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ }
+
+ #if MEDIAINFO_SEEK
+ if (Seek_ID!=(int64u)-1)
+ {
+ if (Ibi.Streams[Seek_ID]->IsModified)
+ {
+ Read_Buffer_Seek(2, Seek_Value, Seek_ID);
+ }
+ else if (Ibi.Streams[Seek_ID]->Infos_Pos>=2 && Ibi.Streams[Seek_ID]->IsSynchronized && Ibi.Streams[Seek_ID]->Infos[Ibi.Streams[Seek_ID]->Infos_Pos-1].StreamOffset>=Seek_Value_Maximal)
+ {
+ InfiniteLoop_Detect++;
+ if (InfiniteLoop_Detect>16)
+ {
+ //Infinite loop
+ Seek_ID=(int64u)-1;
+ Seek_Value=(int64u)-1;
+ InfiniteLoop_Detect=0;
+ Config->Demux_IsSeeking=false;
+ }
+ else
+ {
+ //No intermediate seek point found, going to previous seek point
+ GoTo(Ibi.Streams[Seek_ID]->Infos[Ibi.Streams[Seek_ID]->Infos_Pos-2].StreamOffset);
+ Open_Buffer_Unsynch();
+ }
+ }
+ }
+ #endif //MEDIAINFO_SEEK
+}
+
+//---------------------------------------------------------------------------
+void File_MpegTs::PSI()
+{
+ //Initializing
+ if (payload_unit_start_indicator)
+ {
+ delete ((File_Mpeg_Psi*)Complete_Stream->Streams[pid]->Parser); Complete_Stream->Streams[pid]->Parser=new File_Mpeg_Psi;
+ Open_Buffer_Init(Complete_Stream->Streams[pid]->Parser);
+ ((File_Mpeg_Psi*)Complete_Stream->Streams[pid]->Parser)->Complete_Stream=Complete_Stream;
+ ((File_Mpeg_Psi*)Complete_Stream->Streams[pid]->Parser)->pid=pid;
+ }
+ else if (Complete_Stream->Streams[pid]->Parser==NULL)
+ {
+ Skip_XX(Element_Size, "data");
+ return; //This is not the start of the PSI
+ }
+
+ //Parsing
+ #if MEDIAINFO_IBI
+ Complete_Stream->Streams[pid]->Parser->Ibi_SynchronizationOffset_Current=File_Offset+Buffer_Offset-Header_Size;
+ #endif //MEDIAINFO_IBI
+ Open_Buffer_Continue(Complete_Stream->Streams[pid]->Parser);
+
+ //Filling
+ if (Complete_Stream->Streams[pid]->Parser->Status[IsFilled])
+ {
+ //Accept
+ if (!Status[IsAccepted] && pid==0x0000 && Complete_Stream->Streams[pid]->Parser->Status[IsAccepted])
+ Accept("MPEG-TS");
+
+ //Disabling this pid
+ delete Complete_Stream->Streams[pid]->Parser; Complete_Stream->Streams[pid]->Parser=NULL;
+ Complete_Stream->Streams[pid]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[pid]->Searching_Payload_Continue_Set(false);
+
+ //EPG
+ if (Complete_Stream->Sources_IsUpdated || Complete_Stream->Programs_IsUpdated)
+ {
+ Status[IsUpdated]=true;
+ Status[User_18]=true;
+ }
+
+ //Duration
+ if (Complete_Stream->Duration_End_IsUpdated)
+ {
+ Status[IsUpdated]=true;
+ Status[User_17]=true;
+ }
+
+ //Program change
+ if (pid==0x0000)
+ {
+ Buffer_TotalBytes_LastSynched=Buffer_TotalBytes+Buffer_Offset-Header_Size;
+ Status[IsFilled]=false;
+
+ Status[IsUpdated]=true;
+ Status[User_19]=true;
+ }
+ if (!Complete_Stream->Streams[pid]->Table_IDs.empty() && Complete_Stream->Streams[pid]->Table_IDs[0x02])
+ {
+ Buffer_TotalBytes_LastSynched=Buffer_TotalBytes+Buffer_Offset-Header_Size;
+ Status[IsFilled]=false;
+
+ //Status[IsUpdated]=true;
+ //Status[User_19]=true;
+ }
+
+ //Item removal
+ if (pid==0x0000 || (!Complete_Stream->Streams[pid]->Table_IDs.empty() && Complete_Stream->Streams[pid]->Table_IDs[0x02]))
+ {
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
+ if (!Complete_Stream->StreamPos_ToRemove[StreamKind].empty())
+ {
+ sort(Complete_Stream->StreamPos_ToRemove[StreamKind].begin(), Complete_Stream->StreamPos_ToRemove[StreamKind].end());
+ size_t Pos=Complete_Stream->StreamPos_ToRemove[StreamKind].size();
+ do
+ {
+ Pos--;
+
+ //Erasing text substreams
+ Ztring ID_ToFind=Retrieve((stream_t)StreamKind, Complete_Stream->StreamPos_ToRemove[StreamKind][Pos], General_ID)+_T('-');
+ for (size_t TextPos=0; TextPos<Count_Get(Stream_Text); TextPos++)
+ if (Retrieve(Stream_Text, TextPos, General_ID).find(ID_ToFind)==0)
+ Stream_Erase(Stream_Text, TextPos);
+
+ //Erasing the stream
+ Stream_Erase((stream_t)StreamKind, Complete_Stream->StreamPos_ToRemove[StreamKind][Pos]);
+
+ //Moving other StreamPos
+ for (size_t Pos2=Pos+1; Pos2<Complete_Stream->StreamPos_ToRemove[StreamKind].size(); Pos2++)
+ Complete_Stream->StreamPos_ToRemove[StreamKind][Pos]--;
+
+ //Informing that the menu must be recalculated - TODO: only the related programs
+ if (StreamKind!=Stream_Menu)
+ {
+ for (complete_stream::transport_stream::programs::iterator Program=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.begin(); Program!=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.end(); Program++)
+ Program->second.Update_Needed_StreamPos=true;
+ }
+ else if (Complete_Stream->StreamPos_ToRemove[StreamKind][Pos]<Complete_Stream->program_number_Order.size())
+ {
+ Complete_Stream->program_number_Order.erase(Complete_Stream->program_number_Order.begin()+Complete_Stream->StreamPos_ToRemove[StreamKind][Pos]);
+ }
+ }
+ while (Pos);
+ Complete_Stream->StreamPos_ToRemove[StreamKind].clear();
+ }
+
+ Status[IsUpdated]=true;
+ Status[User_19]=true;
+ }
+ }
+ else
+ //Waiting for more data
+ Complete_Stream->Streams[pid]->Searching_Payload_Continue_Set(true);
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPEGTS_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs.h
new file mode 100644
index 000000000..3e5255d90
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs.h
@@ -0,0 +1,171 @@
+// File_Mpegts - Info for MPEG Transport Stream files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MPEG Transport Stream files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_MpegTsH
+#define MediaInfo_MpegTsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Duplicate.h"
+#include "MediaInfo/Multiple/File_Mpeg_Psi.h"
+#include "MediaInfo/Duplicate/File__Duplicate_MpegTs.h"
+#include "MediaInfo/Duplicate/File__Duplicate__Writer.h"
+#include <map>
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_MpegTs
+//***************************************************************************
+
+class File_MpegTs :
+#if MEDIAINFO_DUPLICATE
+ public File__Duplicate
+#else //MEDIAINFO_DUPLICATE
+ public File__Analyze
+#endif //MEDIAINFO_DUPLICATE
+{
+public :
+ //In
+ #ifdef MEDIAINFO_BDAV_YES
+ size_t BDAV_Size;
+ #endif
+ #ifdef MEDIAINFO_TSP_YES
+ size_t TSP_Size;
+ #endif
+
+ //Constructor/Destructor
+ File_MpegTs();
+ ~File_MpegTs();
+
+private :
+ //Streams management
+ void Streams_Accept();
+ void Streams_Fill();
+ void Streams_Update();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+ void Synched_Init();
+
+ //Options
+ void Option_Manage ();
+
+ //Buffer - Global
+ void Read_Buffer_Continue();
+ void Read_Buffer_AfterParsing ();
+ void Read_Buffer_Unsynched();
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Header_Parse_AdaptationField();
+ void Data_Parse();
+
+ int16u pid;
+ int8u transport_scrambling_control;
+ bool payload_unit_start_indicator;
+
+ //Global infos
+ complete_stream* Complete_Stream;
+
+ //Elements
+ void PSI();
+ void PES();
+ void PES_Parse_Finish();
+
+ //Helpers
+ bool Header_Parser_QuickSearch();
+
+ //Temp
+ #if defined(MEDIAINFO_BDAV_YES) || defined(MEDIAINFO_TSP_YES)
+ size_t TS_Size;
+ #endif
+ int64u MpegTs_JumpTo_Begin;
+ int64u MpegTs_JumpTo_End;
+ int64u Begin_MaxDuration; //in 27 MHz
+ int64u Buffer_TotalBytes_LastSynched;
+ bool ForceStreamDisplay;
+ bool Searching_TimeStamp_Start;
+
+ #if MEDIAINFO_EVENTS
+ void Header_Parse_Events();
+ void Header_Parse_Events_Duration(int64u program_clock_reference);
+ #else //MEDIAINFO_EVENTS
+ inline void Header_Parse_Events() {}
+ inline void Header_Parse_Events_Duration(int64u) {}
+ #endif //MEDIAINFO_EVENTS
+
+ //Helpers
+ void Streams_Update_Programs();
+ void Streams_Update_Programs_PerStream(size_t StreamID);
+ void Streams_Update_EPG();
+ void Streams_Update_EPG_PerProgram(complete_stream::transport_stream::programs::iterator Program);
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ void Streams_Update_Duration_Update();
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ void Streams_Update_Duration_End();
+
+ #if MEDIAINFO_DUPLICATE
+ //File__Duplicate
+ void File__Duplicate_Streams_Finish ();
+ bool File__Duplicate_Set (const Ztring &Value); //Fill a new File__Duplicate value
+ void File__Duplicate_Write ();
+
+ //Output buffer
+ size_t Output_Buffer_Get (const String &Value);
+ size_t Output_Buffer_Get (size_t Pos);
+ std::vector<int16u> Output_Buffer_Get_Pos;
+ #endif //MEDIAINFO_DUPLICATE
+
+ //Config
+ bool Config_Trace_TimeSection_OnlyFirstOccurrence;
+ bool TimeSection_FirstOccurrenceParsed;
+
+ #if MEDIAINFO_SEEK
+ std::map<int16u, int64u> Unsynch_Frame_Counts;
+ int64u Seek_Value;
+ int64u Seek_Value_Maximal;
+ int64u Seek_ID;
+ size_t InfiniteLoop_Detect;
+ bool Duration_Detected;
+ #endif //MEDIAINFO_SEEK
+ #if MEDIAINFO_SEEK && MEDIAINFO_IBI
+ ibi Ibi;
+ #endif //MEDIAINFO_SEEK && MEDIAINFO_IBI
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs_Duplicate.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs_Duplicate.cpp
new file mode 100644
index 000000000..e977ddaec
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_MpegTs_Duplicate.cpp
@@ -0,0 +1,359 @@
+// File__Duplicate - Duplication of some formats
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Duplication helper for some specific formats
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEGTS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_MpegTs.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "ZenLib/ZtringList.h"
+#include "ZenLib/File.h"
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+#if MEDIAINFO_DUPLICATE
+void File_MpegTs::File__Duplicate_Streams_Finish ()
+{
+ if (!File_Name.empty()) //Only if this is not a buffer, with buffer we can have more data
+ Complete_Stream->Duplicates_Speed_FromPID.clear();
+}
+#endif //MEDIAINFO_DUPLICATE
+
+//***************************************************************************
+// Options
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_MpegTs::Option_Manage()
+{
+ if (Complete_Stream && !Complete_Stream->Streams.empty())
+ {
+ #if MEDIAINFO_FILTER
+ //File_Filter configuration
+ if (Config->File_Filter_HasChanged())
+ {
+ bool Searching_Payload_Start=!Config->File_Filter_Get();
+ for (int32u Pos=0x01; Pos<0x10; Pos++)
+ Complete_Stream->Streams[Pos]->Searching_Payload_Start_Set(Searching_Payload_Start); //base PID depends of File_Filter configuration
+ Complete_Stream->Streams[0x0000]->Searching_Payload_Start_Set(true); //program_map
+ }
+ #endif //MEDIAINFO_FILTER
+
+ #if MEDIAINFO_DUPLICATE
+ //File__Duplicate configuration
+ if (File__Duplicate_HasChanged())
+ {
+ for (size_t Pos=0x0000; Pos<0x2000; Pos++)
+ Complete_Stream->Streams[Pos]->ShouldDuplicate=false;
+ Complete_Stream->Streams[0x0000]->ShouldDuplicate=true;
+
+ //For each program
+ for (complete_stream::transport_stream::programs::iterator Program=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.begin(); Program!=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.end(); Program++)
+ {
+ //Do we want this program?
+ bool Wanted=false;
+ for (std::map<const String, File__Duplicate_MpegTs*>::iterator Duplicate=Complete_Stream->Duplicates.begin(); Duplicate!=Complete_Stream->Duplicates.end(); Duplicate++)
+ {
+ if (Duplicate->second->Wanted_program_numbers.find(Program->first)!=Duplicate->second->Wanted_program_numbers.end())
+ Wanted=true;
+ if (Duplicate->second->Wanted_program_map_PIDs.find(Program->second.pid)!=Duplicate->second->Wanted_program_map_PIDs.end())
+ Wanted=true;
+ }
+
+ //Enabling it if wanted
+ if (Wanted)
+ {
+ Complete_Stream->Streams[Program->second.pid]->ShouldDuplicate=true;
+ for (size_t Pos=0; Pos<Program->second.elementary_PIDs.size(); Pos++)
+ Complete_Stream->Streams[Program->second.elementary_PIDs[Pos]]->ShouldDuplicate=true;
+ }
+ }
+ }
+ #endif //MEDIAINFO_DUPLICATE
+ }
+}
+
+//***************************************************************************
+// Set
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DUPLICATE
+bool File_MpegTs::File__Duplicate_Set (const Ztring &Value)
+{
+ //Form: "Code;Target" <--Generic
+ //Form: "program_number" or <--clear it
+ //Form: "program_number;file" or <--the exported filename is filename.program_number
+ //Form: "program_number;file://filename" or <--the exported filename is specified by user
+ //Form: "program_number;memory" or <--This will be a MediaInfo memory block
+ //Form: "program_number;memory://pointer:size" <--Memory block is specified by user
+ //WARNING: program_number & pointer must be in ***DECIMAL*** format.
+ //Example: "451;memory://123456789:1316"
+ ZtringList List(Value);
+
+ //Backward compatibility
+ bool Orders_ToRemove_Global=false;
+
+ //Searching Target
+ bool IsForUs=true; //True by default for backward compatibility
+ std::vector<ZtringList::iterator> Targets_ToAdd;
+ std::vector<ZtringList::iterator> Targets_ToRemove;
+ std::vector<ZtringList::iterator> Orders_ToAdd;
+ std::vector<ZtringList::iterator> Orders_ToRemove;
+ for (ZtringList::iterator Current=List.begin(); Current<List.end(); Current++)
+ {
+ //Detecting if we want to remove
+ bool ToRemove=false;
+ if (Current->find(_T('-'))==0)
+ {
+ ToRemove=true;
+ Current->erase(Current->begin());
+ }
+
+ //Managing targets
+ if (Current->find(_T("file:"))==0
+ || Current->find(_T("memory:"))==0)
+ (ToRemove?Targets_ToRemove:Targets_ToAdd).push_back(Current);
+ //Parser name
+ else if (Current->find(_T("parser="))==0)
+ {
+ if (*Current==_T("parser=MpegTs"))
+ IsForUs=true;
+ else
+ IsForUs=false; //Backward compatibility with missing parser name
+ }
+ //Backward compatibility with "0"
+ else if (*Current==_T("0"))
+ Orders_ToRemove_Global=true;
+ //Managing orders
+ else
+ (ToRemove?Orders_ToRemove:Orders_ToAdd).push_back(Current);
+ }
+
+ //For us?
+ if (!IsForUs)
+ return false;
+
+ //Backward compatibility
+ if (Orders_ToRemove_Global) //with "0"
+ {
+ for (std::vector<ZtringList::iterator>::iterator Order=Orders_ToAdd.begin(); Order<Orders_ToAdd.end(); Order++)
+ Orders_ToRemove.push_back(*Order);
+ Orders_ToAdd.clear();
+ }
+
+ //For each target to add
+ for (std::vector<ZtringList::iterator>::iterator Target=Targets_ToAdd.begin(); Target<Targets_ToAdd.end(); Target++)
+ {
+ //Adding the target if it does not exist yet
+ if (Complete_Stream->Duplicates.find(**Target)==Complete_Stream->Duplicates.end())
+ {
+ Complete_Stream->Duplicates[**Target]=new File__Duplicate_MpegTs(**Target);
+ size_t Pos=Config->File__Duplicate_Memory_Indexes_Get(**Target);
+ if (Pos!=Error)
+ {
+ if (Pos>=Complete_Stream->Duplicates_Speed.size())
+ Complete_Stream->Duplicates_Speed.resize(Pos+1);
+ Complete_Stream->Duplicates_Speed[Pos]=Complete_Stream->Duplicates[**Target];
+ }
+ }
+
+ //For each order to add
+ for (std::vector<ZtringList::iterator>::iterator Order=Orders_ToAdd.begin(); Order<Orders_ToAdd.end(); Order++)
+ Complete_Stream->Duplicates[**Target]->Configure(**Order, false);
+
+ //For each order to remove
+ for (std::vector<ZtringList::iterator>::iterator Order=Orders_ToRemove.begin(); Order<Orders_ToRemove.end(); Order++)
+ Complete_Stream->Duplicates[**Target]->Configure(**Order, true);
+ }
+
+ //For each target to remove
+ for (std::vector<ZtringList::iterator>::iterator Target=Targets_ToRemove.begin(); Target<Targets_ToRemove.end(); Target++)
+ {
+ std::map<const String, File__Duplicate_MpegTs*>::iterator Pointer=Complete_Stream->Duplicates.find(**Target);
+ if (Pointer!=Complete_Stream->Duplicates.end())
+ {
+ //Duplicates_Speed
+ for (std::vector<File__Duplicate_MpegTs*>::iterator Duplicate=Complete_Stream->Duplicates_Speed.begin(); Duplicate<Complete_Stream->Duplicates_Speed.end(); Duplicate++)
+ if (*Duplicate==Pointer->second)
+ *Duplicate=NULL;
+
+ //Duplicates_Speed_FromPID
+ for (std::vector<std::vector<File__Duplicate_MpegTs*> >::iterator Duplicate_FromPID=Complete_Stream->Duplicates_Speed_FromPID.begin(); Duplicate_FromPID<Complete_Stream->Duplicates_Speed_FromPID.end(); Duplicate_FromPID++)
+ for (std::vector<File__Duplicate_MpegTs*>::iterator Duplicate=Duplicate_FromPID->begin(); Duplicate<Duplicate_FromPID->end(); Duplicate++)
+ if (*Duplicate==Pointer->second)
+ *Duplicate=NULL;
+
+ //Duplicate
+ Complete_Stream->Duplicates.erase(**Target);
+ }
+ }
+
+ //Informing the status has changed
+ Complete_Stream->File__Duplicate_HasChanged_=true;
+ if (Complete_Stream->Duplicates_Speed_FromPID.empty())
+ Complete_Stream->Duplicates_Speed_FromPID.resize(0x2000);
+
+ Complete_Stream->Duplicates_Speed_FromPID[0x00]=Complete_Stream->Duplicates_Speed;
+
+ return true;
+}
+#endif //MEDIAINFO_DUPLICATE
+
+//***************************************************************************
+// Write
+//***************************************************************************
+
+#if MEDIAINFO_DUPLICATE
+void File_MpegTs::File__Duplicate_Write ()
+{
+ const int8u* ToAdd=Buffer+Buffer_Offset-(size_t)Header_Size;
+ size_t ToAdd_Size=(size_t)(Element_Size+Header_Size);
+
+ std::vector<File__Duplicate_MpegTs*> &Dup_FromPID=Complete_Stream->Duplicates_Speed_FromPID[pid];
+ size_t Duplicates_Speed_FromPID_Size=Complete_Stream->Duplicates_Speed_FromPID[pid].size();
+ bool ToUpdate=false;
+ for (size_t Pos=0; Pos<Duplicates_Speed_FromPID_Size; Pos++)
+ if (Dup_FromPID[Pos] && Dup_FromPID[Pos]->Write(pid, ToAdd, ToAdd_Size))
+ ToUpdate=true;
+ if (ToUpdate)
+ {
+ Complete_Stream->Duplicates_Speed_FromPID.clear();
+ Complete_Stream->Duplicates_Speed_FromPID.resize(0x2000);
+ Complete_Stream->Duplicates_Speed_FromPID[0x0000]=Complete_Stream->Duplicates_Speed;
+ size_t Duplicates_Speed_Size=Complete_Stream->Duplicates_Speed.size();
+ for (size_t Pos=0; Pos<Duplicates_Speed_Size; Pos++)
+ {
+ File__Duplicate_MpegTs* Dup=Complete_Stream->Duplicates_Speed[Pos];
+ size_t program_map_PIDs_Size=Complete_Stream->Duplicates_Speed[Pos]->program_map_PIDs.size();
+ for (size_t program_map_PIDs_Pos=0; program_map_PIDs_Pos<program_map_PIDs_Size; program_map_PIDs_Pos++)
+ if (Dup->program_map_PIDs[program_map_PIDs_Pos])
+ {
+ bool AlreadyPresent=false;
+ for (size_t Duplicates_Speed_FromPID_Pos=0; Duplicates_Speed_FromPID_Pos<Complete_Stream->Duplicates_Speed_FromPID[program_map_PIDs_Pos].size(); Duplicates_Speed_FromPID_Pos++)
+ if (Complete_Stream->Duplicates_Speed_FromPID[program_map_PIDs_Pos][Duplicates_Speed_FromPID_Pos]==Dup)
+ AlreadyPresent=true;
+ if (!AlreadyPresent)
+ Complete_Stream->Duplicates_Speed_FromPID[program_map_PIDs_Pos].push_back(Dup);
+ }
+ size_t elementary_PIDs_Size=Complete_Stream->Duplicates_Speed[Pos]->program_map_PIDs.size();
+ for (size_t elementary_PIDs_Pos=0; elementary_PIDs_Pos<elementary_PIDs_Size; elementary_PIDs_Pos++)
+ if (Dup->elementary_PIDs[elementary_PIDs_Pos])
+ {
+ bool AlreadyPresent=false;
+ for (size_t Duplicates_Speed_FromPID_Pos=0; Duplicates_Speed_FromPID_Pos<Complete_Stream->Duplicates_Speed_FromPID[elementary_PIDs_Pos].size(); Duplicates_Speed_FromPID_Pos++)
+ if (Complete_Stream->Duplicates_Speed_FromPID[elementary_PIDs_Pos][Duplicates_Speed_FromPID_Pos]==Dup)
+ AlreadyPresent=true;
+ if (!AlreadyPresent)
+ Complete_Stream->Duplicates_Speed_FromPID[elementary_PIDs_Pos].push_back(Dup);
+ }
+ }
+ }
+}
+#endif //MEDIAINFO_DUPLICATE
+
+//***************************************************************************
+// Output_Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DUPLICATE
+size_t File_MpegTs::Output_Buffer_Get (const String &Code)
+{
+ if (Complete_Stream==NULL)
+ return 0;
+ std::map<const String, File__Duplicate_MpegTs*>::iterator Stream=Complete_Stream->Duplicates.find(Code);
+ if (Stream==Complete_Stream->Duplicates.end())
+ return 0;
+
+ return Stream->second->Output_Buffer_Get();
+
+ //Was used for test (AVC output), but is a lot too slow, must find something else
+ /*
+ if (size_t Size=Stream->second->Output_Buffer_Get())
+ return Size;
+
+ //Parsing Parsers
+ for (size_t Stream_Pos=0; Stream_Pos<Streams.size(); Stream_Pos++)
+ if (Streams[Stream_Pos].Parser)
+ if (size_t Size=Streams[Stream_Pos].Parser->Output_Buffer_Get(Code))
+ return Size;
+
+ return 0;
+ */
+}
+#endif //MEDIAINFO_DUPLICATE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DUPLICATE
+size_t File_MpegTs::Output_Buffer_Get (size_t Pos)
+{
+ if (Complete_Stream!=NULL && Pos<Complete_Stream->Duplicates_Speed.size() && Complete_Stream->Duplicates_Speed[Pos]!=NULL)
+ if (size_t Size=Complete_Stream->Duplicates_Speed[Pos]->Output_Buffer_Get())
+ return Size;
+
+ //Parsing Parsers
+ /*
+ for (size_t Stream_Pos=0; Stream_Pos<Complete_Stream->Streams.size(); Stream_Pos++)
+ if (Complete_Stream->Streams[Stream_Pos].Parser)
+ if (size_t Size=Complete_Stream->Streams[Stream_Pos].Parser->Output_Buffer_Get(Pos))
+ {
+ //Optimization
+ //if (Output_Buffer_Get_Pos.size()<=Pos)
+ // Output_Buffer_Get_Pos.resize(Pos+1, (int16u)-1);
+ //Output_Buffer_Get_Pos[Pos]=Stream_Pos;
+
+ return Size;
+ }
+ */
+
+ return 0;
+}
+#endif //MEDIAINFO_DUPLICATE
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPEGTS_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Descriptors.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Descriptors.cpp
new file mode 100644
index 000000000..b10fc2841
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Descriptors.cpp
@@ -0,0 +1,3125 @@
+// File_Mpeg_Descriptors - Info for MPEG files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEGPS_YES) || defined(MEDIAINFO_MPEGTS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Mpeg_Descriptors.h"
+#ifdef MEDIAINFO_MPEG4_YES
+ #include "MediaInfo/Multiple/File_Mpeg4_Descriptors.h"
+#endif
+#include <cmath>
+using namespace std;
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+namespace Elements
+{
+ const int32u AC_3=0x41432D33; //Exactly AC-3
+ const int32u BSSD=0x42535344; //PCM
+ const int32u CUEI=0x43554549; //SCTE
+ const int32u DTS1=0x44545331; //DTS
+ const int32u DTS2=0x44545332; //DTS
+ const int32u DTS3=0x44545333; //DTS
+ const int32u GA94=0x47413934; //ATSC - Terrestrial
+ const int32u HDMV=0x48444D56; //BluRay
+ const int32u KLVA=0x4B4C5641; //KLV Packets
+ const int32u S14A=0x53313441; //ATSC - Satellite
+ const int32u SCTE=0x53435445; //SCTE
+ const int32u TSHV=0x54534856; //TSHV
+ const int32u VC_1=0x56432D31; //Exactly VC-1
+ const int32u drac=0x64726163; //Dirac
+
+ const int32u MANZ=0x4D414E5A; //Manzanita Systems
+
+ const int32u DVB =0x00000001; //Forced value, does not exist is stream
+}
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Extern
+extern const char* Avc_profile_idc(int8u profile_idc);
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Descriptors_audio_type(int8u ID)
+{
+ switch (ID)
+ {
+ case 0x00 : return "Undefined";
+ case 0x01 : return "Clean effects";
+ case 0x02 : return "Hearing impaired";
+ case 0x03 : return "Visual impaired commentary";
+ default : return "Reserved";
+ }
+}
+
+const char* Mpeg_Descriptors_alignment_type(int8u alignment_type)
+{
+ switch (alignment_type)
+ {
+ case 0x01 : return "Slice or video access unit (Video), or sync word (Audio)";
+ case 0x02 : return "Video access unit";
+ case 0x03 : return "GOP, or SEQ";
+ case 0x04 : return "SEQ";
+ default : return "Reserved";
+ }
+}
+
+const char* Mpeg_Descriptors_teletext_type(int8u teletext_type)
+{
+ switch (teletext_type)
+ {
+ case 0x01 : return "Teletext";
+ case 0x02 : return "Teletext Subtitle";
+ case 0x03 : return "Teletext"; //additional information page
+ case 0x04 : return "Teletext"; //programme schedule page
+ case 0x05 : return "Teletext Subtitle"; //for hearing impaired people
+ default : return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_1(int8u content_nibble_level_1)
+{
+ switch (content_nibble_level_1)
+ {
+ case 0x00 : return "undefined";
+ case 0x01 : return "movie/drama";
+ case 0x02 : return "news/current affairs";
+ case 0x03 : return "show/game show";
+ case 0x04 : return "sports";
+ case 0x05 : return "children's/youth programmes";
+ case 0x06 : return "music/ballet/dance";
+ case 0x07 : return "arts/culture (without music)";
+ case 0x08 : return "social/political issues/economics";
+ case 0x09 : return "education/science/factual topics";
+ case 0x0A : return "leisure hobbies";
+ case 0x0B : return "Special characteristics:";
+ default :
+ if (content_nibble_level_1==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2_01(int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_2)
+ {
+ case 0x00 : return "movie/drama";
+ case 0x01 : return "detective/thriller";
+ case 0x02 : return "adventure/western/war";
+ case 0x03 : return "science fiction/fantasy/horror";
+ case 0x04 : return "comedy";
+ case 0x05 : return "soap/melodrama/folkloric";
+ case 0x06 : return "romance";
+ case 0x07 : return "serious/classical/religious/historical movie/drama";
+ case 0x08 : return "adult movie/drama";
+ default :
+ if (content_nibble_level_2==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2_02(int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_2)
+ {
+ case 0x00 : return "news/current affairs";
+ case 0x01 : return "news/weather report";
+ case 0x02 : return "news magazine";
+ case 0x03 : return "documentary";
+ case 0x04 : return "discussion/interview/debate";
+ default :
+ if (content_nibble_level_2==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2_03(int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_2)
+ {
+ case 0x00 : return "show/game show";
+ case 0x01 : return "game show/quiz/contest";
+ case 0x02 : return "variety show";
+ case 0x03 : return "talk show";
+ default :
+ if (content_nibble_level_2==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2_04(int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_2)
+ {
+ case 0x00 : return "sports";
+ case 0x01 : return "special events";
+ case 0x02 : return "sports magazines";
+ case 0x03 : return "football/soccer";
+ case 0x04 : return "tennis/squash";
+ case 0x05 : return "team sports (excluding football)";
+ case 0x06 : return "athletics";
+ case 0x07 : return "motor sport";
+ case 0x08 : return "water sport";
+ case 0x09 : return "winter sports";
+ case 0x0A : return "equestrian";
+ case 0x0B : return "martial sports";
+ default :
+ if (content_nibble_level_2==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2_05(int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_2)
+ {
+ case 0x00 : return "children's/youth programmes";
+ case 0x01 : return "pre-school children's programmes";
+ case 0x02 : return "entertainment programmes for 6 to 14";
+ case 0x03 : return "entertainment programmes for 10 to 16";
+ case 0x04 : return "informational/educational/school programmes";
+ case 0x05 : return "cartoons/puppets";
+ default :
+ if (content_nibble_level_2==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2_06(int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_2)
+ {
+ case 0x00 : return "music/ballet/dance";
+ case 0x01 : return "rock/pop";
+ case 0x02 : return "serious music/classical music";
+ case 0x03 : return "folk/traditional music";
+ case 0x04 : return "jazz";
+ case 0x05 : return "musical/opera";
+ case 0x06 : return "ballet";
+ default :
+ if (content_nibble_level_2==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2_07(int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_2)
+ {
+ case 0x00 : return "arts/culture (without music)";
+ case 0x01 : return "performing arts";
+ case 0x02 : return "fine arts";
+ case 0x03 : return "religion";
+ case 0x04 : return "popular culture/traditional arts";
+ case 0x05 : return "literature";
+ case 0x06 : return "film/cinema";
+ case 0x07 : return "experimental film/video";
+ case 0x08 : return "broadcasting/press";
+ case 0x09 : return "new media";
+ case 0x0A : return "arts/culture magazines";
+ case 0x0B : return "fashion";
+ default :
+ if (content_nibble_level_2==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2_08(int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_2)
+ {
+ case 0x00 : return "social/political issues/economics";
+ case 0x01 : return "magazines/reports/documentary";
+ case 0x02 : return "economics/social advisory";
+ case 0x03 : return "remarkable people";
+ default :
+ if (content_nibble_level_2==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2_09(int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_2)
+ {
+ case 0x00 : return "education/science/factual topics";
+ case 0x01 : return "nature/animals/environment";
+ case 0x02 : return "technology/natural sciences";
+ case 0x03 : return "medicine/physiology/psychology";
+ case 0x04 : return "foreign countries/expeditions";
+ case 0x05 : return "social/spiritual sciences";
+ case 0x06 : return "further education";
+ case 0x07 : return "languages";
+ default :
+ if (content_nibble_level_2==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2_0A(int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_2)
+ {
+ case 0x00 : return "leisure hobbies";
+ case 0x01 : return "tourism/travel";
+ case 0x02 : return "handicraft";
+ case 0x03 : return "motoring";
+ case 0x04 : return "fitness and health";
+ case 0x05 : return "cooking";
+ case 0x06 : return "advertisement/shopping";
+ case 0x07 : return "gardening";
+ default :
+ if (content_nibble_level_2==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2_0B(int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_2)
+ {
+ case 0x00 : return "original language";
+ case 0x01 : return "black and white";
+ case 0x02 : return "unpublished";
+ case 0x03 : return "live broadcast";
+ default :
+ if (content_nibble_level_2==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_content_nibble_level_2(int8u content_nibble_level_1, int8u content_nibble_level_2)
+{
+ switch (content_nibble_level_1)
+ {
+ case 0x00 : return "undefined";
+ case 0x01 : return Mpeg_Descriptors_content_nibble_level_2_01(content_nibble_level_2);
+ case 0x02 : return Mpeg_Descriptors_content_nibble_level_2_02(content_nibble_level_2);
+ case 0x03 : return Mpeg_Descriptors_content_nibble_level_2_03(content_nibble_level_2);
+ case 0x04 : return Mpeg_Descriptors_content_nibble_level_2_04(content_nibble_level_2);
+ case 0x05 : return Mpeg_Descriptors_content_nibble_level_2_05(content_nibble_level_2);
+ case 0x06 : return Mpeg_Descriptors_content_nibble_level_2_06(content_nibble_level_2);
+ case 0x07 : return Mpeg_Descriptors_content_nibble_level_2_07(content_nibble_level_2);
+ case 0x08 : return Mpeg_Descriptors_content_nibble_level_2_08(content_nibble_level_2);
+ case 0x09 : return Mpeg_Descriptors_content_nibble_level_2_09(content_nibble_level_2);
+ case 0x0A : return Mpeg_Descriptors_content_nibble_level_2_0A(content_nibble_level_2);
+ case 0x0B : return Mpeg_Descriptors_content_nibble_level_2_0B(content_nibble_level_2);
+ default :
+ if (content_nibble_level_1==0x0F)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_linkage_type(int8u linkage_type)
+{
+ switch (linkage_type)
+ {
+ case 0x00 : return "reserved for future use";
+ case 0x01 : return "information service";
+ case 0x02 : return "Electronic Programme Guide (EPG) service";
+ case 0x03 : return "CA replacement service";
+ case 0x04 : return "transport stream containing complete Network/Bouquet SI";
+ case 0x05 : return "service replacement service";
+ case 0x06 : return "data broadcast service";
+ case 0xFF : return "reserved for future use";
+ default :
+ if (linkage_type>=0x80)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_dvb_service_type(int8u service_type)
+{
+ switch (service_type)
+ {
+ case 0x01 : return "digital television";
+ case 0x02 : return "digital radio";
+ case 0x03 : return "teletext";
+ case 0x04 : return "NVOD reference";
+ case 0x05 : return "NVOD time-shifted";
+ case 0x06 : return "Mosaic";
+ case 0x0A : return "advanced codec digital radio sound";
+ case 0x0B : return "advanced codec mosaic service";
+ case 0x0C : return "data broadcast";
+ case 0x0D : return "reserved for Common Interface Usage";
+ case 0x0E : return "RCS Map";
+ case 0x0F : return "RCS FLS";
+ case 0x10 : return "DVB MHP";
+ case 0x11 : return "MPEG-2 HD digital television";
+ case 0x16 : return "advanced codec SD digital television";
+ case 0x17 : return "advanced codec SD NVOD time-shifted";
+ case 0x18 : return "advanced codec SD NVOD reference";
+ case 0x19 : return "advanced codec HD digital television";
+ case 0x1A : return "advanced codec HD NVOD time-shifted";
+ case 0x1B : return "advanced codec HD NVOD reference";
+ case 0xFF : return "reserved for future use";
+ default :
+ if (service_type>=0x80)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_stream_content(int8u stream_content)
+{
+ switch (stream_content)
+ {
+ case 0x01 : return "MPEG-2 Video";
+ case 0x02 : return "MPEG-1 Audio L2";
+ case 0x03 : return "Subtitle";
+ case 0x04 : return "AC3";
+ case 0x05 : return "AVC";
+ case 0x06 : return "HE-AAC";
+ case 0x07 : return "DTS";
+ default :
+ if (stream_content>=0x0C)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_component_type_O1(int8u component_type)
+{
+ switch (component_type)
+ {
+ case 0x01 : return "4:3 aspect ratio, 25 Hz";
+ case 0x02 : return "16:9 aspect ratio with pan vectors, 25 Hz";
+ case 0x03 : return "16:9 aspect ratio without pan vectors, 25 Hz";
+ case 0x04 : return ">16:9 aspect ratio, 25 Hz";
+ case 0x05 : return "4:3 aspect ratio, 30 Hz";
+ case 0x06 : return "16:9 aspect ratio with pan vectors, 30 Hz";
+ case 0x07 : return "16:9 aspect ratio without pan vectors, 30 Hz";
+ case 0x08 : return ">16:9 aspect ratio, 30 Hz";
+ case 0x09 : return "4:3 aspect ratio, 25 Hz (high definition)";
+ case 0x0A : return "16:9 aspect ratio with pan vectors, 25 Hz (high definition)";
+ case 0x0B : return "16:9 aspect ratio without pan vectors, 25 Hz (high definition)";
+ case 0x0C : return ">16:9 aspect ratio, 25 Hz (high definition)";
+ case 0x0D : return "4:3 aspect ratio, 30 Hz (high definition)";
+ case 0x0E : return "16:9 aspect ratio with pan vectors, 30 Hz (high definition)";
+ case 0x0F : return "16:9 aspect ratio without pan vectors, 30 Hz (high definition)";
+ case 0x10 : return ">16:9 aspect ratio, 30 Hz (high definition)";
+ default :
+ if (component_type>=0xB0 && component_type<=0xFE)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_component_type_O2(int8u component_type)
+{
+ switch (component_type)
+ {
+ case 0x01 : return "single mono channel";
+ case 0x02 : return "dual mono channel";
+ case 0x03 : return "stereo (2 channel)";
+ case 0x04 : return "multi-lingual, multi-channel";
+ case 0x05 : return "surround sound";
+ case 0x40 : return "description for the visually impaired";
+ case 0x41 : return "for the hard of hearing";
+ case 0x42 : return "receiver-mixed supplementary audio";
+ default :
+ if (component_type>=0xB0 && component_type<=0xFE)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_component_type_O3(int8u component_type)
+{
+ switch (component_type)
+ {
+ case 0x01 : return "EBU Teletext subtitles";
+ case 0x02 : return "associated EBU Teletext";
+ case 0x03 : return "VBI data";
+ case 0x10 : return "DVB subtitle (normal) with no monitor aspect ratio criticality";
+ case 0x11 : return "DVB subtitle (normal) for display on 4:3 aspect ratio monitor";
+ case 0x12 : return "DVB subtitle (normal) for display on 16:9 aspect ratio monitor";
+ case 0x13 : return "DVB subtitle (normal) for display on 2.21:1 aspect ratio monitor";
+ case 0x20 : return "DVB subtitle (for the hard of hearing) with no monitor aspect ratio criticality";
+ case 0x21 : return "DVB subtitle (for the hard of hearing) for display on 4:3 aspect ratio monitor";
+ case 0x22 : return "DVB subtitle (for the hard of hearing) for display on 16:9 aspect ratio monitor";
+ case 0x23 : return "DVB subtitle (for the hard of hearing) for display on 2.21:1 aspect ratio monitor";
+ default :
+ if (component_type>=0xB0 && component_type<=0xFE)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_component_type_O4(int8u)
+{
+ return "Defined by AC3";
+}
+
+const char* Mpeg_Descriptors_component_type_O5(int8u component_type)
+{
+ switch (component_type)
+ {
+ case 0x01 : return "4:3 aspect ratio, 25 Hz";
+ case 0x03 : return "16:9 aspect ratio, 25 Hz";
+ case 0x04 : return ">16:9 aspect ratio, 25 Hz";
+ case 0x05 : return "4:3 aspect ratio, 30 Hz";
+ case 0x07 : return "16:9 aspect ratio, 30 Hz";
+ case 0x08 : return ">16:9 aspect ratio, 30 Hz";
+ case 0x0B : return "16:9 aspect ratio, 25 Hz (high definition)";
+ case 0x0C : return ">16:9 aspect ratio, 25 Hz (high definition)";
+ case 0x0F : return "16:9 aspect ratio, 30 Hz (high definition)";
+ case 0x10 : return ">16:9 aspect ratio, 30 Hz (high definition)";
+ default :
+ if (component_type>=0xB0 && component_type<=0xFE)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_component_type_O6(int8u component_type)
+{
+ switch (component_type)
+ {
+ case 0x01 : return "single mono channel";
+ case 0x03 : return "stereo";
+ case 0x05 : return "surround sound";
+ case 0x40 : return "description for the visually impaired";
+ case 0x41 : return "for the hard of hearing";
+ case 0x42 : return "receiver-mixed supplementary audio";
+ case 0x43 : return "astereo (v2)";
+ case 0x44 : return "description for the visually impaired (v2)";
+ case 0x45 : return "for the hard of hearing (v2)";
+ case 0x46 : return "receiver-mixed supplementary audio (v2)";
+ default :
+ if (component_type>=0xB0 && component_type<=0xFE)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_component_type_O7(int8u)
+{
+ return "Defined by DTS";
+}
+
+const char* Mpeg_Descriptors_codepage_1(int8u codepage)
+{
+ switch (codepage)
+ {
+ case 0x01 : return "ISO/IEC 8859-5 (Cyrillic)";
+ case 0x02 : return "ISO/IEC 8859-6 (Arabic)";
+ case 0x03 : return "ISO/IEC 8859-7 (Greek)";
+ case 0x04 : return "ISO/IEC 8859-8 (Hebrew)";
+ case 0x05 : return "ISO/IEC 8859-9 (Latin)";
+ case 0x06 : return "ISO/IEC 8859-10 (Latin)";
+ case 0x07 : return "ISO/IEC 8859-11 (Thai)";
+ case 0x08 : return "ISO/IEC 8859-12 (Indian)";
+ case 0x09 : return "ISO/IEC 8859-13 (Latin)";
+ case 0x0A : return "ISO/IEC 8859-14 (Celtic)";
+ case 0x0B : return "ISO/IEC 8859-15 (Latin)";
+ case 0x11 : return "ISO/IEC 10646-1 (Basic Multilingual Plane)";
+ case 0x12 : return "KSC5601-1987 (Korean)";
+ case 0x13 : return "GB-2312-1980 (Simplified Chinese)";
+ case 0x14 : return "Big5 (Traditional Chinese)";
+ case 0x15 : return "UTF-8 (Basic Multilingual Plane)";
+ default : return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_component_type(int8u stream_content, int8u component_type)
+{
+ switch (stream_content)
+ {
+ case 0x01 : return Mpeg_Descriptors_component_type_O1(component_type);
+ case 0x02 : return Mpeg_Descriptors_component_type_O2(component_type);
+ case 0x03 : return Mpeg_Descriptors_component_type_O3(component_type);
+ case 0x04 : return Mpeg_Descriptors_component_type_O4(component_type);
+ case 0x05 : return Mpeg_Descriptors_component_type_O5(component_type);
+ case 0x06 : return Mpeg_Descriptors_component_type_O6(component_type);
+ case 0x07 : return Mpeg_Descriptors_component_type_O7(component_type);
+ default :
+ if (component_type>=0xB0 && component_type<=0xFE)
+ return "user defined";
+ else
+ return "reserved for future use";
+ }
+}
+
+const char* Mpeg_Descriptors_registration_format_identifier_Format(int32u format_identifier)
+{
+ switch (format_identifier)
+ {
+ case Elements::AC_3 : return "AC-3";
+ case Elements::BSSD : return "PCM"; //AES3
+ case Elements::CUEI : return "SCTE 35 2003 - Digital Program Insertion Cueing Message for Cable";
+ case Elements::DTS1 : return "DTS"; //512
+ case Elements::DTS2 : return "DTS"; //1024
+ case Elements::DTS3 : return "DTS"; //2048
+ case Elements::GA94 : return "ATSC - Terrestrial";
+ case Elements::HDMV : return "Blu-ray";
+ case Elements::KLVA : return "KLV";
+ case Elements::S14A : return "ATSC - Satellite";
+ case Elements::SCTE : return "SCTE 54 2003 - DV Service Multiplex and Transport System for Cable Television";
+ case Elements::TSHV : return "DV";
+ case Elements::VC_1 : return "VC-1";
+ case Elements::MANZ : return "Manzanita Systems"; //Manzanita Systems
+ default : return "";
+ }
+}
+
+stream_t Mpeg_Descriptors_registration_format_identifier_StreamKind(int32u format_identifier)
+{
+ switch (format_identifier)
+ {
+ case Elements::AC_3 : return Stream_Audio;
+ case Elements::BSSD : return Stream_Audio;
+ case Elements::DTS1 : return Stream_Audio;
+ case Elements::DTS2 : return Stream_Audio;
+ case Elements::DTS3 : return Stream_Audio;
+ case Elements::VC_1 : return Stream_Video;
+ default : return Stream_Max;
+ }
+}
+
+const char* Mpeg_Descriptors_stream_Format(int8u descriptor_tag, int32u format_identifier)
+{
+ switch (descriptor_tag)
+ {
+ case 0x02 : return "MPEG Video";
+ case 0x03 : return "MPEG Audio";
+ case 0x1B : return "MPEG-4 Visual";
+ case 0x1C : return "AAC";
+ case 0x28 : return "AVC";
+ case 0x2B : return "AAC";
+ case 0x2D : return "Text";
+ default :
+ switch (format_identifier)
+ {
+ case Elements::CUEI :
+ case Elements::SCTE : //SCTE
+ case Elements::GA94 :
+ case Elements::S14A : //ATSC
+ switch (descriptor_tag)
+ {
+ case 0x81 : return "AC-3";
+ default : return "";
+ }
+ case Elements::AC_3 : return "AC-3";
+ case Elements::DTS1 : return "DTS";
+ case Elements::DTS2 : return "DTS";
+ case Elements::DTS3 : return "DTS";
+ case Elements::KLVA : return "KLV";
+ case Elements::VC_1 : return "VC-1";
+ case Elements::drac : return "Dirac";
+ default :
+ switch (descriptor_tag)
+ {
+ case 0x56 : return "Teletext";
+ case 0x59 : return "DVB Subtitle";
+ case 0x6A : return "AC-3";
+ case 0x7A : return "E-AC-3";
+ case 0x7B : return "DTS";
+ case 0x7C : return "AAC";
+ case 0x81 : return "AC-3";
+ default : return "";
+ }
+ }
+ }
+}
+
+const char* Mpeg_Descriptors_stream_Codec(int8u descriptor_tag, int32u format_identifier)
+{
+ switch (descriptor_tag)
+ {
+ case 0x02 : return "MPEG-V";
+ case 0x03 : return "MPEG-A";
+ case 0x1B : return "MPEG-4V";
+ case 0x1C : return "AAC";
+ case 0x28 : return "AVC";
+ case 0x2B : return "AAC";
+ case 0x2D : return "Text";
+ default :
+ switch (format_identifier)
+ {
+ case Elements::CUEI :
+ case Elements::SCTE : //SCTE
+ case Elements::GA94 :
+ case Elements::S14A : //ATSC
+ switch (descriptor_tag)
+ {
+ case 0x81 : return "AC3";
+ default : return "";
+ }
+ case Elements::AC_3 : return "AC3";
+ case Elements::DTS1 : return "DTS";
+ case Elements::DTS2 : return "DTS";
+ case Elements::DTS3 : return "DTS";
+ case Elements::KLVA : return "KLV";
+ case Elements::VC_1 : return "VC-1";
+ case Elements::drac : return "Dirac";
+ default :
+ switch (descriptor_tag)
+ {
+ case 0x56 : return "Teletext";
+ case 0x59 : return "DVB Subtitle";
+ case 0x6A : return "AC3";
+ case 0x7A : return "AC3+";
+ case 0x7B : return "DTS";
+ case 0x7C : return "AAC";
+ case 0x81 : return "AC3";
+ default : return "";
+ }
+ }
+ }
+}
+
+stream_t Mpeg_Descriptors_stream_Kind(int8u descriptor_tag, int32u format_identifier)
+{
+ switch (descriptor_tag)
+ {
+ case 0x02 : return Stream_Video;
+ case 0x03 : return Stream_Audio;
+ case 0x1B : return Stream_Video;
+ case 0x1C : return Stream_Audio;
+ case 0x28 : return Stream_Video;
+ case 0x2B : return Stream_Audio;
+ case 0x2D : return Stream_Text;
+ default :
+ switch (format_identifier)
+ {
+ case Elements::CUEI :
+ case Elements::SCTE : //SCTE
+ case Elements::GA94 :
+ case Elements::S14A : //ATSC
+ switch (descriptor_tag)
+ {
+ case 0x81 : return Stream_Audio;
+ default : return Stream_Max;
+ }
+ case Elements::AC_3 : return Stream_Audio;
+ case Elements::DTS1 : return Stream_Audio;
+ case Elements::DTS2 : return Stream_Audio;
+ case Elements::DTS3 : return Stream_Audio;
+ case Elements::VC_1 : return Stream_Video;
+ case Elements::drac : return Stream_Video;
+ default :
+ switch (descriptor_tag)
+ {
+ case 0x56 : return Stream_Text;
+ case 0x59 : return Stream_Text;
+ case 0x6A : return Stream_Audio;
+ case 0x7A : return Stream_Audio;
+ case 0x7B : return Stream_Audio;
+ case 0x7C : return Stream_Audio;
+ case 0x81 : return Stream_Audio;
+ default : return Stream_Max;
+ }
+ }
+ }
+}
+
+const char* Mpeg_Descriptors_MPEG_4_audio_profile_and_level(int8u MPEG_4_audio_profile_and_level)
+{
+ switch (MPEG_4_audio_profile_and_level)
+ {
+ case 0x10 : return "Main@L1";
+ case 0x11 : return "Main@L2";
+ case 0x12 : return "Main@L3";
+ case 0x13 : return "Main@L4";
+ case 0x18 : return "Scalable@L1";
+ case 0x19 : return "Scalable@L2";
+ case 0x1A : return "Scalable@L3";
+ case 0x1B : return "Scalable@L4";
+ case 0x20 : return "Speech@L1";
+ case 0x21 : return "Speech@L2";
+ case 0x28 : return "Synthesis@L1";
+ case 0x29 : return "Synthesis@L2";
+ case 0x2A : return "Synthesis@L3";
+ case 0x30 : return "High quality audio@L1";
+ case 0x31 : return "High quality audio@L2";
+ case 0x32 : return "High quality audio@L3";
+ case 0x33 : return "High quality audio@L4";
+ case 0x34 : return "High quality audio@L5";
+ case 0x35 : return "High quality audio@L6";
+ case 0x36 : return "High quality audio@L7";
+ case 0x37 : return "High quality audio@L8";
+ case 0x38 : return "Low delay audio@L1";
+ case 0x39 : return "Low delay audio@L2";
+ case 0x3A : return "Low delay audio@L3";
+ case 0x3B : return "Low delay audio@L4";
+ case 0x3C : return "Low delay audio@L5";
+ case 0x3D : return "Low delay audio@L6";
+ case 0x3E : return "Low delay audio@L7";
+ case 0x3F : return "Low delay audio@L8";
+ case 0x40 : return "Natural audio@L1";
+ case 0x41 : return "Natural audio@L2";
+ case 0x42 : return "Natural audio@L3";
+ case 0x43 : return "Natural audio@L4";
+ case 0x48 : return "Mobile audio internetworking@L1";
+ case 0x49 : return "Mobile audio internetworking@L2";
+ case 0x4A : return "Mobile audio internetworking@L3";
+ case 0x4B : return "Mobile audio internetworking@L4";
+ case 0x4C : return "Mobile audio internetworking@L5";
+ case 0x4D : return "Mobile audio internetworking@L6";
+ case 0x50 : return "LC@L1";
+ case 0x51 : return "LC@L2";
+ case 0x52 : return "LC@L3";
+ case 0x53 : return "LC@L4";
+ case 0x58 : return "HE-AAC@L2 / LC@L2";
+ case 0x59 : return "HE-AAC@L3 / LC@L3";
+ case 0x5A : return "HE-AAC@L4 / LC@L4";
+ case 0x5B : return "HE-AAC@L5 / LC@L5";
+ case 0x60 : return "HE-AACv2@L2 / HE-AAC@L2 / LC@L2";
+ case 0x61 : return "HE-AACv2@L3 / HE-AAC@L3 / LC@L3";
+ case 0x62 : return "HE-AACv2@L4 / HE-AAC@L4 / LC@L4";
+ case 0x63 : return "HE-AACv2@L5 / HE-AAC@L5 / LC@L5";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+extern const float32 Mpegv_frame_rate[]; //In Video/File_Mpegv.cpp
+extern const char* Mpegv_Colorimetry_format[]; //In Video/File_Mpegv.cpp
+extern const char* Mpegv_profile_and_level_indication_profile[]; //In Video/File_Mpegv.cpp
+extern const char* Mpegv_profile_and_level_indication_level[]; //In Video/File_Mpegv.cpp
+
+//---------------------------------------------------------------------------
+extern const char* Mpega_Version[]; //In Audio/File_Mpega.cpp
+extern const char* Mpega_Layer[]; //In Audio/File_Mpega.cpp
+extern const char* Mpega_Format_Profile_Version[]; //In Audio/File_Mpega.cpp
+extern const char* Mpega_Format_Profile_Layer[]; //In Audio/File_Mpega.cpp
+
+//---------------------------------------------------------------------------
+extern const int32u AC3_SamplingRate[]; //In Audio/File_Ac3.cpp
+extern const int16u AC3_BitRate[]; //In Audio/File_Ac3.cpp
+extern const char* AC3_ChannelPositions[]; //In Audio/File_Ac3.cpp
+extern const int8u AC3_Channels[]; //In Audio/File_Ac3.cpp
+extern const char* AC3_Mode[]; //In Audio/File_Ac3.cpp
+extern const char* AC3_Surround[]; //In Audio/File_Ac3.cpp
+
+const char* Mpeg_Descriptors_AC3_Channels[]=
+{
+ "1",
+ "2",
+ "2",
+ "2",
+ "3+",
+ "6+",
+ "",
+ "",
+};
+
+const char* Mpeg_Descriptors_AC3_Priority[]=
+{
+ "",
+ "Primary Audio",
+ "Other Audio",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Descriptors_bandwidth[]=
+{
+ "8 MHz",
+ "7 MHz",
+ "6 MHz",
+ "5 MHz",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Descriptors_constellation[]=
+{
+ "QPSK",
+ "16-QAM",
+ "64-QAM",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Descriptors_hierarchy_information[]=
+{
+ "non-hierarchical, native interleaver",
+ "1, native interleaver",
+ "2, native interleaver",
+ "4, native interleaver",
+ "non-hierarchical, in-depth interleaver",
+ "1, in-depth interleaver",
+ "2, in-depth interleaver",
+ "4, in-depth interleaver",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Descriptors_code_rate[]=
+{
+ "1/2",
+ "2/3",
+ "3/4",
+ "5/6",
+ "7/8",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Descriptors_guard_interval[]=
+{
+ "1/32",
+ "1/16",
+ "1/8",
+ "1/4",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Descriptors_transmission_mode[]=
+{
+ "2k mode",
+ "8k mode",
+ "4k mode",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Descriptors_original_network_id(int16u original_network_id)
+{
+ switch (original_network_id)
+ {
+ case 0x0001 : return "Astra Satellite Network 19,2'E";
+ case 0x0002 : return "Astra Satellite Network 28,2'E";
+ case 0x0003 : return "Astra 1";
+ case 0x0004 : return "Astra 2";
+ case 0x0005 : return "Astra 3";
+ case 0x0006 : return "Astra 4";
+ case 0x0007 : return "Astra 5";
+ case 0x0008 : return "Astra 6";
+ case 0x0009 : return "Astra 7";
+ case 0x000A : return "Astra 8";
+ case 0x000B : return "Astra 9";
+ case 0x000C : return "Astra 10";
+ case 0x000D : return "Astra 11";
+ case 0x000E : return "Astra 12";
+ case 0x000F : return "Astra 13";
+ case 0x0010 : return "Astra 14";
+ case 0x0011 : return "Astra 15";
+ case 0x0012 : return "Astra 16";
+ case 0x0013 : return "Astra 17";
+ case 0x0014 : return "Astra 18";
+ case 0x0015 : return "Astra 19";
+ case 0x0016 : return "Astra 20";
+ case 0x0017 : return "Astra 21";
+ case 0x0018 : return "Astra 22";
+ case 0x0019 : return "Astra 23";
+ case 0x0020 : return "ASTRA";
+ case 0x0021 : return "Hispasat Network 1";
+ case 0x0022 : return "Hispasat Network 2";
+ case 0x0023 : return "Hispasat Network 3";
+ case 0x0024 : return "Hispasat Network 4";
+ case 0x0025 : return "Hispasat Network 5";
+ case 0x0026 : return "Hispasat Network 6";
+ case 0x0027 : return "Hispasat 30'W (FSS)";
+ case 0x0028 : return "Hispasat 30'W (DBS)";
+ case 0x0029 : return "Hispasat 30'W (America)";
+ case 0x0030 : return "Canal+ Satellite Network";
+ case 0x0031 : return "Hispasat – VIA DIGITAL";
+ case 0x0032 : return "Hispasat Network 7";
+ case 0x0033 : return "Hispasat Network 8";
+ case 0x0034 : return "Hispasat Network 9";
+ case 0x0035 : return "Nethold Main Mux System";
+ case 0x0037 : return "STENTOR";
+ case 0x0040 : return "HPT – Croatian Post and Telecommunications";
+ case 0x0041 : return "Mindport";
+ case 0x0046 : return "1 degree W (Telenor)";
+ case 0x0047 : return "1 degree W (Telenor)";
+ case 0x0050 : return "HRT – Croatian Radio and Television";
+ case 0x0051 : return "Havas";
+ case 0x0052 : return "Osaka Yusen Satellite";
+ case 0x0055 : return "Sirius Satellite System";
+ case 0x0058 : return "Thiacom 1 & 2 co-located 78.5'E (UBC Thailand)";
+ case 0x005E : return "Sirius Satellite System (Nordic Coverage)";
+ case 0x005F : return "Sirius Satellite System (FSS)";
+ case 0x0060 : return "Deutsche Telekom";
+ case 0x0069 : return "Optus B3 156'E";
+ case 0x0070 : return "BONUM1 36 Degrees East (NTV+)";
+ case 0x007E : return "Eutelsat Satellite System at 7'E";
+ case 0x0073 : return "PanAmSat 4 68.5'E";
+ case 0x0085 : return "BetaTechnik";
+ case 0x0090 : return "TDF";
+ case 0x00A0 : return "News Datacom";
+ case 0x00A1 : return "News Datacom";
+ case 0x00A2 : return "News Datacom";
+ case 0x00A3 : return "News Datacom";
+ case 0x00A4 : return "News Datacom";
+ case 0x00A5 : return "News Datacom";
+ case 0x00A6 : return "ART";
+ case 0x00A7 : return "Globecast";
+ case 0x00A8 : return "Foxtel";
+ case 0x00A9 : return "Sky New Zealand";
+ case 0x00B0 : return "TPS";
+ case 0x00B1 : return "TPS";
+ case 0x00B2 : return "TPS";
+ case 0x00B3 : return "TPS";
+ case 0x00B4 : return "Telesat 107.3'W";
+ case 0x00B5 : return "Telesat 111.1'W";
+ case 0x00BA : return "Satellite Express – 6 (80'E)";
+ case 0x00C0 : return "Canal+";
+ case 0x00C1 : return "Canal+";
+ case 0x00C2 : return "Canal+";
+ case 0x00C3 : return "Canal+";
+ case 0x00C4 : return "Canal+";
+ case 0x00C5 : return "Canal+";
+ case 0x00C6 : return "Canal+";
+ case 0x00C7 : return "Canal+";
+ case 0x00C8 : return "Canal+";
+ case 0x00C9 : return "Canal+";
+ case 0x00CA : return "Canal+";
+ case 0x00CB : return "Canal+";
+ case 0x00CC : return "Canal+";
+ case 0x00CD : return "Canal+";
+ case 0x0100 : return "ExpressVu Express";
+ case 0x010E : return "Eutelsat Satellite System at 10'E";
+ case 0x0110 : return "Mediaset";
+ case 0x013E : return "Eutelsat Satellite System at 13'E";
+ case 0x016E : return "Eutelsat Satellite System at 16'E";
+ case 0x029E : return "Eutelsat Satellite System at 29'E";
+ case 0x02BE : return "Arabsat Arabsat (Scientific Atlanta, Eutelsat)";
+ case 0x036E : return "Eutelsat Satellite System at 36'E";
+ case 0x03E8 : return "Telia";
+ case 0x048E : return "Eutelsat Satellite System at 48'E";
+ case 0x0800 : return "Nilesat 101";
+ case 0x0801 : return "Nilesat 101";
+ case 0x0880 : return "MEASAT 1, 91.5'E";
+ case 0x0882 : return "MEASAT 2, 91.5'E";
+ case 0x0883 : return "MEASAT 2, 148.0'E";
+ case 0x088F : return "MEASAT 3";
+ case 0x1000 : return "Optus B3 156'E Optus Communications";
+ case 0x1001 : return "DISH Network Echostar Communications";
+ case 0x1002 : return "Dish Network 61.5 W Echostar Communications";
+ case 0x1003 : return "Dish Network 83 W Echostar Communications";
+ case 0x1004 : return "Dish Network 119 W Echostar Communications";
+ case 0x1005 : return "Dish Network 121 W Echostar Communications";
+ case 0x1006 : return "Dish Network 148 W Echostar Communications";
+ case 0x1007 : return "Dish Network 175 W Echostar Communications";
+ case 0x1008 : return "Dish Network W Echostar Communications";
+ case 0x1009 : return "Dish Network X Echostar Communications";
+ case 0x100A : return "Dish Network Y Echostar Communications";
+ case 0x100B : return "Dish Network Z Echostar Communications";
+ case 0x2000 : return "Thiacom 1 & 2 co-located 78.5'E";
+ case 0x22D4 : return "Spanish Digital Terrestrial Television";
+ case 0x22F1 : return "Swedish Digital Terrestrial Television";
+ case 0x233A : return "UK Digital Terrestrial Television";
+ case 0x2024 : return "Australian Digital Terrestrial Television";
+ case 0x2114 : return "German Digital Terrestrial Television";
+ case 0x3000 : return "PanAmSat 4 68.5'E";
+ case 0x5000 : return "Irdeto Mux System";
+ case 0xF000 : return "Small Cable networks";
+ case 0xF001 : return "Deutsche Telekom";
+ case 0xF010 : return "Telefonica Cable";
+ case 0xF020 : return "Cable and Wireless Communication";
+ case 0xFBFC : return "MATAV";
+ case 0xFBFD : return "Telia Kabel-TV";
+ case 0xFBFE : return "TPS";
+ case 0xFBFF : return "Stream";
+ case 0xFC00 : return "France Telecom Cable";
+ case 0xFC10 : return "Rhone Vision Cable";
+ case 0xFD00 : return "Lyonnaise Communications";
+ case 0xFE00 : return "TeleDenmark Cable TV";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Descriptors_CA_system_ID(int16u CA_ID)
+{
+ switch (CA_ID)
+ {
+ case 0x0100 : return "Seca Mediaguard 1/2";
+ case 0x0101 : return "RusCrypto";
+ case 0x0464 : return "EuroDec";
+ case 0x0500 : return "TPS-Crypt or Viaccess";
+ case 0x0602 :
+ case 0x0604 :
+ case 0x0606 :
+ case 0x0608 :
+ case 0x0622 :
+ case 0x0626 : return "Irdeto";
+ case 0x0700 : return "DigiCipher 2";
+ case 0x0911 :
+ case 0x0919 :
+ case 0x0960 :
+ case 0x0961 : return "NDS Videoguard 1/2";
+ case 0x0B00 : return "Conax CAS 5 /7";
+ case 0x0D00 :
+ case 0x0D02 :
+ case 0x0D03 :
+ case 0x0D05 :
+ case 0x0D07 :
+ case 0x0D20 : return "Cryptoworks";
+ case 0x0E00 : return "PowerVu";
+ case 0x1000 : return "RAS (Remote Authorisation System)";
+ case 0x1702 :
+ case 0x1722 :
+ case 0x1762 : return "BetaCrypt 1 or Nagravision";
+ case 0x1710 : return "BetaCrypt 2";
+ case 0x1800 :
+ case 0x1801 :
+ case 0x1810 :
+ case 0x1830 : return "Nagravision";
+ case 0x22F0 : return "Codicrypt";
+ case 0x2600 : return "BISS";
+ case 0x4800 : return "Accessgate";
+ case 0x4900 : return "China Crypt";
+ case 0x4A10 : return "EasyCas";
+ case 0x4A20 : return "AlphaCrypt";
+ case 0x4A60 :
+ case 0x4A61 :
+ case 0x4A63 : return "SkyCrypt or Neotioncrypt or Neotion SHL";
+ case 0x4A70 : return "DreamCrypt";
+ case 0x4A80 : return "ThalesCrypt";
+ case 0x4AA1 : return "KeyFly";
+ case 0x4ABF : return "DG-Crypt";
+ case 0x4AD0 :
+ case 0x4AD1 : return "X-Crypt";
+ case 0x4AD4 : return "OmniCrypt";
+ case 0x4AE0 : return "RossCrypt";
+ case 0x5500 : return "Z-Crypt or DRE-Crypt";
+ case 0x5501 : return "Griffin";
+ default : return "Encrypted";
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Mpeg_Descriptors::File_Mpeg_Descriptors()
+{
+ //In
+ Complete_Stream=NULL;
+ transport_stream_id=0x0000;
+ pid=0x0000;
+ table_id=0x00;
+ table_id_extension=0x0000;
+ elementary_PID=0x0000;
+ program_number=0x0000;
+ stream_type=0x00;
+ event_id=0x0000;
+ elementary_PID_IsValid=false;
+ program_number_IsValid=false;
+ stream_type_IsValid=false;
+ event_id_IsValid=false;
+
+ //Out
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Header_Parse()
+{
+ int8u descriptor_tag=0, descriptor_length=0;
+ Get_B1 (descriptor_tag, "descriptor_tag");
+ Get_B1 (descriptor_length, "descriptor_length");
+
+ //Size
+ if (Element_Size)
+ Header_Fill_Size(Element_Size);
+ if (Element_Offset)
+ Header_Fill_Size(Element_Offset);
+ if (descriptor_length)
+ Header_Fill_Size(descriptor_length);
+
+ if (Element_Size<Element_Offset+descriptor_length)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ //Filling
+ Header_Fill_Code(descriptor_tag, Ztring().From_Number(descriptor_tag, 16));
+ Header_Fill_Size(2+descriptor_length);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Data_Parse()
+{
+ #define ELEMENT_CASE(_NAME, _DETAIL) \
+ case 0x##_NAME : Element_Name(_DETAIL); Descriptor_##_NAME(); break;
+
+ //Parsing
+ if (table_id> 0x00 && table_id<0x40)
+ {
+ switch (Element_Code)
+ {
+ ELEMENT_CASE(00, "Reserved");
+ ELEMENT_CASE(01, "Reserved");
+ ELEMENT_CASE(02, "video_stream");
+ ELEMENT_CASE(03, "audio_stream");
+ ELEMENT_CASE(04, "hierarchy");
+ ELEMENT_CASE(05, "registration");
+ ELEMENT_CASE(06, "data_stream_alignment");
+ ELEMENT_CASE(07, "target_background_grid");
+ ELEMENT_CASE(08, "Video_window");
+ ELEMENT_CASE(09, "CA");
+ ELEMENT_CASE(0A, "ISO_639_language");
+ ELEMENT_CASE(0B, "System_clock");
+ ELEMENT_CASE(0C, "Multiplex_buffer_utilization");
+ ELEMENT_CASE(0D, "Copyright");
+ ELEMENT_CASE(0E, "Maximum_bitrate");
+ ELEMENT_CASE(0F, "Private_data_indicator");
+ ELEMENT_CASE(10, "Smoothing_buffer");
+ ELEMENT_CASE(11, "STD");
+ ELEMENT_CASE(12, "IBP");
+ ELEMENT_CASE(13, "Defined in ISO/IEC 13818-6");
+ ELEMENT_CASE(14, "Defined in ISO/IEC 13818-6");
+ ELEMENT_CASE(15, "Defined in ISO/IEC 13818-6");
+ ELEMENT_CASE(16, "Defined in ISO/IEC 13818-6");
+ ELEMENT_CASE(17, "Defined in ISO/IEC 13818-6");
+ ELEMENT_CASE(18, "Defined in ISO/IEC 13818-6");
+ ELEMENT_CASE(19, "Defined in ISO/IEC 13818-6");
+ ELEMENT_CASE(1A, "Defined in ISO/IEC 13818-6");
+ ELEMENT_CASE(1B, "MPEG-4_video");
+ ELEMENT_CASE(1C, "MPEG-4_audio");
+ ELEMENT_CASE(1D, "IOD");
+ ELEMENT_CASE(1E, "SL");
+ ELEMENT_CASE(1F, "FMC");
+ ELEMENT_CASE(20, "External_ES_ID");
+ ELEMENT_CASE(21, "MuxCode");
+ ELEMENT_CASE(22, "FmxBufferSize");
+ ELEMENT_CASE(23, "multiplexbuffer");
+ ELEMENT_CASE(24, "content_labeling");
+ ELEMENT_CASE(25, "metadata_pointer");
+ ELEMENT_CASE(26, "metadata");
+ ELEMENT_CASE(27, "metadata_STD");
+ ELEMENT_CASE(28, "AVC video");
+ ELEMENT_CASE(29, "IPMP"); //ISO-IEC 13818-11
+ ELEMENT_CASE(2A, "AVC timing and HRD");
+ ELEMENT_CASE(2B, "MPEG-2 AAC audio");
+ ELEMENT_CASE(2C, "FlexMux_Timing");
+ ELEMENT_CASE(2D, "MPEG-4_text");
+ ELEMENT_CASE(2E, "MPEG-4_audio_extension");
+ ELEMENT_CASE(2F, "Auxiliary_video_data");
+
+ //Following is in private sections, in case there is not network type detected
+ ELEMENT_CASE(40, "DVB - network_name_descriptor");
+ ELEMENT_CASE(41, "DVB - service_list_descriptor");
+ ELEMENT_CASE(42, "DVB - stuffing_descriptor");
+ ELEMENT_CASE(43, "DVB - satellite_delivery_system_descriptor");
+ ELEMENT_CASE(44, "DVB - cable_delivery_system_descriptor");
+ ELEMENT_CASE(45, "DVB - VBI_data_descriptor");
+ ELEMENT_CASE(46, "DVB - VBI_teletext_descriptor");
+ ELEMENT_CASE(47, "DVB - bouquet_name_descriptor");
+ ELEMENT_CASE(48, "DVB - service_descriptor");
+ ELEMENT_CASE(49, "DVB - country_availability_descriptor");
+ ELEMENT_CASE(4A, "DVB - linkage_descriptor");
+ ELEMENT_CASE(4B, "DVB - NVOD_reference_descriptor");
+ ELEMENT_CASE(4C, "DVB - time_shifted_service_descriptor");
+ ELEMENT_CASE(4D, "DVB - short_event_descriptor");
+ ELEMENT_CASE(4E, "DVB - extended_event_descriptor");
+ ELEMENT_CASE(4F, "DVB - time_shifted_event_descriptor");
+ ELEMENT_CASE(50, "DVB - component_descriptor");
+ ELEMENT_CASE(51, "DVB - mosaic_descriptor");
+ ELEMENT_CASE(52, "DVB - stream_identifier_descriptor");
+ ELEMENT_CASE(53, "DVB - CA_identifier_descriptor");
+ ELEMENT_CASE(54, "DVB - content_descriptor");
+ ELEMENT_CASE(55, "DVB - parental_rating_descriptor");
+ ELEMENT_CASE(56, "DVB - teletext_descriptor");
+ ELEMENT_CASE(57, "DVB - telephone_descriptor");
+ ELEMENT_CASE(58, "DVB - local_time_offset_descriptor");
+ ELEMENT_CASE(59, "DVB - subtitling_descriptor");
+ ELEMENT_CASE(5A, "DVB - terrestrial_delivery_system_descriptor");
+ ELEMENT_CASE(5B, "DVB - multilingual_network_name_descriptor");
+ ELEMENT_CASE(5C, "DVB - multilingual_bouquet_name_descriptor");
+ ELEMENT_CASE(5D, "DVB - multilingual_service_name_descriptor");
+ ELEMENT_CASE(5E, "DVB - multilingual_component_descriptor");
+ ELEMENT_CASE(5F, "DVB - private_data_specifier_descriptor");
+ ELEMENT_CASE(60, "DVB - service_move_descriptor");
+ ELEMENT_CASE(61, "DVB - short_smoothing_buffer_descriptor");
+ ELEMENT_CASE(62, "DVB - frequency_list_descriptor");
+ ELEMENT_CASE(63, "DVB - partial_transport_stream_descriptor");
+ ELEMENT_CASE(64, "DVB - data_broadcast_descriptor");
+ ELEMENT_CASE(65, "DVB - scrambling_descriptor");
+ ELEMENT_CASE(66, "DVB - data_broadcast_id_descriptor");
+ ELEMENT_CASE(67, "DVB - transport_stream_descriptor");
+ ELEMENT_CASE(68, "DVB - DSNG_descriptor");
+ ELEMENT_CASE(69, "DVB - PDC_descriptor");
+ ELEMENT_CASE(6A, "DVB - AC-3_descriptor");
+ ELEMENT_CASE(6B, "DVB - ancillary_data_descriptor");
+ ELEMENT_CASE(6C, "DVB - cell_list_descriptor");
+ ELEMENT_CASE(6D, "DVB - cell_frequency_link_descriptor");
+ ELEMENT_CASE(6E, "DVB - announcement_support_descriptor");
+ ELEMENT_CASE(6F, "DVB - application_signalling_descriptor");
+ ELEMENT_CASE(70, "DVB - adaptation_field_data_descriptor");
+ ELEMENT_CASE(71, "DVB - service_identifier_descriptor");
+ ELEMENT_CASE(72, "DVB - service_availability_descriptor");
+ ELEMENT_CASE(73, "DVB - default_authority_descriptor");
+ ELEMENT_CASE(74, "DVB - related_content_descriptor");
+ ELEMENT_CASE(75, "DVB - TVA_id_descriptor");
+ ELEMENT_CASE(76, "DVB - content_identifier_descriptor");
+ ELEMENT_CASE(77, "DVB - time_slice_fec_identifier_descriptor");
+ ELEMENT_CASE(78, "DVB - ECM_repetition_rate_descriptor");
+ ELEMENT_CASE(79, "DVB - S2_satellite_delivery_system_descriptor");
+ ELEMENT_CASE(7A, "DVB - enhanced_AC-3_descriptor");
+ ELEMENT_CASE(7B, "DVB - DTS descriptor");
+ ELEMENT_CASE(7C, "DVB - AAC descriptor");
+ ELEMENT_CASE(7D, "DVB - reserved for future use");
+ ELEMENT_CASE(7E, "DVB - reserved for future use");
+ ELEMENT_CASE(7F, "DVB - extension descriptor");
+ ELEMENT_CASE(80, "ATSC - stuffing");
+ ELEMENT_CASE(81, "ATSC - AC-3 audio");
+ ELEMENT_CASE(86, "ATSC - caption service");
+ ELEMENT_CASE(87, "ATSC - content advisory");
+ ELEMENT_CASE(A0, "ATSC - extended channel name");
+ ELEMENT_CASE(A1, "ATSC - service location");
+ ELEMENT_CASE(A2, "ATSC - time-shifted service");
+ ELEMENT_CASE(A3, "ATSC - component name");
+ ELEMENT_CASE(A8, "ATSC - DCC Departing Request");
+ ELEMENT_CASE(A9, "ATSC - DCC Arriving Request");
+ ELEMENT_CASE(AA, "ATSC - Redistribution Control");
+ ELEMENT_CASE(AB, "ATSC - DCC Location Code");
+ default: if (Element_Code>=0x40)
+ Element_Info1("user private");
+ else
+ Element_Info1("unknown");
+ Skip_XX(Element_Size, "Data");
+ break;
+ }
+ }
+ else if (table_id>=0x40 && table_id<0x80)
+ {
+ switch (Element_Code)
+ {
+ ELEMENT_CASE(40, "DVB - network_name_descriptor");
+ ELEMENT_CASE(41, "DVB - service_list_descriptor");
+ ELEMENT_CASE(42, "DVB - stuffing_descriptor");
+ ELEMENT_CASE(43, "DVB - satellite_delivery_system_descriptor");
+ ELEMENT_CASE(44, "DVB - cable_delivery_system_descriptor");
+ ELEMENT_CASE(45, "DVB - VBI_data_descriptor");
+ ELEMENT_CASE(46, "DVB - VBI_teletext_descriptor");
+ ELEMENT_CASE(47, "DVB - bouquet_name_descriptor");
+ ELEMENT_CASE(48, "DVB - service_descriptor");
+ ELEMENT_CASE(49, "DVB - country_availability_descriptor");
+ ELEMENT_CASE(4A, "DVB - linkage_descriptor");
+ ELEMENT_CASE(4B, "DVB - NVOD_reference_descriptor");
+ ELEMENT_CASE(4C, "DVB - time_shifted_service_descriptor");
+ ELEMENT_CASE(4D, "DVB - short_event_descriptor");
+ ELEMENT_CASE(4E, "DVB - extended_event_descriptor");
+ ELEMENT_CASE(4F, "DVB - time_shifted_event_descriptor");
+ ELEMENT_CASE(50, "DVB - component_descriptor");
+ ELEMENT_CASE(51, "DVB - mosaic_descriptor");
+ ELEMENT_CASE(52, "DVB - stream_identifier_descriptor");
+ ELEMENT_CASE(53, "DVB - CA_identifier_descriptor");
+ ELEMENT_CASE(54, "DVB - content_descriptor");
+ ELEMENT_CASE(55, "DVB - parental_rating_descriptor");
+ ELEMENT_CASE(56, "DVB - teletext_descriptor");
+ ELEMENT_CASE(57, "DVB - telephone_descriptor");
+ ELEMENT_CASE(58, "DVB - local_time_offset_descriptor");
+ ELEMENT_CASE(59, "DVB - subtitling_descriptor");
+ ELEMENT_CASE(5A, "DVB - terrestrial_delivery_system_descriptor");
+ ELEMENT_CASE(5B, "DVB - multilingual_network_name_descriptor");
+ ELEMENT_CASE(5C, "DVB - multilingual_bouquet_name_descriptor");
+ ELEMENT_CASE(5D, "DVB - multilingual_service_name_descriptor");
+ ELEMENT_CASE(5E, "DVB - multilingual_component_descriptor");
+ ELEMENT_CASE(5F, "DVB - private_data_specifier_descriptor");
+ ELEMENT_CASE(60, "DVB - service_move_descriptor");
+ ELEMENT_CASE(61, "DVB - short_smoothing_buffer_descriptor");
+ ELEMENT_CASE(62, "DVB - frequency_list_descriptor");
+ ELEMENT_CASE(63, "DVB - partial_transport_stream_descriptor");
+ ELEMENT_CASE(64, "DVB - data_broadcast_descriptor");
+ ELEMENT_CASE(65, "DVB - scrambling_descriptor");
+ ELEMENT_CASE(66, "DVB - data_broadcast_id_descriptor");
+ ELEMENT_CASE(67, "DVB - transport_stream_descriptor");
+ ELEMENT_CASE(68, "DVB - DSNG_descriptor");
+ ELEMENT_CASE(69, "DVB - PDC_descriptor");
+ ELEMENT_CASE(6A, "DVB - AC-3_descriptor");
+ ELEMENT_CASE(6B, "DVB - ancillary_data_descriptor");
+ ELEMENT_CASE(6C, "DVB - cell_list_descriptor");
+ ELEMENT_CASE(6D, "DVB - cell_frequency_link_descriptor");
+ ELEMENT_CASE(6E, "DVB - announcement_support_descriptor");
+ ELEMENT_CASE(6F, "DVB - application_signalling_descriptor");
+ ELEMENT_CASE(70, "DVB - adaptation_field_data_descriptor");
+ ELEMENT_CASE(71, "DVB - service_identifier_descriptor");
+ ELEMENT_CASE(72, "DVB - service_availability_descriptor");
+ ELEMENT_CASE(73, "DVB - default_authority_descriptor");
+ ELEMENT_CASE(74, "DVB - related_content_descriptor");
+ ELEMENT_CASE(75, "DVB - TVA_id_descriptor");
+ ELEMENT_CASE(76, "DVB - content_identifier_descriptor");
+ ELEMENT_CASE(77, "DVB - time_slice_fec_identifier_descriptor");
+ ELEMENT_CASE(78, "DVB - ECM_repetition_rate_descriptor");
+ ELEMENT_CASE(79, "DVB - S2_satellite_delivery_system_descriptor");
+ ELEMENT_CASE(7A, "DVB - enhanced_AC-3_descriptor");
+ ELEMENT_CASE(7B, "DVB - DTS descriptor");
+ ELEMENT_CASE(7C, "DVB - AAC descriptor");
+ ELEMENT_CASE(7D, "DVB - reserved for future use");
+ ELEMENT_CASE(7E, "DVB - reserved for future use");
+ ELEMENT_CASE(7F, "DVB - extension descriptor");
+ default: if (Element_Code>=0x40)
+ Element_Info1("user private");
+ else
+ Element_Info1("unknown");
+ Skip_XX(Element_Size, "Data");
+ break;
+ }
+ }
+ else if ((table_id>=0xC0 && table_id<0xE0))
+ {
+ switch (Element_Code)
+ {
+ ELEMENT_CASE(80, "ATSC - stuffing");
+ ELEMENT_CASE(81, "ATSC - AC-3 audio");
+ ELEMENT_CASE(86, "ATSC - caption service");
+ ELEMENT_CASE(87, "ATSC - content advisory");
+ ELEMENT_CASE(A0, "ATSC - extended channel name");
+ ELEMENT_CASE(A1, "ATSC - service location");
+ ELEMENT_CASE(A2, "ATSC - time-shifted service");
+ ELEMENT_CASE(A3, "ATSC - component name");
+ ELEMENT_CASE(A8, "ATSC - DCC Departing Request");
+ ELEMENT_CASE(A9, "ATSC - DCC Arriving Request");
+ ELEMENT_CASE(AA, "ATSC - Redistribution Control");
+ ELEMENT_CASE(AB, "ATSC - DCC Location Code");
+ default: if (Element_Code>=0x40)
+ Element_Info1("user private");
+ else
+ Element_Info1("unknown");
+ Skip_XX(Element_Size, "Data");
+ break;
+ }
+ }
+ else if (table_id==0xFC)
+ {
+ //SCTE 35
+ #undef ELEMENT_CASE
+ #define ELEMENT_CASE(_NAME, _DETAIL) \
+ case 0x##_NAME : Element_Name(_DETAIL); CUEI_##_NAME(); break;
+ switch (Element_Code)
+ {
+ ELEMENT_CASE(00, "SCTE35 - avail_descriptor");
+ ELEMENT_CASE(01, "SCTE35 - DTMF_descriptor");
+ ELEMENT_CASE(02, "SCTE35 - segmentation_descriptor");
+ default: Element_Info1("SCTE35 - Reserved");
+ Skip_XX(Element_Size, "Data");
+ break;
+ }
+ }
+ else
+ {
+ if (Element_Code>=0x40)
+ Element_Info1("user private");
+ else
+ Element_Info1("unknown");
+ Skip_XX(Element_Size, "Data");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_02()
+{
+ //Parsing
+ int8u frame_rate_code;
+ bool multiple_frame_rate_flag, MPEG_1_only_flag;
+ int8u profile_and_level_indication_profile=4, profile_and_level_indication_level=10, chroma_format=1;
+ bool frame_rate_extension_flag=false;
+ BS_Begin();
+ Get_SB ( multiple_frame_rate_flag, "multiple_frame_rate_flag");
+ Get_S1 (4, frame_rate_code, "frame_rate_code"); Param_Info1(Mpegv_frame_rate[frame_rate_code]);
+ Get_SB ( MPEG_1_only_flag, "MPEG_1_only_flag");
+ Skip_SB( "constrained_parameter_flag");
+ Skip_SB( "still_picture_flag");
+ if (MPEG_1_only_flag==0)
+ {
+ Skip_SB( "profile_and_level_indication_escape");
+ Get_S1 (3, profile_and_level_indication_profile, "profile_and_level_indication_profile"); Param_Info1(Mpegv_profile_and_level_indication_profile[profile_and_level_indication_profile]);
+ Get_S1 (4, profile_and_level_indication_level, "profile_and_level_indication_level"); Param_Info1(Mpegv_profile_and_level_indication_level[profile_and_level_indication_level]);
+ Get_S1 (2, chroma_format, "chroma_format"); Param_Info1(Mpegv_Colorimetry_format[chroma_format]);
+ Get_SB ( frame_rate_extension_flag, "frame_rate_extension_flag");
+ Skip_S1(5, "reserved");
+ }
+ BS_End();
+
+ //Filling
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ if (!multiple_frame_rate_flag && !frame_rate_extension_flag && frame_rate_code)
+ Complete_Stream->Streams[elementary_PID]->Infos["FrameRate"]=Ztring::ToZtring(Mpegv_frame_rate[frame_rate_code]);
+ Complete_Stream->Streams[elementary_PID]->Infos["Format_Version"]=MPEG_1_only_flag?_T("Version 1"):_T("Version 2");
+ Complete_Stream->Streams[elementary_PID]->Infos["Colorimetry"]=Mpegv_Colorimetry_format[chroma_format];
+ if (profile_and_level_indication_profile)
+ {
+ Complete_Stream->Streams[elementary_PID]->Infos["Format_Profile"]=Ztring().From_Local(Mpegv_profile_and_level_indication_profile[profile_and_level_indication_profile])+_T("@")+Ztring().From_Local(Mpegv_profile_and_level_indication_level[profile_and_level_indication_level]);
+ Complete_Stream->Streams[elementary_PID]->Infos["Codec_Profile"]=Ztring().From_Local(Mpegv_profile_and_level_indication_profile[profile_and_level_indication_profile])+_T("@")+Ztring().From_Local(Mpegv_profile_and_level_indication_level[profile_and_level_indication_level]);
+ }
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_03()
+{
+ //Parsing
+ int8u ID, layer;
+ bool variable_rate_audio_indicator;
+ BS_Begin();
+ Skip_SB( "free_format_flag");
+ Get_S1 (1, ID, "ID"); Param_Info1(Mpega_Version[2+ID]); //Mpega_Version is with MPEG2.5 hack
+ Get_S1 (2, layer, "layer"); Param_Info1(Mpega_Layer[layer]);
+ Get_SB ( variable_rate_audio_indicator, "variable_rate_audio_indicator");
+ Skip_S1(3, "reserved");
+ BS_End();
+
+ FILLING_BEGIN()
+ if (elementary_PID_IsValid)
+ {
+ Complete_Stream->Streams[elementary_PID]->Infos["BitRate_Mode"]=variable_rate_audio_indicator?_T("VBR"):_T("CBR");
+ Complete_Stream->Streams[elementary_PID]->Infos["Codec"]=Ztring(Mpega_Version[ID])+Ztring(Mpega_Layer[layer]);
+ Complete_Stream->Streams[elementary_PID]->Infos["Format"]=_T("MPEG Audio");
+ Complete_Stream->Streams[elementary_PID]->Infos["Format_Version"]=Mpega_Format_Profile_Version[ID];
+ Complete_Stream->Streams[elementary_PID]->Infos["Format_Profile"]=Mpega_Format_Profile_Layer[layer];
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_05()
+{
+ //Parsing
+ int32u format_identifier;
+ Get_B4 (format_identifier, "format_identifier"); Element_Info1(Mpeg_Descriptors_registration_format_identifier_Format(format_identifier)); Param_Info1(Mpeg_Descriptors_registration_format_identifier_Format(format_identifier));
+ if (Element_Size-Element_Offset>0)
+ Skip_XX(Element_Size-Element_Offset, "additional_identification_info");
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ switch (elementary_PID_IsValid)
+ {
+ case false : //Per program
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].registration_format_identifier=format_identifier;
+ break;
+ case true : //Per PES
+ Complete_Stream->Streams[elementary_PID]->registration_format_identifier=format_identifier;
+ if (format_identifier==Elements::KLVA)
+ {
+ if (!Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].Infos["KLVA_PID"].empty())
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].Infos["KLVA_PID"]+=_T(" / ");
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].Infos["KLVA_PID"]+=Ztring::ToZtring(elementary_PID);
+ }
+ //Coherency
+ if (stream_type==0x81 && Complete_Stream->Streams[elementary_PID]->registration_format_identifier==Elements::BSSD)
+ Complete_Stream->Streams[elementary_PID]->registration_format_identifier=0x00000000; //Reseting it, this combinaision is not possible but a stream has it
+ break;
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_06()
+{
+ //Parsing
+ Info_B1(alignment_type, "alignment_type"); Param_Info1(Mpeg_Descriptors_alignment_type(alignment_type));
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_07()
+{
+ //Parsing
+ BS_Begin();
+ Skip_S1(14, "horizontal_size");
+ Skip_S1(14, "vertical_size");
+ Skip_S1( 4, "aspect_ratio_information"); //Same as ISO/IEC 13818-2
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_08()
+{
+ //Parsing
+ BS_Begin();
+ Skip_S1(14, "horizontal_offset");
+ Skip_S1(14, "vertical_offset");
+ Skip_S1( 4, "window_priority");
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_09()
+{
+ //Parsing
+ int16u CA_system_ID, CA_PID;
+ Get_B2 (CA_system_ID, "CA_system_ID"); Param_Info1(Mpeg_Descriptors_CA_system_ID(CA_system_ID));
+ BS_Begin();
+ Skip_S1( 3, "reserved");
+ Get_S2 (13, CA_PID, "CA_PID");
+ BS_End();
+ if (Element_Size-Element_Offset>0)
+ Skip_XX(Element_Size-Element_Offset, "private_data_byte");
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x01 : //conditional_access_section
+ if (Complete_Stream->Streams[CA_PID]->Kind==complete_stream::stream::unknown) //Priority to PES, if this is a PES, we skip the CA
+ {
+ Complete_Stream->Streams[CA_PID]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[CA_PID]->Table_IDs.resize(0x100);
+ #ifdef MEDIAINFO_MPEGTS_ALLSTREAMS_YES
+ Complete_Stream->Streams[CA_PID]->Searching_Payload_Start_Set(true);
+ #endif
+ }
+ break;
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ if (Complete_Stream->Streams[CA_PID]->Kind==complete_stream::stream::unknown) //Priority to PES, if this is a PES, we skip the CA
+ {
+ Complete_Stream->Streams[CA_PID]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[CA_PID]->Table_IDs.resize(0x100);
+ #ifdef MEDIAINFO_MPEGTS_ALLSTREAMS_YES
+ Complete_Stream->Streams[CA_PID]->Searching_Payload_Start_Set(true);
+ #endif
+ }
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_0A()
+{
+ //Parsing
+ int32u ISO_639_language_code;
+ int8u audio_type;
+ Get_C3 (ISO_639_language_code, "ISO_639_language_code");
+ Get_B1 (audio_type, "audio_type"); Param_Info1(Mpeg_Descriptors_audio_type(audio_type));
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Ztring ISO_639_2;
+ if (ISO_639_language_code)
+ ISO_639_2.From_CC3(ISO_639_language_code);
+ const Ztring& ISO_639_1=MediaInfoLib::Config.Iso639_1_Get(ISO_639_2);
+ Complete_Stream->Streams[elementary_PID]->Infos["Language"]=ISO_639_1.empty()?ISO_639_2:ISO_639_1;
+ if (audio_type)
+ Complete_Stream->Streams[elementary_PID]->Infos["Language_More"]=Mpeg_Descriptors_audio_type(audio_type);
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_0B()
+{
+ //Parsing
+ int8u clock_accuracy_integer, clock_accuracy_exponent;
+ BS_Begin();
+ Skip_SB( "external_clock_reference_indicator");
+ Skip_SB( "reserved");
+ Get_S1 (6, clock_accuracy_integer, "clock_accuracy_integer");
+ Get_S1 (3, clock_accuracy_exponent, "clock_accuracy_exponent"); Param_Info1(Ztring::ToZtring(clock_accuracy_integer*(int64u)pow(10.0, clock_accuracy_exponent)));
+ Skip_S1(5, "reserved");
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_0D()
+{
+ //Parsing
+ int32u copyright_identifier;
+ Get_B4 (copyright_identifier, "copyright_identifier");
+ if ((copyright_identifier&0xFF000000)>=0x61000000 && (copyright_identifier&0xFF000000)<=0x7A000000
+ && (copyright_identifier&0x00FF0000)>=0x00610000 && (copyright_identifier&0x00FF0000)<=0x007A0000
+ && (copyright_identifier&0x0000FF00)>=0x00006100 && (copyright_identifier&0x0000FF00)<=0x00007A00
+ && (copyright_identifier&0x000000FF)>=0x00000061 && (copyright_identifier&0x000000FF)<=0x0000007A)
+ {
+ Param_Info1(Ztring().From_CC4(copyright_identifier));
+ Element_Info1(Ztring().From_CC4(copyright_identifier));
+ }
+ if (copyright_identifier==Elements::MANZ)
+ {
+ if (Element_Offset<Element_Size)
+ Skip_Local(Element_Size-Element_Offset, "Info");
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Infos["Encoded_Library"]=_T("Manzanita Systems");
+ }
+
+ if (Element_Offset<Element_Size)
+ Skip_Local(Element_Size-Element_Offset, "Info");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_0E()
+{
+ //Parsing
+ int32u maximum_bitrate;
+ BS_Begin();
+ Skip_S1( 2, "reserved");
+ Get_S3 (22, maximum_bitrate, "maximum_bitrate"); Param_Info2(maximum_bitrate*400, " bps");
+ BS_End();
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ Complete_Stream->Streams[elementary_PID]->Infos["BitRate_Maximum"]=Ztring::ToZtring(maximum_bitrate*400);
+ else
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].Infos["BitRate_Maximum"]=Ztring::ToZtring(maximum_bitrate*400);
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_0F()
+{
+ //Parsing
+ int32u private_data_indicator;
+ Get_B4 (private_data_indicator, "private_data_indicator");
+ if ((private_data_indicator&0xFF000000)>=0x41000000 && (private_data_indicator&0xFF000000)<=0x7A000000
+ && (private_data_indicator&0x00FF0000)>=0x00410000 && (private_data_indicator&0x00FF0000)<=0x007A0000
+ && (private_data_indicator&0x0000FF00)>=0x00004100 && (private_data_indicator&0x0000FF00)<=0x00007A00
+ && (private_data_indicator&0x000000FF)>=0x00000041 && (private_data_indicator&0x000000FF)<=0x0000007A)
+ {
+ Param_Info1(Ztring().From_CC4(private_data_indicator));
+ Element_Info1(Ztring().From_CC4(private_data_indicator));
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_10()
+{
+ //Parsing
+ BS_Begin();
+ Skip_S1( 2, "reserved");
+ Info_S3(22, sb_leak_rate, "sb_leak_rate"); Param_Info2(sb_leak_rate*400, " bps");
+ Skip_S1( 2, "reserved");
+ Info_S3(22, sb_size, "sb_size"); Param_Info2(sb_size, " bytes");
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_11()
+{
+ //Parsing
+ BS_Begin();
+ Skip_S1( 7, "reserved");
+ Skip_SB( "leak_valid_flag");
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_1C()
+{
+ //Parsing
+ int8u Profile_and_level;
+ Get_B1 ( Profile_and_level, "Profile_and_level"); Param_Info1(Mpeg_Descriptors_MPEG_4_audio_profile_and_level(Profile_and_level));
+
+ FILLING_BEGIN();
+ Complete_Stream->Streams[elementary_PID]->Infos["Format_Profile"]=Mpeg_Descriptors_MPEG_4_audio_profile_and_level(Profile_and_level);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_1D()
+{
+ //Parsing
+ int8u IOD_label;
+ Skip_B1( "Scope_of_IOD_label");
+ Get_B1 (IOD_label, "IOD_label");
+
+ #ifdef MEDIAINFO_MPEG4_YES
+ if (Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].IOD_ESs.find(IOD_label)==Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].IOD_ESs.end())
+ {
+ File_Mpeg4_Descriptors MI;
+ MI.Parser_DoNotFreeIt=true;
+ MI.SLConfig_DoNotFreeIt=true;
+ Open_Buffer_Init(&MI);
+ Open_Buffer_Continue(&MI);
+ Finish(&MI);
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].IOD_ESs[MI.ES_ID].Parser=MI.Parser;
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].IOD_ESs[MI.ES_ID].SLConfig=MI.SLConfig;
+ }
+ #else
+ Skip_XX(Element_Size-Element_Offset, "MPEG-4 Descriptor");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_1F()
+{
+ //Parsing
+ int16u ES_ID;
+ while (Element_Offset<Element_Size)
+ {
+ Element_Begin1("FlexMux");
+ Get_B2 (ES_ID, "ES_ID");
+ if (Element_Offset!=Element_Size)
+ Skip_B1( "FlexMuxChannel");
+ Element_End0();
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Complete_Stream->Streams[elementary_PID]->FMC_ES_ID=ES_ID;
+ Complete_Stream->Streams[elementary_PID]->FMC_ES_ID_IsValid=true;
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_28()
+{
+ //Parsing
+ int8u profile_idc, level_idc;
+ Get_B1 (profile_idc, "profile_idc"); Param_Info1(Avc_profile_idc(profile_idc));
+ BS_Begin();
+ Element_Begin1("constraints");
+ Skip_SB( "constraint_set0_flag");
+ Skip_SB( "constraint_set1_flag");
+ Skip_SB( "constraint_set2_flag");
+ Skip_SB( "constraint_set3_flag");
+ Skip_SB( "reserved_zero_4bits");
+ Skip_SB( "reserved_zero_4bits");
+ Skip_SB( "reserved_zero_4bits");
+ Skip_SB( "reserved_zero_4bits");
+ Element_End0();
+ BS_End();
+ Get_B1 (level_idc, "level_idc");
+ BS_Begin();
+ Skip_SB( "AVC_still_present");
+ Skip_SB( "AVC_24_hour_picture_flag");
+ Skip_S1(6, "reserved");
+ BS_End();
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Complete_Stream->Streams[elementary_PID]->Infos["Format"]=_T("AVC");
+ Complete_Stream->Streams[elementary_PID]->Infos["Format_Profile"]=Ztring().From_Local(Avc_profile_idc(profile_idc))+_T("@L")+Ztring().From_Number(((float)level_idc)/10, 1);
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_2A()
+{
+ //Parsing
+ BS_Begin();
+ Skip_SB( "hrd_management_valid_flag");
+ Skip_S1(6, "reserved");
+ TEST_SB_SKIP( "picture_and_timing_info_present");
+ bool x90kHz_flag;
+ Get_SB (x90kHz_flag, "90kHz_flag");
+ Skip_S1(7, "reserved");
+ BS_End();
+ if (x90kHz_flag)
+ {
+ Skip_B4( "N");
+ Skip_B4( "K");
+ }
+ Skip_B4( "num_units_in_tick");
+ BS_Begin();
+ TEST_SB_END();
+ Skip_SB( "fixed_frame_rate_flag");
+ Skip_SB( "temporal_poc_flag");
+ Skip_SB( "picture_to_display_conversion_flag");
+ Skip_S1(5, "reserved");
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_2F()
+{
+ //Parsing
+ int8u aux_video_params_length;
+ Skip_B1( "aux_video_type"); //ISO/IEC 23002-3
+ Get_B1 (aux_video_params_length, "aux_video_params_length");
+ Skip_XX(aux_video_params_length, "aux_video_params");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_40()
+{
+ //Parsing
+ Ztring network_name;
+ Get_DVB_Text(Element_Size, network_name, "network_name");
+
+ FILLING_BEGIN();
+ Complete_Stream->network_name=network_name;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_41()
+{
+ //Parsing
+ while (Element_Offset<Element_Size)
+ {
+ Element_Begin1("service");
+ int16u service_id;
+ int8u service_type;
+ Get_B2 (service_id, "service_id"); Element_Info1(Ztring::ToZtring(service_id, 16));
+ Get_B1 (service_type, "service_type"); Param_Info1(Mpeg_Descriptors_dvb_service_type(service_type));
+ Element_End1(Ztring::ToZtring(service_id));
+
+ FILLING_BEGIN();
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[service_id].Infos["ServiceType"]=Mpeg_Descriptors_dvb_service_type(service_type);
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_43()
+{
+ //Parsing
+ int32u frequency, symbol_rate;
+ int16u orbital_position;
+ int8u polarization, roll_off, modulation_type, FEC_inner;
+ bool west_east_flag, modulation_system;
+ Get_B4 (frequency, "frequency"); Param_Info1(Frequency_DVB__BCD(frequency));
+ Get_B2 (orbital_position, "orbital_position"); Param_Info1(OrbitalPosition_DVB__BCD(orbital_position));
+ BS_Begin();
+ Get_SB ( west_east_flag, "west_east_flag"); Param_Info1(west_east_flag?"E":"W");
+ Get_S1 ( 2, polarization, "polarization");
+ Get_S1 ( 2, roll_off, "roll_off");
+ Get_SB ( modulation_system, "modulation_system");
+ Get_S1 ( 2, modulation_type, "modulation_type");
+ Get_S4 (28, symbol_rate, "symbol_rate");
+ Get_S1 ( 4, FEC_inner, "FEC_inner");
+ BS_End();
+
+ FILLING_BEGIN();
+ Complete_Stream->Transport_Streams[transport_stream_id].Infos["Frequency"]=Frequency_DVB__BCD(frequency);
+ Complete_Stream->Transport_Streams[transport_stream_id].Infos["OrbitalPosition"]=OrbitalPosition_DVB__BCD(orbital_position)+(west_east_flag?_T('E'):_T('W'));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_48()
+{
+ //Parsing
+ Ztring service_provider_name, service_name;
+ int8u service_type, service_provider_name_length, service_name_length;
+ Get_B1 (service_type, "service_type"); Param_Info1(Mpeg_Descriptors_dvb_service_type(service_type));
+ Get_B1 (service_provider_name_length, "service_provider_name_length");
+ Get_DVB_Text(service_provider_name_length, service_provider_name, "service_provider_name");
+ Get_B1 (service_name_length, "service_name_length");
+ Get_DVB_Text(service_name_length, service_name, "service_name");
+
+ //Filling
+ FILLING_BEGIN();
+ if (program_number_IsValid)
+ {
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].Infos["ServiceName"]=service_name;
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].Infos["ServiceProvider"]=service_provider_name;
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].Infos["ServiceType"]=Mpeg_Descriptors_dvb_service_type(service_type);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_4A()
+{
+ //Parsing
+ int8u linkage_type;
+ Skip_B2( "transport_stream_id");
+ Info_B2(original_network_id, "original_network_id"); Param_Info1(Mpeg_Descriptors_original_network_id(original_network_id));
+ Skip_B2( "service_id");
+ Get_B1 (linkage_type, "linkage_type"); Param_Info1(Mpeg_Descriptors_linkage_type(linkage_type));
+ if (Element_Size>7)
+ Skip_XX(Element_Size-7, "private_data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_4D()
+{
+ //Parsing
+ Ztring event_name, text;
+ int32u ISO_639_language_code;
+ int8u event_name_length, text_length;
+ Get_C3 (ISO_639_language_code, "ISO_639_language_code");
+ Get_B1 (event_name_length, "event_name_length");
+ Get_DVB_Text(event_name_length, event_name, "event_name"); Element_Info1(event_name);
+ Get_B1 (text_length, "text_length");
+ Get_DVB_Text(text_length, text, "text");
+
+ FILLING_BEGIN();
+ if (table_id>=0x4E && table_id<=0x6F) //event_information_section
+ {
+ if (event_id_IsValid)
+ {
+ Ztring ISO_639_2; ISO_639_2.From_CC3(ISO_639_language_code);
+ const Ztring& ISO_639_1=MediaInfoLib::Config.Iso639_1_Get(ISO_639_2);
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks[table_id].Events[event_id].short_event.event_name=(ISO_639_1.empty()?ISO_639_2:ISO_639_1)+_T(':')+event_name;
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks[table_id].Events[event_id].short_event.text=(ISO_639_1.empty()?ISO_639_2:ISO_639_1)+_T(':')+text;
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks_IsUpdated=true;
+ Complete_Stream->Programs_IsUpdated=true;
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_50()
+{
+ //Parsing
+ int32u ISO_639_language_code;
+ int8u stream_content;
+ BS_Begin();
+ Skip_S1(4, "reserved_future_use");
+ Get_S1 (4, stream_content, "stream_content"); Param_Info1(Mpeg_Descriptors_stream_content(stream_content)); Element_Info1(Mpeg_Descriptors_stream_content(stream_content));
+ BS_End();
+ Info_B1(component_type, "component_type"); Param_Info1(Mpeg_Descriptors_component_type(stream_content, component_type)); Element_Info1(Mpeg_Descriptors_component_type(stream_content, component_type));
+ Info_B1(component_tag, "component_tag");
+ Get_C3 (ISO_639_language_code, "ISO_639_language_code");
+ Skip_DVB_Text(Element_Size-Element_Offset, "text");
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Ztring ISO_639_2; ISO_639_2.From_CC3(ISO_639_language_code);
+ const Ztring& ISO_639_1=MediaInfoLib::Config.Iso639_1_Get(ISO_639_2);
+ Complete_Stream->Streams[elementary_PID]->Infos["Language"]=ISO_639_1.empty()?ISO_639_2:ISO_639_1;
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_52()
+{
+ //Parsing
+ Skip_B1( "component_tag");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_54()
+{
+ //Parsing
+ while (Element_Offset<Element_Size)
+ {
+ BS_Begin();
+ int8u content_nibble_level_1, content_nibble_level_2;
+ Get_S1 (4, content_nibble_level_1, "content_nibble_level_1"); Param_Info1(Mpeg_Descriptors_content_nibble_level_1(content_nibble_level_1)); Element_Info1(Mpeg_Descriptors_content_nibble_level_1(content_nibble_level_1));
+ Get_S1 (4, content_nibble_level_2, "content_nibble_level_2"); Param_Info1(Mpeg_Descriptors_content_nibble_level_2(content_nibble_level_1, content_nibble_level_2)); Element_Info1C((content_nibble_level_1==0xB || content_nibble_level_2!=0), Mpeg_Descriptors_content_nibble_level_2(content_nibble_level_1, content_nibble_level_2));
+ Skip_S1(4, "user_nibble");
+ Skip_S1(4, "user_nibble");
+ BS_End();
+
+ FILLING_BEGIN();
+ if (event_id_IsValid)
+ {
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks[table_id].Events[event_id].content=Ztring().From_UTF8(Mpeg_Descriptors_content_nibble_level_2(content_nibble_level_1, content_nibble_level_2))+_T(", ");
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks_IsUpdated=true;
+ Complete_Stream->Programs_IsUpdated=true;
+ }
+ FILLING_END();
+ }
+
+ FILLING_BEGIN();
+ if (event_id_IsValid)
+ {
+ if (!Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks[table_id].Events[event_id].content.empty())
+ {
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks[table_id].Events[event_id].content.resize(Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks[table_id].Events[event_id].content.size()-2);
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks_IsUpdated=true;
+ Complete_Stream->Programs_IsUpdated=true;
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_55()
+{
+ //Parsing
+ while (Element_Offset<Element_Size)
+ {
+ Skip_Local(3, "country_code");
+ Info_B1(rating, "rating"); Param_Info2(rating+3, " years old"); Element_Info2(rating+3, " years old");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_56()
+{
+ //Parsing
+ Ztring Languages;
+ while (Element_Offset<Element_Size)
+ {
+ Element_Begin1("teletext");
+ Ztring ISO_639_language_code;
+ int8u teletext_type;
+ int8u teletext_magazine_number;
+ int8u teletext_page_number_1;
+ int8u teletext_page_number_2;
+ Get_Local(3, ISO_639_language_code, "ISO_639_language_code");
+ BS_Begin();
+ Get_S1 (5, teletext_type, "teletext_type"); Param_Info1(Mpeg_Descriptors_teletext_type(teletext_type));
+ Get_S1 (3, teletext_magazine_number, "teletext_magazine_number");
+ Get_S1 (4, teletext_page_number_1, "teletext_page_number_1");
+ Get_S1 (4, teletext_page_number_2, "teletext_page_number_2");
+ BS_End();
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid /*&& (teletext_type==2 || teletext_type==5)*/) //Subtitles are the only supported format
+ {
+ int16u ID=(teletext_magazine_number==0?8:teletext_magazine_number)*100+teletext_page_number_1*10+teletext_page_number_2;
+ Complete_Stream->Streams[elementary_PID]->descriptor_tag=0x56;
+ Complete_Stream->Streams[elementary_PID]->Teletexts[ID].Infos["Language"]=MediaInfoLib::Config.Iso639_1_Get(ISO_639_language_code);
+ Complete_Stream->Streams[elementary_PID]->Teletexts[ID].Infos["Format"]=Mpeg_Descriptors_teletext_type(teletext_type);
+ Complete_Stream->Streams[elementary_PID]->Teletexts[ID].Infos["Codec"]=Mpeg_Descriptors_teletext_type(teletext_type);
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_58()
+{
+ //Parsing
+ while (Element_Offset<Element_Size)
+ {
+ int32u country_code;
+ int16u local_time_offset;
+ int8u country_region_id;
+ bool local_time_offset_polarity;
+ Get_C3 (country_code, "country_code");
+ BS_Begin();
+ Get_S1 (6, country_region_id, "country_region_id");
+ Skip_SB( "reserved");
+ Get_SB (local_time_offset_polarity, "local_time_offset_polarity"); Param_Info1(local_time_offset_polarity?"-":"+");
+ BS_End();
+ Get_B2 (local_time_offset, "local_time_offset"); Param_Info1(TimeHHMM_BCD(local_time_offset));
+ Info_B2(date, "time_of_change (date)"); Param_Info1(Date_MJD(date));
+ Info_B3(time, "time_of_change (time)"); Param_Info1(Time_BCD(time));
+ Info_B2(next_time_offset, "next_time_offset"); Param_Info1(TimeHHMM_BCD(next_time_offset));
+
+ FILLING_BEGIN();
+ Ztring Country; Country.From_CC3(country_code);
+ if (country_region_id)
+ Country+=_T(" (")+Ztring::ToZtring(country_region_id)+_T(")");
+ Complete_Stream->TimeZones[Country]=(local_time_offset_polarity?_T('-'):_T('+'))+TimeHHMM_BCD(local_time_offset);
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_59()
+{
+ //Parsing
+ Ztring Languages;
+ while (Element_Offset<Element_Size)
+ {
+ Element_Begin1("subtitle");
+ int32u ISO_639_language_code;
+ Get_C3 (ISO_639_language_code, "ISO_639_language_code");
+ Info_B1(subtitling_type, "subtitling_type"); Param_Info1(Mpeg_Descriptors_component_type_O3(subtitling_type));
+ Skip_B2( "composition_page_id");
+ Skip_B2( "ancillary_page_id");
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Ztring ISO_639_2; ISO_639_2.From_CC3(ISO_639_language_code);
+ const Ztring& ISO_639_1=MediaInfoLib::Config.Iso639_1_Get(ISO_639_2);
+ Languages+=(ISO_639_1.empty()?ISO_639_2:ISO_639_1)+_T(" / ");
+ //TODO: this stream is teletext. Be careful, multiple stream in a pid
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+
+ Element_End0();
+ }
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Complete_Stream->Streams[elementary_PID]->StreamKind_FromDescriptor=Stream_Text;
+ Complete_Stream->Streams[elementary_PID]->descriptor_tag=0x59;
+ if (!Languages.empty())
+ Languages.resize(Languages.size()-3);
+ Complete_Stream->Streams[elementary_PID]->Infos["Language"]=Languages;
+ Complete_Stream->Streams[elementary_PID]->Infos["Format"]=_T("DVB Subtitle");
+ Complete_Stream->Streams[elementary_PID]->Infos["Codec"]=_T("DVB Subtitle");
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_5A()
+{
+ //Parsing
+ Info_B4(centre_frequency, "centre_frequency"); Param_Info2(((int64u)centre_frequency)*10, " Hz");
+ BS_Begin();
+ Info_S1(3, bandwidth, "bandwidth"); Param_Info1(Mpeg_Descriptors_bandwidth[bandwidth]);
+ Info_SB( priority, "priority"); Param_Info1(priority?"HP":"LP");
+ Skip_SB( "Time_Slicing_indicator");
+ Skip_SB( "MPE-FEC_indicator");
+ Skip_S1(2, "reserved");
+ Info_S1(2, constellation, "constellation"); Param_Info1(Mpeg_Descriptors_constellation[constellation]);
+ Info_S1(3, hierarchy_information, "hierarchy_information"); Param_Info1(Mpeg_Descriptors_hierarchy_information[hierarchy_information]);
+ Info_S1(3, code_rate_HP, "code_rate-HP_stream"); Param_Info1(Mpeg_Descriptors_code_rate[code_rate_HP]);
+ Info_S1(3, code_rate_LP, "code_rate-LP_stream"); Param_Info1(Mpeg_Descriptors_code_rate[code_rate_LP]);
+ Info_S1(2, guard_interval, "guard_interval"); Param_Info1(Mpeg_Descriptors_guard_interval[guard_interval]);
+ Info_S1(2, transmission_mode, "transmission_mode"); Param_Info1(Mpeg_Descriptors_transmission_mode[transmission_mode]);
+ Skip_SB( "other_frequency_flag");
+ BS_End();
+ Skip_B4( "reserved");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_5D()
+{
+ //Parsing
+ Ztring ServiceProvider, ServiceName;
+ while (Element_Offset<Element_Size)
+ {
+ Ztring service_provider_name, service_name;
+ int32u ISO_639_language_code;
+ int8u service_provider_name_length, service_name_length;
+ Get_C3 (ISO_639_language_code, "ISO_639_language_code");
+ Get_B1 (service_provider_name_length, "service_provider_name_length");
+ Get_DVB_Text(service_provider_name_length, service_provider_name, "service_provider_name");
+ Get_B1 (service_name_length, "service_name_length");
+ Get_DVB_Text(service_name_length, service_name, "service_name");
+
+ //Filling
+ FILLING_BEGIN();
+ Ztring ISO_639_2=Ztring().From_CC3(ISO_639_language_code);
+ const Ztring& ISO_639_1=MediaInfoLib::Config.Iso639_1_Get(ISO_639_2);
+ ServiceProvider+=(ISO_639_1.empty()?ISO_639_2:ISO_639_1)+_T(':')+service_provider_name+_T( " - ");
+ ServiceName+=(ISO_639_1.empty()?ISO_639_2:ISO_639_1)+_T(':')+service_name+_T( " - ");
+ FILLING_END();
+ }
+
+ if (!ServiceProvider.empty())
+ {
+ ServiceProvider.resize(ServiceProvider.size()-3);
+ if (program_number_IsValid)
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].Infos["ServiceProvider"]=ServiceProvider;
+ }
+ if (!ServiceName.empty())
+ {
+ ServiceName.resize(ServiceName.size()-3);
+ if (program_number_IsValid)
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].Infos["ServiceName"]=ServiceName;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_5F()
+{
+ //Parsing
+ Info_B4(private_data_specifier, "private_data_specifier"); Param_Info1(Ztring().From_CC4(private_data_specifier));
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_63()
+{
+ //Parsing
+ int32u peak_rate;
+ BS_Begin();
+ Skip_S1( 2, "DVB_reserved_future_use");
+ Get_S3 (22, peak_rate, "peak_rate");
+ Skip_S1( 2, "DVB_reserved_future_use");
+ Skip_S3(22, "minimum_overall_smoothing_rate");
+ Skip_S1( 2, "DVB_reserved_future_use");
+ Skip_S2(14, "maximum_overall_smoothing_buffer");
+ BS_End();
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ Complete_Stream->Streams[elementary_PID]->Infos["OverallBitRate_Maximum"]=Ztring::ToZtring(peak_rate*400);
+ break;
+ case 0x7F : //selection_information_section
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Infos["OverallBitRate_Maximum"]=Ztring::ToZtring(peak_rate*400);
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_66()
+{
+ //Parsing
+ Ztring ISO_639_language_code;
+ int8u selector_length, text_length;
+ Skip_B2( "data_broadcast_id");
+ Skip_B1( "component_tag");
+ Get_B1 (selector_length, "selector_length");
+ Skip_XX(selector_length, "selector_bytes");
+ Get_Local(3, ISO_639_language_code, "ISO_639_language_code");
+ Get_B1 (text_length, "text_length");
+ Skip_Local(text_length, "text_chars");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_6A()
+{
+ //Parsing
+ BS_Begin();
+ bool component_type_flag, bsid_flag, mainid_flag, asvc_flag, enhanced_ac3=false;
+ Get_SB ( component_type_flag, "component_type_flag");
+ Get_SB ( bsid_flag, "bsid_flag");
+ Get_SB ( mainid_flag, "mainid_flag");
+ Get_SB ( asvc_flag, "asvc_flag");
+ Skip_SB( "reserved_flag");
+ Skip_SB( "reserved_flag");
+ Skip_SB( "reserved_flag");
+ Skip_SB( "reserved_flag");
+ BS_End();
+ if (component_type_flag)
+ {
+ int8u service_type, number_of_channels;
+ BS_Begin();
+ Get_SB ( enhanced_ac3, "enhanced AC-3");
+ Skip_SB( "full_service");
+ Get_S1 (3, service_type, "service_type"); Param_Info1(AC3_Mode[service_type]);
+ Get_S1 (3, number_of_channels, "number_of_channels"); Param_Info2(Mpeg_Descriptors_AC3_Channels[number_of_channels], " channels");
+ BS_End();
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Complete_Stream->Streams[elementary_PID]->descriptor_tag=0x6A;
+ Complete_Stream->Streams[elementary_PID]->Infos["Channel(s)"]=Ztring().From_Local(Mpeg_Descriptors_AC3_Channels[number_of_channels]);
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+ }
+ if (bsid_flag)
+ {
+ BS_Begin();
+ Skip_S1(3, "zero");
+ Skip_S1(5, "bsid");
+ BS_End();
+ }
+ if (mainid_flag)
+ {
+ Skip_B1( "mainid");
+ }
+ if (asvc_flag)
+ {
+ Skip_B1( "asvc");
+ }
+
+ FILLING_BEGIN(); //Can be more
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Complete_Stream->Streams[elementary_PID]->StreamKind_FromDescriptor=Stream_Audio;
+ Complete_Stream->Streams[elementary_PID]->Infos["Format"]=enhanced_ac3?_T("E-AC-3"):_T("AC-3");
+ Complete_Stream->Streams[elementary_PID]->Infos["Codec"]=_T("AC3+");
+ if (Complete_Stream->Streams[elementary_PID]->registration_format_identifier==Elements::BSSD)
+ Complete_Stream->Streams[elementary_PID]->registration_format_identifier=0x00000000; //Reseting it, this combinaision is not possible but an stream has it
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_7A()
+{
+ //Parsing
+ bool component_type_flag, bsid_flag, mainid_flag, asvc_flag, mixinfoexists, substream1_flag, substream2_flag, substream3_flag, enhanced_ac3=0;
+ BS_Begin();
+ Get_SB ( component_type_flag, "component_type_flag");
+ Get_SB ( bsid_flag, "bsid_flag");
+ Get_SB ( mainid_flag, "mainid_flag");
+ Get_SB ( asvc_flag, "asvc_flag");
+ Get_SB ( mixinfoexists, "mixinfoexists");
+ Get_SB ( substream1_flag, "substream1_flag");
+ Get_SB ( substream2_flag, "substream2_flag");
+ Get_SB ( substream3_flag, "substream3_flag");
+ BS_End();
+ if (component_type_flag)
+ {
+ int8u service_type, number_of_channels;
+ BS_Begin();
+ Get_SB ( enhanced_ac3, "enhanced AC-3");
+ Skip_SB( "full_service");
+ Get_S1 (3, service_type, "service_type"); Param_Info1(AC3_Mode[service_type]);
+ Get_S1 (3, number_of_channels, "number_of_channels"); Param_Info2(Mpeg_Descriptors_AC3_Channels[number_of_channels], " channels");
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Complete_Stream->Streams[elementary_PID]->descriptor_tag=0x7A;
+ Complete_Stream->Streams[elementary_PID]->Infos["Channel(s)"]=Ztring().From_Local(Mpeg_Descriptors_AC3_Channels[number_of_channels]);
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+ BS_End();
+ }
+ if (bsid_flag)
+ {
+ BS_Begin();
+ Skip_S1(3, "zero");
+ Skip_S1(5, "bsid");
+ BS_End();
+ }
+ if (mainid_flag)
+ {
+ Skip_B1( "mainid");
+ }
+ if (asvc_flag)
+ {
+ Skip_B1( "asvc");
+ }
+ if (substream1_flag)
+ {
+ Skip_B1( "substream1");
+ }
+ if (substream2_flag)
+ {
+ Skip_B1( "substream2");
+ }
+ if (substream3_flag)
+ {
+ Skip_B1( "substream3");
+ }
+
+ FILLING_BEGIN(); //Can be more
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Complete_Stream->Streams[elementary_PID]->StreamKind_FromDescriptor=Stream_Audio;
+ Complete_Stream->Streams[elementary_PID]->Infos["Format"]=enhanced_ac3?_T("E-AC-3"):_T("AC-3");
+ Complete_Stream->Streams[elementary_PID]->Infos["Codec"]=_T("AC3+");
+ }
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_7B()
+{
+ //Parsing
+ BS_Begin();
+ Skip_S1(6, "bit_rate_code");
+ Skip_S2(7, "nblks");
+ Skip_S2(14, "fsize");
+ Skip_S1(6, "surround_mode");
+ Skip_SB( "lfe_flag");
+ Skip_S1(2, "extended_surround_flag");
+ BS_End();
+ //BS_End_CANBEMORE();
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Complete_Stream->Streams[elementary_PID]->descriptor_tag=0x7B;
+ }
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_7C()
+{
+ //Parsing
+ int8u Profile_and_level;
+ bool AAC_type_flag;
+ Get_B1 ( Profile_and_level, "Profile_and_level"); Param_Info1(Mpeg_Descriptors_MPEG_4_audio_profile_and_level(Profile_and_level));
+ BS_Begin();
+ Get_SB ( AAC_type_flag, "AAC_type_flag");
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ BS_End();
+ if (AAC_type_flag)
+ {
+ Skip_B1( "AAC_type");
+ }
+ if (Element_Size-Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Complete_Stream->Streams[elementary_PID]->descriptor_tag=0x7C;
+ Complete_Stream->Streams[elementary_PID]->Infos["Format_Profile"]=Mpeg_Descriptors_MPEG_4_audio_profile_and_level(Profile_and_level);
+ }
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_81()
+{
+ //Parsing
+ Ztring Text, Language1, Language2;
+ int8u sample_rate_code, bit_rate_code, surround_mode, bsmod, num_channels, langcod, textlen, text_code;
+ bool language_flag, language_flag_2;
+ BS_Begin();
+ Get_S1 (3, sample_rate_code, "sample_rate_code"); if (sample_rate_code<4) {Param_Info2(AC3_SamplingRate[sample_rate_code], " Hz");}
+ Skip_S1(5, "bsid");
+ Get_S1 (6, bit_rate_code, "bit_rate_code"); Param_Info2(AC3_BitRate[bit_rate_code]*1000, " Kbps");
+ Get_S1 (2, surround_mode, "surround_mode"); Param_Info1(AC3_Surround[surround_mode]);
+ Get_S1 (3, bsmod, "bsmod");
+ Get_S1 (4, num_channels, "num_channels"); if (num_channels<8) {Param_Info2(AC3_Channels[num_channels], " channels");}
+ Skip_SB( "full_svc");
+ BS_End();
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ {
+ Complete_Stream->Streams[elementary_PID]->descriptor_tag=0x81;
+ if (sample_rate_code<4)
+ Complete_Stream->Streams[elementary_PID]->Infos["SamplingRate"]=Ztring::ToZtring(AC3_SamplingRate[sample_rate_code]);
+ Complete_Stream->Streams[elementary_PID]->Infos["BitRate"]=Ztring::ToZtring(AC3_BitRate[bit_rate_code]*1000);
+ if (num_channels<8)
+ Complete_Stream->Streams[elementary_PID]->Infos["Channel(s)"]=Ztring::ToZtring(AC3_Channels[num_channels]);
+ }
+ }
+ FILLING_END();
+
+ //Parsing
+ if (Element_Offset==Element_Size) return;
+ Get_B1 (langcod, "langcod");
+
+ //Parsing
+ if (Element_Offset==Element_Size) return;
+ if (num_channels==0) //1+1 mode
+ Skip_B1( "langcod2");
+
+ //Parsing
+ if (Element_Offset==Element_Size) return;
+ if (bsmod<2)
+ {
+ BS_Begin();
+ Skip_S1(3, "mainid");
+ Info_BS(2, priority, "priority"); Param_Info1(Mpeg_Descriptors_AC3_Priority[priority]);
+ Skip_S1(3, "reserved");
+ BS_End();
+ }
+ else
+ Skip_B1( "asvcflags");
+
+ //Parsing
+ if (Element_Offset==Element_Size) return;
+ BS_Begin();
+ Get_S1 (7, textlen, "textlen");
+ Get_S1 (1, text_code, "text_code"); Param_Info1C((text_code), "Unicode");
+ BS_End();
+ if (textlen)
+ Get_Local(textlen, Text, "text");
+
+ //Parsing
+ if (Element_Offset==Element_Size) return;
+ BS_Begin();
+ Get_SB ( language_flag, "language_flag");
+ Get_SB ( language_flag_2, "language_flag_2");
+ Skip_S1(6, "reserved");
+ BS_End();
+
+ //Parsing
+ if (Element_Offset==Element_Size) return;
+ if (language_flag)
+ Get_Local(3, Language1, "language1");
+
+ //Parsing
+ if (Element_Offset==Element_Size) return;
+ if (language_flag_2)
+ Get_Local(3, Language2, "language2");
+
+ //Parsing
+ if (Element_Offset==Element_Size) return;
+ Skip_XX(Element_Size-Element_Offset, "additional_info");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_86()
+{
+ //Parsing
+ Ztring Text, Language1, Language2;
+ int8u number_of_services;
+ BS_Begin();
+ Skip_S1(3, "reserved");
+ Get_S1 (5, number_of_services, "number_of_services");
+ BS_End();
+
+ for (int8u Pos=0; Pos<number_of_services; Pos++)
+ {
+ Element_Begin1("service");
+ Ztring language;
+ int8u caption_service_number;
+ bool digital_cc;
+ Get_Local(3, language, "language");
+ BS_Begin();
+ Get_SB (digital_cc, "digital_cc");
+ Skip_SB( "reserved");
+ if (digital_cc) //line21
+ Get_S1 (6, caption_service_number, "caption_service_number");
+ else
+ {
+ bool line21_field;
+ Skip_S1(5, "reserved");
+ Get_SB ( line21_field, "line21_field");
+ caption_service_number=128+(line21_field?2:1);
+ }
+ Skip_SB( "easy_reader");
+ Skip_SB( "wide_aspect_ratio");
+ Skip_S2(14, "reserved");
+ BS_End();
+ Element_End0();
+
+ if (event_id_IsValid)
+ {
+ if (Complete_Stream->Sources[table_id_extension].ATSC_EPG_Blocks[Complete_Stream->Streams[pid]->table_type].Events[event_id].Languages[caption_service_number].empty()) //We use only the first detected value
+ Complete_Stream->Sources[table_id_extension].ATSC_EPG_Blocks[Complete_Stream->Streams[pid]->table_type].Events[event_id].Languages[caption_service_number]=language;
+ }
+ if (elementary_PID_IsValid)
+ {
+ if (Complete_Stream->Streams[elementary_PID]->Languages[caption_service_number].empty()) //We use only the first detected value
+ Complete_Stream->Streams[elementary_PID]->Languages[caption_service_number]=language;
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_87()
+{
+ //Parsing
+ int8u rating_region_count;
+ BS_Begin();
+ Skip_S1(2, "reserved");
+ Get_S1 (6, rating_region_count, "rating_region_count");
+ BS_End();
+ for (int8u rating_region_Pos=0; rating_region_Pos<rating_region_count; rating_region_Pos++)
+ {
+ Element_Begin1("rating_region");
+ int8u rated_dimensions;
+ Skip_B1( "rating_region");
+ Get_B1 (rated_dimensions, "rated_dimensions");
+ for (int8u rated_dimension_Pos=0; rated_dimension_Pos<rated_dimensions; rated_dimension_Pos++)
+ {
+ Element_Begin1("rated_dimension");
+ Skip_B1( "rating_dimension_j");
+ BS_Begin();
+ Skip_S1(4, "reserved");
+ Skip_S1(4, "rating_value");
+ BS_End();
+ Element_End0();
+ }
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_A0()
+{
+ //Parsing
+ Ztring title;
+ ATSC_multiple_string_structure(title, "title");
+
+ FILLING_BEGIN(); //Can be more
+ switch (table_id)
+ {
+ case 0xC8 : //TVCT
+ case 0xC9 : //CVCT
+ case 0xDA : //SVCT
+ if (program_number_IsValid)
+ if (!title.empty())
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].Infos["ServiceName"]=title;
+ break;
+ default : ;
+ }
+ FILLING_END();
+ FILLING_BEGIN();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_A1()
+{
+ //Parsing
+ int8u number_elements;
+ BS_Begin();
+ Skip_S1( 3, "reserved");
+ Skip_S2(13, "PCR_PID");
+ BS_End();
+ Get_B1 ( number_elements, "number_elements");
+ for (int8u Pos=0; Pos<number_elements; Pos++)
+ {
+ Element_Begin0();
+ Ztring Language;
+ int16u elementary_PID;
+ Skip_B1( "stream_type");
+ BS_Begin();
+ Skip_S1( 3, "reserved");
+ Get_S2 (13, elementary_PID, "elementary_PID");
+ BS_End();
+ Get_Local(3, Language, "ISO_639_language_code");
+ Element_End1(Ztring().From_CC2(elementary_PID));
+
+ //Filling
+ if (Complete_Stream->Streams[elementary_PID]->Infos["Language"].empty()) //We use only the first detected value
+ Complete_Stream->Streams[elementary_PID]->Infos["Language"]=Language;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_A3()
+{
+ //Parsing
+ Ztring Value;
+ ATSC_multiple_string_structure(Value, "name");
+
+ FILLING_BEGIN();
+ switch (table_id)
+ {
+ case 0x02 : //program_map_section
+ if (elementary_PID_IsValid)
+ if (!Value.empty())
+ Complete_Stream->Streams[elementary_PID]->Infos["Name"]=Value;
+ break;
+ default : ;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Descriptor_AA()
+{
+ //Parsing
+ Skip_XX(Element_Size, "rc_information");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::CUEI_00()
+{
+ Skip_C4( "identifier (\"CUEI\")"); //CUEI
+ Skip_B4( "provider_avail_id");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::CUEI_01()
+{
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::CUEI_02()
+{
+ //Parsing
+ int32u segmentation_event_id;
+ bool segmentation_event_cancel_indicator;
+ Skip_C4( "identifier (\"CUEI\")"); //CUEI
+ Get_B4 (segmentation_event_id, "segmentation_event_id");
+ BS_Begin();
+ Get_SB ( segmentation_event_cancel_indicator, "segmentation_event_cancel_indicator");
+ Skip_S1( 7, "reserved");
+ BS_End();
+ if (!segmentation_event_cancel_indicator)
+ {
+ int8u segmentation_upid_length, segmentation_type_id;
+ bool program_segmentation_flag, segmentation_duration_flag;
+ BS_Begin();
+ Get_SB ( program_segmentation_flag, "program_segmentation_flag");
+ Get_SB ( segmentation_duration_flag, "segmentation_duration_flag");
+ Skip_S1( 6, "reserved");
+ BS_End();
+ if (!program_segmentation_flag)
+ {
+ int8u component_count;
+ Get_B1 (component_count, "component_count");
+ for (int8u Pos=0; Pos<component_count; Pos++)
+ {
+ Skip_B1( "component_tag");
+ BS_Begin();
+ Skip_S1( 7, "reserved");
+ Skip_S5(33, "pts_offset");
+ BS_End();
+ }
+ }
+ if (segmentation_duration_flag)
+ {
+ Skip_B5( "segmentation_duration");
+ }
+ Skip_B1( "segmentation_upid_type");
+ Get_B1 (segmentation_upid_length, "segmentation_upid_length");
+ Skip_XX(segmentation_upid_length, "segmentation_upid"); //TODO
+ Get_B1 (segmentation_type_id, "segmentation_type_id");
+ Skip_B1( "segment_num");
+ Skip_B1( "segments_expected");
+
+ FILLING_BEGIN();
+ for (size_t Program_Pos=0; Program_Pos<Complete_Stream->Streams[pid]->program_numbers.size(); Program_Pos++)
+ {
+ complete_stream::transport_stream::program::scte35* Scte35=Complete_Stream->Transport_Streams[transport_stream_id].Programs[Complete_Stream->Streams[pid]->program_numbers[Program_Pos]].Scte35;
+ if (Scte35)
+ {
+ int8u Status=0; //Running
+ switch (segmentation_type_id)
+ {
+ case 0x11 : segmentation_type_id=0x10; Status=1; break; //Program Start/End
+ case 0x12 : segmentation_type_id=0x10; Status=2; break; //Program Start/Early Termination
+ case 0x14 : segmentation_type_id=0x13; Status=1; break; //Program Breakaway/Resumption
+ case 0x21 : segmentation_type_id=0x20; Status=1; break; //Chapter Start/End
+ case 0x31 : segmentation_type_id=0x30; Status=1; break; //Provider Advertisement Start/End
+ case 0x33 : segmentation_type_id=0x32; Status=1; break; //Distributor Advertisement Start/End
+ case 0x41 : segmentation_type_id=0x40; Status=1; break; //Unscheduled Event Start/End
+ default : ;
+ }
+
+ Scte35->Segmentations[segmentation_event_id].Segments[segmentation_type_id].Status=Status;
+ }
+ }
+ FILLING_END();
+ }
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::ATSC_multiple_string_structure(Ztring &Value, const char* Name)
+{
+ //Parsing
+ Ztring string;
+ int8u number_strings, number_segments;
+ Element_Begin1(Name);
+ Get_B1(number_strings, "number_strings");
+ for (int8u string_Pos=0; string_Pos<number_strings; string_Pos++)
+ {
+ Element_Begin1("String");
+ int32u ISO_639_language_code;
+ Get_C3(ISO_639_language_code, "ISO_639_language_code");
+ Get_B1(number_segments, "number_segments");
+ for (int8u segment_Pos=0; segment_Pos<number_segments; segment_Pos++)
+ {
+ Element_Begin1("Segment");
+ Ztring segment;
+ int8u compression_type, mode, number_bytes;
+ Get_B1 (compression_type, "compression_type");
+ Get_B1 (mode, "mode");
+ Get_B1 (number_bytes, "number_bytes");
+ switch (compression_type)
+ {
+ case 0x00 :
+ switch (mode)
+ {
+ case 0x00 : Get_Local(number_bytes, segment, "string"); break;
+ case 0x3F : Get_UTF16B(number_bytes, segment, "string"); break;
+ default : Skip_XX(number_bytes, "Unknown");
+ segment=_T("(Encoded with mode=0x")+Ztring::ToZtring(mode, 16)+_T(')');
+ }
+ break;
+ default : Skip_XX(number_bytes, "(Compressed)");
+ segment=_T("(Compressed)");
+ }
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (segment.find_first_not_of(_T("\t\n "))!=std::string::npos)
+ string+=segment+_T(" - ");
+ FILLING_END();
+ }
+
+ FILLING_BEGIN();
+ if (!string.empty())
+ string.resize(string.size()-3);
+ Ztring ISO_639_2=Ztring().From_CC3(ISO_639_language_code);
+ const Ztring& ISO_639_1=MediaInfoLib::Config.Iso639_1_Get(ISO_639_2);
+ Value+=(ISO_639_1.empty()?ISO_639_2:ISO_639_1)+_T(':')+string+_T(" - ");
+ FILLING_END();
+
+ Element_Info1(string);
+ Element_End1("String");
+ }
+
+ if (!Value.empty())
+ Value.resize(Value.size()-3);
+
+ Element_Info1(Value);
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Descriptors::Get_DVB_Text(int64u Size, Ztring &Value, const char* Info)
+{
+ if (Size<1)
+ {
+ Get_Local(Size, Value, Info);
+ return;
+ }
+
+ //Testing if there is a codepage
+ int8u CodePage1;
+ Peek_B1(CodePage1);
+ if (CodePage1<0x20)
+ {
+ Skip_B1( "CodePage"); Param_Info1(Mpeg_Descriptors_codepage_1(CodePage1));
+ if (CodePage1!=0x10)
+ {
+ Get_Local(Size-1, Value, Info);
+ }
+ else
+ {
+ if (Size<3)
+ {
+ Value.clear();
+ return;
+ }
+ int16u CodePage2;
+ Get_B2 (CodePage2, "CodePage2");
+ if (CodePage2==0x02)
+ {
+ Get_ISO_8859_2(Size-3, Value, Info);
+ }
+ else //Unknown
+ Get_Local(Size-3, Value, Info);
+ }
+
+ }
+ else
+ Get_Local(Size, Value, Info);
+}
+
+//---------------------------------------------------------------------------
+//Modified Julian Date
+Ztring File_Mpeg_Descriptors::Date_MJD(int16u Date_)
+{
+ //Calculating
+ float64 Date=Date_;
+ int Y2=(int)((Date-15078.2)/365.25);
+ int M2=(int)(((Date-14956.1) - ((int)(Y2*365.25))) /30.6001);
+ int D =(int)(Date-14956 - ((int)(Y2*365.25)) - ((int)(M2*30.6001)));
+ int K=0;
+ if (M2==14 || M2==15)
+ K=1;
+ int Y =Y2+K;
+ int M =M2-1-K*12;
+
+ //Formating
+ return Ztring::ToZtring(1900+Y)+_T("-")
+ + (M<10?_T("0"):_T(""))+Ztring::ToZtring( M)+_T("-")
+ + (D<10?_T("0"):_T(""))+Ztring::ToZtring( D);
+}
+
+//---------------------------------------------------------------------------
+//Form: HHMMSS, BCD
+Ztring File_Mpeg_Descriptors::Time_BCD(int32u Time)
+{
+ return (((Time>>16)&0xFF)<10?_T("0"):_T("")) + Ztring::ToZtring((Time>>16)&0xFF, 16)+_T(":") //BCD
+ + (((Time>> 8)&0xFF)<10?_T("0"):_T("")) + Ztring::ToZtring((Time>> 8)&0xFF, 16)+_T(":") //BCD
+ + (((Time )&0xFF)<10?_T("0"):_T("")) + Ztring::ToZtring((Time )&0xFF, 16); //BCD
+}
+
+//---------------------------------------------------------------------------
+//Form: HHMM, BCD
+Ztring File_Mpeg_Descriptors::TimeHHMM_BCD(int16u Time)
+{
+ return (((Time>> 8)&0xFF)<10?_T("0"):_T("")) + Ztring::ToZtring((Time>> 8)&0xFF, 16)+_T(":") //BCD
+ + (((Time )&0xFF)<10?_T("0"):_T("")) + Ztring::ToZtring((Time )&0xFF, 16)+_T(":00"); //BCD
+}
+
+//---------------------------------------------------------------------------
+//Form: Frequency in 10 KHz
+Ztring File_Mpeg_Descriptors::Frequency_DVB__BCD(int32u Frequency)
+{
+ int64u ToReturn=((((int64u)Frequency)>>28)&0xF)*10000000
+ + ((((int64u)Frequency)>>24)&0xF)* 1000000
+ + ((((int64u)Frequency)>>20)&0xF)* 100000
+ + ((((int64u)Frequency)>>16)&0xF)* 10000
+ + ((((int64u)Frequency)>>12)&0xF)* 1000
+ + ((((int64u)Frequency)>> 8)&0xF)* 100
+ + ((((int64u)Frequency)>> 4)&0xF)* 10
+ + ((((int64u)Frequency) )&0xF)* 1;
+ return Ztring::ToZtring(ToReturn*10000);
+}
+
+//---------------------------------------------------------------------------
+//Form: Orbital Position
+Ztring File_Mpeg_Descriptors::OrbitalPosition_DVB__BCD(int32u OrbitalPosition)
+{
+ int64u ToReturn=((OrbitalPosition>>12)&0xF)* 1000
+ + ((OrbitalPosition>> 8)&0xF)* 100
+ + ((OrbitalPosition>> 4)&0xF)* 10
+ + ((OrbitalPosition )&0xF) ;
+ return Ztring::ToZtring(((float)ToReturn)/10, 1);
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPEGTS_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Descriptors.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Descriptors.h
new file mode 100644
index 000000000..b931ab0b8
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Descriptors.h
@@ -0,0 +1,666 @@
+// File_Mpeg_Descriptors - Info for MPEG files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MPEG files, Descriptors
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Mpeg_DescriptorsH
+#define MediaInfo_Mpeg_DescriptorsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Multiple/File_Mpeg4_Descriptors.h"
+#include "MediaInfo/Duplicate/File__Duplicate_MpegTs.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Global object
+//***************************************************************************
+
+struct complete_stream
+{
+ //Global
+ int16u transport_stream_id; //The processed transport_stream_id
+ bool transport_stream_id_IsValid; //The processed transport_stream_id
+ Ztring original_network_name;
+ Ztring network_name;
+ Ztring Duration_Start;
+ Ztring Duration_End;
+ bool Duration_End_IsUpdated;
+ std::map<Ztring, Ztring> TimeZones; //Key is country code
+
+ //Per transport_stream
+ struct transport_stream
+ {
+ bool HasChanged;
+ std::map<std::string, Ztring> Infos;
+ struct program
+ {
+ bool HasChanged;
+ std::map<std::string, Ztring> Infos;
+ std::map<Ztring, Ztring> EPGs;
+ std::vector<int16u> elementary_PIDs;
+ size_t StreamPos; //Stream_Menu
+ int32u registration_format_identifier;
+ int16u pid;
+ int16u PCR_PID;
+ int16u source_id; //ATSC
+ bool source_id_IsValid;
+ bool IsParsed;
+ bool IsRegistered;
+ bool Update_Needed_IsRegistered;
+ bool Update_Needed_StreamCount;
+ bool Update_Needed_StreamPos;
+ bool Update_Needed_Info;
+
+ //DVB
+ struct dvb_epg_block
+ {
+ struct event
+ {
+ Ztring start_time;
+ Ztring duration;
+ struct short_event_
+ {
+ Ztring event_name;
+ Ztring text;
+ };
+ short_event_ short_event;
+ Ztring content;
+ Ztring running_status;
+ };
+
+ typedef std::map<int16u, event> events; //Key is event_id
+ events Events; //Key is event_id
+ };
+ typedef std::map<int8u, dvb_epg_block> dvb_epg_blocks; //Key is table_id
+ dvb_epg_blocks DVB_EPG_Blocks; //Key is table_id
+ bool DVB_EPG_Blocks_IsUpdated;
+
+ //SCTE 35
+ struct scte35
+ {
+ struct segmentation
+ {
+ struct segment
+ {
+ int8u Status; //If it is currently in the program: 0=Running, 1=Ended, 2=Early termination
+
+ segment()
+ {
+ Status=(int8u)-1;
+ }
+ };
+
+ typedef std::map<int8u, segment> segments; //Key is segmentation_type_id
+ segments Segments;
+ ;
+ };
+
+ typedef std::map<int32u, segmentation> segmentations; //Key is segmentation_event_id
+ segmentations Segmentations;
+ int16u pid;
+
+ scte35()
+ {
+ pid=(int16u)-1;
+ }
+ };
+ scte35* Scte35;
+
+ //Constructor/Destructor
+ program()
+ {
+ HasChanged=false;
+ StreamPos=(size_t)-1;
+ registration_format_identifier=0x00000000;
+ pid=0x00000;
+ PCR_PID=0x0000;
+ source_id=(int16u)-1;
+ source_id_IsValid=false;
+ IsParsed=false;
+ IsRegistered=false;
+ Update_Needed_IsRegistered=false;
+ Update_Needed_StreamCount=false;
+ Update_Needed_StreamPos=false;
+ Update_Needed_Info=false;
+ DVB_EPG_Blocks_IsUpdated=false;
+ Scte35=NULL;
+ }
+ };
+ typedef std::map<int16u, program> programs; //Key is program_number
+ programs Programs; //Key is program_number
+ size_t Programs_NotParsedCount;
+
+ //Per IOD
+ struct iod_es
+ {
+ File__Analyze* Parser;
+ #ifdef MEDIAINFO_MPEG4_YES
+ File_Mpeg4_Descriptors::slconfig* SLConfig;
+ #endif
+
+ //Constructor/Destructor
+ iod_es()
+ {
+ Parser=NULL;
+ #ifdef MEDIAINFO_MPEG4_YES
+ SLConfig=NULL;
+ #endif
+ }
+
+ ~iod_es()
+ {
+ delete Parser; //Parser=NULL;
+ #ifdef MEDIAINFO_MPEG4_YES
+ delete SLConfig; //SLConfig=NULL;
+ #endif
+ }
+ };
+ typedef std::map<int16u, iod_es> iod_ess; //Key is ES_ID
+ std::map<int16u, iod_es> IOD_ESs; //Key is ES_ID
+
+ //ATSC
+ int16u source_id; //Global
+ int16u source_id_IsValid;
+
+ transport_stream()
+ {
+ HasChanged=false;
+ source_id=(int16u)-1;
+ source_id_IsValid=false;
+ Programs_NotParsedCount=(size_t)-1;
+ }
+ };
+ typedef std::map<int16u, transport_stream> transport_streams; //Key is transport_stream_id
+ transport_streams Transport_Streams; //Key is transport_stream_id
+
+ //Per pid
+ struct stream
+ {
+ File__Analyze* Parser;
+
+ enum ts_kind
+ {
+ //MPEG
+ unknown,
+ pes,
+ psi,
+ ts_kind_Max,
+ };
+ std::vector<int16u> program_numbers;
+ struct table_id
+ {
+ struct table_id_extension
+ {
+ typedef std::vector<bool> section_numbers; //Key is section_number
+ section_numbers Section_Numbers; //Key is section_number
+ int8u version_number;
+ };
+ typedef std::map<int16u, table_id_extension> table_id_extensions; //Key is table_id_extensions
+ table_id_extensions Table_ID_Extensions; //Key is table_id_extensions
+ bool Table_ID_Extensions_CanAdd;
+
+ table_id()
+ {
+ Table_ID_Extensions_CanAdd=true;
+ }
+ };
+ typedef std::vector<table_id*> table_ids;
+ table_ids Table_IDs; //Key is table_id
+ std::map<std::string, Ztring> Infos;
+ std::map<int8u, Ztring> Languages; //Key is caption_service_number or 128+line21_field
+ struct teletext
+ {
+ std::map<std::string, Ztring> Infos;
+ };
+ std::map<int16u, teletext> Teletexts; //Key is teletext_magazine_number
+ #if MEDIAINFO_TRACE
+ Ztring Element_Info1;
+ #endif //MEDIAINFO_TRACE
+ stream_t StreamKind;
+ stream_t StreamKind_FromDescriptor;
+ size_t StreamPos;
+ ts_kind Kind;
+ bool IsParsed;
+ bool IsPCR;
+ float64 IsPCR_Duration;
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ int64u TimeStamp_Start;
+ int64u TimeStamp_Start_Offset;
+ int64u TimeStamp_End;
+ int64u TimeStamp_End_Offset;
+ int16u PCR_PID; //If this pid has no PCR, decide which PCR should be used
+ bool TimeStamp_End_IsUpdated;
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ int32u registration_format_identifier;
+ int16u FMC_ES_ID;
+ int16u table_type; //ATSC
+ int8u stream_type;
+ int8u descriptor_tag;
+ bool FMC_ES_ID_IsValid;
+ bool Searching;
+ bool Searching_Payload_Start;
+ bool Searching_Payload_Continue;
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ bool Searching_TimeStamp_Start;
+ bool Searching_TimeStamp_End;
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ bool Searching_ParserTimeStamp_Start;
+ bool Searching_ParserTimeStamp_End;
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ bool EndTimeStampMoreThanxSeconds;
+ bool ShouldDuplicate;
+ bool IsRegistered;
+ bool IsUpdated_IsRegistered;
+ bool IsUpdated_Info;
+ size_t IsScrambled;
+ int16u SubStream_pid;
+ #if MEDIAINFO_IBI
+ int64u Ibi_SynchronizationOffset_BeginOfFrame;
+ #endif //MEDIAINFO_IBI
+
+ //Constructor/Destructor
+ stream()
+ {
+ Parser=NULL;
+ StreamKind=Stream_Max;
+ StreamKind_FromDescriptor=Stream_Max;
+ StreamPos=(size_t)-1;
+ Kind=unknown;
+ IsParsed=false;
+ IsPCR=false;
+ IsPCR_Duration=0;
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ TimeStamp_Start=(int64u)-1;
+ TimeStamp_Start_Offset=(int64u)-1;
+ TimeStamp_End=(int64u)-1;
+ TimeStamp_End_Offset=(int64u)-1;
+ PCR_PID=0x0000;
+ TimeStamp_End_IsUpdated=false;
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ registration_format_identifier=0x00000000;
+ FMC_ES_ID=0x0000;
+ table_type=0x0000;
+ stream_type=(int8u)-1;
+ descriptor_tag=(int8u)-1;
+ FMC_ES_ID_IsValid=false;
+ Searching=false;
+ Searching_Payload_Start=false;
+ Searching_Payload_Continue=false;
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ Searching_TimeStamp_Start=false;
+ Searching_TimeStamp_End=false;
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ Searching_ParserTimeStamp_Start=false;
+ Searching_ParserTimeStamp_End=false;
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ EndTimeStampMoreThanxSeconds=false;
+ ShouldDuplicate=false;
+ IsRegistered=false;
+ IsUpdated_IsRegistered=false;
+ IsUpdated_Info=false;
+ IsScrambled=false;
+ SubStream_pid=0x0000;
+ #if MEDIAINFO_IBI
+ Ibi_SynchronizationOffset_BeginOfFrame=(int64u)-1;
+ #endif //MEDIAINFO_IBI
+ }
+
+ ~stream()
+ {
+ delete Parser; //Parser=NULL;
+ for (size_t Pos=0; Pos<Table_IDs.size(); Pos++)
+ delete Table_IDs[Pos]; //Table_IDs[Pos]=NULL;
+ }
+
+ //Helpers
+ void Searching_Payload_Start_Set(bool ToSet)
+ {
+ Searching_Payload_Start=ToSet;
+ Searching_Test();
+ }
+ void Searching_Payload_Continue_Set(bool ToSet)
+ {
+ Searching_Payload_Continue=ToSet;
+ Searching_Test();
+ }
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ void Searching_TimeStamp_Start_Set(bool ToSet)
+ {
+ Searching_TimeStamp_Start=ToSet;
+ Searching_Test();
+ }
+ void Searching_TimeStamp_End_Set(bool ToSet)
+ {
+ Searching_TimeStamp_End=ToSet;
+ Searching_Test();
+ }
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ void Searching_ParserTimeStamp_Start_Set(bool ToSet)
+ {
+ Searching_ParserTimeStamp_Start=ToSet;
+ Searching_Test();
+ }
+ void Searching_ParserTimeStamp_End_Set(bool ToSet)
+ {
+ Searching_ParserTimeStamp_End=ToSet;
+ Searching_Test();
+ }
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ void Searching_Test()
+ {
+ Searching=Searching_Payload_Start
+ | Searching_Payload_Continue
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ | Searching_TimeStamp_Start
+ | Searching_TimeStamp_End
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ | Searching_ParserTimeStamp_Start
+ | Searching_ParserTimeStamp_End
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ ;
+ }
+ };
+ typedef std::vector<stream*> streams;
+ streams Streams; //Key is pid
+ size_t Streams_NotParsedCount;
+ size_t Streams_With_StartTimeStampCount;
+ size_t Streams_With_EndTimeStampMoreThanxSecondsCount;
+
+ //ATSC
+ int8u GPS_UTC_offset;
+ struct source
+ {
+ std::map<int16u, Ztring> texts;
+ struct atsc_epg_block
+ {
+ struct event
+ {
+ int32u start_time;
+ Ztring duration;
+ Ztring title;
+ std::map<int8u, Ztring> Languages; //Key is caption_service_number or 128+line21_field
+ std::map<int16u, Ztring> texts;
+
+ event()
+ {
+ start_time=(int32u)-1;
+ }
+ };
+
+ typedef std::map<int16u, event> events; //Key is event_id
+ events Events; //Key is event_id
+ };
+ typedef std::map<int16u, atsc_epg_block> atsc_epg_blocks; //Key is table_id
+ atsc_epg_blocks ATSC_EPG_Blocks; //Key is table_id
+ bool ATSC_EPG_Blocks_IsUpdated;
+
+ source()
+ {
+ ATSC_EPG_Blocks_IsUpdated=false;
+ }
+ };
+ typedef std::map<int16u, source> sources; //Key is source_id
+ sources Sources; //Key is source_id
+ bool Sources_IsUpdated; //For EPG ATSC
+ bool Programs_IsUpdated; //For EPG DVB
+ bool NoPatPmt;
+
+ //File__Duplicate
+ bool File__Duplicate_HasChanged_;
+ size_t Config_File_Duplicate_Get_AlwaysNeeded_Count;
+ std::vector<File__Duplicate_MpegTs*> Duplicates_Speed;
+ std::vector<std::vector<File__Duplicate_MpegTs*> > Duplicates_Speed_FromPID;
+ std::map<const String, File__Duplicate_MpegTs*> Duplicates;
+ bool File__Duplicate_Get_From_PID (int16u pid)
+ {
+ if (Duplicates_Speed_FromPID.empty())
+ return false;
+ return !Duplicates_Speed_FromPID[pid].empty();
+ }
+
+ //SpeedUp information
+ std::vector<std::vector<size_t> > StreamPos_ToRemove;
+ std::map<int16u, int16u> PCR_PIDs; //Key is PCR_PID, value is count of programs using it
+ std::set<int16u> PES_PIDs; //Key is pid
+ std::vector<int16u> program_number_Order;
+
+ //Constructor/Destructor
+ complete_stream()
+ {
+ transport_stream_id=(int16u)-1;
+ transport_stream_id_IsValid=false;
+ Duration_End_IsUpdated=false;
+ Streams_NotParsedCount=(size_t)-1;
+ Streams_With_StartTimeStampCount=0;
+ Streams_With_EndTimeStampMoreThanxSecondsCount=0;
+ GPS_UTC_offset=0;
+ Sources_IsUpdated=false;
+ Programs_IsUpdated=false;
+ NoPatPmt=false;
+ StreamPos_ToRemove.resize(Stream_Max);
+ }
+
+ ~complete_stream()
+ {
+ for (size_t StreamID=0; StreamID<Streams.size(); StreamID++)
+ delete Streams[StreamID]; //Streams[StreamID]=NULL;
+
+ std::map<const String, File__Duplicate_MpegTs*>::iterator Duplicates_Temp=Duplicates.begin();
+ while (Duplicates_Temp!=Duplicates.end())
+ {
+ delete Duplicates_Temp->second; //Duplicates_Temp->second=NULL
+ Duplicates_Temp++;
+ }
+ }
+};
+
+//***************************************************************************
+// Class File_Mpeg_Descriptors
+//***************************************************************************
+
+class File_Mpeg_Descriptors : public File__Analyze
+{
+public :
+ //In
+ complete_stream* Complete_Stream;
+ int16u transport_stream_id;
+ int16u pid;
+ int8u table_id;
+ int16u table_id_extension;
+ int16u elementary_PID;
+ int16u program_number;
+ int32u registration_format_identifier;
+ int8u stream_type;
+ int16u event_id;
+ bool elementary_PID_IsValid;
+ bool program_number_IsValid;
+ bool registration_format_identifier_IsValid;
+ bool stream_type_IsValid;
+ bool event_id_IsValid;
+
+ //Out
+
+ //Constructor/Destructor
+ File_Mpeg_Descriptors();
+
+private :
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Descriptors();
+ void Descriptor();
+ void Descriptor_00() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_01() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_02();
+ void Descriptor_03();
+ void Descriptor_04() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_05();
+ void Descriptor_06();
+ void Descriptor_07();
+ void Descriptor_08();
+ void Descriptor_09();
+ void Descriptor_0A();
+ void Descriptor_0B();
+ void Descriptor_0C() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_0D();
+ void Descriptor_0E();
+ void Descriptor_0F();
+ void Descriptor_10();
+ void Descriptor_11();
+ void Descriptor_12() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_13() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_14() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_15() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_16() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_17() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_18() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_19() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_1A() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_1B() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_1C();
+ void Descriptor_1D();
+ void Descriptor_1E() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_1F();
+ void Descriptor_20() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_21() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_22() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_23() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_24() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_25() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_26() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_27() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_28();
+ void Descriptor_29() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_2A();
+ void Descriptor_2B() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_2C() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_2D() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_2E() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_2F();
+ void Descriptor_40();
+ void Descriptor_41();
+ void Descriptor_42() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_43();
+ void Descriptor_44() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_45() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_46() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_47() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_48();
+ void Descriptor_49() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_4A();
+ void Descriptor_4B() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_4C() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_4D();
+ void Descriptor_4E() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_4F() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_50();
+ void Descriptor_51() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_52();
+ void Descriptor_53() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_54();
+ void Descriptor_55();
+ void Descriptor_56();
+ void Descriptor_57() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_58();
+ void Descriptor_59();
+ void Descriptor_5A();
+ void Descriptor_5B() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_5C() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_5D();
+ void Descriptor_5E() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_5F();
+ void Descriptor_60() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_61() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_62() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_63();
+ void Descriptor_64() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_65() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_66();
+ void Descriptor_67() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_68() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_69() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_6A();
+ void Descriptor_6B() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_6C() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_6D() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_6E() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_6F() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_70() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_71() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_72() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_73() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_74() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_75() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_76() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_77() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_78() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_79() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_7A();
+ void Descriptor_7B();
+ void Descriptor_7C();
+ void Descriptor_7D() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_7E() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_7F() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_80() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_81();
+ void Descriptor_86();
+ void Descriptor_87();
+ void Descriptor_A0();
+ void Descriptor_A1();
+ void Descriptor_A2() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_A3();
+ void Descriptor_A8() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_A9() {Skip_XX(Element_Size, "Data");};
+ void Descriptor_AA();
+ void Descriptor_AB() {Skip_XX(Element_Size, "Data");};
+
+ //SCTE 35
+ void CUEI_00();
+ void CUEI_01();
+ void CUEI_02();
+
+ //Helpers
+ void ATSC_multiple_string_structure(Ztring &Value, const char* Info);
+ void Get_DVB_Text(int64u Size, Ztring &Value, const char* Info);
+ void Skip_DVB_Text(int64u Size, const char* Info) {Ztring Temp; Get_DVB_Text(Size, Temp, Info);};
+ Ztring Date_MJD(int16u Date);
+ Ztring Time_BCD(int32u Time);
+ Ztring TimeHHMM_BCD(int16u Time);
+ Ztring Frequency_DVB__BCD(int32u Frequency);
+ Ztring OrbitalPosition_DVB__BCD(int32u OrbitalPosition);
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Psi.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Psi.cpp
new file mode 100644
index 000000000..5320fc72d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Psi.cpp
@@ -0,0 +1,2608 @@
+// File_Mpeg_Psi - Info for MPEG Stream files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEGPS_YES) || defined(MEDIAINFO_MPEGTS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Mpeg_Psi.h"
+#include "MediaInfo/Multiple/File_Mpeg_Descriptors.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "ZenLib/Dir.h"
+#include <memory>
+#include <algorithm>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+namespace Elements
+{
+ const int32u CUEI=0x43554549; //SCTE
+ const int32u GA94=0x47413934; //ATSC - Terrestrial
+ const int32u HDMV=0x48444D56; //BluRay
+ const int32u S14A=0x53313441; //ATSC - Satellite
+ const int32u SCTE=0x53435445; //SCTE
+ const int32u TSHV=0x54534856; //TSHV
+}
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Psi_ATSC_table_type(int16u ID)
+{
+ switch (ID)
+ {
+ case 0x0000 : return "Terrestrial VCT with current_next_indicator=1";
+ case 0x0001 : return "Terrestrial VCT with current_next_indicator=0";
+ case 0x0002 : return "Cable VCT with current_next_indicator=1";
+ case 0x0003 : return "Cable VCT with current_next_indicator==0";
+ case 0x0004 : return "Channel ETT";
+ case 0x0005 : return "DCCSCT";
+ case 0x0010 : return "Short-form Virtual Channel Table-VCM Subtyp";
+ case 0x0011 : return "Short-form Virtual Channel Table-DCM Subtyp";
+ case 0x0012 : return "Short-form Virtual Channel Table-ICM Subtyp";
+ case 0x0020 : return "Network Information Table-CDS Table Subtype";
+ case 0x0021 : return "Network Information Table-MMS Table Subtype";
+ case 0x0030 : return "Network Text Tabl e-SNS Subtype";
+ default :
+ if (ID>=0x0100
+ && ID<=0x017F) return "Event Information Table (EIT)";
+ if (ID>=0x0200
+ && ID<=0x027F) return "Event Extended Text Table (EETT)";
+ if (ID>=0x0300
+ && ID<=0x03FF) return "Rating Region Table (RRT)";
+ if (ID>=0x0400
+ && ID<=0x0FFF) return "User private";
+ if (ID>=0x1000
+ && ID<=0x10FF) return "Aggregate Event Information Table (AEIT)";
+ if (ID>=0x1100
+ && ID<=0x11FF) return "Aggregate Extended Text Table (AETT)";
+ if (ID>=0x1400
+ && ID<=0x14FF) return "DCCT";
+ return "Reserved";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Psi_stream_type_Format(int8u stream_type, int32u format_identifier)
+{
+ switch (stream_type)
+ {
+ case 0x01 : return "MPEG Video"; //Version 1
+ case 0x02 : return "MPEG Video"; //Version 2
+ case 0x03 : return "MPEG Audio"; //Version 1
+ case 0x04 : return "MPEG Audio"; //Version 2
+ case 0x0F : return "AAC";
+ case 0x10 : return "MPEG-4 Visual";
+ case 0x11 : return "AAC";
+ case 0x1B : return "AVC";
+ case 0x1C : return "AAC";
+ case 0x1D : return "Timed Text";
+ case 0x1E : return "MPEG Video"; //ISO/IEC 23002-3
+ case 0x1F : return "AVC";
+ case 0x20 : return "AVC";
+ default :
+ switch (format_identifier)
+ {
+ case Elements::CUEI :
+ case Elements::SCTE : //SCTE
+ case Elements::GA94 :
+ case Elements::S14A : //ATSC
+ switch (stream_type)
+ {
+ case 0x80 : return "MPEG Video";
+ case 0x81 : return "AC-3";
+ case 0x82 : return "Text";
+ case 0x87 : return "E-AC-3";
+ default : return "";
+ }
+ case Elements::HDMV : //Bluray
+ switch (stream_type)
+ {
+ case 0x80 : return "PCM";
+ case 0x81 : return "AC-3";
+ case 0x82 : return "DTS";
+ case 0x83 : return "AC-3"; // (TrueHD)"
+ case 0x84 : return "E-AC-3";
+ case 0x85 : return "DTS"; //" (HD-HRA)"
+ case 0x86 : return "DTS"; //" (HD-MA)"
+ case 0x90 : return "PGS";
+ case 0xA1 : return "AC-3";
+ case 0xA2 : return "DTS";
+ case 0xEA : return "VC-1";
+ default : return "";
+ }
+ case 0xFFFFFFFF : //Unknown
+ return "";
+ default :
+ switch (stream_type)
+ {
+ case 0x80 : return "MPEG Video";
+ case 0x81 : return "AC-3";
+ case 0x87 : return "E-AC-3";
+ case 0x88 : return "VC-1";
+ case 0xD1 : return "Dirac";
+ default : return "";
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Psi_stream_type_Codec(int8u stream_type, int32u format_identifier)
+{
+ switch (stream_type)
+ {
+ case 0x01 : return "MPEG-1V";
+ case 0x02 : return "MPEG-2V";
+ case 0x03 : return "MPEG-1A";
+ case 0x04 : return "MPEG-2A";
+ case 0x0F : return "AAC";
+ case 0x10 : return "MPEG-4V";
+ case 0x11 : return "AAC";
+ case 0x1B : return "AVC";
+ case 0x1C : return "AAC";
+ case 0x1D : return "Text";
+ case 0x1E : return "MPEG-2V";
+ case 0x1F : return "AVC";
+ case 0x20 : return "AVC";
+ default :
+ switch (format_identifier)
+ {
+ case Elements::CUEI :
+ case Elements::SCTE : //SCTE
+ case Elements::GA94 :
+ case Elements::S14A : //ATSC
+ switch (stream_type)
+ {
+ case 0x80 : return "MPEG-2V";
+ case 0x81 : return "AC3";
+ case 0x82 : return "Text";
+ case 0x87 : return "AC3+";
+ default : return "";
+ }
+ case Elements::HDMV : //Bluray
+ switch (stream_type)
+ {
+ case 0x80 : return "PCM";
+ case 0x81 : return "AC3";
+ case 0x82 : return "DTS";
+ case 0x83 : return "AC3+";
+ case 0x86 : return "DTS";
+ case 0x90 : return "PGS";
+ case 0xEA : return "VC1";
+ default : return "";
+ }
+ case 0xFFFFFFFF : //Unknown
+ return "";
+ default :
+ switch (stream_type)
+ {
+ case 0x80 : return "MPEG-2V";
+ case 0x81 : return "AC3";
+ case 0x87 : return "AC3+";
+ case 0x88 : return "VC-1";
+ case 0xD1 : return "Dirac";
+ default : return "";
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+stream_t Mpeg_Psi_stream_type_StreamKind(int32u stream_type, int32u format_identifier)
+{
+ switch (stream_type)
+ {
+ case 0x01 : return Stream_Video;
+ case 0x02 : return Stream_Video;
+ case 0x03 : return Stream_Audio;
+ case 0x04 : return Stream_Audio;
+ case 0x0F : return Stream_Audio;
+ case 0x10 : return Stream_Video;
+ case 0x11 : return Stream_Audio;
+ case 0x1B : return Stream_Video;
+ case 0x1C : return Stream_Audio;
+ case 0x1D : return Stream_Text;
+ case 0x1E : return Stream_Video;
+ case 0x1F : return Stream_Video;
+ case 0x20 : return Stream_Video;
+ default :
+ switch (format_identifier)
+ {
+ case Elements::CUEI :
+ case Elements::SCTE : //SCTE
+ case Elements::GA94 :
+ case Elements::S14A : //ATSC
+ switch (stream_type)
+ {
+ case 0x80 : return Stream_Video;
+ case 0x81 : return Stream_Audio;
+ case 0x82 : return Stream_Text;
+ case 0x87 : return Stream_Audio;
+ default : return Stream_Max;
+ }
+ case Elements::HDMV : //Bluray
+ switch (stream_type)
+ {
+ case 0x80 : return Stream_Audio;
+ case 0x81 : return Stream_Audio;
+ case 0x82 : return Stream_Audio;
+ case 0x83 : return Stream_Audio;
+ case 0x84 : return Stream_Audio;
+ case 0x85 : return Stream_Audio;
+ case 0x86 : return Stream_Audio;
+ case 0x90 : return Stream_Text;
+ case 0xA1 : return Stream_Audio;
+ case 0xA2 : return Stream_Audio;
+ case 0xEA : return Stream_Video;
+ default : return Stream_Max;
+ }
+ case Elements::TSHV : //DV
+ switch (stream_type)
+ {
+ case 0xA0 : return Stream_General;
+ case 0xA1 : return Stream_General;
+ default : return Stream_Max;
+ }
+ case 0xFFFFFFFF : //Unknown
+ return Stream_Max;
+ default :
+ switch (stream_type)
+ {
+ case 0x80 : return Stream_Video;
+ case 0x81 : return Stream_Audio;
+ case 0x87 : return Stream_Audio;
+ case 0x88 : return Stream_Video;
+ case 0xD1 : return Stream_Video;
+ default : return Stream_Max;
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Psi_stream_type_Info(int8u stream_type, int32u format_identifier)
+{
+ switch (stream_type)
+ {
+ case 0x00 : return "ITU-T | ISO/IEC Reserved";
+ case 0x01 : return "ISO/IEC 11172 Video";
+ case 0x02 : return "ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream";
+ case 0x03 : return "ISO/IEC 11172 Audio";
+ case 0x04 : return "ISO/IEC 13818-3 Audio";
+ case 0x05 : return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections";
+ case 0x06 : return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data";
+ case 0x07 : return "ISO/IEC 13522 MHEG";
+ case 0x08 : return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM-CC";
+ case 0x09 : return "ITU-T Rec. H.222.1";
+ case 0x0A : return "ISO/IEC 13818-6 type A";
+ case 0x0B : return "ISO/IEC 13818-6 type B";
+ case 0x0C : return "ISO/IEC 13818-6 type C";
+ case 0x0D : return "ISO/IEC 13818-6 type D";
+ case 0x0E : return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary";
+ case 0x0F : return "ISO/IEC 13818-7 Audio with ADTS transport syntax";
+ case 0x10 : return "ISO/IEC 14496-2 Visual";
+ case 0x11 : return "ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1";
+ case 0x12 : return "ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets";
+ case 0x13 : return "ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC14496_sections.";
+ case 0x14 : return "ISO/IEC 13818-6 Synchronized Download Protocol";
+ case 0x15 : return "Metadata carried in PES packets";
+ case 0x16 : return "Metadata carried in metadata_sections";
+ case 0x17 : return "Metadata carried in ISO/IEC 13818-6 Data Carousel";
+ case 0x18 : return "Metadata carried in ISO/IEC 13818-6 Object Carousel";
+ case 0x19 : return "Metadata carried in ISO/IEC 13818-6 Synchronized Download Protocol";
+ case 0x1A : return "IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)";
+ case 0x1B : return "AVC video stream as defined in ITU-T Rec. H.264 | ISO/IEC 14496-10 Video";
+ case 0x1C : return "ISO/IEC 14496-3 Audio, without using any additional transport syntax";
+ case 0x1D : return "ISO/IEC 14496-17 Text";
+ case 0x1E : return "Auxiliary video data stream as defined in ISO/IEC 23002-3";
+ case 0x1F : return "SVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex G of ITU-T Rec. H.264 | ISO/IEC 14496-10";
+ case 0x20 : return "MVC video sub-bitstream of an AVC video stream conforming to one or more profiles defined in Annex H of ITU-T Rec. H.264 | ISO/IEC 14496-10";
+ case 0x7F : return "IPMP stream";
+ default :
+ if (stream_type<=0x7F) return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 reserved";
+ switch (format_identifier)
+ {
+ case Elements::CUEI :
+ case Elements::GA94 :
+ case Elements::S14A : //ATSC
+ case Elements::SCTE : //SCTE
+ switch (stream_type)
+ {
+ case 0x80 : return "SCTE - MPEG Video";
+ case 0x81 : return "ATSC - AC-3";
+ case 0x82 : return "SCTE - Standard Subtitle";
+ case 0x83 : return "SCTE - Isochronous Data";
+ case 0x84 : return "ATSC - Reserved";
+ case 0x85 : return "ATSC - Program Identifier";
+ case 0x86 : return "SCTE - Splice";
+ case 0x87 : return "ATSC - E-AC-3";
+ case 0x90 : return "DVB - stream_type value for Time Slicing / MPE-FEC";
+ case 0x95 : return "ATSC - Data Service Table, Network Resources Table";
+ default : return "ATSC/SCTE - Unknown";
+ }
+ case Elements::HDMV : //Bluray
+ switch (stream_type)
+ {
+ case 0x80 : return "BluRay - PCM";
+ case 0x81 : return "BluRay - AC-3";
+ case 0x82 : return "BluRay - DTS";
+ case 0x83 : return "BluRay - AC-3 (TrueHD)";
+ case 0x84 : return "BluRay - E-AC-3";
+ case 0x85 : return "BluRay - DTS (HD-HRA)";
+ case 0x86 : return "BluRay - DTS (HD-MA)";
+ case 0x90 : return "BluRay - PGS";
+ case 0xA1 : return "BluRay - AC-3";
+ case 0xA2 : return "BluRay - DTS";
+ case 0xEA : return "BluRay - VC-1";
+ default : return "Bluray - Unknown";
+ }
+ case Elements::TSHV : //DV
+ switch (stream_type)
+ {
+ case 0xA0 : return "DV - Data 0";
+ case 0xA1 : return "DV - Data 1";
+ default : return "Bluray - Unknown";
+ }
+ case 0xFFFFFFFF : //Unknown
+ return "";
+ default :
+ switch (stream_type)
+ {
+ case 0x80 : return "DigiCipher II video";
+ case 0x81 : return "AC-3";
+ case 0x88 : return "VC-1";
+ case 0x87 : return "E-AC-3";
+ case 0xD1 : return "Dirac";
+ default : return "User Private";
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Psi_table_id(int8u table_id)
+{
+ switch (table_id)
+ {
+ case 0x00 : return "program_association_section";
+ case 0x01 : return "conditional_access_section";
+ case 0x02 : return "TS_program_map_section";
+ case 0x03 : return "TS_description_section";
+ case 0x04 : return "ISO_IEC_14496_scene_description_section";
+ case 0x05 : return "ISO_IEC_14496_object_descriptor_section";
+ case 0x06 : return "Metadata?";
+ case 0x38 : return "ISO/IEC 13818-6 reserved";
+ case 0x39 : return "DSM-CC addressable section";
+ case 0x3A : return "DSM-CC : return MPE";
+ case 0x3B : return "DSM-CC : return U-N messages : return except DDM";
+ case 0x3C : return "DSM-CC : return DDM";
+ case 0x3D : return "DSM-CC : return stream descriptors";
+ case 0x3E : return "DSM-CC : return private data : return IP-Datagram";
+ case 0x3F : return "DSM-CC addressable section";
+ case 0x40 : return "DVB - network_information_section - actual_network";
+ case 0x41 : return "DVB - network_information_section - other_network";
+ case 0x42 : return "DVB - service_description_section - actual_transport_stream";
+ case 0x46 : return "DVB - service_description_section - other_transport_stream";
+ case 0x4A : return "DVB - bouquet_association_section";
+ case 0x4E : return "DVB - event_information_section - actual_transport_stream : return present/following";
+ case 0x4F : return "DVB - event_information_section - other_transport_stream : return present/following";
+ case 0x50 :
+ case 0x51 :
+ case 0x52 :
+ case 0x53 :
+ case 0x54 :
+ case 0x55 :
+ case 0x56 :
+ case 0x57 :
+ case 0x58 :
+ case 0x59 :
+ case 0x5A :
+ case 0x5B :
+ case 0x5C :
+ case 0x5E :
+ case 0x5F : return "DVB - event_information_section - actual_transport_stream : return schedule";
+ case 0x60 :
+ case 0x61 :
+ case 0x62 :
+ case 0x63 :
+ case 0x64 :
+ case 0x65 :
+ case 0x66 :
+ case 0x67 :
+ case 0x68 :
+ case 0x69 :
+ case 0x6A :
+ case 0x6B :
+ case 0x6C :
+ case 0x6D :
+ case 0x6E :
+ case 0x6F : return "DVB - event_information_section - other_transport_stream : return schedule";
+ case 0x70 : return "DVB - time_date_section";
+ case 0x71 : return "DVB - running_status_section";
+ case 0x72 : return "DVB - stuffing_section";
+ case 0x73 : return "DVB - time_offset_section";
+ case 0x74 : return "DVB - application information section";
+ case 0x75 : return "DVB - container section";
+ case 0x76 : return "DVB - related content section";
+ case 0x77 : return "DVB - content identifier section";
+ case 0x78 : return "DVB - MPE-FEC section";
+ case 0x79 : return "DVB - resolution notification section";
+ case 0x7E : return "DVB - discontinuity_information_section";
+ case 0x7F : return "DVB - selection_information_section";
+ case 0xC0 : return "ATSC - Program Information Message";
+ case 0xC1 : return "ATSC - Program Name Message";
+ case 0xC2 : return "ATSC/SCTE - Network Information Message";
+ case 0xC3 : return "ATSC/SCTE - Network Text Table (NTT)";
+ case 0xC4 : return "ATSC/SCTE - Short Form Virtual Channel Table (S-VCT)";
+ case 0xC5 : return "ATSC/SCTE - System Time Table (STT)";
+ case 0xC6 : return "ATSC/SCTE - Subtitle Message";
+ case 0xC7 : return "ATSC - Master Guide Table (MGT)";
+ case 0xC8 : return "ATSC - Terrestrial Virtual Channel Table (TVCT)";
+ case 0xC9 : return "ATSC - Cable Virtual Channel Table (CVCT) / Long-form Virtual Channel Table (L-VCT)";
+ case 0xCA : return "ATSC - Rating Region Table (RRT)";
+ case 0xCB : return "ATSC - Event Information Table (EIT)";
+ case 0xCC : return "ATSC - Extended Text Table (ETT)";
+ case 0xCD : return "ATSC - System Time Table (STT)";
+ case 0xCE : return "ATSC - Data Event Table (DET)";
+ case 0xCF : return "ATSC - Data Service Table (DST)";
+ case 0xD0 : return "ATSC - Program Identifier Table (PIT)";
+ case 0xD1 : return "ATSC - Network Resource Table (NRT)";
+ case 0xD2 : return "ATSC - Long-term Service Table (L-TST)";
+ case 0xD3 : return "ATSC - Directed Channel Change Table (DCCT)";
+ case 0xD4 : return "ATSC - DCC Selection Code Table (DCCSCT)";
+ case 0xD5 : return "ATSC - Selection Information Table (SIT)";
+ case 0xD6 : return "ATSC - Aggregate Event Information Table (AEIT)";
+ case 0xD7 : return "ATSC - Aggregate Extended Text Table (AETT)";
+ case 0xD8 : return "ATSC - Cable Emergency Alert";
+ case 0xD9 : return "ATSC - Aggregate Data Event Table";
+ case 0xDA : return "ATSC - Satellite VCT (SVCT)";
+ case 0xFC : return "SCTE - Splice";
+ default :
+ if (table_id>=0x06
+ && table_id<=0x37) return "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 reserved";
+ if (table_id>=0x40
+ && table_id<=0x7F) return "DVB - reserved";
+ if (table_id>=0x80
+ && table_id<=0x8F) return "CA message";
+ if (table_id>=0xC0
+ && table_id<=0xDF) return "ATSC/SCTE - reserved";
+ if (table_id<=0xFE) return "User Private";
+ return "unknown";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Psi_atsc_service_type(int8u service_type)
+{
+ switch (service_type)
+ {
+ case 0x00 : return "reserved";
+ case 0x01 : return "Analog television";
+ case 0x02 : return "Digital television";
+ case 0x03 : return "Digital radio";
+ case 0x04 : return "Data";
+ default : return "reserved for future use";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Psi_table_id_extension(int8u table_id)
+{
+ switch (table_id)
+ {
+ case 0x00 : return "transport_stream_id";
+ case 0x01 : return "reserved";
+ case 0x02 : return "program_number";
+ case 0x03 : return "reserved";
+ case 0x40 : return "network_id";
+ case 0x42 :
+ case 0x46 : return "transport_stream_id";
+ case 0x4E :
+ case 0x4F :
+ case 0x50 :
+ case 0x51 :
+ case 0x52 :
+ case 0x53 :
+ case 0x54 :
+ case 0x55 :
+ case 0x56 :
+ case 0x57 :
+ case 0x58 :
+ case 0x59 :
+ case 0x5A :
+ case 0x5B :
+ case 0x5C :
+ case 0x5E :
+ case 0x5F :
+ case 0x60 :
+ case 0x61 :
+ case 0x62 :
+ case 0x63 :
+ case 0x64 :
+ case 0x65 :
+ case 0x66 :
+ case 0x67 :
+ case 0x68 :
+ case 0x69 :
+ case 0x6A :
+ case 0x6B :
+ case 0x6C :
+ case 0x6D :
+ case 0x6E :
+ case 0x6F : return "service_id";
+ case 0x7F : return "DVB_reserved_for_future_use";
+ case 0xC8 :
+ case 0xC9 : return "transport_stream_id";
+ case 0xCA : return "reserved + rating_region";
+ case 0xCB : return "source_id";
+ case 0xCC : return "ETT_table_id_extension";
+ case 0xD9 : return "AEIT_subtype + MGT_tag";
+ case 0xDA : return "SVCT_subtype + SVCT_id";
+ default : return "table_id_extension";
+ }
+}
+
+//---------------------------------------------------------------------------
+// CRC_32_Table
+// A CRC is computed like this:
+// Init: int32u CRC_32 = 0xFFFFFFFF;
+// for each data byte do
+// CRC_32=(CRC_32<<8) ^ CRC_32_Table[(CRC_32>>24)^(data_byte)];
+int32u Psi_CRC_32_Table[256] =
+{
+ 0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9,
+ 0x130476DC, 0x17C56B6B, 0x1A864DB2, 0x1E475005,
+ 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61,
+ 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD,
+ 0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9,
+ 0x5F15ADAC, 0x5BD4B01B, 0x569796C2, 0x52568B75,
+ 0x6A1936C8, 0x6ED82B7F, 0x639B0DA6, 0x675A1011,
+ 0x791D4014, 0x7DDC5DA3, 0x709F7B7A, 0x745E66CD,
+ 0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039,
+ 0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5,
+ 0xBE2B5B58, 0xBAEA46EF, 0xB7A96036, 0xB3687D81,
+ 0xAD2F2D84, 0xA9EE3033, 0xA4AD16EA, 0xA06C0B5D,
+ 0xD4326D90, 0xD0F37027, 0xDDB056FE, 0xD9714B49,
+ 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95,
+ 0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1,
+ 0xE13EF6F4, 0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D,
+ 0x34867077, 0x30476DC0, 0x3D044B19, 0x39C556AE,
+ 0x278206AB, 0x23431B1C, 0x2E003DC5, 0x2AC12072,
+ 0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16,
+ 0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA,
+ 0x7897AB07, 0x7C56B6B0, 0x71159069, 0x75D48DDE,
+ 0x6B93DDDB, 0x6F52C06C, 0x6211E6B5, 0x66D0FB02,
+ 0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1, 0x53DC6066,
+ 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA,
+ 0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E,
+ 0xBFA1B04B, 0xBB60ADFC, 0xB6238B25, 0xB2E29692,
+ 0x8AAD2B2F, 0x8E6C3698, 0x832F1041, 0x87EE0DF6,
+ 0x99A95DF3, 0x9D684044, 0x902B669D, 0x94EA7B2A,
+ 0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E,
+ 0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2,
+ 0xC6BCF05F, 0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686,
+ 0xD5B88683, 0xD1799B34, 0xDC3ABDED, 0xD8FBA05A,
+ 0x690CE0EE, 0x6DCDFD59, 0x608EDB80, 0x644FC637,
+ 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB,
+ 0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F,
+ 0x5C007B8A, 0x58C1663D, 0x558240E4, 0x51435D53,
+ 0x251D3B9E, 0x21DC2629, 0x2C9F00F0, 0x285E1D47,
+ 0x36194D42, 0x32D850F5, 0x3F9B762C, 0x3B5A6B9B,
+ 0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF,
+ 0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623,
+ 0xF12F560E, 0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7,
+ 0xE22B20D2, 0xE6EA3D65, 0xEBA91BBC, 0xEF68060B,
+ 0xD727BBB6, 0xD3E6A601, 0xDEA580D8, 0xDA649D6F,
+ 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3,
+ 0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7,
+ 0xAE3AFBA2, 0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B,
+ 0x9B3660C6, 0x9FF77D71, 0x92B45BA8, 0x9675461F,
+ 0x8832161A, 0x8CF30BAD, 0x81B02D74, 0x857130C3,
+ 0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640,
+ 0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C,
+ 0x7B827D21, 0x7F436096, 0x7200464F, 0x76C15BF8,
+ 0x68860BFD, 0x6C47164A, 0x61043093, 0x65C52D24,
+ 0x119B4BE9, 0x155A565E, 0x18197087, 0x1CD86D30,
+ 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC,
+ 0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088,
+ 0x2497D08D, 0x2056CD3A, 0x2D15EBE3, 0x29D4F654,
+ 0xC5A92679, 0xC1683BCE, 0xCC2B1D17, 0xC8EA00A0,
+ 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB, 0xDBEE767C,
+ 0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18,
+ 0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4,
+ 0x89B8FD09, 0x8D79E0BE, 0x803AC667, 0x84FBDBD0,
+ 0x9ABC8BD5, 0x9E7D9662, 0x933EB0BB, 0x97FFAD0C,
+ 0xAFB010B1, 0xAB710D06, 0xA6322BDF, 0xA2F33668,
+ 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Psi_running_status[]=
+{
+ "",
+ "Not running",
+ "Starts in a few seconds",
+ "Pausing",
+ "Running",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+};
+
+//---------------------------------------------------------------------------
+extern const char* Mpeg_Descriptors_original_network_id(int16u original_network_id);
+
+//---------------------------------------------------------------------------
+const char* Mpeg_Psi_splice_command_type(int8u splice_command_type)
+{
+ switch (splice_command_type)
+ {
+ case 0x00 : return "splice_null";
+ case 0x04 : return "splice_schedule";
+ case 0x05 : return "splice_insert";
+ case 0x06 : return "time_signal";
+ case 0x07 : return "bandwidth_reservation";
+ default : return "Reserved";
+ }
+};
+
+
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Mpeg_Psi::File_Mpeg_Psi()
+:File__Analyze()
+{
+ //In
+ From_TS=true; //Default is from TS
+ Complete_Stream=NULL;
+ pid=(int16u)-1;
+
+ //Temp
+ transport_stream_id=0x0000; //Impossible
+ CRC_32=0;
+ elementary_PID=0x0000;
+ program_number=0x0000;
+ stream_type=0x00;
+ event_id=0x0000;
+ elementary_PID_IsValid=false;
+ program_number_IsValid=false;
+ stream_type_IsValid=false;
+ event_id_IsValid=false;
+ current_next_indicator=false;
+ IsATSC=false;
+ ForceStreamDisplay=MediaInfoLib::Config.MpegTs_ForceStreamDisplay_Get();
+}
+
+//---------------------------------------------------------------------------
+File_Mpeg_Psi::~File_Mpeg_Psi()
+{
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::FileHeader_Parse()
+{
+ //Parsing
+ if (From_TS)
+ {
+ int8u pointer_field;
+ Get_B1 (pointer_field, "pointer_field");
+ if (pointer_field)
+ Skip_XX(pointer_field, "payload");
+ }
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Mpeg_Psi::Header_Begin()
+{
+ if (Buffer_Offset) //Not the first one
+ {
+ Peek_B1(table_id);
+ if (table_id==0xFF)
+ {
+ Accept();
+ Fill();
+ Finish();
+ return false;
+ }
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Header_Parse()
+{
+ //From Program stream
+ if (!From_TS)
+ {
+ //Filling
+ table_id=0xFF; //Make it invalid
+ section_syntax_indicator=false;
+ Header_Fill_Code((int64u)-1, "program_stream_map"); //(int64u)-1 for precising "out of scope"
+ Header_Fill_Size(Element_Size-4);
+ return;
+ }
+
+ //Parsing
+ int16u section_length;
+ Get_B1 (table_id, "table_id");
+ BS_Begin();
+ Get_SB ( section_syntax_indicator, "section_syntax_indicator");
+ Skip_SB( "private_indicator");
+ Skip_S1( 2, "reserved");
+ Get_S2 (12, section_length, "section_length");
+ BS_End();
+
+ //Size
+ if ((size_t)section_length<Element_Offset+(section_syntax_indicator?4:0)) //We must have 4 more byte for CRC
+ {
+ Reject("PSI"); //Error, we exit
+ return;
+ }
+ if (Element_Size<Element_Offset+section_length)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ //Element[Element_Level-1].IsComplete=true;
+
+ //CRC32
+ if (section_syntax_indicator || table_id==0xC1)
+ {
+ int32u CRC_32=0xffffffff;
+ const int8u* CRC_32_Buffer=Buffer+Buffer_Offset+(size_t)Element_Offset-3; //table_id position
+
+ while(CRC_32_Buffer<Buffer+Buffer_Offset+(size_t)Element_Offset+section_length) //from table_id to the end, CRC_32 included
+ {
+ CRC_32=(CRC_32<<8) ^ Psi_CRC_32_Table[(CRC_32>>24)^(*CRC_32_Buffer)];
+ CRC_32_Buffer++;
+ }
+
+ if (CRC_32)
+ {
+ Reject();
+ return;
+ }
+ }
+
+ //Filling
+ Header_Fill_Code(table_id, Ztring().From_Number(table_id, 16));
+ Header_Fill_Size(3+section_length);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Data_Parse()
+{
+ //Check if OK
+ if(CRC_32!=0)
+ {
+ Skip_XX(Element_Size, "Data (CRC failed)");
+ Finish("PSI");
+ return;
+ }
+
+ if (section_syntax_indicator)
+ {
+ Element_Size-=4; //Reserving size of CRC32
+ Get_B2( table_id_extension, Mpeg_Psi_table_id_extension(table_id)); Element_Name(Ztring(Mpeg_Psi_table_id_extension(table_id))+_T("=")+Ztring::ToZtring_From_CC2(table_id_extension));
+ BS_Begin();
+ Skip_S1( 2, "reserved");
+ Get_S1 ( 5, version_number, "version_number"); Element_Info1(_T("Version=")+Ztring::ToZtring(version_number));
+ Get_SB ( current_next_indicator, "current_next_indicator");
+ BS_End();
+ Info_B1( section_number, "section_number"); Element_Info1(_T("Section=")+Ztring::ToZtring(section_number));
+ Skip_B1( "last_section_number");
+ }
+ else if (table_id==0xC1)
+ {
+ Element_Size-=4; //Reserving size of CRC32
+ }
+
+ #define ELEMENT_CASE(_NAME, _DETAIL) \
+ case 0x##_NAME : Element_Name(_DETAIL); Table_##_NAME(); break;
+
+ switch (table_id)
+ {
+ ELEMENT_CASE(00, "program_association_section");
+ ELEMENT_CASE(01, "conditional_access_section");
+ ELEMENT_CASE(02, "TS_program_map_section");
+ ELEMENT_CASE(03, "TS_description_section");
+ ELEMENT_CASE(04, "ISO_IEC_14496_scene_description_section");
+ ELEMENT_CASE(05, "ISO_IEC_14496_object_descriptor_section");
+ ELEMENT_CASE(06, "Metadata?");
+ ELEMENT_CASE(38, "ISO/IEC 13818-6 reserved");
+ ELEMENT_CASE(39, "DSM-CC addressable section");
+ ELEMENT_CASE(3A, "DSM-CC, MPE");
+ ELEMENT_CASE(3B, "DSM-CC, U-N messages, except DDM");
+ ELEMENT_CASE(3C, "DSM-CC, DDM");
+ ELEMENT_CASE(3D, "DSM-CC, stream descriptors");
+ ELEMENT_CASE(3E, "DSM-CC, private data, IP-Datagram");
+ ELEMENT_CASE(3F, "DSM-CC addressable section");
+ ELEMENT_CASE(40, "DVB - network_information_section - actual_network");
+ ELEMENT_CASE(41, "DVB - network_information_section - other_network");
+ ELEMENT_CASE(42, "DVB - service_description_section - actual_transport_stream");
+ ELEMENT_CASE(46, "DVB - service_description_section - other_transport_stream");
+ ELEMENT_CASE(4A, "DVB - bouquet_association_section");
+ ELEMENT_CASE(4E, "DVB - event_information_section - actual_transport_stream, present/following");
+ ELEMENT_CASE(4F, "DVB - event_information_section - other_transport_stream, present/following");
+ case 0x50 :
+ case 0x51 :
+ case 0x52 :
+ case 0x53 :
+ case 0x54 :
+ case 0x55 :
+ case 0x56 :
+ case 0x57 :
+ case 0x58 :
+ case 0x59 :
+ case 0x5A :
+ case 0x5B :
+ case 0x5C :
+ case 0x5E :
+ ELEMENT_CASE(5F, "DVB - event_information_section - actual_transport_stream, schedule");
+ case 0x60 :
+ case 0x61 :
+ case 0x62 :
+ case 0x63 :
+ case 0x64 :
+ case 0x65 :
+ case 0x66 :
+ case 0x67 :
+ case 0x68 :
+ case 0x69 :
+ case 0x6A :
+ case 0x6B :
+ case 0x6C :
+ case 0x6D :
+ case 0x6E :
+ ELEMENT_CASE(6F, "DVB - event_information_section - other_transport_stream, schedule");
+ ELEMENT_CASE(70, "DVB - time_date_section");
+ ELEMENT_CASE(71, "DVB - running_status_section");
+ ELEMENT_CASE(72, "DVB - stuffing_section");
+ ELEMENT_CASE(73, "DVB - time_offset_section");
+ ELEMENT_CASE(74, "DVB - application information section");
+ ELEMENT_CASE(75, "DVB - container section");
+ ELEMENT_CASE(76, "DVB - related content section");
+ ELEMENT_CASE(77, "DVB - content identifier section");
+ ELEMENT_CASE(78, "DVB - MPE-FEC section");
+ ELEMENT_CASE(79, "DVB - resolution notification section");
+ ELEMENT_CASE(7E, "DVB - discontinuity_information_section");
+ ELEMENT_CASE(7F, "DVB - selection_information_section");
+ ELEMENT_CASE(C0, "ATSC - Program Information Message");
+ ELEMENT_CASE(C1, "ATSC - Program Name Message");
+ ELEMENT_CASE(C2, "ATSC/SCTE - Network Information Message");
+ ELEMENT_CASE(C3, "ATSC/SCTE - Network Text Table (NTT)");
+ ELEMENT_CASE(C4, "ATSC/SCTE - Short Form Virtual Channel Table (S-VCT)");
+ ELEMENT_CASE(C5, "ATSC/SCTE - System Time Table (STT)");
+ ELEMENT_CASE(C6, "ATSC/SCTE - Subtitle Message");
+ ELEMENT_CASE(C7, "ATSC - Master Guide Table (MGT)");
+ ELEMENT_CASE(C8, "ATSC - Terrestrial Virtual Channel Table (TVCT)");
+ ELEMENT_CASE(C9, "ATSC - Cable Virtual Channel Table (CVCT) / Long-form Virtual Channel Table (L-VCT)");
+ ELEMENT_CASE(CA, "ATSC - Rating Region Table (RRT)");
+ ELEMENT_CASE(CB, "ATSC - Event Information Table (EIT)");
+ ELEMENT_CASE(CC, "ATSC - Extended Text Table (ETT)");
+ ELEMENT_CASE(CD, "ATSC - System Time Table (STT)");
+ ELEMENT_CASE(CE, "ATSC - Data Event Table (DET)");
+ ELEMENT_CASE(CF, "ATSC - Data Service Table (DST)");
+ ELEMENT_CASE(D0, "ATSC - Program Identifier Table (PIT)");
+ ELEMENT_CASE(D1, "ATSC - Network Resource Table (NRT)");
+ ELEMENT_CASE(D2, "ATSC - Long-term Service Table (L-TST)");
+ ELEMENT_CASE(D3, "ATSC - Directed Channel Change Table (DCCT)");
+ ELEMENT_CASE(D4, "ATSC - DCC Selection Code Table (DCCSCT)");
+ ELEMENT_CASE(D5, "ATSC - Selection Information Table (SIT)");
+ ELEMENT_CASE(D6, "ATSC - Aggregate Event Information Table (AEIT)");
+ ELEMENT_CASE(D7, "ATSC - Aggregate Extended Text Table (AETT)");
+ ELEMENT_CASE(D8, "ATSC - Cable Emergency Alert");
+ ELEMENT_CASE(D9, "ATSC - Aggregate Data Event Table");
+ ELEMENT_CASE(DA, "ATSC - Satellite VCT");
+ ELEMENT_CASE(FC, "SCTE - Splice");
+ default :
+ if (table_id>=0x06
+ && table_id<=0x37) {Element_Name("ITU-T Rec. H.222.0 | ISO/IEC 13818-1 reserved"); Skip_XX(Element_Size, "Unknown"); break;}
+ if (table_id>=0x40
+ && table_id<=0x7F) {Element_Name("DVB - reserved"); Skip_XX(Element_Size, "Unknown"); break;}
+ if (table_id>=0x80
+ && table_id<=0x8F) {Element_Name("CA message, EMM, ECM"); Skip_XX(Element_Size, "Unknown"); break;}
+ if (table_id>=0xC0
+ && table_id<=0xDF) {Element_Name("ATSC/SCTE - reserved");Skip_XX(Element_Size, "Unknown"); break;}
+ if (table_id<=0xFE) {Element_Name("User Private"); Skip_XX(Element_Size, "Unknown"); break;}
+ if (Element_Code==(int64u)-1) {program_stream_map(); break;} //Specific to MPEG-PS
+ {Element_Name("forbidden"); Skip_XX(Element_Size, "Unknown"); break;}
+ }
+
+ if (section_syntax_indicator || table_id==0xC1)
+ {
+ Element_Size+=4;
+ Skip_B4( "CRC32");
+ }
+
+ if (table_id>=0x40 && Complete_Stream->Streams_NotParsedCount!=(size_t)-1 && Complete_Stream->Streams_NotParsedCount!=0)
+ Complete_Stream->Streams_NotParsedCount=(size_t)-1; //Disabling speed up for detection in case of DVB/ATSC tables, we want all of them.
+
+ if (Buffer_Offset+Element_Size==Buffer_Size)
+ {
+ Accept();
+ Fill();
+ Finish();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_reserved()
+{
+
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_iso13818_6()
+{
+ Element_Info1("Defined in ISO/IEC 13818-6");
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_user_private()
+{
+ Element_Info1("user_private");
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_forbidden()
+{
+ Element_Info1("forbidden");
+ Skip_XX(Element_Size, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::program_stream_map()
+{
+ Element_Name("program_stream_map");
+ table_id=0x02; // program_map_section
+
+ //Parsing
+ int16u elementary_stream_map_length;
+ bool single_extension_stream_flag;
+ BS_Begin();
+ Skip_SB( "current_next_indicator");
+ Get_SB (single_extension_stream_flag, "single_extension_stream_flag");
+ Skip_SB( "reserved");
+ Skip_S1( 5, "program_stream_map_version");
+ Skip_S1( 7, "reserved");
+ Mark_1 ();
+ BS_End();
+ Get_B2 (Descriptors_Size, "program_stream_info_length");
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ Get_B2 (elementary_stream_map_length, "elementary_stream_map_length");
+ int16u elementary_stream_map_Pos=0;
+ while (Element_Offset<Element_Size && elementary_stream_map_Pos<elementary_stream_map_length)
+ {
+ Element_Begin0();
+ int16u ES_info_length;
+ int8u stream_type, elementary_stream_id;
+ Get_B1 (stream_type, "stream_type"); Param_Info1(Mpeg_Psi_stream_type_Info(stream_type, 0x00000000));
+ Get_B1 (elementary_stream_id, "elementary_stream_id");
+ Get_B2 (ES_info_length, "ES_info_length");
+ Descriptors_Size=ES_info_length;
+ Element_Name(Ztring::ToZtring(elementary_stream_id, 16));
+ if (elementary_stream_id==0xFD && !single_extension_stream_flag)
+ {
+ Skip_S1(8, "pseudo_descriptor_tag");
+ Skip_S1(8, "pseudo_descriptor_length");
+ Mark_1();
+ Skip_S1(7, "elementary_stream_id_extension");
+ if (Descriptors_Size>=3)
+ Descriptors_Size-=3;
+ }
+ if (Descriptors_Size>0)
+ {
+ elementary_PID=elementary_stream_id;
+ elementary_PID_IsValid=true;
+ Descriptors();
+ }
+ Element_End0();
+ elementary_stream_map_Pos+=4+ES_info_length;
+
+ FILLING_BEGIN();
+ Complete_Stream->Streams[elementary_stream_id]->stream_type=stream_type;
+ Complete_Stream->Streams[elementary_stream_id]->Infos["CodecID"].From_Number(stream_type);
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_00()
+{
+ //transport_stream_id
+ if (!Complete_Stream->transport_stream_id_IsValid || table_id_extension!=Complete_Stream->transport_stream_id)
+ {
+ if (Complete_Stream->Transport_Streams.find(Complete_Stream->transport_stream_id)!=Complete_Stream->Transport_Streams.end())
+ while (!Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.empty())
+ {
+ program_number=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.begin()->first;
+ program_number_Remove();
+ }
+
+ Complete_Stream->transport_stream_id=table_id_extension;
+ Complete_Stream->transport_stream_id_IsValid=true;
+ }
+
+ if (Complete_Stream->Transport_Streams[table_id_extension].Programs_NotParsedCount==(size_t)-1)
+ Complete_Stream->Transport_Streams[table_id_extension].Programs_NotParsedCount=0;
+
+ //Saving previous status
+ std::map<int16u, complete_stream::transport_stream::program> program_numbers_Previous=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs;
+
+ //Reseting
+ std::vector<int16u> Table_ID_Extension_List;
+ for (complete_stream::stream::table_id::table_id_extensions::iterator Table_ID_Extension=Complete_Stream->Streams[0x0000]->Table_IDs[0x00]->Table_ID_Extensions.begin(); Table_ID_Extension!=Complete_Stream->Streams[0x0000]->Table_IDs[0x00]->Table_ID_Extensions.end(); Table_ID_Extension++)
+ if (Table_ID_Extension->first!=table_id_extension)
+ Table_ID_Extension_List.push_back(Table_ID_Extension->first);
+ for (size_t Pos=0; Pos<Table_ID_Extension_List.size(); Pos++)
+ Complete_Stream->Streams[0x0000]->Table_IDs[0x00]->Table_ID_Extensions.erase(Table_ID_Extension_List[Pos]);
+
+ //Parsing
+ while (Element_Offset<Element_Size)
+ {
+ Element_Begin1("program");
+ Get_B2 ( program_number, "program_number");
+ BS_Begin();
+ Skip_S1( 3, "reserved");
+ Get_S2 ( 13, elementary_PID, program_number?"program_map_PID":"network_PID"); Element_Info1(Ztring::ToZtring_From_CC2(elementary_PID));
+ BS_End();
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (elementary_PID
+ #if MEDIAINFO_FILTER
+ && Config->File_Filter_Get(program_number)
+ #endif //MEDIAINFO_FILTER
+ )
+ {
+ program_number_Update();
+
+ std::map<int16u, complete_stream::transport_stream::program>::iterator program_number_Previous=program_numbers_Previous.find(program_number);
+ if (program_number_Previous!=program_numbers_Previous.end())
+ program_numbers_Previous.erase(program_number_Previous);
+ }
+ FILLING_END();
+ }
+ BS_End();
+
+ FILLING_BEGIN();
+ //Removing previous elementary_PIDs no more used
+ for (std::map<int16u, complete_stream::transport_stream::program>::iterator program_number_Previous=program_numbers_Previous.begin(); program_number_Previous!=program_numbers_Previous.end(); program_number_Previous++)
+ {
+ program_number=program_number_Previous->first;
+ program_number_Remove();
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_01()
+{
+ //Parsing
+ if (Element_Offset<Element_Size)
+ {
+ Descriptors_Size=(int16u)(Element_Size-Element_Offset);
+ if (Descriptors_Size>0)
+ Descriptors();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_02()
+{
+ //Informing PSI is parsed
+ if (!Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].IsParsed)
+ {
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs_NotParsedCount--;
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].IsParsed=true;
+ }
+
+ //Saving previous status
+ std::vector<int16u> elementary_PIDs_Previous=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].elementary_PIDs;
+
+ //Parsing
+ int16u PCR_PID;
+ BS_Begin();
+ Skip_S1( 3, "reserved");
+ Get_S2 (13, PCR_PID, "PCR_PID");
+ Skip_S1( 4, "reserved");
+ Get_S2 (12, Descriptors_Size, "program_info_length");
+ BS_End();
+
+ //Descriptors
+ program_number=table_id_extension;
+ program_number_IsValid=true;
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ //Parsing
+ while (Element_Offset<Element_Size)
+ {
+ Element_Begin0();
+ BS_Begin();
+ Get_S1 ( 8, stream_type, "stream_type"); Element_Info1(Mpeg_Psi_stream_type_Info(stream_type, Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].registration_format_identifier)); Param_Info1(Mpeg_Psi_stream_type_Info(stream_type, Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].registration_format_identifier));
+ Skip_S1( 3, "reserved");
+ Get_S2 (13, elementary_PID, "elementary_PID");
+ Skip_S1( 4, "reserved");
+ Get_S2 (12, Descriptors_Size, "ES_info_length");
+ BS_End();
+
+ FILLING_BEGIN();
+ //Searching for hidden Stereoscopic stream
+ if (stream_type==0x20 && File_Name_WithoutDemux.size()>=4+1+6+1+4+1+10 && Config->File_Bdmv_ParseTargetedFile_Get())
+ {
+ //Searching the playlist with the pid
+ Ztring Name=File_Name_WithoutDemux;
+ Name.resize(Name.size()-(4+1+6+1+4+1+10)); //Removing BDMV/STREAM/SSIF/xxxxx.ssif
+ ZtringList List=Dir::GetAllFileNames(Name+_T("BDMV")+PathSeparator+_T("PLAYLIST")+PathSeparator+_T("*.mpls"), Dir::Include_Files);
+ std::vector<MediaInfo_Internal*> MIs;
+ MIs.resize(List.size());
+ size_t FileWithRightPID_Pos=(size_t)-1;
+ for (size_t Pos=0; Pos<MIs.size(); Pos++)
+ {
+ MIs[Pos]=new MediaInfo_Internal();
+ MIs[Pos]->Option(_T("File_Bdmv_ParseTargetedFile"), _T("0"));
+ MIs[Pos]->Open(List[Pos]);
+ if (MIs[Pos]->Count_Get(Stream_Video)==1)
+ {
+ int16u pid=Ztring(MIs[Pos]->Get(Stream_Video, 0, Video_ID)).To_int16u();
+ if (pid==elementary_PID)
+ {
+ FileWithRightPID_Pos=Pos;
+ break;
+ }
+ }
+ }
+
+ if (FileWithRightPID_Pos!=(size_t)-1)
+ {
+ ZtringList ID_List;
+ ID_List.Separator_Set(0, _T(" / "));
+ ID_List.Write(MIs[FileWithRightPID_Pos]->Get(Stream_Video, 0, Video_ID));
+ if (ID_List.size()==2)
+ {
+ Complete_Stream->Streams[ID_List[1].To_int16u()]->SubStream_pid=elementary_PID;
+ Complete_Stream->Streams[elementary_PID]->SubStream_pid=ID_List[1].To_int16u();
+
+ elementary_PID=ID_List[1].To_int16u();
+ stream_type=0x1B;
+
+ bool IsAlreadyPresent=false;
+ for (size_t Pos=0; Pos<Complete_Stream->Streams[elementary_PID]->program_numbers.size(); Pos++)
+ if (Complete_Stream->Streams[elementary_PID]->program_numbers[Pos]==program_number)
+ IsAlreadyPresent=true;
+ if (!IsAlreadyPresent)
+ {
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].elementary_PIDs.push_back(elementary_PID);
+ Complete_Stream->Streams[elementary_PID]->program_numbers.push_back(program_number);
+ Complete_Stream->Streams[elementary_PID]->registration_format_identifier=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].registration_format_identifier;
+ }
+ if (Complete_Stream->Streams[elementary_PID]->Kind!=complete_stream::stream::pes)
+ {
+ if (Complete_Stream->Streams_NotParsedCount==(size_t)-1)
+ Complete_Stream->Streams_NotParsedCount=0;
+ Complete_Stream->Streams_NotParsedCount++;
+ Complete_Stream->Streams[elementary_PID]->Kind=complete_stream::stream::pes;
+ Complete_Stream->Streams[elementary_PID]->stream_type=stream_type;
+ Complete_Stream->Streams[elementary_PID]->Searching_Payload_Start_Set(true);
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ Complete_Stream->Streams[elementary_PID]->Searching_TimeStamp_Start_Set(true);
+ Complete_Stream->Streams[elementary_PID]->PCR_PID=PCR_PID;
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ //Complete_Stream->Streams[elementary_PID]->Searching_ParserTimeStamp_Start_Set(true);
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ #if MEDIAINFO_TRACE
+ Complete_Stream->Streams[elementary_PID]->Element_Info1="PES";
+ #endif //MEDIAINFO_TRACE
+ if (Complete_Stream->File__Duplicate_Get_From_PID(elementary_PID))
+ Complete_Stream->Streams[elementary_PID]->ShouldDuplicate=true;
+ }
+ }
+
+ }
+
+ for (size_t Pos=0; Pos<MIs.size(); Pos++)
+ delete MIs[Pos]; //MIs[Pos]=NULL;
+ }
+
+ if (elementary_PID)
+ {
+ elementary_PID_Update(PCR_PID);
+
+ //Removing from the list of previous elementary_PIDs to remove
+ for (size_t Pos=0; Pos<elementary_PIDs_Previous.size(); Pos++)
+ if (elementary_PIDs_Previous[Pos]==elementary_PID)
+ elementary_PIDs_Previous.erase(elementary_PIDs_Previous.begin()+Pos);
+ }
+ FILLING_END();
+
+ //Descriptors
+ elementary_PID_IsValid=true;
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ Element_End1(Ztring::ToZtring_From_CC2(elementary_PID));
+ }
+
+ FILLING_BEGIN();
+ //Removing previous elementary_PIDs no more used
+ if (Config->File_MpegTs_RealTime_Get())
+ {
+ for (size_t Pos=0; Pos<elementary_PIDs_Previous.size(); Pos++)
+ {
+ elementary_PID=elementary_PIDs_Previous[Pos];
+ elementary_PID_Remove();
+
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].Update_Needed_StreamCount=true;
+ }
+ }
+
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ if (PCR_PID!=0x1FFF) //Not padding packet
+ {
+ Complete_Stream->Streams[PCR_PID]->IsPCR=true;
+ Complete_Stream->PCR_PIDs[PCR_PID]++;
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].PCR_PID=PCR_PID;
+ if (Complete_Stream->Streams[PCR_PID]->TimeStamp_Start==(int64u)-1)
+ Complete_Stream->Streams[PCR_PID]->Searching_TimeStamp_Start_Set(true);
+ #if MEDIAINFO_TRACE
+ if (Complete_Stream->Streams[PCR_PID]->Kind==complete_stream::stream::unknown)
+ Complete_Stream->Streams[PCR_PID]->Element_Info1="PCR";
+ #endif //MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+
+ //Sorting
+ sort(Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].elementary_PIDs.begin(), Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].elementary_PIDs.end());
+
+ //Handling ATSC/CEA/DVB
+ if (!Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs_NotParsedCount)
+ {
+ //We know what is each pid, so we can try known values
+ #ifdef MEDIAINFO_MPEGTS_ALLSTREAMS_YES
+ for (size_t pid=0x10; pid<0x1FFF; pid++) //Wanting 0x10-->0x2F (DVB), 0x1ABC (cea_osd), 0x1FF7-->0x1FFF (ATSC)
+ for (size_t Table_ID=0x00; Table_ID<0xFF; Table_ID++)
+ {
+ Complete_Stream->Streams[pid]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[pid]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[pid]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[pid]->Table_IDs[Table_ID]=new complete_stream::stream::table_id; //event_information_section - actual_transport_stream, schedule
+
+ if (Pos==0x001F)
+ Pos=0x1ABB; //Skipping normal data
+ if (Pos==0x01ABC)
+ Pos=0x1FF6; //Skipping normal data
+ }
+ #else //MEDIAINFO_MPEGTS_ALLSTREAMS_YES
+ if (Complete_Stream->Streams[0x0010]->Kind==complete_stream::stream::unknown)
+ {
+ Complete_Stream->Streams[0x0010]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x0010]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x0010]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x0010]->Table_IDs[0x40]=new complete_stream::stream::table_id; //network_information_section - actual_network
+ }
+ if (Complete_Stream->Streams[0x0011]->Kind==complete_stream::stream::unknown)
+ {
+ Complete_Stream->Streams[0x0011]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x0011]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x0011]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x0011]->Table_IDs[0x42]=new complete_stream::stream::table_id; //service_description_section - actual_transport_stream
+ }
+ if (Complete_Stream->Streams[0x0012]->Kind==complete_stream::stream::unknown)
+ {
+ Complete_Stream->Streams[0x0012]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x0012]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x0012]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x0012]->Table_IDs[0x4E]=new complete_stream::stream::table_id; //event_information_section - actual_transport_stream, present/following
+ for (size_t Table_ID=0x50; Table_ID<0x60; Table_ID++)
+ Complete_Stream->Streams[0x0012]->Table_IDs[Table_ID]=new complete_stream::stream::table_id; //event_information_section - actual_transport_stream, schedule
+ }
+ if (Complete_Stream->Streams[0x0014]->Kind==complete_stream::stream::unknown)
+ {
+ Complete_Stream->Streams[0x0014]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x0014]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x0014]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x0014]->Table_IDs[0x70]=new complete_stream::stream::table_id; //time_date_section
+ Complete_Stream->Streams[0x0014]->Table_IDs[0x73]=new complete_stream::stream::table_id; //time_offset_section
+ }
+ if (Complete_Stream->Streams[0x1FFB]->Kind==complete_stream::stream::unknown)
+ {
+ Complete_Stream->Streams[0x1FFB]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[0x1FFB]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[0x1FFB]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[0x1FFB]->Table_IDs[0xC7]=new complete_stream::stream::table_id; //Master Guide Table
+ Complete_Stream->Streams[0x1FFB]->Table_IDs[0xCD]=new complete_stream::stream::table_id; //System Time Table
+ }
+ #endif //MEDIAINFO_MPEGTS_ALLSTREAMS_YES
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_03()
+{
+ //Parsing
+ if (Element_Offset<Element_Size)
+ {
+ Descriptors_Size=(int16u)(Element_Size-Element_Offset);
+ if (Descriptors_Size>0)
+ Descriptors();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_40()
+{
+ if (IsATSC)
+ {
+ Skip_XX(Element_Size, "Unknown ATSC");
+ return;
+ }
+
+ //Parsing
+ BS_Begin();
+ Skip_S1( 4, "reserved");
+ Get_S2 (12, Descriptors_Size, "network_descriptors_length");
+ BS_End();
+
+ //Descriptors
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ //Parsing
+ int16u transport_stream_loop_length;
+ BS_Begin();
+ Skip_S1( 4, "reserved");
+ Get_S2 (12, transport_stream_loop_length, "transport_stream_loop_length");
+ BS_End();
+
+ if (Element_Offset<Element_Size)
+ {
+ int16u original_network_id;
+ Element_Begin0();
+ Get_B2 (transport_stream_id, "transport_stream_id"); Element_Info1(transport_stream_id);
+ Get_B2 (original_network_id, "original_network_id"); Param_Info1(Mpeg_Descriptors_original_network_id(original_network_id));
+ BS_Begin();
+ Skip_S1( 4, "reserved");
+ Get_S2 (12, Descriptors_Size, "transport_descriptors_length");
+ BS_End();
+
+ //Descriptors
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ Element_End0();
+
+ FILLING_BEGIN();
+ Complete_Stream->original_network_name=Mpeg_Descriptors_original_network_id(original_network_id);
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_42()
+{
+ //Parsing
+ Skip_B2( "original_network_id");
+ Skip_B1( "reserved_future_use");
+ while (Element_Offset<Element_Size)
+ {
+ Element_Begin0();
+ int64u Test;
+ Peek_B5(Test);
+ if (Test!=0xFFFFFFFFFFULL)
+ {
+ Get_B2 ( program_number, "service_id");
+ BS_Begin();
+ Skip_S1( 6, "reserved_future_use");
+ Skip_SB( "EIT_schedule_flag");
+ Skip_SB( "EIT_present_following_flag");
+ Info_S1( 3, running_status, "running_status"); Param_Info1(Mpeg_Psi_running_status[running_status]);
+ Skip_SB( "free_CA_mode");
+ Get_S2 (12, Descriptors_Size, "ES_info_length");
+ BS_End();
+
+ //Descriptors
+ program_number_IsValid=true;
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ Element_End1(Ztring::ToZtring_From_CC2(program_number));
+ }
+ else
+ {
+ Skip_XX(Element_Size-Element_Offset, "Junk");
+ Element_End1("Junk");
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_46()
+{
+ Table_42();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_4E()
+{
+ //Clearing
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks[table_id].Events.clear();
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks_IsUpdated=true;
+ Complete_Stream->Programs_IsUpdated=true;
+
+ //Parsing
+ Get_B2 (transport_stream_id, "transport_stream_id");
+ if (table_id==0x4E || (table_id&0xF0)==0x50) //current transport_stream_id
+ transport_stream_id=Complete_Stream->transport_stream_id; //On the example I have, transport_stream_id is something else, what?
+ Skip_B2( "original_network_id");
+ Skip_B1( "segment_last_section_number");
+ Skip_B1( "last_table_id");
+ if (Element_Offset==Element_Size)
+ {
+ Element_DoNotShow(); //This is empty!
+ return;
+ }
+ while (Element_Offset<Element_Size)
+ {
+ Element_Begin0();
+ int32u time, duration;
+ int16u date;
+ int8u running_status;
+ Get_B2 (event_id, "event_id");
+ Get_B2 (date, "start_time (date)"); Param_Info1(Date_MJD(date));
+ Get_B3 (time, "start_time (time)"); Param_Info1(Time_BCD(time));
+ Get_B3 (duration, "duration"); Param_Info1(Time_BCD(duration));
+ BS_Begin();
+ Get_S1 ( 3, running_status, "running_status"); Param_Info1(Mpeg_Psi_running_status[running_status]);
+ Skip_SB( "free_CA_mode");
+ Get_S2 (12, Descriptors_Size, "descriptors_loop_length");
+ BS_End();
+
+ //Descriptors
+ event_id_IsValid=true;
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ Element_End1(Ztring::ToZtring_From_CC2(event_id));
+
+ FILLING_BEGIN();
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks[table_id].Events[event_id].start_time=_T("UTC ")+Date_MJD(date)+_T(" ")+Time_BCD(time);
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks[table_id].Events[event_id].duration=Time_BCD(duration);
+ if (running_status)
+ Complete_Stream->Transport_Streams[transport_stream_id].Programs[table_id_extension].DVB_EPG_Blocks[table_id].Events[event_id].running_status=Mpeg_Psi_running_status[running_status];
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_4F()
+{
+ Table_4E();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_5F()
+{
+ Table_4E();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_6F()
+{
+ Table_4F();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_70()
+{
+ //Parsing
+ int32u time;
+ int16u date;
+ Get_B2 (date, "UTC_time (date)"); Param_Info1(Date_MJD(date));
+ Get_B3 (time, "UTC_time (time)"); Param_Info1(Time_BCD(time));
+
+ FILLING_BEGIN();
+ if (Complete_Stream->Duration_Start.empty())
+ Complete_Stream->Duration_Start=_T("UTC ")+Date_MJD(date)+_T(" ")+Time_BCD(time);
+ Complete_Stream->Duration_End=_T("UTC ")+Date_MJD(date)+_T(" ")+Time_BCD(time);
+ Complete_Stream->Duration_End_IsUpdated=true;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_73()
+{
+ //Parsing
+ int32u time;
+ int16u date;
+ Get_B2 (date, "UTC_time (date)"); Param_Info1(Date_MJD(date));
+ Get_B3 (time, "UTC_time (time)"); Param_Info1(Time_BCD(time));
+ BS_Begin();
+ Skip_S1( 4, "DVB_reserved_for_future_use");
+ Get_S2 (12, Descriptors_Size, "transmission_info_loop_length");
+ BS_End();
+
+ //Descriptors
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ Skip_B4( "CRC32");
+
+ FILLING_BEGIN();
+ if (Complete_Stream->Duration_Start.empty())
+ Complete_Stream->Duration_Start=_T("UTC ")+Date_MJD(date)+_T(" ")+Time_BCD(time);
+ Complete_Stream->Duration_End=_T("UTC ")+Date_MJD(date)+_T(" ")+Time_BCD(time);
+ Complete_Stream->Duration_End_IsUpdated=true;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_7F()
+{
+ //Parsing
+ BS_Begin();
+ Skip_S1( 4, "DVB_reserved_for_future_use");
+ Get_S2 (12, Descriptors_Size, "transmission_info_loop_length");
+ BS_End();
+
+ //Descriptors
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ while (Element_Offset<Element_Size)
+ {
+ Element_Begin0();
+ Get_B2 ( program_number, "service_id");
+ BS_Begin();
+ Skip_SB( "DVB_reserved_future_use");
+ Info_S1( 3, running_status, "running_status"); Param_Info1(Mpeg_Psi_running_status[running_status]);
+ Get_S2 (12, Descriptors_Size, "service_loop_length");
+ BS_End();
+
+ //Descriptors
+ program_number_IsValid=true;
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ Element_End1(Ztring::ToZtring_From_CC2(program_number));
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_C0()
+{
+ //TODO
+ Skip_XX(Element_Size-Element_Offset, "data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_C1()
+{
+ IsATSC=true;
+
+ //Parsing
+ Ztring program_name, alternate_program_name;
+ int8u protocol_version, program_name_length, alternate_program_name_length, package_count;
+ BS_Begin();
+ Skip_S1(3, "reserved");
+ Get_S1 (5, protocol_version, "protocol_version");
+ BS_End();
+ if (protocol_version!=0)
+ {
+ Skip_XX(Element_Size-Element_Offset, "data");
+ return;
+ }
+ Skip_C3( "ISO_639_language_code");
+ Skip_B2( "program_number");
+ Skip_B1( "reserved");
+ Skip_B1( "sequence");
+ Skip_B1( "program_epoch_number");
+ BS_Begin();
+ Skip_SB( "display_name_when_not_auth");
+ Skip_SB( "use_alt_name_in_purchase_history");
+ Skip_SB( "use_alt_name_if_not_auth");
+ Skip_SB( "display_ratings");
+ Skip_S1(4, "reserved");
+ BS_End();
+ Get_B1 (program_name_length, "program_name_length");
+ SCTE_multilingual_text_string(program_name_length, program_name, "program_name");
+ Get_B1 (alternate_program_name_length, "alternate_program_name_length");
+ SCTE_multilingual_text_string(alternate_program_name_length, alternate_program_name, "alternate_program_name");
+ BS_Begin();
+ Skip_S1(3, "reserved");
+ Get_S1 (5, package_count, "package_count");
+ BS_End();
+ for (int8u Pos=0; Pos<package_count; Pos++)
+ {
+ Ztring package_name;
+ int8u package_name_length;
+ Get_B1 (package_name_length, "package_name_length");
+ SCTE_multilingual_text_string(package_name_length, package_name, "package_name");
+ }
+
+ if (Element_Offset<Element_Size)
+ {
+ BS_Begin();
+ Skip_S1( 6, "reserved");
+ Get_S2 (10, Descriptors_Size, "descriptors_length");
+ BS_End();
+
+ //Descriptors
+ if (Descriptors_Size>0)
+ Descriptors();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_C7()
+{
+ //Parsing
+ int16u tables_defined;
+ int8u protocol_version;
+ Get_B1 (protocol_version, "protocol_version");
+ if (protocol_version!=0)
+ {
+ Skip_XX(Element_Size-Element_Offset, "data");
+ return;
+ }
+ Get_B2 (tables_defined, "tables_defined");
+ for (int16u Pos=0; Pos<tables_defined; Pos++)
+ {
+ int16u table_type, table_type_PID;
+ Element_Begin0();
+ Get_B2 ( table_type, "table_type"); Param_Info1(Mpeg_Psi_ATSC_table_type(table_type));
+ BS_Begin();
+ Skip_S1( 3, "reserved");
+ Get_S2 (13, table_type_PID, "table_type_PID");
+ Skip_S1( 3, "reserved");
+ Skip_S1( 5, "table_type_version_number");
+ BS_End();
+ Skip_B4( "number_bytes");
+ BS_Begin();
+ Skip_S1( 4, "reserved");
+ Get_S2 (12, Descriptors_Size, "table_type_descriptors_length");
+ BS_End();
+
+ //Descriptors
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ Element_Info1(Mpeg_Psi_ATSC_table_type(table_type));
+ Element_Info1C((table_type>=0x0100), table_type%0x100);
+ Element_End1(Ztring::ToZtring_From_CC2(table_type_PID));
+
+ FILLING_BEGIN();
+ if (Complete_Stream->Streams[table_type_PID]->Kind==complete_stream::stream::unknown && table_type!=0x0001 && table_type!=0x0003) //Not activing current_next_indicator='0'
+ {
+ Complete_Stream->Streams[table_type_PID]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[table_type_PID]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[table_type_PID]->Table_IDs.resize(0x100);
+ }
+ #ifdef MEDIAINFO_MPEGTS_ALLSTREAMS_YES
+ for (int8u table_id=0x00; table_id<0xFF; table_id++)
+ if (Complete_Stream->Streams[table_type_PID].Table_IDs[table_id]==NULL)
+ Complete_Stream->Streams[table_type_PID].Table_IDs[table_id]=new complete_stream::stream::table_id; //Master Guide Table
+ #else //MEDIAINFO_MPEGTS_ALLSTREAMS_YES
+ int8u table_id;
+ if (table_type==0x0000) //Terrestrial VCT with current_next_indicator=1
+ table_id=0xC8;
+ else if (table_type==0x0002) //Cable VCT with current_next_indicator=1
+ table_id=0xC9;
+ else if (table_type==0x0004) //Channel ETT
+ table_id=0xCC;
+ else if (table_type>=0x0100 && table_type<=0x017F) //EIT-0 to EIT-127
+ table_id=0xCB;
+ else if (table_type>=0x0200 && table_type<=0x027F) //Event ETT-0 to event ETT-127
+ table_id=0xCC;
+ else if (table_type>=0x0301 && table_type<=0x03FF) //RRT with rating_region 1-255
+ table_id=0xCA;
+ else if (table_type>=0x1000 && table_type<0x10FF) //Aggregate Event Information Table
+ table_id=0xD6;
+ else if (table_type>=0x1100 && table_type<0x11FF) //Aggregate Extended Text Table
+ table_id=0xD7;
+ else if (table_type>=0x1600 && table_type<0x16FF) //Satellite Virtual Channel Table
+ table_id=0xDA;
+ else
+ table_id=0xFF;
+ if (table_id!=0xFF && Complete_Stream->Streams[table_type_PID]->Table_IDs[table_id]==NULL)
+ Complete_Stream->Streams[table_type_PID]->Table_IDs[table_id]=new complete_stream::stream::table_id; //Master Guide Table
+ #endif //MEDIAINFO_MPEGTS_ALLSTREAMS_YES
+ Complete_Stream->Streams[table_type_PID]->table_type=table_type-((table_type&0x200)?0x100:0); //For having the same table_type for both EIT and ETT
+ FILLING_END();
+ }
+ BS_Begin();
+ Skip_S1( 4, "reserved");
+ Get_S2 (12, Descriptors_Size, "descriptors_length");
+ BS_End();
+
+ //Descriptors
+ if (Descriptors_Size>0)
+ Descriptors();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_C9()
+{
+ //Parsing
+ Ztring short_name;
+ int8u num_channels_in_section;
+ Skip_B1( "protocol_version");
+ Get_B1 ( num_channels_in_section, "num_channels_in_section");
+ BS_End();
+ for (int8u Pos=0; Pos<num_channels_in_section; Pos++)
+ {
+ int16u major_channel_number, minor_channel_number, source_id;
+ int8u service_type;
+ Element_Begin0();
+ Get_UTF16B(table_id==0xDA?16:14, short_name, "short_name"); //8 chars for satellite, else 7 chars
+ BS_Begin();
+ Skip_S1( 4, "reserved");
+ Get_S2 (10, major_channel_number, "major_channel_number");
+ Get_S2 (10, minor_channel_number, "minor_channel_number");
+ if (table_id==0xDA) //Satellite
+ {
+ Skip_S1( 6, "modulation_mode");
+ Skip_S4(32, "carrier_frequency");
+ Skip_S4(32, "carrier_symbol_rate");
+ Skip_S1( 2, "polarization");
+ BS_End();
+ Skip_B1( "FEC_Inner");
+ }
+ else //Terrestrial and Cable
+ {
+ BS_End();
+ Skip_B1( "modulation_mode");
+ Skip_B4( "carrier_frequency");
+ }
+ Skip_B2( "channel_TSID");
+ Get_B2 ( program_number, "program_number");
+ BS_Begin();
+ Skip_S1( 2, "ETM_location");
+ Skip_SB( table_id==0xDA?"reserved":"access_controlled");
+ Skip_SB( "hidden");
+ if (table_id==0xC8) //Terrestrial
+ {
+ Skip_SB( "path_select");
+ Skip_SB( "out_of_band");
+ }
+ else //Cable and satellite
+ Skip_S1( 2, "reserved");
+ Skip_SB( "hide_guide");
+ Skip_S1( 3, "reserved");
+ Get_S1 ( 6, service_type, "service_type");
+ BS_End();
+ Get_B2 ( source_id, "source_id");
+ if (table_id==0xDA) //Satellite
+ Skip_B1( "feed_id");
+ BS_Begin();
+ Skip_S1( 6, "reserved");
+ Get_S2 (10, Descriptors_Size, "descriptors_length");
+ BS_End();
+
+ FILLING_BEGIN();
+ if (!Config->File_MpegTs_Atsc_transport_stream_id_Trust_Get())
+ table_id_extension=Complete_Stream->transport_stream_id;
+ Ztring Channel=Ztring::ToZtring(major_channel_number);
+ if (minor_channel_number)
+ Channel+=_T("-")+Ztring::ToZtring(minor_channel_number);
+ if (minor_channel_number==0 || program_number==0xFFFF)
+ {
+ Complete_Stream->Transport_Streams[table_id_extension].Infos["ServiceName"]=short_name;
+ Complete_Stream->Transport_Streams[table_id_extension].Infos["ServiceChannel"]=Channel;
+ Complete_Stream->Transport_Streams[table_id_extension].Infos["ServiceType"]=Mpeg_Psi_atsc_service_type(service_type);
+ Complete_Stream->Transport_Streams[table_id_extension].source_id=source_id;
+ Complete_Stream->Transport_Streams[table_id_extension].source_id_IsValid=true;
+ }
+ else if (program_number<0x2000)
+ {
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].Infos["ServiceName"]=short_name;
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].Infos["ServiceChannel"]=Channel;
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].Infos["ServiceType"]=Mpeg_Psi_atsc_service_type(service_type);
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].source_id=source_id;
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].source_id_IsValid=true;
+ }
+ FILLING_END();
+
+ //Descriptors
+ program_number_IsValid=true;
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ Element_End1(Ztring::ToZtring_From_CC2(program_number));
+ }
+
+ BS_Begin();
+ Skip_S1( 6, "reserved");
+ Get_S2 (10, Descriptors_Size, "additional_descriptors_length");
+ BS_End();
+
+ //Descriptors
+ if (Descriptors_Size>0)
+ Descriptors();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_CA()
+{
+ //Parsing
+ Ztring rating_region_name;
+ int8u dimensions_defined;
+ Skip_B1( "protocol_version");
+ Skip_B1( "rating_region_name_length"); //Not used
+ ATSC_multiple_string_structure(rating_region_name, "rating_region_name");
+ Get_B1 ( dimensions_defined, "dimensions_defined");
+ BS_End();
+ for (int8u dimension_Pos=0; dimension_Pos<dimensions_defined; dimension_Pos++)
+ {
+ Element_Begin1("dimension");
+ Ztring dimension_name;
+ int8u values_defined;
+ Skip_B1( "dimension_name_length"); //Not used
+ ATSC_multiple_string_structure(dimension_name, "dimension_name"); Element_Info1(dimension_name);
+ BS_Begin();
+ Skip_S1( 3, "reserved");
+ Skip_SB( "graduated_scale");
+ Get_S1 ( 4, values_defined, "values_defined");
+ BS_End();
+ for (int8u value_Pos=0; value_Pos<values_defined; value_Pos++)
+ {
+ Element_Begin1("value");
+ Ztring abbrev_rating_value, rating_value;
+ Skip_B1( "abbrev_rating_value_length"); //Not used
+ ATSC_multiple_string_structure(abbrev_rating_value, "abbrev_rating_value"); Element_Info1(abbrev_rating_value);
+ Skip_B1( "rating_value_length"); //Not used
+ ATSC_multiple_string_structure(rating_value, "rating_value"); Element_Info1(rating_value);
+ Element_End0();
+ }
+ Element_End0();
+ }
+
+ BS_Begin();
+ Skip_S1( 6, "reserved");
+ Get_S2 (10, Descriptors_Size, "descriptors_length");
+ BS_End();
+
+ //Descriptors
+ if (Descriptors_Size>0)
+ Descriptors();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_CB()
+{
+ //Clear
+ Complete_Stream->Sources[table_id_extension].ATSC_EPG_Blocks[table_id].Events.clear();
+ Complete_Stream->Sources[table_id_extension].ATSC_EPG_Blocks_IsUpdated=true;
+ Status[IsUpdated]=true;
+
+ //Parsing
+ int8u num_events_in_section;
+ if (table_id==0xCB) //EIT (not A-EIT)
+ Skip_B1( "protocol_version");
+ Get_B1 ( num_events_in_section, "num_events_in_section");
+ BS_End();
+ for (int8u Pos=0; Pos<num_events_in_section; Pos++)
+ {
+ Ztring title;
+ int32u start_time, length_in_seconds;
+ Element_Begin0();
+ BS_Begin();
+ Skip_SB( table_id==0xD9?"off_air":"reserved");
+ Skip_SB( "reserved");
+ Get_S2 (14, event_id, "event_id");
+ BS_End();
+ Get_B4 ( start_time, "start_time"); Param_Info1(Ztring().Date_From_Seconds_1970(start_time+315964800)); Element_Info1(Ztring().Date_From_Seconds_1970(start_time+315964800-Complete_Stream->GPS_UTC_offset)); //UTC 1980-01-06 00:00:00
+ BS_Begin();
+ Skip_S1( 2, "reserved");
+ Skip_S1( 2, table_id==0xCB?"ETM_location":"reserved");
+ Get_S3 (20, length_in_seconds, "length_in_seconds");
+ BS_End();
+ Skip_B1 ( "title_length"); //We don't use it for verification
+ ATSC_multiple_string_structure(title, "title");
+ BS_Begin();
+ Skip_S1( 6, "reserved");
+ Get_S2 (10, Descriptors_Size, "descriptors_length");
+ BS_End();
+
+ //Descriptors
+ event_id_IsValid=true;
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ Element_End1(Ztring::ToZtring_From_CC2(event_id));
+
+ FILLING_BEGIN();
+ Complete_Stream->Sources[table_id_extension].ATSC_EPG_Blocks[Complete_Stream->Streams[pid]->table_type].Events[event_id].start_time=start_time;
+ Ztring duration =(length_in_seconds<36000?_T("0"):_T(""))+Ztring::ToZtring(length_in_seconds/3600)+_T(":");
+ length_in_seconds%=3600;
+ duration+=(length_in_seconds< 600?_T("0"):_T(""))+Ztring::ToZtring(length_in_seconds/ 60)+_T(":");
+ length_in_seconds%=60;
+ duration+=(length_in_seconds< 10?_T("0"):_T(""))+Ztring::ToZtring(length_in_seconds );
+ Complete_Stream->Sources[table_id_extension].ATSC_EPG_Blocks[Complete_Stream->Streams[pid]->table_type].Events[event_id].duration=duration;
+ Complete_Stream->Sources[table_id_extension].ATSC_EPG_Blocks[Complete_Stream->Streams[pid]->table_type].Events[event_id].title=title;
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_CC()
+{
+ //Parsing
+ Ztring extended_text_message;
+ int16u source_id, event_id;
+ Skip_B1( "protocol_version");
+ Element_Begin1("ETM_id");
+ Get_B2 ( source_id, "source_id");
+ BS_Begin();
+ Get_S2 (14, event_id, "event_id");
+ Skip_S1( 2, "lsb");
+ BS_End();
+ Element_End0();
+ ATSC_multiple_string_structure(extended_text_message, "extended_text_message");
+
+ FILLING_BEGIN();
+ if (Complete_Stream->Streams[pid]->table_type==4)
+ Complete_Stream->Sources[source_id].texts[table_id_extension]=extended_text_message;
+ else
+ {
+ Complete_Stream->Sources[source_id].ATSC_EPG_Blocks[Complete_Stream->Streams[pid]->table_type].Events[event_id].texts[table_id_extension]=extended_text_message;
+ Complete_Stream->Sources[source_id].ATSC_EPG_Blocks_IsUpdated=true;
+ Complete_Stream->Sources_IsUpdated=true;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_CD()
+{
+ //Parsing
+ int32u system_time;
+ int8u GPS_UTC_offset;
+ Skip_B1( "protocol_version");
+ Get_B4 (system_time, "system_time"); Param_Info1(Ztring().Date_From_Seconds_1970(system_time+315964800)); //UTC 1980-01-06 00:00:00
+ Get_B1 (GPS_UTC_offset, "GPS_UTC_offset");
+ Element_Begin1("daylight_savings");
+ BS_Begin();
+ Skip_SB( "DS_status");
+ Skip_SB( "Reserved");
+ Skip_SB( "Reserved");
+ Skip_S1(5, "DS_day_of_month");
+ BS_End();
+ Skip_B1( "DS_hour");
+ Element_End0();
+
+ //Descriptors
+ Descriptors_Size=(int16u)(Element_Size-Element_Offset);
+ if (Descriptors_Size>0)
+ Descriptors();
+
+ FILLING_BEGIN();
+ if (Complete_Stream->Duration_Start.empty())
+ Complete_Stream->Duration_Start=Ztring().Date_From_Seconds_1970(system_time+315964800-GPS_UTC_offset);
+ Complete_Stream->Duration_End=Ztring().Date_From_Seconds_1970(system_time+315964800-GPS_UTC_offset);
+ Complete_Stream->Duration_End_IsUpdated=true;
+ Complete_Stream->GPS_UTC_offset=GPS_UTC_offset;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_D6()
+{
+ //Parsing
+ if ((table_id_extension&0xFF00)==0x0000)
+ {
+ int8u num_sources_in_section;
+ Get_B1 ( num_sources_in_section, "num_sources_in_section");
+ for (int8u Pos=0; Pos<num_sources_in_section; Pos++)
+ {
+ Get_B2 (table_id_extension, "source_id");
+ Table_CB();
+ }
+ }
+ else
+ Skip_XX(Element_Size, "reserved");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_FC()
+{
+ //Parsing
+ int16u splice_command_length;
+ int8u splice_command_type;
+ bool encrypted_packet;
+ Skip_B1( "protocol_version");
+ BS_Begin();
+ Get_SB ( encrypted_packet, "encrypted_packet");
+ Skip_S1( 6, "encryption_algorithm");
+ Skip_S5(33, "pts_adjustment");
+ Skip_S1( 8, "cw_index");
+ Skip_S2(12, "reserved");
+ Get_S2 (12, splice_command_length, "splice_command_length");
+ if (splice_command_length==0xFFF)
+ splice_command_length=(int16u)(Element_Size-4-Element_Offset);
+ Get_S1 ( 8, splice_command_type, "splice_command_type"); Param_Info1(Mpeg_Psi_splice_command_type(splice_command_type));
+ BS_End();
+
+ Element_Begin0();
+ #undef ELEMENT_CASE
+ #define ELEMENT_CASE(_NAME, _DETAIL) \
+ case 0x##_NAME : Element_Name(_DETAIL); Table_FC_##_NAME(); break;
+ switch (splice_command_type)
+ {
+ ELEMENT_CASE (00, "splice_null"); break;
+ ELEMENT_CASE (04, "splice_schedule"); break;
+ ELEMENT_CASE (05, "splice_insert"); break;
+ ELEMENT_CASE (06, "time_signal"); break;
+ ELEMENT_CASE (07, "bandwidth_reservation"); break;
+ default : Skip_XX(splice_command_length, "Unknown");
+ }
+ Element_End0();
+
+ if (Element_Offset+4<Element_Size)
+ {
+ Get_B2 (Descriptors_Size, "descriptor_loop_length");
+ transport_stream_id=Complete_Stream->transport_stream_id; //SCTE 35 is automaticly linked to the current transport_stream_id
+ if (Descriptors_Size>0)
+ Descriptors();
+ }
+
+ if (Element_Offset+4<Element_Size)
+ Skip_XX(Element_Size-(Element_Offset+4), "alignment_stuffing");
+ if (encrypted_packet)
+ Skip_B4( "E_CRC_32");
+ Skip_B4( "CRC32");
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_FC_00()
+{
+ //Null
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_FC_04()
+{
+ //TODO
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_FC_05()
+{
+ //Parsing
+ bool splice_event_cancel_indicator;
+ Skip_B4( "splice_event_id");
+ BS_Begin();
+ Get_SB ( splice_event_cancel_indicator, "splice_event_cancel_indicator");
+ Skip_S1( 7, "reserved");
+ BS_End();
+ if (!splice_event_cancel_indicator)
+ {
+ bool program_splice_flag, duration_flag, splice_immediate_flag;
+ BS_Begin();
+ Skip_SB( "out_of_network_indicator");
+ Get_SB ( program_splice_flag, "program_splice_flag");
+ Get_SB ( duration_flag, "duration_flag");
+ Get_SB ( splice_immediate_flag, "splice_immediate_flag");
+ Skip_S1( 4, "reserved");
+ BS_End();
+ if(program_splice_flag && !splice_immediate_flag)
+ Table_FC_05_splice_time();
+ if (!program_splice_flag)
+ {
+ int8u component_count;
+ Get_B1(component_count, "component_count");
+ for (int8u component=0; component<component_count; component++)
+ {
+ Skip_B1( "component_tag");
+ Table_FC_05_splice_time();
+ }
+ }
+ if(duration_flag)
+ Table_FC_05_break_duration();
+ Skip_B2( "unique_program_id");
+ Skip_B1( "avail_num");
+ Skip_B1( "avails_expected");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_FC_05_break_duration()
+{
+ Element_Begin1("break_duration");
+
+ //Parsing
+ BS_Begin();
+ Skip_SB( "auto_return");
+ Skip_S1( 6, "reserved");
+ Skip_S5(33, "duration");
+ BS_End();
+
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_FC_05_splice_time()
+{
+ Element_Begin1("splice_time");
+
+ //Parsing
+ bool time_specified_flag;
+ BS_Begin();
+ Get_SB ( time_specified_flag, "time_specified_flag");
+ if (time_specified_flag)
+ {
+ Skip_S1( 6, "reserved");
+ Skip_S5(33, "pts_time");
+
+ }
+ else
+ Skip_S5(7, "reserved");
+ BS_End();
+
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_FC_06()
+{
+ Table_FC_05_splice_time();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Table_FC_07()
+{
+ //TODO
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::Descriptors()
+{
+ if (Element_Offset+Descriptors_Size>Element_Size)
+ {
+ Trusted_IsNot("Descriptor size too big");
+ return;
+ }
+
+ //Configuring
+ File_Mpeg_Descriptors Descriptors;
+ Descriptors.Complete_Stream=Complete_Stream;
+ Descriptors.transport_stream_id=transport_stream_id;
+ Descriptors.pid=pid;
+ Descriptors.table_id=table_id;
+ Descriptors.table_id_extension=table_id_extension;
+ Descriptors.elementary_PID=elementary_PID;
+ Descriptors.program_number=program_number;
+ Descriptors.stream_type=stream_type;
+ Descriptors.event_id=event_id;
+ Descriptors.elementary_PID_IsValid=elementary_PID_IsValid;
+ Descriptors.program_number_IsValid=program_number_IsValid;
+ Descriptors.stream_type_IsValid=stream_type_IsValid;
+ Descriptors.event_id_IsValid=event_id_IsValid;
+
+ //Parsing
+ if (Descriptors_Size!=0)
+ {
+ Element_Begin1("Descriptors");
+ Open_Buffer_Init(&Descriptors);
+ Open_Buffer_Continue(&Descriptors, Descriptors_Size);
+ Element_End0();
+ }
+
+ //Configuring
+ elementary_PID_IsValid=false;
+ program_number_IsValid=false;
+ stream_type_IsValid=false;
+ event_id_IsValid=false;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::ATSC_multiple_string_structure(Ztring &Value, const char* Name)
+{
+ //Parsing
+ Ztring string;
+ int8u number_strings, number_segments;
+ Element_Begin1(Name);
+ Get_B1(number_strings, "number_strings");
+ for (int8u string_Pos=0; string_Pos<number_strings; string_Pos++)
+ {
+ Element_Begin1("String");
+ int32u ISO_639_language_code;
+ Get_C3(ISO_639_language_code, "ISO_639_language_code");
+ Get_B1(number_segments, "number_segments");
+ for (int8u segment_Pos=0; segment_Pos<number_segments; segment_Pos++)
+ {
+ Element_Begin1("Segment");
+ Ztring segment;
+ int8u compression_type, mode, number_bytes;
+ Get_B1 (compression_type, "compression_type");
+ Get_B1 (mode, "mode");
+ Get_B1 (number_bytes, "number_bytes");
+ switch (compression_type)
+ {
+ case 0x00 :
+ switch (mode)
+ {
+ case 0x00 : Get_Local(number_bytes, segment, "string"); break;
+ case 0x3F : Get_UTF16B(number_bytes, segment, "string"); break;
+ default : Skip_XX(number_bytes, "Unknown");
+ segment=_T("(Encoded with mode=0x")+Ztring::ToZtring(mode, 16)+_T(')');
+ }
+ break;
+ default : Skip_XX(number_bytes, "(Compressed)");
+ segment=_T("(Compressed)");
+ }
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (segment.find_first_not_of(_T("\t\n "))!=std::string::npos)
+ string+=segment+_T(" - ");
+ FILLING_END();
+ }
+
+ FILLING_BEGIN();
+ if (!string.empty())
+ string.resize(string.size()-3);
+ Ztring ISO_639_2=Ztring().From_CC3(ISO_639_language_code);
+ const Ztring& ISO_639_1=MediaInfoLib::Config.Iso639_1_Get(ISO_639_2);
+ Value+=(ISO_639_1.empty()?ISO_639_2:ISO_639_1)+_T(':')+string+_T(" - ");
+ FILLING_END();
+
+ Element_Info1(string);
+ Element_End1("String");
+ }
+
+ if (!Value.empty())
+ Value.resize(Value.size()-3);
+
+ Element_Info1(Value);
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::SCTE_multilingual_text_string(int8u Size, Ztring &Value, const char* Name)
+{
+ //Parsing
+ Element_Begin1(Name);
+ int64u End=Element_Offset+Size;
+ while (Element_Offset<End)
+ {
+ int8u mode;
+ Get_B1 (mode, "mode");
+ if (mode<0x3F)
+ {
+ int8u eightbit_string_length;
+ Get_B1 (eightbit_string_length, "eightbit_string_length");
+ if (mode==0)
+ Get_ISO_8859_1(eightbit_string_length, Value, "eightbit_string");
+ else
+ Skip_XX(eightbit_string_length, "eightbit_string (unsupporeted)");
+ }
+ else if (mode==0x3F)
+ {
+ int8u sixteenbit_string_length;
+ Get_B1 (sixteenbit_string_length, "sixteenbit_string_length");
+ Get_UTF16B(sixteenbit_string_length, Value, "sixteenbit_string");
+ }
+ else if (mode>=0xA0)
+ {
+ int8u format_effector_param_length;
+ Get_B1 (format_effector_param_length, "format_effector_param_length");
+ Skip_XX(format_effector_param_length, "format_effector_data");
+ }
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+//Modified Julian Date
+Ztring File_Mpeg_Psi::Date_MJD(int16u Date_)
+{
+ //Calculating
+ float64 Date=Date_;
+ int Y2=(int)((Date-15078.2)/365.25);
+ int M2=(int)(((Date-14956.1) - ((int)(Y2*365.25))) /30.6001);
+ int D =(int)(Date-14956 - ((int)(Y2*365.25)) - ((int)(M2*30.6001)));
+ int K=0;
+ if (M2==14 || M2==15)
+ K=1;
+ int Y =Y2+K;
+ int M =M2-1-K*12;
+
+ //Formating
+ return Ztring::ToZtring(1900+Y)+_T("-")
+ + (M<10?_T("0"):_T(""))+Ztring::ToZtring( M)+_T("-")
+ + (D<10?_T("0"):_T(""))+Ztring::ToZtring( D);
+}
+
+//---------------------------------------------------------------------------
+//Form: HHMMSS, BCD
+Ztring File_Mpeg_Psi::Time_BCD(int32u Time)
+{
+ return (((Time>>16)&0xFF)<10?_T("0"):_T("")) + Ztring::ToZtring((Time>>16)&0xFF, 16)+_T(":") //BCD
+ + (((Time>> 8)&0xFF)<10?_T("0"):_T("")) + Ztring::ToZtring((Time>> 8)&0xFF, 16)+_T(":") //BCD
+ + (((Time )&0xFF)<10?_T("0"):_T("")) + Ztring::ToZtring((Time )&0xFF, 16); //BCD
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::program_number_Update()
+{
+ //Setting the pid as program_map_section
+ if (Complete_Stream->Streams[elementary_PID]->Kind!=complete_stream::stream::psi)
+ {
+ Complete_Stream->Streams[elementary_PID]->Searching_Payload_Start_Set(true);
+ Complete_Stream->Streams[elementary_PID]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[elementary_PID]->Table_IDs.resize(0x100);
+ if (program_number)
+ Complete_Stream->Streams[elementary_PID]->Table_IDs[0x02]=new complete_stream::stream::table_id; //program_map_section
+ }
+ if (Complete_Stream->File__Duplicate_Get_From_PID(elementary_PID))
+ Complete_Stream->Streams[elementary_PID]->ShouldDuplicate=true;
+
+ //Handling a program
+ if (program_number)
+ {
+ Complete_Stream->Transport_Streams[table_id_extension].Programs_NotParsedCount++;
+ Complete_Stream->Transport_Streams[table_id_extension].Programs[program_number].pid=elementary_PID;
+ if (Complete_Stream->Streams.size()<0x2000)
+ Complete_Stream->Streams.resize(0x2000); //TODO: find the reason this code is called
+ Complete_Stream->Streams[elementary_PID]->program_numbers.push_back(program_number);
+ if (Complete_Stream->Streams[elementary_PID]->Table_IDs.size()<0x100)
+ Complete_Stream->Streams[elementary_PID]->Table_IDs.resize(0x100); //TODO: find the reason this code is called
+ if (Complete_Stream->Streams[elementary_PID]->Table_IDs[0x02]==NULL)
+ Complete_Stream->Streams[elementary_PID]->Table_IDs[0x02]=new complete_stream::stream::table_id; //TODO: find the reason this code is called
+ if (Complete_Stream->Streams[elementary_PID]->Table_IDs[0x02]->Table_ID_Extensions.find(program_number)==Complete_Stream->Streams[elementary_PID]->Table_IDs[0x02]->Table_ID_Extensions.end())
+ {
+ Complete_Stream->Streams[elementary_PID]->Table_IDs[0x02]->Table_ID_Extensions_CanAdd=false;
+ Complete_Stream->Streams[elementary_PID]->Table_IDs[0x02]->Table_ID_Extensions[program_number].version_number=0xFF;
+ Complete_Stream->Streams[elementary_PID]->Table_IDs[0x02]->Table_ID_Extensions[program_number].Section_Numbers.clear();
+ Complete_Stream->Streams[elementary_PID]->Table_IDs[0x02]->Table_ID_Extensions[program_number].Section_Numbers.resize(0x100);
+ }
+ }
+
+ //Handling a network except basic version
+ else if (Complete_Stream->Streams[elementary_PID]->Table_IDs[0x00]==NULL)
+ {
+ for (size_t Table_ID=1; Table_ID<0x100; Table_ID++)
+ {
+ if (Complete_Stream->Streams[elementary_PID]->Table_IDs[Table_ID]==NULL)
+ Complete_Stream->Streams[elementary_PID]->Table_IDs[Table_ID]=new complete_stream::stream::table_id; //all
+
+ if (Table_ID==1)
+ Table_ID++; //Skipping TableID 2
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::program_number_Remove()
+{
+ //Removing this program_number from the list of program_numbers for each elementary_PID
+ for (size_t Pos=0; Pos<Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].elementary_PIDs.size(); Pos++)
+ {
+ int16u elementary_PID_Temp=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].elementary_PIDs[Pos];
+
+ //Removing this program_number from the list of program_numbers for this elementary_PID
+ for (size_t Pos=0; Pos<Complete_Stream->Streams[elementary_PID_Temp]->program_numbers.size(); Pos++)
+ if (Complete_Stream->Streams[elementary_PID_Temp]->program_numbers[Pos]==program_number)
+ Complete_Stream->Streams[elementary_PID_Temp]->program_numbers.erase(Complete_Stream->Streams[elementary_PID_Temp]->program_numbers.begin()+Pos);
+
+ //Removing parser if no more program_number
+ if (Complete_Stream->Streams[elementary_PID_Temp]->program_numbers.empty())
+ {
+ stream_t StreamKind=Complete_Stream->Streams[elementary_PID_Temp]->StreamKind;
+ size_t StreamPos=Complete_Stream->Streams[elementary_PID_Temp]->StreamPos;
+ if (StreamKind!=Stream_Max && StreamPos!=(size_t)-1)
+ Complete_Stream->StreamPos_ToRemove[StreamKind].push_back(StreamPos);
+
+ if (Complete_Stream->Streams_NotParsedCount!=(size_t)-1 && Complete_Stream->Streams_NotParsedCount>0 && !Complete_Stream->Streams[elementary_PID_Temp]->IsParsed)
+ Complete_Stream->Streams_NotParsedCount--; //Not parsed, and no need to parse it now
+ delete Complete_Stream->Streams[elementary_PID_Temp]; Complete_Stream->Streams[elementary_PID_Temp]=new complete_stream::stream;
+ }
+ }
+
+ //Removing related PCR
+ std::map<int16u, int16u>::iterator PCR_PID=Complete_Stream->PCR_PIDs.find(Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].PCR_PID);
+ if (PCR_PID!=Complete_Stream->PCR_PIDs.end())
+ {
+ PCR_PID->second--;
+ if (PCR_PID->second==0)
+ Complete_Stream->PCR_PIDs.erase(PCR_PID);
+ }
+
+ //Removing program_number
+ size_t StreamPos=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].StreamPos;
+ if (StreamPos!=(size_t)-1)
+ {
+ Complete_Stream->StreamPos_ToRemove[Stream_Menu].push_back(StreamPos);
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].StreamPos=(size_t)-1;
+ }
+ int16u program_number_pid=Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].pid;
+ if (program_number_pid)
+ {
+ for (size_t Pos=0; Pos<Complete_Stream->Streams[program_number_pid]->program_numbers.size(); Pos++)
+ if (Complete_Stream->Streams[program_number_pid]->program_numbers[Pos]==program_number)
+ Complete_Stream->Streams[program_number_pid]->program_numbers.erase(Complete_Stream->Streams[program_number_pid]->program_numbers.begin()+Pos);
+ if (Complete_Stream->Streams[program_number_pid]->Table_IDs[0x02])
+ Complete_Stream->Streams[program_number_pid]->Table_IDs[0x02]->Table_ID_Extensions.erase(program_number);
+ }
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs.erase(program_number);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::elementary_PID_Update(int16u PCR_PID)
+{
+ if (Complete_Stream->Streams[elementary_PID]->Kind==complete_stream::stream::psi)
+ {
+ //A PID can not be PSI and PES at the same time
+ return;
+ }
+
+ //stream_type
+ if (stream_type!=Complete_Stream->Streams[elementary_PID]->stream_type && Complete_Stream->Streams[elementary_PID]->stream_type!=(int8u)-1)
+ {
+ if (Complete_Stream->Streams_NotParsedCount!=(size_t)-1 && Complete_Stream->Streams_NotParsedCount>0 && !Complete_Stream->Streams[elementary_PID]->IsParsed)
+ Complete_Stream->Streams_NotParsedCount--; //Not parsed, and no need to parse it now
+ delete Complete_Stream->Streams[elementary_PID]; Complete_Stream->Streams[elementary_PID]=new complete_stream::stream;
+ Complete_Stream->Streams[elementary_PID]->Kind=complete_stream::stream::unknown;
+ }
+ if (Complete_Stream->Streams[elementary_PID]->Kind!=complete_stream::stream::pes)
+ {
+ delete Complete_Stream->Streams[elementary_PID]; Complete_Stream->Streams[elementary_PID]=new complete_stream::stream;
+
+ if (Complete_Stream->Streams_NotParsedCount==(size_t)-1)
+ Complete_Stream->Streams_NotParsedCount=0;
+ Complete_Stream->Streams_NotParsedCount++;
+ if (stream_type==0x86 && Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].registration_format_identifier==Elements::CUEI)
+ {
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].Infos["SCTE35_PID"]=Ztring::ToZtring(elementary_PID);
+ Complete_Stream->Streams[elementary_PID]->Kind=complete_stream::stream::psi;
+ Complete_Stream->Streams[elementary_PID]->Table_IDs.resize(0x100);
+ Complete_Stream->Streams[elementary_PID]->Table_IDs[0xFC]=new complete_stream::stream::table_id; //Splice
+ if (Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].Scte35==NULL)
+ {
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].Scte35=new complete_stream::transport_stream::program::scte35;
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[table_id_extension].Scte35->pid=elementary_PID;
+ }
+ #if MEDIAINFO_TRACE
+ Complete_Stream->Streams[elementary_PID]->Element_Info1="PSI";
+ #endif //MEDIAINFO_TRACE
+ }
+ else
+ {
+ Complete_Stream->Streams[elementary_PID]->Kind=complete_stream::stream::pes;
+ Complete_Stream->Streams[elementary_PID]->Infos["CodecID"].From_Number(stream_type);
+ #if MEDIAINFO_TRACE
+ Complete_Stream->Streams[elementary_PID]->Element_Info1="PES";
+ #endif //MEDIAINFO_TRACE
+ }
+ Complete_Stream->Streams[elementary_PID]->stream_type=stream_type;
+ Complete_Stream->Streams[elementary_PID]->Searching_Payload_Start_Set(true);
+ #ifdef MEDIAINFO_MPEGTS_PCR_YES
+ Complete_Stream->Streams[elementary_PID]->Searching_TimeStamp_Start_Set(true);
+ Complete_Stream->Streams[elementary_PID]->PCR_PID=PCR_PID;
+ #endif //MEDIAINFO_MPEGTS_PCR_YES
+ #ifdef MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ //Complete_Stream->Streams[elementary_PID]->Searching_ParserTimeStamp_Start_Set(true);
+ #endif //MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+ if (Complete_Stream->File__Duplicate_Get_From_PID(elementary_PID))
+ Complete_Stream->Streams[elementary_PID]->ShouldDuplicate=true;
+ }
+
+ //Program information
+ bool IsAlreadyPresent=false;
+ for (size_t Pos=0; Pos<Complete_Stream->Streams[elementary_PID]->program_numbers.size(); Pos++)
+ if (Complete_Stream->Streams[elementary_PID]->program_numbers[Pos]==program_number)
+ IsAlreadyPresent=true;
+ if (!IsAlreadyPresent)
+ {
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].elementary_PIDs.push_back(elementary_PID);
+ Complete_Stream->Streams[elementary_PID]->program_numbers.push_back(program_number);
+ if (ForceStreamDisplay || (Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].registration_format_identifier==Elements::HDMV && Complete_Stream->Streams[elementary_PID]->stream_type==0x90)) //Testing if forcing display of all streams or if it is a PGS from Blu-ray
+ Complete_Stream->PES_PIDs.insert(elementary_PID); //Adding it for sure
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg_Psi::elementary_PID_Remove()
+{
+ //Removing this elementary_PID from the list of elementary_PIDs for this program_number
+ for (size_t Pos=0; Pos<Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].elementary_PIDs.size(); Pos++)
+ if (Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].elementary_PIDs[Pos]==elementary_PID)
+ Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].elementary_PIDs.erase(Complete_Stream->Transport_Streams[Complete_Stream->transport_stream_id].Programs[program_number].elementary_PIDs.begin()+Pos);
+
+ //Removing this program_number from the list of program_numbers for this elementary_PID
+ for (size_t Pos=0; Pos<Complete_Stream->Streams[elementary_PID]->program_numbers.size(); Pos++)
+ if (Complete_Stream->Streams[elementary_PID]->program_numbers[Pos]==program_number)
+ Complete_Stream->Streams[elementary_PID]->program_numbers.erase(Complete_Stream->Streams[elementary_PID]->program_numbers.begin()+Pos);
+
+ //Removing parser if no more program_number
+ if (Complete_Stream->Streams[elementary_PID]->program_numbers.empty())
+ {
+ stream_t StreamKind=Complete_Stream->Streams[elementary_PID]->StreamKind;
+ size_t StreamPos=Complete_Stream->Streams[elementary_PID]->StreamPos;
+ if (StreamKind!=Stream_Max && StreamPos!=(size_t)-1)
+ Complete_Stream->StreamPos_ToRemove[StreamKind].push_back(StreamPos);
+
+ if (Complete_Stream->Streams_NotParsedCount!=(size_t)-1 && Complete_Stream->Streams_NotParsedCount>0 && !Complete_Stream->Streams[elementary_PID]->IsParsed)
+ Complete_Stream->Streams_NotParsedCount--; //Not parsed, and no need to parse it now
+ delete Complete_Stream->Streams[elementary_PID]; Complete_Stream->Streams[elementary_PID]=new complete_stream::stream;
+ Complete_Stream->PES_PIDs.erase(elementary_PID);
+ }
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPEGTS_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Psi.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Psi.h
new file mode 100644
index 000000000..4ddce7c52
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mpeg_Psi.h
@@ -0,0 +1,183 @@
+// File_Mpeg_Psi - Info for MPEG Stream files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MPEG files, Program Map Section
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Mpeg_PsiH
+#define MediaInfo_Mpeg_PsiH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Multiple/File_Mpeg_Descriptors.h"
+#include <map>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Mpeg_Psi
+//***************************************************************************
+
+class File_Mpeg_Psi : public File__Analyze
+{
+public :
+ //In
+ bool From_TS;
+ complete_stream* Complete_Stream;
+ int16u pid;
+
+public :
+ File_Mpeg_Psi();
+ ~File_Mpeg_Psi();
+
+private :
+ //Buffer - File header
+ void FileHeader_Parse();
+
+ //Buffer - Per element
+ bool Header_Begin();
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements - Base
+ void Table_reserved();
+ void Table_iso13818_6();
+ void Table_user_private();
+ void Table_forbidden();
+
+ //Elements - MPEG
+ void program_stream_map(); //From PS
+ void Table_00();
+ void Table_01();
+ void Table_02();
+ void Table_03();
+ void Table_04() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_05() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_06() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ //Elements - DVB
+ void Table_38() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_39() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_3A() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_3B() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_3C() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_3D() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_3E() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_3F() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_40();
+ void Table_41() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_42();
+ void Table_46();
+ void Table_4A() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_4E();
+ void Table_4F();
+ void Table_5F(); //50 --> 5F
+ void Table_6F(); //60 --> 6F
+ void Table_70();
+ void Table_71() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_72() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_73();
+ void Table_74() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_75() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_76() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_77() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_78() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_79() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_7E() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_7F();
+ //Elements - ASTC
+ void Table_C0();
+ void Table_C1();
+ void Table_C2() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_C3() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_C4() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_C5() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_C6() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_C7();
+ void Table_C8() {Table_C9();};
+ void Table_C9();
+ void Table_CA();
+ void Table_CB();
+ void Table_CC();
+ void Table_CD();
+ void Table_CE() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_CF() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_D0() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_D1() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_D2() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_D3() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_D4() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_D5() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_D6();
+ void Table_D7() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_D8() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_D9() {Skip_XX(Element_Size-Element_Offset, "Data");};
+ void Table_DA() {Table_C9();};
+ void Table_FC();
+ void Table_FC_00();
+ void Table_FC_04();
+ void Table_FC_05();
+ void Table_FC_05_break_duration();
+ void Table_FC_05_splice_time();
+ void Table_FC_06();
+ void Table_FC_07();
+
+ //Helpers
+ int16u Descriptors_Size;
+ void Descriptors();
+ void ATSC_multiple_string_structure(Ztring &Value, const char* Info);
+ void SCTE_multilingual_text_string(int8u Size, Ztring &Value, const char* Info);
+ Ztring Date_MJD(int16u Date);
+ Ztring Time_BCD(int32u Time);
+
+ //Items removal
+ void program_number_Update();
+ void program_number_Remove();
+ void elementary_PID_Update(int16u PCR_PID);
+ void elementary_PID_Remove();
+
+ //Data
+ int32u CRC_32;
+ int16u transport_stream_id;
+ int16u table_id_extension;
+ int16u elementary_PID;
+ int16u program_number;
+ int8u stream_type;
+ int16u event_id;
+ int8u pointer_field;
+ int8u table_id;
+ int8u version_number;
+ bool current_next_indicator;
+ bool section_syntax_indicator;
+ bool elementary_PID_IsValid;
+ bool program_number_IsValid;
+ bool stream_type_IsValid;
+ bool event_id_IsValid;
+ bool IsATSC;
+ bool ForceStreamDisplay;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mxf.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mxf.cpp
new file mode 100644
index 000000000..49ddba5d8
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mxf.cpp
@@ -0,0 +1,9156 @@
+// File_Mxf - Info for MXF files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MXF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Mxf.h"
+#if defined(MEDIAINFO_DVDIF_YES)
+ #include "MediaInfo/Multiple/File_DvDif.h"
+#endif
+#if defined(MEDIAINFO_DVDIF_YES)
+ #include "MediaInfo/Multiple/File_DvDif.h"
+#endif
+#if defined(MEDIAINFO_AVC_YES)
+ #include "MediaInfo/Video/File_Avc.h"
+#endif
+#if defined(MEDIAINFO_MPEG4V_YES)
+ #include "MediaInfo/Video/File_Mpeg4v.h"
+#endif
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_VC3_YES)
+ #include "MediaInfo/Video/File_Vc3.h"
+#endif
+#if defined(MEDIAINFO_AAC_YES)
+ #include "MediaInfo/Audio/File_Aac.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_AES3_YES)
+ #include "MediaInfo/Audio/File_Aes3.h"
+#endif
+#if defined(MEDIAINFO_AES3_YES)
+ #include "MediaInfo/Audio/File_ChannelGrouping.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if defined(MEDIAINFO_PCM_YES)
+ #include "MediaInfo/Audio/File_Pcm.h"
+#endif
+#if defined(MEDIAINFO_JPEG_YES)
+ #include "MediaInfo/Image/File_Jpeg.h"
+#endif
+#include "MediaInfo/File_Unknown.h"
+#include "ZenLib/File.h"
+#include "ZenLib/FileName.h"
+#include "ZenLib/Dir.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/Multiple/File__ReferenceFilesHelper.h"
+#include "ZenLib/Format/Http/Http_Utils.h"
+#if MEDIAINFO_SEEK
+ #include <algorithm>
+#endif //MEDIAINFO_SEEK
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+//
+// PartitionPack
+// Primer
+// Preface
+// --> ContentStorage
+// --> Packages --> Package (Material, Source)
+// --> Tracks --> Track
+// --> Sequence
+// --> StructuralComponents --> StructuralComponent (Timecode, SourceClip)
+// --> Descriptors --> Descriptor (Multiple, Essence)
+// --> Descriptors --> Descriptor (Essence)
+// --> EssenceContainerData
+// --> Identifications --> Identification
+//
+//***************************************************************************
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+#define UUID(NAME, PART1, PART2, PART3, PART4) \
+ const int32u NAME##1=0x##PART1; \
+ const int32u NAME##2=0x##PART2; \
+ const int32u NAME##3=0x##PART3; \
+ const int32u NAME##4=0x##PART4; \
+
+namespace Elements
+{
+ //Item - Elements - Interpretive - Fundamental - Data Interpretations and Definitions - Name-Value Construct Interpretations
+ UUID(Ansi_01, 060E2B34, 01010105, 0301020A, 01000000)
+ UUID(UTF16_01, 060E2B34, 01010105, 0301020A, 01010000)
+ UUID(Ansi_02, 060E2B34, 01010105, 0301020A, 02000000)
+ UUID(UTF16_02, 060E2B34, 01010105, 0301020A, 02010000)
+
+ //Item - Elements - Interpretive - Fundamental - Data Interpretations and Definitions - KLV Interpretations
+ UUID(Filler01, 060E2B34, 01010101, 03010210, 01000000)
+ UUID(Filler02, 060E2B34, 01010102, 03010210, 01000000)
+ UUID(TerminatingFiller, 060E2B34, 01010102, 03010210, 05000000)
+
+ //Item - Elements - Interpretive - Fundamental - Data Interpretations and Definitions - XML Constructs and Interpretations
+ UUID(XmlDocumentText, 060E2B34, 01010105, 03010220, 01000000)
+
+ //Item - Elements - User organization registred for public use - AAF Association - Generic Container - Version 1
+ UUID(GenericContainer_Aaf, 060E2B34, 01020101, 0D010301, 00000000)
+
+ //Item - Elements - User organization registred for private use - Avid - Generic Container - Version 1
+ UUID(GenericContainer_Avid, 060E2B34, 01020101, 0E040301, 00000000)
+
+ //Item - Elements - Parametric - Video and Image Essence Characteristics - Digital Video and Image Compression Parameters - MPEG Coding Parameters - MPEG-2 Coding Parameters
+ UUID(MPEG2VideoDescriptor_SingleSequence, 060E2B34, 01010105, 04010602, 01020000)
+ UUID(MPEG2VideoDescriptor_ConstantBFrames, 060E2B34, 01010105, 04010602, 01030000)
+ UUID(MPEG2VideoDescriptor_CodedContentType, 060E2B34, 01010105, 04010602, 01040000)
+ UUID(MPEG2VideoDescriptor_LowDelay, 060E2B34, 01010105, 04010602, 01050000)
+ UUID(MPEG2VideoDescriptor_ClosedGOP, 060E2B34, 01010105, 04010602, 01060000)
+ UUID(MPEG2VideoDescriptor_IdenticalGOP, 060E2B34, 01010105, 04010602, 01070000)
+ UUID(MPEG2VideoDescriptor_MaxGOP, 060E2B34, 01010105, 04010602, 01080000)
+ UUID(MPEG2VideoDescriptor_BPictureCount, 060E2B34, 01010105, 04010602, 01090000)
+ UUID(MPEG2VideoDescriptor_ProfileAndLevel, 060E2B34, 01010105, 04010602, 010A0000)
+ UUID(MPEG2VideoDescriptor_BitRate, 060E2B34, 01010105, 04010602, 010B0000)
+
+ //Groups - Elements - User organization registred for public use - AAF Association - AAF Attributes - AAF Information Attributes - Version 1 - Enumerated Attributes
+ UUID(Sequence, 060E2B34, 02530101, 0D010101, 01010F00)
+ UUID(SourceClip, 060E2B34, 02530101, 0D010101, 01011100)
+ UUID(TimecodeComponent, 060E2B34, 02530101, 0D010101, 01011400)
+ UUID(ContentStorage, 060E2B34, 02530101, 0D010101, 01011800)
+ UUID(EssenceContainerData, 060E2B34, 02530101, 0D010101, 01012300)
+ UUID(CDCIEssenceDescriptor, 060E2B34, 02530101, 0D010101, 01012800)
+ UUID(RGBAEssenceDescriptor, 060E2B34, 02530101, 0D010101, 01012900)
+ UUID(Preface, 060E2B34, 02530101, 0D010101, 01012F00)
+ UUID(Identification, 060E2B34, 02530101, 0D010101, 01013000)
+ UUID(NetworkLocator, 060E2B34, 02530101, 0D010101, 01013200)
+ UUID(TextLocator, 060E2B34, 02530101, 0D010101, 01013300)
+ UUID(MaterialPackage, 060E2B34, 02530101, 0D010101, 01013600)
+ UUID(SourcePackage, 060E2B34, 02530101, 0D010101, 01013700)
+ UUID(EventTrack, 060E2B34, 02530101, 0D010101, 01013900)
+ UUID(StaticTrack, 060E2B34, 02530101, 0D010101, 01013A00)
+ UUID(Track, 060E2B34, 02530101, 0D010101, 01013B00)
+ UUID(DMSegment, 060E2B34, 02530101, 0D010101, 01014100)
+ UUID(GenericSoundEssenceDescriptor, 060E2B34, 02530101, 0D010101, 01014200)
+ UUID(MultipleDescriptor, 060E2B34, 02530101, 0D010101, 01014400)
+ UUID(AES3PCMDescriptor, 060E2B34, 02530101, 0D010101, 01014700)
+ UUID(WaveAudioDescriptor, 060E2B34, 02530101, 0D010101, 01014800)
+ UUID(MPEG2VideoDescriptor, 060E2B34, 02530101, 0D010101, 01015100)
+ UUID(JPEG2000PictureSubDescriptor, 060E2B34, 02530101, 0D010101, 01015A00)
+ UUID(Unknown1, 060E2B34, 02530101, 0D010101, 01015B00)
+ UUID(AncPacketsDescriptor, 060E2B34, 02530101, 0D010101, 01015C00)
+
+ //Groups - Elements - User organization registred for public use - AAF Association - ? - Version 1 - ?
+ UUID(OpenIncompleteHeaderPartition, 060E2B34, 02050101, 0D010201, 01020100)
+ UUID(ClosedIncompleteHeaderPartition, 060E2B34, 02050101, 0D010201, 01020200)
+ UUID(OpenCompleteHeaderPartition, 060E2B34, 02050101, 0D010201, 01020300)
+ UUID(ClosedCompleteHeaderPartition, 060E2B34, 02050101, 0D010201, 01020400)
+ UUID(OpenIncompleteBodyPartition, 060E2B34, 02050101, 0D010201, 01030100)
+ UUID(ClosedIncompleteBodyPartition, 060E2B34, 02050101, 0D010201, 01030200)
+ UUID(OpenCompleteBodyPartition, 060E2B34, 02050101, 0D010201, 01030300)
+ UUID(ClosedCompleteBodyPartition, 060E2B34, 02050101, 0D010201, 01030400)
+ UUID(OpenIncompleteFooterPartition, 060E2B34, 02050101, 0D010201, 01040100)
+ UUID(ClosedIncompleteFooterPartition, 060E2B34, 02050101, 0D010201, 01040200)
+ UUID(OpenCompleteFooterPartition, 060E2B34, 02050101, 0D010201, 01040300)
+ UUID(ClosedCompleteFooterPartition, 060E2B34, 02050101, 0D010201, 01040400)
+
+ //Groups - Elements - User organization registred for public use - AAF Association - ? - Version 1 - ?
+ UUID(Primer, 060E2B34, 02050101, 0D010201, 01050100)
+
+ //Groups - Elements - User organization registred for public use - AAF Association - ? - Version 1 - ?
+ UUID(IndexTableSegment, 060E2B34, 02530101, 0D010201, 01100100)
+
+ //Groups - Elements - User organization registred for public use - AAF Association - ? - Version 1 - ?
+ UUID(RandomIndexMetadata, 060E2B34, 02050101, 0D010201, 01110100)
+
+ //Groups - Elements - User organization registred for public use - AAF Association - ? - Version 1 - ? (SDTI-CP (SMPTE 385M))
+ UUID(SDTI_SystemMetadataPack, 060E2B34, 02050101, 0D010301, 04010100)
+ UUID(SDTI_PackageMetadataSet, 060E2B34, 02430101, 0D010301, 04010200)
+ UUID(SDTI_PictureMetadataSet, 060E2B34, 02430101, 0D010301, 04010300)
+ UUID(SDTI_SoundMetadataSet, 060E2B34, 02430101, 0D010301, 04010400)
+ UUID(SDTI_DataMetadataSet, 060E2B34, 02430101, 0D010301, 04010500)
+ UUID(SDTI_ControlMetadataSet, 060E2B34, 02630101, 0D010301, 04010600)
+
+ //Groups - Elements - User organization registred for public use - AAF Association - ? - Version 1 - ? (SystemScheme (SMPTE 405M))
+ UUID(SystemScheme1, 060E2B34, 02530101, 0D010301, 14020100)
+
+ //Groups - Elements - User organization registred for private use - Omneon Video Networks
+ UUID(Omneon_010201010100, 060E2B34, 02530105, 0E0B0102, 01010100)
+ UUID(Omneon_010201020100, 060E2B34, 02530105, 0E0B0102, 01020100)
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_Category(int8u Category)
+{
+ switch(Category)
+ {
+ case 0x01 : return "Item";
+ case 0x02 : return "Group (Set/Pack)";
+ case 0x03 : return "Wrapper";
+ case 0x04 : return "Value";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_Registry(int8u Category, int8u Registry)
+{
+ switch(Category)
+ {
+ case 0x01 : //"Item"
+ switch(Registry)
+ {
+ case 0x01 : return "Metadata";
+ case 0x02 : return "Essence";
+ default : return "";
+ }
+ case 0x02 : //"Group (Set/Pack)"
+ switch(Registry)
+ {
+ case 0x05 : return "Predefined items";
+ case 0x43 : return "1-byte tag, 2-byte length";
+ case 0x53 : return "2-byte tag, 2-byte length";
+ case 0x63 : return "1-byte tag, 4-byte length";
+ default : return "";
+ }
+ case 0x04 : //"Value"
+ switch(Registry)
+ {
+ case 0x01 : return "Fixed";
+ default : return "";
+ }
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_Structure(int8u Category, int8u Registry, int8u Structure)
+{
+ switch(Category)
+ {
+ case 0x01 : //"Item"
+ switch(Registry)
+ {
+ case 0x02 : //Essence
+ switch(Structure)
+ {
+ case 0x01 : return "Standard";
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_MPEG2_CodedContentType(int8u CodedContentType)
+{
+ switch(CodedContentType)
+ {
+ case 0x01 : return "Progressive";
+ case 0x02 : return "Interlaced";
+ case 0x03 : return ""; //Mixed
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_OperationalPattern(int128u OperationalPattern)
+{
+ //Item and Package Complexity
+ int32u Code_Compare4=(int32u)OperationalPattern.lo;
+ switch ((int8u)(Code_Compare4>>24))
+ {
+ case 0x01 : switch ((int8u)(Code_Compare4>>16))
+ {
+ case 0x01 : return "OP-1a";
+ case 0x02 : return "OP-1b";
+ case 0x03 : return "OP-1c";
+ default : return "";
+ }
+ case 0x02 : switch ((int8u)(Code_Compare4>>16))
+ {
+ case 0x01 : return "OP-2a";
+ case 0x02 : return "OP-2b";
+ case 0x03 : return "OP-2c";
+ default : return "";
+ }
+ case 0x03 : switch ((int8u)(Code_Compare4>>16))
+ {
+ case 0x01 : return "OP-3a";
+ case 0x02 : return "OP-3b";
+ case 0x03 : return "OP-3c";
+ default : return "";
+ }
+ case 0x10 : return "OP-Atom";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_EssenceElement(int128u EssenceElement)
+{
+ if ((EssenceElement.hi&0xFFFFFFFFFFFFFF00LL)!=0x060E2B3401020100LL)
+ return "";
+
+ int8u Code5=(int8u)((EssenceElement.lo&0x00000000FF000000LL)>>24);
+ int8u Code7=(int8u)((EssenceElement.lo&0x000000000000FF00LL)>> 8);
+
+ switch (Code5)
+ {
+ case 0x05 : //CP Picture (SMPTE 326M)
+ switch (Code7)
+ {
+ case 0x01 : return "D-10 Video";
+ default : return "Unknown stream";
+ }
+ case 0x06 : //CP Sound (SMPTE 326M)
+ switch (Code7)
+ {
+ case 0x10 : return "D-10 Audio";
+ default : return "Unknown stream";
+ }
+ case 0x07 : //CP Data (SMPTE 326M)
+ return "";
+ case 0x14 : //MXF in MXF?
+ switch (Code7)
+ {
+ case 0x01 : return "MXF in MXF?";
+ default : return "Unknown stream";
+ }
+ case 0x15 : //GC Picture
+ switch (Code7)
+ {
+ case 0x01 : return "RGB";
+ case 0x05 : return "MPEG stream (Frame)";
+ case 0x06 : return "MPEG stream (Clip)";
+ case 0x07 : return "MPEG stream (Custom)";
+ case 0x08 : return "JPEG 2000";
+ default : return "Unknown stream";
+ }
+ case 0x16 : //GC Sound
+ switch (Code7)
+ {
+ case 0x01 : return "PCM"; //BWF
+ case 0x02 : return "PCM"; //BWF
+ case 0x03 : return "PCM"; //DV Audio
+ case 0x04 : return "PCM"; //BWF
+ case 0x05 : return "MPEG Audio / AC-3";
+ case 0x0A : return "A-law";
+ default : return "Unknown stream";
+ }
+ case 0x17 : //GC Data
+ switch (Code7)
+ {
+ case 0x02 : return "ANC"; //Frame-Wrapped ANC Data Element
+ default : return "Unknown stream";
+ }
+ case 0x18 : //GC Compound
+ switch (Code7)
+ {
+ case 0x01 : return "DV"; //Frame
+ case 0x02 : return "DV"; //Clip
+ default : return "Unknown stream";
+ }
+ default : return "Unknown stream";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_EssenceContainer(int128u EssenceContainer)
+{
+ if ((EssenceContainer.hi&0xFFFFFFFFFFFFFF00LL)!=0x060E2B3404010100LL)
+ return "";
+
+ int8u Code1=(int8u)((EssenceContainer.lo&0xFF00000000000000LL)>>56);
+ int8u Code2=(int8u)((EssenceContainer.lo&0x00FF000000000000LL)>>48);
+ int8u Code3=(int8u)((EssenceContainer.lo&0x0000FF0000000000LL)>>40);
+ int8u Code4=(int8u)((EssenceContainer.lo&0x000000FF00000000LL)>>32);
+ int8u Code5=(int8u)((EssenceContainer.lo&0x00000000FF000000LL)>>24);
+ int8u Code6=(int8u)((EssenceContainer.lo&0x0000000000FF0000LL)>>16);
+ //int8u Code7=(int8u)((EssenceContainer.lo&0x000000000000FF00LL)>> 8);
+
+ switch (Code1)
+ {
+ case 0x0D : //Public Use
+ switch (Code2)
+ {
+ case 0x01 : //AAF
+ switch (Code3)
+ {
+ case 0x03 : //Essence Container Application
+ switch (Code4)
+ {
+ case 0x01 : //MXF EC Structure version
+ switch (Code5)
+ {
+ case 0x02 : //Essence container kind
+ switch (Code6)
+ {
+ case 0x01 : return "D-10 Audio";
+ case 0x02 : return "DV";
+ case 0x05 : return "Uncompressed pictures";
+ case 0x06 : return "PCM";
+ case 0x04 : return "MPEG ES mappings with Stream ID";
+ case 0x0A : return "A-law";
+ case 0x0C : return "JPEG 2000";
+ case 0x11 : return "VC-3";
+ case 0x16 : return "AVC";
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ case 0x0E : //Private Use
+ switch (Code2)
+ {
+ case 0x04 : //Avid
+ switch (Code3)
+ {
+ case 0x03 : //Essence Container Application
+ switch (Code4)
+ {
+ case 0x01 : //MXF EC Structure version
+ switch (Code5)
+ {
+ case 0x02 : //Essence container kind
+ switch (Code6)
+ {
+ case 0x06 : return "VC-3";
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_EssenceContainer_Mapping(int8u Code6, int8u Code7, int8u Code8)
+{
+ switch (Code6)
+ {
+ case 0x01 : //D-10, SMPTE 386M
+ return "Frame (D-10)";
+ case 0x02 : //DV, SMPTE 383M
+ switch (Code8)
+ {
+ case 0x01 : return "Frame";
+ case 0x02 : return "Clip";
+ default : return "";
+ }
+ case 0x04 : //MPEG ES, SMPTE 381M
+ case 0x07 : //MPEG PES, SMPTE 381M
+ case 0x08 : //MPEG PS, SMPTE 381M
+ case 0x09 : //MPEG TS, SMPTE 381M
+ case 0x10 : //AVC
+ case 0x15 : //YUV
+ switch (Code8)
+ {
+ case 0x01 : return "Frame";
+ case 0x02 : return "Clip";
+ case 0x03 : return "Custom: Stripe";
+ case 0x04 : return "Custom: PES";
+ case 0x05 : return "Custom: Fixed Audio Size";
+ case 0x06 : return "Custom: Splice";
+ case 0x07 : return "Custom: Closed GOP";
+ case 0x08 : return "Custom: Slave";
+ case 0x7F : return "Custom";
+ default : return "";
+ }
+ case 0x05 : //Uncompressed pictures, SMPTE 384M
+ switch (Code8)
+ {
+ case 0x01 : return "Frame";
+ case 0x02 : return "Clip";
+ case 0x03 : return "Line";
+ default : return "";
+ }
+ case 0x06 : //AES-PCM, SMPTE 382M
+ switch (Code7)
+ {
+ case 0x01 : return "Frame (BWF)";
+ case 0x02 : return "Clip (BWF)";
+ case 0x03 : return "Frame (AES)";
+ case 0x04 : return "Clip (AES)";
+ case 0x08 : return "Custom (BWF)";
+ case 0x09 : return "Custom (AES)";
+ default : return "";
+ }
+ case 0x0A : //A-Law
+ switch (Code7)
+ {
+ case 0x01 : return "Frame";
+ case 0x02 : return "Clip";
+ case 0x03 : return "?";
+ case 0x07 : return "Custom";
+ default : return "";
+ }
+ case 0x0C : //JPEG 2000
+ switch (Code7)
+ {
+ case 0x01 : return "Frame";
+ case 0x02 : return "Clip";
+ default : return "";
+ }
+ case 0x11 : //VC-3, SMPTE 2019-4
+ switch (Code7)
+ {
+ case 0x01 : return "Frame";
+ case 0x02 : return "Clip";
+ default : return "";
+ }
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_EssenceCompression(int128u EssenceCompression)
+{
+ if ((EssenceCompression.hi&0xFFFFFFFFFFFFFF00LL)!=0x060E2B3404010100LL || !((EssenceCompression.lo&0xFF00000000000000LL)==0x0400000000000000LL || (EssenceCompression.lo&0xFF00000000000000LL)==0x0E00000000000000LL))
+ return "";
+
+ int8u Code1=(int8u)((EssenceCompression.lo&0xFF00000000000000LL)>>56);
+ int8u Code2=(int8u)((EssenceCompression.lo&0x00FF000000000000LL)>>48);
+ int8u Code3=(int8u)((EssenceCompression.lo&0x0000FF0000000000LL)>>40);
+ int8u Code4=(int8u)((EssenceCompression.lo&0x000000FF00000000LL)>>32);
+ int8u Code5=(int8u)((EssenceCompression.lo&0x00000000FF000000LL)>>24);
+ int8u Code6=(int8u)((EssenceCompression.lo&0x0000000000FF0000LL)>>16);
+ int8u Code7=(int8u)((EssenceCompression.lo&0x000000000000FF00LL)>> 8);
+
+ switch (Code1)
+ {
+ case 0x04 : //
+ switch (Code2)
+ {
+ case 0x01 : //Picture
+ switch (Code3)
+ {
+ case 0x02 : //Coding characteristics
+ switch (Code4)
+ {
+ case 0x01 : //Uncompressed coding
+ switch (Code5)
+ {
+ case 0x01 : //Uncompressed picture coding
+ return "YUV";
+ default : return "";
+ }
+ case 0x02 : //Compressed coding
+ switch (Code5)
+ {
+ case 0x01 : //MPEG Compression
+ switch (Code6)
+ {
+ case 0x01 : return "MPEG Video"; //Version 2
+ case 0x02 : return "MPEG Video"; //Version 2
+ case 0x03 : return "MPEG Video"; //Version 2
+ case 0x04 : return "MPEG Video"; //Version 2
+ case 0x11 : return "MPEG Video"; //Version 1
+ case 0x20 : return "MPEG-4 Visual";
+ case 0x32 : return "AVC";
+ default : return "";
+ }
+ case 0x02 : return "DV";
+ case 0x03 : //Individual Picture Coding Schemes
+ switch (Code6)
+ {
+ case 0x01 : return "JPEG 2000";
+ default : return "";
+ }
+ case 0x71 : return "VC-3";
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ case 0x02 : //Sound
+ switch (Code3)
+ {
+ case 0x02 : //Coding characteristics
+ switch (Code4)
+ {
+ case 0x01 : //Uncompressed Sound Coding
+ switch (Code5)
+ {
+ case 0x00 : return "PCM";
+ case 0x01 : return "PCM";
+ case 0x7E : return "PCM"; //AIFF
+ case 0x7F : return "PCM";
+ default : return "";
+ }
+ case 0x02 : //Compressed coding
+ switch (Code5)
+ {
+ case 0x03 : //Compressed Audio Coding
+ switch (Code6)
+ {
+ case 0x01 : //Compandeded Audio Coding
+ switch (Code7)
+ {
+ case 0x01 : return "A-law";
+ case 0x10 : return "DV Audio"; //DV 12-bit
+ default : return ""; //Unknown
+ }
+ case 0x02 : //SMPTE 338M Audio Coding
+ switch (Code7)
+ {
+ case 0x01 : return "AC-3";
+ case 0x04 : return "MPEG-1 Audio Layer 1";
+ case 0x05 : return "MPEG-1 Audio Layer 2 or 3";
+ case 0x06 : return "MPEG-2 Audio Layer 1";
+ case 0x1C : return "Dolby E";
+ default : return ""; //Unknown
+ }
+ case 0x03 : //MPEG-2 Coding (not defined in SMPTE 338M)
+ switch (Code7)
+ {
+ case 0x01 : return "AAC version 2";
+ default : return ""; //Unknown
+ }
+ case 0x04 : //MPEG-4 Audio Coding
+ switch (Code7)
+ {
+ case 0x01 : return "MPEG-4 Speech Profile";
+ case 0x02 : return "MPEG-4 Synthesis Profile";
+ case 0x03 : return "MPEG-4 Scalable Profile";
+ case 0x04 : return "MPEG-4 Main Profile";
+ case 0x05 : return "MPEG-4 High Quality Audio Profile";
+ case 0x06 : return "MPEG-4 Low Delay Audio Profile";
+ case 0x07 : return "MPEG-4 Natural Audio Profile";
+ case 0x08 : return "MPEG-4 Mobile Audio Internetworking Profile";
+ default : return ""; //Unknown
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ case 0x0E : //Private Use
+ switch (Code2)
+ {
+ case 0x04 : //Avid
+ switch (Code3)
+ {
+ case 0x02 : //Essence Compression ?
+ switch (Code4)
+ {
+ case 0x01 : //?
+ switch (Code5)
+ {
+ case 0x02 : //?
+ switch (Code6)
+ {
+ case 0x04 : return "VC-3";
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_EssenceCompression_Version(int128u EssenceCompression)
+{
+ int8u Code2=(int8u)((EssenceCompression.lo&0x00FF000000000000LL)>>48);
+ int8u Code3=(int8u)((EssenceCompression.lo&0x0000FF0000000000LL)>>40);
+ int8u Code4=(int8u)((EssenceCompression.lo&0x000000FF00000000LL)>>32);
+ int8u Code5=(int8u)((EssenceCompression.lo&0x00000000FF000000LL)>>24);
+ int8u Code6=(int8u)((EssenceCompression.lo&0x0000000000FF0000LL)>>16);
+ int8u Code7=(int8u)((EssenceCompression.lo&0x000000000000FF00LL)>> 8);
+
+ switch (Code2)
+ {
+ case 0x01 : //Picture
+ switch (Code3)
+ {
+ case 0x02 : //Coding characteristics
+ switch (Code4)
+ {
+ case 0x02 : //Compressed coding
+ switch (Code5)
+ {
+ case 0x01 : //MPEG Compression
+ switch (Code6)
+ {
+ case 0x01 : return "Version 2";
+ case 0x02 : return "Version 2";
+ case 0x03 : return "Version 2";
+ case 0x04 : return "Version 2";
+ case 0x11 : return "Version 1";
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ case 0x02 : //Sound
+ switch (Code3)
+ {
+ case 0x02 : //Coding characteristics
+ switch (Code4)
+ {
+ case 0x02 : //Compressed coding
+ switch (Code5)
+ {
+ case 0x03 : //Compressed Audio Coding
+ switch (Code6)
+ {
+ case 0x02 : //SMPTE 338M Audio Coding
+ switch (Code7)
+ {
+ case 0x04 : return "Version 1"; //Layer 1
+ case 0x05 : return "Version 1"; //Layer 2 or 3
+ case 0x06 : return "Version 2"; //Layer 1
+ default : return ""; //Unknown
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_Sequence_DataDefinition(int128u DataDefinition)
+{
+ int8u Code4=(int8u)((DataDefinition.lo&0x000000FF00000000LL)>>32);
+ int8u Code5=(int8u)((DataDefinition.lo&0x00000000FF000000LL)>>24);
+
+ switch (Code4)
+ {
+ case 0x01 : return "Time";
+ case 0x02 :
+ switch (Code5)
+ {
+ case 0x01 : return "Picture";
+ case 0x02 : return "Sound";
+ case 0x03 : return "Data";
+ default : return "";
+ }
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_FrameLayout(int8u FrameLayout)
+{
+ switch (FrameLayout)
+ {
+ case 0x00 : return "Full frame";
+ case 0x01 : return "Separated fields";
+ case 0x02 : return "Single field";
+ case 0x03 : return "Mixed fields";
+ case 0x04 : return "Segmented frame";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mxf_FrameLayout_ScanType(int8u FrameLayout)
+{
+ switch (FrameLayout)
+ {
+ case 0x01 :
+ case 0x04 :
+ case 0xFF : //Seen in one file
+ return "Interlaced";
+ default :
+ return "Progressive";
+ }
+}
+
+//---------------------------------------------------------------------------
+int8u Mxf_FrameLayout_Multiplier(int8u FrameLayout)
+{
+ switch (FrameLayout)
+ {
+ case 0x01 :
+ case 0x04 :
+ case 0xFF : //Seen in one file
+ return 2;
+ default :
+ return 1;
+ }
+}
+
+//---------------------------------------------------------------------------
+extern const char* Mpegv_profile_and_level_indication_profile[];
+extern const char* Mpegv_profile_and_level_indication_level[];
+
+//---------------------------------------------------------------------------
+extern const char* AfdBarData_active_format[];
+extern const char* AfdBarData_active_format_4_3[];
+extern const char* AfdBarData_active_format_16_9[];
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Mxf::File_Mxf()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("MXF");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Mxf;
+ StreamIDs_Width[0]=8;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ #endif //MEDIAINFO_DEMUX
+ MustSynchronize=true;
+ DataMustAlwaysBeComplete=false;
+ Buffer_MaximumSize=16*1024*1024; //Some big frames are possible (e.g YUV 4:2:2 10 bits 1080p)
+ Buffer_TotalBytes_Fill_Max=(int64u)-1; //Disabling this feature for this format, this is done in the parser
+ FrameInfo.DTS=0;
+ Frame_Count_NotParsedIncluded=0;
+ #if MEDIAINFO_DEMUX
+ Demux_EventWasSent_Accept_Specific=true;
+ #endif //MEDIAINFO_DEMUX
+
+ //Temp
+ RandomIndexMetadatas_AlreadyParsed=false;
+ Streams_Count=(size_t)-1;
+ OperationalPattern=0;
+ Buffer_Begin=(int64u)-1;
+ Buffer_End=0;
+ Buffer_Header_Size=0;
+ Preface_Current.hi=0;
+ Preface_Current.lo=0;
+ IsParsingMiddle_MaxOffset=(int64u)-1;
+ Track_Number_IsAvailable=false;
+ IsParsingEnd=false;
+ IsCheckingRandomAccessTable=false;
+ IsCheckingFooterPartitionAddress=false;
+ FooterPartitionAddress_Jumped=false;
+ PartitionPack_Parsed=false;
+ IdIsAlwaysSame_Offset=0;
+ PartitionMetadata_PreviousPartition=(int64u)-1;
+ PartitionMetadata_FooterPartition=(int64u)-1;
+ TimeCode_StartTimecode=(int64u)-1;
+ TimeCode_RoundedTimecodeBase=0;
+ TimeCode_DropFrame=false;
+ DTS_Delay=0;
+ StreamPos_StartAtOne=true;
+ SDTI_TimeCode_StartTimecode=(int64u)-1;
+ SDTI_SizePerFrame=0;
+ SDTI_IsPresent=false;
+ SDTI_IsInIndexStreamOffset=true;
+ SystemScheme1_TimeCodeArray_StartTimecode=(int64u)-1;
+ SystemScheme1_FrameRateFromDescriptor=0;
+ Essences_FirstEssence_Parsed=false;
+ ReferenceFiles=NULL;
+ #if MEDIAINFO_NEXTPACKET
+ ReferenceFiles_IsParsing=false;
+ #endif //MEDIAINFO_NEXTPACKET
+ #if defined(MEDIAINFO_ANCILLARY_YES)
+ Ancillary=NULL;
+ Ancillary_IsBinded=false;
+ #endif //defined(MEDIAINFO_ANCILLARY_YES)
+
+ #if MEDIAINFO_DEMUX
+ Demux_HeaderParsed=false;
+ #endif //MEDIAINFO_DEMUX
+
+ Partitions_Pos=0;
+ Partitions_IsCalculatingHeaderByteCount=false;
+ Partitions_IsCalculatingSdtiByteCount=false;
+ Partitions_IsFooter=false;
+
+ #if MEDIAINFO_SEEK
+ IndexTables_Pos=0;
+ Clip_Header_Size=0;
+ Clip_Begin=(int64u)-1;
+ Clip_End=0;
+ OverallBitrate_IsCbrForSure=0;
+ Duration_Detected=false;
+ #endif //MEDIAINFO_SEEK
+}
+
+//---------------------------------------------------------------------------
+File_Mxf::~File_Mxf()
+{
+ delete ReferenceFiles;
+ if (!Ancillary_IsBinded)
+ delete Ancillary;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Fill()
+{
+ for (essences::iterator Essence=Essences.begin(); Essence!=Essences.end(); Essence++)
+ if (Essence->second.Parser)
+ Fill(Essence->second.Parser);
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Finish()
+{
+ #if MEDIAINFO_NEXTPACKET
+ //Locators only
+ if (ReferenceFiles_IsParsing)
+ {
+ ReferenceFiles->ParseReferences();
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return;
+ #endif //MEDIAINFO_DEMUX
+
+ Streams_Finish_CommercialNames();
+ return;
+ }
+ #endif //MEDIAINFO_NEXTPACKET
+
+ //Per stream
+ for (essences::iterator Essence=Essences.begin(); Essence!=Essences.end(); Essence++)
+ if (Essence->second.Parser)
+ {
+ if (!Essence->second.Parser->Status[IsFinished])
+ {
+ int64u File_Size_Temp=File_Size;
+ File_Size=File_Offset+Buffer_Offset+Element_Offset;
+ Open_Buffer_Continue(Essence->second.Parser, Buffer, 0);
+ File_Size=File_Size_Temp;
+ Finish(Essence->second.Parser);
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return;
+ #endif //MEDIAINFO_DEMUX
+ }
+ }
+
+ if (!Track_Number_IsAvailable)
+ {
+ if (Tracks.empty())
+ {
+ for (essences::iterator Essence=Essences.begin(); Essence!=Essences.end(); Essence++)
+ if (Essence->second.Parser)
+ Merge(*Essence->second.Parser);
+ }
+ else
+ for (tracks::iterator Track=Tracks.begin(); Track!=Tracks.end(); Track++)
+ {
+ //Searching the corresponding Descriptor
+ stream_t StreamKind=Stream_Max;
+ for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ if (Descriptor->second.LinkedTrackID==Track->second.TrackID)
+ {
+ StreamKind=Descriptor->second.StreamKind;
+ break;
+ }
+ if (StreamKind!=Stream_Max)
+ {
+ for (essences::iterator Essence=Essences.begin(); Essence!=Essences.end(); Essence++)
+ if (Essence->second.StreamKind==StreamKind && !Essence->second.Track_Number_IsMappedToTrack)
+ {
+ Track->second.TrackNumber=Essence->first;
+ Essence->second.Track_Number_IsMappedToTrack=true;
+ break;
+ }
+ }
+ }
+ }
+
+ File_Size_Total=File_Size;
+ StreamKind_Last=Stream_Max;
+ StreamPos_Last=(size_t)-1;
+
+ Streams_Finish_Preface(Preface_Current);
+
+ //OperationalPattern
+ Fill(Stream_General, 0, General_Format_Profile, Mxf_OperationalPattern(OperationalPattern));
+
+ //Parsing locators
+ Locators_Test();
+ #if MEDIAINFO_NEXTPACKET
+ if (Config->NextPacket_Get() && ReferenceFiles && !ReferenceFiles->References.empty())
+ {
+ ReferenceFiles_IsParsing=true;
+ return;
+ }
+ #endif //MEDIAINFO_NEXTPACKET
+
+ //Commercial names
+ Streams_Finish_CommercialNames();
+
+ //Handling separate streams
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Count_Get((stream_t)StreamKind); StreamPos++)
+ if (Retrieve((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_StreamSize_Encoded)).empty() && !Retrieve((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_BitRate_Encoded)).empty() && !Retrieve((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_Duration)).empty())
+ {
+ float64 BitRate_Encoded=Retrieve((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_BitRate_Encoded)).To_float64();
+ float64 Duration=Retrieve((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_Duration)).To_float64();
+ if (Duration)
+ Fill((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_StreamSize_Encoded), BitRate_Encoded/8*(Duration/1000), 3);
+ }
+
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Finish_Preface (int128u PrefaceUID)
+{
+ prefaces::iterator Preface=Prefaces.find(PrefaceUID);
+ if (Preface==Prefaces.end())
+ return;
+
+ //ContentStorage
+ Streams_Finish_ContentStorage(Preface->second.ContentStorage);
+
+ //Identifications
+ for (size_t Pos=0; Pos<Preface->second.Identifications.size(); Pos++)
+ Streams_Finish_Identification(Preface->second.Identifications[Pos]);
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Finish_ContentStorage (int128u ContentStorageUID)
+{
+ contentstorages::iterator ContentStorage=ContentStorages.find(ContentStorageUID);
+ if (ContentStorage==ContentStorages.end())
+ return;
+
+ for (size_t Pos=0; Pos<ContentStorage->second.Packages.size(); Pos++)
+ Streams_Finish_Package(ContentStorage->second.Packages[Pos]);
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Finish_Package (int128u PackageUID)
+{
+ packages::iterator Package=Packages.find(PackageUID);
+ if (Package==Packages.end() || !Package->second.IsSourcePackage)
+ return;
+
+ for (size_t Pos=0; Pos<Package->second.Tracks.size(); Pos++)
+ Streams_Finish_Track(Package->second.Tracks[Pos]);
+
+ Streams_Finish_Descriptor(Package->second.Descriptor, PackageUID);
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Finish_Track(int128u TrackUID)
+{
+ tracks::iterator Track=Tracks.find(TrackUID);
+ if (Track==Tracks.end() || Track->second.Stream_Finish_Done)
+ return;
+
+ StreamKind_Last=Stream_Max;
+ StreamPos_Last=(size_t)-1;
+
+ Streams_Finish_Essence(Track->second.TrackNumber, TrackUID);
+
+ //Sequence
+ if (StreamKind_Last!=Stream_Max)
+ Streams_Finish_Component(Track->second.Sequence, Track->second.EditRate);
+
+ //Done
+ Track->second.Stream_Finish_Done=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Finish_Essence(int32u EssenceUID, int128u TrackUID)
+{
+ essences::iterator Essence=Essences.find(EssenceUID);
+ if (Essence==Essences.end() || Essence->second.Stream_Finish_Done)
+ return;
+
+ if (Essence->second.Parser==NULL)
+ return;
+
+ if (Config_ParseSpeed<=1.0)
+ {
+ Fill(Essence->second.Parser);
+ Essence->second.Parser->Open_Buffer_Unsynch();
+ }
+ Finish(Essence->second.Parser);
+ StreamKind_Last=Stream_Max;
+ if (Essence->second.Parser->Count_Get(Stream_Video))
+ Stream_Prepare(Stream_Video);
+ else if (Essence->second.Parser->Count_Get(Stream_Audio))
+ Stream_Prepare(Stream_Audio);
+ else if (Essence->second.Parser->Count_Get(Stream_Text))
+ Stream_Prepare(Stream_Text);
+ else if (Essence->second.StreamKind!=Stream_Max)
+ Stream_Prepare(Essence->second.StreamKind);
+ else
+ {
+ for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ if (Descriptor->second.LinkedTrackID==Essence->second.TrackID)
+ {
+ if (Descriptor->second.StreamKind!=Stream_Max)
+ {
+ Stream_Prepare(Descriptor->second.StreamKind);
+ Descriptor->second.StreamPos=StreamPos_Last;
+ }
+ break;
+ }
+ if (StreamKind_Last==Stream_Max)
+ return; //Not found
+ }
+
+ for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ if (Descriptor->second.LinkedTrackID==Essence->second.TrackID)
+ {
+ if (Descriptor->second.StreamKind!=Stream_Max)
+ {
+ Descriptor->second.StreamPos=StreamPos_Last;
+ }
+ break;
+ }
+
+ for (std::map<std::string, Ztring>::iterator Info=Essence->second.Infos.begin(); Info!=Essence->second.Infos.end(); Info++)
+ Fill(StreamKind_Last, StreamPos_Last, Info->first.c_str(), Info->second, true);
+ if (TimeCode_RoundedTimecodeBase && TimeCode_StartTimecode!=(int64u)-1)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay), DTS_Delay*1000, 0, true);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Source), "Container");
+ }
+ if (SDTI_TimeCode_StartTimecode!=(int64u)-1)
+ Fill(StreamKind_Last, StreamPos_Last, "Delay_SDTI", SDTI_TimeCode_StartTimecode);
+ if (SystemScheme1_TimeCodeArray_StartTimecode!=(int64u)-1)
+ Fill(StreamKind_Last, StreamPos_Last, "Delay_SystemScheme1", SystemScheme1_TimeCodeArray_StartTimecode);
+
+ //Special case - Multiple sub-streams in a stream
+ if (Essence->second.Parser->Retrieve(Stream_General, 0, General_Format)==_T("ChannelGrouping") && Essence->second.Parser->Count_Get(Stream_Audio))
+ {
+ //Before
+ Clear(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_StreamSize));
+ if (StreamKind_Last==Stream_Audio)
+ {
+ Clear(Stream_Audio, StreamPos_Last, Audio_Format_Settings_Sign);
+ }
+ ZtringList StreamSave; StreamSave.Write((*File__Analyze::Stream)[StreamKind_Last][StreamPos_Last].Read());
+ ZtringListList StreamMoreSave; StreamMoreSave.Write((*Stream_More)[StreamKind_Last][StreamPos_Last].Read());
+
+ //Erasing former streams data
+ stream_t NewKind=StreamKind_Last;
+ size_t NewPos1;
+ Ztring ID;
+
+ //Searching second stream
+ size_t StreamPos_Difference=Essence->second.StreamPos-Essence->second.StreamPos_Initial;
+ essences::iterator Essence1=Essence;
+ Essence1--;
+ Essence->second.StreamPos=Essence1->second.StreamPos;
+ for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ {
+ if (Descriptor->second.LinkedTrackID==Essence1->second.TrackID)
+ Descriptor->second.StreamPos=Essence1->second.StreamPos;
+ if (Descriptor->second.LinkedTrackID==Essence->second.TrackID)
+ Descriptor->second.StreamPos=Essence->second.StreamPos;
+ }
+
+ //Removing the 2 corresponding streams
+ NewPos1=(Essence->second.StreamPos_Initial/2)*2+StreamPos_Difference;
+ size_t NewPos2=NewPos1+1;
+ ID=Ztring::ToZtring(Essence1->second.TrackID)+_T(" / ")+Ztring::ToZtring(Essence->second.TrackID);
+
+ Stream_Erase(NewKind, NewPos2);
+ Stream_Erase(NewKind, NewPos1);
+
+ //After
+ for (size_t StreamPos=0; StreamPos<Essence->second.Parser->Count_Get(NewKind); StreamPos++)
+ {
+ Stream_Prepare(NewKind, NewPos1+StreamPos);
+ Merge(*Essence->second.Parser, StreamKind_Last, StreamPos, StreamPos_Last);
+ Ztring Parser_ID=Retrieve(StreamKind_Last, StreamPos_Last, General_ID);
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, ID+(Parser_ID.empty()?Ztring():(_T("-")+Parser_ID)), true);
+ for (size_t Pos=0; Pos<StreamSave.size(); Pos++)
+ if (Retrieve(StreamKind_Last, StreamPos_Last, Pos).empty())
+ Fill(StreamKind_Last, StreamPos_Last, Pos, StreamSave[Pos]);
+ for (size_t Pos=0; Pos<StreamMoreSave.size(); Pos++)
+ Fill(StreamKind_Last, StreamPos_Last, StreamMoreSave(Pos, 0).To_Local().c_str(), StreamMoreSave(Pos, 1));
+ }
+
+ //Positioning other streams
+ for (essences::iterator Essence_Temp=Essence; Essence_Temp!=Essences.end(); Essence_Temp++)
+ if (Essence_Temp->second.Parser && Essence_Temp->second.Parser->Count_Get(Stream_Audio))
+ {
+ Essence_Temp->second.StreamPos-=2; //ChannelGrouping
+ Essence_Temp->second.StreamPos+=Essence_Temp->second.Parser->Count_Get(Stream_Audio);
+ }
+ }
+ else //Normal
+ {
+ Merge(*Essence->second.Parser, StreamKind_Last, 0, StreamPos_Last);
+ for (size_t StreamPos=1; StreamPos<Essence->second.Parser->Count_Get(StreamKind_Last); StreamPos++) //If more than 1 stream, TODO: better way to do this
+ {
+ Stream_Prepare(StreamKind_Last);
+ Merge(*Essence->second.Parser, StreamKind_Last, StreamPos, StreamPos_Last);
+ }
+ }
+
+ if (Retrieve(StreamKind_Last, StreamPos_Last, General_ID).empty() || StreamKind_Last==Stream_Text) //TODO: better way to do detect subID
+ {
+ //Looking for Material package TrackID
+ int32u TrackID=(int32u)-1;
+ for (packages::iterator SourcePackage=Packages.begin(); SourcePackage!=Packages.end(); SourcePackage++)
+ if (SourcePackage->second.PackageUID.hi.hi) //Looking fo a SourcePackage with PackageUID only
+ {
+ //Testing if the Track is in this SourcePackage
+ for (size_t Tracks_Pos=0; Tracks_Pos<SourcePackage->second.Tracks.size(); Tracks_Pos++)
+ if (SourcePackage->second.Tracks[Tracks_Pos]==TrackUID)
+ {
+ tracks::iterator Track=Tracks.find(SourcePackage->second.Tracks[Tracks_Pos]);
+ if (Track!=Tracks.end())
+ TrackID=Track->second.TrackID;
+ }
+ }
+
+ Ztring ID;
+ Ztring ID_String;
+ if (TrackID!=(int32u)-1)
+ ID=Ztring::ToZtring(TrackID);
+ else if (Tracks[TrackUID].TrackID!=(int32u)-1)
+ ID=Ztring::ToZtring(Tracks[TrackUID].TrackID);
+ else
+ {
+ ID=Ztring::ToZtring(Essence->first);
+ ID_String=Ztring::ToZtring(Essence->first, 16);
+ }
+ if (!ID.empty())
+ {
+ for (size_t StreamPos=StreamPos_Last-(Essence->second.Parser->Count_Get(StreamKind_Last)?(Essence->second.Parser->Count_Get(StreamKind_Last)-1):0); StreamPos<=StreamPos_Last; StreamPos++) //If more than 1 stream
+ {
+ Ztring ID_Temp(ID);
+ if (!Retrieve(StreamKind_Last, StreamPos, General_ID).empty())
+ {
+ ID_Temp+=_T("-");
+ ID_Temp+=Retrieve(StreamKind_Last, StreamPos, General_ID);
+ }
+ Fill(StreamKind_Last, StreamPos, General_ID, ID_Temp, true);
+ if (!ID_String.empty())
+ Fill(StreamKind_Last, StreamPos, General_ID_String, ID_String, true);
+ }
+ }
+ if (!Tracks[TrackUID].TrackName.empty())
+ {
+ for (size_t StreamPos=StreamPos_Last-(Essence->second.Parser->Count_Get(StreamKind_Last)?(Essence->second.Parser->Count_Get(StreamKind_Last)-1):0); StreamPos<=StreamPos_Last; StreamPos++) //If more than 1 stream
+ Fill(StreamKind_Last, StreamPos, "Title", Tracks[TrackUID].TrackName);
+ }
+ }
+
+ //Special case - DV
+ #if defined(MEDIAINFO_DVDIF_YES)
+ if (StreamKind_Last==Stream_Video && Retrieve(Stream_Video, StreamPos_Last, Video_Format)==_T("DV"))
+ {
+ if (Retrieve(Stream_General, 0, General_Recorded_Date).empty())
+ Fill(Stream_General, 0, General_Recorded_Date, Essence->second.Parser->Retrieve(Stream_General, 0, General_Recorded_Date));
+
+ //Video and Audio are together
+ size_t Audio_Count=Essence->second.Parser->Count_Get(Stream_Audio);
+ for (size_t Audio_Pos=0; Audio_Pos<Audio_Count; Audio_Pos++)
+ {
+ Fill_Flush();
+ Stream_Prepare(Stream_Audio);
+ size_t Pos=Count_Get(Stream_Audio)-1;
+ Essence->second.Parser->Finish();
+ if (TimeCode_RoundedTimecodeBase && TimeCode_StartTimecode!=(int64u)-1)
+ {
+ Fill(Stream_Audio, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay), DTS_Delay*1000, 0, true);
+ Fill(Stream_Audio, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Source), "Container");
+ }
+ Merge(*Essence->second.Parser, Stream_Audio, Audio_Pos, StreamPos_Last);
+ if (Retrieve(Stream_Audio, Pos, Audio_MuxingMode).empty())
+ Fill(Stream_Audio, Pos, Audio_MuxingMode, Retrieve(Stream_Video, Essence->second.StreamPos-(StreamPos_StartAtOne?1:0), Video_Format), true);
+ else
+ Fill(Stream_Audio, Pos, Audio_MuxingMode, Retrieve(Stream_Video, Essence->second.StreamPos-(StreamPos_StartAtOne?1:0), Video_Format)+_T(" / ")+Retrieve(Stream_Audio, Pos, Audio_MuxingMode), true);
+ Fill(Stream_Audio, Pos, Audio_Duration, Retrieve(Stream_Video, Essence->second.StreamPos-(StreamPos_StartAtOne?1:0), Video_Duration));
+ Fill(Stream_Audio, Pos, Audio_StreamSize_Encoded, 0); //Included in the DV stream size
+ Ztring ID=Retrieve(Stream_Audio, Pos, Audio_ID);
+ Fill(Stream_Audio, Pos, Audio_ID, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_ID)+_T("-")+ID, true);
+ Fill(Stream_Audio, Pos, Audio_ID_String, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_ID_String)+_T("-")+ID, true);
+ Fill(Stream_Audio, Pos, Audio_Title, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_Title), true);
+ }
+
+ StreamKind_Last=Stream_Video;
+ StreamPos_Last=Essence->second.StreamPos-(StreamPos_StartAtOne?1:0);
+ }
+ #endif
+
+ //Special case - MPEG Video + Captions
+ if (StreamKind_Last==Stream_Video && Essence->second.Parser && Essence->second.Parser->Count_Get(Stream_Text))
+ {
+ //Video and Text are together
+ File__Analyze* Parser=Essence->second.Parser;
+ size_t Parser_Text_Count=Parser->Count_Get(Stream_Text);
+ for (size_t Parser_Text_Pos=0; Parser_Text_Pos<Parser_Text_Count; Parser_Text_Pos++)
+ {
+ size_t StreamPos_Video=StreamPos_Last;
+ Fill_Flush();
+ Stream_Prepare(Stream_Text);
+ Parser->Finish();
+ if (TimeCode_RoundedTimecodeBase && TimeCode_StartTimecode!=(int64u)-1)
+ {
+ Fill(Stream_Text, Parser_Text_Pos, Fill_Parameter(StreamKind_Last, Generic_Delay), DTS_Delay*1000, 0, true);
+ Fill(Stream_Text, Parser_Text_Pos, Fill_Parameter(StreamKind_Last, Generic_Delay_Source), "Container");
+ }
+ Merge(*Parser, Stream_Text, Parser_Text_Pos, StreamPos_Last);
+ Fill(Stream_Text, StreamPos_Last, Text_Duration, Retrieve(Stream_Video, StreamPos_Video, Video_Duration));
+ Ztring ID=Retrieve(Stream_Text, StreamPos_Last, Text_ID);
+ if (Retrieve(Stream_Text, StreamPos_Last, Text_MuxingMode).find(_T("Ancillary"))!=string::npos)
+ {
+ for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ if (Descriptor->second.Type==descriptor::Type_AncPackets)
+ {
+ Fill(Stream_Text, StreamPos_Last, Text_ID, Ztring::ToZtring(Descriptor->second.LinkedTrackID)+_T("-")+ID, true);
+ Fill(Stream_Text, StreamPos_Last, Text_ID_String, Ztring::ToZtring(Descriptor->second.LinkedTrackID)+_T("-")+ID, true);
+ Fill(Stream_Text, StreamPos_Last, Text_Title, Tracks[TrackUID].TrackName, true);
+ break;
+ }
+ }
+ else
+ {
+ Fill(Stream_Text, StreamPos_Last, Text_ID, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_ID)+_T("-")+ID, true);
+ Fill(Stream_Text, StreamPos_Last, Text_ID_String, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_ID_String)+_T("-")+ID, true);
+ Fill(Stream_Text, StreamPos_Last, Text_Title, Retrieve(Stream_Video, Count_Get(Stream_Video)-1, Video_Title), true);
+ }
+ }
+
+ StreamKind_Last=Stream_Video;
+ StreamPos_Last=Essence->second.StreamPos-(StreamPos_StartAtOne?1:0);
+ }
+
+ //Stream size
+ if (StreamKind_Last!=Stream_Max && Count_Get(Stream_Video)+Count_Get(Stream_Audio)==1 && Essence->second.Stream_Size!=(int64u)-1)
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_StreamSize), Essence->second.Stream_Size);
+
+ //Done
+ Essence->second.Stream_Finish_Done=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Finish_Descriptor(int128u DescriptorUID, int128u PackageUID)
+{
+ descriptors::iterator Descriptor=Descriptors.find(DescriptorUID);
+ if (Descriptor==Descriptors.end())
+ return;
+
+ //Subs
+ if (!Descriptor->second.SubDescriptors.empty())
+ {
+ for (size_t Pos=0; Pos<Descriptor->second.SubDescriptors.size(); Pos++)
+ Streams_Finish_Descriptor(Descriptor->second.SubDescriptors[Pos], PackageUID);
+ return; //Is not a real descriptor
+ }
+
+ StreamKind_Last=Stream_Max;
+ StreamPos_Last=(size_t)-1;
+ if (Descriptor->second.StreamKind!=Stream_Max)
+ {
+ StreamKind_Last=Descriptor->second.StreamKind;
+ StreamPos_Last=Descriptor->second.StreamPos;
+ if (StreamPos_Last==(size_t)-1)
+ {
+ for (size_t Pos=0; Pos<Count_Get(StreamKind_Last); Pos++)
+ if (Ztring::ToZtring(Descriptor->second.LinkedTrackID)==Retrieve(StreamKind_Last, Pos, General_ID))
+ {
+ StreamPos_Last=Pos;
+ break;
+ }
+ }
+ if (StreamPos_Last==(size_t)-1)
+ {
+ if (Descriptors.size()==1 && Count_Get(StreamKind_Last)==1)
+ StreamPos_Last=0;
+ else if (Descriptor->second.LinkedTrackID!=(int32u)-1)
+ {
+ //Workaround for a specific file with same ID
+ if (!Locators.empty())
+ for (descriptors::iterator Descriptor1=Descriptors.begin(); Descriptor1!=Descriptor; Descriptor1++)
+ if (Descriptor1->second.LinkedTrackID==Descriptor->second.LinkedTrackID)
+ {
+ IdIsAlwaysSame_Offset++;
+ break;
+ }
+
+ Stream_Prepare(Descriptor->second.StreamKind);
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, Descriptor->second.LinkedTrackID+IdIsAlwaysSame_Offset);
+ }
+ else
+ {
+ //Looking for Material package TrackID
+ packages::iterator SourcePackage=Packages.find(PackageUID);
+ //We have the the right PackageUID, looking for SourceClip from Sequence from Track from MaterialPackage
+ for (components::iterator SourceClip=Components.begin(); SourceClip!=Components.end(); SourceClip++)
+ if (SourceClip->second.SourcePackageID.lo==SourcePackage->second.PackageUID.lo) //int256u doesn't support yet ==
+ {
+ //We have the right SourceClip, looking for the Sequence from Track from MaterialPackage
+ for (components::iterator Sequence=Components.begin(); Sequence!=Components.end(); Sequence++)
+ for (size_t StructuralComponents_Pos=0; StructuralComponents_Pos<Sequence->second.StructuralComponents.size(); StructuralComponents_Pos++)
+ if (Sequence->second.StructuralComponents[StructuralComponents_Pos]==SourceClip->first)
+ {
+ //We have the right Sequence, looking for Track from MaterialPackage
+ for (tracks::iterator Track=Tracks.begin(); Track!=Tracks.end(); Track++)
+ {
+ if (Track->second.Sequence==Sequence->first)
+ {
+ Ztring ID=Ztring::ToZtring(Track->second.TrackID);
+ StreamKind_Last=Stream_Max;
+ StreamPos_Last=(size_t)-1;
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Count_Get((stream_t)StreamKind); StreamPos++)
+ if (ID==Retrieve((stream_t)StreamKind, StreamPos, General_ID))
+ {
+ StreamKind_Last=(stream_t)StreamKind;
+ StreamPos_Last=(stream_t)StreamPos;
+ }
+ if (StreamPos_Last==(size_t)-1 && !Descriptor->second.Locators.empty()) //TODO: 1 file has a TimeCode stream linked to a video stream, and it is displayed if Locator test is removed. Why? AS02 files streams are not filled if I remove completely this block, why?
+ {
+ Stream_Prepare(Descriptor->second.StreamKind);
+ if (Track->second.TrackID!=(int32u)-1)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, ID);
+ Fill(StreamKind_Last, StreamPos_Last, "Title", Track->second.TrackName);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //Locators
+ size_t Before_Count[Stream_Max];
+ for (size_t Pos=0; Pos<Stream_Max; Pos++)
+ Before_Count[Pos]=(size_t)-1;
+ Before_Count[Stream_Video]=Count_Get(Stream_Video);
+ Before_Count[Stream_Audio]=Count_Get(Stream_Audio);
+ Before_Count[Stream_Text]=Count_Get(Stream_Text);
+ for (size_t Locator_Pos=0; Locator_Pos<Descriptor->second.Locators.size(); Locator_Pos++)
+ {
+ //Locator
+ Streams_Finish_Locator(Descriptor->second.Locators[Locator_Pos]);
+ }
+
+ if (StreamPos_Last==(size_t)-1 && Essences.size()==1)
+ {
+ //Only one essence, there is sometimes no LinkedTrackID
+ if (Count_Get(Stream_Video)==1)
+ {
+ StreamKind_Last=Stream_Video;
+ StreamPos_Last=0;
+ }
+ else if (Count_Get(Stream_Audio)==1)
+ {
+ StreamKind_Last=Stream_Audio;
+ StreamPos_Last=0;
+ }
+ }
+
+ if (StreamKind_Last!=Stream_Max && StreamPos_Last!=(size_t)-1)
+ {
+ //Handling buggy files
+ std::map<std::string, Ztring>::iterator Info=Descriptor->second.Infos.find("ScanType");
+ if (Info!=Descriptor->second.Infos.end() && Info->second==_T("Interlaced") && Descriptor->second.Height==1152 && Descriptor->second.Height_Display==1152 && Descriptor->second.Width==720) //Height value is height of the frame instead of the field
+ Descriptor->second.Height_Display/=2;
+
+ //ID
+ if (Descriptor->second.LinkedTrackID!=(int32u)-1 && Retrieve(StreamKind_Last, StreamPos_Last, General_ID).empty())
+ {
+ for (size_t StreamKind=0; StreamKind<Stream_Max; StreamKind++)
+ for (size_t StreamPos=Before_Count[StreamKind]; StreamPos<Count_Get((stream_t)StreamKind); StreamPos++)
+ {
+ Ztring ID=Retrieve((stream_t)StreamKind, StreamPos, General_ID);
+ if (ID.empty() || Config->File_ID_OnlyRoot_Get())
+ Fill((stream_t)StreamKind, StreamPos, General_ID, Descriptor->second.LinkedTrackID, 10, true);
+ else
+ Fill((stream_t)StreamKind, StreamPos, General_ID, Ztring::ToZtring(Descriptor->second.LinkedTrackID)+ID, true);
+ }
+ }
+
+ if (Descriptor->second.Width!=(int32u)-1 && Retrieve(Stream_Video, StreamPos_Last, Video_Width).empty())
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Descriptor->second.Width, 10, true);
+ if (Descriptor->second.Width_Display!=(int32u)-1 && Descriptor->second.Width_Display!=Retrieve(Stream_Video, StreamPos_Last, Video_Width).To_int32u())
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Width_Original, Retrieve(Stream_Video, StreamPos_Last, Video_Width), true);
+ if (Retrieve(Stream_Video, StreamPos_Last, Video_PixelAspectRatio_Original).empty())
+ Fill(Stream_Video, StreamPos_Last, Video_PixelAspectRatio_Original, Retrieve(Stream_Video, StreamPos_Last, Video_PixelAspectRatio), true);
+ Clear(Stream_Video, StreamPos_Last, Video_PixelAspectRatio);
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Descriptor->second.Width_Display, 10, true);
+ if (Descriptor->second.Width_Display_Offset!=(int32u)-1)
+ Fill(Stream_Video, StreamPos_Last, Video_Width_Offset, Descriptor->second.Width_Display_Offset, 10, true);
+ }
+ if (Descriptor->second.Height!=(int32u)-1 && Retrieve(Stream_Video, StreamPos_Last, Video_Height).empty())
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Descriptor->second.Height, 10, true);
+ if (Descriptor->second.Height_Display!=(int32u)-1 && Descriptor->second.Height_Display!=Retrieve(Stream_Video, StreamPos_Last, Video_Height).To_int32u())
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Height_Original, Retrieve(Stream_Video, StreamPos_Last, Video_Height), true);
+ if (Retrieve(Stream_Video, StreamPos_Last, Video_PixelAspectRatio_Original).empty())
+ Fill(Stream_Video, StreamPos_Last, Video_PixelAspectRatio_Original, Retrieve(Stream_Video, StreamPos_Last, Video_PixelAspectRatio), true);
+ Clear(Stream_Video, StreamPos_Last, Video_PixelAspectRatio);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Descriptor->second.Height_Display, 10, true);
+ if (Descriptor->second.Height_Display_Offset!=(int32u)-1)
+ Fill(Stream_Video, StreamPos_Last, Video_Height_Offset, Descriptor->second.Height_Display_Offset, 10, true);
+ }
+
+ //Special case
+ if (StreamKind_Last==Stream_Audio)
+ {
+ std::map<std::string, Ztring>::iterator Info=Descriptor->second.Infos.find("FrameRate");
+ if (Info!=Descriptor->second.Infos.end())
+ Descriptor->second.Infos.erase(Info);
+ }
+
+ //Info
+ for (std::map<std::string, Ztring>::iterator Info=Descriptor->second.Infos.begin(); Info!=Descriptor->second.Infos.end(); Info++)
+ if (Retrieve(StreamKind_Last, StreamPos_Last, Info->first.c_str()).empty())
+ Fill(StreamKind_Last, StreamPos_Last, Info->first.c_str(), Info->second, true);
+
+ //Bitrate (PCM)
+ if (StreamKind_Last==Stream_Audio && Retrieve(Stream_Audio, StreamPos_Last, Audio_BitRate).empty() && Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("PCM") && Retrieve(Stream_Audio, StreamPos_Last, Audio_Format_Settings_Wrapping).find(_T("D-10"))!=string::npos)
+ {
+ int64u SamplingRate=Retrieve(Stream_Audio, StreamPos_Last, Audio_SamplingRate).To_int64u();
+ if (SamplingRate)
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate, 8*SamplingRate*32);
+ }
+ if (StreamKind_Last==Stream_Audio && Retrieve(Stream_Audio, StreamPos_Last, Audio_BitRate).empty() && Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("PCM"))
+ {
+ int64u Channels=Retrieve(Stream_Audio, StreamPos_Last, Audio_Channel_s_).To_int64u();
+ int64u SamplingRate=Retrieve(Stream_Audio, StreamPos_Last, Audio_SamplingRate).To_int64u();
+ int64u Resolution=Retrieve(Stream_Audio, StreamPos_Last, Audio_BitDepth).To_int64u();
+ if (Channels && SamplingRate && Resolution)
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate, Channels*SamplingRate*Resolution);
+ }
+
+ //Bitrate (Video)
+ if (StreamKind_Last==Stream_Video && Retrieve(Stream_Video, StreamPos_Last, Video_BitRate).empty())
+ {
+ //Until now, I only found CBR files
+ Fill(Stream_Video, StreamPos_Last, Video_BitRate, Retrieve(Stream_Video, StreamPos_Last, Video_BitRate_Nominal));
+ }
+
+ //Frame rate
+ if (StreamKind_Last==Stream_Video && Descriptor->second.Infos.find("FrameRate")!=Descriptor->second.Infos.end() && Descriptor->second.Infos["FrameRate"]!=Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate))
+ {
+ //Until now, I only found CBR files
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Original, Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate));
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, Descriptor->second.Infos["FrameRate"], true);
+ }
+
+ //Display Aspect Ratio
+ if (StreamKind_Last==Stream_Video && !Descriptor->second.Infos["DisplayAspectRatio"].empty() && Retrieve(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio)!=Descriptor->second.Infos["DisplayAspectRatio"])
+ {
+ Ztring DAR=Retrieve(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio);
+ Clear(Stream_Video, StreamPos_Last, Video_PixelAspectRatio);
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, Descriptor->second.Infos["DisplayAspectRatio"], true);
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio_Original, DAR);
+ float32 Width =Retrieve(Stream_Video, StreamPos_Last, Video_Width ).To_float32();
+ float32 Height=Retrieve(Stream_Video, StreamPos_Last, Video_Height ).To_float32();
+ float32 DAR_F =DAR.To_float32();
+ if (Width && Height && DAR_F)
+ {
+ float32 PAR =1/(Width/Height/DAR_F);
+ if (PAR>(float32)12/(float32)11*0.99 && PAR<(float32)12/(float32)11*1.01)
+ PAR=(float32)12/(float32)11;
+ if (PAR>(float32)10/(float32)11*0.99 && PAR<(float32)10/(float32)11*1.01)
+ PAR=(float32)10/(float32)11;
+ if (PAR>(float32)16/(float32)11*0.99 && PAR<(float32)16/(float32)11*1.01)
+ PAR=(float32)16/(float32)11;
+ if (PAR>(float32)40/(float32)33*0.99 && PAR<(float32)40/(float32)33*1.01)
+ PAR=(float32)40/(float32)33;
+ if (PAR>(float32)24/(float32)11*0.99 && PAR<(float32)24/(float32)11*1.01)
+ PAR=(float32)24/(float32)11;
+ if (PAR>(float32)20/(float32)11*0.99 && PAR<(float32)20/(float32)11*1.01)
+ PAR=(float32)20/(float32)11;
+ if (PAR>(float32)32/(float32)11*0.99 && PAR<(float32)32/(float32)11*1.01)
+ PAR=(float32)32/(float32)11;
+ if (PAR>(float32)80/(float32)33*0.99 && PAR<(float32)80/(float32)33*1.01)
+ PAR=(float32)80/(float32)33;
+ if (PAR>(float32)18/(float32)11*0.99 && PAR<(float32)18/(float32)11*1.01)
+ PAR=(float32)18/(float32)11;
+ if (PAR>(float32)15/(float32)11*0.99 && PAR<(float32)15/(float32)11*1.01)
+ PAR=(float32)15/(float32)11;
+ if (PAR>(float32)64/(float32)33*0.99 && PAR<(float32)64/(float32)33*1.01)
+ PAR=(float32)64/(float32)33;
+ if (PAR>(float32)160/(float32)99*0.99 && PAR<(float32)160/(float32)99*1.01)
+ PAR=(float32)160/(float32)99;
+ if (PAR>(float32)4/(float32)3*0.99 && PAR<(float32)4/(float32)3*1.01)
+ PAR=(float32)4/(float32)3;
+ if (PAR>(float32)3/(float32)2*0.99 && PAR<(float32)3/(float32)2*1.01)
+ PAR=(float32)3/(float32)2;
+ if (PAR>(float32)2/(float32)1*0.99 && PAR<(float32)2/(float32)1*1.01)
+ PAR=(float32)2;
+ if (PAR>(float32)59/(float32)54*0.99 && PAR<(float32)59/(float32)54*1.01)
+ PAR=(float32)59/(float32)54;
+ }
+ }
+
+ //ActiveFormatDescriptor
+ if (StreamKind_Last==Stream_Video && Descriptor->second.ActiveFormat!=(int8u)-1 && Retrieve(Stream_Video, StreamPos_Last, Video_ActiveFormatDescription).empty())
+ {
+ Fill(Stream_Video, 0, Video_ActiveFormatDescription, Descriptor->second.ActiveFormat);
+ if (Descriptor->second.ActiveFormat<16)
+ {
+ float32 DAR=Retrieve(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio).To_float32();
+ if (DAR>(float32)4/(float32)3*0.99 && DAR<(float32)4/(float32)3*1.01)
+ Fill(Stream_Video, 0, Video_ActiveFormatDescription_String, AfdBarData_active_format_4_3[Descriptor->second.ActiveFormat]);
+ if (DAR>(float32)16/(float32)9*0.99 && DAR<(float32)16/(float32)9*1.01)
+ Fill(Stream_Video, 0, Video_ActiveFormatDescription_String, AfdBarData_active_format_16_9[Descriptor->second.ActiveFormat]);
+ }
+ if (Retrieve(Stream_Video, 0, Video_ActiveFormatDescription_String).empty())
+ Fill(Stream_Video, 0, Video_ActiveFormatDescription_String, Descriptor->second.ActiveFormat);
+ }
+ }
+
+ //Fallback on partition data if classic methods failed
+ if (StreamKind_Last!=Stream_Max && StreamPos_Last!=(size_t)-1 && Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format)).empty() && Descriptors.size()==1 && Count_Get(StreamKind_Last)==1)
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), Mxf_EssenceContainer(EssenceContainer_FromPartitionMetadata));
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Finish_Locator(int128u LocatorUID)
+{
+ locators::iterator Locator=Locators.find(LocatorUID);
+ if (Locator==Locators.end())
+ return;
+
+ //External file name specific
+ if (!Locator->second.IsTextLocator && !Locator->second.EssenceLocator.empty())
+ {
+ //Preparing
+ Locator->second.StreamKind=StreamKind_Last;
+ Locator->second.StreamPos=StreamPos_Last;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Finish_CommercialNames ()
+{
+ //Commercial names
+ if (Count_Get(Stream_Video)==1)
+ {
+ Streams_Finish_StreamOnly();
+ if (!Retrieve(Stream_Video, 0, Video_Format_Commercial_IfAny).empty())
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, Retrieve(Stream_Video, 0, Video_Format_Commercial_IfAny));
+ Fill(Stream_General, 0, General_Format_Commercial, _T("MXF ")+Retrieve(Stream_Video, 0, Video_Format_Commercial_IfAny));
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("DV"))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "DV");
+ Fill(Stream_General, 0, General_Format_Commercial, "MXF DV");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("AVC") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:0") && Retrieve(Stream_Video, 0, Video_BitRate)==_T("56064000"))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "AVC-Intra 50");
+ Fill(Stream_General, 0, General_Format_Commercial, "MXF AVC-Intra 50");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "AVC-Intra 50");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("AVC") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:2") && Retrieve(Stream_Video, 0, Video_BitRate)==_T("113664000"))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "AVC-Intra 100");
+ Fill(Stream_General, 0, General_Format_Commercial, "MXF AVC-Intra 100");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "AVC-Intra 100");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:2") && (Retrieve(Stream_Video, 0, Video_BitRate)==_T("30000000") || Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==_T("30000000") || Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==_T("30000000")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "IMX 30");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "IMX 30");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:2") && (Retrieve(Stream_Video, 0, Video_BitRate)==_T("40000000") || Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==_T("40000000") || Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==_T("40000000")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "IMX 40");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "IMX 40");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:2") && (Retrieve(Stream_Video, 0, Video_BitRate)==_T("50000000") || Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==_T("50000000") || Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==_T("50000000")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "IMX 50");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "IMX 50");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)!=_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:0") && (Retrieve(Stream_Video, 0, Video_BitRate)==_T("18000000") || Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==_T("25000000") || Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==_T("25000000")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "XDCAM HD 18");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "XDCAM HD 18");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)!=_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:0") && (Retrieve(Stream_Video, 0, Video_BitRate)==_T("25000000") || Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==_T("25000000") || Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==_T("25000000")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "XDCAM HD 25");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "XDCAM HD 25");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)!=_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:0") && (Retrieve(Stream_Video, 0, Video_BitRate)==_T("35000000") || Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==_T("35000000") || Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==_T("35000000")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "XDCAM HD 35");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "XDCAM HD 35");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)!=_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:2") && (Retrieve(Stream_Video, 0, Video_BitRate)==_T("50000000") || Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==_T("50000000") || Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==_T("50000000")))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "XDCAM HD422");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "XDCAM HD422");
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Finish_Component(int128u ComponentUID, float64 EditRate)
+{
+ components::iterator Component=Components.find(ComponentUID);
+ if (Component==Components.end())
+ return;
+
+ //Duration
+ if (EditRate && StreamKind_Last!=Stream_Max && Component->second.Duration!=(int64u)-1)
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), Component->second.Duration*1000/EditRate, 0, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Streams_Finish_Identification (int128u IdentificationUID)
+{
+ identifications::iterator Identification=Identifications.find(IdentificationUID);
+ if (Identification==Identifications.end())
+ return;
+
+ if (!Identification->second.ProductName.empty())
+ {
+ Ztring Encoded_Library_Name;
+ if (!Identification->second.CompanyName.empty())
+ {
+ Encoded_Library_Name+=Identification->second.CompanyName;
+ Encoded_Library_Name+=_T(' ');
+ }
+ Encoded_Library_Name+=Identification->second.ProductName;
+ Ztring Encoded_Library_Version;
+ if (!Identification->second.ProductVersion.empty())
+ {
+ Encoded_Library_Version=Identification->second.ProductVersion;
+ }
+ else if (!Identification->second.VersionString.empty())
+ {
+ Encoded_Library_Version=Identification->second.VersionString;
+ }
+ Ztring Encoded_Application=Encoded_Library_Name;
+ if (!Encoded_Library_Version.empty())
+ {
+ Encoded_Application+=_T(' ');
+ Encoded_Application+=Encoded_Library_Version;
+ }
+ Fill(Stream_General, 0, General_Encoded_Application, Encoded_Application, true);
+ Fill(Stream_General, 0, General_Encoded_Library_Name, Encoded_Library_Name, true);
+ Fill(Stream_General, 0, General_Encoded_Library_Version, Encoded_Library_Version, true);
+ }
+
+ for (std::map<std::string, Ztring>::iterator Info=Identification->second.Infos.begin(); Info!=Identification->second.Infos.end(); Info++)
+ Fill(Stream_General, 0, Info->first.c_str(), Info->second, true);
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mxf::Read_Buffer_Init()
+{
+ EssenceContainer_FromPartitionMetadata=0;
+ #if MEDIAINFO_DEMUX
+ Demux_UnpacketizeContainer=Config->Demux_Unpacketize_Get();
+ Demux_Rate=Config->Demux_Rate_Get();
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Read_Buffer_Continue()
+{
+ if (!IsSub)
+ {
+ if (Config_ParseSpeed>=1.0)
+ {
+ if (Config->File_IsGrowing)
+ {
+ File F;
+ F.Open(File_Name);
+ int8u SearchingPartitionPack[65536];
+ size_t SearchingPartitionPack_Size=F.Read(SearchingPartitionPack, 65536);
+ for (size_t Pos=0; Pos+16<SearchingPartitionPack_Size; Pos++)
+ if (SearchingPartitionPack[Pos ]==0x06
+ && SearchingPartitionPack[Pos+ 1]==0x0E
+ && SearchingPartitionPack[Pos+ 2]==0x2B
+ && SearchingPartitionPack[Pos+ 3]==0x34
+ && SearchingPartitionPack[Pos+ 4]==0x02
+ && SearchingPartitionPack[Pos+ 5]==0x05
+ && SearchingPartitionPack[Pos+ 6]==0x01
+ && SearchingPartitionPack[Pos+ 7]==0x01
+ && SearchingPartitionPack[Pos+ 8]==0x0D
+ && SearchingPartitionPack[Pos+ 9]==0x01
+ && SearchingPartitionPack[Pos+10]==0x02
+ && SearchingPartitionPack[Pos+11]==0x01
+ && SearchingPartitionPack[Pos+12]==0x01
+ && SearchingPartitionPack[Pos+13]==0x02) //Header Partition Pack
+ {
+ switch (SearchingPartitionPack[Pos+14])
+ {
+ case 0x02 :
+ case 0x04 :
+ {
+ //Filling duration
+ F.Close();
+ Config->File_IsNotGrowingAnymore=true;
+ MediaInfo_Internal MI;
+ Ztring ParseSpeed_Save=MI.Option(_T("ParseSpeed_Get"), _T(""));
+ Ztring Demux_Save=MI.Option(_T("Demux_Get"), _T(""));
+ MI.Option(_T("ParseSpeed"), _T("0"));
+ MI.Option(_T("Demux"), Ztring());
+ size_t MiOpenResult=MI.Open(File_Name);
+ MI.Option(_T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
+ MI.Option(_T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
+ if (MiOpenResult)
+ {
+ Fill(Stream_General, 0, General_Format_Settings, MI.Get(Stream_General, 0, General_Format_Settings), true);
+ Fill(Stream_General, 0, General_Duration, MI.Get(Stream_General, 0, General_Duration), true);
+ Fill(Stream_General, 0, General_FileSize, MI.Get(Stream_General, 0, General_FileSize), true);
+ }
+ }
+ break;
+ default : ;
+ }
+ }
+
+ }
+
+ Config->State_Set(((float)Buffer_TotalBytes)/Config->File_Size);
+ }
+ }
+
+ if ((IsCheckingRandomAccessTable || IsCheckingFooterPartitionAddress) && File_Offset+Buffer_Offset+16<File_Size)
+ {
+ if (Buffer_Offset+16>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ if (CC4(Buffer+Buffer_Offset)!=0x060E2B34 || CC3(Buffer+Buffer_Offset+4)!=0x020501 || CC3(Buffer+Buffer_Offset+8)!=0x0D0102 || CC1(Buffer+Buffer_Offset+12)!=0x01)
+ {
+ if (IsCheckingRandomAccessTable || (IsCheckingFooterPartitionAddress && FooterPartitionAddress_Jumped))
+ TryToFinish(); //No footer
+ else if (IsCheckingFooterPartitionAddress)
+ {
+ IsParsingEnd=true;
+ GoToFromEnd(4); //For random access table
+ FooterPartitionAddress_Jumped=true;
+ Open_Buffer_Unsynch();
+ }
+ }
+ IsCheckingRandomAccessTable=false;
+ IsCheckingFooterPartitionAddress=false;
+ }
+
+ if (Config_ParseSpeed<1.0 && File_Offset+Buffer_Offset+4==File_Size)
+ {
+ int32u Length;
+ Get_B4 (Length, "Length (Random Index)");
+ if (Length>=16+4 && Length<File_Size/2)
+ {
+ GoToFromEnd(Length); //For random access table
+ Open_Buffer_Unsynch();
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Read_Buffer_AfterParsing()
+{
+ if (File_Offset+Buffer_Offset>=IsParsingMiddle_MaxOffset)
+ {
+ Fill();
+ Open_Buffer_Unsynch();
+ Finish();
+ return;
+ }
+
+ if (File_Offset+Buffer_Size>=File_Size)
+ {
+ if (IsParsingEnd)
+ {
+ if (PartitionMetadata_PreviousPartition && RandomIndexMetadatas.empty() && !RandomIndexMetadatas_AlreadyParsed)
+ {
+ Partitions_Pos=0;
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset!=PartitionMetadata_PreviousPartition)
+ Partitions_Pos++;
+ if (Partitions_Pos==Partitions.size())
+ {
+ GoTo(PartitionMetadata_PreviousPartition);
+ Open_Buffer_Unsynch();
+ return;
+ }
+ }
+ }
+
+ //Checking if we want to seek again
+ if (File_GoTo==(int64u)-1)
+ TryToFinish();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Read_Buffer_Unsynched()
+{
+ //Adapting DataSizeToParse
+ if (Buffer_End)
+ {
+ if (File_GoTo>=Buffer_End //Too much late
+ || File_GoTo<=Buffer_Begin) //Too much early
+ {
+ Buffer_Begin=(int64u)-1;
+ Buffer_End=0;
+ Buffer_Header_Size=0;
+ MustSynchronize=true;
+ Synched=false;
+ }
+ else
+ Synched=true; //Always in clip data
+ }
+
+ for (essences::iterator Essence=Essences.begin(); Essence!=Essences.end(); Essence++)
+ if (Essence->second.Parser)
+ {
+ Essence->second.Parser->Open_Buffer_Unsynch();
+ Essence->second.FrameInfo=frame_info();
+ if (!File_GoTo)
+ Essence->second.FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000);
+ Essence->second.Frame_Count_NotParsedIncluded=File_GoTo?(int64u)-1:0;
+ }
+ if (File_GoTo)
+ Frame_Count_NotParsedIncluded=(int64u)-1;
+ else
+ {
+ FrameInfo=frame_info();
+ FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000);
+ Frame_Count_NotParsedIncluded=0;
+ }
+
+ Partitions_Pos=0;
+ if (Partitions_IsCalculatingHeaderByteCount)
+ {
+ Partitions.erase(Partitions.end()-1);
+ Partitions_IsCalculatingHeaderByteCount=false;
+ }
+ if (Partitions_IsCalculatingSdtiByteCount)
+ Partitions_IsCalculatingSdtiByteCount=false;
+ Essences_FirstEssence_Parsed=false;
+
+ #if MEDIAINFO_SEEK
+ IndexTables_Pos=0;
+ #endif //MEDIAINFO_SEEK
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_Mxf::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ if (ReferenceFiles)
+ return ReferenceFiles->Read_Buffer_Seek(Method, Value, ID);
+
+ //Init
+ if (!Duration_Detected)
+ {
+ MediaInfo_Internal MI;
+ MI.Option(_T("File_KeepInfo"), _T("1"));
+ Ztring ParseSpeed_Save=MI.Option(_T("ParseSpeed_Get"), _T(""));
+ Ztring Demux_Save=MI.Option(_T("Demux_Get"), _T(""));
+ MI.Option(_T("ParseSpeed"), _T("0"));
+ MI.Option(_T("Demux"), Ztring());
+ size_t MiOpenResult=MI.Open(File_Name);
+ MI.Option(_T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
+ MI.Option(_T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
+ if (!MiOpenResult || MI.Get(Stream_General, 0, General_Format)!=_T("MXF"))
+ return 0;
+ Partitions=((File_Mxf*)MI.Info)->Partitions;
+ std::sort(Partitions.begin(), Partitions.end());
+ IndexTables=((File_Mxf*)MI.Info)->IndexTables;
+ std::sort(IndexTables.begin(), IndexTables.end());
+ SDTI_SizePerFrame=((File_Mxf*)MI.Info)->SDTI_SizePerFrame;
+ Clip_Begin=((File_Mxf*)MI.Info)->Clip_Begin;
+ Clip_End=((File_Mxf*)MI.Info)->Clip_End;
+ Clip_Header_Size=((File_Mxf*)MI.Info)->Clip_Header_Size;
+ Clip_Code=((File_Mxf*)MI.Info)->Clip_Code;
+ if (MI.Get(Stream_General, 0, General_OverallBitRate_Mode)==_T("CBR") && Partitions.size()==2 && Partitions[0].FooterPartition==Partitions[1].StreamOffset && !Descriptors.empty())
+ {
+ //Searching duration
+ int64u Duration=0;
+ for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ if (Descriptor->second.Duration!=(int64u)-1 && Descriptor->second.Duration)
+ {
+ if (Duration && Duration!=Descriptor->second.Duration)
+ {
+ Duration=0;
+ break; //Not supported
+ }
+ Duration=Descriptor->second.Duration;
+ }
+
+ //Computing the count of bytes per frame
+ if (Duration)
+ {
+ int64u Begin=Partitions[0].StreamOffset+Partitions[0].PartitionPackByteCount+Partitions[0].HeaderByteCount+Partitions[0].IndexByteCount;
+ float64 BytesPerFrameF=((float64)(Partitions[0].FooterPartition-Begin)/Duration);
+ OverallBitrate_IsCbrForSure=float64_int64s(BytesPerFrameF);
+ if (OverallBitrate_IsCbrForSure!=BytesPerFrameF) //Testing integrity of the computing
+ OverallBitrate_IsCbrForSure=0;
+ }
+ }
+ Duration_Detected=true;
+ }
+
+ //Parsing
+ switch (Method)
+ {
+ case 0 :
+ {
+ //Calculating the byte count not included in seek information (partition, index...)
+ Partitions_Pos=0;
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset<Value)
+ Partitions_Pos++;
+ if (Partitions_Pos && (Partitions_Pos==Partitions.size() || Partitions[Partitions_Pos].StreamOffset!=Value))
+ Partitions_Pos--; //This is the previous item
+ if (Partitions_Pos>=Partitions.size())
+ {
+ GoTo(0);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ int64u StreamOffset_Offset=Partitions[Partitions_Pos].StreamOffset-Partitions[Partitions_Pos].BodyOffset+Partitions[Partitions_Pos].PartitionPackByteCount+Partitions[Partitions_Pos].HeaderByteCount+Partitions[Partitions_Pos].IndexByteCount;
+
+ //If in header
+ if ((Clip_Begin!=(int64u)-1 && Value<Clip_Begin) || Value<StreamOffset_Offset)
+ {
+ GoTo(0);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+
+ if (Buffer_End
+ && Descriptors.size()==1 && Descriptors.begin()->second.ByteRate!=(int32u)-1 && Descriptors.begin()->second.BlockAlign && Descriptors.begin()->second.BlockAlign!=(int16u)-1 && Descriptors.begin()->second.SampleRate)
+ {
+ if (Value>StreamOffset_Offset)
+ {
+ float64 BytesPerFrame=Descriptors.begin()->second.ByteRate/Descriptors.begin()->second.SampleRate;
+ int64u FrameCount=(int64u)((Value-Buffer_Begin)/BytesPerFrame);
+ int64u SizeBlockAligned=float64_int64s(FrameCount*BytesPerFrame);
+ SizeBlockAligned/=Descriptors.begin()->second.BlockAlign;
+ SizeBlockAligned*=Descriptors.begin()->second.BlockAlign;
+
+ GoTo(Buffer_Begin+SizeBlockAligned);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ }
+ else if (Buffer_End
+ && !IndexTables.empty() && IndexTables[0].EditUnitByteCount)
+ {
+ int64u Stream_Offset=0;
+ for (size_t Pos=0; Pos<IndexTables.size(); Pos++)
+ {
+ if (IndexTables[Pos].IndexDuration==0 || Value<StreamOffset_Offset+Stream_Offset+IndexTables[Pos].IndexDuration*IndexTables[Pos].EditUnitByteCount)
+ {
+ int64u FrameToAdd=(Value-(StreamOffset_Offset+Stream_Offset))/IndexTables[Pos].EditUnitByteCount;
+ Stream_Offset+=FrameToAdd*IndexTables[Pos].EditUnitByteCount;
+
+ GoTo(Buffer_Begin+Stream_Offset);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ else
+ Stream_Offset+=IndexTables[Pos].IndexDuration*IndexTables[Pos].EditUnitByteCount;
+ }
+ return 2; //Invalid value
+ }
+
+ GoTo(Value);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ case 1 :
+ return Read_Buffer_Seek(0, File_Size*Value/10000, ID);
+ case 2 : //Timestamp
+ {
+ //We transform TimeStamp to a frame number
+ descriptors::iterator Descriptor;
+ for (Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ if (Descriptors.begin()->second.SampleRate)
+ break;
+ if (Descriptor==Descriptors.end())
+ return (size_t)-1; //Not supported
+
+ if (TimeCode_StartTimecode!=(int64u)-1)
+ {
+ int64u Delay=float64_int64s(DTS_Delay*1000000000);
+ if (Value<Delay)
+ return 2; //Invalid value
+ Value-=Delay;
+ }
+ Value=float64_int64s(((float64)Value)/1000000000*Descriptor->second.SampleRate);
+ }
+ //No break;
+ case 3 : //FrameNumber
+ if (Descriptors.size()==1 && Descriptors.begin()->second.ByteRate!=(int32u)-1 && Descriptors.begin()->second.BlockAlign && Descriptors.begin()->second.BlockAlign!=(int16u)-1 && Descriptors.begin()->second.SampleRate)
+ {
+ //Config - TODO: merge with the one in Data_Parse()
+ if (!Essences_FirstEssence_Parsed)
+ {
+ if (Demux_UnpacketizeContainer && Descriptors.size()==1 && Descriptors.begin()->second.StreamKind==Stream_Audio)
+ {
+ //Configuring bitrate is not available in descriptor
+ if (Descriptors.begin()->second.ByteRate==(int32u)-1 && Descriptors.begin()->second.Infos.find("SamplingRate")!=Descriptors.begin()->second.Infos.end())
+ {
+ int32u SamplingRate=Descriptors.begin()->second.Infos["SamplingRate"].To_int32u();
+
+ if (Descriptors.begin()->second.BlockAlign!=(int16u)-1)
+ Descriptors.begin()->second.ByteRate=SamplingRate*Descriptors.begin()->second.BlockAlign;
+ else if (Descriptors.begin()->second.QuantizationBits!=(int8u)-1)
+ Descriptors.begin()->second.ByteRate=SamplingRate*Descriptors.begin()->second.QuantizationBits/8;
+ }
+
+ //Configuring EditRate if needed (e.g. audio at 48000 Hz)
+ if (Demux_Rate) //From elsewhere
+ {
+ Descriptors.begin()->second.SampleRate=Demux_Rate;
+ }
+ else if (Descriptors.begin()->second.SampleRate>1000)
+ {
+ Descriptors.begin()->second.SampleRate=25; //Default value
+ }
+ }
+
+ Essences_FirstEssence_Parsed=true;
+ }
+
+ float64 BytesPerFrame=Descriptors.begin()->second.ByteRate/Descriptors.begin()->second.SampleRate;
+ int64u StreamOffset=(int64u)(Value*BytesPerFrame);
+ StreamOffset/=Descriptors.begin()->second.BlockAlign;
+ StreamOffset*=Descriptors.begin()->second.BlockAlign;
+
+ //Calculating the byte count not included in seek information (partition, index...)
+ int64u StreamOffset_Offset=0;
+ Partitions_Pos=0;
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset<=StreamOffset_Offset+StreamOffset+Value*SDTI_SizePerFrame)
+ {
+ StreamOffset_Offset+=Partitions[Partitions_Pos].PartitionPackByteCount+Partitions[Partitions_Pos].HeaderByteCount+Partitions[Partitions_Pos].IndexByteCount;
+ Partitions_Pos++;
+ }
+
+ if (Clip_Begin!=(int64u)-1)
+ {
+ Buffer_Begin=Clip_Begin;
+ Buffer_End=Clip_End;
+ Buffer_Header_Size=Clip_Header_Size;
+ Code=Clip_Code;
+ MustSynchronize=false;
+ #if MEDIAINFO_DEMUX
+ if (Buffer_End && Demux_UnpacketizeContainer && Essences.size()==1 && Essences.begin()->second.Parser && Essences.begin()->second.Parser->Demux_UnpacketizeContainer)
+ {
+ Essences.begin()->second.Parser->Demux_Level=1; //Frame
+ Essences.begin()->second.Parser->Demux_UnpacketizeContainer=false;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ GoTo(StreamOffset_Offset+Buffer_Header_Size+StreamOffset+Value*SDTI_SizePerFrame);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ else if (!IndexTables.empty() && IndexTables[0].EditUnitByteCount)
+ {
+ if (Descriptors.size()==1 && Descriptors.begin()->second.SampleRate!=IndexTables[0].IndexEditRate)
+ {
+ float64 ValueF=(float64)Value;
+ ValueF/=Descriptors.begin()->second.SampleRate;
+ ValueF*=IndexTables[0].IndexEditRate;
+ Value=float64_int64s(ValueF);
+ }
+
+ if (IndexTables[IndexTables.size()-1].IndexDuration && IndexTables[IndexTables.size()-1].IndexStartPosition!=(int64u)-1 && Value>=IndexTables[IndexTables.size()-1].IndexStartPosition+IndexTables[IndexTables.size()-1].IndexDuration) //Considering IndexDuration=0 as unlimited
+ return 2; //Invalid value
+
+ int64u StreamOffset=0;
+ for (size_t Pos=0; Pos<IndexTables.size(); Pos++)
+ {
+ if (IndexTables[Pos].IndexDuration && Value>IndexTables[Pos].IndexStartPosition+IndexTables[Pos].IndexDuration) //Considering IndexDuration=0 as unlimited
+ StreamOffset+=IndexTables[Pos].EditUnitByteCount*IndexTables[Pos].IndexDuration;
+ else
+ {
+ StreamOffset+=IndexTables[Pos].EditUnitByteCount*(Value-IndexTables[Pos].IndexStartPosition);
+ break;
+ }
+ }
+
+ //Calculating the byte count not included in seek information (partition, index...)
+ int64u StreamOffset_Offset=0;
+ Partitions_Pos=0;
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset<=StreamOffset_Offset+StreamOffset+Value*SDTI_SizePerFrame)
+ {
+ StreamOffset_Offset+=Partitions[Partitions_Pos].PartitionPackByteCount+Partitions[Partitions_Pos].HeaderByteCount+Partitions[Partitions_Pos].IndexByteCount;
+ Partitions_Pos++;
+ }
+
+ if (Clip_Begin!=(int64u)-1)
+ {
+ Buffer_Begin=Clip_Begin;
+ Buffer_End=Clip_End;
+ Buffer_Header_Size=Clip_Header_Size;
+ Code=Clip_Code;
+ MustSynchronize=false;
+ #if MEDIAINFO_DEMUX
+ if (Buffer_End && Demux_UnpacketizeContainer && Essences.size()==1 && Essences.begin()->second.Parser && Essences.begin()->second.Parser->Demux_UnpacketizeContainer)
+ {
+ Essences.begin()->second.Parser->Demux_Level=1; //Frame
+ Essences.begin()->second.Parser->Demux_UnpacketizeContainer=false;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ GoTo(StreamOffset_Offset+Buffer_Header_Size+StreamOffset+Value*SDTI_SizePerFrame);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ else if (!IndexTables.empty() && !IndexTables[0].Entries.empty())
+ {
+ for (size_t Pos=0; Pos<IndexTables.size(); Pos++)
+ {
+ if (Value>=IndexTables[Pos].IndexStartPosition && Value<IndexTables[Pos].IndexStartPosition+IndexTables[Pos].IndexDuration)
+ {
+ while (Value>=IndexTables[Pos].IndexStartPosition && IndexTables[Pos].Entries[(size_t)(Value-IndexTables[Pos].IndexStartPosition)].Type)
+ {
+ Value--;
+ if (Value<IndexTables[Pos].IndexStartPosition)
+ {
+ if (Pos==0)
+ break; //There is a problem
+ Pos--; //In previous index
+ }
+ }
+
+ int64u StreamOffset=IndexTables[Pos].Entries[(size_t)(Value-IndexTables[Pos].IndexStartPosition)].StreamOffset;
+
+ //Calculating the byte count not included in seek information (partition, index...)
+ int64u StreamOffset_Offset=0;
+ Partitions_Pos=0;
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset<=StreamOffset_Offset+StreamOffset+Value*SDTI_SizePerFrame)
+ {
+ StreamOffset_Offset+=Partitions[Partitions_Pos].PartitionPackByteCount+Partitions[Partitions_Pos].HeaderByteCount+Partitions[Partitions_Pos].IndexByteCount;
+ Partitions_Pos++;
+ }
+
+ if (Clip_Begin!=(int64u)-1)
+ {
+ Buffer_Begin=Clip_Begin;
+ Buffer_End=Clip_End;
+ Buffer_Header_Size=Clip_Header_Size;
+ Code=Clip_Code;
+ MustSynchronize=false;
+ #if MEDIAINFO_DEMUX
+ if (Buffer_End && Demux_UnpacketizeContainer && Essences.size()==1 && Essences.begin()->second.Parser && Essences.begin()->second.Parser->Demux_UnpacketizeContainer)
+ {
+ Essences.begin()->second.Parser->Demux_Level=1; //Frame
+ Essences.begin()->second.Parser->Demux_UnpacketizeContainer=false;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ GoTo(StreamOffset_Offset+Buffer_Header_Size+StreamOffset+Value*SDTI_SizePerFrame);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ }
+ return 2; //Invalid value
+ }
+ else if (OverallBitrate_IsCbrForSure)
+ {
+ int64u Begin=Partitions[0].StreamOffset+Partitions[0].PartitionPackByteCount+Partitions[0].HeaderByteCount+Partitions[0].IndexByteCount;
+ GoTo(Begin+Value*OverallBitrate_IsCbrForSure);
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ else
+ return (size_t)-1; //Not supported
+ default : return (size_t)-1; //Not supported
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Mxf::FileHeader_Begin()
+{
+ //DCA uses buffer interface without filename
+ if (File_Name.empty())
+ File_Name=Config->File_FileName_Get();
+
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Mxf::Synchronize()
+{
+ //Synchronizing
+ while (Buffer_Offset+4<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x06
+ || Buffer[Buffer_Offset+1]!=0x0E
+ || Buffer[Buffer_Offset+2]!=0x2B
+ || Buffer[Buffer_Offset+3]!=0x34))
+ {
+ Buffer_Offset++;
+ while (Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x06)
+ Buffer_Offset++;
+ }
+
+
+ while (Buffer_Offset+4<=Buffer_Size
+ && CC4(Buffer+Buffer_Offset)!=0x060E2B34)
+ Buffer_Offset++;
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+4>Buffer_Size)
+ {
+ if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x060E2B)
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x060E)
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x06)
+ Buffer_Offset++;
+ return false;
+ }
+
+ if (!Status[IsAccepted])
+ {
+ Accept();
+
+ Fill(Stream_General, 0, General_Format, "MXF");
+
+ File_Buffer_Size_Hint_Pointer=Config->File_Buffer_Size_Hint_Pointer_Get();
+ #if MEDIAINFO_DEMUX
+ Demux_Interleave=Config->File_Demux_Interleave_Get();
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ //Synched is OK
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Mxf::Synched_Test()
+{
+ //Trailing 0x00
+ while(Buffer_Offset+1<=Buffer_Size && Buffer[Buffer_Offset]==0x00)
+ Buffer_Offset++;
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+16>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (CC4(Buffer+Buffer_Offset)!=0x060E2B34)
+ Synched=false;
+
+ //Trace config
+ #if MEDIAINFO_TRACE
+ if (Synched)
+ {
+ int64u Compare=CC8(Buffer+Buffer_Offset+ 4);
+ if (Compare==0x010201010D010301LL //Raw stream
+ || (Compare==0x0101010203010210LL && CC1(Buffer+Buffer_Offset+12)==0x01) //Filler
+ || (Compare==0x020501010D010301LL && CC3(Buffer+Buffer_Offset+12)==0x040101) //SDTI Package Metadata Pack
+ || (Compare==0x024301010D010301LL && CC3(Buffer+Buffer_Offset+12)==0x040102) //SDTI Package Metadata Set
+ || (Compare==0x025301010D010301LL && CC3(Buffer+Buffer_Offset+12)==0x140201)) //System Scheme 1
+ {
+ Trace_Layers_Update(8); //Stream
+ }
+ else
+ {
+ Trace_Layers_Update(0); //Container1
+ }
+ }
+ #endif //MEDIAINFO_TRACE
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Mxf::Header_Begin()
+{
+ while (Buffer_End)
+ {
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer && Descriptors.size()==1 && Descriptors.begin()->second.ByteRate!=(int32u)-1 && Descriptors.begin()->second.BlockAlign && Descriptors.begin()->second.BlockAlign!=(int16u)-1 && Descriptors.begin()->second.SampleRate)
+ {
+ float64 BytesPerFrame=((float64)Descriptors.begin()->second.ByteRate)/Descriptors.begin()->second.SampleRate;
+ int64u FramesAlreadyParsed=float64_int64s(((float64)(File_Offset+Buffer_Offset-Buffer_Begin))/BytesPerFrame);
+ Element_Size=float64_int64s(Descriptors.begin()->second.ByteRate/Descriptors.begin()->second.SampleRate*(FramesAlreadyParsed+1));
+ Element_Size/=Descriptors.begin()->second.BlockAlign;
+ Element_Size*=Descriptors.begin()->second.BlockAlign;
+ Element_Size-=File_Offset+Buffer_Offset-Buffer_Begin;
+ while (Element_Size && File_Offset+Buffer_Offset+Element_Size>Buffer_End)
+ Element_Size-=Descriptors.begin()->second.BlockAlign;
+ if (Buffer_Offset+Element_Size>Buffer_Size)
+ return false;
+ }
+ else if (Demux_UnpacketizeContainer && !IndexTables.empty() && IndexTables[0].EditUnitByteCount)
+ {
+ //Calculating the byte count not included in seek information (partition, index...)
+ int64u StreamOffset_Offset;
+ if (!Partitions.empty())
+ {
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset<File_Offset+Buffer_Offset-Header_Size)
+ Partitions_Pos++;
+ if (Partitions_Pos && (Partitions_Pos==Partitions.size() || Partitions[Partitions_Pos].StreamOffset!=File_Offset+Buffer_Offset-Header_Size))
+ Partitions_Pos--; //This is the previous item
+ StreamOffset_Offset=Partitions[Partitions_Pos].StreamOffset-Partitions[Partitions_Pos].BodyOffset+Partitions[Partitions_Pos].PartitionPackByteCount+Partitions[Partitions_Pos].HeaderByteCount+Partitions[Partitions_Pos].IndexByteCount;
+ }
+ else
+ StreamOffset_Offset=0;
+
+ int64u Position=0;
+ for (size_t Pos=0; Pos<IndexTables.size(); Pos++)
+ {
+ if (IndexTables[Pos].IndexDuration && File_Offset+Buffer_Offset>=StreamOffset_Offset+Buffer_Header_Size+Position+IndexTables[Pos].IndexDuration*IndexTables[Pos].EditUnitByteCount) //Considering IndexDuration==0 as unlimited
+ Position+=IndexTables[Pos].EditUnitByteCount*IndexTables[Pos].IndexDuration;
+ else
+ {
+ Element_Size=IndexTables[Pos].EditUnitByteCount;
+ if (File_Offset+Buffer_Offset+Element_Size>Buffer_End)
+ {
+ Element_Size=Buffer_End-(File_Offset+Buffer_Offset);
+ break; //There is a problem
+ }
+
+ if (Buffer_Offset+Element_Size>Buffer_Size)
+ {
+ //Hints
+ if (File_Buffer_Size_Hint_Pointer)
+ {
+ size_t Buffer_Size_Target=(size_t)(Buffer_Offset+Element_Size-Buffer_Size+24); //+24 for next packet header
+ if ((*File_Buffer_Size_Hint_Pointer)<Buffer_Size_Target)
+ (*File_Buffer_Size_Hint_Pointer)=Buffer_Size_Target;
+ }
+
+ return false;
+ }
+ break;
+ }
+ }
+
+ if (Buffer_Offset+(size_t)Element_Size>Buffer_Size)
+ Element_Size=Buffer_Size-Buffer_Offset; //There is a problem
+ }
+ else if (Demux_UnpacketizeContainer && !IndexTables.empty() && !IndexTables[0].Entries.empty())
+ {
+ //Calculating the byte count not included in seek information (partition, index...)
+ int64u StreamOffset_Offset;
+ if (!Partitions.empty())
+ {
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset<File_Offset+Buffer_Offset-Header_Size)
+ Partitions_Pos++;
+ if (Partitions_Pos && (Partitions_Pos==Partitions.size() || Partitions[Partitions_Pos].StreamOffset!=File_Offset+Buffer_Offset-Header_Size))
+ Partitions_Pos--; //This is the previous item
+ StreamOffset_Offset=Partitions[Partitions_Pos].StreamOffset-Partitions[Partitions_Pos].BodyOffset+Partitions[Partitions_Pos].PartitionPackByteCount+Partitions[Partitions_Pos].HeaderByteCount+Partitions[Partitions_Pos].IndexByteCount;
+ }
+ else
+ StreamOffset_Offset=0;
+
+ int64u StreamOffset=File_Offset+Buffer_Offset-StreamOffset_Offset;
+ for (size_t Pos=0; Pos<IndexTables.size(); Pos++)
+ {
+ //Searching the right index
+ if (!IndexTables[Pos].Entries.empty() && StreamOffset>=IndexTables[Pos].Entries[0].StreamOffset+(IndexTables[Pos].IndexStartPosition)*SDTI_SizePerFrame && (Pos+1>=IndexTables.size() || StreamOffset<IndexTables[Pos+1].Entries[0].StreamOffset+(IndexTables[Pos+1].IndexStartPosition)*SDTI_SizePerFrame))
+ {
+ //Searching the frame pos
+ for (size_t EntryPos=0; EntryPos<IndexTables[Pos].Entries.size(); EntryPos++)
+ {
+ //Testing coherency
+ int64u Entry0_StreamOffset=0; //For coherency checking
+ int64u Entry_StreamOffset=IndexTables[Pos].Entries[EntryPos].StreamOffset+(IndexTables[Pos].IndexStartPosition+EntryPos)*SDTI_SizePerFrame;
+ int64u Entry1_StreamOffset=File_Size; //For coherency checking
+ if (EntryPos==0 && Pos && IndexTables[Pos-1].Entries.empty())
+ Entry0_StreamOffset=IndexTables[Pos-1].Entries[IndexTables[Pos-1].Entries.size()-1].StreamOffset+(IndexTables[Pos].IndexStartPosition+EntryPos-1)*SDTI_SizePerFrame;
+ else if (EntryPos)
+ Entry0_StreamOffset=IndexTables[Pos].Entries[EntryPos-1].StreamOffset+(IndexTables[Pos].IndexStartPosition+EntryPos-1)*SDTI_SizePerFrame;
+ if (EntryPos+1<IndexTables[Pos].Entries.size())
+ Entry1_StreamOffset=IndexTables[Pos].Entries[EntryPos+1].StreamOffset+(IndexTables[Pos].IndexStartPosition+EntryPos+1)*SDTI_SizePerFrame;
+ else if (Pos+1<IndexTables.size() && !IndexTables[Pos+1].Entries.empty())
+ Entry1_StreamOffset=IndexTables[Pos+1].Entries[0].StreamOffset+(IndexTables[Pos].IndexStartPosition+EntryPos+1)*SDTI_SizePerFrame;
+
+ if (Entry0_StreamOffset>Entry_StreamOffset || Entry_StreamOffset>Entry1_StreamOffset)
+ break; //Problem
+
+ if (StreamOffset>=Entry_StreamOffset && StreamOffset<Entry1_StreamOffset)
+ {
+ Element_Size=StreamOffset_Offset+Buffer_Header_Size+Entry1_StreamOffset-(File_Offset+Buffer_Offset);
+ if (File_Offset+Buffer_Offset+Element_Size>Buffer_End)
+ {
+ Element_Size=Buffer_End-(File_Offset+Buffer_Offset);
+ break; //There is a problem
+ }
+
+ if (Buffer_Offset+Element_Size>Buffer_Size)
+ {
+ //Hints
+ if (File_Buffer_Size_Hint_Pointer)
+ {
+ size_t Buffer_Size_Target=(size_t)(Buffer_Offset+Element_Size-Buffer_Size+24); //+24 for next packet header
+ if ((*File_Buffer_Size_Hint_Pointer)<Buffer_Size_Target)
+ (*File_Buffer_Size_Hint_Pointer)=Buffer_Size_Target;
+ }
+
+ return false;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ else
+ #endif //MEDIAINFO_DEMUX
+ if (File_Offset+Buffer_Size<=Buffer_End)
+ Element_Size=Buffer_Size-Buffer_Offset; //All the buffer is used
+ else
+ Element_Size=Buffer_End-(File_Offset+Buffer_Offset);
+
+ Element_Begin0();
+ Data_Parse();
+ Buffer_Offset+=(size_t)Element_Size;
+ Element_Size-=Element_Offset;
+ Element_Offset=0;
+ Element_End0();
+
+ if (Buffer_Offset>=Buffer_Size)
+ return false;
+
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return false;
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Header_Parse()
+{
+ //Parsing
+ int64u Length;
+ Get_UL(Code, "Code", NULL);
+ Get_BER(Length, "Length");
+
+ //Filling
+ int32u Code_Compare1=Code.hi>>32;
+ int32u Code_Compare2=(int32u)Code.hi;
+ int32u Code_Compare3=Code.lo>>32;
+ int32u Code_Compare4=(int32u)Code.lo;
+ if (Partitions_IsCalculatingHeaderByteCount)
+ {
+ if (!(Code_Compare1==Elements::Filler011
+ && (Code_Compare2&0xFFFFFF00)==(Elements::Filler012&0xFFFFFF00)
+ && Code_Compare3==Elements::Filler013))
+ {
+ Partitions_IsCalculatingHeaderByteCount=false;
+ if (Partitions_Pos<Partitions.size())
+ Partitions[Partitions_Pos].PartitionPackByteCount=File_Offset+Buffer_Offset-Partitions[Partitions_Pos].StreamOffset;
+ }
+ }
+ if (Partitions_IsCalculatingSdtiByteCount)
+ {
+ if (!((Code_Compare1==Elements::SDTI_SystemMetadataPack1
+ && (Code_Compare2&0xFF00FFFF)==(Elements::SDTI_SystemMetadataPack2&0xFF00FFFF) //Independent of Category
+ && Code_Compare3==Elements::SDTI_SystemMetadataPack3
+ && (Code_Compare4&0xFFFF0000)==(Elements::SDTI_SystemMetadataPack4&0xFFFF0000))
+ || ((Code_Compare1==Elements::Filler011
+ && (Code_Compare2&0xFFFFFF00)==(Elements::Filler012&0xFFFFFF00)
+ && Code_Compare3==Elements::Filler013))))
+ {
+ if (Partitions_Pos<Partitions.size() && !SDTI_IsInIndexStreamOffset)
+ SDTI_SizePerFrame=File_Offset+Buffer_Offset-(Partitions[Partitions_Pos].StreamOffset+Partitions[Partitions_Pos].PartitionPackByteCount+Partitions[Partitions_Pos].HeaderByteCount);
+ Partitions_IsCalculatingSdtiByteCount=false;
+ }
+ }
+
+ #if MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
+ if (!Demux_HeaderParsed && !Partitions.empty() && Partitions[Partitions.size()-1].StreamOffset+Partitions[Partitions.size()-1].PartitionPackByteCount+Partitions[Partitions.size()-1].HeaderByteCount+Partitions[Partitions.size()-1].IndexByteCount==File_Offset+Buffer_Offset)
+ {
+ Demux_HeaderParsed=true;
+
+ //Testing locators
+ Locators_CleanUp();
+
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ {
+ if (Locators.empty())
+ {
+ Config->Demux_EventWasSent=true; //First set is to indicate the user that header is parsed
+ return;
+ }
+ }
+ }
+ #endif //MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
+
+ #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ if (IsParsingEnd && PartitionPack_Parsed && !Partitions.empty() && Partitions[Partitions.size()-1].StreamOffset+Partitions[Partitions.size()-1].PartitionPackByteCount+Partitions[Partitions.size()-1].HeaderByteCount+Partitions[Partitions.size()-1].IndexByteCount==File_Offset+Buffer_Offset
+ && !(Code_Compare1==Elements::RandomIndexMetadata1 && Code_Compare2==Elements::RandomIndexMetadata2 && Code_Compare3==Elements::RandomIndexMetadata3 && Code_Compare4==Elements::RandomIndexMetadata4))
+ {
+ if (RandomIndexMetadatas.empty())
+ {
+ if (!RandomIndexMetadatas_AlreadyParsed)
+ {
+ Partitions_Pos=0;
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset!=PartitionMetadata_PreviousPartition)
+ Partitions_Pos++;
+ if (Partitions_Pos==Partitions.size())
+ {
+ GoTo(PartitionMetadata_PreviousPartition);
+ Open_Buffer_Unsynch();
+ }
+ else
+ TryToFinish();
+ }
+ }
+ else
+ {
+ GoTo(RandomIndexMetadatas[0].ByteOffset);
+ RandomIndexMetadatas.erase(RandomIndexMetadatas.begin());
+ PartitionPack_Parsed=false;
+ Open_Buffer_Unsynch();
+ }
+ return;
+ }
+ #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+
+ if (Buffer_Offset+Element_Offset+Length>(size_t)-1 || Buffer_Offset+(size_t)(Element_Offset+Length)>Buffer_Size) //Not complete
+ {
+ #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ if (Length>File_Size/2) //Divided by 2 for testing if this is a big chunk = Clip based and not frames.
+ {
+ //Calculating the byte count not included in seek information (partition, index...)
+ int64u StreamOffset_Offset;
+ if (!Partitions.empty())
+ {
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset<File_Offset+Buffer_Offset-Header_Size)
+ Partitions_Pos++;
+ if (Partitions_Pos && (Partitions_Pos==Partitions.size() || Partitions[Partitions_Pos].StreamOffset!=File_Offset+Buffer_Offset-Header_Size))
+ Partitions_Pos--; //This is the previous item
+ StreamOffset_Offset=Partitions[Partitions_Pos].StreamOffset-Partitions[Partitions_Pos].BodyOffset+Partitions[Partitions_Pos].PartitionPackByteCount+Partitions[Partitions_Pos].HeaderByteCount+Partitions[Partitions_Pos].IndexByteCount;
+ }
+ else
+ StreamOffset_Offset=0;
+
+ if (StreamOffset_Offset<=File_Offset+Buffer_Offset
+ && !Partitions_IsFooter
+ && !(Code_Compare1==Elements::OpenIncompleteHeaderPartition1 //Skipping any kind of Partition
+ && Code_Compare2==Elements::OpenIncompleteHeaderPartition2
+ && Code_Compare3==Elements::OpenIncompleteHeaderPartition3)
+ && !(Code_Compare1==Elements::IndexTableSegment1 //Skipping any kind of IndexTableSegment
+ && Code_Compare2==Elements::IndexTableSegment2
+ && Code_Compare3==Elements::IndexTableSegment3))
+ {
+ Clip_Begin=Buffer_Begin=File_Offset+Buffer_Offset+Element_Offset;
+ Clip_End=Buffer_End=Buffer_Begin+Length;
+ Clip_Header_Size=Buffer_Header_Size=Element_Offset;
+ Clip_Code=Code;
+ MustSynchronize=false;
+ Length=0;
+ }
+ }
+
+ if (Clip_Begin==(int64u)-1)
+ #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ {
+ if (Length<=File_Size/2) //Divided by 2 for testing if this is a big chunk = Clip based and not frames.))
+ {
+ if (File_Buffer_Size_Hint_Pointer)
+ {
+ int64u Buffer_Size_Target=(size_t)(Buffer_Offset+Element_Offset+Length-Buffer_Size+24); //+24 for next packet header
+
+ if ((*File_Buffer_Size_Hint_Pointer)<Buffer_Size_Target)
+ (*File_Buffer_Size_Hint_Pointer)=(size_t)Buffer_Size_Target;
+ }
+
+
+ Element_WaitForMoreData();
+ return;
+ }
+ }
+ }
+
+ #if MEDIAINFO_TRACE
+ Header_Fill_Code(0, Ztring::ToZtring(Code.hi, 16)+Ztring::ToZtring(Code.lo, 16));
+ #else //MEDIAINFO_TRACE
+ Header_Fill_Code(0);
+ #endif //MEDIAINFO_TRACE
+ Header_Fill_Size(Element_Offset+Length);
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Data_Parse()
+{
+ //Clearing
+ InstanceUID=0;
+
+ //Parsing
+ int32u Code_Compare1=Code.hi>>32;
+ int32u Code_Compare2=(int32u)Code.hi;
+ int32u Code_Compare3=Code.lo>>32;
+ int32u Code_Compare4=(int32u)Code.lo;
+ #undef ELEMENT
+ #define ELEMENT(_ELEMENT, _NAME) \
+ else if (Code_Compare1==Elements::_ELEMENT##1 \
+ && Code_Compare2==Elements::_ELEMENT##2 \
+ && Code_Compare3==Elements::_ELEMENT##3 \
+ && Code_Compare4==Elements::_ELEMENT##4) \
+ { \
+ if (!Element_IsComplete_Get()) \
+ { \
+ if (Buffer_End==0) \
+ { \
+ Element_WaitForMoreData(); \
+ return; \
+ } \
+ Skip_XX(Element_Size, "Data"); \
+ } \
+ Element_Name(_NAME); \
+ switch (Code_Compare2>>24) \
+ { \
+ case 0x01 : _ELEMENT(); break; \
+ case 0x02 : switch ((int8u)(Code_Compare2>>16)) \
+ { \
+ case 0x05 : _ELEMENT(); break; \
+ case 0x43 : _ELEMENT(); break; \
+ case 0x53 : \
+ while(Element_Offset<Element_Size) \
+ { \
+ Element_Begin0(); \
+ Element_Begin1("Header"); \
+ Get_B2 (Code2, "Code"); \
+ Get_B2 (Length2, "Length"); \
+ Element_End0(); \
+ Element_Name(Ztring().From_CC2(Code2)); \
+ \
+ int64u End=Element_Offset+Length2; \
+ _ELEMENT(); \
+ if (Element_Offset<End) \
+ Skip_XX(End-Element_Offset, "Unknown"); \
+ \
+ Element_End0(); \
+ } \
+ break; \
+ case 0x63 : _ELEMENT(); break; \
+ default : Skip_XX(Element_Size, "Unknown"); \
+ } \
+ } \
+ } \
+
+ //Parsing
+ if (0) {}
+ ELEMENT(Filler01, "Filler")
+ ELEMENT(Filler02, "Padding")
+ ELEMENT(TerminatingFiller, "Terminating Filler")
+ ELEMENT(XmlDocumentText, "XML Document Text")
+ ELEMENT(Sequence, "Sequence")
+ ELEMENT(SourceClip, "Source Clip")
+ ELEMENT(TimecodeComponent, "Timecode Component")
+ ELEMENT(ContentStorage, "Content Storage")
+ ELEMENT(EssenceContainerData, "Essence Container Data")
+ ELEMENT(CDCIEssenceDescriptor, "CDCI Essence Descriptor")
+ ELEMENT(RGBAEssenceDescriptor, "RGBA Essence Descriptor")
+ ELEMENT(Preface, "Preface")
+ ELEMENT(Identification, "Identification")
+ ELEMENT(NetworkLocator, "Network Locator")
+ ELEMENT(TextLocator, "Text Locator")
+ ELEMENT(MaterialPackage, "Material Package")
+ ELEMENT(SourcePackage, "Source Package")
+ ELEMENT(EventTrack, "Event track")
+ ELEMENT(StaticTrack, "Static Track")
+ ELEMENT(Track, "Track")
+ ELEMENT(DMSegment, "Descriptive Metadata Segment")
+ ELEMENT(GenericSoundEssenceDescriptor, "Generic Sound Essence Descriptor")
+ ELEMENT(MultipleDescriptor, "Multiple Descriptor")
+ ELEMENT(AES3PCMDescriptor, "AES3 Descriptor")
+ ELEMENT(WaveAudioDescriptor, "Wave Audio Descriptor")
+ ELEMENT(MPEG2VideoDescriptor, "MPEG-2 Video Descriptor")
+ ELEMENT(JPEG2000PictureSubDescriptor, "JPEG 2000 Picture Sub Descriptor")
+ ELEMENT(Unknown1, "Unknown Descriptor")
+ ELEMENT(AncPacketsDescriptor, "ANC Packets Descriptor")
+ ELEMENT(OpenIncompleteHeaderPartition, "Open and Incomplete Header Partition Pack")
+ ELEMENT(ClosedIncompleteHeaderPartition, "Closed and Iomplete Header Partition Pack")
+ ELEMENT(OpenCompleteHeaderPartition, "Open and Complete Header Partition Pack")
+ ELEMENT(ClosedCompleteHeaderPartition, "Closed and Complete Header Partition Pack")
+ ELEMENT(OpenIncompleteBodyPartition, "Open and Incomplete Body Partition Pack")
+ ELEMENT(ClosedIncompleteBodyPartition, "Closed and Iomplete Body Partition Pack")
+ ELEMENT(OpenCompleteBodyPartition, "Open and Complete Body Partition Pack")
+ ELEMENT(ClosedCompleteBodyPartition, "Closed and Complete Body Partition Pack")
+ ELEMENT(OpenIncompleteFooterPartition, "Open and Incomplete Footer Partition Pack")
+ ELEMENT(ClosedIncompleteFooterPartition, "Closed and Iomplete Footer Partition Pack")
+ ELEMENT(OpenCompleteFooterPartition, "Open and Complete Footer Partition Pack")
+ ELEMENT(ClosedCompleteFooterPartition, "Closed and Complete Footer Partition Pack")
+ ELEMENT(Primer, "Primer")
+ ELEMENT(IndexTableSegment, "Index Table (Segment)")
+ ELEMENT(RandomIndexMetadata, "Random Index Metadata")
+ ELEMENT(SDTI_SystemMetadataPack, "SDTI System Metadata Pack")
+ else if (Code_Compare1==Elements::SDTI_SystemMetadataPack1
+ && ((Code_Compare2)&0xFF00FFFF)==(Elements::SDTI_SystemMetadataPack2&0xFF00FFFF)
+ && Code_Compare3==Elements::SDTI_SystemMetadataPack3
+ && ((Code_Compare4)&0xFFFF0000)==(Elements::SDTI_SystemMetadataPack4&0xFFFF0000))
+ {
+ Code_Compare4&=0xFFFFFF00; //Remove MetaData Block Count
+ if (0) {}
+ ELEMENT(SDTI_PackageMetadataSet, "SDTI Package Metadata Set")
+ ELEMENT(SDTI_PictureMetadataSet, "SDTI Picture Metadata Set")
+ ELEMENT(SDTI_SoundMetadataSet, "SDTI Sound Metadata Set")
+ ELEMENT(SDTI_DataMetadataSet, "SDTI Data Metadata Set")
+ ELEMENT(SDTI_ControlMetadataSet, "SDTI Control Metadata Set")
+ }
+ ELEMENT(SystemScheme1, "System Scheme 1") //SMPTE 405M
+ ELEMENT(Omneon_010201010100, "Omneon (010201010100)")
+ ELEMENT(Omneon_010201020100, "Omneon (010201020100)")
+ else if (Code_Compare1==Elements::GenericContainer_Aaf1
+ && Code_Compare2==Elements::GenericContainer_Aaf2
+ && (Code_Compare3==Elements::GenericContainer_Aaf3
+ || Code_Compare3==Elements::GenericContainer_Avid3))
+ {
+ Element_Name(Mxf_EssenceElement(Code));
+
+ //Config
+ #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ if (!Essences_FirstEssence_Parsed)
+ {
+ if (Demux_UnpacketizeContainer && Descriptors.size()==1 && Descriptors.begin()->second.StreamKind==Stream_Audio)
+ {
+ //Configuring bitrate is not available in descriptor
+ if (Descriptors.begin()->second.ByteRate==(int32u)-1 && Descriptors.begin()->second.Infos.find("SamplingRate")!=Descriptors.begin()->second.Infos.end())
+ {
+ int32u SamplingRate=Descriptors.begin()->second.Infos["SamplingRate"].To_int32u();
+
+ if (Descriptors.begin()->second.BlockAlign!=(int16u)-1)
+ Descriptors.begin()->second.ByteRate=SamplingRate*Descriptors.begin()->second.BlockAlign;
+ else if (Descriptors.begin()->second.QuantizationBits!=(int8u)-1)
+ Descriptors.begin()->second.ByteRate=SamplingRate*Descriptors.begin()->second.QuantizationBits/8;
+ }
+
+ //Configuring EditRate if needed (e.g. audio at 48000 Hz)
+ if (Demux_Rate) //From elsewhere
+ {
+ Descriptors.begin()->second.SampleRate=Demux_Rate;
+ }
+ else if (Descriptors.begin()->second.SampleRate>1000)
+ {
+ Descriptors.begin()->second.SampleRate=25; //Default value
+ }
+ }
+
+ Essences_FirstEssence_Parsed=true;
+ }
+ #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+
+ if (IsParsingEnd)
+ {
+ //We have the necessary for indexes, jumping to next index
+ Skip_XX(Element_Size, "Data");
+ if (RandomIndexMetadatas.empty())
+ {
+ if (!RandomIndexMetadatas_AlreadyParsed)
+ {
+ Partitions_Pos=0;
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset!=PartitionMetadata_PreviousPartition)
+ Partitions_Pos++;
+ if (Partitions_Pos==Partitions.size())
+ {
+ GoTo(PartitionMetadata_PreviousPartition);
+ Open_Buffer_Unsynch();
+ }
+ else
+ TryToFinish();
+ }
+ }
+ else
+ {
+ GoTo(RandomIndexMetadatas[0].ByteOffset);
+ RandomIndexMetadatas.erase(RandomIndexMetadatas.begin());
+ Open_Buffer_Unsynch();
+ }
+ return;
+ }
+
+ essences::iterator Essence=Essences.find(Code_Compare4);
+ if (Essence==Essences.end())
+ Essence=Essences.insert(make_pair(Code_Compare4,essence())).first;
+
+ if (Essence->second.Parser==NULL)
+ {
+ //Format_Settings_Wrapping
+ if (Descriptors.size()==1 && (Descriptors.begin()->second.Infos.find("Format_Settings_Wrapping")==Descriptors.begin()->second.Infos.end() || Descriptors.begin()->second.Infos["Format_Settings_Wrapping"].empty()) && (Buffer_End?(Buffer_End-Buffer_Begin):Element_Size)>File_Size/2) //Divided by 2 for testing if this is a big chunk = Clip based and not frames.
+ Descriptors.begin()->second.Infos["Format_Settings_Wrapping"]=_T("Clip"); //By default, not sure about it, should be from descriptor
+
+ //Searching the corresponding Track (for TrackID)
+ if (!Essence->second.TrackID_WasLookedFor)
+ {
+ for (tracks::iterator Track=Tracks.begin(); Track!=Tracks.end(); Track++)
+ if (Track->second.TrackNumber==Code_Compare4)
+ Essence->second.TrackID=Track->second.TrackID;
+ Essence->second.TrackID_WasLookedFor=true;
+ }
+
+ //Searching the corresponding Descriptor
+ for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ if (Descriptors.size()==1 || (Descriptor->second.LinkedTrackID==Essence->second.TrackID && Descriptor->second.LinkedTrackID!=(int32u)-1))
+ {
+ Essence->second.StreamPos_Initial=Essence->second.StreamPos=Code_Compare4&0x000000FF;
+ if ((Code_Compare4&0x000000FF)==0x00000000)
+ StreamPos_StartAtOne=false;
+
+ if (Descriptor->second.StreamKind==Stream_Audio && Descriptor->second.Infos.find("Format_Settings_Endianness")==Descriptor->second.Infos.end())
+ {
+ Ztring Format;
+ Format.From_Local(Mxf_EssenceCompression(Descriptor->second.EssenceCompression));
+ if (Format.empty())
+ Format.From_Local(Mxf_EssenceContainer(Descriptor->second.EssenceContainer));
+ if (Format.find(_T("PCM"))==0)
+ Descriptor->second.Infos["Format_Settings_Endianness"]=_T("Little");
+ }
+
+ Essence->second.Parser=ChooseParser(Essence, Descriptor); //Searching by the descriptor
+ if (Essence->second.Parser==NULL)
+ ChooseParser__FromEssence(Essence, Descriptor); //Searching by the track identifier
+
+ #ifdef MEDIAINFO_VC3_YES
+ if (Ztring().From_Local(Mxf_EssenceContainer(Descriptor->second.EssenceContainer))==_T("VC-3"))
+ ((File_Vc3*)Essence->second.Parser)->FrameRate=Descriptor->second.Infos["FrameRate"].To_float32();
+ #endif //MEDIAINFO_VC3_YES
+ break;
+ }
+
+ //Searching by the track identifier
+ if (Essence->second.Parser==NULL)
+ ChooseParser__FromEssence(Essence, Descriptors.end());
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ //Configuration
+ Essence->second.Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded;
+ Essence->second.FrameInfo=FrameInfo;
+ if (Essence->second.TrackID!=(int32u)-1)
+ Element_Code=Essence->second.TrackID;
+ else
+ Element_Code=Code.lo;
+ #endif //MEDIAINFO_DEMUX
+
+ if (Essence->second.Parser)
+ {
+ Element_Code=Essence->second.TrackID;
+ Open_Buffer_Init(Essence->second.Parser);
+ if (Essence->second.Parser->Status[IsFinished])
+ if (Streams_Count>0)
+ Streams_Count--;
+ }
+
+ //Stream size is sometime easy to find
+ if ((Buffer_End?(Buffer_End-Buffer_Begin):Element_Size)>=File_Size*0.98) //let imagine: if element size is 98% of file size, this is the only one element in the file
+ Essence->second.Stream_Size=Buffer_End?(Buffer_End-Buffer_Begin):Element_Size;
+
+ //Compute stream bit rate if there is only one stream
+ int64u Stream_Size;
+ if (Essence->second.Stream_Size!=(int64u)-1)
+ Stream_Size=Essence->second.Stream_Size;
+ else
+ Stream_Size=File_Size; //TODO: find a way to remove header/footer correctly
+ if (Stream_Size!=(int64u)-1 && Essence->second.Parser)
+ {
+ if (Essence->second.Parser && Descriptors.size()==1 && Descriptors.begin()->second.ByteRate!=(int32u)-1)
+ Essences.begin()->second.Parser->Stream_BitRateFromContainer=Descriptors.begin()->second.ByteRate*8;
+ else if (Descriptors.size()==1 && Descriptors.begin()->second.Infos["Duration"].To_float64())
+ Essences.begin()->second.Parser->Stream_BitRateFromContainer=((float64)Stream_Size)*8/(Descriptors.begin()->second.Infos["Duration"].To_float64()/1000);
+ }
+ }
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ if (Essence->second.TrackID!=(int32u)-1)
+ Element_Code=Essence->second.TrackID;
+ else
+ Element_Code=Code.lo;
+ Demux_Level=(Essence->second.Parser && (Essence->second.Parser->Demux_UnpacketizeContainer || Essence->second.Parser->Demux_Level==2))?4:2; //Intermediate (D-10 Audio) / Container
+ Essence->second.FrameInfo.DUR=(int64u)-1;
+ #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ //Calculating the byte count not included in seek information (partition, index...)
+ int64u StreamOffset_Offset=0;
+ Partitions_Pos=0;
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset<=File_Offset+Buffer_Offset)
+ {
+ StreamOffset_Offset+=Partitions[Partitions_Pos].PartitionPackByteCount+Partitions[Partitions_Pos].HeaderByteCount+Partitions[Partitions_Pos].IndexByteCount;
+ Partitions_Pos++;
+ }
+
+ if (Descriptors.size()==1 && Descriptors.begin()->second.ByteRate!=(int32u)-1 && Descriptors.begin()->second.SampleRate)
+ {
+ float64 BytePerFrame=Descriptors.begin()->second.ByteRate/Descriptors.begin()->second.SampleRate;
+ float64 Frame_Count_NotParsedIncluded_Precise=(File_Offset+Buffer_Offset-(StreamOffset_Offset+Buffer_Header_Size))/BytePerFrame; //In case of audio at frame rate not an integer
+ Essence->second.Frame_Count_NotParsedIncluded=float64_int64s(Frame_Count_NotParsedIncluded_Precise);
+ Essence->second.FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000+((float64)Frame_Count_NotParsedIncluded_Precise)*1000000000/Descriptors.begin()->second.SampleRate);
+ Essence->second.FrameInfo.PTS=Essence->second.FrameInfo.DTS;
+ Essence->second.FrameInfo.DUR=float64_int64s(1000000000/Descriptors.begin()->second.SampleRate);
+ Demux_random_access=true;
+ }
+ else if (!IndexTables.empty() && IndexTables[0].EditUnitByteCount)
+ {
+ int64u Position=0;
+ Essence->second.Frame_Count_NotParsedIncluded=0;
+ for (size_t Pos=0; Pos<IndexTables.size(); Pos++)
+ {
+ if (IndexTables[0].IndexDuration && File_Offset+Buffer_Offset>=((Buffer_End?Buffer_Begin:(StreamOffset_Offset+Buffer_Header_Size))+Position)+IndexTables[Pos].IndexDuration*IndexTables[Pos].EditUnitByteCount) //Considering IndexDuration=0 as unlimited
+ {
+ Position+=SDTI_SizePerFrame+IndexTables[Pos].EditUnitByteCount*IndexTables[Pos].IndexDuration;
+ Essence->second.Frame_Count_NotParsedIncluded+=IndexTables[Pos].IndexDuration;
+ }
+ else
+ {
+ int64u FramesToAdd=(File_Offset+Buffer_Offset-((Buffer_End?Buffer_Begin:(StreamOffset_Offset+Buffer_Header_Size))+Position))/IndexTables[Pos].EditUnitByteCount;
+ Position+=(SDTI_SizePerFrame+IndexTables[Pos].EditUnitByteCount)*FramesToAdd;
+ if (IndexTables[Pos].IndexEditRate)
+ {
+ if (Descriptors.size()==1 && Descriptors.begin()->second.SampleRate!=IndexTables[Pos].IndexEditRate)
+ {
+ float64 Frame_Count_NotParsedIncluded_Precise=((float64)FramesToAdd)/IndexTables[Pos].IndexEditRate*Descriptors.begin()->second.SampleRate;
+ Essence->second.Frame_Count_NotParsedIncluded+=float64_int64s(((float64)FramesToAdd)/IndexTables[Pos].IndexEditRate*Descriptors.begin()->second.SampleRate);
+ Essence->second.FrameInfo.PTS=Essence->second.FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000+((float64)Frame_Count_NotParsedIncluded_Precise)*1000000000/Descriptors.begin()->second.SampleRate);
+ }
+ else
+ {
+ Essence->second.Frame_Count_NotParsedIncluded+=FramesToAdd;
+ Essence->second.FrameInfo.PTS=Essence->second.FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000+((float64)Essence->second.Frame_Count_NotParsedIncluded)*1000000000/IndexTables[Pos].IndexEditRate);
+ }
+ }
+ else
+ Essence->second.FrameInfo.PTS=Essence->second.FrameInfo.DTS=(int64u)-1;
+ Demux_random_access=true;
+
+ break;
+ }
+ }
+ }
+ else if (!IndexTables.empty() && !IndexTables[0].Entries.empty())
+ {
+ int64u StreamOffset=File_Offset+Buffer_Offset-StreamOffset_Offset;
+ for (size_t Pos=0; Pos<IndexTables.size(); Pos++)
+ {
+ //Searching the right index
+ if (!IndexTables[Pos].Entries.empty() && StreamOffset>=IndexTables[Pos].Entries[0].StreamOffset+(IndexTables[Pos].IndexStartPosition)*SDTI_SizePerFrame && (Pos+1>=IndexTables.size() || StreamOffset<IndexTables[Pos+1].Entries[0].StreamOffset+(IndexTables[Pos+1].IndexStartPosition)*SDTI_SizePerFrame))
+ {
+ //Searching the frame pos
+ for (size_t EntryPos=0; EntryPos<IndexTables[Pos].Entries.size(); EntryPos++)
+ {
+ //Testing coherency
+ int64u Entry0_StreamOffset=0; //For coherency checking
+ int64u Entry_StreamOffset=IndexTables[Pos].Entries[EntryPos].StreamOffset+(IndexTables[Pos].IndexStartPosition+EntryPos)*SDTI_SizePerFrame;
+ int64u Entry1_StreamOffset=File_Size; //For coherency checking
+ if (EntryPos==0 && Pos && IndexTables[Pos-1].Entries.empty())
+ Entry0_StreamOffset=IndexTables[Pos-1].Entries[IndexTables[Pos-1].Entries.size()-1].StreamOffset+(IndexTables[Pos].IndexStartPosition+EntryPos-1)*SDTI_SizePerFrame;
+ else if (EntryPos)
+ Entry0_StreamOffset=IndexTables[Pos].Entries[EntryPos-1].StreamOffset+(IndexTables[Pos].IndexStartPosition+EntryPos-1)*SDTI_SizePerFrame;
+ if (EntryPos+1<IndexTables[Pos].Entries.size())
+ Entry1_StreamOffset=IndexTables[Pos].Entries[EntryPos+1].StreamOffset+(IndexTables[Pos].IndexStartPosition+EntryPos+1)*SDTI_SizePerFrame;
+ else if (Pos+1<IndexTables.size() && !IndexTables[Pos+1].Entries.empty())
+ Entry1_StreamOffset=IndexTables[Pos+1].Entries[0].StreamOffset+(IndexTables[Pos].IndexStartPosition+EntryPos+1)*SDTI_SizePerFrame;
+
+ if (Entry0_StreamOffset>Entry_StreamOffset || Entry_StreamOffset>Entry1_StreamOffset)
+ break; //Problem
+
+ if (StreamOffset>=Entry_StreamOffset && StreamOffset<Entry1_StreamOffset)
+ {
+ //Special case: we are not sure the last index is the last frame, doing nothing
+ if (Pos+1==IndexTables.size() && EntryPos+1==IndexTables[Pos].Entries.size())
+ break;
+
+ Essence->second.Frame_Count_NotParsedIncluded=IndexTables[Pos].IndexStartPosition+EntryPos;
+ if (IndexTables[Pos].IndexEditRate)
+ Essence->second.FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000+((float64)Essence->second.Frame_Count_NotParsedIncluded)/IndexTables[Pos].IndexEditRate*1000000000);
+ Demux_random_access=IndexTables[Pos].Entries[EntryPos].Type?false:true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ else if (OverallBitrate_IsCbrForSure)
+ {
+ int64u Begin=Partitions[0].StreamOffset+Partitions[0].PartitionPackByteCount+Partitions[0].HeaderByteCount+Partitions[0].IndexByteCount;
+ Essence->second.Frame_Count_NotParsedIncluded=(File_Offset+Buffer_Offset-Begin)/OverallBitrate_IsCbrForSure;
+ if (!Descriptors.empty() && Descriptors.begin()->second.SampleRate)
+ Essence->second.FrameInfo.PTS=Essence->second.FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000+((float64)Essence->second.Frame_Count_NotParsedIncluded)*1000000000/Descriptors.begin()->second.SampleRate);
+ }
+ else if (Essence->second.Frame_Count_NotParsedIncluded==0)
+ {
+ Essence->second.FrameInfo.DTS=float64_int64s(DTS_Delay*1000000000);
+ #if MEDIAINFO_DEMUX
+ if (Buffer_End && Demux_UnpacketizeContainer && Essences.size()==1 && Essences.begin()->second.Parser && !Essences.begin()->second.Parser->Demux_UnpacketizeContainer)
+ {
+ Essences.begin()->second.Parser->Demux_Level=2; //Container
+ Essences.begin()->second.Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ //Default
+ if (!Essence->second.Frame_Count_NotParsedIncluded && !Demux_random_access)
+ Demux_random_access=true;
+ #else //MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ //Hints
+ if (File_Buffer_Size_Hint_Pointer)
+ {
+ size_t Buffer_Size_Target=Header_Size+(Buffer_End?(Buffer_End-Buffer_Begin):Element_Size); //We bet this is CBR
+ if ((*File_Buffer_Size_Hint_Pointer)<Buffer_Size_Target)
+ (*File_Buffer_Size_Hint_Pointer)=Buffer_Size_Target;
+ }
+ #endif //MEDIAINFO_SEEK
+ if (!IsSub) //Updating for MXF only if MXF is not embedded in another container
+ {
+ if (Essence->second.FrameInfo.DUR==(int64u)-1)
+ {
+ if (!IndexTables.empty() && IndexTables[0].IndexEditRate)
+ Essence->second.FrameInfo.DUR=float64_int64s(1000000000/IndexTables[0].IndexEditRate);
+ else if (!Tracks.empty() && Tracks.begin()->second.EditRate) //TODO: use the corresponding track instead of the first one
+ Essence->second.FrameInfo.DUR=float64_int64s(1000000000/Tracks.begin()->second.EditRate);
+ }
+ FrameInfo=Essence->second.FrameInfo;
+ Frame_Count_NotParsedIncluded=Essence->second.Frame_Count_NotParsedIncluded;
+ }
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ #endif //MEDIAINFO_DEMUX
+
+ if (Essence->second.Parser && !Essence->second.Parser->Status[IsFinished])
+ {
+ if (Code_Compare4==0x17010201)
+ {
+ //Ancillary with
+ int16u Count;
+ Get_B2 (Count, "Number of ANC packets");
+ for (int16u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("ANC packet");
+ int16u Size;
+ Skip_B2( "Line Number");
+ Skip_B1( "Wrapping Type");
+ Skip_B1( "Payload Sample Coding");
+ Get_B2 (Size, "Payload Sample Count");
+ Skip_B4( "Size?");
+ Skip_B4( "Count?");
+ if (FrameInfo.DTS!=(int64u)-1)
+ Essence->second.Parser->FrameInfo.DTS=FrameInfo.DTS;
+ if (FrameInfo.PTS!=(int64u)-1)
+ Essence->second.Parser->FrameInfo.PTS=FrameInfo.PTS;
+ if (FrameInfo.DUR!=(int64u)-1)
+ Essence->second.Parser->FrameInfo.DUR=FrameInfo.DUR;
+ if (Essence->second.Parser->ParserName==_T("Ancillary") && (((File_Ancillary*)Essence->second.Parser)->FrameRate==0 || ((File_Ancillary*)Essence->second.Parser)->AspectRatio==0))
+ {
+ //Configuring with video info
+ for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ if (Descriptor->second.StreamKind==Stream_Video)
+ {
+ ((File_Ancillary*)Essence->second.Parser)->HasBFrames=Descriptor->second.HasBFrames;
+ ((File_Ancillary*)Essence->second.Parser)->AspectRatio=Descriptor->second.DisplayAspectRatio;
+ ((File_Ancillary*)Essence->second.Parser)->FrameRate=Descriptor->second.SampleRate;
+ break;
+ }
+ }
+ Open_Buffer_Continue(Essence->second.Parser, Buffer+Buffer_Offset+(size_t)(Element_Offset), Size);
+ if (Essence->second.Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Essence->second.Frame_Count_NotParsedIncluded+=Essence->second.Parser->Frame_Count_InThisBlock;
+ if (Essence->second.FrameInfo.DTS!=(int64u)-1 && Essence->second.FrameInfo.DUR!=(int64u)-1)
+ Essence->second.FrameInfo.DTS+=Essence->second.FrameInfo.DUR;
+ if (Essence->second.FrameInfo.PTS!=(int64u)-1 && Essence->second.FrameInfo.DUR!=(int64u)-1)
+ Essence->second.FrameInfo.PTS+=Essence->second.FrameInfo.DUR;
+ Element_Offset+=Size;
+ if (Size%4)
+ Skip_XX(4-(Size%4), "Padding");
+ Element_End0();
+ }
+ }
+ else if (Element_Size)
+ {
+ //Parsing
+ if (FrameInfo.DTS!=(int64u)-1)
+ Essence->second.Parser->FrameInfo.DTS=FrameInfo.DTS;
+ if (FrameInfo.PTS!=(int64u)-1)
+ Essence->second.Parser->FrameInfo.PTS=FrameInfo.PTS;
+ if (FrameInfo.DUR!=(int64u)-1)
+ Essence->second.Parser->FrameInfo.DUR=FrameInfo.DUR;
+ Open_Buffer_Continue(Essence->second.Parser);
+ #if MEDIAINFO_DEMUX
+ if (Buffer_End && Demux_UnpacketizeContainer && Essences.size()==1 && Essences.begin()->second.Parser && Essences.begin()->second.Parser->Demux_UnpacketizeContainer)
+ {
+ Essence->second.Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded=(int64u)-1;
+ Essence->second.FrameInfo.DTS=FrameInfo.DTS=(int64u)-1;
+ Essence->second.FrameInfo.PTS=FrameInfo.PTS=(int64u)-1;
+ }
+ else
+ #endif //MEDIAINFO_DEMUX
+ {
+ #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ if (Descriptors.size()==1 && Descriptors.begin()->second.ByteRate!=(int32u)-1 && Descriptors.begin()->second.SampleRate)
+ {
+ float64 BytePerFrame=Descriptors.begin()->second.ByteRate/Descriptors.begin()->second.SampleRate;
+ float64 Frame_Count_NotParsedIncluded_Precise=(File_Offset+Buffer_Offset+Element_Size-(StreamOffset_Offset+Buffer_Header_Size))/BytePerFrame; //In case of audio at frame rate not an integer
+ Frame_Count_NotParsedIncluded=float64_int64s(Frame_Count_NotParsedIncluded_Precise);
+ }
+ else
+ #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded+=Essence->second.Parser->Frame_Count_InThisBlock; //TODO: if !(MEDIAINFO_DEMUX || MEDIAINFO_SEEK), this is wrong for some PCM streams with ByteRate==2
+ if (FrameInfo.DTS!=(int64u)-1 && FrameInfo.DUR!=(int64u)-1)
+ FrameInfo.DTS+=FrameInfo.DUR;
+ if (FrameInfo.PTS!=(int64u)-1 && FrameInfo.DUR!=(int64u)-1)
+ FrameInfo.PTS+=FrameInfo.DUR;
+ Essence->second.Frame_Count_NotParsedIncluded=Frame_Count_NotParsedIncluded;
+ if (Essence->second.FrameInfo.DTS!=(int64u)-1 && Essence->second.FrameInfo.DUR!=(int64u)-1)
+ Essence->second.FrameInfo.DTS+=Essence->second.FrameInfo.DUR;
+ if (Essence->second.FrameInfo.PTS!=(int64u)-1 && Essence->second.FrameInfo.DUR!=(int64u)-1)
+ Essence->second.FrameInfo.PTS+=Essence->second.FrameInfo.DUR;
+ }
+
+ //Disabling this Streams
+ if (((!Essence->second.IsFilled && Essence->second.Parser->Status[IsFinished]) || Essence->second.Parser->Status[IsFilled]) || Config_ParseSpeed==0)
+ {
+ if (Streams_Count>0)
+ Streams_Count--;
+ Essence->second.IsFilled=true;
+ if (Config_ParseSpeed<1.0 && IsSub)
+ {
+ Fill();
+ Open_Buffer_Unsynch();
+ Finish();
+ }
+ }
+ }
+ }
+ else
+ Skip_XX(Element_Size, "Data");
+ }
+ else
+ Skip_XX(Element_Size, "Unknown");
+
+ if (Buffer_End && File_Offset+Buffer_Offset+Element_Size>=Buffer_End)
+ {
+ Buffer_Begin=(int64u)-1;
+ Buffer_End=0;
+ Buffer_Header_Size=0;
+ MustSynchronize=true;
+ }
+
+ if ((!IsParsingEnd && IsParsingMiddle_MaxOffset==(int64u)-1 && MediaInfoLib::Config.ParseSpeed_Get()<1.0)
+ && ((!IsSub && File_Offset>=0x4000000) //TODO: 64 MB by default (security), should be changed
+ || (Streams_Count==0 && !Descriptors.empty())))
+ {
+ Fill();
+
+ IsParsingEnd=true;
+ if (PartitionMetadata_FooterPartition!=(int64u)-1)
+ {
+ GoTo(PartitionMetadata_FooterPartition);
+ IsCheckingFooterPartitionAddress=true;
+ }
+ else
+ {
+ GoToFromEnd(4); //For random access table
+ FooterPartitionAddress_Jumped=true;
+ }
+ Open_Buffer_Unsynch();
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+#undef ELEMENT
+#define ELEMENT(_CODE, _CALL, _NAME) \
+ case 0x##_CODE : Element_Name(_NAME); _CALL(); break; \
+
+#define ELEMENT_UUID(_ELEMENT, _NAME) \
+else if (Code_Compare1==Elements::_ELEMENT##1 \
+ && Code_Compare2==Elements::_ELEMENT##2 \
+ && Code_Compare3==Elements::_ELEMENT##3 \
+ && Code_Compare4==Elements::_ELEMENT##4) \
+{ \
+ Element_Name(_NAME); \
+ _ELEMENT(); \
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::AES3PCMDescriptor()
+{
+ switch(Code2)
+ {
+ ELEMENT(3D08, AES3PCMDescriptor_AuxBitsMode, "Use of Auxiliary Bits")
+ ELEMENT(3D0D, AES3PCMDescriptor_Emphasis, "Emphasis")
+ ELEMENT(3D0F, AES3PCMDescriptor_BlockStartOffset, "Position of first Z preamble in essence stream")
+ ELEMENT(3D10, AES3PCMDescriptor_ChannelStatusMode, "Enumerated mode of carriage of channel status data")
+ ELEMENT(3D11, AES3PCMDescriptor_FixedChannelStatusData, "Fixed data pattern for channel status data")
+ ELEMENT(3D12, AES3PCMDescriptor_UserDataMode, "Mode of carriage of user data")
+ ELEMENT(3D13, AES3PCMDescriptor_FixedUserData, "Fixed data pattern for user data")
+ default: WaveAudioDescriptor();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::CDCIEssenceDescriptor()
+{
+ switch(Code2)
+ {
+ ELEMENT(3301, CDCIEssenceDescriptor_ComponentDepth, "Active bits per sample")
+ ELEMENT(3302, CDCIEssenceDescriptor_HorizontalSubsampling, "Horizontal colour subsampling")
+ ELEMENT(3303, CDCIEssenceDescriptor_ColorSiting, "Color siting")
+ ELEMENT(3304, CDCIEssenceDescriptor_BlackRefLevel, "Black refernece level")
+ ELEMENT(3305, CDCIEssenceDescriptor_WhiteReflevel, "White reference level")
+ ELEMENT(3306, CDCIEssenceDescriptor_ColorRange, "Color range")
+ ELEMENT(3307, CDCIEssenceDescriptor_PaddingBits, "Bits to round up each pixel to stored size")
+ ELEMENT(3308, CDCIEssenceDescriptor_VerticalSubsampling,"Vertical colour subsampling")
+ ELEMENT(3309, CDCIEssenceDescriptor_AlphaSampleDepth, "Bits per alpha sample")
+ ELEMENT(330B, CDCIEssenceDescriptor_ReversedByteOrder, "Luma followed by Chroma")
+ default: GenericPictureEssenceDescriptor();
+ }
+
+ if (Descriptors[InstanceUID].Infos["ColorSpace"].empty())
+ Descriptors[InstanceUID].Infos["ColorSpace"]="YUV";
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::OpenIncompleteHeaderPartition()
+{
+ //Parsing
+ PartitionMetadata();
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::ClosedIncompleteHeaderPartition()
+{
+ //Parsing
+ PartitionMetadata();
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::OpenCompleteHeaderPartition()
+{
+ //Parsing
+ PartitionMetadata();
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::ClosedCompleteHeaderPartition()
+{
+ //Parsing
+ PartitionMetadata();
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::OpenIncompleteBodyPartition()
+{
+ //Parsing
+ PartitionMetadata();
+
+ #if MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
+ if (!Demux_HeaderParsed)
+ {
+ Demux_HeaderParsed=true;
+
+ //Testing locators
+ Locators_CleanUp();
+
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ {
+ if (Locators.empty())
+ {
+ Config->Demux_EventWasSent=true; //First set is to indicate the user that header is parsed
+ return;
+ }
+ }
+ }
+ #endif //MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::ClosedIncompleteBodyPartition()
+{
+ //Parsing
+ PartitionMetadata();
+
+ #if MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
+ if (!Demux_HeaderParsed)
+ {
+ Demux_HeaderParsed=true;
+
+ //Testing locators
+ Locators_CleanUp();
+
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ {
+ if (Locators.empty())
+ {
+ Config->Demux_EventWasSent=true; //First set is to indicate the user that header is parsed
+ return;
+ }
+ }
+ }
+ #endif //MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::OpenCompleteBodyPartition()
+{
+ //Parsing
+ PartitionMetadata();
+
+ #if MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
+ if (!Demux_HeaderParsed)
+ {
+ Demux_HeaderParsed=true;
+
+ //Testing locators
+ Locators_CleanUp();
+
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ {
+ if (Locators.empty())
+ {
+ Config->Demux_EventWasSent=true; //First set is to indicate the user that header is parsed
+ return;
+ }
+ }
+ }
+ #endif //MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::ClosedCompleteBodyPartition()
+{
+ //Parsing
+ PartitionMetadata();
+
+ #if MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
+ if (!Demux_HeaderParsed)
+ {
+ Demux_HeaderParsed=true;
+
+ //Testing locators
+ Locators_CleanUp();
+
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ {
+ if (Locators.empty())
+ {
+ Config->Demux_EventWasSent=true; //First set is to indicate the user that header is parsed
+ return;
+ }
+ }
+ }
+ #endif //MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::OpenIncompleteFooterPartition()
+{
+ //Parsing
+ PartitionMetadata();
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::ClosedIncompleteFooterPartition()
+{
+ //Parsing
+ PartitionMetadata();
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::OpenCompleteFooterPartition()
+{
+ //Parsing
+ PartitionMetadata();
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::ClosedCompleteFooterPartition()
+{
+ //Parsing
+ PartitionMetadata();
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::ContentStorage()
+{
+ switch(Code2)
+ {
+ ELEMENT(1901, ContentStorage_Packages, "Packages")
+ ELEMENT(1902, ContentStorage_EssenceContainerData, "EssenceContainerData")
+ default: GenerationInterchangeObject();
+ }
+
+ if (Code2==0x3C0A && InstanceUID==Prefaces[Preface_Current].ContentStorage) //InstanceIUD
+ {
+ Element_Level--;
+ Element_Info1("Valid from Preface");
+ Element_Level++;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::DMSegment()
+{
+ switch(Code2)
+ {
+ ELEMENT(6101, DMSegment_DMFramework, "DM Framework")
+ default: StructuralComponent();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::EssenceContainerData()
+{
+ switch(Code2)
+ {
+ ELEMENT(2701, EssenceContainerData_LinkedPackageUID, "LinkedPackageUID")
+ ELEMENT(3F06, EssenceContainerData_IndexSID, "IndexSID")
+ ELEMENT(3F07, EssenceContainerData_BodySID, "BodySID")
+ default: GenerationInterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::EventTrack()
+{
+ switch(Code2)
+ {
+ ELEMENT(4901, EventTrack_EventEditRate, "Edit Rate of Event Track")
+ ELEMENT(4902, EventTrack_EventOrigin, "Offset used to resolved timeline references to this event track")
+ default: GenericTrack();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::FileDescriptor()
+{
+ switch(Code2)
+ {
+ ELEMENT(3001, FileDescriptor_SampleRate, "SampleRate")
+ ELEMENT(3002, FileDescriptor_ContainerDuration, "ContainerDuration")
+ ELEMENT(3004, FileDescriptor_EssenceContainer, "EssenceContainer")
+ ELEMENT(3005, FileDescriptor_Codec, "Codec")
+ ELEMENT(3006, FileDescriptor_LinkedTrackID, "LinkedTrackID")
+ default: GenericDescriptor();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Identification()
+{
+ switch(Code2)
+ {
+ ELEMENT(3C01, Identification_CompanyName, "CompanyName")
+ ELEMENT(3C02, Identification_ProductName, "ProductName")
+ ELEMENT(3C03, Identification_ProductVersion, "ProductVersion")
+ ELEMENT(3C04, Identification_VersionString, "VersionString")
+ ELEMENT(3C05, Identification_ProductUID, "ProductUID")
+ ELEMENT(3C06, Identification_ModificationDate , "ModificationDate ")
+ ELEMENT(3C07, Identification_ToolkitVersion, "ToolkitVersion")
+ ELEMENT(3C08, Identification_Platform, "Platform")
+ ELEMENT(3C09, Identification_ThisGenerationUID, "ThisGenerationUID")
+ default: InterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::IndexTableSegment()
+{
+ if (Element_Offset==4)
+ {
+ #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ //Testing if already parsed
+ for (size_t Pos=0; Pos<IndexTables.size(); Pos++)
+ if (File_Offset+Buffer_Offset-Header_Size==IndexTables[Pos].StreamOffset)
+ {
+ Element_Offset=Element_Size;
+ return;
+ }
+
+ IndexTables.push_back(indextable());
+ IndexTables[IndexTables.size()-1].StreamOffset=File_Offset+Buffer_Offset-Header_Size;
+ #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ }
+
+ switch(Code2)
+ {
+ ELEMENT(3F05, IndexTableSegment_EditUnitByteCount, "Edit Unit Byte Count")
+ ELEMENT(3F06, IndexTableSegment_IndexSID, "IndexSID")
+ ELEMENT(3F07, IndexTableSegment_BodySID, "BodySID")
+ ELEMENT(3F08, IndexTableSegment_SliceCount, "Slice Count")
+ ELEMENT(3F09, IndexTableSegment_DeltaEntryArray, "Delta Entry Array")
+ ELEMENT(3F0A, IndexTableSegment_IndexEntryArray, "Index Entry Array")
+ ELEMENT(3F0B, IndexTableSegment_IndexEditRate, "Index Edit Rate")
+ ELEMENT(3F0C, IndexTableSegment_IndexStartPosition, "Index Start Position")
+ ELEMENT(3F0D, IndexTableSegment_IndexDuration, "Index Duration")
+ ELEMENT(3F0E, IndexTableSegment_PosTableCount, "PosTableCount")
+ ELEMENT(8002, IndexTableSegment_8002, "8002?")
+ default: InterchangeObject();
+ }
+
+ if (Code2==0x3C0A) //InstanceIUD
+ {
+ IndexTable_NSL=0;
+ IndexTable_NPE=0;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::GenericDescriptor()
+{
+ switch(Code2)
+ {
+ ELEMENT(2F01, GenericDescriptor_Locators, "Locators")
+ default: GenerationInterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::JPEG2000PictureSubDescriptor()
+{
+ switch(Code2)
+ {
+ ELEMENT(8001, JPEG2000PictureSubDescriptor_Rsiz, "Decoder capabilities")
+ ELEMENT(8002, JPEG2000PictureSubDescriptor_Xsiz, "Width")
+ ELEMENT(8003, JPEG2000PictureSubDescriptor_Ysiz, "Height")
+ ELEMENT(8004, JPEG2000PictureSubDescriptor_XOsiz, "Horizontal offset")
+ ELEMENT(8005, JPEG2000PictureSubDescriptor_YOsiz, "Vertical offset ")
+ ELEMENT(8006, JPEG2000PictureSubDescriptor_XTsiz, "Width of one reference tile ")
+ ELEMENT(8007, JPEG2000PictureSubDescriptor_YTsiz, "Height of one reference tile ")
+ ELEMENT(8008, JPEG2000PictureSubDescriptor_XTOsiz, "Horizontal offset of the first tile")
+ ELEMENT(8009, JPEG2000PictureSubDescriptor_YTOsiz, "Vertical offset of the first tile")
+ ELEMENT(800A, JPEG2000PictureSubDescriptor_Csiz, "Number of components in the picture")
+ ELEMENT(800B, JPEG2000PictureSubDescriptor_PictureComponentSizing, "Picture components")
+ default: GenerationInterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::GenerationInterchangeObject()
+{
+ //Parsing
+ switch(Code2)
+ {
+ ELEMENT(0102, GenerationInterchangeObject_GenerationUID, "GenerationUID")
+ default: InterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::GenericPackage()
+{
+ switch(Code2)
+ {
+ ELEMENT(4401, GenericPackage_PackageUID, "PackageUID")
+ ELEMENT(4402, GenericPackage_Name, "Name")
+ ELEMENT(4403, GenericPackage_Tracks, "Tracks")
+ ELEMENT(4404, GenericPackage_PackageModifiedDate, "PackageModifiedDate")
+ ELEMENT(4405, GenericPackage_PackageCreationDate, "PackageCreationDate")
+ default: GenerationInterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::GenericPictureEssenceDescriptor()
+{
+ switch(Code2)
+ {
+ ELEMENT(3201, GenericPictureEssenceDescriptor_PictureEssenceCoding, "Identifier of the Picture Compression Scheme")
+ ELEMENT(3202, GenericPictureEssenceDescriptor_StoredHeight, "Vertical Field Size")
+ ELEMENT(3203, GenericPictureEssenceDescriptor_StoredWidth, "Horizontal Size")
+ ELEMENT(3204, GenericPictureEssenceDescriptor_SampledHeight, "Sampled height supplied to codec")
+ ELEMENT(3205, GenericPictureEssenceDescriptor_SampledWidth, "Sampled width supplied to codec")
+ ELEMENT(3206, GenericPictureEssenceDescriptor_SampledXOffset, "Offset from sampled to stored width")
+ ELEMENT(3207, GenericPictureEssenceDescriptor_SampledYOffset, "Offset from sampled to stored height")
+ ELEMENT(3208, GenericPictureEssenceDescriptor_DisplayHeight, "Displayed Height placed in Production Aperture")
+ ELEMENT(3209, GenericPictureEssenceDescriptor_DisplayWidth, "Displayed Width placed in Production Aperture")
+ ELEMENT(320A, GenericPictureEssenceDescriptor_DisplayXOffset,"Horizontal offset from the of the picture as displayed")
+ ELEMENT(320B, GenericPictureEssenceDescriptor_DisplayYOffset,"Vertical offset of the picture as displayed")
+ ELEMENT(320C, GenericPictureEssenceDescriptor_FrameLayout, "Interlace or Progressive layout")
+ ELEMENT(320D, GenericPictureEssenceDescriptor_VideoLineMap, "First active line in each field")
+ ELEMENT(320E, GenericPictureEssenceDescriptor_AspectRatio, "Aspect ratio")
+ ELEMENT(320F, GenericPictureEssenceDescriptor_AlphaTransparency, "Is Alpha Inverted")
+ ELEMENT(3210, GenericPictureEssenceDescriptor_Gamma, "Gamma")
+ ELEMENT(3211, GenericPictureEssenceDescriptor_ImageAlignmentOffset, "Byte Boundary alignment required for Low Level Essence Storage")
+ ELEMENT(3212, GenericPictureEssenceDescriptor_FieldDominance,"Number of the field which is considered temporally to come first")
+ ELEMENT(3213, GenericPictureEssenceDescriptor_ImageStartOffset, "Unused bytes before start of stored data")
+ ELEMENT(3214, GenericPictureEssenceDescriptor_ImageEndOffset,"Unused bytes before start of stored data")
+ ELEMENT(3215, GenericPictureEssenceDescriptor_SignalStandard, "Underlying signal standard")
+ ELEMENT(3216, GenericPictureEssenceDescriptor_StoredF2Offset, "Topness Adjustment for stored picture")
+ ELEMENT(3217, GenericPictureEssenceDescriptor_DisplayF2Offset, "Topness Adjustment for Displayed Picture")
+ ELEMENT(3218, GenericPictureEssenceDescriptor_ActiveFormatDescriptor, "Specifies the intended framing of the content within the displayed image")
+ default: FileDescriptor();
+ }
+
+ if (Descriptors[InstanceUID].StreamKind==Stream_Max)
+ {
+ Descriptors[InstanceUID].StreamKind=Stream_Video;
+ if (Streams_Count==(size_t)-1)
+ Streams_Count=0;
+ Streams_Count++;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::GenericSoundEssenceDescriptor()
+{
+ //Parsing
+ switch(Code2)
+ {
+ ELEMENT(3D01, GenericSoundEssenceDescriptor_QuantizationBits, "QuantizationBits")
+ ELEMENT(3D02, GenericSoundEssenceDescriptor_Locked , "Locked ")
+ ELEMENT(3D03, GenericSoundEssenceDescriptor_AudioSamplingRate, "AudioSamplingRate")
+ ELEMENT(3D04, GenericSoundEssenceDescriptor_AudioRefLevel, "AudioRefLevel")
+ ELEMENT(3D05, GenericSoundEssenceDescriptor_ElectroSpatialFormulation, "ElectroSpatialFormulation")
+ ELEMENT(3D06, GenericSoundEssenceDescriptor_SoundEssenceCompression, "SoundEssenceCompression")
+ ELEMENT(3D07, GenericSoundEssenceDescriptor_ChannelCount, "ChannelCount")
+ ELEMENT(3D0C, GenericSoundEssenceDescriptor_DialNorm, "DialNorm")
+ default: FileDescriptor();
+ }
+
+ if (Descriptors[InstanceUID].StreamKind==Stream_Max)
+ {
+ Descriptors[InstanceUID].StreamKind=Stream_Audio;
+ if (Streams_Count==(size_t)-1)
+ Streams_Count=0;
+ Streams_Count++;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::GenericTrack()
+{
+ //Parsing
+ switch(Code2)
+ {
+ ELEMENT(4801, GenericTrack_TrackID, "TrackID")
+ ELEMENT(4802, GenericTrack_TrackName, "TrackName")
+ ELEMENT(4803, GenericTrack_Sequence, "Sequence")
+ ELEMENT(4804, GenericTrack_TrackNumber, "TrackNumber")
+ default: GenerationInterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::InterchangeObject()
+{
+ //Parsing
+ switch(Code2)
+ {
+ ELEMENT(3C0A, InterchangeObject_InstanceUID, "InstanceUID")
+ default: ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::MaterialPackage()
+{
+ GenericPackage();
+
+ if (Code2==0x3C0A)
+ {
+ if (InstanceUID==Prefaces[Preface_Current].PrimaryPackage) //InstanceIUD
+ {
+ Element_Level--;
+ Element_Info1("Primary package");
+ Element_Level++;
+ }
+ for (contentstorages::iterator ContentStorage=ContentStorages.begin(); ContentStorage!=ContentStorages.end(); ContentStorage++)
+ {
+ for (size_t Pos=0; Pos<ContentStorage->second.Packages.size(); Pos++)
+ if (InstanceUID==ContentStorage->second.Packages[Pos])
+ {
+ Element_Level--;
+ Element_Info1("Valid from Content storage");
+ Element_Level++;
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::MPEG2VideoDescriptor()
+{
+ std::map<int16u, int128u>::iterator Primer_Value=Primer_Values.find(Code2);
+ if (Primer_Value==Primer_Values.end()) //if not a standard code or unknown user defined code
+ {
+ CDCIEssenceDescriptor();
+ return;
+ }
+
+ int32u Code_Compare1=Primer_Value->second.hi>>32;
+ int32u Code_Compare2=(int32u)Primer_Value->second.hi;
+ int32u Code_Compare3=Primer_Value->second.lo>>32;
+ int32u Code_Compare4=(int32u)Primer_Value->second.lo;
+ if(0);
+ ELEMENT_UUID(MPEG2VideoDescriptor_SingleSequence, "Single sequence")
+ ELEMENT_UUID(MPEG2VideoDescriptor_ConstantBFrames, "Number of B frames always constant")
+ ELEMENT_UUID(MPEG2VideoDescriptor_CodedContentType, "Coded content type")
+ ELEMENT_UUID(MPEG2VideoDescriptor_LowDelay, "Low delay")
+ ELEMENT_UUID(MPEG2VideoDescriptor_ClosedGOP, "Closed GOP")
+ ELEMENT_UUID(MPEG2VideoDescriptor_IdenticalGOP, "Identical GOP")
+ ELEMENT_UUID(MPEG2VideoDescriptor_MaxGOP, "Maximum occurring spacing between I frames")
+ ELEMENT_UUID(MPEG2VideoDescriptor_BPictureCount, "Maximum number of B pictures between P or I frames")
+ ELEMENT_UUID(MPEG2VideoDescriptor_ProfileAndLevel, "Profile and level")
+ ELEMENT_UUID(MPEG2VideoDescriptor_BitRate, "Maximum bit rate")
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::MultipleDescriptor()
+{
+ switch(Code2)
+ {
+ ELEMENT(3F01, MultipleDescriptor_SubDescriptorUIDs, "SubDescriptorUIDs")
+ default: FileDescriptor();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::NetworkLocator()
+{
+ switch(Code2)
+ {
+ ELEMENT(4001, NetworkLocator_URLString, "A URL indicating where the essence may be found.")
+ default: GenerationInterchangeObject();
+ }
+
+ if (Code2==0x3C0A)
+ {
+ for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ {
+ for (size_t Pos=0; Pos<Descriptor->second.Locators.size(); Pos++)
+ if (InstanceUID==Descriptor->second.Locators[Pos])
+ {
+ Element_Level--;
+ Element_Info1("Valid from Descriptor");
+ Element_Level++;
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Preface()
+{
+ switch(Code2)
+ {
+ ELEMENT(3B02, Preface_LastModifiedDate, "LastModifiedDate")
+ ELEMENT(3B03, Preface_ContentStorage, "ContentStorage")
+ ELEMENT(3B05, Preface_Version, "Version")
+ ELEMENT(3B06, Preface_Identifications, "Identifications")
+ ELEMENT(3B07, Preface_ObjectModelVersion, "ObjectModelVersion")
+ ELEMENT(3B08, Preface_PrimaryPackage, "PrimaryPackage")
+ ELEMENT(3B09, Preface_OperationalPattern, "OperationalPattern")
+ ELEMENT(3B0A, Preface_EssenceContainers, "EssenceContainers")
+ ELEMENT(3B0B, Preface_DMSchemes, "DMSchemes")
+ default: GenerationInterchangeObject();
+ }
+
+ if (Code2==0x3C0A) //InstanceIUD
+ {
+ Preface_Current=InstanceUID;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Primer()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("LocalTagEntryBatch");
+ int16u LocalTag;
+ int128u UID;
+ Get_B2 (LocalTag, "LocalTag"); Element_Info1(Ztring().From_CC2(LocalTag));
+ Get_UL (UID, "UID", NULL); Element_Info1(Ztring().From_UUID(UID));
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (LocalTag>=0x8000) //user defined
+ Primer_Values[LocalTag]=UID;
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::RGBAEssenceDescriptor()
+{
+ switch(Code2)
+ {
+ ELEMENT(3401, RGBAEssenceDescriptor_PixelLayout, "Pixel Layout")
+ ELEMENT(3403, RGBAEssenceDescriptor_Palette, "Palette")
+ ELEMENT(3404, RGBAEssenceDescriptor_PaletteLayout, "Palette Layout")
+ ELEMENT(3405, RGBAEssenceDescriptor_ScanningDirection, "Enumerated Scanning Direction")
+ ELEMENT(3406, RGBAEssenceDescriptor_ComponentMaxRef, "Maximum value for RGB components")
+ ELEMENT(3407, RGBAEssenceDescriptor_ComponentMinRef, "Minimum value for RGB components")
+ ELEMENT(3408, RGBAEssenceDescriptor_AlphaMaxRef, "Maximum value for alpha component")
+ ELEMENT(3409, RGBAEssenceDescriptor_AlphaMinRef, "Minimum value for alpha component")
+ default: GenericPictureEssenceDescriptor();
+ }
+
+ if (Descriptors[InstanceUID].Infos["ColorSpace"].empty())
+ Descriptors[InstanceUID].Infos["ColorSpace"]="RGB";
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::RandomIndexMetadata()
+{
+ //Parsing
+ while (Element_Offset+4<Element_Size)
+ {
+ Element_Begin1("PartitionArray");
+ randomindexmetadata RandomIndexMetadata;
+ Get_B4 (RandomIndexMetadata.BodySID, "BodySID"); Element_Info1(RandomIndexMetadata.BodySID);
+ Get_B8 (RandomIndexMetadata.ByteOffset, "ByteOffset"); Element_Info1(Ztring::ToZtring(RandomIndexMetadata.ByteOffset, 16));
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (!RandomIndexMetadatas_AlreadyParsed && PartitionPack_AlreadyParsed.find(RandomIndexMetadata.ByteOffset)==PartitionPack_AlreadyParsed.end())
+ RandomIndexMetadatas.push_back(RandomIndexMetadata);
+ FILLING_END();
+ }
+ Skip_B4( "Length");
+
+ FILLING_BEGIN();
+ if (MediaInfoLib::Config.ParseSpeed_Get()<1.0 && !RandomIndexMetadatas_AlreadyParsed && !RandomIndexMetadatas.empty())
+ {
+ IsParsingEnd=true;
+ IsCheckingRandomAccessTable=true;
+ GoTo(RandomIndexMetadatas[0].ByteOffset);
+ RandomIndexMetadatas.erase(RandomIndexMetadatas.begin());
+ Open_Buffer_Unsynch();
+ }
+ RandomIndexMetadatas_AlreadyParsed=true;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Sequence()
+{
+ switch(Code2)
+ {
+ ELEMENT(1001, Sequence_StructuralComponents, "StructuralComponents")
+ default: StructuralComponent();
+ }
+
+ if (Code2==0x3C0A)
+ {
+ for (std::map<int128u, track>::iterator Track=Tracks.begin(); Track!=Tracks.end(); Track++)
+ {
+ if (InstanceUID==Track->second.Sequence)
+ {
+ Element_Level--;
+ Element_Info1("Valid from track");
+ Element_Level++;
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::SourceClip()
+{
+ switch(Code2)
+ {
+ ELEMENT(1101, SourceClip_SourcePackageID, "SourcePackageID")
+ ELEMENT(1102, SourceClip_SourceTrackID, "SourceTrackID")
+ ELEMENT(1201, SourceClip_StartPosition, "StartPosition")
+ default: StructuralComponent();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::SourcePackage()
+{
+ switch(Code2)
+ {
+ //SourcePackage
+ ELEMENT(4701, SourcePackage_Descriptor, "Descriptor")
+ default: GenericPackage();
+ Packages[InstanceUID].IsSourcePackage=true;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::StaticTrack()
+{
+ GenericTrack();
+}
+
+//---------------------------------------------------------------------------
+//SMPTE 405M
+void File_Mxf::SystemScheme1()
+{
+ switch(Code2)
+ {
+ ELEMENT(0102, SystemScheme1_TimeCodeArray, "TimeCode Array")
+ default: InterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::StructuralComponent()
+{
+ switch(Code2)
+ {
+ ELEMENT(0201, StructuralComponent_DataDefinition, "DataDefinition")
+ ELEMENT(0202, StructuralComponent_Duration, "Duration")
+ default: GenerationInterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::TextLocator()
+{
+ switch(Code2)
+ {
+ ELEMENT(4101, TextLocator_LocatorName, "Human-readable locator text string for manual location of essence")
+ default: GenerationInterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::TimecodeComponent()
+{
+ if (Element_Offset==4)
+ {
+ TimeCode_StartTimecode=(int64u)-1;
+ TimeCode_RoundedTimecodeBase=0;
+ TimeCode_DropFrame=false;
+ DTS_Delay=0;
+ }
+
+ switch(Code2)
+ {
+ ELEMENT(1501, TimecodeComponent_StartTimecode, "StartTimecode")
+ ELEMENT(1502, TimecodeComponent_RoundedTimecodeBase, "RoundedTimecodeBase")
+ ELEMENT(1503, TimecodeComponent_DropFrame, "DropFrame")
+ default: StructuralComponent();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::WaveAudioDescriptor()
+{
+ switch(Code2)
+ {
+ ELEMENT(3D09, WaveAudioDescriptor_AvgBps, "Average Bytes per second")
+ ELEMENT(3D0A, WaveAudioDescriptor_BlockAlign, "Sample Block alignment")
+ ELEMENT(3D0B, WaveAudioDescriptor_SequenceOffset, "Frame number of first essence")
+ ELEMENT(3D29, WaveAudioDescriptor_PeakEnvelopeVersion, "Peak envelope version information")
+ ELEMENT(3D2A, WaveAudioDescriptor_PeakEnvelopeFormat, "Format of a peak point")
+ ELEMENT(3D2B, WaveAudioDescriptor_PointsPerPeakValue, "Number of peak points per peak value")
+ ELEMENT(3D2C, WaveAudioDescriptor_PeakEnvelopeBlockSize,"Number of audio samples used to generate each peak frame")
+ ELEMENT(3D2D, WaveAudioDescriptor_PeakChannels, "Number of peak channels")
+ ELEMENT(3D2E, WaveAudioDescriptor_PeakFrames, "Number of peak frames")
+ ELEMENT(3D2F, WaveAudioDescriptor_PeakOfPeaksPosition, "Offset to the first audio sample whose absolute value is the maximum value of the entire audio file")
+ ELEMENT(3D30, WaveAudioDescriptor_PeakEnvelopeTimestamp,"Time stamp of the creation of the peak data")
+ ELEMENT(3D31, WaveAudioDescriptor_PeakEnvelopeData , "Peak envelope data")
+ ELEMENT(3D32, WaveAudioDescriptor_ChannelAssignment, "Channel assignment in use")
+ default: GenericSoundEssenceDescriptor();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Unknown1()
+{
+ //switch(Code2)
+ //{
+ // default:
+ FileDescriptor();
+ //}
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::AncPacketsDescriptor()
+{
+ //switch(Code2)
+ //{
+ // default:
+ FileDescriptor();
+ //}
+
+ if (Descriptors[InstanceUID].Type==descriptor::Type_Unknown)
+ {
+ Descriptors[InstanceUID].Type=descriptor::Type_AncPackets;
+ if (Streams_Count==(size_t)-1)
+ Streams_Count=0;
+ Streams_Count++;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Filler()
+{
+ Skip_XX(Element_Size, "Junk");
+
+ Buffer_PaddingBytes+=Element_Size;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::TerminatingFiller()
+{
+ Skip_XX(Element_Size, "Junk");
+
+ Buffer_PaddingBytes+=Element_Size;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::XmlDocumentText()
+{
+ Skip_XX(Element_Size, "XML data");
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::SDTI_SystemMetadataPack() //SMPTE 385M + 326M
+{
+ //Info for SDTI in Index StreamOffset
+ if (!SDTI_IsPresent)
+ {
+ if (!Partitions.empty() && File_Offset+Buffer_Offset<Partitions[Partitions_Pos].StreamOffset+Partitions[Partitions_Pos].BodyOffset)
+ SDTI_IsInIndexStreamOffset=false;
+ SDTI_IsPresent=true;
+ }
+
+ //Parsing
+ int8u SMB, CPR_Rate, Format;
+ bool SMB_UL_Present, SMB_CreationTimeStamp, SMB_UserTimeStamp, CPR_DropFrame;
+ Get_B1 (SMB, "System Metadata Bitmap");
+ Skip_Flags(SMB, 7, "FEC Active");
+ Get_Flags (SMB, 6, SMB_UL_Present, "SMPTE Label");
+ Get_Flags (SMB, 5, SMB_CreationTimeStamp, "Creation Date/Time");
+ Get_Flags (SMB, 4, SMB_UserTimeStamp, "User Date/Time");
+ Skip_Flags(SMB, 3, "Picture item");
+ Skip_Flags(SMB, 2, "Sound item");
+ Skip_Flags(SMB, 1, "Data item");
+ Skip_Flags(SMB, 0, "Control item");
+ BS_Begin();
+ Element_Begin1("Content Package Rate");
+ Skip_S1(2, "Reserved");
+ Get_S1 (5, CPR_Rate, "Package Rate"); //See SMPTE 326M
+ Get_SB ( CPR_DropFrame, "1.001 Flag");
+ Element_End0();
+ Element_Begin1("Content Package Type");
+ Skip_S1(3, "Stream Status");
+ Skip_SB( "Sub-package flag");
+ Skip_SB( "Transfer Mode");
+ Skip_S1(3, "Timing Mode");
+ Element_End0();
+ BS_End();
+ Skip_B2( "channel handle");
+ Skip_B2( "continuity count");
+
+ //Some computing
+ float64 FrameRate;
+ switch (CPR_Rate) //See SMPTE 326M
+ {
+ case 0x01 : FrameRate=24; break;
+ case 0x02 : FrameRate=25; break;
+ case 0x03 : FrameRate=30; break;
+ case 0x04 : FrameRate=48; break;
+ case 0x05 : FrameRate=50; break;
+ case 0x06 : FrameRate=60; break;
+ case 0x07 : FrameRate=72; break;
+ case 0x08 : FrameRate=75; break;
+ case 0x09 : FrameRate=90; break;
+ case 0x0A : FrameRate=96; break;
+ case 0x0B : FrameRate=100; break;
+ case 0x0C : FrameRate=120; break;
+ default : FrameRate=0; break;
+ }
+ if (CPR_DropFrame)
+ {
+ FrameRate*=1000;
+ FrameRate/=1001;
+ }
+
+ //Parsing
+ if (SMB_UL_Present)
+ Skip_UL( "SMPTE Universal label");
+ if (SMB_CreationTimeStamp)
+ {
+ Get_B1 (Format, "Format"); //0x81=timecode, 0x82=date-timecode
+ Skip_B8( "Time stamp");
+ Skip_B8( "Zero");
+ }
+ else
+ Skip_XX(17, "Junk");
+ if (SMB_UserTimeStamp)
+ {
+ Get_B1 (Format, "Format"); //0x81=timecode, 0x82=date-timecode, SMPTE 331M
+ Element_Begin1("TimeCode");
+ int8u Frames_Units, Frames_Tens, Seconds_Units, Seconds_Tens, Minutes_Units, Minutes_Tens, Hours_Units, Hours_Tens;
+ bool DropFrame;
+ BS_Begin();
+
+ Skip_SB( "CF - Color fame");
+ Get_SB ( DropFrame, "DP - Drop frame");
+ Get_S1 (2, Frames_Tens, "Frames (Tens)");
+ Get_S1 (4, Frames_Units, "Frames (Units)");
+
+ Skip_SB( "FP - Field Phase / BGF0");
+ Get_S1 (3, Seconds_Tens, "Seconds (Tens)");
+ Get_S1 (4, Seconds_Units, "Seconds (Units)");
+
+ Skip_SB( "BGF0 / BGF2");
+ Get_S1 (3, Minutes_Tens, "Minutes (Tens)");
+ Get_S1 (4, Minutes_Units, "Minutes (Units)");
+
+ Skip_SB( "BGF2 / Field Phase");
+ Skip_SB( "BGF1");
+ Get_S1 (2, Hours_Tens, "Hours (Tens)");
+ Get_S1 (4, Hours_Units, "Hours (Units)");
+
+ Skip_S1(4, "BG2");
+ Skip_S1(4, "BG1");
+
+ Skip_S1(4, "BG4");
+ Skip_S1(4, "BG3");
+
+ Skip_S1(4, "BG6");
+ Skip_S1(4, "BG5");
+
+ Skip_S1(4, "BG8");
+ Skip_S1(4, "BG7");
+
+ BS_End();
+
+ int64u TimeCode_ms=(int64u)(Hours_Tens *10*60*60*1000
+ + Hours_Units *60*60*1000
+ + Minutes_Tens *10*60*1000
+ + Minutes_Units *60*1000
+ + Seconds_Tens *10*1000
+ + Seconds_Units *1000
+ + (FrameRate?float64_int32s((Frames_Tens*10+Frames_Units)*1000/FrameRate):0));
+
+ Element_Info1(Ztring().Duration_From_Milliseconds(TimeCode_ms));
+
+ Element_End0();
+
+ Skip_B8( "Zero");
+
+ //TimeCode
+ if (SDTI_TimeCode_StartTimecode==(int64u)-1)
+ SDTI_TimeCode_StartTimecode=TimeCode_ms;
+ }
+ else
+ Skip_XX(17, "Junk");
+
+ //Filling
+ if (SDTI_SizePerFrame==0)
+ Partitions_IsCalculatingSdtiByteCount=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::SDTI_PackageMetadataSet()
+{
+ while (Element_Offset<Element_Size)
+ {
+ //Parsing
+ Element_Begin1("Item");
+ int128u Tag;
+ int16u Length;
+ int8u Type;
+ Get_B1 (Type, "Type");
+ Get_B2 (Length, "Length");
+ int64u End=Element_Offset+Length;
+ Get_UL (Tag, "Tag", NULL);
+ switch (Type)
+ {
+ case 0x83 : //UMID
+ {
+ Skip_UMID( );
+ Skip_UL ( "Zeroes");
+ }
+ break;
+ case 0x88 : //KLV Metadata
+ {
+ while (Element_Offset<End)
+ {
+ int64u Length;
+ Get_BER(Length, "Length");
+ switch ((Tag.lo>>16)&0xFF)
+ {
+ case 0x00 : Skip_Local(Length,"Data"); break;
+ case 0x01 : Skip_UTF16L(Length,"Data"); break;
+ default : Skip_XX(Length, "Data");
+ }
+ }
+ }
+ break;
+ default : Skip_XX(Length, "Unknown");
+ }
+ Element_End0();
+ }
+
+ //Filling
+ if (SDTI_SizePerFrame==0)
+ Partitions_IsCalculatingSdtiByteCount=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::SDTI_PictureMetadataSet()
+{
+ Skip_XX(Element_Size, "Data");
+
+ //Filling
+ if (SDTI_SizePerFrame==0)
+ Partitions_IsCalculatingSdtiByteCount=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::SDTI_SoundMetadataSet()
+{
+ Skip_XX(Element_Size, "Data");
+
+ //Filling
+ if (SDTI_SizePerFrame==0)
+ Partitions_IsCalculatingSdtiByteCount=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::SDTI_DataMetadataSet()
+{
+ Skip_XX(Element_Size, "Data");
+
+ //Filling
+ if (SDTI_SizePerFrame==0)
+ Partitions_IsCalculatingSdtiByteCount=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::SDTI_ControlMetadataSet()
+{
+ Skip_XX(Element_Size, "Data");
+
+ //Filling
+ if (SDTI_SizePerFrame==0)
+ Partitions_IsCalculatingSdtiByteCount=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Omneon_010201010100()
+{
+ //Parsing
+ switch(Code2)
+ {
+ ELEMENT(8001, Omneon_010201010100_8001, "Omneon (80.01)")
+ ELEMENT(8003, Omneon_010201010100_8003, "Omneon (80.03)")
+ default: GenerationInterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Omneon_010201020100()
+{
+ //Parsing
+ switch(Code2)
+ {
+ ELEMENT(8002, Omneon_010201020100_8002, "Omneon (80.02)")
+ ELEMENT(8003, Omneon_010201020100_8003, "Omneon (80.03)")
+ ELEMENT(8004, Omneon_010201020100_8004, "Omneon (80.04)")
+ ELEMENT(8005, Omneon_010201020100_8005, "Omneon (80.05)")
+ ELEMENT(8006, Omneon_010201020100_8006, "Omneon (80.06)")
+ default: GenerationInterchangeObject();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Track()
+{
+ //Parsing
+ switch(Code2)
+ {
+ ELEMENT(4B01, Track_EditRate, "EditRate")
+ ELEMENT(4B02, Track_Origin, "Origin")
+ default: GenericTrack();
+ }
+
+ if (Code2==0x3C0A)
+ {
+ for (packages::iterator Package=Packages.begin(); Package!=Packages.end(); Package++)
+ {
+ if (Package->first==Prefaces[Preface_Current].PrimaryPackage) //InstanceIUD
+ {
+ Element_Level--;
+ Element_Info1("Primary package");
+ Element_Level++;
+ }
+ for (size_t Pos=0; Pos<Package->second.Tracks.size(); Pos++)
+ if (InstanceUID==Package->second.Tracks[Pos])
+ {
+ Element_Level--;
+ Element_Info1("Valid from Package");
+ Element_Level++;
+ }
+ }
+ }
+}
+
+//***************************************************************************
+// Base
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// 0x3D08
+void File_Mxf::AES3PCMDescriptor_AuxBitsMode()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D0D
+void File_Mxf::AES3PCMDescriptor_Emphasis()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D0F
+void File_Mxf::AES3PCMDescriptor_BlockStartOffset()
+{
+ //Parsing
+ Info_B2(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D10
+void File_Mxf::AES3PCMDescriptor_ChannelStatusMode()
+{
+ //Parsing
+ Skip_XX(Length2, "Batch");
+}
+
+//---------------------------------------------------------------------------
+// 0x3D11
+void File_Mxf::AES3PCMDescriptor_FixedChannelStatusData()
+{
+ //Parsing
+ Skip_XX(Length2, "Data");
+}
+
+//---------------------------------------------------------------------------
+// 0x3D12
+void File_Mxf::AES3PCMDescriptor_UserDataMode()
+{
+ //Parsing
+ Skip_XX(Length2, "Data");
+}
+
+//---------------------------------------------------------------------------
+// 0x3D13
+void File_Mxf::AES3PCMDescriptor_FixedUserData()
+{
+ //Parsing
+ Skip_XX(Length2, "Data");
+}
+
+//---------------------------------------------------------------------------
+// 0x3301
+void File_Mxf::CDCIEssenceDescriptor_ComponentDepth()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ if (Data)
+ Descriptors[InstanceUID].Infos["BitDepth"].From_Number(Data);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3302
+void File_Mxf::CDCIEssenceDescriptor_HorizontalSubsampling()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].SubSampling_Horizontal=Data;
+ Subsampling_Compute(Descriptors.find(InstanceUID));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3303
+void File_Mxf::CDCIEssenceDescriptor_ColorSiting()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3304
+void File_Mxf::CDCIEssenceDescriptor_BlackRefLevel()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3305
+void File_Mxf::CDCIEssenceDescriptor_WhiteReflevel()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3306
+void File_Mxf::CDCIEssenceDescriptor_ColorRange()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3307
+void File_Mxf::CDCIEssenceDescriptor_PaddingBits()
+{
+ //Parsing
+ Info_B2(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3308
+void File_Mxf::CDCIEssenceDescriptor_VerticalSubsampling()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].SubSampling_Vertical=Data;
+ Subsampling_Compute(Descriptors.find(InstanceUID));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3309
+void File_Mxf::CDCIEssenceDescriptor_AlphaSampleDepth()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x330B
+void File_Mxf::CDCIEssenceDescriptor_ReversedByteOrder()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x1901
+void File_Mxf::ContentStorage_Packages()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ int128u Data;
+ Get_UUID(Data, "Package");
+
+ FILLING_BEGIN();
+ Element_Info1C((Data==Prefaces[Preface_Current].PrimaryPackage), "Primary package");
+ ContentStorages[InstanceUID].Packages.push_back(Data);
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x1902
+void File_Mxf::ContentStorage_EssenceContainerData()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ Skip_UUID( "EssenceContainer");
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x6101
+void File_Mxf::DMSegment_DMFramework()
+{
+ //Parsing
+ Info_UUID(Data, "DM Framework"); Element_Info1(Ztring().From_UUID(Data));
+}
+
+//---------------------------------------------------------------------------
+// 0x2701
+void File_Mxf::EssenceContainerData_LinkedPackageUID()
+{
+ //Parsing
+ Skip_UMID();
+}
+
+//---------------------------------------------------------------------------
+// 0x3F06
+void File_Mxf::EssenceContainerData_IndexSID()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3F07
+void File_Mxf::EssenceContainerData_BodySID()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x4901
+void File_Mxf::EventTrack_EventEditRate()
+{
+ //Parsing
+ Info_Rational();
+}
+
+//---------------------------------------------------------------------------
+// 0x4902
+void File_Mxf::EventTrack_EventOrigin()
+{
+ //Parsing
+ Info_B8(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3001
+void File_Mxf::FileDescriptor_SampleRate()
+{
+ //Parsing
+ Get_Rational(Descriptors[InstanceUID].SampleRate); Element_Info1(Descriptors[InstanceUID].SampleRate);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].Infos["FrameRate"]=Ztring().From_Number(Descriptors[InstanceUID].SampleRate, 3);
+ if (Descriptors[InstanceUID].SampleRate && Descriptors[InstanceUID].Duration!=(int64u)-1)
+ Descriptors[InstanceUID].Infos["Duration"].From_Number(Descriptors[InstanceUID].Duration/Descriptors[InstanceUID].SampleRate*1000, 0);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3002
+void File_Mxf::FileDescriptor_ContainerDuration()
+{
+ //Parsing
+ int64u Data;
+ Get_B8 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ if (Data)
+ {
+ Descriptors[InstanceUID].Duration=Data;
+ if (Descriptors[InstanceUID].SampleRate && Descriptors[InstanceUID].Duration!=(int64u)-1)
+ Descriptors[InstanceUID].Infos["Duration"].From_Number(Descriptors[InstanceUID].Duration/Descriptors[InstanceUID].SampleRate*1000, 0);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3004
+void File_Mxf::FileDescriptor_EssenceContainer()
+{
+ //Parsing
+ int128u EssenceContainer;
+ Get_UL (EssenceContainer, "EssenceContainer", Mxf_EssenceContainer); Element_Info1(Mxf_EssenceContainer(EssenceContainer));
+
+ FILLING_BEGIN();
+ int8u Code6=(int8u)((EssenceContainer.lo&0x0000000000FF0000LL)>>16);
+ int8u Code7=(int8u)((EssenceContainer.lo&0x000000000000FF00LL)>> 8);
+ int8u Code8=(int8u)((EssenceContainer.lo&0x00000000000000FFLL) );
+
+ Descriptors[InstanceUID].EssenceContainer=EssenceContainer;
+ Descriptors[InstanceUID].Infos["Format_Settings_Wrapping"].From_UTF8(Mxf_EssenceContainer_Mapping(Code6, Code7, Code8));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3005
+void File_Mxf::FileDescriptor_Codec()
+{
+ //Parsing
+ Skip_UL( "UUID");
+}
+
+//---------------------------------------------------------------------------
+// 0x3006
+void File_Mxf::FileDescriptor_LinkedTrackID()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ if (Descriptors[InstanceUID].LinkedTrackID==(int32u)-1)
+ Descriptors[InstanceUID].LinkedTrackID=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3C0A
+void File_Mxf::InterchangeObject_InstanceUID()
+{
+ //Parsing
+ Get_UUID(InstanceUID, "UUID"); Element_Info1(Ztring().From_UUID(InstanceUID));
+
+ FILLING_BEGIN();
+ //Putting the right UID for already parsed items
+ prefaces::iterator Preface=Prefaces.find(0);
+ if (Preface!=Prefaces.end())
+ {
+ Prefaces[InstanceUID]=Preface->second;
+ Prefaces.erase(Preface);
+ }
+ identifications::iterator Identification=Identifications.find(0);
+ if (Identification!=Identifications.end())
+ {
+ Identifications[InstanceUID]=Identification->second;
+ Identifications.erase(Identification);
+ }
+ contentstorages::iterator ContentStorage=ContentStorages.find(0);
+ if (ContentStorage!=ContentStorages.end())
+ {
+ ContentStorages[InstanceUID]=ContentStorage->second;
+ ContentStorages.erase(ContentStorage);
+ }
+ packages::iterator Package=Packages.find(0);
+ if (Package!=Packages.end())
+ {
+ Packages[InstanceUID]=Package->second;
+ Packages.erase(Package);
+ }
+ tracks::iterator Track=Tracks.find(0);
+ if (Track!=Tracks.end())
+ {
+ Tracks[InstanceUID]=Track->second;
+ Tracks.erase(Track);
+ }
+ descriptors::iterator Descriptor=Descriptors.find(0);
+ if (Descriptor!=Descriptors.end())
+ {
+ Descriptors[InstanceUID]=Descriptor->second;
+ Descriptors.erase(Descriptor);
+ }
+ locators::iterator Locator=Locators.find(0);
+ if (Locator!=Locators.end())
+ {
+ Locators[InstanceUID]=Locator->second;
+ Locators.erase(Locator);
+ }
+ components::iterator Component=Components.find(0);
+ if (Component!=Components.end())
+ {
+ Components[InstanceUID].Update(Component->second);
+ Components.erase(Component);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x0102
+void File_Mxf::GenerationInterchangeObject_GenerationUID()
+{
+ //Parsing
+ Skip_UUID( "UUID");
+}
+
+//---------------------------------------------------------------------------
+// 0x2F01
+void File_Mxf::GenericDescriptor_Locators()
+{
+ Descriptors[InstanceUID].Locators.clear();
+
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("Locator");
+ int128u UUID;
+ Get_UUID(UUID, "UUID");
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].Locators.push_back(UUID);
+ FILLING_END();
+
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x4401
+void File_Mxf::GenericPackage_PackageUID()
+{
+ //Parsing
+ int256u Data;
+ Get_UMID (Data, "PackageUID");
+
+ FILLING_BEGIN();
+ Packages[InstanceUID].PackageUID=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x4402
+void File_Mxf::GenericPackage_Name()
+{
+ //Parsing
+ Info_UTF16B(Length2, Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x4403
+void File_Mxf::GenericPackage_Tracks()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ int128u Data;
+ Get_UUID(Data, "Track");
+
+ FILLING_BEGIN();
+ Packages[InstanceUID].Tracks.push_back(Data);
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x4404
+void File_Mxf::GenericPackage_PackageModifiedDate()
+{
+ //Parsing
+ Info_Timestamp();
+}
+
+//---------------------------------------------------------------------------
+// 0x4405
+void File_Mxf::GenericPackage_PackageCreationDate()
+{
+ //Parsing
+ Info_Timestamp();
+}
+
+//---------------------------------------------------------------------------
+// 0x3201
+void File_Mxf::GenericPictureEssenceDescriptor_PictureEssenceCoding()
+{
+ //Parsing
+ int128u Data;
+ Get_UL(Data, "Data", Mxf_EssenceCompression); Element_Info1(Mxf_EssenceCompression(Data));
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].EssenceCompression=Data;
+ Descriptors[InstanceUID].StreamKind=Stream_Video;
+ Descriptors[InstanceUID].Infos["Format"]=Mxf_EssenceCompression(Data);
+ Descriptors[InstanceUID].Infos["Format_Version"]=Mxf_EssenceCompression_Version(Data);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3202
+void File_Mxf::GenericPictureEssenceDescriptor_StoredHeight()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ std::map<std::string, Ztring>::iterator Info=Descriptors[InstanceUID].Infos.find("ScanType");
+ if (Info!=Descriptors[InstanceUID].Infos.end() && Info->second==_T("Interlaced"))
+ Data*=2; //This is per field
+ if (Descriptors[InstanceUID].Height==(int32u)-1)
+ Descriptors[InstanceUID].Height=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3203
+void File_Mxf::GenericPictureEssenceDescriptor_StoredWidth()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ if (Descriptors[InstanceUID].Width==(int32u)-1)
+ Descriptors[InstanceUID].Width=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3204
+void File_Mxf::GenericPictureEssenceDescriptor_SampledHeight()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ std::map<std::string, Ztring>::iterator Info=Descriptors[InstanceUID].Infos.find("ScanType");
+ if (Info!=Descriptors[InstanceUID].Infos.end() && Info->second==_T("Interlaced"))
+ Data*=2; //This is per field
+ Descriptors[InstanceUID].Height=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3205
+void File_Mxf::GenericPictureEssenceDescriptor_SampledWidth()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].Width=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3206
+void File_Mxf::GenericPictureEssenceDescriptor_SampledXOffset()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3207
+void File_Mxf::GenericPictureEssenceDescriptor_SampledYOffset()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3208
+void File_Mxf::GenericPictureEssenceDescriptor_DisplayHeight()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ std::map<std::string, Ztring>::iterator Info=Descriptors[InstanceUID].Infos.find("ScanType");
+ if (Info!=Descriptors[InstanceUID].Infos.end() && Info->second==_T("Interlaced"))
+ Data*=2; //This is per field
+ Descriptors[InstanceUID].Height_Display=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3209
+void File_Mxf::GenericPictureEssenceDescriptor_DisplayWidth()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].Width_Display=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x320A
+void File_Mxf::GenericPictureEssenceDescriptor_DisplayXOffset()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].Width_Display_Offset=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x320B
+void File_Mxf::GenericPictureEssenceDescriptor_DisplayYOffset()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ std::map<std::string, Ztring>::iterator Info=Descriptors[InstanceUID].Infos.find("ScanType");
+ if (Info!=Descriptors[InstanceUID].Infos.end() && Info->second==_T("Interlaced"))
+ Data*=2; //This is per field
+ Descriptors[InstanceUID].Height_Display_Offset=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x320C
+void File_Mxf::GenericPictureEssenceDescriptor_FrameLayout()
+{
+ //Parsing
+ int8u Data;
+ Get_B1 (Data, "Data"); Element_Info1(Data); Param_Info1(Mxf_FrameLayout(Data)); Element_Info1(Mxf_FrameLayout(Data));
+
+ FILLING_BEGIN();
+ if (Data && Descriptors[InstanceUID].Infos.find("ScanType")==Descriptors[InstanceUID].Infos.end())
+ {
+ if (Descriptors[InstanceUID].Height!=(int32u)-1) Descriptors[InstanceUID].Height*=Mxf_FrameLayout_Multiplier(Data);
+ if (Descriptors[InstanceUID].Height_Display!=(int32u)-1) Descriptors[InstanceUID].Height_Display*=Mxf_FrameLayout_Multiplier(Data);
+ if (Descriptors[InstanceUID].Height_Display_Offset!=(int32u)-1) Descriptors[InstanceUID].Height_Display_Offset*=Mxf_FrameLayout_Multiplier(Data);
+ }
+ Descriptors[InstanceUID].Infos["ScanType"]=Mxf_FrameLayout_ScanType(Data);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x320D
+void File_Mxf::GenericPictureEssenceDescriptor_VideoLineMap()
+{
+ //Parsing
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ Skip_B4( "VideoLineMapEntry");
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x320E
+void File_Mxf::GenericPictureEssenceDescriptor_AspectRatio()
+{
+ //Parsing
+ float64 Data;
+ Get_Rational(Data);
+
+ FILLING_BEGIN();
+ if (Data)
+ {
+ Descriptors[InstanceUID].DisplayAspectRatio=Data;
+ Descriptors[InstanceUID].Infos["DisplayAspectRatio"].From_Number(Data, 3);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x320F
+void File_Mxf::GenericPictureEssenceDescriptor_AlphaTransparency()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3210
+void File_Mxf::GenericPictureEssenceDescriptor_Gamma()
+{
+ //Parsing
+ Skip_UL( "Data");
+}
+
+//---------------------------------------------------------------------------
+// 0x3211
+void File_Mxf::GenericPictureEssenceDescriptor_ImageAlignmentOffset()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3212
+void File_Mxf::GenericPictureEssenceDescriptor_FieldDominance()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3213
+void File_Mxf::GenericPictureEssenceDescriptor_ImageStartOffset()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3214
+void File_Mxf::GenericPictureEssenceDescriptor_ImageEndOffset()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3215
+void File_Mxf::GenericPictureEssenceDescriptor_SignalStandard()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3216
+void File_Mxf::GenericPictureEssenceDescriptor_StoredF2Offset()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3217
+void File_Mxf::GenericPictureEssenceDescriptor_DisplayF2Offset()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3218
+void File_Mxf::GenericPictureEssenceDescriptor_ActiveFormatDescriptor()
+{
+ //Parsing
+ int8u Data;
+ Get_B1 (Data, "Data"); Element_Info1C((Data<16), AfdBarData_active_format[Data]);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].ActiveFormat=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3D01
+void File_Mxf::GenericSoundEssenceDescriptor_QuantizationBits()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ if (Data)
+ {
+ Descriptors[InstanceUID].Infos["BitDepth"].From_Number(Data);
+ Descriptors[InstanceUID].QuantizationBits=Data;
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3D02
+void File_Mxf::GenericSoundEssenceDescriptor_Locked()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data?"Yes":"No");
+}
+
+//---------------------------------------------------------------------------
+// 0x3D03
+void File_Mxf::GenericSoundEssenceDescriptor_AudioSamplingRate()
+{
+ //Parsing
+ float64 Data;
+ Get_Rational(Data); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].Infos["SamplingRate"].From_Number(Data, 0);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3D04
+void File_Mxf::GenericSoundEssenceDescriptor_AudioRefLevel()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info2(Data, " dB");
+}
+
+//---------------------------------------------------------------------------
+// 0x3D05
+void File_Mxf::GenericSoundEssenceDescriptor_ElectroSpatialFormulation()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data); //Enum
+}
+
+//---------------------------------------------------------------------------
+// 0x3D06
+void File_Mxf::GenericSoundEssenceDescriptor_SoundEssenceCompression()
+{
+ //Parsing
+ int128u Data;
+ Get_UL(Data, "Data", Mxf_EssenceCompression); Element_Info1(Mxf_EssenceCompression(Data));
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].EssenceCompression=Data;
+ Descriptors[InstanceUID].StreamKind=Stream_Audio;
+ Descriptors[InstanceUID].Infos["Format"]=Mxf_EssenceCompression(Data);
+ Descriptors[InstanceUID].Infos["Format_Version"]=Mxf_EssenceCompression_Version(Data);
+ if ((Data.lo&0xFFFFFFFFFF000000LL)==0x040202017e000000LL)
+ Descriptors[InstanceUID].Infos["Format_Settings_Endianness"]=_T("Big");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3D07
+void File_Mxf::GenericSoundEssenceDescriptor_ChannelCount()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].ChannelCount=Data;
+ Descriptors[InstanceUID].Infos["Channel(s)"].From_Number(Data);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3D0C
+void File_Mxf::GenericSoundEssenceDescriptor_DialNorm()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info2(Data, " dB");
+}
+
+//---------------------------------------------------------------------------
+// 0x4801
+void File_Mxf::GenericTrack_TrackID()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ if (Tracks[InstanceUID].TrackID==(int32u)-1)
+ Tracks[InstanceUID].TrackID=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x4802
+void File_Mxf::GenericTrack_TrackName()
+{
+ //Parsing
+ Ztring Data;
+ Get_UTF16B (Length2, Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Tracks[InstanceUID].TrackName=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x4803
+void File_Mxf::GenericTrack_Sequence()
+{
+ //Parsing
+ int128u Data;
+ Get_UUID(Data, "Data"); Element_Info1(Ztring::ToZtring(Data, 16));
+
+ FILLING_BEGIN();
+ Tracks[InstanceUID].Sequence=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x4804
+void File_Mxf::GenericTrack_TrackNumber()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Ztring::ToZtring(Data, 16));
+
+ FILLING_BEGIN();
+ Tracks[InstanceUID].TrackNumber=Data;
+ Track_Number_IsAvailable=true;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3C01
+void File_Mxf::Identification_CompanyName()
+{
+ //Parsing
+ Ztring Data;
+ Get_UTF16B(Length2, Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Identifications[InstanceUID].CompanyName=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3C02
+void File_Mxf::Identification_ProductName()
+{
+ //Parsing
+ Ztring Data;
+ Get_UTF16B(Length2, Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Identifications[InstanceUID].ProductName=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3C03
+void File_Mxf::Identification_ProductVersion()
+{
+ //Parsing
+ int16u Major, Minor, Patch, Build, Release;
+ Get_B2 (Major, "Major");
+ Get_B2 (Minor, "Minor");
+ Get_B2 (Patch, "Patch");
+ Get_B2 (Build, "Build");
+ Get_B2 (Release, "Release");
+ Ztring Version=Ztring::ToZtring(Major)+_T('.')
+ +Ztring::ToZtring(Minor)+_T('.')
+ +Ztring::ToZtring(Patch)+_T('.')
+ +Ztring::ToZtring(Build)+_T('.')
+ +Ztring::ToZtring(Release) ;
+ Element_Info1(Version);
+
+ FILLING_BEGIN();
+ Identifications[InstanceUID].ProductVersion=Version;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3C04
+void File_Mxf::Identification_VersionString()
+{
+ //Parsing
+ Ztring Data;
+ Get_UTF16B(Length2, Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Identifications[InstanceUID].VersionString=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3C05
+void File_Mxf::Identification_ProductUID()
+{
+ //Parsing
+ Skip_UUID( "UUID");
+}
+
+//---------------------------------------------------------------------------
+// 0x3C06
+void File_Mxf::Identification_ModificationDate()
+{
+ //Parsing
+ Info_Timestamp();
+}
+
+//---------------------------------------------------------------------------
+// 0x3C07
+void File_Mxf::Identification_ToolkitVersion()
+{
+ //Parsing
+ //Parsing
+ Info_B2(Major, "Major");
+ Info_B2(Minor, "Minor");
+ Info_B2(Patch, "Patch");
+ Info_B2(Build, "Build");
+ Info_B2(Release, "Release");
+ Element_Info1(Ztring::ToZtring(Major)+_T('.')
+ +Ztring::ToZtring(Minor)+_T('.')
+ +Ztring::ToZtring(Patch)+_T('.')
+ +Ztring::ToZtring(Build)+_T('.')
+ +Ztring::ToZtring(Release) );
+}
+
+//---------------------------------------------------------------------------
+// 0x3C08
+void File_Mxf::Identification_Platform()
+{
+ //Parsing
+ Info_UTF16B(Length2, Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3C09
+void File_Mxf::Identification_ThisGenerationUID()
+{
+ //Parsing
+ Skip_UUID( "UUID");
+}
+
+//---------------------------------------------------------------------------
+// 0x3F05
+void File_Mxf::IndexTableSegment_EditUnitByteCount()
+{
+ //Parsing
+ int32u Data;
+ Get_B4(Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ #if MEDIAINFO_SEEK
+ IndexTables[IndexTables.size()-1].EditUnitByteCount=Data;
+ #endif //MEDIAINFO_SEEK
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3F06
+void File_Mxf::IndexTableSegment_IndexSID()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3F07
+void File_Mxf::IndexTableSegment_BodySID()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3F08
+void File_Mxf::IndexTableSegment_SliceCount()
+{
+ //Parsing
+ int8u Data;
+ Get_B1(Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ IndexTable_NSL=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3F09
+void File_Mxf::IndexTableSegment_DeltaEntryArray()
+{
+ //Parsing
+ int32u NDE, Length;
+ Get_B4(NDE, "NDE");
+ Get_B4(Length, "Length");
+ for (int32u Pos=0; Pos<NDE; Pos++)
+ {
+ Element_Begin1("Delta Entry");
+ Skip_B1( "PosTableIndex");
+ Skip_B1( "Slice");
+ Skip_B4( "Element Delta");
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x3F0A
+void File_Mxf::IndexTableSegment_IndexEntryArray()
+{
+ //Parsing
+ int32u NIE, Length;
+ Get_B4(NIE, "NIE");
+ Get_B4(Length, "Length");
+ for (int32u Pos=0; Pos<NIE; Pos++)
+ {
+ #if MEDIAINFO_SEEK
+ indextable::entry Entry;
+ int64u Stream_Offset;
+ bool forward_rediction_flag, backward_prediction_flag;
+ #endif //MEDIAINFO_SEEK
+ int8u Flags;
+ Element_Begin1("Index Entry");
+ Skip_B1( "Temporal Offset");
+ Skip_B1( "Key-Frame Offset");
+ Get_B1 (Flags, "Flags");
+ Skip_Flags(Flags, 7, "Random Access");
+ Skip_Flags(Flags, 6, "Sequence Header");
+ #if MEDIAINFO_SEEK
+ Get_Flags (Flags, 5, forward_rediction_flag, "forward prediction flag");
+ Get_Flags (Flags, 4, backward_prediction_flag, "backward prediction flag");
+ #else //MEDIAINFO_SEEK
+ Skip_Flags(Flags, 5, "forward prediction flag");
+ Skip_Flags(Flags, 4, "backward prediction flag");
+ #endif //MEDIAINFO_SEEK
+ #if MEDIAINFO_SEEK
+ Get_B8 (Stream_Offset, "Stream Offset");
+ if (IndexTables[IndexTables.size()-1].IndexDuration==0 //Filling in all cases if IndexDuration is not yet filled
+ || NIE==IndexTables[IndexTables.size()-1].IndexDuration
+ || (NIE/2==IndexTables[IndexTables.size()-1].IndexDuration && (Pos%2)==0)) //Detecting corrupted index having index position twice per frame
+ {
+ Entry.StreamOffset=Stream_Offset;
+ Entry.Type=(forward_rediction_flag?1:0)*2+(backward_prediction_flag?1:0);
+ IndexTables[IndexTables.size()-1].Entries.push_back(Entry);
+ }
+ #else //MEDIAINFO_SEEK
+ Skip_B8( "Stream Offset");
+ #endif //MEDIAINFO_SEEK
+ for (int32u NSL_Pos=0; NSL_Pos<IndexTable_NSL; NSL_Pos++)
+ Skip_B4( "SliceOffset");
+ for (int32u NPE_Pos=0; NPE_Pos<IndexTable_NPE; NPE_Pos++)
+ Skip_B4( "PosTable");
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x3F0B
+void File_Mxf::IndexTableSegment_IndexEditRate()
+{
+ //Parsing
+ float64 Data;
+ Get_Rational(Data);
+
+ FILLING_BEGIN();
+ #if MEDIAINFO_SEEK
+ IndexTables[IndexTables.size()-1].IndexEditRate=Data;
+ #endif //MEDIAINFO_SEEK
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3F0C
+void File_Mxf::IndexTableSegment_IndexStartPosition()
+{
+ //Parsing
+ int64u Data;
+ Get_B8 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ #if MEDIAINFO_SEEK
+ IndexTables[IndexTables.size()-1].IndexStartPosition=Data;
+
+ //Integrity test (in one file, I have 2 indexes with IndexStartPosition=0, the first one is weird (only one frame), or the same index is repeated
+ //Integrity test (in one file, I have 2 indexes with IndexStartPosition=0, the second one is weird (only one frame), or the same index is repeated
+ for (size_t Pos=0; Pos<IndexTables.size()-1; Pos++)
+ if (IndexTables[Pos].IndexStartPosition==Data)
+ {
+ if (IndexTables[Pos].IndexDuration==1 && Pos!=IndexTables.size()-1)
+ IndexTables.erase(IndexTables.begin()+Pos);
+ else
+ {
+ IndexTables.erase(IndexTables.begin()+IndexTables.size()-1);
+ Element_Offset=Element_Size;
+ }
+
+ return;
+ }
+ #endif //MEDIAINFO_SEEK
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3F0D
+void File_Mxf::IndexTableSegment_IndexDuration()
+{
+ //Parsing
+ int64u Data;
+ Get_B8 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ #if MEDIAINFO_SEEK
+ IndexTables[IndexTables.size()-1].IndexDuration=Data;
+ #endif //MEDIAINFO_SEEK
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3F0E
+void File_Mxf::IndexTableSegment_PosTableCount()
+{
+ //Parsing
+ int8u Data;
+ Get_B1(Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ IndexTable_NPE=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x8002
+void File_Mxf::IndexTableSegment_8002()
+{
+ //Parsing
+ Info_B8(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x8001
+void File_Mxf::JPEG2000PictureSubDescriptor_Rsiz()
+{
+ //Parsing
+ Info_B2(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x8002
+void File_Mxf::JPEG2000PictureSubDescriptor_Xsiz()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x8003
+void File_Mxf::JPEG2000PictureSubDescriptor_Ysiz()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x8004
+void File_Mxf::JPEG2000PictureSubDescriptor_XOsiz()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x8005
+void File_Mxf::JPEG2000PictureSubDescriptor_YOsiz()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x8006
+void File_Mxf::JPEG2000PictureSubDescriptor_XTsiz()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x8007
+void File_Mxf::JPEG2000PictureSubDescriptor_YTsiz()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x8008
+void File_Mxf::JPEG2000PictureSubDescriptor_XTOsiz()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x8009
+void File_Mxf::JPEG2000PictureSubDescriptor_YTOsiz()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x800A
+void File_Mxf::JPEG2000PictureSubDescriptor_Csiz()
+{
+ //Parsing
+ Info_B2(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x800B
+void File_Mxf::JPEG2000PictureSubDescriptor_PictureComponentSizing()
+{
+ //Parsing
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("PictureComponentSize");
+ Info_B1(Ssiz, "Component sample precision"); Element_Info1(Ssiz);
+ Info_B1(XRsiz, "Horizontal separation of a sample"); Element_Info1(XRsiz);
+ Info_B1(YRsiz, "Vertical separation of a sample"); Element_Info1(YRsiz);
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x3B02
+void File_Mxf::Preface_LastModifiedDate()
+{
+ //Parsing
+ Ztring Value;
+ Get_Timestamp(Value); Element_Info1(Value);
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_Encoded_Date, Value, true);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x
+void File_Mxf::MPEG2VideoDescriptor_SingleSequence()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data?"Yes":"No");
+}
+
+//---------------------------------------------------------------------------
+// 0x
+void File_Mxf::MPEG2VideoDescriptor_ConstantBFrames()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data?"Yes":"No");
+}
+
+//---------------------------------------------------------------------------
+// 0x
+void File_Mxf::MPEG2VideoDescriptor_CodedContentType()
+{
+ //Parsing
+ int8u Data;
+ Get_B1 (Data, "Data"); Element_Info1(Mxf_MPEG2_CodedContentType(Data));
+
+ FILLING_BEGIN();
+ if (Data==2 && Descriptors[InstanceUID].Infos.find("ScanType")==Descriptors[InstanceUID].Infos.end())
+ {
+ if (Descriptors[InstanceUID].Height!=(int32u)-1) Descriptors[InstanceUID].Height*=2;
+ if (Descriptors[InstanceUID].Height_Display!=(int32u)-1) Descriptors[InstanceUID].Height_Display*=2;
+ if (Descriptors[InstanceUID].Height_Display_Offset!=(int32u)-1) Descriptors[InstanceUID].Height_Display_Offset*=2;
+ }
+ Descriptors[InstanceUID].Infos["ScanType"]=Mxf_MPEG2_CodedContentType(Data);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x
+void File_Mxf::MPEG2VideoDescriptor_LowDelay()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data?"Yes":"No");
+}
+
+//---------------------------------------------------------------------------
+// 0x
+void File_Mxf::MPEG2VideoDescriptor_ClosedGOP()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data?"Yes":"No");
+}
+
+//---------------------------------------------------------------------------
+// 0x
+void File_Mxf::MPEG2VideoDescriptor_IdenticalGOP()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data?"Yes":"No");
+}
+
+//---------------------------------------------------------------------------
+// 0x
+void File_Mxf::MPEG2VideoDescriptor_MaxGOP()
+{
+ //Parsing
+ Info_B2(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x
+void File_Mxf::MPEG2VideoDescriptor_BPictureCount()
+{
+ //Parsing
+ int16u Data;
+ Get_B2 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].HasBFrames=Data?true:false;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x
+void File_Mxf::MPEG2VideoDescriptor_ProfileAndLevel()
+{
+ //Parsing
+ int8u profile_and_level_indication_profile, profile_and_level_indication_level;
+ BS_Begin();
+ Skip_SB( "profile_and_level_indication_escape");
+ Get_S1 ( 3, profile_and_level_indication_profile, "profile_and_level_indication_profile"); Param_Info1(Mpegv_profile_and_level_indication_profile[profile_and_level_indication_profile]);
+ Get_S1 ( 4, profile_and_level_indication_level, "profile_and_level_indication_level"); Param_Info1(Mpegv_profile_and_level_indication_level[profile_and_level_indication_level]);
+ BS_End();
+
+ FILLING_BEGIN();
+ if (profile_and_level_indication_profile && profile_and_level_indication_level)
+ Descriptors[InstanceUID].Infos["Format_Profile"]=Ztring().From_Local(Mpegv_profile_and_level_indication_profile[profile_and_level_indication_profile])+_T("@")+Ztring().From_Local(Mpegv_profile_and_level_indication_level[profile_and_level_indication_level]);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x
+void File_Mxf::MPEG2VideoDescriptor_BitRate()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].Infos["BitRate"].From_Number(Data);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x4001
+void File_Mxf::NetworkLocator_URLString()
+{
+ //Parsing
+ Ztring Data;
+ Get_UTF16B(Length2, Data, "Essence Locator"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Locators[InstanceUID].EssenceLocator=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3F01
+void File_Mxf::MultipleDescriptor_SubDescriptorUIDs()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ //Parsing
+ int128u Data;
+ Get_UUID(Data, "UUID");
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].SubDescriptors.push_back(Data);
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::PartitionMetadata()
+{
+ //Parsing
+ int64u PreviousPartition, FooterPartition, HeaderByteCount, IndexByteCount, BodyOffset;
+ int32u IndexSID;
+ int32u KAGSize;
+ Skip_B2( "MajorVersion");
+ Skip_B2( "MinorVersion");
+ Get_B4 (KAGSize, "KAGSize");
+ Skip_B8( "ThisPartition");
+ Get_B8 (PreviousPartition, "PreviousPartition");
+ Get_B8 (FooterPartition, "FooterPartition");
+ Get_B8 (HeaderByteCount, "HeaderByteCount");
+ Get_B8 (IndexByteCount, "IndexByteCount");
+ Get_B4 (IndexSID, "IndexSID");
+ Get_B8 (BodyOffset, "BodyOffset");
+ Skip_B4( "BodySID");
+ Get_UL (OperationalPattern, "OperationalPattern", Mxf_OperationalPattern);
+
+ Element_Begin1("EssenceContainers"); //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ int128u EssenceContainer;
+ Get_UL (EssenceContainer, "EssenceContainer", Mxf_EssenceContainer);
+ if (Count==1)
+ EssenceContainer_FromPartitionMetadata=EssenceContainer;
+ }
+ Element_End0();
+
+ PartitionPack_Parsed=true;
+ Partitions_IsFooter=(Code.lo&0x00FF0000)==0x00040000;
+ if (PreviousPartition!=File_Offset+Buffer_Offset-Header_Size)
+ PartitionMetadata_PreviousPartition=PreviousPartition;
+ if (FooterPartition)
+ PartitionMetadata_FooterPartition=FooterPartition;
+ bool AlreadyParsed=false;
+ for (size_t Pos=0; Pos<Partitions.size(); Pos++)
+ if (Partitions[Pos].StreamOffset==File_Offset+Buffer_Offset-Header_Size)
+ AlreadyParsed=true;
+ if (!AlreadyParsed)
+ {
+ partition Partition;
+ Partition.StreamOffset=File_Offset+Buffer_Offset-Header_Size;
+ Partition.FooterPartition=FooterPartition;
+ Partition.HeaderByteCount=HeaderByteCount;
+ Partition.IndexByteCount=IndexByteCount;
+ Partition.BodyOffset=BodyOffset;
+ Partitions_Pos=0;
+ while (Partitions_Pos<Partitions.size() && Partitions[Partitions_Pos].StreamOffset<Partition.StreamOffset)
+ Partitions_Pos++;
+ Partitions.insert(Partitions.begin()+Partitions_Pos, Partition);
+ Partitions_IsCalculatingHeaderByteCount=true;
+ }
+
+ if ((Code.lo&0xFF0000)==0x020000) //If Header Partition Pack
+ switch ((Code.lo>>8)&0xFF)
+ {
+ case 0x01 : Fill(Stream_General, 0, General_Format_Settings, "Open / Incomplete" , Unlimited, true, true); if (Config_ParseSpeed>=1.0) Config->File_IsGrowing=true; break;
+ case 0x02 : Fill(Stream_General, 0, General_Format_Settings, "Closed / Incomplete", Unlimited, true, true); break;
+ case 0x03 : Fill(Stream_General, 0, General_Format_Settings, "Open / Complete" , Unlimited, true, true); if (Config_ParseSpeed>=1.0) Config->File_IsGrowing=true; break;
+ case 0x04 : Fill(Stream_General, 0, General_Format_Settings, "Closed / Complete" , Unlimited, true, true); break;
+ default : ;
+ }
+
+ PartitionPack_AlreadyParsed.insert(File_Offset+Buffer_Offset-Header_Size);
+}
+
+//---------------------------------------------------------------------------
+// 0x3B03
+void File_Mxf::Preface_ContentStorage()
+{
+ //Parsing
+ int128u Data;
+ Get_UUID(Data, "Data"); Element_Info1(Ztring().From_UUID(Data));
+
+ FILLING_BEGIN();
+ Prefaces[Preface_Current].ContentStorage=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3B05
+void File_Mxf::Preface_Version()
+{
+ //Parsing
+ Info_B1(Major, "Major"); //1
+ Info_B1(Minor, "Minor"); //2
+ Element_Info1(Ztring::ToZtring(Major)+_T('.')+Ztring::ToZtring(Minor));
+}
+
+//---------------------------------------------------------------------------
+// 0x3B06
+void File_Mxf::Preface_Identifications()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("Identification");
+ int128u Data;
+ Get_UUID(Data, "UUID"); Element_Info1(Ztring().From_UUID(Data));
+ Element_End0();
+
+ FILLING_BEGIN();
+ Prefaces[Preface_Current].Identifications.push_back(Data);
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x3B07
+void File_Mxf::Preface_ObjectModelVersion()
+{
+ //Parsing
+ Skip_B4( "Data");
+}
+
+//---------------------------------------------------------------------------
+// 0x3B08
+void File_Mxf::Preface_PrimaryPackage()
+{
+ //Parsing
+ int128u Data;
+ Get_UUID(Data, "Data");
+
+ FILLING_BEGIN();
+ Prefaces[Preface_Current].PrimaryPackage=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3B09
+void File_Mxf::Preface_OperationalPattern()
+{
+ //Parsing
+ Get_UL (OperationalPattern, "UUID", Mxf_OperationalPattern); Element_Info1(Mxf_OperationalPattern(OperationalPattern));
+}
+
+//---------------------------------------------------------------------------
+// 0x3B0A
+void File_Mxf::Preface_EssenceContainers()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ Info_UL(EssenceContainer, "EssenceContainer", Mxf_EssenceContainer);
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x3B0B
+void File_Mxf::Preface_DMSchemes()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ if (Length==16)
+ {
+ Info_UL(Data, "DMScheme", NULL); Element_Info1(Ztring().From_UUID(Data));
+ }
+ else
+ Skip_XX(Length, "DMScheme");
+}
+
+//---------------------------------------------------------------------------
+// 0x3401
+void File_Mxf::RGBAEssenceDescriptor_PixelLayout()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3403
+void File_Mxf::RGBAEssenceDescriptor_Palette()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3404
+void File_Mxf::RGBAEssenceDescriptor_PaletteLayout()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3405
+void File_Mxf::RGBAEssenceDescriptor_ScanningDirection()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3406
+void File_Mxf::RGBAEssenceDescriptor_ComponentMaxRef()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3407
+void File_Mxf::RGBAEssenceDescriptor_ComponentMinRef()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3408
+void File_Mxf::RGBAEssenceDescriptor_AlphaMaxRef()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3409
+void File_Mxf::RGBAEssenceDescriptor_AlphaMinRef()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x1001
+void File_Mxf::Sequence_StructuralComponents()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ int128u Data;
+ Get_UUID (Data, "StructuralComponent");
+
+ FILLING_BEGIN();
+ Components[InstanceUID].StructuralComponents.push_back(Data);
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x1101
+void File_Mxf::SourceClip_SourcePackageID()
+{
+ //Parsing
+ int256u Data;
+ Get_UMID(Data, "SourcePackageID");
+
+ FILLING_BEGIN();
+ Components[InstanceUID].SourcePackageID=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x1102
+void File_Mxf::SourceClip_SourceTrackID()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "SourceTrackID"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ if (Components[InstanceUID].SourceTrackID==(int32u)-1)
+ Components[InstanceUID].SourceTrackID=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x1201
+void File_Mxf::SourceClip_StartPosition()
+{
+ //Parsing
+ Info_B8(Data, "StartPosition"); Element_Info1(Data); //units of edit rate
+}
+
+//---------------------------------------------------------------------------
+// 0x4701
+void File_Mxf::SourcePackage_Descriptor()
+{
+ //Parsing
+ int128u Data;
+ Get_UUID(Data, "Data"); Element_Info1(Ztring().From_UUID(Data));
+
+ FILLING_BEGIN();
+ Packages[InstanceUID].Descriptor=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x0201
+void File_Mxf::StructuralComponent_DataDefinition()
+{
+ //Parsing
+ Info_UL(Data, "Data", Mxf_Sequence_DataDefinition); Element_Info1(Mxf_Sequence_DataDefinition(Data));
+}
+
+//---------------------------------------------------------------------------
+// 0x0202
+void File_Mxf::StructuralComponent_Duration()
+{
+ //Parsing
+ int64u Data;
+ Get_B8 (Data, "Data"); Element_Info1(Data); //units of edit rate
+
+ FILLING_BEGIN();
+ if (Data!=0xFFFFFFFFFFFFFFFFLL)
+ Components[InstanceUID].Duration=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x0102
+void File_Mxf::SystemScheme1_TimeCodeArray()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("TimeCode");
+ int8u Frames_Units, Frames_Tens, Seconds_Units, Seconds_Tens, Minutes_Units, Minutes_Tens, Hours_Units, Hours_Tens;
+ bool DropFrame;
+ BS_Begin();
+
+ Skip_SB( "CF - Color fame");
+ Get_SB ( DropFrame, "DP - Drop frame");
+ Get_S1 (2, Frames_Tens, "Frames (Tens)");
+ Get_S1 (4, Frames_Units, "Frames (Units)");
+
+ Skip_SB( "FP - Field Phase / BGF0");
+ Get_S1 (3, Seconds_Tens, "Seconds (Tens)");
+ Get_S1 (4, Seconds_Units, "Seconds (Units)");
+
+ Skip_SB( "BGF0 / BGF2");
+ Get_S1 (3, Minutes_Tens, "Minutes (Tens)");
+ Get_S1 (4, Minutes_Units, "Minutes (Units)");
+
+ Skip_SB( "BGF2 / Field Phase");
+ Skip_SB( "BGF1");
+ Get_S1 (2, Hours_Tens, "Hours (Tens)");
+ Get_S1 (4, Hours_Units, "Hours (Units)");
+
+ Skip_S1(4, "BG2");
+ Skip_S1(4, "BG1");
+
+ Skip_S1(4, "BG4");
+ Skip_S1(4, "BG3");
+
+ Skip_S1(4, "BG6");
+ Skip_S1(4, "BG5");
+
+ Skip_S1(4, "BG8");
+ Skip_S1(4, "BG7");
+
+ BS_End();
+
+ int64u TimeCode=(int64u)(Hours_Tens *10*60*60*1000
+ + Hours_Units *60*60*1000
+ + Minutes_Tens *10*60*1000
+ + Minutes_Units *60*1000
+ + Seconds_Tens *10*1000
+ + Seconds_Units *1000
+ + (SystemScheme1_FrameRateFromDescriptor?float64_int32s((Frames_Tens*10+Frames_Units)*1000/(float64)SystemScheme1_FrameRateFromDescriptor):0));
+
+ Element_Info1(Ztring().Duration_From_Milliseconds(TimeCode));
+
+ Element_End0();
+
+ //TimeCode
+ if (SystemScheme1_TimeCodeArray_StartTimecode==(int64u)-1)
+ SystemScheme1_TimeCodeArray_StartTimecode=TimeCode;
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x4101
+void File_Mxf::TextLocator_LocatorName()
+{
+ //Parsing
+ Info_UTF16B(Length2, Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Locators[InstanceUID].EssenceLocator=Data;
+ Locators[InstanceUID].IsTextLocator=true;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x1501
+void File_Mxf::TimecodeComponent_StartTimecode()
+{
+ //Parsing
+ int64u Data;
+ Get_B8 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ if (Data!=(int64u)-1)
+ {
+ TimeCode_StartTimecode=Data;
+ if (TimeCode_RoundedTimecodeBase)
+ {
+ DTS_Delay=((float64)TimeCode_StartTimecode)/TimeCode_RoundedTimecodeBase;
+ if (TimeCode_DropFrame)
+ {
+ DTS_Delay*=1001;
+ DTS_Delay/=1000;
+ }
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x1502
+void File_Mxf::TimecodeComponent_RoundedTimecodeBase()
+{
+ //Parsing
+ int16u Data;
+ Get_B2 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ if (Data && Data!=(int16u)-1)
+ {
+ TimeCode_RoundedTimecodeBase=Data;
+ if (TimeCode_StartTimecode!=(int64u)-1)
+ {
+ DTS_Delay=((float64)TimeCode_StartTimecode)/TimeCode_RoundedTimecodeBase;
+ if (TimeCode_DropFrame)
+ {
+ DTS_Delay*=1001;
+ DTS_Delay/=1000;
+ }
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x1503
+void File_Mxf::TimecodeComponent_DropFrame()
+{
+ //Parsing
+ int8u Data;
+ Get_B1 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ if (Data!=(int8u)-1 && Data)
+ {
+ TimeCode_DropFrame=true;
+ if (DTS_Delay)
+ {
+ DTS_Delay*=1001;
+ DTS_Delay/=1000;
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x4B01
+void File_Mxf::Track_EditRate()
+{
+ //Parsing
+ float64 Data;
+ Get_Rational(Data); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Tracks[InstanceUID].EditRate=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x4B02
+void File_Mxf::Track_Origin()
+{
+ //Parsing
+ Info_B8(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D09
+void File_Mxf::WaveAudioDescriptor_AvgBps()
+{
+ //Parsing
+ int32u Data;
+ Get_B4 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].Infos["BitRate"].From_Number(Data*8);
+ Descriptors[InstanceUID].ByteRate=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3D0A
+void File_Mxf::WaveAudioDescriptor_BlockAlign()
+{
+ //Parsing
+ int16u Data;
+ Get_B2 (Data, "Data"); Element_Info1(Data);
+
+ FILLING_BEGIN();
+ Descriptors[InstanceUID].BlockAlign=Data;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// 0x3D0B
+void File_Mxf::WaveAudioDescriptor_SequenceOffset()
+{
+ //Parsing
+ Info_B1(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D29
+void File_Mxf::WaveAudioDescriptor_PeakEnvelopeVersion()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D2A
+void File_Mxf::WaveAudioDescriptor_PeakEnvelopeFormat()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D2B
+void File_Mxf::WaveAudioDescriptor_PointsPerPeakValue()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D2C
+void File_Mxf::WaveAudioDescriptor_PeakEnvelopeBlockSize()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D2D
+void File_Mxf::WaveAudioDescriptor_PeakChannels()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D2E
+void File_Mxf::WaveAudioDescriptor_PeakFrames()
+{
+ //Parsing
+ Info_B4(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D2F
+void File_Mxf::WaveAudioDescriptor_PeakOfPeaksPosition()
+{
+ //Parsing
+ Info_B8(Data, "Data"); Element_Info1(Data);
+}
+
+//---------------------------------------------------------------------------
+// 0x3D30
+void File_Mxf::WaveAudioDescriptor_PeakEnvelopeTimestamp()
+{
+ //Parsing
+ Info_Timestamp();
+}
+
+//---------------------------------------------------------------------------
+// 0x3D31
+void File_Mxf::WaveAudioDescriptor_PeakEnvelopeData()
+{
+ //Parsing
+ Skip_XX(Length2, "Data");
+}
+
+//---------------------------------------------------------------------------
+// 0x3D32
+void File_Mxf::WaveAudioDescriptor_ChannelAssignment()
+{
+ //Parsing
+ Skip_B16( "Label");
+}
+
+//---------------------------------------------------------------------------
+// 0x8001
+void File_Mxf::Omneon_010201010100_8001()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ Skip_UUID( "UUID Omneon_010201020100");
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x8001
+void File_Mxf::Omneon_010201010100_8003()
+{
+ //Parsing
+ //Vector
+ int32u Count, Length;
+ Get_B4 (Count, "Count");
+ Get_B4 (Length, "Length");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ Skip_UUID( "UUID Omneon_010201020100");
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x8003
+void File_Mxf::Omneon_010201020100_8002()
+{
+ //Parsing
+ Skip_UTF16B(Length2, "Content");
+}
+
+//---------------------------------------------------------------------------
+// 0x8003
+void File_Mxf::Omneon_010201020100_8003()
+{
+ //Parsing
+ Skip_UTF16B(Length2, "Content");
+}
+
+//---------------------------------------------------------------------------
+// 0x8004
+void File_Mxf::Omneon_010201020100_8004()
+{
+ //Parsing
+ Skip_XX(Length2, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+// 0x8005
+void File_Mxf::Omneon_010201020100_8005()
+{
+ //Parsing
+ Skip_UTF16B(Length2, "Content");
+}
+
+//---------------------------------------------------------------------------
+// 0x8006
+void File_Mxf::Omneon_010201020100_8006()
+{
+ //Parsing
+ Skip_Local(Length2, "Content");
+}
+
+//***************************************************************************
+// Basic types
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mxf::Get_Rational(float64 &Value)
+{
+ //Parsing
+ int32u N, D;
+ Get_B4 (N, "Numerator");
+ Get_B4 (D, "Denominator");
+ if (D)
+ Value=((float32)N)/D;
+ else
+ Value=0; //Error
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Skip_Rational()
+{
+ //Parsing
+ Skip_B4( "Numerator");
+ Skip_B4( "Denominator");
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Info_Rational()
+{
+ //Parsing
+ Info_B4(N, "Numerator");
+ Info_B4(D, "Denominator");
+ Element_Info1C(D, ((float32)N)/D);
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Get_UL(int128u &Value, const char* Name, const char* (*Param) (int128u))
+{
+ #ifdef MEDIAINFO_MINIMIZE_SIZE
+ Skip_UUID();
+ #else
+ //Parsing
+ Element_Begin1(Name);
+ int64u Value_hi, Value_lo;
+ int8u Category, Registry, Structure;
+ Peek_B8(Value_hi);
+ Skip_B1( "Start (0x06)");
+ Skip_B1( "Length of the remaining key (0x0E)");
+ Skip_B1( "ISO, ORG (0x2B)");
+ Skip_B1( "SMPTE (0x34)");
+ Get_B1 (Category, "Category"); Param_Info1(Mxf_Category(Category));
+ Get_B1 (Registry, "Registry"); Param_Info1(Mxf_Registry(Category, Registry));
+ Get_B1 (Structure, "Structure"); Param_Info1(Mxf_Structure(Category, Registry, Structure));
+ Skip_B1( "Version");
+ Peek_B8(Value_lo);
+ switch (Category)
+ {
+ case 0x01 : //Item
+ {
+ //switch (Registry)
+ //{
+ // default :
+ {
+ switch (Structure)
+ {
+ case 0x01 : //Standard
+ Param_Info1("Essence element"); //SMPTE 379M
+ Info_UL_01xx01_Items();
+ break;
+ default :
+ Skip_B8( "Unknown");
+ }
+ }
+ //}
+ }
+ break;
+ case 0x02 : //Group
+ {
+ //switch (Registry)
+ //{
+ // default :
+ {
+ switch (Structure)
+ {
+ case 0x01 :
+ Info_UL_02xx01_Groups();
+ break;
+ default :
+ Skip_B8( "Unknown");
+ }
+ }
+ //}
+ }
+ break;
+ case 0x04 : //Value
+ {
+ switch (Registry)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Labels");
+ switch (Structure)
+ {
+ case 0x01 :
+ Info_UL_040101_Values();
+ break;
+ default :
+ Skip_B8( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B8( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B8( "Unknown");
+ }
+
+
+ Value.hi=Value_hi;
+ Value.lo=Value_lo;
+ Element_Info1C((Param), Param(Value));
+ Element_End0();
+ #endif
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File_Mxf::Info_UL_01xx01_Items()
+{
+ Info_B1(Code1, "Item Designator");
+ switch (Code1)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Identifiers and locators");
+ Info_B1(Code2, "Code (2)");
+ switch (Code2)
+ {
+ case 0x01 :
+ {
+ Param_Info1("GUID");
+ Info_B1(Code3, "Code (3)");
+ switch (Code3)
+ {
+ case 0x0D :
+ {
+ Param_Info1("UMID Mixed");
+ Info_B1(Code4, "Code (4)");
+ Info_B1(Code5, "Code (5)");
+ Info_B1(Code6, "Code (6)");
+ Info_B1(Code7, "Code (7)");
+ Info_B1(Code8, "Code (8)");
+ }
+ break;
+ default :
+ Skip_B5( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B6( "Unknown");
+ }
+ }
+ break;
+ case 0x03 :
+ {
+ Param_Info1("Interpretive");
+ Info_B1(Code2, "Code (2)");
+ switch (Code2)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Fundamental");
+ Info_B1(Code3, "Code (3)");
+ switch (Code3)
+ {
+ case 0x02 :
+ {
+ Param_Info1("Data Interpretations and Definitions");
+ Info_B1(Code4, "Code (4)");
+ switch (Code4)
+ {
+ case 0x0A :
+ {
+ Param_Info1("Name-Value Construct Interpretations");
+ Info_B1(Code5, "Code (5)");
+ switch (Code5)
+ {
+ case 0x01 :
+ case 0x02 :
+ {
+ Param_Info1("");
+ Info_B1(Code6, "Code (6)");
+ switch (Code6)
+ {
+ case 0x00 :
+ {
+ Param_Info1("ANSI");
+ Info_B1(Code7, "Reserved");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ case 0x01 :
+ {
+ Param_Info1("UTF-16");
+ Info_B1(Code7, "Reserved");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ default :
+ Skip_B2( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ case 0x10 :
+ {
+ Param_Info1("KLV Interpretations");
+ Info_B1(Code5, "Code (5)");
+ switch (Code5)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Filler");
+ Info_B1(Code6, "Reserved");
+ Info_B1(Code7, "Reserved");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ case 0x05 :
+ {
+ Param_Info1("Terminating Filler");
+ Info_B1(Code6, "Reserved");
+ Info_B1(Code7, "Reserved");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ case 0x20 :
+ {
+ Param_Info1("XML Constructs and Interpretations");
+ Info_B1(Code5, "Code (5)");
+ switch (Code5)
+ {
+ case 0x01 :
+ {
+ Param_Info1("XML Document Text");
+ Info_B1(Code6, "Reserved");
+ Info_B1(Code7, "Reserved");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B5( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B6( "Unknown");
+ }
+ }
+ break;
+ case 0x0D :
+ {
+ Param_Info1("User Organisation Registered For Public Use");
+ Info_B1(Code2, "Organization");
+ switch (Code2)
+ {
+ case 0x01 :
+ {
+ Param_Info1("AAF");
+ Info_B1(Code3, "Application");
+ switch (Code3)
+ {
+ case 0x03 :
+ {
+ Param_Info1("MXF Generic Container Keys");
+ Info_B1(Code4, "Structure Version");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Version 1");
+ Info_B1(Code5, "Item Type Identifier");
+ switch (Code5)
+ {
+ case 0x05 : Param_Info1("CP Picture (SMPTE 326M)"); break;
+ case 0x06 : Param_Info1("CP Sound (SMPTE 326M)"); break;
+ case 0x07 : Param_Info1("CP Data (SMPTE 326M)"); break;
+ case 0x14 : Param_Info1("MXF in MXF? (To confirm)"); break;
+ case 0x15 : Param_Info1("GC Picture"); break;
+ case 0x16 : Param_Info1("GC Sound"); break;
+ case 0x17 : Param_Info1("GC Data"); break;
+ case 0x18 : Param_Info1("GC Compound"); break;
+ default : ;
+ }
+ Info_B1(Code6, "Essence Element Count");
+ Info_B1(Code7, "Essence Element Type");
+ Info_B1(Code8, "Essence Element Number");
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B5( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B6( "Unknown");
+ }
+ }
+ break;
+ case 0x0E :
+ {
+ Param_Info1("User Organisation Registered For Private Use");
+ Info_B1(Code2, "Organization");
+ switch (Code2)
+ {
+ case 0x04 :
+ {
+ Param_Info1("Avid");
+ Info_B1(Code3, "Application");
+ switch (Code3)
+ {
+ case 0x03 :
+ {
+ Param_Info1("Container Keys");
+ Info_B1(Code4, "Structure Version");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Version 1");
+ Info_B1(Code5, "Item Type Identifier");
+ switch (Code5)
+ {
+ case 0x15 : Param_Info1("Picture"); break;
+ default : ;
+ }
+ Info_B1(Code6, "Essence Element Count");
+ Info_B1(Code7, "Essence Element Type");
+ Info_B1(Code8, "Essence Element Number");
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B5( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B6( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B7( "Unknown");
+ }
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File_Mxf::Info_UL_02xx01_Groups()
+{
+ Info_B1(Code1, "Item Designator");
+ switch (Code1)
+ {
+ case 0x0D :
+ {
+ Param_Info1("User Organisation Registered For Public Use");
+ Info_B1(Code2, "Organization");
+ switch (Code2)
+ {
+ case 0x01 :
+ {
+ Param_Info1("AAF");
+ Info_B1(Code3, "Application");
+ switch (Code3)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Structural Metadata Sets");
+ Info_B1(Code4, "Structure Version");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Version 1");
+ Info_B1(Code5, "Structure Kind");
+ switch (Code5)
+ {
+ case 0x01 :
+ {
+ Param_Info1("MXF / AAF Association compatible sets & packs");
+ Info_B1(Code6, "Set Kind (1)"); //See table 14
+ Info_B1(Code7, "Set Kind (2)"); //See table 14
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ case 0x02 :
+ {
+ Param_Info1("MXF File Structure");
+ Info_B1(Code4, "Structure Version");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Version 1");
+ Info_B1(Code5, "Structure Kind");
+ switch (Code5)
+ {
+ case 0x01 :
+ {
+ Param_Info1("MXF File Structure sets & packs");
+ Info_B1(Code6, "Set / Pack Kind");
+ switch (Code6)
+ {
+ case 0x02 :
+ {
+ Param_Info1("Header Partition");
+ Info_B1(Code7, "Partition Status");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ case 0x03 :
+ {
+ Param_Info1("Body Partition");
+ Info_B1(Code7, "Partition Status");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ case 0x04 :
+ {
+ Param_Info1("Footer Partition");
+ Info_B1(Code7, "Partition Status");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ case 0x05 :
+ {
+ Param_Info1("Primer");
+ Info_B1(Code7, "Version of the Primer Pack");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ case 0x10 :
+ Param_Info1("Index Table Segment");
+ Skip_B1( "Version");
+ Skip_B1( "Reserved");
+ break;
+ case 0x11 :
+ Param_Info1("Random Index Pack");
+ Skip_B1( "Version");
+ Skip_B1( "Reserved");
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ case 0x03 :
+ {
+ Param_Info1("MXF Generic Container Keys");
+ Info_B1(Code4, "Structure Version");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("MXF-GC Version 1");
+ Info_B1(Code5, "Item Type Identifier");
+ switch (Code5)
+ {
+ case 0x04 :
+ {
+ Param_Info1("CP-Compatible System Item"); //SMPTE 379M
+ Info_B1(Code6, "System Scheme Identifier");
+ switch (Code6)
+ {
+ case 0x02 :
+ {
+ Param_Info1("SDTI-CP, version 1"); //SMPTE 385M
+ Info_B1(Code7, "Metadata or Control Element Identifier");
+ switch (Code7)
+ {
+ case 0x01 :
+ {
+ Param_Info1("System Metadata Pack");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ case 0x02 :
+ {
+ Param_Info1("Package metadata set");
+ Info_B1(Code8, "Metadata Block Count");
+ }
+ break;
+ case 0x03 :
+ {
+ Param_Info1("Picture metadata set");
+ Info_B1(Code8, "Metadata Block Count");
+ }
+ break;
+ case 0x04 :
+ {
+ Param_Info1("Sound metadata set");
+ Info_B1(Code8, "Metadata Block Count");
+ }
+ break;
+ case 0x05 :
+ {
+ Param_Info1("Data metadata set");
+ Info_B1(Code8, "Metadata Block Count");
+ }
+ break;
+ case 0x06 :
+ {
+ Param_Info1("Control data set");
+ Info_B1(Code8, "Metadata Block Count");
+ }
+ break;
+ default :
+ Info_B1(Code8, "Metadata Block Count");
+ }
+ }
+ break;
+ default :
+ Info_B1(Code7, "Metadata or Control Element Identifier");
+ Info_B1(Code8, "Reserved");
+ }
+ }
+ break;
+ case 0x14 :
+ {
+ Param_Info1("GC-Compatible System Item"); //SMPTE 379M
+ Info_B1(Code6, "System Scheme Identifier");
+ switch (Code6)
+ {
+ case 0x02 :
+ {
+ Param_Info1("GC System Scheme 1"); //SMPTE 394M
+ Info_B1(Code7, "Metadata or Control Element Identifier");
+ switch (Code7)
+ {
+ case 0x01 :
+ Param_Info1("First Element");
+ break;
+ case 0x02 :
+ Param_Info1("Subsequent Element");
+ break;
+ case 0x03 :
+ Param_Info1("Picture Item Descriptor");
+ break;
+ case 0x04 :
+ Param_Info1("Sound Item Descriptor");
+ break;
+ case 0x05 :
+ Param_Info1("Data Item Descriptor");
+ break;
+ case 0x06 :
+ Param_Info1("Control Item Descriptor");
+ break;
+ case 0x07 :
+ Param_Info1("Compound Item Descriptor");
+ break;
+ default : if (Code7>=0x10 && Code7<=0x7F) Param_Info1("Pack coded System Elements (SMPTE 336M)");
+ }
+ Info_B1(Code8, "Element Number");
+ }
+ break;
+ default :
+ Info_B1(Code7, "Metadata or Control Element Identifier");
+ Info_B1(Code8, "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ case 0x04 :
+ {
+ Param_Info1("MXF / AAF Descriptive Metadata sets");
+ Info_B1(Code4, "Structure Version");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Version 1");
+ Info_B1(Code5, "Structure / Scheme Kind");
+ Info_B1(Code6, "Reserved");
+ Info_B1(Code7, "Reserved");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B5( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B6( "Unknown");
+ }
+ }
+ break;
+ case 0x0E :
+ {
+ Param_Info1("User Organisation Registered For Private Use");
+ Skip_B7( "Private");
+ break;
+ }
+ default :
+ Skip_B7( "Unknown");
+ }
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_TRACE
+void File_Mxf::Info_UL_040101_Values()
+{
+ Info_B1(Code1, "Item Designator");
+ switch (Code1)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Interpretive");
+ Info_B1(Code2, "Code (2)");
+ switch (Code2)
+ {
+ case 0x03 :
+ {
+ Info_B1(Code3, "Code (3)");
+ switch (Code3)
+ {
+ case 0x02 :
+ Skip_B5( "Track identifier");
+ break;
+ default :
+ Skip_B5( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B6( "Unknown");
+ }
+ }
+ break;
+ case 0x04 :
+ {
+ Param_Info1("Parametric");
+ Info_B1(Code2, "Code (2)");
+ switch (Code2)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Picture essence");
+ Info_B1(Code3, "Code (3)");
+ switch (Code3)
+ {
+ case 0x01 :
+ Param_Info1("Fundamental Picture Characteristics");
+ Skip_B5( "Picture coding or compression");
+ break;
+ case 0x02 :
+ Param_Info1("Picture Coding Characteristics");
+ Info_B1(Code4, "Code (4)");
+ switch (Code4)
+ {
+ case 0x01 :
+ Param_Info1("Uncompressed Picture Coding");
+ Skip_B1( "Item Type Identifier"); //if 0x14: SMPTE 384M Uncompressed picture Line wrapped
+ Skip_B1( "System Scheme Identifier"); //SMPTE 384M
+ Skip_B1( "System Element Identifier"); //SMPTE 384M
+ Skip_B1( "Reserved");
+ break;
+ case 0x02 :
+ {
+ Param_Info1("Compressed Picture Coding");
+ Info_B1(Code5, "Code (5)");
+ switch (Code5)
+ {
+ case 0x01 :
+ {
+ Param_Info1("MPEG Compression");
+ Info_B1(Code6, "Code (6)");
+ switch (Code6)
+ {
+ case 0x01 :
+ Param_Info1("MPEG-2 MP@ML");
+ Skip_B2( "Unknown");
+ break;
+ case 0x02 :
+ Param_Info1("MPEG-2 422P@ML");
+ Skip_B2( "Unknown");
+ break;
+ case 0x03 :
+ Param_Info1("MPEG-2 MP@HL");
+ Skip_B2( "Unknown");
+ break;
+ case 0x04 :
+ Param_Info1("MPEG-2 422P@HL");
+ Skip_B2( "Unknown");
+ break;
+ case 0x10 :
+ Param_Info1("MPEG-1");
+ Skip_B2( "Unknown");
+ break;
+ case 0x20 :
+ Param_Info1("MPEG-4 Visual");
+ Skip_B2( "Unknown");
+ break;
+ case 0x32 :
+ Param_Info1("AVC");
+ Skip_B2( "Unknown");
+ break;
+ default :
+ Skip_B2( "Unknown");
+ }
+ }
+ break;
+ case 0x02 :
+ {
+ Param_Info1("DV Video Compression");
+ Info_B1(Code6, "Code (6)");
+ switch (Code6)
+ {
+ case 0x02 :
+ Param_Info1("DV-Based Compression");
+ Info_B1(Code7, "DV type (SMPTE 383)");
+ Info_B1(Code8, "Mapping Kind"); Param_Info1(Mxf_EssenceContainer_Mapping(Code6, Code7, Code8));
+ break;
+ default :
+ Skip_B2( "Unknown");
+ }
+ }
+ break;
+ case 0x03 :
+ {
+ Param_Info1("Individual Picture Coding Schemes");
+ Info_B1(Code6, "Code (6)");
+ switch (Code6)
+ {
+ case 0x01 :
+ Param_Info1("JPEG 2000");
+ Skip_B1( "Unused");
+ Skip_B1( "Unused");
+ break;
+ default :
+ Skip_B2( "Unknown");
+ }
+ }
+ break;
+ case 0x71 :
+ {
+ Param_Info1("VC-3");
+ Skip_B1( "Variant");
+ Skip_B1( "Unused");
+ Skip_B1( "Unused");
+ }
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ break;
+ default :
+ Skip_B5( "Unknown");
+ }
+ }
+ break;
+ case 0x02 :
+ {
+ Param_Info1("Sound essence");
+ Info_B1(Code3, "Code (3)");
+ switch (Code3)
+ {
+ case 0x01 :
+ Skip_B5( "Sound coding or compression");
+ break;
+ case 0x02 :
+ {
+ Param_Info1("Sound Coding Characteristics");
+ Info_B1(Code4, "Code (4)");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Uncompressed Sound Coding");
+ Info_B1(Code5, "Code (5)");
+ switch (Code5)
+ {
+ case 0x7E :
+ {
+ Param_Info1("PCM (AIFF)");
+ Skip_B3( "Reserved");
+ }
+ break;
+ case 0x7F :
+ {
+ Param_Info1("PCM");
+ Skip_B3( "Reserved");
+ }
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ case 0x02 :
+ {
+ Param_Info1("Compressed Sound Coding");
+ Info_B1(Code5, "Code (5)");
+ switch (Code5)
+ {
+ case 0x03 :
+ {
+ Param_Info1("Compressed Audio Coding");
+ Info_B1(Code6, "Code (6)");
+ switch (Code6)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Compandeded Audio Coding");
+ Info_B1(Code7, "Code (7)");
+ switch (Code7)
+ {
+ case 0x01 :
+ Param_Info1("A-law Coded Audio (default)");
+ Skip_B1("Unknown");
+ break;
+ case 0x02 :
+ Param_Info1("DV Compressed Audio");
+ Skip_B1("Unknown");
+ break;
+ default :
+ Skip_B2("Unknown");
+ }
+ }
+ break;
+ case 0x02 :
+ {
+ Param_Info1("SMPTE 338M Audio Coding");
+ Info_B1(Code7, "Code (7)");
+ switch (Code7)
+ {
+ case 0x01 :
+ Param_Info1("AC-3");
+ Skip_B1("Unknown");
+ break;
+ case 0x04 :
+ Param_Info1("MPEG-1 Audio Layer 1");
+ Skip_B1("Unknown");
+ break;
+ case 0x05 :
+ Param_Info1("MPEG-1 Audio Layer 2");
+ Skip_B1("Unknown");
+ break;
+ case 0x06 :
+ Param_Info1("MPEG-2 Audio Layer 1");
+ Skip_B1("Unknown");
+ break;
+ case 0x1C :
+ Param_Info1("Dolby E");
+ Skip_B1("Unknown");
+ break;
+ default :
+ Skip_B2("Unknown");
+ }
+ }
+ break;
+ case 0x03 :
+ {
+ Param_Info1("MPEG-2 Coding (not defined in SMPTE 338M)");
+ Info_B1(Code7, "Code (7)");
+ switch (Code7)
+ {
+ case 0x01 :
+ Param_Info1("AAC version 2");
+ Skip_B1("Unknown");
+ break;
+ default :
+ Skip_B2("Unknown");
+ }
+ }
+ break;
+ case 0x04 :
+ {
+ Param_Info1("MPEG-4 Audio Coding");
+ Info_B1(Code7, "Code (7)");
+ switch (Code7)
+ {
+ case 0x01 :
+ Param_Info1("MPEG-4 Speech Profile");
+ Skip_B1("Unknown");
+ break;
+ case 0x02 :
+ Param_Info1("MPEG-4 Synthesis Profile");
+ Skip_B1("Unknown");
+ break;
+ case 0x03 :
+ Param_Info1("MPEG-4 Scalable Profile");
+ Skip_B1("Unknown");
+ break;
+ case 0x04 :
+ Param_Info1("MPEG-4 Main Profile");
+ Skip_B1("Unknown");
+ break;
+ case 0x05 :
+ Param_Info1("MPEG-4 High Quality Audio Profile");
+ Skip_B1("Unknown");
+ break;
+ case 0x06 :
+ Param_Info1("MPEG-4 Low Delay Audio Profile");
+ Skip_B1("Unknown");
+ break;
+ case 0x07 :
+ Param_Info1("MPEG-4 Natural Audio Profile");
+ Skip_B1("Unknown");
+ break;
+ case 0x08 :
+ Param_Info1("MPEG-4 Mobile Audio Internetworking Profile");
+ Skip_B1("Unknown");
+ break;
+ default :
+ Skip_B2("Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B2( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B5( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B6( "Unknown");
+ }
+ }
+ break;
+ case 0x0D :
+ {
+ Param_Info1("User Organisation Registered For Public Use");
+ Info_B1(Code2, "Organization");
+ switch (Code2)
+ {
+ case 0x01 :
+ {
+ Param_Info1("AAF");
+ Info_B1(Code3, "Application");
+ switch (Code3)
+ {
+ case 0x02 :
+ {
+ Param_Info1("Operational Patterns");
+ Info_B1(Code4, "Version");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Version 1");
+ Info_B1(Code5, "Item Complexity");
+ Info_B1(Code6, "Package Complexity");
+ Info_B1(Code7, "Qualifier");
+ Skip_Flags(Code7, 3, "uni/multi-track");
+ Skip_Flags(Code7, 2, "stream/non-stream file");
+ Skip_Flags(Code7, 1, "internal/external essence");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ case 0x02 :
+ {
+ Info_B1(Code5, "Code (5)");
+ switch (Code5)
+ {
+ case 0x01 :
+ Skip_B3( "Essence container kind");
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ case 0x03 :
+ {
+ Param_Info1("Essence Container Application");
+ Info_B1(Code4, "Structure Version");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("MXF EC Structure Version 1");
+ Info_B1(Code5, "Essence container Kind");
+ switch (Code5)
+ {
+ case 0x01 :
+ Param_Info1("Deprecated Essence Container Kind");
+ Skip_B3( "Unknown");
+ break;
+ case 0x02 :
+ {
+ Param_Info1("Essence Container Kind");
+ Info_B1(Code6, "Code (6)");
+ switch (Code6)
+ {
+ case 0x01 : //SMPTE 386M
+ {
+ Param_Info1("Type D-10 Mapping");
+ Skip_B1( "MPEG Constraints"); //SMPTE 356M
+ Skip_B1( "Template Extension");
+ }
+ break;
+ case 0x02 :
+ {
+ Param_Info1("DV Mappings");
+ Skip_B1( "Mapping Kind");
+ Skip_B1( "Locally defined");
+ }
+ break;
+ case 0x03 :
+ {
+ Param_Info1("Type D-11 Mapping");
+ Skip_B1( "Mapping Kind");
+ Skip_B1( "Locally defined");
+ }
+ break;
+ case 0x04 :
+ {
+ Param_Info1("MPEG ES mappings");
+ Info_B1(Code7, "ISO13818-1 stream_id bits 6..0"); Param_Info1(Ztring::ToZtring(0x80+Code7, 16));
+ Info_B1(Code8, "Mapping Kind"); Param_Info1(Mxf_EssenceContainer_Mapping(Code6, Code7, Code8));
+ }
+ break;
+ case 0x05 : //SMPTE 384M
+ {
+ Param_Info1("Uncompressed Pictures");
+ Info_B1(Code7, "Number of lines / field rate combination"); //SMPTE 384M
+ Info_B1(Code8, "Mapping Kind"); Param_Info1(Mxf_EssenceContainer_Mapping(Code6, Code7, Code8));
+ }
+ break;
+ case 0x06 :
+ {
+ Param_Info1("AES-BWF");
+ Info_B1(Code7, "Mapping Kind"); Param_Info1(Mxf_EssenceContainer_Mapping(Code6, Code7, 0x7F));
+ Skip_B1( "Locally defined");
+ }
+ break;
+ case 0x07 :
+ {
+ Param_Info1("MPEG PES mappings");
+ Info_B1(Code7, "ISO13818-1 stream_id bits 6..0"); Param_Info1(Ztring::ToZtring(0x80+Code7, 16));
+ Info_B1(Code8, "Mapping Kind"); Param_Info1(Mxf_EssenceContainer_Mapping(Code6, Code7, Code8));
+ }
+ break;
+ case 0x08 :
+ {
+ Param_Info1("MPEG PS mappings");
+ Info_B1(Code7, "ISO13818-1 stream_id bits 6..0"); Param_Info1(Ztring::ToZtring(0x80+Code7, 16));
+ Info_B1(Code8, "Mapping Kind"); Param_Info1(Mxf_EssenceContainer_Mapping(Code6, Code7, Code8));
+ }
+ break;
+ case 0x09 :
+ {
+ Param_Info1("MPEG TS mappings");
+ Info_B1(Code7, "ISO13818-1 stream_id bits 6..0"); Param_Info1(Ztring::ToZtring(0x80+Code7, 16));
+ Info_B1(Code8, "Mapping Kind"); Param_Info1(Mxf_EssenceContainer_Mapping(Code6, Code7, Code8));
+ }
+ break;
+ case 0x0A :
+ {
+ Param_Info1("A-law Sound Element Mapping");
+ Info_B1(Code7, "Mapping Kind"); Param_Info1(Mxf_EssenceContainer_Mapping(Code6, Code7, 0xFF));
+ Skip_B1( "Locally defined");
+ }
+ break;
+ case 0x0B :
+ {
+ Param_Info1("Encrypted Generic Container");
+ Skip_B1( "Mapping Kind");
+ Skip_B1( "Locally defined");
+ }
+ break;
+ case 0x0C :
+ {
+ Param_Info1("JPEG 2000 Picture Mapping");
+ Skip_B1( "Mapping Kind");
+ Skip_B1( "Locally defined");
+ }
+ break;
+ case 0x11 :
+ {
+ Param_Info1("VC-3 Picture Element");
+ Info_B1(Code7, "Content Kind"); Param_Info1(Mxf_EssenceContainer_Mapping(Code6, Code7, 0xFF));
+ Skip_B1( "Reserved");
+ }
+ break;
+ case 0x16 :
+ {
+ Param_Info1("AVC Picture Element");
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ }
+ break;
+ case 0x7F :
+ {
+ Param_Info1("Generic Essence Container Wrapping");
+ Skip_B1( "Mapping Kind");
+ Skip_B1( "Locally defined");
+ }
+ break;
+ default :
+ {
+ Skip_B1( "Mapping Kind");
+ Skip_B1( "Locally defined");
+ }
+ }
+ }
+ break;
+ default :
+ Skip_B1( "Essence container Kind");
+ Skip_B1( "Mapping Kind");
+ Skip_B1( "Locally defined");
+ }
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ case 0x04 :
+ {
+ Param_Info1("MXF / AAF compatible Descriptive Metadata Labels");
+ Info_B1(Code4, "Label Version");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("Version 1");
+ Info_B1(Code5, "Scheme Kind");
+ Info_B1(Code6, "Reserved");
+ Info_B1(Code7, "Reserved");
+ Info_B1(Code8, "Reserved");
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B5( "Unknown");
+ }
+ }
+ break;
+ case 0x02 :
+ {
+ Param_Info1("EBU/UER");
+ Skip_B6( "Unknown");
+ }
+ break;
+ case 0x03 :
+ {
+ Param_Info1("Pro-MPEG Forum");
+ Skip_B6( "Unknown");
+ }
+ break;
+ case 0x04 :
+ {
+ Param_Info1("BBC");
+ Skip_B6( "Unknown");
+ }
+ break;
+ case 0x05 :
+ {
+ Param_Info1("IRT");
+ Skip_B6( "Unknown");
+ }
+ break;
+ case 0x06 :
+ {
+ Param_Info1("ARIB");
+ Skip_B6( "Unknown");
+ }
+ break;
+ default :
+ Skip_B6( "Unknown");
+ }
+ }
+ break;
+ case 0x0E :
+ {
+ Param_Info1("User Organisation Registered For Private Use");
+ Info_B1(Code2, "Code (2)");
+ switch (Code2)
+ {
+ case 0x04 :
+ {
+ Param_Info1("Avid");
+ Info_B1(Code3, "Code (3)");
+ switch (Code3)
+ {
+ case 0x02 :
+ {
+ Param_Info1("Essence Compression?");
+ Info_B1(Code4, "?");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("?");
+ Info_B1(Code5, "?");
+ switch (Code5)
+ {
+ case 0x02 :
+ {
+ Param_Info1("?");
+ Info_B1(Code6, "Code (6)");
+ switch (Code6)
+ {
+ case 0x04 :
+ Param_Info1("VC-3");
+ Skip_B2( "Unknown");
+ break;
+ default :
+ Skip_B2( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ case 0x03 :
+ {
+ Param_Info1("Essence Container Application");
+ Info_B1(Code4, "Structure Version");
+ switch (Code4)
+ {
+ case 0x01 :
+ {
+ Param_Info1("MXF EC Structure Version 1");
+ Info_B1(Code5, "Essence container Kind");
+ switch (Code5)
+ {
+ case 0x02 :
+ {
+ Param_Info1("Essence Container Kind");
+ Info_B1(Code6, "Code (6)");
+ switch (Code6)
+ {
+ case 0x06 :
+ Param_Info1("VC-3");
+ Skip_B2( "Unknown");
+ break;
+ default :
+ Skip_B2( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B3( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B4( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B5( "Unknown");
+ }
+ }
+ break;
+ default :
+ Skip_B6( "Private");
+ }
+ }
+ break;
+ default :
+ Skip_B7( "Unknown");
+ }
+}
+#endif //MEDIAINFO_TRACE
+
+//---------------------------------------------------------------------------
+void File_Mxf::Skip_UL(const char* Name)
+{
+ #ifdef MEDIAINFO_MINIMIZE_SIZE
+ Skip_UUID();
+ #else
+ int128u Value;
+ Get_UL(Value, Name, NULL);
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Get_UMID(int256u &Value, const char* Name)
+{
+ Element_Name(Name);
+
+ //Parsing
+ Get_UUID (Value.hi, "Fixed");
+ Get_UUID (Value.lo, "UUID"); Element_Info1(Ztring().From_UUID(Value.lo));
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Skip_UMID()
+{
+ //Parsing
+ Skip_UUID( "Fixed");
+ Info_UUID(Data, "UUID"); Element_Info1(Ztring().From_UUID(Data));
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Get_Timestamp(Ztring &Value)
+{
+ //Parsing
+ int16u Year;
+ int8u Month, Day, Hours, Minutes, Seconds, Milliseconds;
+ Get_B2 (Year, "Year");
+ Get_B1 (Month, "Month");
+ Get_B1 (Day, "Day");
+ Get_B1 (Hours, "Hours");
+ Get_B1 (Minutes, "Minutes");
+ Get_B1 (Seconds, "Seconds");
+ Get_B1 (Milliseconds, "Milliseconds/4"); Param_Info2(Milliseconds*4, " ms");
+ Value.From_Number(Year);
+ Value+=_T('-');
+ Ztring Temp;
+ Temp.From_Number(Month);
+ if (Temp.size()<2)
+ Temp.insert(0, 1, _T('0'));
+ Value+=Temp;
+ Value+=_T('-');
+ Temp.From_Number(Day);
+ if (Temp.size()<2)
+ Temp.insert(0, 1, _T('0'));
+ Value+=Temp;
+ Value+=_T(' ');
+ Temp.From_Number(Hours);
+ if (Temp.size()<2)
+ Temp.insert(0, 1, _T('0'));
+ Value+=Temp;
+ Value+=_T(':');
+ Temp.From_Number(Minutes);
+ if (Temp.size()<2)
+ Temp.insert(0, 1, _T('0'));
+ Value+=Temp;
+ Value+=_T(':');
+ Temp.From_Number(Seconds);
+ if (Temp.size()<2)
+ Temp.insert(0, 1, _T('0'));
+ Value+=Temp;
+ Value+=_T('.');
+ Temp.From_Number(Milliseconds*4);
+ if (Temp.size()<3)
+ Temp.insert(0, 3-Temp.size(), _T('0'));
+ Value+=Temp;
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Skip_Timestamp()
+{
+ //Parsing
+ Skip_B2( "Year");
+ Skip_B1( "Month");
+ Skip_B1( "Day");
+ Skip_B1( "Hours");
+ Skip_B1( "Minutes");
+ Skip_B1( "Seconds");
+ Info_B1(Milliseconds, "Milliseconds/4"); Param_Info2(Milliseconds*4, " ms");
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Info_Timestamp()
+{
+ //Parsing
+ Info_B2(Year, "Year");
+ Info_B1(Month, "Month");
+ Info_B1(Day, "Day");
+ Info_B1(Hours, "Hours");
+ Info_B1(Minutes, "Minutes");
+ Info_B1(Seconds, "Seconds");
+ Info_B1(Milliseconds, "Milliseconds/4"); Param_Info2(Milliseconds*4, " ms");
+ Element_Info1(Ztring::ToZtring(Year )+_T('-')+
+ Ztring::ToZtring(Month )+_T('-')+
+ Ztring::ToZtring(Day )+_T(' ')+
+ Ztring::ToZtring(Hours )+_T(':')+
+ Ztring::ToZtring(Minutes )+_T(':')+
+ Ztring::ToZtring(Seconds )+_T('.')+
+ Ztring::ToZtring(Milliseconds*4) );
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Get_BER(int64u &Value, const char* Name)
+{
+ int8u Length;
+ Get_B1(Length, Name);
+ if (Length<0x80)
+ {
+ Value=Length; //1-byte
+ return;
+ }
+
+ Length&=0x7F;
+ switch (Length)
+ {
+ case 1 :
+ {
+ int8u Length1;
+ Get_B1(Length1, Name);
+ Value=Length1;
+ break;
+ }
+ case 2 :
+ {
+ int16u Length2;
+ Get_B2(Length2, Name);
+ Value=Length2;
+ break;
+ }
+ case 3 :
+ {
+ int32u Length3;
+ Get_B3(Length3, Name);
+ Value=Length3;
+ break;
+ }
+ case 4 :
+ {
+ int32u Length4;
+ Get_B4(Length4, Name);
+ Value=Length4;
+ break;
+ }
+ case 5 :
+ {
+ int64u Length5;
+ Get_B5(Length5, Name);
+ Value=Length5;
+ break;
+ }
+ case 6 :
+ {
+ int64u Length6;
+ Get_B6(Length6, Name);
+ Value=Length6;
+ break;
+ }
+ case 7 :
+ {
+ int64u Length7;
+ Get_B7(Length7, Name);
+ Value=Length7;
+ break;
+ }
+ case 8 :
+ {
+ int64u Length8;
+ Get_B8(Length8, Name);
+ Value=Length8;
+ break;
+ }
+ default:Value=(int64u)-1; //Problem
+ }
+}
+
+//***************************************************************************
+// Parsers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ if ((Descriptor->second.EssenceCompression.hi&0xFFFFFFFFFFFFFF00LL)!=0x060E2B3404010100LL || (Descriptor->second.EssenceCompression.lo&0xFF00000000000000LL)!=0x0400000000000000LL)
+ return ChooseParser__FromEssenceContainer (Essence, Descriptor);
+
+ int8u Code2=(int8u)((Descriptor->second.EssenceCompression.lo&0x00FF000000000000LL)>>48);
+ int8u Code3=(int8u)((Descriptor->second.EssenceCompression.lo&0x0000FF0000000000LL)>>40);
+ int8u Code4=(int8u)((Descriptor->second.EssenceCompression.lo&0x000000FF00000000LL)>>32);
+ int8u Code5=(int8u)((Descriptor->second.EssenceCompression.lo&0x00000000FF000000LL)>>24);
+ int8u Code6=(int8u)((Descriptor->second.EssenceCompression.lo&0x0000000000FF0000LL)>>16);
+ int8u Code7=(int8u)((Descriptor->second.EssenceCompression.lo&0x000000000000FF00LL)>> 8);
+
+ switch (Code2)
+ {
+ case 0x01 : //Picture
+ switch (Code3)
+ {
+ case 0x02 : //Coding characteristics
+ switch (Code4)
+ {
+ case 0x01 : //Uncompressed Picture Coding
+ switch (Code5)
+ {
+ case 0x01 : return ChooseParser_Raw(Essence, Descriptor);
+ case 0x7F : return ChooseParser_RV24(Essence, Descriptor);
+ default : return NULL;
+ }
+ case 0x02 : //Compressed coding
+ switch (Code5)
+ {
+ case 0x01 : //MPEG Compression
+ switch (Code6)
+ {
+ case 0x01 :
+ case 0x02 :
+ case 0x03 :
+ case 0x04 :
+ case 0x11 : return ChooseParser_Mpegv(Essence, Descriptor);
+ case 0x20 : return ChooseParser_Mpeg4v(Essence, Descriptor);
+ case 0x32 : return ChooseParser_Avc(Essence, Descriptor);
+ default : return NULL;
+ }
+ case 0x02 : return ChooseParser_DV(Essence, Descriptor);
+ case 0x03 : //Individual Picture Coding Schemes
+ switch (Code6)
+ {
+ case 0x01 : return ChooseParser_Jpeg2000(Essence, Descriptor);
+ default : return NULL;
+ }
+ case 0x71 : return ChooseParser_Vc3(Essence, Descriptor);
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ case 0x02 : //Sound
+ switch (Code3)
+ {
+ case 0x02 : //Coding characteristics
+ switch (Code4)
+ {
+ case 0x01 : //Uncompressed Sound Coding
+ return ChooseParser_Pcm(Essence, Descriptor);
+ case 0x02 : //Compressed coding
+ switch (Code5)
+ {
+ case 0x03 : //Compressed Audio Coding
+ switch (Code6)
+ {
+ case 0x01 : //Compandeded Audio Coding
+ switch (Code7)
+ {
+ case 0x01 : if ((Descriptor->second.EssenceContainer.lo&0xFFFF0000)==0x02060000) //Test coherency between container and compression
+ return ChooseParser_Pcm(Essence, Descriptor); //Compression is A-Law but Container is PCM, not logic, prioritizing PCM
+ else
+ return ChooseParser_Alaw(Essence, Descriptor);
+ case 0x10 : return ChooseParser_Pcm(Essence, Descriptor); //DV 12-bit
+ default : return NULL;
+ }
+ case 0x02 : //SMPTE 338M Audio Coding
+ switch (Code7)
+ {
+ case 0x01 : return ChooseParser_Ac3(Essence, Descriptor);
+ case 0x04 :
+ case 0x05 :
+ case 0x06 : return ChooseParser_Mpega(Essence, Descriptor);
+ case 0x1C : return ChooseParser_ChannelGrouping(Essence, Descriptor); //Dolby E (in 2 mono streams)
+ default : return NULL;
+ }
+ case 0x03 : //MPEG-2 Coding (not defined in SMPTE 338M)
+ switch (Code7)
+ {
+ case 0x01 : return ChooseParser_Aac(Essence, Descriptor);
+ default : return NULL;
+ }
+ case 0x04 : //MPEG-4 Audio Coding
+ switch (Code7)
+ {
+ case 0x01 :
+ case 0x02 :
+ case 0x03 :
+ case 0x04 :
+ case 0x05 :
+ case 0x06 :
+ case 0x07 :
+ case 0x08 : return ChooseParser_Aac(Essence, Descriptor);
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser__FromEssenceContainer(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int8u Code1=(int8u)((Descriptor->second.EssenceContainer.lo&0xFF00000000000000LL)>>56);
+ int8u Code2=(int8u)((Descriptor->second.EssenceContainer.lo&0x00FF000000000000LL)>>48);
+ int8u Code3=(int8u)((Descriptor->second.EssenceContainer.lo&0x0000FF0000000000LL)>>40);
+ int8u Code4=(int8u)((Descriptor->second.EssenceContainer.lo&0x000000FF00000000LL)>>32);
+ int8u Code5=(int8u)((Descriptor->second.EssenceContainer.lo&0x00000000FF000000LL)>>24);
+ int8u Code6=(int8u)((Descriptor->second.EssenceContainer.lo&0x0000000000FF0000LL)>>16);
+ //int8u Code7=(int8u)((Descriptor->second.EssenceContainer.lo&0x000000000000FF00LL)>> 8);
+
+ switch (Code1)
+ {
+ case 0x0D : //Public Use
+ switch (Code2)
+ {
+ case 0x01 : //AAF
+ switch (Code3)
+ {
+ case 0x03 : //Essence Container Application
+ switch (Code4)
+ {
+ case 0x01 : //MXF EC Structure version
+ switch (Code5)
+ {
+ case 0x02 : //Essence container kind
+ switch (Code6)
+ {
+ case 0x01 : switch(Descriptor->second.StreamKind)
+ {
+ case Stream_Video : return ChooseParser_Mpegv(Essence, Descriptor);
+ case Stream_Audio : return ChooseParser_Aes3(Essence, Descriptor);
+ default : return NULL;
+ }
+ case 0x02 : return NULL; //DV
+ case 0x05 : return ChooseParser_Raw(Essence, Descriptor);
+ case 0x06 : if (Descriptor->second.ChannelCount==1) return ChooseParser_ChannelGrouping(Essence, Descriptor); else return ChooseParser_Pcm(Essence, Descriptor); //PCM, but one file is found with Dolby E in it
+ case 0x04 : return NULL; //MPEG ES mappings with Stream ID
+ case 0x0A : return ChooseParser_Alaw(Essence, Descriptor);
+ case 0x0C : return ChooseParser_Jpeg2000(Essence, Descriptor);
+ case 0x11 : return ChooseParser_Vc3(Essence, Descriptor);
+ case 0x16 : return ChooseParser_Avc(Essence, Descriptor);
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ case 0x0E : //Private Use
+ switch (Code2)
+ {
+ case 0x04 : //Avid
+ switch (Code3)
+ {
+ case 0x03 : //Essence Container Application
+ switch (Code4)
+ {
+ case 0x01 : //MXF EC Structure version
+ switch (Code5)
+ {
+ case 0x02 : //Essence container kind
+ switch (Code6)
+ {
+ case 0x06 : return ChooseParser_Vc3(Essence, Descriptor);
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+ default : return NULL;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::ChooseParser__FromEssence(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare3=Code.lo>>32;
+
+ switch (Code_Compare3)
+ {
+ case Elements::GenericContainer_Aaf3 : return ChooseParser__Aaf(Essence, Descriptor);
+ case Elements::GenericContainer_Avid3 : return ChooseParser__Avid(Essence, Descriptor);
+ default : Essences[(int32u)Code.lo].Parser=new File__Analyze();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::ChooseParser__Aaf(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare4=(int32u)Code.lo;
+ int8u Code_Compare4_1=Code_Compare4>>24;
+
+ switch (Code_Compare4_1)
+ {
+ case 0x05 : //CP Picture
+ ChooseParser__Aaf_CP_Picture(Essence, Descriptor);
+ break;
+ case 0x06 : //CP Sound
+ ChooseParser__Aaf_CP_Sound(Essence, Descriptor);
+ break;
+ case 0x07 : //CP Data
+ ChooseParser__Aaf_CP_Data(Essence, Descriptor);
+ break;
+ case 0x14 : //MXF in MXF?
+ ChooseParser__Aaf_14(Essence, Descriptor);
+ break;
+ case 0x15 : //CP Picture
+ ChooseParser__Aaf_GC_Picture(Essence, Descriptor);
+ break;
+ case 0x16 : //CP Sound
+ ChooseParser__Aaf_GC_Sound(Essence, Descriptor);
+ break;
+ case 0x17 : //CP Data
+ ChooseParser__Aaf_GC_Data(Essence, Descriptor);
+ break;
+ case 0x18 : //CP Compound
+ ChooseParser__Aaf_GC_Compound(Essence, Descriptor);
+ break;
+ default : //Unknown
+ Essences[Code_Compare4].Parser=new File__Analyze();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::ChooseParser__Avid(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare4=(int32u)Code.lo;
+ int8u Code_Compare4_1=Code_Compare4>>24;
+
+ switch (Code_Compare4_1)
+ {
+ case 0x15 : //CP Picture
+ ChooseParser__Avid_Picture(Essence, Descriptor);
+ break;
+ default : //Unknown
+ Essences[Code_Compare4].Parser=new File__Analyze();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x05, SMPTE 326M
+void File_Mxf::ChooseParser__Aaf_CP_Picture(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare4=(int32u)Code.lo;
+ int8u Code_Compare4_3=(int8u)(Code_Compare4>>8);
+
+ Essences[Code_Compare4].StreamKind=Stream_Video;
+ Essences[Code_Compare4].StreamPos=Code_Compare4&0x000000FF;
+
+ switch (Code_Compare4_3)
+ {
+ case 0x01 : //D-10 Video, SMPTE 386M
+ Essences[Code_Compare4].Parser=ChooseParser_Mpegv(Essence, Descriptor);
+ break;
+ default : //Unknown
+ Essences[Code_Compare4].Parser=new File__Analyze();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x06, SMPTE 326M
+void File_Mxf::ChooseParser__Aaf_CP_Sound(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare4=(int32u)Code.lo;
+ int8u Code_Compare4_3=(int8u)(Code_Compare4>>8);
+
+ Essences[Code_Compare4].StreamKind=Stream_Audio;
+ Essences[Code_Compare4].StreamPos=Code_Compare4&0x000000FF;
+
+ switch (Code_Compare4_3)
+ {
+ case 0x10 : //D-10 Audio, SMPTE 386M
+ Essences[Code_Compare4].Parser=ChooseParser_Aes3(Essence, Descriptor);
+ break;
+ default : //Unknown
+ Essences[Code_Compare4].Parser=new File__Analyze();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x07, SMPTE 326M
+void File_Mxf::ChooseParser__Aaf_CP_Data(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare4=(int32u)Code.lo;
+ //int8u Code_Compare4_3=(int8u)(Code_Compare4>>8);
+
+ //switch (Code_Compare4_3)
+ //{
+ // default : //Unknown
+ Essences[Code_Compare4].Parser=new File__Analyze();
+ //}
+}
+
+//---------------------------------------------------------------------------
+// 0x14
+void File_Mxf::ChooseParser__Aaf_14(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare4=(int32u)Code.lo;
+ int8u Code_Compare4_3=(int8u)(Code_Compare4>>8);
+
+ switch (Code_Compare4_3)
+ {
+ case 0x01 : //MXF in MXF?
+ Essences[Code_Compare4].Parser=new File_Mxf();
+ break;
+ default : Essences[Code_Compare4].Parser=new File__Analyze();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x15
+void File_Mxf::ChooseParser__Aaf_GC_Picture(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare4=(int32u)Code.lo;
+ int8u Code_Compare4_3=(int8u)(Code_Compare4>>8);
+
+ Essences[Code_Compare4].StreamKind=Stream_Video;
+ Essences[Code_Compare4].StreamPos=Code_Compare4&0x000000FF;
+
+ switch (Code_Compare4_3)
+ {
+ case 0x01 : //RV24
+ Essences[Code_Compare4].Parser=ChooseParser_RV24(Essence, Descriptor);
+ break;
+ case 0x02 : //Raw video
+ Essences[Code_Compare4].Parser=ChooseParser_Raw(Essence, Descriptor);
+ break;
+ case 0x05 : //SMPTE 381M, Frame wrapped
+ Essences[Code_Compare4].Parser=ChooseParser_Mpegv(Essence, Descriptor); //Trying...
+ Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=_T("Frame");
+ break;
+ case 0x06 : //SMPTE 381M, Clip wrapped
+ Essences[Code_Compare4].Parser=ChooseParser_Mpegv(Essence, Descriptor); //Trying...
+ Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=_T("Clip");
+ break;
+ case 0x07 : //SMPTE 381M, Custom wrapped
+ Essences[Code_Compare4].Parser=ChooseParser_Mpegv(Essence, Descriptor); //Trying...
+ Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=_T("Custom");
+ break;
+ case 0x08 : //JPEG 2000
+ Essences[Code_Compare4].Parser=ChooseParser_Jpeg2000(Essence, Descriptor);
+ break;
+ case 0x0D : //VC-3
+ Essences[Code_Compare4].Parser=ChooseParser_Vc3(Essence, Descriptor);
+ break;
+ default : //Unknown
+ Essences[Code_Compare4].Parser=new File__Analyze();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x16
+void File_Mxf::ChooseParser__Aaf_GC_Sound(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare4=(int32u)Code.lo;
+ int8u Code_Compare4_3=(int8u)(Code_Compare4>>8);
+
+ Essences[Code_Compare4].StreamKind=Stream_Audio;
+ Essences[Code_Compare4].StreamPos=Code_Compare4&0x000000FF;
+
+ switch (Code_Compare4_3)
+ {
+ case 0x01 : //BWF (PCM)
+ case 0x02 : //BWF (PCM)
+ case 0x03 : //DV Audio (PCM)
+ case 0x04 : //P2 Audio (PCM)
+ Essences[Code_Compare4].Parser=ChooseParser_Pcm(Essences.begin(), Descriptors.begin());
+ break;
+ case 0x05 : //MPEG Audio
+ Essences[Code_Compare4].Parser=ChooseParser_Mpega(Essence, Descriptor);
+ break;
+ case 0x08 : //A-law, Frame wrapped
+ Essences[Code_Compare4].Parser=ChooseParser_Alaw(Essence, Descriptor);
+ Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=_T("Frame");
+ break;
+ case 0x09 : //A-law, Clip wrapped
+ Essences[Code_Compare4].Parser=ChooseParser_Alaw(Essence, Descriptor);
+ Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=_T("Clip");
+ break;
+ case 0x0A : //A-law, Custom wrapped
+ Essences[Code_Compare4].Parser=ChooseParser_Alaw(Essence, Descriptor);
+ Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=_T("Custom");
+ break;
+ default : //Unknown
+ Essences[Code_Compare4].Parser=new File__Analyze();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x17
+void File_Mxf::ChooseParser__Aaf_GC_Data(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare4=(int32u)Code.lo;
+ int8u Code_Compare4_3=(int8u)(Code_Compare4>>8);
+
+ switch (Code_Compare4_3)
+ {
+ case 0x02 : //Ancillary
+ if (Ancillary)
+ Essences[Code_Compare4].Parser=Ancillary;
+ else
+ {
+ Essences[Code_Compare4].Parser=new File_Ancillary();
+ Ancillary=(File_Ancillary*)Essences[Code_Compare4].Parser;
+ }
+ Ancillary_IsBinded=true;
+ break;
+ case 0x08 : //Line Wrapped Data Element, SMPTE 384M
+ case 0x09 : //Line Wrapped VANC Data Element, SMPTE 384M
+ case 0x0A : //Line Wrapped HANC Data Element, SMPTE 384M
+ break;
+ default : //Unknown
+ Essences[Code_Compare4].Parser=new File__Analyze();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x18
+void File_Mxf::ChooseParser__Aaf_GC_Compound(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare4=(int32u)Code.lo;
+ int8u Code_Compare4_3=(int8u)(Code_Compare4>>8);
+
+ Essences[Code_Compare4].StreamKind=Stream_Video; //Default to video, audio will be merge later
+ Essences[Code_Compare4].StreamPos=Code_Compare4&0x000000FF;
+
+ switch (Code_Compare4_3)
+ {
+ case 0x01 : //DV
+ case 0x02 : //DV
+ Essences[Code_Compare4].Parser=ChooseParser_DV(Essence, Descriptor);
+ break;
+ default : //Unknown
+ Essences[Code_Compare4].Parser=new File__Analyze();
+ }
+}
+
+//---------------------------------------------------------------------------
+// 0x15
+void File_Mxf::ChooseParser__Avid_Picture(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ int32u Code_Compare4=(int32u)Code.lo;
+ int8u Code_Compare4_3=(int8u)(Code_Compare4>>8);
+
+ Essences[Code_Compare4].StreamKind=Stream_Video;
+ Essences[Code_Compare4].StreamPos=Code_Compare4&0x000000FF;
+
+ switch (Code_Compare4_3)
+ {
+ case 0x05 : //VC-1, Frame wrapped
+ Essences[Code_Compare4].Parser=ChooseParser_Vc3(Essence, Descriptor);
+ Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=_T("Frame");
+ break;
+ case 0x06 : //VC-1, Clip wrapped
+ Essences[Code_Compare4].Parser=ChooseParser_Vc3(Essence, Descriptor);
+ Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=_T("Clip");
+ break;
+ case 0x07 : //VC-1, Custom wrapped
+ Essences[Code_Compare4].Parser=ChooseParser_Vc3(Essence, Descriptor);
+ Essences[Code_Compare4].Infos["Format_Settings_Wrapping"]=_T("Custom");
+ break;
+ default : //Unknown
+ Essences[Code_Compare4].Parser=new File__Analyze();
+ }
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Avc(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Video;
+
+ //Filling
+ #if defined(MEDIAINFO_AVC_YES)
+ File_Avc* Parser=new File_Avc;
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Format, "AVC");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_DV(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Video;
+
+ //Filling
+ #if defined(MEDIAINFO_DVDIF_YES)
+ File_DvDif* Parser=new File_DvDif;
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "DV");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Mpeg4v(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Video;
+
+ //Filling
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ File_Mpeg4v* Parser=new File_Mpeg4v;
+ Parser->OnlyVOP();
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Format, "MPEG-4 Visual");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Mpegv(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Video;
+
+ //Filling
+ #if defined(MEDIAINFO_MPEGV_YES)
+ File_Mpegv* Parser=new File_Mpegv();
+ Parser->Ancillary=&Ancillary;
+ #else
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Format, "MPEG Video");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Raw(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Video;
+
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Format, "YUV");
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_RV24(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Video;
+
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Format, "RV24");
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Vc3(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Video;
+
+ //Filling
+ #if defined(MEDIAINFO_VC3_YES)
+ File_Vc3* Parser=new File_Vc3;
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Format, "VC-3");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Aac(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Audio;
+
+ //Filling
+ #if defined(MEDIAINFO_AAC_YES)
+ File_Aac* Parser=new File_Aac;
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "AAC");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Ac3(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Audio;
+
+ //Filling
+ #if defined(MEDIAINFO_AC3_YES)
+ File_Ac3* Parser=new File_Ac3;
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "AC-3");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Aes3(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Audio;
+
+ //Filling
+ #if defined(MEDIAINFO_AES3_YES)
+ File_Aes3* Parser=new File_Aes3;
+ Parser->From_Raw=true;
+ if (Descriptor!=Descriptors.end())
+ {
+ if (Descriptor->second.QuantizationBits!=(int32u)-1)
+ Parser->QuantizationBits=Descriptor->second.QuantizationBits;
+ if (Descriptor->second.Infos.find("SamplingRate")!=Descriptor->second.Infos.end())
+ Parser->SampleRate=Descriptor->second.Infos["SamplingRate"].To_int32u();
+ if (Descriptor->second.Infos.find("Format_Settings_Endianness")!=Descriptor->second.Infos.end())
+ {
+ if (Descriptor->second.Infos["Format_Settings_Endianness"]==_T("Big"))
+ Parser->Endianness='B';
+ else
+ Parser->Endianness='L';
+ }
+ else
+ Parser->Endianness='L';
+ }
+ else
+ Parser->Endianness='L';
+
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer)
+ {
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "AAC");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Alaw(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Audio;
+
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "Alaw");
+ return Parser;
+}
+
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_ChannelGrouping(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Audio;
+
+ //Creating the parser
+ //if (Descriptor->second.BlockAlign==3) //Channels==1 && ((StreamPos_Last%2==0) || Streams.find(moov_trak_tkhd_TrackID-1)!=Streams.end() && Streams[moov_trak_tkhd_TrackID-1].IsPcmMono))
+ {
+ File_ChannelGrouping* Parser;
+ if ((Essence->second.StreamPos-(StreamPos_StartAtOne?1:0))%2)
+ {
+ essences::iterator FirstChannel=Essences.find(Essence->first-1);
+ if (FirstChannel==Essences.end() || !FirstChannel->second.IsChannelGrouping)
+ return ChooseParser_Pcm(Essence, Descriptor); //Not a channel grouping
+
+ Parser=new File_ChannelGrouping;
+ Parser->Channel_Pos=1;
+ Parser->Common=((File_ChannelGrouping*)Essences[Essence->first-1].Parser)->Common;
+ Parser->StreamID=Essence->second.TrackID-1;
+ }
+ else
+ {
+ Parser=new File_ChannelGrouping;
+ Parser->Channel_Pos=0;
+ if (Descriptor!=Descriptors.end() && Descriptor->second.Infos.find("SamplingRate")!=Descriptor->second.Infos.end())
+ Parser->SampleRate=Descriptor->second.Infos["SamplingRate"].To_int32u();
+ Essence->second.IsChannelGrouping=true;
+ }
+ Parser->Channel_Total=2;
+ if (Descriptor!=Descriptors.end())
+ {
+ Parser->ByteDepth=Descriptor->second.BlockAlign<=4?Descriptor->second.BlockAlign:(Descriptor->second.BlockAlign/2); //In one file, BlockAlign is size of the aggregated channelgroup
+ if (Descriptor->second.Infos.find("Format_Settings_Endianness")!=Descriptor->second.Infos.end())
+ {
+ if (Descriptor->second.Infos["Format_Settings_Endianness"]==_T("Big"))
+ Parser->Endianness='B';
+ else
+ Parser->Endianness='L';
+ }
+ else
+ Parser->Endianness='L';
+ }
+ else
+ Parser->Endianness='L';
+
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer)
+ {
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ return Parser;
+ }
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Mpega(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Audio;
+
+ //Filling
+ #if defined(MEDIAINFO_MPEGA_YES)
+ File_Mpega* Parser=new File_Mpega;
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "MPEG Audio");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Pcm(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Audio;
+
+ //Creating the parser
+ #if defined(MEDIAINFO_AES3_YES)
+ File_Aes3* Parser=new File_Aes3;
+ if (Descriptor!=Descriptors.end())
+ {
+ if (Descriptor->second.BlockAlign!=(int16u)-1)
+ Parser->ByteSize=Descriptor->second.BlockAlign;
+ if (Descriptor->second.Infos.find("SamplingRate")!=Descriptor->second.Infos.end())
+ Parser->SampleRate=Descriptor->second.Infos["SamplingRate"].To_int32u();
+ if (Descriptor->second.Infos.find("Channel(s)")!=Descriptor->second.Infos.end())
+ Parser->ChannelCount=Descriptor->second.Infos["Channel(s)"].To_int32u();
+ if (Descriptor->second.Infos.find("Format_Settings_Endianness")!=Descriptor->second.Infos.end())
+ {
+ if (Descriptor->second.Infos["Format_Settings_Endianness"]==_T("Big"))
+ Parser->Endianness='B';
+ else
+ Parser->Endianness='L';
+ }
+ else
+ Parser->Endianness='L';
+ }
+ else
+ Parser->Endianness='L';
+
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer)
+ {
+ Parser->Demux_Level=2; //Container
+ Parser->Demux_UnpacketizeContainer=true;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Audio);
+ Parser->Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ #endif
+ return Parser;
+}
+
+//---------------------------------------------------------------------------
+File__Analyze* File_Mxf::ChooseParser_Jpeg2000(const essences::iterator &Essence, const descriptors::iterator &Descriptor)
+{
+ Essence->second.StreamKind=Stream_Video;
+
+ //Filling
+ #if defined(MEDIAINFO_JPEG_YES)
+ File_Jpeg* Parser=new File_Jpeg;
+ Parser->StreamKind=Stream_Video;
+ if (Descriptor!=Descriptors.end())
+ {
+ std::map<std::string, Ztring>::iterator Info=Descriptor->second.Infos.find("ScanType");
+ Parser->Interlaced=Info!=Descriptor->second.Infos.end() && Info->second==_T("Interlaced");
+ }
+ #else
+ //Filling
+ File__Analyze* Parser=new File_Unknown();
+ Open_Buffer_Init(Parser);
+ Parser->Stream_Prepare(Stream_Video);
+ Parser->Fill(Stream_Video, 0, Video_Format, "JPEG 2000");
+ #endif
+ return Parser;
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mxf::Subsampling_Compute(descriptors::iterator Descriptor)
+{
+ if (Descriptor->second.SubSampling_Horizontal==(int32u)-1 || Descriptor->second.SubSampling_Vertical==(int32u)-1)
+ return;
+
+ switch (Descriptor->second.SubSampling_Horizontal)
+ {
+ case 1 : switch (Descriptor->second.SubSampling_Vertical)
+ {
+ case 1 : Descriptor->second.Infos["ChromaSubsampling"]=_T("4:4:4"); return;
+ default: Descriptor->second.Infos["ChromaSubsampling"].clear(); return;
+ }
+ case 2 : switch (Descriptor->second.SubSampling_Vertical)
+ {
+ case 1 : Descriptor->second.Infos["ChromaSubsampling"]=_T("4:2:2"); return;
+ case 2 : Descriptor->second.Infos["ChromaSubsampling"]=_T("4:2:0"); return;
+ default: Descriptor->second.Infos["ChromaSubsampling"].clear(); return;
+ }
+ case 4 : switch (Descriptor->second.SubSampling_Vertical)
+ {
+ case 1 : Descriptor->second.Infos["ChromaSubsampling"]=_T("4:1:1"); return;
+ default: Descriptor->second.Infos["ChromaSubsampling"].clear(); return;
+ }
+ default: return;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Locators_CleanUp()
+{
+ //Testing locators (TODO: check if this is still useful)
+ if (Locators.size()==1)
+ {
+ Locators.clear();
+ return;
+ }
+
+ locators::iterator Locator=Locators.begin();
+ while (Locator!=Locators.end())
+ {
+ bool IsReferenced=false;
+ for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ for (size_t Pos=0; Pos<Descriptor->second.Locators.size(); Pos++)
+ if (Locator->first==Descriptor->second.Locators[Pos])
+ IsReferenced=true;
+ if (!IsReferenced)
+ {
+ //Deleting current locator
+ locators::iterator LocatorToDelete=Locator;
+ Locator++;
+ Locators.erase(LocatorToDelete);
+ }
+ else
+ Locator++;
+ }
+
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::Locators_Test()
+{
+ Locators_CleanUp();
+
+ if (!Locators.empty() && ReferenceFiles==NULL)
+ {
+ ReferenceFiles=new File__ReferenceFilesHelper(this, Config);
+
+ for (locators::iterator Locator=Locators.begin(); Locator!=Locators.end(); Locator++)
+ if (!Locator->second.IsTextLocator && !Locator->second.EssenceLocator.empty() && Locator->second.StreamKind!=Stream_Max) //TODO: support VBI
+ {
+ File__ReferenceFilesHelper::reference ReferenceFile;
+ ReferenceFile.FileNames.push_back(Locator->second.EssenceLocator);
+ ReferenceFile.StreamKind=Locator->second.StreamKind;
+ ReferenceFile.StreamPos=Locator->second.StreamPos;
+ ReferenceFile.StreamID=Retrieve(Locator->second.StreamKind, Locator->second.StreamPos, General_ID).To_int64u();
+ ReferenceFile.Delay=float64_int64s(DTS_Delay*1000000000);
+ if (Locator->second.StreamKind==Stream_Video)
+ {
+ //Searching the corresponding frame rate
+ for (descriptors::iterator Descriptor=Descriptors.begin(); Descriptor!=Descriptors.end(); Descriptor++)
+ for (size_t LocatorPos=0; LocatorPos<Descriptor->second.Locators.size(); LocatorPos++)
+ if (Descriptor->second.Locators[LocatorPos]==Locator->first)
+ ReferenceFile.FrameRate=Descriptor->second.SampleRate;
+ }
+ ReferenceFiles->References.push_back(ReferenceFile);
+ }
+
+ ReferenceFiles->ParseReferences();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mxf::TryToFinish()
+{
+ if (!IsSub && IsParsingEnd && File_Size!=(int64u)-1 && Config_ParseSpeed<1 && IsParsingMiddle_MaxOffset==(int64u)-1 && File_Size/2>0x4000000) //TODO: 64 MB by default;
+ {
+ IsParsingMiddle_MaxOffset=File_Size/2+0x4000000; //TODO: 64 MB by default;
+ GoTo(File_Size/2);
+ Open_Buffer_Unsynch();
+ IsParsingEnd=false;
+ Streams_Count=(size_t)-1;
+ return;
+ }
+
+ Fill();
+ Open_Buffer_Unsynch();
+ Finish();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_MXF_*
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mxf.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mxf.h
new file mode 100644
index 000000000..14633b72c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Mxf.h
@@ -0,0 +1,800 @@
+// File_Mxf - Info for MXF files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Mxf files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_MxfH
+#define MediaInfo_File_MxfH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#if defined(MEDIAINFO_ANCILLARY_YES)
+ #include <MediaInfo/Multiple/File_Ancillary.h>
+#endif //defined(MEDIAINFO_ANCILLARY_YES)
+#include "MediaInfo/MediaInfo_Internal.h"
+#include <vector>
+#include <set>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class File__ReferenceFilesHelper;
+
+//***************************************************************************
+// Class File_Mxf
+//***************************************************************************
+
+class File_Mxf : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Mxf();
+ ~File_Mxf();
+
+ //int256u
+ class int256u
+ {
+ public:
+ // Binary correct representation of signed 256bit integer
+ int128u lo;
+ int128u hi;
+
+ int256u()
+ {
+ lo.lo=0;
+ lo.hi=0;
+ hi.lo=0;
+ hi.hi=0;
+ }
+ };
+
+
+protected :
+ //Streams management
+ void Streams_Fill ();
+ void Streams_Finish ();
+ void Streams_Finish_Preface (int128u PrefaceUID);
+ void Streams_Finish_ContentStorage (int128u ContentStorageUID);
+ void Streams_Finish_Package (int128u PackageUID);
+ void Streams_Finish_Track (int128u TrackUID);
+ void Streams_Finish_Essence (int32u EssenceUID, int128u TrackUID);
+ void Streams_Finish_Descriptor (int128u DescriptorUID, int128u PackageUID);
+ void Streams_Finish_Locator (int128u LocatorUID);
+ void Streams_Finish_Component (int128u ComponentUID, float64 EditRate);
+ void Streams_Finish_Identification (int128u IdentificationUID);
+ void Streams_Finish_CommercialNames ();
+
+ //Buffer - Global
+ void Read_Buffer_Init ();
+ void Read_Buffer_Continue ();
+ void Read_Buffer_AfterParsing ();
+ void Read_Buffer_Unsynched();
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+
+ //Buffer - Per element
+ bool Header_Begin();
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Filler();
+ void Filler01() {Filler();}
+ void Filler02() {Filler();}
+ void TerminatingFiller();
+ void XmlDocumentText();
+ void Sequence();
+ void SourceClip();
+ void TimecodeComponent();
+ void ContentStorage();
+ void EssenceContainerData();
+ void CDCIEssenceDescriptor();
+ void RGBAEssenceDescriptor();
+ void Preface();
+ void Identification();
+ void NetworkLocator();
+ void TextLocator();
+ void MaterialPackage();
+ void SourcePackage();
+ void EventTrack();
+ void StaticTrack();
+ void Track();
+ void DMSegment();
+ void GenericSoundEssenceDescriptor();
+ void MultipleDescriptor();
+ void AES3PCMDescriptor();
+ void WaveAudioDescriptor();
+ void MPEG2VideoDescriptor();
+ void JPEG2000PictureSubDescriptor();
+ void Unknown1();
+ void AncPacketsDescriptor();
+ void OpenIncompleteHeaderPartition();
+ void ClosedIncompleteHeaderPartition();
+ void OpenCompleteHeaderPartition();
+ void ClosedCompleteHeaderPartition();
+ void OpenIncompleteBodyPartition();
+ void ClosedIncompleteBodyPartition();
+ void OpenCompleteBodyPartition();
+ void ClosedCompleteBodyPartition();
+ void OpenIncompleteFooterPartition();
+ void ClosedIncompleteFooterPartition();
+ void OpenCompleteFooterPartition();
+ void ClosedCompleteFooterPartition();
+ void Primer();
+ void IndexTableSegment();
+ void RandomIndexMetadata();
+ void SDTI_SystemMetadataPack();
+ void SDTI_PackageMetadataSet();
+ void SDTI_PictureMetadataSet();
+ void SDTI_SoundMetadataSet();
+ void SDTI_DataMetadataSet();
+ void SDTI_ControlMetadataSet();
+ void SystemScheme1();
+ void Omneon_010201010100();
+ void Omneon_010201020100();
+
+ //Common
+ void GenerationInterchangeObject();
+ void InterchangeObject();
+ void GenericPictureEssenceDescriptor();
+ void PartitionMetadata();
+ void GenericTrack();
+ void GenericPackage();
+ void FileDescriptor();
+ void StructuralComponent();
+ void GenericDescriptor();
+
+ //Complex types
+ void AES3PCMDescriptor_AuxBitsMode(); //3D08
+ void AES3PCMDescriptor_Emphasis(); //3D0D
+ void AES3PCMDescriptor_BlockStartOffset(); //3D0F
+ void AES3PCMDescriptor_ChannelStatusMode(); //3D10
+ void AES3PCMDescriptor_FixedChannelStatusData(); //3D11
+ void AES3PCMDescriptor_UserDataMode(); //3D12
+ void AES3PCMDescriptor_FixedUserData(); //3D13
+ void CDCIEssenceDescriptor_ComponentDepth(); //3301
+ void CDCIEssenceDescriptor_HorizontalSubsampling(); //3302
+ void CDCIEssenceDescriptor_ColorSiting(); //3303
+ void CDCIEssenceDescriptor_BlackRefLevel(); //3304
+ void CDCIEssenceDescriptor_WhiteReflevel(); //3305
+ void CDCIEssenceDescriptor_ColorRange(); //3306
+ void CDCIEssenceDescriptor_PaddingBits(); //3307
+ void CDCIEssenceDescriptor_VerticalSubsampling(); //3308
+ void CDCIEssenceDescriptor_AlphaSampleDepth(); //3309
+ void CDCIEssenceDescriptor_ReversedByteOrder(); //330B
+ void ContentStorage_Packages(); //1901
+ void ContentStorage_EssenceContainerData(); //1902
+ void DMSegment_DMFramework(); //6101
+ void EssenceContainerData_LinkedPackageUID(); //2701
+ void EssenceContainerData_IndexSID(); //3F06
+ void EssenceContainerData_BodySID(); //3F07
+ void EventTrack_EventEditRate(); //4901
+ void EventTrack_EventOrigin(); //4902
+ void FileDescriptor_SampleRate(); //3001
+ void FileDescriptor_ContainerDuration(); //3002
+ void FileDescriptor_EssenceContainer(); //3004
+ void FileDescriptor_Codec(); //3005
+ void FileDescriptor_LinkedTrackID(); //3006
+ void InterchangeObject_InstanceUID(); //3C0A
+ void GenerationInterchangeObject_GenerationUID(); //0102
+ void GenericDescriptor_Locators(); //2F01
+ void GenericPackage_PackageUID(); //4401
+ void GenericPackage_Name(); //4402
+ void GenericPackage_Tracks(); //4403
+ void GenericPackage_PackageModifiedDate(); //4404
+ void GenericPackage_PackageCreationDate(); //4405
+ void GenericPictureEssenceDescriptor_PictureEssenceCoding();//3201
+ void GenericPictureEssenceDescriptor_StoredHeight(); //3202
+ void GenericPictureEssenceDescriptor_StoredWidth(); //3203
+ void GenericPictureEssenceDescriptor_SampledHeight(); //3204
+ void GenericPictureEssenceDescriptor_SampledWidth(); //3205
+ void GenericPictureEssenceDescriptor_SampledXOffset(); //3206
+ void GenericPictureEssenceDescriptor_SampledYOffset(); //3207
+ void GenericPictureEssenceDescriptor_DisplayHeight(); //3208
+ void GenericPictureEssenceDescriptor_DisplayWidth(); //3209
+ void GenericPictureEssenceDescriptor_DisplayXOffset(); //320A
+ void GenericPictureEssenceDescriptor_DisplayYOffset(); //320B
+ void GenericPictureEssenceDescriptor_FrameLayout(); //320C
+ void GenericPictureEssenceDescriptor_VideoLineMap(); //320D
+ void GenericPictureEssenceDescriptor_AspectRatio(); //320E
+ void GenericPictureEssenceDescriptor_AlphaTransparency(); //320F
+ void GenericPictureEssenceDescriptor_Gamma(); //3210
+ void GenericPictureEssenceDescriptor_ImageAlignmentOffset();//3211
+ void GenericPictureEssenceDescriptor_FieldDominance(); //3212
+ void GenericPictureEssenceDescriptor_ImageStartOffset(); //3213
+ void GenericPictureEssenceDescriptor_ImageEndOffset(); //3214
+ void GenericPictureEssenceDescriptor_SignalStandard(); //3215
+ void GenericPictureEssenceDescriptor_StoredF2Offset(); //3216
+ void GenericPictureEssenceDescriptor_DisplayF2Offset(); //3217
+ void GenericPictureEssenceDescriptor_ActiveFormatDescriptor();//3218
+ void GenericSoundEssenceDescriptor_QuantizationBits(); //3D01
+ void GenericSoundEssenceDescriptor_Locked(); //3D02
+ void GenericSoundEssenceDescriptor_AudioSamplingRate(); //3D03
+ void GenericSoundEssenceDescriptor_AudioRefLevel(); //3D04
+ void GenericSoundEssenceDescriptor_ElectroSpatialFormulation(); //3D05
+ void GenericSoundEssenceDescriptor_SoundEssenceCompression(); //3D06
+ void GenericSoundEssenceDescriptor_ChannelCount(); //3D07
+ void GenericSoundEssenceDescriptor_DialNorm(); //3D0C
+ void GenericTrack_TrackID(); //4801
+ void GenericTrack_TrackName(); //4802
+ void GenericTrack_Sequence(); //4803
+ void GenericTrack_TrackNumber(); //4804
+ void Identification_CompanyName(); //3C01
+ void Identification_ProductName(); //3C02
+ void Identification_ProductVersion(); //3C03
+ void Identification_VersionString(); //3C04
+ void Identification_ProductUID(); //3C05
+ void Identification_ModificationDate(); //3C06
+ void Identification_ToolkitVersion(); //3C07
+ void Identification_Platform(); //3C08
+ void Identification_ThisGenerationUID(); //3C09
+ void IndexTableSegment_EditUnitByteCount(); //3F05
+ void IndexTableSegment_IndexSID(); //3F06
+ void IndexTableSegment_BodySID(); //3F07
+ void IndexTableSegment_SliceCount(); //3F08
+ void IndexTableSegment_DeltaEntryArray(); //3F09
+ void IndexTableSegment_IndexEntryArray(); //3F0A
+ void IndexTableSegment_IndexEditRate(); //3F0B
+ void IndexTableSegment_IndexStartPosition(); //3F0C
+ void IndexTableSegment_IndexDuration(); //3F0D
+ void IndexTableSegment_PosTableCount(); //3F0E
+ void IndexTableSegment_8002(); //8002
+ void JPEG2000PictureSubDescriptor_Rsiz(); //8001
+ void JPEG2000PictureSubDescriptor_Xsiz(); //8002
+ void JPEG2000PictureSubDescriptor_Ysiz(); //8003
+ void JPEG2000PictureSubDescriptor_XOsiz(); //8004
+ void JPEG2000PictureSubDescriptor_YOsiz(); //8005
+ void JPEG2000PictureSubDescriptor_XTsiz(); //8006
+ void JPEG2000PictureSubDescriptor_YTsiz(); //8007
+ void JPEG2000PictureSubDescriptor_XTOsiz(); //8008
+ void JPEG2000PictureSubDescriptor_YTOsiz(); //8009
+ void JPEG2000PictureSubDescriptor_Csiz(); //800A
+ void JPEG2000PictureSubDescriptor_PictureComponentSizing(); //800B
+ void MultipleDescriptor_SubDescriptorUIDs(); //3F01
+ void MPEG2VideoDescriptor_SingleSequence(); //
+ void MPEG2VideoDescriptor_ConstantBFrames(); //
+ void MPEG2VideoDescriptor_CodedContentType(); //
+ void MPEG2VideoDescriptor_LowDelay(); //
+ void MPEG2VideoDescriptor_ClosedGOP(); //
+ void MPEG2VideoDescriptor_IdenticalGOP(); //
+ void MPEG2VideoDescriptor_MaxGOP(); //
+ void MPEG2VideoDescriptor_BPictureCount(); //
+ void MPEG2VideoDescriptor_ProfileAndLevel(); //
+ void MPEG2VideoDescriptor_BitRate(); //
+ void NetworkLocator_URLString(); //4001
+ void Preface_LastModifiedDate(); //3B02
+ void Preface_ContentStorage(); //3B03
+ void Preface_Version(); //3B05
+ void Preface_Identifications(); //3B06
+ void Preface_ObjectModelVersion(); //3B07
+ void Preface_PrimaryPackage(); //3B08
+ void Preface_OperationalPattern(); //3B09
+ void Preface_EssenceContainers(); //3B0A
+ void Preface_DMSchemes(); //3B0B
+ void RGBAEssenceDescriptor_PixelLayout(); //3401
+ void RGBAEssenceDescriptor_Palette(); //3403
+ void RGBAEssenceDescriptor_PaletteLayout(); //3404
+ void RGBAEssenceDescriptor_ScanningDirection(); //3405
+ void RGBAEssenceDescriptor_ComponentMaxRef(); //3406
+ void RGBAEssenceDescriptor_ComponentMinRef(); //3407
+ void RGBAEssenceDescriptor_AlphaMaxRef(); //3408
+ void RGBAEssenceDescriptor_AlphaMinRef(); //3409
+ void Sequence_StructuralComponents(); //1001
+ void SourceClip_SourcePackageID(); //1101
+ void SourceClip_SourceTrackID(); //1102
+ void SourceClip_StartPosition(); //1201
+ void SourcePackage_Descriptor(); //4701
+ void StructuralComponent_DataDefinition(); //0201
+ void StructuralComponent_Duration(); //0202
+ void SystemScheme1_TimeCodeArray(); //0102
+ void TextLocator_LocatorName(); //4101
+ void TimecodeComponent_StartTimecode(); //1501
+ void TimecodeComponent_RoundedTimecodeBase(); //1502
+ void TimecodeComponent_DropFrame(); //1503
+ void Track_EditRate(); //4B01
+ void Track_Origin(); //4B02
+ void WaveAudioDescriptor_AvgBps(); //3D09
+ void WaveAudioDescriptor_BlockAlign(); //3D0A
+ void WaveAudioDescriptor_SequenceOffset(); //3D0B
+ void WaveAudioDescriptor_PeakEnvelopeVersion(); //3D29
+ void WaveAudioDescriptor_PeakEnvelopeFormat(); //3D2A
+ void WaveAudioDescriptor_PointsPerPeakValue(); //3D2B
+ void WaveAudioDescriptor_PeakEnvelopeBlockSize(); //3D2C
+ void WaveAudioDescriptor_PeakChannels(); //3D2D
+ void WaveAudioDescriptor_PeakFrames(); //3D2E
+ void WaveAudioDescriptor_PeakOfPeaksPosition(); //3D2F
+ void WaveAudioDescriptor_PeakEnvelopeTimestamp(); //3D30
+ void WaveAudioDescriptor_PeakEnvelopeData(); //3D31
+ void WaveAudioDescriptor_ChannelAssignment(); //3D31
+ void Omneon_010201010100_8001(); //8001
+ void Omneon_010201010100_8003(); //8003
+ void Omneon_010201020100_8002(); //8002
+ void Omneon_010201020100_8003(); //8003
+ void Omneon_010201020100_8004(); //8004
+ void Omneon_010201020100_8005(); //8005
+ void Omneon_010201020100_8006(); //8006
+
+ //Basic types
+ void Get_Rational(float64 &Value);
+ void Skip_Rational();
+ void Info_Rational();
+ void Get_Timestamp (Ztring &Value);
+ void Skip_Timestamp();
+ void Info_Timestamp();
+ void Get_UMID (int256u &Value, const char* Name);
+ void Skip_UMID ();
+
+ void Get_UL (int128u &Value, const char* Name, const char* (*Param) (int128u));
+ void Skip_UL(const char* Name);
+ void Get_BER(int64u &Value, const char* Name);
+ #if MEDIAINFO_TRACE
+ void Info_UL_01xx01_Items ();
+ void Info_UL_02xx01_Groups ();
+ void Info_UL_040101_Values ();
+ #define Info_UL(_INFO, _NAME, _PARAM) int128u _INFO; Get_UL(_INFO, _NAME, _PARAM)
+ #else //MEDIAINFO_TRACE
+ void Info_UL_01xx01_Items () {Element_Offset+=8;};
+ void Info_UL_02xx01_Groups () {Element_Offset+=8;};
+ void Info_UL_040101_Values () {Element_Offset+=8;};
+ #define Info_UL(_INFO, _NAME, _PARAM) int128u _INFO;
+ #endif //MEDIAINFO_TRACE
+
+ struct randomindexmetadata
+ {
+ int64u ByteOffset;
+ int32u BodySID;
+ };
+ std::vector<randomindexmetadata> RandomIndexMetadatas;
+ bool RandomIndexMetadatas_AlreadyParsed;
+ std::set<int64u> PartitionPack_AlreadyParsed;
+ size_t Streams_Count;
+ int128u Code;
+ int128u OperationalPattern;
+ int128u InstanceUID;
+ int64u Buffer_Begin;
+ int64u Buffer_End;
+ int64u Buffer_Header_Size;
+ int16u Code2;
+ int16u Length2;
+ int64u File_Size_Total; //Used only in Finish()
+ int64u IsParsingMiddle_MaxOffset;
+ bool Track_Number_IsAvailable;
+ bool IsParsingEnd;
+ bool IsCheckingRandomAccessTable;
+ bool IsCheckingFooterPartitionAddress;
+ bool FooterPartitionAddress_Jumped;
+ bool PartitionPack_Parsed;
+ size_t IdIsAlwaysSame_Offset;
+
+ //Primer
+ std::map<int16u, int128u> Primer_Values;
+
+ //Preface
+ struct preface
+ {
+ int128u PrimaryPackage;
+ std::vector<int128u> Identifications;
+ int128u ContentStorage;
+
+ preface()
+ {
+ PrimaryPackage.hi=(int64u)-1;
+ PrimaryPackage.lo=(int64u)-1;
+ ContentStorage.hi=(int64u)-1;
+ ContentStorage.lo=(int64u)-1;
+ }
+ };
+ typedef std::map<int128u, preface> prefaces; //Key is InstanceUID of preface
+ prefaces Prefaces;
+ int128u Preface_Current;
+
+ //Identification
+ struct identification
+ {
+ Ztring CompanyName;
+ Ztring ProductName;
+ Ztring ProductVersion;
+ Ztring VersionString;
+ std::map<std::string, Ztring> Infos;
+ };
+ typedef std::map<int128u, identification> identifications; //Key is InstanceUID of identification
+ identifications Identifications;
+
+ //ContentStorage
+ struct contentstorage
+ {
+ std::vector<int128u> Packages;
+ };
+ typedef std::map<int128u, contentstorage> contentstorages; //Key is InstanceUID of ContentStorage
+ contentstorages ContentStorages;
+
+ //Package
+ struct package
+ {
+ int256u PackageUID;
+ int128u Descriptor;
+ std::vector<int128u> Tracks;
+ bool IsSourcePackage;
+
+ package()
+ {
+ Descriptor=0;
+ IsSourcePackage=false;
+ }
+ };
+ typedef std::map<int128u, package> packages; //Key is InstanceUID of package
+ packages Packages;
+
+ //Track
+ struct track
+ {
+ int128u Sequence;
+ int32u TrackID;
+ Ztring TrackName;
+ int32u TrackNumber;
+ float64 EditRate;
+ bool Stream_Finish_Done;
+
+ track()
+ {
+ Sequence=0;
+ TrackID=(int32u)-1;
+ TrackNumber=(int32u)-1;
+ EditRate=(float64)0;
+ Stream_Finish_Done=false;
+ }
+ };
+ typedef std::map<int128u, track> tracks; //Key is InstanceUID of the track
+ tracks Tracks;
+
+ //Essence
+ struct essence
+ {
+ stream_t StreamKind;
+ size_t StreamPos;
+ size_t StreamPos_Initial;
+ File__Analyze* Parser;
+ std::map<std::string, Ztring> Infos;
+ int64u Stream_Size;
+ int32u TrackID;
+ bool TrackID_WasLookedFor;
+ bool Stream_Finish_Done;
+ bool Track_Number_IsMappedToTrack; //if !Track_Number_IsAvailable, is true when it was euristicly mapped
+ bool IsFilled;
+ bool IsChannelGrouping;
+ int64u Frame_Count_NotParsedIncluded;
+ frame_info FrameInfo;
+
+ essence()
+ {
+ StreamKind=Stream_Max;
+ StreamPos=(size_t)-1;
+ StreamPos_Initial=(size_t)-1;
+ Parser=NULL;
+ Stream_Size=(int64u)-1;
+ TrackID=(int32u)-1;
+ TrackID_WasLookedFor=false;
+ Stream_Finish_Done=false;
+ Track_Number_IsMappedToTrack=false;
+ IsFilled=false;
+ IsChannelGrouping=false;
+ Frame_Count_NotParsedIncluded=(int64u)-1;
+ FrameInfo.DTS=(int64u)-1;
+ }
+
+ ~essence()
+ {
+ delete Parser; //Parser=NULL;
+ }
+ };
+ typedef std::map<int32u, essence> essences; //Key is TrackNumber
+ essences Essences;
+
+ //Descriptor
+ struct descriptor
+ {
+ std::vector<int128u> SubDescriptors;
+ std::vector<int128u> Locators;
+
+ stream_t StreamKind;
+ size_t StreamPos;
+ float64 SampleRate;
+ float64 DisplayAspectRatio;
+ int128u InstanceUID;
+ int128u EssenceContainer;
+ int128u EssenceCompression;
+ int32u LinkedTrackID;
+ int32u Width;
+ int32u Width_Display;
+ int32u Width_Display_Offset;
+ int32u Height;
+ int32u Height_Display;
+ int32u Height_Display_Offset;
+ int32u SubSampling_Horizontal;
+ int32u SubSampling_Vertical;
+ int32u ChannelCount;
+ std::map<std::string, Ztring> Infos;
+ int16u BlockAlign;
+ int32u QuantizationBits;
+ int64u Duration;
+ int8u ActiveFormat;
+ enum type
+ {
+ Type_Unknown,
+ Type_CDCI,
+ Type_RGBA,
+ Type_MPEG2Video,
+ Type_WaveAudio,
+ Type_AES3PCM,
+ Type_JPEG2000Picture,
+ Type_AncPackets,
+ };
+ type Type;
+ bool HasBFrames;
+ int32u ByteRate;
+
+ descriptor()
+ {
+ StreamKind=Stream_Max;
+ StreamPos=(size_t)-1;
+ SampleRate=0;
+ DisplayAspectRatio=0;
+ InstanceUID.hi=(int64u)-1;
+ InstanceUID.lo=(int64u)-1;
+ EssenceContainer.hi=(int64u)-1;
+ EssenceContainer.lo=(int64u)-1;
+ EssenceCompression.hi=(int64u)-1;
+ EssenceCompression.lo=(int64u)-1;
+ LinkedTrackID=(int32u)-1;
+ Width=(int32u)-1;
+ Width_Display=(int32u)-1;
+ Width_Display_Offset=(int32u)-1;
+ Height=(int32u)-1;
+ Height_Display=(int32u)-1;
+ Height_Display_Offset=(int32u)-1;
+ SubSampling_Horizontal=(int32u)-1;
+ SubSampling_Vertical=(int32u)-1;
+ ChannelCount=(int32u)-1;
+ BlockAlign=(int16u)-1;
+ QuantizationBits=(int8u)-1;
+ Duration=(int64u)-1;
+ ActiveFormat=(int8u)-1;
+ Type=Type_Unknown;
+ HasBFrames=false;
+ ByteRate=(int32u)-1;
+ }
+ };
+ typedef std::map<int128u, descriptor> descriptors; //Key is InstanceUID of Descriptor
+ descriptors Descriptors;
+
+ //Locator
+ struct locator
+ {
+ Ztring EssenceLocator;
+ stream_t StreamKind;
+ size_t StreamPos;
+ bool IsTextLocator;
+
+ locator()
+ {
+ StreamKind=Stream_Max;
+ StreamPos=(size_t)-1;
+ IsTextLocator=false;
+ }
+
+ ~locator()
+ {
+ }
+ };
+ typedef std::map<int128u, locator> locators; //Key is InstanceUID of the locator
+ locators Locators;
+ File__ReferenceFilesHelper* ReferenceFiles;
+ #if MEDIAINFO_NEXTPACKET
+ bool ReferenceFiles_IsParsing;
+ #endif //MEDIAINFO_NEXTPACKET
+
+ //Component (Sequence, TimeCode, Source Clip)
+ struct component
+ {
+ int64u Duration;
+ int256u SourcePackageID; //Sequence from SourcePackage only
+ int32u SourceTrackID;
+ std::vector<int128u> StructuralComponents; //Sequence from MaterialPackage only
+
+ component()
+ {
+ Duration=(int64u)-1;
+ SourceTrackID=(int32u)-1;
+ }
+
+ void Update (struct component &New)
+ {
+ if (New.Duration!=(int64u)-1)
+ Duration=New.Duration;
+ if (New.SourcePackageID.hi || New.SourcePackageID.lo)
+ SourcePackageID=New.SourcePackageID;
+ if (New.SourceTrackID!=(int32u)-1)
+ SourceTrackID=New.SourceTrackID;
+ if (!New.StructuralComponents.empty())
+ StructuralComponents=New.StructuralComponents;
+ }
+ };
+ typedef std::map<int128u, component> components; //Key is InstanceUID of the component
+ components Components;
+
+ //Parsers
+ void ChooseParser__FromEssence(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ void ChooseParser__Aaf(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ void ChooseParser__Aaf_CP_Picture(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ void ChooseParser__Aaf_CP_Sound(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ void ChooseParser__Aaf_CP_Data(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ void ChooseParser__Aaf_14(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ void ChooseParser__Aaf_GC_Picture(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ void ChooseParser__Aaf_GC_Sound(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ void ChooseParser__Aaf_GC_Data(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ void ChooseParser__Aaf_GC_Compound(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ void ChooseParser__Avid(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ void ChooseParser__Avid_Picture(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser__FromEssenceContainer(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Avc(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_DV(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Mpeg4v(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Mpegv(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Raw(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_RV24(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Vc3(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Aac(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Ac3(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Aes3(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Alaw(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_ChannelGrouping(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Mpega(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Pcm(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+ File__Analyze* ChooseParser_Jpeg2000(const essences::iterator &Essence, const descriptors::iterator &Descriptor);
+
+ //Helpers
+ void Subsampling_Compute(descriptors::iterator Descriptor);
+ void Locators_CleanUp();
+ void Locators_Test();
+ void TryToFinish();
+
+ //Temp
+ int128u EssenceContainer_FromPartitionMetadata;
+ int64u PartitionMetadata_PreviousPartition;
+ int64u PartitionMetadata_FooterPartition;
+ int64u TimeCode_StartTimecode;
+ int16u TimeCode_RoundedTimecodeBase;
+ bool TimeCode_DropFrame;
+ float64 DTS_Delay; //In seconds
+ bool StreamPos_StartAtOne; //information about the base of StreamPos (0 or 1, 1 is found in 1 file)
+ int64u SDTI_TimeCode_StartTimecode;
+ int64u SDTI_SizePerFrame;
+ bool SDTI_IsPresent; //Used to test if SDTI packet is used for Index StreamOffset calculation
+ bool SDTI_IsInIndexStreamOffset; //Used to test if SDTI packet is used for Index StreamOffset calculation
+ int64u SystemScheme1_TimeCodeArray_StartTimecode;
+ int64u SystemScheme1_FrameRateFromDescriptor;
+ bool Essences_FirstEssence_Parsed;
+ int32u IndexTable_NSL;
+ int32u IndexTable_NPE;
+ #if defined(MEDIAINFO_ANCILLARY_YES)
+ File_Ancillary* Ancillary;
+ bool Ancillary_IsBinded;
+ #endif //defined(MEDIAINFO_ANCILLARY_YES)
+
+ //Hints
+ size_t* File_Buffer_Size_Hint_Pointer;
+
+ //Partitions
+ struct partition
+ {
+ int64u StreamOffset; //From file, not MXF one
+ int64u PartitionPackByteCount; //Fill included
+ int64u FooterPartition;
+ int64u HeaderByteCount;
+ int64u IndexByteCount;
+ int64u BodyOffset;
+
+ partition()
+ {
+ StreamOffset=0;
+ PartitionPackByteCount=(int64u)-1;
+ FooterPartition=0;
+ HeaderByteCount=0;
+ IndexByteCount=0;
+ BodyOffset=0;
+ }
+
+ bool operator < (const partition& lhs) const
+ {
+ return StreamOffset<lhs.StreamOffset;
+ }
+ };
+ typedef std::vector<partition> partitions;
+ partitions Partitions;
+ size_t Partitions_Pos;
+ bool Partitions_IsCalculatingHeaderByteCount;
+ bool Partitions_IsCalculatingSdtiByteCount;
+ bool Partitions_IsFooter;
+
+ #if MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+ bool Demux_HeaderParsed;
+ bool Demux_Interleave;
+ size_t CountOfLocatorsToParse;
+ float64 Demux_Rate;
+
+ //IndexTable
+ struct indextable
+ {
+ int64u StreamOffset; //From file, not MXF one
+ int64u IndexStartPosition;
+ int64u IndexDuration;
+ int32u EditUnitByteCount;
+ float64 IndexEditRate;
+ struct entry
+ {
+ int64u StreamOffset;
+ int8u Type;
+ };
+ std::vector<entry> Entries;
+
+ indextable()
+ {
+ StreamOffset=(int64u)-1;
+ IndexStartPosition=0;
+ IndexDuration=0;
+ EditUnitByteCount=0;
+ IndexEditRate=0;
+ }
+
+ bool operator < (const indextable& lhs) const
+ {
+ return IndexStartPosition<lhs.IndexStartPosition;
+ }
+ };
+ typedef std::vector<indextable> indextables;
+ indextables IndexTables;
+ size_t IndexTables_Pos;
+
+ //Other
+ int64u Clip_Header_Size;
+ int64u Clip_Begin;
+ int64u Clip_End;
+ int128u Clip_Code;
+ int64u OverallBitrate_IsCbrForSure;
+ bool Duration_Detected;
+ #endif //MEDIAINFO_DEMUX || MEDIAINFO_SEEK
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Nut.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Nut.cpp
new file mode 100644
index 000000000..20a2f1d51
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Nut.cpp
@@ -0,0 +1,300 @@
+// File_Nut - Info for Nut files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Source: http://svn.mplayerhq.hu/nut/docs/nut.txt?view=markup
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_NUT_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Nut.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Const
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+namespace Elements
+{
+ const int64u main =0x4E4D7A561F5F04ADLL;
+ const int64u stream =0x4E5311405BF2F9DBLL;
+ const int64u syncpoint =0x4E4BE4ADEECA4569LL;
+ const int64u index =0x4E58DD672F23E64ELL;
+ const int64u info =0x4E49AB68B596BA78LL;
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Nut::Header_Parse()
+{
+ /*
+ //Parsing
+ int8u N;
+ Peek_B1(N);
+ if (N==0x4E) //'N'
+ {
+ //Header
+ int64u startcode, forward_ptr;
+ Get_B8(startcode, "startcode");
+ Get_VS(forward_ptr, "forward_ptr");
+ if (forward_ptr>4096)
+ Skip_B4( "header_checksum");
+
+ Header_Fill_Code(startcode, Ztring().From_Number(startcode, 16)); //Quick filling for CC8 with text
+ Header_Fill_Size(Element_Offset+forward_ptr); //4 for cheksum
+
+ }
+ else
+ {
+ //Frame
+ Header_Fill_Code(0, "Frame");
+ Header_Fill_Size(0);
+ Finished();
+ }
+ */
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Nut::FileHeader_Parse()
+{
+ //Parsing
+ Element_Begin1("Nut header");
+ std::string file_id_string;
+ Get_String(25, file_id_string, "file_id_string");
+ Element_End0();
+
+ FILLING_BEGIN();
+ //Integrity
+ if (file_id_string!="nut/multimedia container")
+ {
+ Reject("Nut");
+ return;
+ }
+
+ //Filling
+ Accept("Nut");
+
+ Fill(Stream_General, 0, General_Format, "Nut");
+
+ Finish("Nut");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Nut::Data_Parse()
+{
+}
+
+/*
+//---------------------------------------------------------------------------
+void File_Nut::Data_Parse()
+{
+ #define ELEMENT_CASE(_NAME) \
+ case Elements::_NAME : _NAME(); break;
+
+ //Parsing
+ #ifndef __BORLANDC__
+ switch (Element_Code)
+ #else //__BORLANDC__
+ switch (Element_Code&0xFFFFFFFF) //Borland does not like int64u for const?
+ #endif //__BORLANDC__
+ {
+ ELEMENT_CASE(main);
+ ELEMENT_CASE(stream);
+ ELEMENT_CASE(syncpoint);
+ ELEMENT_CASE(index);
+ ELEMENT_CASE(info);
+ default : Skip_XX(Element_Size-4, "Data");
+ }
+
+ Skip_B4( "cheksum");
+}
+*/
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+/*
+//---------------------------------------------------------------------------
+void File_Nut::main()
+{
+ Element_Name("main");
+
+ //Parsing
+ int64u time_base_count;
+ Skip_VS( "version");
+ Skip_VS( "stream_count");
+ Skip_VS( "max_distance");
+ Get_VS (time_base_count, "time_base_count");
+ for(int64u i=0; i<time_base_count; i++)
+ {
+ Skip_VS( "time_base_num");
+ Skip_VS( "time_base_denom");
+ //time_base[i]= time_base_num/time_base_denom
+ }
+ int64u tmp_mul=1, tmp_stream=0;
+ int64s tmp_pts=0;
+ for(int16u i=0; i<256;)
+ {
+ int64u tmp_fields, tmp_size, tmp_res, count;
+ Skip_VS( "tmp_flag");
+ Get_VS (tmp_fields, "tmp_fields");
+ if(tmp_fields>0)
+ Skip_SL( "tmp_pts");
+ if(tmp_fields>1)
+ Skip_VS( "tmp_mul");
+ if(tmp_fields>2)
+ Skip_VS( "tmp_stream");
+ if(tmp_fields>3)
+ Get_VS (tmp_size, "tmp_size");
+ else
+ tmp_size=0;
+ if(tmp_fields>4)
+ Get_VS (tmp_res, "tmp_res");
+ else
+ tmp_res=0;
+ if(tmp_fields>5)
+ Skip_VS( "count");
+ else
+ count=tmp_mul-tmp_size;
+ for(int64u j=6; j<tmp_fields; j++)
+ Skip_VS( "tmp_reserved[i]");
+
+ for(int64u j=0; j<count && i<256; j++, i++)
+ {
+ if (i == 'N')
+ {
+ //flags[i]= FLAG_INVALID;
+ j--;
+ continue;
+ }
+ //flags[i]= tmp_flag;
+ //stream_id[i]= tmp_stream;
+ //data_size_mul[i]= tmp_mul;
+ //data_size_lsb[i]= tmp_size + j;
+ //pts_delta[i]= tmp_pts;
+ //reserved_count[i]= tmp_res;
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Nut::stream()
+{
+ Element_Name("stream");
+
+ //Parsing
+ int64u stream_class, fourcc_length, codec_specific_data_length;
+ Skip_VS( "stream_id");
+ Get_VS (stream_class, "stream_class");
+ Get_VS (fourcc_length, "fourcc length");
+ switch (fourcc_length)
+ {
+ case 2 : Skip_C2( "fourcc"); break;
+ case 4 : Skip_C4( "fourcc"); break;
+ default: Skip_XX(fourcc_length, "fourcc");
+ }
+ Skip_VS( "time_base_id");
+ Skip_VS( "msb_pts_shift");
+ Skip_VS( "max_pts_distance");
+ Skip_VS( "decode_delay");
+ Skip_VS( "stream_flags");
+ Get_VS (codec_specific_data_length, "codec_specific_data length");
+ Skip_XX(codec_specific_data_length, "codec_specific_data");
+ switch (stream_class)
+ {
+ case 0 : //video
+ {
+ Skip_VS( "width");
+ Skip_VS( "height");
+ Skip_VS( "sample_width");
+ Skip_VS( "sample_height");
+ Skip_VS( "colorspace_type");
+ }
+ break;
+ case 1 : //audio
+ {
+ Skip_VS( "samplerate_num");
+ Skip_VS( "samplerate_denom");
+ Skip_VS( "channel_count");
+ }
+ break;
+ case 2 : //subtitles
+ {
+ }
+ break;
+ case 3 : //userdata
+ {
+ }
+ break;
+ default: ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Nut::syncpoint()
+{
+ Element_Name("syncpoint");
+}
+
+//---------------------------------------------------------------------------
+void File_Nut::index()
+{
+ Element_Name("index");
+}
+
+//---------------------------------------------------------------------------
+void File_Nut::info()
+{
+ Element_Name("info");
+}
+
+*/
+
+}
+
+#endif //MEDIAINFO_NUT_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Nut.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Nut.h
new file mode 100644
index 000000000..c55213273
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Nut.h
@@ -0,0 +1,59 @@
+// File_Nut - Info for Nut files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Nut files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_NutH
+#define MediaInfo_File_NutH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Nut
+//***************************************************************************
+
+class File_Nut : public File__Analyze
+{
+private :
+ //Buffer
+ void Header_Parse();
+ void FileHeader_Parse();
+ void Data_Parse();
+
+ //Elements
+ void main();
+ void stream();
+ void syncpoint();
+ void index();
+ void info();
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg.cpp
new file mode 100644
index 000000000..737016eae
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg.cpp
@@ -0,0 +1,406 @@
+// File_Ogg - Info for ogg files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_OGG_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Ogg.h"
+#include "MediaInfo/Multiple/File_Ogg_SubElement.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Ogg::File_Ogg()
+:File__Analyze()
+{
+ //Configuration
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+
+ //In
+ SizedBlocks=false;
+ XiphLacing=false;
+
+ //Temp - Global
+ StreamsToDo=0;
+ Parsing_End=false;
+
+ //Temp - Stream
+ Chunk_Sizes_Finished=true;
+ packet_type=0;
+ continued=false;
+ eos=false;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ogg::Streams_Fill()
+{
+ std::map<int64u, stream>::iterator Stream_Temp=Stream.begin();
+ while (Stream_Temp!=Stream.end())
+ {
+ //Filling
+ if (Stream_Temp->second.Parser)
+ {
+ Stream_Temp->second.Parser->Fill();
+ Merge(*Stream_Temp->second.Parser);
+ Merge(*Stream_Temp->second.Parser, Stream_General, 0, 0);
+ Stream_Temp->second.StreamKind=((File_Ogg_SubElement*)Stream_Temp->second.Parser)->StreamKind;
+ Stream_Temp->second.StreamPos=Count_Get(Stream_Temp->second.StreamKind)-1;
+ if (!SizedBlocks && !XiphLacing)
+ Stream_Temp->second.absolute_granule_position_Resolution=((File_Ogg_SubElement*)Stream_Temp->second.Parser)->absolute_granule_position_Resolution;
+ if (Stream_Temp->second.StreamKind==Stream_Audio && Stream_Temp->second.absolute_granule_position_Resolution==0)
+ Stream_Temp->second.absolute_granule_position_Resolution=Retrieve(Stream_Audio, Stream_Temp->second.StreamPos, Audio_SamplingRate).To_int64u();
+ if (!IsSub && Stream_Temp->second.absolute_granule_position && Stream_Temp->second.absolute_granule_position_Resolution)
+ {
+ if (Stream_Temp->second.StreamKind==Stream_Audio)
+ Fill(Stream_Temp->second.StreamKind, Stream_Temp->second.StreamPos, Fill_Parameter(Stream_Temp->second.StreamKind, Generic_Duration), float64_int64s(((float64)(Stream_Temp->second.absolute_granule_position))*1000/Stream_Temp->second.absolute_granule_position_Resolution), 10, true);
+ }
+ if (!IsSub)
+ {
+ if (Stream_Temp->second.StreamKind==Stream_Max)
+ {
+ Stream_Temp->second.StreamKind=Stream_General;
+ Stream_Temp->second.StreamPos=0;
+ }
+ Fill(Stream_Temp->second.StreamKind, Stream_Temp->second.StreamPos, General_ID, Stream_Temp->first);
+ Fill(Stream_Temp->second.StreamKind, Stream_Temp->second.StreamPos, General_ID_String, Ztring::ToZtring(Stream_Temp->first)+_T(" (0x")+Ztring::ToZtring(Stream_Temp->first, 16)+_T(')'), true);
+ }
+ }
+ Stream_Temp++;
+ }
+
+ Fill(Stream_General, 0, General_Format, "OGG", Unlimited, true, true);
+ if (Count_Get(Stream_Video)==0 && Count_Get(Stream_Image)==0)
+ Fill(Stream_General, 0, General_InternetMediaType, "audio/ogg", Unlimited, true, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg::Streams_Finish()
+{
+ std::map<int64u, stream>::iterator Stream_Temp=Stream.begin();
+ while (Stream_Temp!=Stream.end())
+ {
+ //Filling
+ if (Stream_Temp->second.Parser)
+ {
+ Finish(Stream_Temp->second.Parser);
+ Merge(*Stream_Temp->second.Parser, Stream_Temp->second.StreamKind, 0, Stream_Temp->second.StreamPos);
+ Merge(*Stream_Temp->second.Parser, Stream_General, 0, 0);
+ }
+ Stream_Temp++;
+ }
+
+ //No more need
+ if (!File_Name.empty()) //Only if this is not a buffer, with buffer we can have more data
+ Stream.clear();
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Ogg::FileHeader_Begin()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Size<4)
+ return false; //Must wait for more data
+
+ //False positives detection: Detect AVI files, or the parser can synchronize with OggS stream in a AVI chunk
+ if (CC4(Buffer)==0x52494646) //"RIFF"
+ {
+ Finish("OGG");
+ return false;
+ }
+
+ //All should be OK...
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Ogg::Synchronize()
+{
+ //Synchronizing
+ while (Buffer_Offset+4<=Buffer_Size)
+ {
+ while(Buffer_Offset+4<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x4F
+ || Buffer[Buffer_Offset+1]!=0x67
+ || Buffer[Buffer_Offset+2]!=0x67
+ || Buffer[Buffer_Offset+3]!=0x53)) //"OggS"
+ {
+ Buffer_Offset+=1+2;
+ while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x67)
+ Buffer_Offset+=2;
+ if (Buffer_Offset>=Buffer_Size || Buffer[Buffer_Offset-1]==0x67)
+ Buffer_Offset--;
+ Buffer_Offset--;
+ }
+
+ if (Buffer_Offset+4<=Buffer_Size) //Testing if size is coherant
+ {
+ //Retrieving some info
+ if (Buffer_Offset+27>Buffer_Size)
+ return false; //Need more data
+ int8u page_segments=CC1(Buffer+Buffer_Offset+26);
+ if (Buffer_Offset+27+page_segments>Buffer_Size)
+ return false; //Need more data
+ size_t Size=0;
+ for (int8u Pos=0; Pos<page_segments; Pos++)
+ Size+=CC1(Buffer+Buffer_Offset+27+Pos);
+
+ //Testing
+ if (Buffer_Offset+27+page_segments+Size+4>Buffer_Size)
+ return false; //Need more data
+ if (CC4(Buffer+Buffer_Offset+27+page_segments+Size)!=0x4F676753) //"OggS"
+ Buffer_Offset++;
+ else
+ break;
+ }
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+4>Buffer_Size)
+ {
+ if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x4F6767) //"Ogg"
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x4F67) //"Og"
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x4F) //"O"
+ Buffer_Offset++;
+ return false;
+ }
+
+ //Synched is OK
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Ogg::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (CC4(Buffer+Buffer_Offset)!=0x4F676753) //"OggS"
+ Synched=false;
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ogg::Header_Parse()
+{
+ //Specific case
+ if (SizedBlocks)
+ {
+ int16u Size;
+ Get_B2 (Size, "Size");
+
+ Chunk_Sizes.clear();
+ Chunk_Sizes.push_back(Size);
+ Header_Fill_Size(2+Size);
+ Header_Fill_Code(0, Ztring::ToZtring(0, 16));
+ return;
+ }
+ if (XiphLacing)
+ {
+ if (Chunk_Sizes.empty())
+ {
+ int8u CountMinus1;
+ Get_B1 (CountMinus1, "Number of frames minus one");
+
+ int64u UsedSize=0;
+ for (size_t Pos=0; Pos<CountMinus1; Pos++)
+ {
+ int32u Size=0;
+ int8u Size8;
+ do
+ {
+ Get_B1 (Size8, "Size");
+ Size+=Size8;
+ }
+ while (Size8==0xFF);
+ Param_Info1(Size);
+ Chunk_Sizes.push_back(Size);
+ UsedSize+=Size;
+ }
+ Chunk_Sizes.push_back((size_t)(Element_Size-UsedSize-1));
+ }
+
+ Header_Fill_Size(Element_Size);
+ Header_Fill_Code(0, Ztring::ToZtring(0, 16));
+ return;
+ }
+
+ //Parsing
+ int64u absolute_granule_position;
+ int32u stream_serial_number, page_sequence_no;
+ int16u total_page_size;
+ int8u stream_structure_version, flags, page_segments, packet_lacing_value;
+ Skip_C4( "capture_pattern");
+ Get_L1 (stream_structure_version, "stream_structure_version");
+ Get_L1 (flags, "header_type_flag");
+ Get_Flags (flags, 0, continued, "continued packet");
+ Skip_Flags(flags, 1, "first page of logical bitstream (bos)");
+ Get_Flags (flags, 2, eos, "last page of logical bitstream (eos)");
+ Get_L8 (absolute_granule_position, "absolute granule position");
+ Get_L4 (stream_serial_number, "stream serial number");
+ Get_L4 (page_sequence_no, "page sequence no");
+ Skip_L4( "page checksum");
+ Get_L1 (page_segments, "page_segments");
+ total_page_size=0;
+ Chunk_Sizes.clear();
+ Chunk_Sizes.push_back(0);
+ for (int8u Pos=0; Pos<page_segments; Pos++)
+ {
+ Get_L1 (packet_lacing_value, "packet lacing value");
+ total_page_size+=packet_lacing_value;
+ Chunk_Sizes[Chunk_Sizes.size()-1]+=packet_lacing_value;
+ if (packet_lacing_value!=0xFF)
+ {
+ Chunk_Sizes.push_back(0);
+ Chunk_Sizes_Finished=true;
+ }
+ else
+ Chunk_Sizes_Finished=false;
+ }
+ if (Chunk_Sizes_Finished)
+ Chunk_Sizes.resize(Chunk_Sizes.size()-1); //Keep out the last value
+
+ //Filling
+ Header_Fill_Size(27+page_segments+total_page_size);
+ Header_Fill_Code(stream_serial_number, Ztring::ToZtring(stream_serial_number, 16));
+ Stream[stream_serial_number].absolute_granule_position=absolute_granule_position;
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg::Data_Parse()
+{
+ //Counting
+ Frame_Count++;
+
+ //If first chunk of a stream
+ if (Stream[Element_Code].Parser==NULL)
+ {
+ if (Parsing_End)
+ return; //Maybe multitracks concatained, not supported
+ Stream[Element_Code].Parser=new File_Ogg_SubElement;
+ Open_Buffer_Init(Stream[Element_Code].Parser);
+ ((File_Ogg_SubElement*)Stream[Element_Code].Parser)->InAnotherContainer=IsSub;
+ StreamsToDo++;
+ }
+ ((File_Ogg_SubElement*)Stream[Element_Code].Parser)->MultipleStreams=Stream.size()>1; //has no sens for the first init, must check allways
+
+ //Parsing
+ File_Ogg_SubElement* Parser=(File_Ogg_SubElement*)Stream[Element_Code].Parser;
+ if (Stream[Element_Code].SearchingPayload)
+ //For each chunk
+ for (size_t Chunk_Sizes_Pos=0; Chunk_Sizes_Pos<Chunk_Sizes.size(); Chunk_Sizes_Pos++)
+ {
+ //Info
+ if (!continued)
+ Peek_L1(packet_type); //Only for information
+ Element_Info1(Ztring::ToZtring(packet_type, 16));
+ Element_Info1C((continued), "Continue");
+
+ //Parsing
+ if (continued || Parser->File_Offset!=Parser->File_Size)
+ Open_Buffer_Continue(Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, Chunk_Sizes[Chunk_Sizes_Pos]);
+ if (Chunk_Sizes_Pos<Chunk_Sizes.size()-1
+ || (Chunk_Sizes_Pos==Chunk_Sizes.size()-1 && Chunk_Sizes_Finished))
+ {
+ Open_Buffer_Continue(Parser, Buffer+Buffer_Offset, 0); //Purge old datas
+ }
+
+ Element_Offset+=Chunk_Sizes[Chunk_Sizes_Pos];
+ continued=false; //If there is another chunk, this can not be a continued chunk
+ if (Parser->File_GoTo!=(int64u)-1)
+ Chunk_Sizes_Pos=Chunk_Sizes.size();
+
+ if (!Status[IsAccepted] && Parser->Status[IsAccepted])
+ Accept("OGG");
+ if (Parser->Status[IsFinished] || (Element_Offset==Element_Size && eos))
+ {
+ StreamsToDo--;
+ Stream[Element_Code].SearchingPayload=false;
+ break;
+ }
+
+ }
+ else
+ Skip_XX(Element_Size, "Data");
+
+ //End of stream
+ if (!Parsing_End &&
+ (StreamsToDo==0 || File_Offset+Buffer_Offset+Element_Offset>256*1024))
+ {
+ if (IsSub)
+ Finish("OGG");
+ else
+ GoToFromEnd(256*1024, "OGG");
+ std::map<int64u, stream>::iterator Stream_Temp=Stream.begin();
+ if (File_GoTo!=(int64u)-1)
+ while (Stream_Temp!=Stream.end())
+ {
+ Stream_Temp->second.absolute_granule_position=0;
+ Stream_Temp++;
+ }
+ Parsing_End=true;
+ }
+
+ Element_Show();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_OGG_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg.h
new file mode 100644
index 000000000..186fe5716
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg.h
@@ -0,0 +1,110 @@
+// File_Ogg - Info for ogg files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Ogg files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_OggH
+#define MediaInfo_File_OggH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Ogg
+//***************************************************************************
+
+class File_Ogg : public File__Analyze
+{
+public :
+ //In
+ bool SizedBlocks;
+ bool XiphLacing;
+
+ //Constructor/Destructor
+ File_Ogg();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Header_Parse_AdaptationField();
+ void Data_Parse();
+
+ //Temp - Global
+ int32u StreamsToDo;
+ bool Parsing_End;
+
+ //Temp - Stream
+ struct stream
+ {
+ File__Analyze* Parser;
+ stream_t StreamKind;
+ size_t StreamPos;
+ bool SearchingPayload;
+ bool SearchingTimeCode;
+ int64u absolute_granule_position;
+ int64u absolute_granule_position_Resolution;
+
+ stream()
+ {
+ Parser=NULL;
+ StreamKind=Stream_Max;
+ StreamPos=(size_t)-1;
+ SearchingPayload=true;
+ SearchingTimeCode=true;
+ absolute_granule_position=0;
+ absolute_granule_position_Resolution=0;
+ }
+ ~stream()
+ {
+ delete Parser; //Parser=NULL
+ }
+ };
+
+ int8u packet_type;
+ bool continued;
+ bool eos;
+ bool continued_NextFrame;
+ std::map<int64u, stream> Stream;
+ std::vector<size_t> Chunk_Sizes;
+ bool Chunk_Sizes_Finished;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg_SubElement.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg_SubElement.cpp
new file mode 100644
index 000000000..5999eda7e
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg_SubElement.cpp
@@ -0,0 +1,881 @@
+// File_Ogg_SubElement - Info for OGG files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_OGG_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Ogg_SubElement.h"
+#include "MediaInfo/Tag/File_VorbisCom.h"
+#include "ZenLib/ZtringListList.h"
+#include "ZenLib/BitStream.h"
+#include "ZenLib/Utils.h"
+#include <cmath>
+#include <memory>
+#if defined(MEDIAINFO_DIRAC_YES)
+ #include "MediaInfo/Video/File_Dirac.h"
+#endif
+#if defined(MEDIAINFO_MPEG4V_YES)
+ #include "MediaInfo/Video/File_Mpeg4v.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_CELT_YES)
+ #include "MediaInfo/Audio/File_Celt.h"
+#endif
+#if defined(MEDIAINFO_FLAC_YES)
+ #include "MediaInfo/Audio/File_Flac.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if defined(MEDIAINFO_SPEEX_YES)
+ #include "MediaInfo/Audio/File_Speex.h"
+#endif
+#if defined(MEDIAINFO_THEORA_YES)
+ #include "MediaInfo/Video/File_Theora.h"
+#endif
+#if defined(MEDIAINFO_VORBIS_YES)
+ #include "MediaInfo/Audio/File_Vorbis.h"
+#endif
+#if defined(MEDIAINFO_CMML_YES)
+ #include "MediaInfo/Text/File_Cmml.h"
+#endif
+#if defined(MEDIAINFO_KATE_YES)
+ #include "MediaInfo/Text/File_Kate.h"
+#endif
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+#ifdef __BORLANDC__ //Borland converts int64u to int32u without error or warning
+ #define OGG_ID(NAME, PART1, PART2, COUNT) \
+ const int32u Identifier_##NAME##1=0x##PART1; \
+ const int32u Identifier_##NAME##2=0x##PART2; \
+ const size_t Identifier_##NAME##3=0x##COUNT; \
+
+#elif defined(WINDOWS) //__BORLANDC__
+ #define OGG_ID(NAME, PART1, PART2, COUNT) \
+ const int64u Identifier_##NAME=(int64u)0x##PART1##PART2##ULL; \
+ const size_t Identifier_##NAME##3=0x##COUNT; \
+
+#else //__BORLANDC__
+ #define OGG_ID(NAME, PART1, PART2, COUNT) \
+ const int64u Identifier_##NAME=(int64u)0x##PART1##PART2##LL; \
+ const size_t Identifier_##NAME##3=0x##COUNT; \
+
+#endif //__BORLANDC__
+
+namespace Elements
+{
+ const int32u fLaC=0x664C6143;
+
+ //http://wiki.xiph.org/index.php/MIMETypesCodecs
+ OGG_ID(CELT, 43454C54, 20202020, 8)
+ OGG_ID(CMML, 434D4D4C, 00000000, 8)
+ OGG_ID(BBCD, 42, 42434400, 5)
+ OGG_ID(FLAC, 7F, 464C4143, 5)
+ OGG_ID(JNG, 8B4A4E47, 0D0A1A0A, 8)
+ OGG_ID(kate, 806B6174, 65000000, 8)
+ OGG_ID(KW_DIRAC, 4B572D44, 49524143, 8)
+ OGG_ID(OggMIDI, 4D67674D, 49444900, 8)
+ OGG_ID(MNG, 8A4D4E47, 0D0A1A0A, 8)
+ OGG_ID(PCM, 50434D20, 20202020, 8)
+ OGG_ID(PNG, 89504E47, 0D0A1A0A, 8)
+ OGG_ID(Speex, 53706565, 78202020, 8)
+ OGG_ID(theora, 807468, 656F7261, 7)
+ OGG_ID(vorbis, 01766F, 72626973, 7)
+ OGG_ID(YUV4MPEG, 59555634, 4D504547, 8)
+
+ //Not Xiph registered, but found
+ OGG_ID(video, 017669, 64656F00, 7)
+ OGG_ID(audio, 016175, 64696F00, 7)
+ OGG_ID(text, 017465, 78740000, 7)
+ OGG_ID(fLaC, 0, 664C6143, 4)
+
+ //Ogg Skeleton
+ OGG_ID(fishead, 66697368, 65616400, 8)
+ OGG_ID(fisbone, 66697362, 6F6E6500, 8)
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Ogg_SubElement::File_Ogg_SubElement()
+:File__Analyze()
+{
+ //In
+ StreamKind=Stream_Max;
+ MultipleStreams=false;
+ InAnotherContainer=false;
+ absolute_granule_position_Resolution=0;
+
+ //Temp
+ Parser=NULL;
+ OldSize=0;
+ Identified=false;
+ WithType=true;
+}
+
+//---------------------------------------------------------------------------
+File_Ogg_SubElement::~File_Ogg_SubElement()
+{
+ delete Parser; //Parser=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Streams_Fill()
+{
+ if (Parser==NULL)
+ return;
+
+ Fill(Parser);
+ if (Parser->Count_Get(Stream_Video))
+ {
+ //Hack - Before
+ Ztring Codec_Temp=Retrieve(Stream_Video, 0, Video_Codec); //We want to keep the 4CC of AVI
+
+ Merge(*Parser, Stream_Video, 0, 0);
+
+ //Hacks - After
+ if (!Codec_Temp.empty())
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, Codec_Temp, true);
+ }
+ if (Parser->Count_Get(Stream_Audio))
+ {
+ //Hack - Before
+ Ztring Codec_Temp=Retrieve(Stream_Audio, 0, Audio_Codec); //We want to keep the 2CC of AVI
+
+ Merge(*Parser, Stream_Audio, 0, 0);
+
+ //Hacks - After
+ if (!Codec_Temp.empty())
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Codec_Temp, true);
+ }
+ Merge(*Parser, Stream_Text, 0, 0);
+ Merge(*Parser, Stream_Image, 0, 0);
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Streams_Finish()
+{
+ if (Parser==NULL)
+ return;
+
+ Finish(Parser);
+ if (Parser->Count_Get(Stream_Video))
+ {
+ //Hack - Before
+ Ztring Codec_Temp=Retrieve(Stream_Video, 0, Video_Codec); //We want to keep the 4CC of AVI
+
+ Merge(*Parser, Stream_Video, 0, 0);
+
+ //Hacks - After
+ if (!Codec_Temp.empty())
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, Codec_Temp, true);
+ }
+ if (Parser->Count_Get(Stream_Audio))
+ {
+ //Hack - Before
+ Ztring Codec_Temp=Retrieve(Stream_Audio, 0, Audio_Codec); //We want to keep the 2CC of AVI
+
+ Merge(*Parser, Stream_Audio, 0, 0);
+
+ //Hacks - After
+ if (!Codec_Temp.empty())
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Codec_Temp, true);
+ }
+ Merge(*Parser, Stream_Text, 0, 0);
+ Merge(*Parser, Stream_Image, 0, 0);
+}
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::FileHeader_Parse()
+{
+ Accept("OGG (Sub element)");
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Ogg_SubElement::Header_Begin()
+{
+ //Already parsed (there is only one pass)
+ if (Buffer_Offset!=0)
+ return false;
+
+ //We are waiting for the end of the stream, signaled by a empty buffer adding
+ if (Buffer_Size!=OldSize)
+ {
+ OldSize=Buffer_Size;
+ return false;
+ }
+ else
+ {
+ OldSize=0;
+ return true;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Header_Parse()
+{
+ //Parsing
+ int8u Type;
+ bool lenbytes0, lenbytes1, lenbytes2;
+ if (Identified && WithType)
+ {
+ Get_L1 (Type, "Type");
+ Skip_Flags(Type, 0, "Indicates data packet");
+ Get_Flags (Type, 1, lenbytes2, "Bit 2 of lenbytes");
+ Skip_Flags(Type, 2, "unused");
+ Skip_Flags(Type, 3, "Keyframe");
+ Skip_Flags(Type, 4, "unused");
+ Skip_Flags(Type, 5, "unused");
+ Get_Flags (Type, 6, lenbytes0, "Bit 0 of lenbytes");
+ Get_Flags (Type, 7, lenbytes1, "Bit 1 of lenbytes");
+ if ((Type&0x01)==0) //TODO : find a better algo
+ {
+ if (lenbytes2)
+ {
+ if (lenbytes1)
+ {
+ if (lenbytes0)
+ Skip_L7( "SamplesCount");
+ else
+ Skip_L6( "SamplesCount");
+ }
+ else
+ {
+ if (lenbytes0)
+ Skip_L5( "SamplesCount");
+ else
+ Skip_L4( "SamplesCount");
+ }
+ }
+ else
+ {
+ if (lenbytes1)
+ {
+ if (lenbytes0)
+ Skip_L3 ( "SamplesCount");
+ else
+ Skip_L2 ( "SamplesCount");
+ }
+ else
+ {
+ if (lenbytes0)
+ Skip_L1 ( "SamplesCount");
+ }
+ }
+ }
+ //Filling
+ Header_Fill_Code(Type, Ztring::ToZtring(Type, 16));
+ }
+ else
+ //Filling
+ Header_Fill_Code(0, "Identification");
+
+ //Filling
+ Header_Fill_Size(Element_Size);
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Data_Parse()
+{
+ //Parsing
+ if (!Identified)
+ Identification();
+ else if (!WithType)
+ Default();
+ else
+ switch (Element_Code&0x7F)
+ {
+ case 0x01 :
+ case 0x03 : Comment(); break;
+ case 0x00 :
+ case 0x02 :
+ case 0x05 :
+ case 0x08 : Default(); break;
+ default : Skip_XX(Element_Size, "Unknown");
+ Finish("OggSubElement");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification()
+{
+ Element_Name("Identification");
+
+ //Parsing
+ int64u ID_Identification;
+ if (Element_Size==4)
+ {
+ int32u ID_Identification_32;
+ Peek_B4(ID_Identification_32);
+ ID_Identification=((int64u)ID_Identification_32)<<32;
+ }
+ else
+ Peek_B8(ID_Identification);
+
+ //Filling
+ #undef ELEMENT_CASE
+ #ifdef __BORLANDC__ //Borland converts int64u to int32u
+ #define ELEMENT_CASE(_NAME) \
+ else if (ID_Identification>>(64-8*Elements::Identifier_##_NAME##3)==(((int64u)Elements::Identifier_##_NAME##1)*0x100000000LL+Elements::Identifier_##_NAME##2)) Identification_##_NAME();
+
+ #else //__BORLANDC__
+ #define ELEMENT_CASE(_NAME) \
+ else if (ID_Identification>>(64-8*Elements::Identifier_##_NAME##3)==Elements::Identifier_##_NAME) Identification_##_NAME();
+
+ #endif //__BORLANDC__
+
+ if (0) ;
+ ELEMENT_CASE(CELT)
+ ELEMENT_CASE(CMML)
+ ELEMENT_CASE(BBCD)
+ ELEMENT_CASE(FLAC)
+ ELEMENT_CASE(JNG)
+ ELEMENT_CASE(kate)
+ ELEMENT_CASE(KW_DIRAC)
+ ELEMENT_CASE(OggMIDI)
+ ELEMENT_CASE(MNG)
+ ELEMENT_CASE(PCM)
+ ELEMENT_CASE(PNG)
+ ELEMENT_CASE(Speex)
+ ELEMENT_CASE(theora)
+ ELEMENT_CASE(vorbis)
+ ELEMENT_CASE(YUV4MPEG)
+ ELEMENT_CASE(video)
+ ELEMENT_CASE(audio)
+ ELEMENT_CASE(text)
+ ELEMENT_CASE(fLaC)
+ ELEMENT_CASE(fishead)
+ ELEMENT_CASE(fisbone)
+ else
+ {
+ Skip_XX(Element_Size, "Unknown");
+ Accept("OggSubElement");
+ Finish("OggSubElement");
+ return;
+ }
+ Open_Buffer_Init(Parser);
+
+ //Parsing
+ Default();
+
+ //Filling
+ StreamKind=StreamKind_Last;
+ if (0) ;
+ ELEMENT_CASE(fishead)
+ ELEMENT_CASE(fisbone)
+ else
+ Identified=true;
+ Accept("OggSubElement");
+ Element_Show();
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_CELT()
+{
+ #if defined(MEDIAINFO_CELT_YES)
+ StreamKind_Last=Stream_Audio;
+ Parser=new File_Celt;
+ #else
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "celt");
+ Fill(Stream_Audio, 0, Audio_Codec, "celt");
+ #endif
+ WithType=false;
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_CMML()
+{
+ #if defined(MEDIAINFO_CMML_YES)
+ StreamKind_Last=Stream_Text;
+ Parser=new File_Cmml;
+ #else
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Format, "CMML");
+ Fill(Stream_Text, 0, Text_Codec, "CMML");
+ #endif
+ WithType=false;
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_BBCD()
+{
+ #if defined(MEDIAINFO_DIRAC_YES)
+ StreamKind_Last=Stream_Video;
+ Parser=new File_Dirac;
+ ((File_Dirac*)Parser)->Ignore_End_of_Sequence=true;
+ #else
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "Dirac");
+ Fill(Stream_Video, 0, Video_Codec, "Dirac");
+ #endif
+ WithType=false;
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_FLAC()
+{
+ #if defined(MEDIAINFO_FLAC_YES)
+ StreamKind_Last=Stream_Audio;
+ Parser=new File_Flac;
+ ((File_Flac*)Parser)->VorbisHeader=true;
+ #else
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "FLAC");
+ Fill(Stream_Audio, 0, Audio_Codec, "FLAC");
+ #endif
+ WithType=false;
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_JNG()
+{
+ #if defined(MEDIAINFO__YES)
+ StreamKind_Last=Stream_Video;
+ Parser=new File_Jng;
+ #else
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "JNG");
+ Fill(Stream_Video, 0, Video_Codec, "JNG");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_kate()
+{
+ #if defined(MEDIAINFO_KATE_YES)
+ StreamKind_Last=Stream_Text;
+ Parser=new File_Kate;
+ #else
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Format, "Kate");
+ Fill(Stream_Text, 0, Text_Codec, "Kate");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_KW_DIRAC()
+{
+ Identification_BBCD();
+ Fill(Stream_Video, 0, Video_CodecID, "KW-DIRAC", Unlimited, true, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_OggMIDI()
+{
+ #if defined(MEDIAINFO__YES)
+ StreamKind_Last=Stream_Audio;
+ Parser=new File_Midi;
+ #else
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "Midi");
+ Fill(Stream_Audio, 0, Audio_Codec, "Midi");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_MNG()
+{
+ #if defined(MEDIAINFO__YES)
+ StreamKind_Last=Stream_Video;
+ Parser=new File_Mng;
+ #else
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "MNG");
+ Fill(Stream_Video, 0, Video_Codec, "MNG");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_PCM()
+{
+ #if defined(MEDIAINFO__YES)
+ StreamKind_Last=Stream_Audio;
+ Parser=new File_Pcm;
+ #else
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ Fill(Stream_Audio, 0, Audio_Codec, "PCM");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_PNG()
+{
+ #if defined(MEDIAINFO__YES)
+ StreamKind_Last=Stream_Video;
+ Parser=new File_Png;
+ #else
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "PNG");
+ Fill(Stream_Video, 0, Video_Codec, "PNG");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_Speex()
+{
+ #if defined(MEDIAINFO_SPEEX_YES)
+ StreamKind_Last=Stream_Audio;
+ Parser=new File_Speex;
+ #else
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "Speex");
+ Fill(Stream_Audio, 0, Audio_Codec, "Speex");
+ #endif
+ WithType=false;
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_theora()
+{
+ #if defined(MEDIAINFO_THEORA_YES)
+ StreamKind_Last=Stream_Video;
+ Parser=new File_Theora;
+ #else
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Video, 0, Text_Format, "Theora");
+ Fill(Stream_Video, 0, Text_Codec, "Theora");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_vorbis()
+{
+ #if defined(MEDIAINFO_VORBIS_YES)
+ StreamKind_Last=Stream_Audio;
+ Parser=new File_Vorbis;
+ #else
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Text_Format, "Vorbis");
+ Fill(Stream_Audio, 0, Text_Codec, "Vorbis");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_YUV4MPEG()
+{
+ #if defined(MEDIAINFO__YES)
+ StreamKind_Last=Stream_Video;
+ Parser=new File_Yuv;
+ #else
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "YUV");
+ Fill(Stream_Video, 0, Video_Codec, "YUV");
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_video()
+{
+ Element_Info1("Video");
+
+ //Parsing
+ int64u TimeUnit;
+ int32u fccHandler, Width, Height;
+ Skip_B1 ( "Signature");
+ Skip_Local(6, "Signature");
+ Skip_L2( "Reserved");
+ Get_C4 (fccHandler, "fccHandler");
+ Skip_L4( "SizeOfStructure");
+ Get_L8 (TimeUnit, "TimeUnit"); //10000000/TimeUnit is stream tick rate in ticks/sec
+ Skip_L4( "SamplesPerUnit");
+ Skip_L8( "DefaultLengh"); //in media time
+ Skip_L4( "BufferSize");
+ Skip_L2( "BitsPerSample");
+ Skip_L2( "Reserved");
+ Get_L4 (Width, "Width");
+ Get_L4 (Height, "Height");
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+
+ //Filling
+ Stream_Prepare(Stream_Video);
+ CodecID_Fill(Ztring().From_CC4(fccHandler), Stream_Video, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, Ztring().From_CC4(fccHandler));
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, (float)10000000/(float)TimeUnit, 3);
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Width);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Height);
+
+ //Creating the parser
+ if (0);
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(fccHandler))==_T("MPEG-4 Visual"))
+ {
+ Parser=new File_Mpeg4v;
+ ((File_Mpeg4v*)Parser)->FrameIsAlwaysComplete=true;
+ }
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_audio()
+{
+ Element_Info1("Audio");
+
+ //Parsing
+ int64u TimeUnit, SamplesPerUnit;
+ int32u fccHandler, AvgBytesPerSec;
+ int16u Channels;
+ Skip_B1 ( "Signature");
+ Skip_Local(6, "Signature");
+ Skip_L2( "Reserved");
+ Get_C4 (fccHandler, "fccHandler");
+ Skip_L4( "SizeOfStructure");
+ Get_L8 (TimeUnit, "TimeUnit"); //10000000/TimeUnit is stream tick rate in ticks/sec
+ Get_L8 (SamplesPerUnit, "SamplesPerUnit");
+ Skip_L4( "DefaultLengh"); //in media time
+ Skip_L4( "BufferSize");
+ Skip_L2( "BitsPerSample");
+ Skip_L2( "Reserved");
+ Get_L2 (Channels, "Channels");
+ Skip_L2( "BlockAlign");
+ Get_L4 (AvgBytesPerSec, "AvgBytesPerSec");
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+
+ //Filling
+ Stream_Prepare(Stream_Audio);
+ Ztring Codec; Codec.From_CC4(fccHandler);
+ Codec.TrimLeft(_T('0'));
+ CodecID_Fill(Codec, Stream_Audio, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Codec);
+ if (AvgBytesPerSec<0x80000000) //This is a signed value, and negative values are not OK
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate, AvgBytesPerSec*8);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels==5?6:Channels); //5 channels are 5.1
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, SamplesPerUnit);
+ absolute_granule_position_Resolution=SamplesPerUnit;
+
+ //Creating the parser
+ if (0);
+ #if defined(MEDIAINFO_MPEGA_YES)
+ else if (MediaInfoLib::Config.Codec_Get(Codec, InfoCodec_KindofCodec).find(_T("MPEG-"))==0)
+ {
+ Parser=new File_Mpega;
+ }
+ #endif
+ #if defined(MEDIAINFO_AC3_YES)
+ else if (fccHandler==0x32303030)
+ {
+ Parser=new File_Ac3;
+ ((File_Ac3*)Parser)->Frame_Count_Valid=2;
+ }
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_text()
+{
+ Element_Info1("Text");
+
+ //Parsing
+ Skip_B1 ( "Signature");
+ Skip_Local(6, "Signature");
+ Skip_L2( "Reserved");
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+
+ //Filling
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, StreamPos_Last, Text_Format, "Subrip");
+ Fill(Stream_Text, StreamPos_Last, Text_Codec, "Subrip");
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_fLaC()
+{
+ #if defined(MEDIAINFO_FLAC_YES)
+ Parser=new File_Flac;
+ StreamKind_Last=Stream_Audio;
+ #endif
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "FLAC");
+ Fill(Stream_Audio, 0, Audio_Codec, "FLAC");
+ Fill(Stream_Audio, 0, Audio_MuxingMode, "pre-FLAC 1.1.1");
+ WithType=false;
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_fishead()
+{
+ //Quick workaroud for Identification bool
+ if (Element_Offset==Element_Size)
+ return;
+
+ Element_Info1("Skeleton");
+
+ //Parsing
+ int16u VersionMajor;
+ Skip_Local(7, "Signature");
+ Skip_B1 ( "Signature");
+ Get_L2 (VersionMajor, "Version major");
+ if (VersionMajor==3)
+ {
+ Skip_L2( "Version minor");
+ Skip_L8( "Presentationtime numerator");
+ Skip_L8( "Presentationtime denominator");
+ Skip_L8( "Basetime numerator");
+ Skip_L8( "Basetime denominator");
+ Skip_L16( "UTC");
+ Skip_L4( "UTC");
+ }
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Identification_fisbone()
+{
+ //Quick workaroud for Identification bool
+ if (Element_Offset==Element_Size)
+ return;
+
+ Element_Info1("Skeleton");
+
+ //Parsing
+ int32u Offset;
+ Skip_Local(7, "Signature");
+ Skip_B1 ( "Signature");
+ Get_L4 (Offset, "Offset to message header fields");
+ Skip_L4( "Serial number");
+ Skip_L4( "Number of header packets");
+ Skip_L8( "Granulerate numerator");
+ Skip_L8( "Granulerate denominator");
+ Skip_L8( "Basegranule");
+ Skip_L4( "Preroll");
+ Skip_L1( "Granuleshift");
+ if (Element_Offset<8+Offset)
+ Skip_XX(8+Offset-Element_Offset, "Unknown");
+ if (Element_Offset<Element_Size)
+ Skip_Local(Element_Size-Element_Offset, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Comment()
+{
+ Element_Name("Comment");
+
+ //Integrity
+ if (Element_Size<8)
+ return;
+
+ //Parsing
+ int64u ID_Identification;
+ Peek_B8(ID_Identification);
+
+ #undef ELEMENT_CASE
+ #ifdef __BORLANDC__ //Borland converts int64u to int32u
+ #define ELEMENT_CASE(_NAME) \
+ else if (ID_Identification>>(64-8*Elements::Identifier_##_NAME##3)==(((((int64u)Elements::Identifier_##_NAME##1)*0x100000000LL+Elements::Identifier_##_NAME##2)&0x00FFFFFFFFFFFFFFLL)<<8))
+
+ #else //__BORLANDC__
+ #define ELEMENT_CASE(_NAME) \
+ else if (ID_Identification>>(64-8*Elements::Identifier_##_NAME##3)==((Elements::Identifier_##_NAME&0x00FFFFFFFFFFFFFFLL)<<8))
+
+ #endif //__BORLANDC__
+
+ int32u ID_Identification_Size;
+ if (0) ;
+ ELEMENT_CASE(kate) ID_Identification_Size=8;
+ else ID_Identification_Size=6; //Default
+ Skip_Local(ID_Identification_Size, "ID");
+
+
+ //Preparing
+ File_VorbisCom Vorbis;
+ Vorbis.StreamKind_Specific=StreamKind;
+ Vorbis.StreamKind_Multiple=MultipleStreams?StreamKind:Stream_General;
+ Vorbis.StreamKind_Common=InAnotherContainer?StreamKind:Stream_General;
+ Open_Buffer_Init(&Vorbis);
+
+ //Parsing
+ Open_Buffer_Continue(&Vorbis);
+
+ //Filling
+ Finish(&Vorbis);
+ Merge(Vorbis, Stream_General, 0, 0);
+ Merge(Vorbis, StreamKind, 0, 0);
+ Merge(Vorbis, Stream_Menu, 0, 0);
+
+ //Testing if we must continue
+ if (Identified && (Parser==NULL || Parser->Status[IsFinished]))
+ Finish("OggSubElement");
+}
+
+//---------------------------------------------------------------------------
+void File_Ogg_SubElement::Default()
+{
+ Element_Name("Frame");
+
+ if (Parser)
+ {
+ Open_Buffer_Continue(Parser);
+ if (Identified && Parser->Status[IsFilled])
+ Finish("OggSubElement");
+ }
+ else if (Element_Offset<Element_Size)
+ {
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ if (Identified)
+ Finish("OggSubElement");
+ }
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_OGG_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg_SubElement.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg_SubElement.h
new file mode 100644
index 000000000..369c51fd7
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Ogg_SubElement.h
@@ -0,0 +1,102 @@
+// File_Ogg_SubElement - Info for OGG files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MPEG Transport Stream files, Program Map Section
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Ogg_Setup_VorbisH
+#define MediaInfo_Ogg_Setup_VorbisH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Ogg_SubElement
+//***************************************************************************
+
+class File_Ogg_SubElement : public File__Analyze
+{
+public :
+ //In
+ stream_t StreamKind;
+ bool MultipleStreams;
+ bool InAnotherContainer;
+ int64u absolute_granule_position_Resolution;
+
+protected :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ void FileHeader_Parse ();
+
+public :
+ File_Ogg_SubElement();
+ ~File_Ogg_SubElement();
+
+private :
+ //Buffer
+ bool Header_Begin();
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Identification();
+ void Identification_CELT();
+ void Identification_CMML();
+ void Identification_BBCD();
+ void Identification_FLAC();
+ void Identification_JNG();
+ void Identification_kate();
+ void Identification_KW_DIRAC();
+ void Identification_OggMIDI();
+ void Identification_MNG();
+ void Identification_PCM();
+ void Identification_PNG();
+ void Identification_Speex();
+ void Identification_theora();
+ void Identification_vorbis();
+ void Identification_YUV4MPEG();
+ void Identification_video();
+ void Identification_audio();
+ void Identification_text();
+ void Identification_fLaC();
+ void Identification_fishead();
+ void Identification_fisbone();
+ void Comment();
+ void Default();
+
+ //Temp
+ File__Analyze* Parser;
+ size_t OldSize;
+ bool Identified;
+ bool WithType;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_P2_Clip.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_P2_Clip.cpp
new file mode 100644
index 000000000..88854ca02
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_P2_Clip.cpp
@@ -0,0 +1,405 @@
+// File_P2_Clip - Info for P2 Clip (XML) files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_P2_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_P2_Clip.h"
+#include "MediaInfo/MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/Multiple/File__ReferenceFilesHelper.h"
+#include "ZenLib/Dir.h"
+#include "ZenLib/FileName.h"
+#include "tinyxml2.h"
+using namespace tinyxml2;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_P2_Clip::File_P2_Clip()
+:File__Analyze()
+{
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_None; //TODO
+ StreamIDs_Width[0]=sizeof(size_t)*2;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_EventWasSent_Accept_Specific=true;
+ #endif //MEDIAINFO_DEMUX
+
+ //Temp
+ ReferenceFiles=NULL;
+}
+
+//---------------------------------------------------------------------------
+File_P2_Clip::~File_P2_Clip()
+{
+ delete ReferenceFiles; //ReferenceFiles=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_P2_Clip::Streams_Finish()
+{
+ if (ReferenceFiles==NULL)
+ return;
+
+ ReferenceFiles->ParseReferences();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_P2_Clip::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ if (ReferenceFiles==NULL)
+ return 0;
+
+ return ReferenceFiles->Read_Buffer_Seek(Method, Value, ID);
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_P2_Clip::FileHeader_Begin()
+{
+ XMLDocument document;
+ if (!FileHeader_Begin_XML(document))
+ return false;
+
+ {
+ XMLElement* Root=document.FirstChildElement("P2Main");
+ if (Root)
+ {
+ Accept("P2_Clip");
+ Fill(Stream_General, 0, General_Format, "P2 Clip");
+
+ ReferenceFiles=new File__ReferenceFilesHelper(this, Config);
+
+ XMLElement* ClipContent=Root->FirstChildElement("ClipContent");
+ if (ClipContent)
+ {
+ XMLElement* ChildElement;
+
+ //ID
+ ChildElement=ClipContent->FirstChildElement("GlobalClipID");
+ if (ChildElement)
+ Fill(Stream_General, 0, General_UniqueID, ChildElement->GetText());
+
+ //Duration
+ Ztring Duration, EditUnit;
+ ChildElement=ClipContent->FirstChildElement("Duration");
+ if (ChildElement)
+ Duration=ChildElement->GetText();
+ ChildElement=ClipContent->FirstChildElement("EditUnit");
+ if (ChildElement)
+ EditUnit=ChildElement->GetText();
+ int64u Duration_Frames=Duration.To_int64u();
+ int64u EditUnit_Numerator=EditUnit.SubString(Ztring(), _T("/")).To_int64u();
+ int64u EditUnit_Denominator=EditUnit.SubString(_T("/"), Ztring()).To_int64u();
+ if (Duration_Frames && EditUnit_Numerator && EditUnit_Denominator)
+ Fill(Stream_General, 0, General_Duration, ((float32)Duration_Frames)*1000*EditUnit_Numerator/EditUnit_Denominator, 0);
+
+ //EssenceList
+ XMLElement* EssenceList=ClipContent->FirstChildElement("EssenceList");
+ if (EssenceList)
+ {
+ XMLElement* Track=EssenceList->FirstChildElement();
+ size_t Audio_Count=0;
+ while (Track)
+ {
+ string Field=Track->Value();
+ if (Field=="Video")
+ {
+ File__ReferenceFilesHelper::reference ReferenceFile;
+
+ //FrameRate
+ ChildElement=Track->FirstChildElement("FrameRate");
+ if (ChildElement)
+ {
+ Ztring FrameRateS=Ztring(ChildElement->GetText());
+ if (FrameRateS.find(_T("23.97"))==0)
+ ReferenceFile.FrameRate=((float64)24)*1000/1001;
+ else if (FrameRateS.find(_T("29.97"))==0)
+ ReferenceFile.FrameRate=((float64)30)*1000/1001;
+ else if (FrameRateS.find(_T("59.94"))==0)
+ ReferenceFile.FrameRate=((float64)60)*1000/1001;
+ else
+ ReferenceFile.FrameRate=FrameRateS.To_float64();
+ if (FrameRateS.find('i')!=string::npos)
+ ReferenceFile.FrameRate/=2;
+ }
+
+ //CreationDate
+ ChildElement=Track->FirstChildElement("StartTimecode");
+ if (ChildElement)
+ {
+ string Text=ChildElement->GetText();
+ if (Text.size()==11)
+ {
+ int64u ToFill=(Text[0]-'0')*10*60*60*1000
+ + (Text[1]-'0') *60*60*1000
+ + (Text[3]-'0') *10*60*1000
+ + (Text[4]-'0') *60*1000
+ + (Text[6]-'0') *10*1000
+ + (Text[7]-'0') *1000;
+ if (ReferenceFile.FrameRate)
+ ToFill+=float64_int64s(((Text[9]-'0')*10+(Text[10]-'0'))*1000/ReferenceFile.FrameRate);
+ //Fill(Stream_Video, StreamPos_Last, Video_Delay, ToFill);
+ //Fill(Stream_Video, StreamPos_Last, Video_Delay_Source, "P2 Clip");
+ }
+ }
+
+ #if defined(MEDIAINFO_MXF_YES)
+ if (File_Name.size()>10+1+4
+ && File_Name[File_Name.size()-10-1]==PathSeparator
+ && (File_Name[File_Name.size()-10-2]&(~0x20))==_T('P')
+ && (File_Name[File_Name.size()-10-3]&(~0x20))==_T('I')
+ && (File_Name[File_Name.size()-10-4]&(~0x20))==_T('L')
+ && (File_Name[File_Name.size()-10-5]&(~0x20))==_T('C'))
+ {
+ Ztring file=File_Name.substr(File_Name.size()-10, 6);
+ Ztring MXF_File=File_Name;
+ MXF_File.resize(MXF_File.size()-(10+1+4));
+ MXF_File+=_T("VIDEO");
+ MXF_File+=PathSeparator;
+ MXF_File+=file;
+ MXF_File+=_T(".MXF");
+
+ ReferenceFile.FileNames.push_back(MXF_File);
+ ReferenceFile.StreamKind=Stream_Video;
+ ReferenceFile.StreamID=ReferenceFiles->References.size()+1;
+ ReferenceFiles->References.push_back(ReferenceFile);
+ }
+ #endif //defined(MEDIAINFO_MXF_YES)
+ }
+ else if (Field=="Audio")
+ {
+ #if defined(MEDIAINFO_MXF_YES)
+ if (File_Name.size()>10+1+4
+ && File_Name[File_Name.size()-10-1]==PathSeparator
+ && (File_Name[File_Name.size()-10-2]&(~0x20))==_T('P')
+ && (File_Name[File_Name.size()-10-3]&(~0x20))==_T('I')
+ && (File_Name[File_Name.size()-10-4]&(~0x20))==_T('L')
+ && (File_Name[File_Name.size()-10-5]&(~0x20))==_T('C'))
+ {
+ Ztring file=File_Name.substr(File_Name.size()-10, 6);
+ Ztring MXF_File=File_Name;
+ MXF_File.resize(MXF_File.size()-(10+1+4));
+ MXF_File+=_T("AUDIO");
+ MXF_File+=PathSeparator;
+ MXF_File+=file;
+ Ztring Pos=Ztring::ToZtring(Audio_Count);
+ if (Pos.size()<2)
+ Pos.insert(0, 1, _T('0'));
+ MXF_File+=Pos;
+ MXF_File+=_T(".MXF");
+
+ File__ReferenceFilesHelper::reference ReferenceFile;
+ ReferenceFile.FileNames.push_back(MXF_File);
+ ReferenceFile.StreamKind=Stream_Audio;
+ ReferenceFile.StreamID=ReferenceFiles->References.size()+1;
+ ReferenceFiles->References.push_back(ReferenceFile);
+
+ Audio_Count++;
+ }
+ #endif //defined(MEDIAINFO_MXF_YES)
+ }
+
+ Track=Track->NextSiblingElement();
+ }
+ }
+
+ //ClipMetadata
+ XMLElement* ClipMetadata=ClipContent->FirstChildElement("ClipMetadata");
+ if (ClipMetadata)
+ {
+ XMLElement* Access=ClipMetadata->FirstChildElement("Access");
+ if (Access)
+ {
+ //CreationDate
+ ChildElement=Access->FirstChildElement("CreationDate");
+ if (ChildElement)
+ {
+ Ztring Content=ChildElement->GetText();
+ if (Content.size()>=11 && Content[10]==_T('T'))
+ Content[10]=_T(' ');
+ if (Content.find(_T("+00:00"))!=string::npos)
+ {
+ Content.resize(10+1+8);
+ Content.insert(0, _T("UTC "));
+ }
+ Fill(Stream_General, 0, General_Recorded_Date, Content);
+ }
+
+ //CreationDate
+ ChildElement=Access->FirstChildElement("LastUpdateDate");
+ if (ChildElement)
+ {
+ Ztring Content=ChildElement->GetText();
+ if (Content.size()>=11 && Content[10]==_T('T'))
+ Content[10]=_T(' ');
+ if (Content.find(_T("+00:00"))!=string::npos)
+ {
+ Content.resize(10+1+8);
+ Content.insert(0, _T("UTC "));
+ }
+ Fill(Stream_General, 0, General_Tagged_Date, Content);
+ }
+ }
+
+ XMLElement* Device=ClipMetadata->FirstChildElement("Device");
+ if (Device)
+ {
+ //Manufacturer+ModelName
+ XMLElement* Manufacturer=Device->FirstChildElement("Manufacturer");
+ XMLElement* ModelName=Device->FirstChildElement("ModelName");
+ if (Manufacturer && ModelName)
+ Fill(Stream_General, 0, General_Encoded_Application, string(Manufacturer->GetText())+" "+ModelName->GetText());
+ }
+
+ XMLElement* Shoot=ClipMetadata->FirstChildElement("Shoot");
+ if (Shoot)
+ {
+ //StartDate
+ ChildElement=Shoot->FirstChildElement("StartDate");
+ if (ChildElement)
+ {
+ Ztring Content=ChildElement->GetText();
+ if (Content.size()>=11 && Content[10]==_T('T'))
+ Content[10]=_T(' ');
+ if (Content.find(_T("+00:00"))!=string::npos)
+ {
+ Content.resize(10+1+8);
+ Content.insert(0, _T("UTC "));
+ }
+ Fill(Stream_General, 0, General_Duration_Start, Content);
+ }
+
+ //EndDate
+ ChildElement=Shoot->FirstChildElement("EndDate");
+ if (ChildElement)
+ {
+ Ztring Content=ChildElement->GetText();
+ if (Content.size()>=11 && Content[10]==_T('T'))
+ Content[10]=_T(' ');
+ if (Content.find(_T("+00:00"))!=string::npos)
+ {
+ Content.resize(10+1+8);
+ Content.insert(0, _T("UTC "));
+ }
+ Fill(Stream_General, 0, General_Duration_End, Content);
+ }
+
+ //Location
+ XMLElement* Location=Shoot->FirstChildElement("Location");
+ if (Location)
+ {
+ //Longitude+Latitude
+ XMLElement* Longitude=Location->FirstChildElement("Longitude");
+ XMLElement* Latitude=Location->FirstChildElement("Latitude");
+ if (Longitude && Latitude)
+ Fill(Stream_General, 0, General_Recorded_Location, string(Latitude->GetText())+", "+Longitude->GetText());
+ }
+ }
+
+ XMLElement* Scenario=ClipMetadata->FirstChildElement("Scenario");
+ if (Scenario)
+ {
+ //ProgramName
+ ChildElement=Scenario->FirstChildElement("ProgramName");
+ if (ChildElement)
+ Fill(Stream_General, 0, General_Title, ChildElement->GetText());
+
+ //SceneNo.
+ ChildElement=Scenario->FirstChildElement("SceneNo.");
+ if (ChildElement)
+ Fill(Stream_General, 0, "Scene Number", ChildElement->GetText());
+
+ //TakeNo.
+ ChildElement=Scenario->FirstChildElement("TakeNo.");
+ if (ChildElement)
+ Fill(Stream_General, 0, "Take Number", ChildElement->GetText());
+ }
+
+ XMLElement* News=ClipMetadata->FirstChildElement("News");
+ if (News)
+ {
+ //Reporter
+ ChildElement=News->FirstChildElement("Reporter");
+ if (ChildElement)
+ Fill(Stream_General, 0, "Reporter", ChildElement->GetText());
+
+ //Purpose
+ ChildElement=News->FirstChildElement("Purpose");
+ if (ChildElement)
+ Fill(Stream_General, 0, "Purpose", ChildElement->GetText());
+
+ //Object
+ ChildElement=News->FirstChildElement("Object");
+ if (ChildElement)
+ Fill(Stream_General, 0, "Object", ChildElement->GetText());
+ }
+ }
+ }
+ }
+ else
+ {
+ Reject("P2_Clip");
+ return false;
+ }
+ }
+
+ //All should be OK...
+ return true;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_P2_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_P2_Clip.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_P2_Clip.h
new file mode 100644
index 000000000..051bb059a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_P2_Clip.h
@@ -0,0 +1,69 @@
+// File_P2_Clip - Info for P2 Clip (XML) files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about P2 Clip files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_P2_ClipH
+#define MediaInfo_File_P2_ClipH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class File__ReferenceFilesHelper;
+
+//***************************************************************************
+// Class File_P2_Clip
+//***************************************************************************
+
+class File_P2_Clip : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_P2_Clip();
+ ~File_P2_Clip();
+
+private :
+ //Streams management
+ void Streams_Finish ();
+
+ //Buffer - Global
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Temp
+ File__ReferenceFilesHelper* ReferenceFiles;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff.cpp
new file mode 100644
index 000000000..084a2c03d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff.cpp
@@ -0,0 +1,911 @@
+// File_Riff - Info for RIFF files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_RIFF_YES
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Riff.h"
+#if defined(MEDIAINFO_MPEG4V_YES)
+ #include "MediaInfo/Video/File_Mpeg4v.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_DTS_YES)
+ #include "MediaInfo/Audio/File_Dts.h"
+#endif
+#if defined(MEDIAINFO_DVDIF_YES)
+ #include "MediaInfo/Multiple/File_DvDif.h"
+#endif
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#include <ZenLib/File.h>
+#include <ZenLib/Utils.h>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Const
+//***************************************************************************
+
+namespace Elements
+{
+ const int32u AIFF_SSND=0x53534E44;
+ const int32u AVI_=0x41564920;
+ const int32u AVI__hdlr_strl_strh_txts=0x74787473;
+ const int32u FORM=0x464F524D;
+ const int32u LIST=0x4C495354;
+ const int32u MThd=0x4D546864;
+ const int32u ON2_=0x4F4E3220;
+ const int32u ON2f=0x4F4E3266;
+ const int32u RIFF=0x52494646;
+ const int32u riff=0x72696666;
+ const int32u RF64=0x52463634;
+ const int32u SMV0=0x534D5630;
+ const int32u SMV0_xxxx=0x534D563A;
+ const int32u W3DI=0x57334449;
+ const int32u WAVE=0x57415645;
+ const int32u WAVE_data=0x64617461;
+ const int32u WAVE_ds64=0x64733634;
+}
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Riff::File_Riff()
+:File__Analyze()
+{
+ //Configuration
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Riff;
+ StreamIDs_Width[0]=4;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ Demux_EventWasSent_Accept_Specific=true;
+ #endif //MEDIAINFO_DEMUX
+ DataMustAlwaysBeComplete=false;
+
+ //In/Out
+ #if defined(MEDIAINFO_ANCILLARY_YES)
+ Ancillary=NULL;
+ #endif //defined(MEDIAINFO_ANCILLARY_YES)
+
+ //Data
+ Interleaved0_1=0;
+ Interleaved0_10=0;
+ Interleaved1_1=0;
+ Interleaved1_10=0;
+
+ //Temp
+ WAVE_data_Size=0xFFFFFFFF;
+ WAVE_fact_samplesCount=0xFFFFFFFF;
+ Buffer_DataToParse_Begin=(int64u)-1;
+ Buffer_DataToParse_End=0;
+ #if MEDIAINFO_DEMUX
+ AvgBytesPerSec=0;
+ #endif //!MEDIAINFO_DEMUX
+ avih_FrameRate=0;
+ avih_TotalFrame=0;
+ dmlh_TotalFrame=0;
+ Idx1_Offset=(int64u)-1;
+ movi_Size=0;
+ TimeReference=(int64u)-1;
+ SMV_BlockSize=0;
+ SamplesPerSec=0;
+ stream_Count=0;
+ rec__Present=false;
+ NeedOldIndex=true;
+ IsBigEndian=false;
+ IsWave64=false;
+ IsRIFF64=false;
+ IsWaveBroken=false;
+ IsNotWordAligned=false;
+ IsNotWordAligned_Tested=false;
+ SecondPass=false;
+ DV_FromHeader=NULL;
+ Kind=Kind_None;
+
+ //Pointers
+ Stream_Structure_Temp=Stream_Structure.end();
+}
+
+//---------------------------------------------------------------------------
+File_Riff::~File_Riff()
+{
+ #ifdef MEDIAINFO_DVDIF_YES
+ delete (File_DvDif*)DV_FromHeader; //DV_FromHeader=NULL
+ #endif //MEDIAINFO_DVDIF_YES
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Riff::Streams_Finish ()
+{
+ //Ancillary specific
+ if (Ancillary && (*Ancillary))
+ {
+ Finish(*Ancillary);
+ Merge(**Ancillary);
+ return;
+ }
+
+ //Global
+ if (IsRIFF64)
+ Fill(Stream_General, 0, General_Format_Profile, "RF64");
+
+ //For each stream
+ std::map<int32u, stream>::iterator Temp=Stream.begin();
+ while (Temp!=Stream.end())
+ {
+ //Preparing
+ StreamKind_Last=Temp->second.StreamKind;
+ StreamPos_Last=Temp->second.StreamPos;
+
+ //StreamSize
+ if (Temp->second.StreamSize>0)
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_StreamSize), Temp->second.StreamSize);
+
+ //Parser specific
+ if (Temp->second.Parsers.size()==1)
+ {
+ //Finalizing and Merging (except Video codec and 120 fps hack)
+ Temp->second.Parsers[0]->ShouldContinueParsing=false;
+
+ //Hack - Before
+ Ztring StreamSize, Codec_Temp;
+ if (StreamKind_Last==Stream_Video)
+ Codec_Temp=Retrieve(Stream_Video, StreamPos_Last, Video_Codec); //We want to keep the 4CC of AVI
+ StreamSize=Retrieve(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_StreamSize)); //We want to keep the 4CC of AVI
+
+ //Merging
+ if (Config_ParseSpeed<=1.0)
+ {
+ Fill(Temp->second.Parsers[0]);
+ Temp->second.Parsers[0]->Open_Buffer_Unsynch();
+ }
+ Finish(Temp->second.Parsers[0]);
+ Merge(*Temp->second.Parsers[0], StreamKind_Last, 0, StreamPos_Last);
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, ((Temp->first>>24)-'0')*10+(((Temp->first>>16)&0xFF)-'0'));
+
+ //Hacks - After
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_StreamSize), StreamSize, true);
+ if (StreamKind_Last==Stream_Video)
+ {
+ if (!Codec_Temp.empty())
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, Codec_Temp, true);
+
+ //120 fps hack
+ const Ztring &FrameRate=Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate);
+ if (FrameRate.To_int32u()==120)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_String, MediaInfoLib::Config.Language_Get(FrameRate+_T(" (24/30)"), _T(" fps")), true);
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Minimum, 24, 10, true);
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Maximum, 30, 10, true);
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Mode, "VFR");
+ }
+ }
+
+ //Alignment
+ if (StreamKind_Last==Stream_Audio && Count_Get(Stream_Video)>0) //Only if this is not a WAV file
+ {
+ Fill(Stream_Audio, StreamPos_Last, Audio_Alignment, Temp->second.ChunksAreComplete?"Aligned":"Split");
+ Fill(Stream_Audio, StreamPos_Last, Audio_Alignment_String, MediaInfoLib::Config.Language_Get(Temp->second.ChunksAreComplete?_T("Alignment_Aligned"):_T("Alignment_Split")));
+ }
+
+ //Delay
+ if (StreamKind_Last==Stream_Audio && Count_Get(Stream_Video)==1 && Temp->second.Rate!=0 && Temp->second.Parsers[0]->Status[IsAccepted])
+ {
+ float Delay=0;
+ bool Delay_IsValid=false;
+
+ if (Temp->second.Parsers[0]->Buffer_TotalBytes_FirstSynched==0)
+ {
+ Delay=0;
+ Delay_IsValid=true;
+ }
+ else if (Temp->second.Rate!=0)
+ {
+ Delay=((float)Temp->second.Parsers[0]->Buffer_TotalBytes_FirstSynched)*1000/Temp->second.Rate;
+ Delay_IsValid=true;
+ }
+ else if (Temp->second.Parsers[0]->Retrieve(Stream_Audio, 0, Audio_BitRate).To_int64u()!=0)
+ {
+ Delay=((float)Temp->second.Parsers[0]->Buffer_TotalBytes_FirstSynched)*1000/Temp->second.Parsers[0]->Retrieve(Stream_Audio, 0, Audio_BitRate).To_int64u();
+ Delay_IsValid=true;
+ }
+ else if (Temp->second.Parsers[0]->Retrieve(Stream_Audio, 0, Audio_BitRate_Nominal).To_int64u()!=0)
+ {
+ Delay=((float)Temp->second.Parsers[0]->Buffer_TotalBytes_FirstSynched)*1000/Temp->second.Parsers[0]->Retrieve(Stream_Audio, 0, Audio_BitRate_Nominal).To_int64u();
+ Delay_IsValid=true;
+ }
+
+ if (Delay_IsValid)
+ {
+ Delay+=((float)Temp->second.Start)*1000/Temp->second.Rate;
+ Fill(Stream_Audio, StreamPos_Last, Audio_Delay, Delay, 0, true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Delay_Source, "Stream", Unlimited, true, true);
+ for (size_t StreamPos=0; StreamPos<Count_Get(Stream_Video); StreamPos++)
+ Fill(Stream_Video, StreamPos, Video_Delay, 0, 10, true);
+ }
+ }
+
+ //Special case: AAC
+ if (StreamKind_Last==Stream_Audio
+ && (Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("AAC")
+ || Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("MPEG Audio")
+ || Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("Vorbis")))
+ Clear(Stream_Audio, StreamPos_Last, Audio_BitDepth); //Resolution is not valid for AAC / MPEG Audio / Vorbis
+
+ //Format specific
+ #if defined(MEDIAINFO_DVDIF_YES)
+ if (StreamKind_Last==Stream_Video && (MediaInfoLib::Config.Codec_Get(Ztring().From_CC4(Temp->second.Compression), InfoCodec_KindofCodec).find(_T("DV"))==0
+ || Retrieve(Stream_Video, StreamPos_Last, Video_Format)==_T("DV")
+ || Retrieve(Stream_Video, StreamPos_Last, Video_Codec)==_T("DV")))
+ {
+ if (Retrieve(Stream_General, 0, General_Recorded_Date).empty())
+ Fill(Stream_General, 0, General_Recorded_Date, Temp->second.Parsers[0]->Retrieve(Stream_General, 0, General_Recorded_Date));
+
+ //Video and Audio are together
+ size_t Audio_Count=Temp->second.Parsers[0]->Count_Get(Stream_Audio);
+ for (size_t Audio_Pos=0; Audio_Pos<Audio_Count; Audio_Pos++)
+ {
+ Fill_Flush();
+ Stream_Prepare(Stream_Audio);
+ size_t Pos=Count_Get(Stream_Audio)-1;
+ Merge(*Temp->second.Parsers[0], Stream_Audio, Audio_Pos, StreamPos_Last);
+ Fill(Stream_Audio, Pos, Audio_MuxingMode, "DV");
+ Fill(Stream_Audio, Pos, Audio_Duration, Retrieve(Stream_Video, Temp->second.StreamPos, Video_Duration));
+ Fill(Stream_Audio, Pos, "MuxingMode_MoreInfo", _T("Muxed in Video #")+Ztring().From_Number(Temp->second.StreamPos+1));
+ Fill(Stream_Audio, Pos, Audio_StreamSize_Encoded, 0); //Included in the DV stream size
+ Ztring ID=Retrieve(Stream_Audio, Pos, Audio_ID);
+ Fill(Stream_Audio, Pos, Audio_ID, Retrieve(Stream_Video, Temp->second.StreamPos, Video_ID)+_T("-")+ID, true);
+ }
+
+ StreamKind_Last=Stream_Video;
+ StreamPos_Last=Temp->second.StreamPos;
+ }
+ #endif
+ }
+ else if (StreamKind_Last!=Stream_General)
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, ((Temp->first>>24)-'0')*10+(((Temp->first>>16)&0xFF)-'0'));
+
+ //Duration
+ if (Temp->second.PacketCount>0)
+ {
+ if (StreamKind_Last==Stream_Video) // && Retrieve(Stream_Video, StreamPos_Last, Video_Duration).empty())
+ {
+ //Duration in case it is missing from header (malformed header...)
+ if (Temp->second.indx_Duration && Temp->second.Rate)
+ Fill(Stream_Video, StreamPos_Last, Video_Duration, ((float64)Temp->second.indx_Duration)*1000*Temp->second.Scale/Temp->second.Rate, 0, true);
+ else
+ Fill(Stream_Video, StreamPos_Last, Video_FrameCount, Temp->second.PacketCount, 10, true);
+ }
+ if (StreamKind_Last==Stream_Audio)
+ {
+ //Duration in case it is missing from header (malformed header...)
+ int64u SamplingCount=0;
+ #if defined(MEDIAINFO_MPEGA_YES)
+ if (Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("MPEG Audio"))
+ {
+ if (Temp->second.Parsers[0] && Temp->second.PacketPos==((File_Mpega*)Temp->second.Parsers[0])->Frame_Count_Valid) //Only for stream with one frame per chunk
+ {
+ Ztring Version=Retrieve(Stream_Audio, StreamPos_Last, Audio_Format_Version);
+ Ztring Layer=Retrieve(Stream_Audio, StreamPos_Last, Audio_Format_Profile);
+ if (Version==_T("Version 1") && Layer==_T("Layer 1"))
+ SamplingCount=Temp->second.PacketCount*384; //MPEG-1 Layer 1
+ else if ((Version==_T("Version 2") || Version==_T("Version 2.5")) && Layer==_T("Layer 1"))
+ SamplingCount=Temp->second.PacketCount*192; //MPEG-2 or 2.5 Layer 1
+ else if ((Version==_T("Version 2") || Version==_T("Version 2.5")) && Layer==_T("Layer 3"))
+ SamplingCount=Temp->second.PacketCount*576; //MPEG-2 or 2.5 Layer 3
+ else
+ SamplingCount=Temp->second.PacketCount*1152;
+ }
+ }
+ #endif
+ if (Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("PCM"))
+ {
+ int64u Resolution=Retrieve(Stream_Audio, StreamPos_Last, Audio_BitDepth).To_int64u();
+ int64u Channels=Retrieve(Stream_Audio, StreamPos_Last, Audio_Channel_s_).To_int64u();
+ if (Resolution>0 && Channels>0)
+ SamplingCount=Temp->second.StreamSize*8/Resolution/Channels;
+ }
+ if (Retrieve(Stream_Audio, StreamPos_Last, Audio_Format)==_T("ADPCM"))
+ {
+ int64u Resolution=Retrieve(Stream_Audio, StreamPos_Last, Audio_BitDepth).To_int64u();
+ int64u Channels=Retrieve(Stream_Audio, StreamPos_Last, Audio_Channel_s_).To_int64u();
+ if (Resolution>0 && Channels>0)
+ SamplingCount=(int64u)(Temp->second.StreamSize*8/Resolution/Channels*0.98); //0.98 is not precise!
+
+ //ADPCM estimation is not precise, if container sampling count is around our value, using it rather than the estimation
+ float32 SamplingRate=Retrieve(Stream_Audio, StreamPos_Last, Audio_SamplingRate).To_float32();
+ if (SamplingRate>0
+ && SamplingCount*1000/SamplingRate<((float32)avih_TotalFrame)/avih_FrameRate*1000*1.10
+ && SamplingCount*1000/SamplingRate>((float32)avih_TotalFrame)/avih_FrameRate*1000*0.10)
+ SamplingCount=0; //Value disabled
+ }
+ //One AC-3 frame is 32 ms
+ //One DTS frame is 21 ms
+
+ float32 SamplingRate=Retrieve(Stream_Audio, StreamPos_Last, Audio_SamplingRate).To_float32();
+ if (SamplingCount>0 && SamplingRate>0)
+ Fill(Stream_Audio, StreamPos_Last, Audio_Duration, SamplingCount*1000/SamplingRate, 0, true);
+ else if (Temp->second.indx_Duration && Temp->second.Rate)
+ Fill(Stream_Audio, StreamPos_Last, Audio_Duration, ((float64)Temp->second.indx_Duration)*1000*Temp->second.Scale/Temp->second.Rate, 0, true);
+ else if (Temp->second.Rate && Temp->second.Scale!=1) //Note: some files with Scale==1 are buggy
+ Fill(Stream_Audio, StreamPos_Last, Audio_Duration, ((float64)Temp->second.Length)*1000*Temp->second.Scale/Temp->second.Rate, 0, true);
+
+ //Interleave
+ if (Stream[0x30300000].PacketCount && Temp->second.PacketCount)
+ {
+ Fill(Stream_Audio, StreamPos_Last, "Interleave_VideoFrames", (float)Stream[0x30300000].PacketCount/Temp->second.PacketCount, 2);
+ if (Retrieve(Stream_Video, 0, Video_FrameRate).To_float32())
+ {
+ Fill(Stream_Audio, StreamPos_Last, "Interleave_Duration", (float)Stream[0x30300000].PacketCount/Temp->second.PacketCount*1000/Retrieve(Stream_Video, 0, Video_FrameRate).To_float32(), 0);
+ Ztring Interleave_Duration_String;
+ Interleave_Duration_String+=Retrieve(Stream_Audio, StreamPos_Last, "Interleave_Duration");
+ Interleave_Duration_String+=_T(" ");
+ Interleave_Duration_String+=MediaInfoLib::Config.Language_Get(_T("ms"));
+ if (!Retrieve(Stream_Audio, StreamPos_Last, "Interleave_VideoFrames").empty())
+ {
+ Interleave_Duration_String+=_T(" (");
+ Interleave_Duration_String+=MediaInfoLib::Config.Language_Get(Retrieve(Stream_Audio, StreamPos_Last, "Interleave_VideoFrames"), _T(" video frames"));
+ Interleave_Duration_String+=_T(")");
+ }
+ Fill(Stream_Audio, StreamPos_Last, "Interleave_Duration/String", Interleave_Duration_String);
+ }
+ int64u Audio_FirstBytes=0;
+ for (std::map<int64u, stream_structure>::iterator Stream_Structure_Temp=Stream_Structure.begin(); Stream_Structure_Temp!=Stream_Structure.end(); Stream_Structure_Temp++)
+ {
+ if (Stream_Structure_Temp->second.Name==0x30300000)
+ break;
+ if (Stream_Structure_Temp->second.Name==Temp->first)
+ Audio_FirstBytes+=Stream_Structure_Temp->second.Size;
+ }
+ if (Audio_FirstBytes && Retrieve(Stream_Audio, StreamPos_Last, Audio_BitRate).To_int32u())
+ {
+ Fill(Stream_Audio, StreamPos_Last, "Interleave_Preload", Audio_FirstBytes*1000/Temp->second.AvgBytesPerSec);
+ Fill(Stream_Audio, StreamPos_Last, "Interleave_Preload/String", Retrieve(Stream_Audio, StreamPos_Last, "Interleave_Preload")+_T(" ")+MediaInfoLib::Config.Language_Get(_T("ms")));
+ }
+ }
+ }
+
+ //Source duration
+ if (Temp->second.PacketCount && Temp->second.Length!=Temp->second.PacketCount)
+ {
+ if (StreamKind_Last==Stream_Video && Temp->second.Rate)
+ Fill(Stream_Video, StreamPos_Last, "Source_Duration", ((float64)Temp->second.PacketCount)*1000*Temp->second.Scale/Temp->second.Rate, 0);
+ if (StreamKind_Last==Stream_Audio && Temp->second.Rate)
+ {
+ float64 Duration_Source=((float64)Temp->second.StreamSize)*1000/Temp->second.AvgBytesPerSec;
+ float64 Duration_Header=Retrieve(Stream_Audio, StreamPos_Last, Audio_Duration).To_float64();
+ float64 Difference=Duration_Source-Duration_Header;
+ if (Difference<-2 || Difference>2) //+/- 2 ms
+ Fill(Stream_Audio, StreamPos_Last, "Source_Duration", Duration_Source, 0);
+ }
+ }
+ }
+
+ Temp++;
+ }
+
+ //Some work on the first video stream
+ if (Count_Get(Stream_Video))
+ {
+ //ODML
+ if (dmlh_TotalFrame!=0 && Retrieve(Stream_Video, 0, Video_Duration).empty())
+ for (size_t StreamPos=0; StreamPos<Count_Get(Stream_Video); StreamPos++)
+ Fill(Stream_Video, StreamPos, Video_FrameCount, dmlh_TotalFrame, 10, true);
+ }
+
+ //Rec
+ if (rec__Present)
+ Fill(Stream_General, 0, General_Format_Settings, "rec");
+
+ //Interleaved
+ if (Interleaved0_1 && Interleaved0_10 && Interleaved1_1 && Interleaved1_10)
+ Fill(Stream_General, 0, General_Interleaved, ((Interleaved0_1<Interleaved1_1 && Interleaved0_10>Interleaved1_1)
+ || (Interleaved1_1<Interleaved0_1 && Interleaved1_10>Interleaved0_1))?"Yes":"No");
+
+ //Time codes
+ TimeCode_Fill(_T("ISMP"), INFO_ISMP);
+ TimeCode_Fill(_T("tc_A"), Tdat_tc_A);
+ TimeCode_Fill(_T("tc_O"), Tdat_tc_O);
+
+ //MD5
+ size_t Pos=0;
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Count_Get((stream_t)StreamKind); StreamPos++)
+ if (Pos<MD5s.size())
+ {
+ Fill((stream_t)StreamKind, StreamPos, "MD5", MD5s[Pos]);
+ Pos++;
+ }
+
+ //Purge what is not needed anymore
+ if (!File_Name.empty()) //Only if this is not a buffer, with buffer we can have more data
+ {
+ Stream.clear();
+ Stream_Structure.clear();
+ delete DV_FromHeader; DV_FromHeader=NULL;
+ }
+
+ //Commercial names
+ if (Count_Get(Stream_Video)==1)
+ {
+ Streams_Finish_StreamOnly();
+ if (!Retrieve(Stream_Video, 0, Video_Format_Commercial_IfAny).empty())
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, Retrieve(Stream_Video, 0, Video_Format_Commercial_IfAny));
+ Fill(Stream_General, 0, General_Format_Commercial, _T("AVI ")+Retrieve(Stream_Video, 0, Video_Format_Commercial_IfAny));
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("DV"))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "DV");
+ Fill(Stream_General, 0, General_Format_Commercial, "AVI DV");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:2") && Retrieve(Stream_Video, 0, Video_BitRate)==_T("30000000"))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "MPEG IMX 30");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "MPEG IMX 30");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:2") && Retrieve(Stream_Video, 0, Video_BitRate)==_T("40000000"))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "MPEG IMX 40");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "MPEG IMX 40");
+ }
+ else if (Retrieve(Stream_Video, 0, Video_Format)==_T("MPEG Video") && Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)==_T("N=1") && Retrieve(Stream_Video, 0, Video_Colorimetry)==_T("4:2:2") && Retrieve(Stream_Video, 0, Video_BitRate)==_T("50000000"))
+ {
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, "MPEG IMX 50");
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "MPEG IMX 50");
+ }
+ }
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Riff::Read_Buffer_Init()
+{
+ #if MEDIAINFO_DEMUX
+ Demux_UnpacketizeContainer=Config->Demux_Unpacketize_Get();
+ Demux_Rate=Config->Demux_Rate_Get();
+ if (Demux_Rate==0)
+ Demux_Rate=25; //Default value
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_Riff::Read_Buffer_Seek (size_t Method, int64u Value, int64u /*ID*/)
+{
+ //Only Wave and AIFF
+ switch (Kind)
+ {
+ case Kind_Wave :
+ case Kind_Aiff :
+ break;
+ default : return (size_t)-1;
+ }
+
+ //Parsing
+ switch (Method)
+ {
+ case 0 :
+ if (Value<Buffer_DataToParse_Begin)
+ Value=Buffer_DataToParse_Begin;
+ if (Value>Buffer_DataToParse_End)
+ Value=Buffer_DataToParse_End;
+ GoTo(Value);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 1 :
+ GoTo(Buffer_DataToParse_Begin+(Buffer_DataToParse_End-Buffer_DataToParse_Begin)*Value/10000);
+ Open_Buffer_Unsynch();
+ return 1;
+ case 2 : //Timestamp
+ {
+ if (AvgBytesPerSec==0)
+ return (size_t)-1;
+
+ float64 ValueF=(float64)Value;
+ ValueF/=1000000000; //Value is in ns
+ ValueF*=AvgBytesPerSec;
+ GoTo(Buffer_DataToParse_Begin+float64_int64s(ValueF));
+ return 1;
+ }
+ case 3 : //FrameNumber
+ {
+ if (AvgBytesPerSec==0 || Demux_Rate==0 || BlockAlign==0)
+ return (size_t)-1;
+
+ float64 BytesPerFrame=AvgBytesPerSec/Demux_Rate;
+ int64u StreamOffset=(int64u)(Value*BytesPerFrame);
+ StreamOffset/=BlockAlign;
+ StreamOffset*=BlockAlign;
+
+ GoTo(Buffer_DataToParse_Begin+StreamOffset);
+ return 1;
+ }
+ default : return (size_t)-1; //Not supported
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//---------------------------------------------------------------------------
+void File_Riff::Read_Buffer_Unsynched()
+{
+ if (IsSub)
+ {
+ while(Element_Level)
+ Element_End0();
+
+ //Ancillary specific
+ if (Ancillary && (*Ancillary))
+ (*Ancillary)->Open_Buffer_Unsynch();
+ }
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Riff::Header_Begin()
+{
+ while (File_Offset+Buffer_Offset<Buffer_DataToParse_End)
+ {
+ #if MEDIAINFO_DEMUX
+ if (AvgBytesPerSec && Demux_Rate && BlockAlign)
+ {
+ float64 BytesPerFrame=((float64)AvgBytesPerSec)/Demux_Rate;
+ Frame_Count_NotParsedIncluded=float64_int64s(((float64)(File_Offset+Buffer_Offset-Buffer_DataToParse_Begin))/BytesPerFrame);
+ Element_Size=float64_int64s(BytesPerFrame*(Frame_Count_NotParsedIncluded+1));
+ Element_Size/=BlockAlign;
+ Element_Size*=BlockAlign;
+ Element_Size-=File_Offset+Buffer_Offset-Buffer_DataToParse_Begin;
+ FrameInfo.PTS=FrameInfo.DTS=float64_int64s(((float64)Frame_Count_NotParsedIncluded)*1000000000/Demux_Rate);
+ while (Element_Size && File_Offset+Buffer_Offset+Element_Size>Buffer_DataToParse_End)
+ Element_Size-=BlockAlign;
+ if (Element_Size==0)
+ Element_Size=BlockAlign;
+ if (Buffer_Offset+Element_Size>Buffer_Size)
+ return false;
+ }
+ else
+ #endif //MEDIAINFO_DEMUX
+ if (File_Offset+Buffer_Size<=Buffer_DataToParse_End)
+ Element_Size=Buffer_Size; //All the buffer is used
+ else
+ {
+ Element_Size=File_Offset+Buffer_Size-Buffer_DataToParse_End;
+ Buffer_DataToParse_End=0;
+ }
+
+ if (Buffer_Offset+(size_t)Element_Size>Buffer_Size)
+ return false;
+
+ Element_Begin0();
+ switch (Kind)
+ {
+ case Kind_Wave : WAVE_data_Continue(); break;
+ case Kind_Aiff : AIFF_SSND_Continue(); break;
+ case Kind_Rmp3 : RMP3_data_Continue(); break;
+ default : AVI__movi_xxxx();
+ }
+
+ if (Config_ParseSpeed<1.0 && File_Offset+Buffer_Offset+Element_Offset-Buffer_DataToParse_Begin>=0x10000)
+ {
+ Buffer_Offset=(size_t)(Buffer_DataToParse_End-File_Offset);
+ if (Buffer_Offset<Buffer_Size)
+ Element_Size=Buffer_Size-Buffer_Offset;
+ else
+ Element_Size=0;
+ }
+ else
+ {
+ Buffer_Offset+=(size_t)Element_Size;
+ Element_Size-=Element_Offset;
+ }
+ Element_Offset=0;
+ Element_End0();
+
+ if (Buffer_Offset>=Buffer_Size)
+ return false;
+
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_EventWasSent)
+ return false;
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::Header_Parse()
+{
+ //Special case : W3DI tags (unknown format!) are at the end of the file
+ if (Element_Level==2 && File_Offset+Buffer_Size==File_Size && Buffer_Size>8)
+ {
+ if (CC4(Buffer+Buffer_Size-4)==Elements::W3DI)
+ {
+ int32u Size=LittleEndian2int32u(Buffer+Buffer_Size-8);
+ if (Size>8 && Size<=Buffer_Size && Buffer_Offset+Size==Buffer_Size)
+ {
+ //Filling
+ Header_Fill_Code(Elements::W3DI, "W3DI");
+ Header_Fill_Size(Size);
+ return;
+ }
+ }
+ }
+
+ //Special case : SMV file detected
+ if (SMV_BlockSize)
+ {
+ //Filling
+ Header_Fill_Code(Elements::SMV0_xxxx, "SMV Block");
+ Header_Fill_Size(SMV_BlockSize);
+ return;
+ }
+
+ //Parsing
+ int32u Size, Name;
+ Get_C4 (Name, "Name");
+ if (Name==Elements::SMV0)
+ {
+ //SMV specific
+ //Filling
+ Header_Fill_Code(Elements::SMV0, "SMV header");
+ Header_Fill_Size(51);
+ return;
+ }
+ if (Name==Elements::riff)
+ IsWave64=true;
+ if (IsWave64)
+ {
+ //Wave64 specific
+ int64u Size_Complete;
+ Skip_XX(12, "Name (GUID)");
+ Get_L8 (Size_Complete, "Size");
+
+ //Alignment
+ if (Name!=Elements::riff && Size_Complete%8)
+ {
+ Alignement_ExtraByte=Size_Complete%8;
+ Size_Complete+=Alignement_ExtraByte; //Always 8-byte aligned
+ }
+ else
+ Alignement_ExtraByte=0;
+
+ //Top level chunks
+ if (Name==Elements::riff)
+ {
+ Get_C4 (Name, "Real Name");
+ Skip_XX(12, "Real Name (GUID)");
+ }
+
+ //Filling
+ Header_Fill_Code(Name, Ztring().From_CC4(Name));
+ Header_Fill_Size(Size_Complete);
+ return;
+ }
+ if (Name==Elements::FORM
+ || Name==Elements::MThd)
+ IsBigEndian=true; //Swap from Little to Big Endian for "FORM" files (AIFF...)
+ if (IsBigEndian)
+ Get_B4 (Size, "Size");
+ else
+ {
+ Get_L4 (Size, "Size");
+
+ //Testing malformed (not word aligned)
+ if (!IsNotWordAligned_Tested && Size%2)
+ {
+ if (File_Offset+Buffer_Offset+8+Size==File_Size)
+ IsNotWordAligned=true;
+ else if (!File_Name.empty())
+ {
+ File F(File_Name);
+ F.GoTo(File_Offset+Buffer_Offset+8+Size);
+ int8u Temp;
+ if (F.Read(&Temp, 1))
+ {
+ if (!((Temp<'A' || Temp>'z') && Temp!=' '))
+ IsNotWordAligned=true;
+ }
+ }
+ IsNotWordAligned_Tested=true;
+ }
+ }
+
+ //RF64
+ int64u Size_Complete=Size;
+ if (Size==0 && Name==Elements::RIFF)
+ Size_Complete=File_Size-8;
+ else if (Size==0xFFFFFFFF)
+ {
+ if (Element_Size<0x1C)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ if (Name==Elements::RF64 && CC4(Buffer+Buffer_Offset+0x0C)==Elements::WAVE_ds64)
+ {
+ Size_Complete=LittleEndian2int64u(Buffer+Buffer_Offset+0x14);
+ Param_Info1(Size_Complete);
+ }
+ else if (Name==Elements::WAVE_data)
+ {
+ Size_Complete=WAVE_data_Size;
+ Param_Info1(Size_Complete);
+ }
+ }
+
+ //Coherency
+ if (Stream_Structure_Temp!=Stream_Structure.end() && Stream_Structure_Temp->second.Size==0)
+ {
+ Name=(int32u)-1;
+ Size_Complete=0; //Hack in some indexes with Size==0 (why?), ignoring content of header
+ }
+ if (File_Offset+Buffer_Offset+8+Size_Complete>File_Size)
+ Size_Complete=File_Size-(File_Offset+Buffer_Offset+8);
+
+ //Alignment
+ if (Size_Complete%2 && !IsNotWordAligned)
+ {
+ Size_Complete++; //Always 2-byte aligned
+ Alignement_ExtraByte=1;
+ }
+ else
+ Alignement_ExtraByte=0;
+
+ //Top level chunks
+ if (Name==Elements::LIST
+ || Name==Elements::RIFF
+ || Name==Elements::RF64
+ || Name==Elements::ON2_
+ || Name==Elements::FORM)
+ {
+ if (Name==Elements::RF64)
+ IsRIFF64=true;
+ Get_C4 (Name, "Real Name");
+ }
+
+ //Integrity
+ if (Name==0x00000000)
+ {
+ //Filling
+ Header_Fill_Code(0, "Junk");
+ Header_Fill_Size(File_Size-(File_Offset+Buffer_Offset));
+ Alignement_ExtraByte=0;
+ return;
+ }
+
+ //Specific
+ if (Name==Elements::ON2f)
+ Name=Elements::AVI_;
+
+ //Filling
+ if (movi_Size && Size_Complete>movi_Size/2 && 8+Size_Complete>1024*1024 && !((Name&0xFFFF0000)==0x69780000 || (Name&0x0000FFFF)==0x00006978) && Element_Level==(rec__Present?(size_t)5:(size_t)4) && Buffer_Offset+8+Size_Complete>Buffer_Size)
+ {
+ Buffer_DataToParse_End=File_Offset+Buffer_Offset+8+Size_Complete;
+ Size_Complete=Buffer_Size-(Buffer_Offset+8);
+ }
+ if ((Name==Elements::WAVE_data || Name==Elements::AIFF_SSND))
+ {
+ Buffer_DataToParse_Begin=File_Offset+Buffer_Offset+8;
+ Buffer_DataToParse_End=File_Offset+Buffer_Offset+8+Size_Complete;
+ Size_Complete=0;
+ }
+
+ //Filling
+ Header_Fill_Code(Name, Ztring().From_CC4(Name));
+ if (Element_Level==2 && Name==Elements::WAVE && !IsRIFF64 && File_Size>0xFFFFFFFF)
+ IsWaveBroken=true; //Non standard big files detection
+ if (IsWaveBroken && (Name==Elements::WAVE || Name==Elements::WAVE_data))
+ Size_Complete=File_Size-(File_Offset+Buffer_Offset+8); //Non standard big files detection
+ Header_Fill_Size(Size_Complete+8);
+}
+
+//---------------------------------------------------------------------------
+bool File_Riff::BookMark_Needed()
+{
+ //Go to the first usefull chunk
+ if (stream_Count==0 && Stream_Structure.empty())
+ return false; //No need
+
+ Stream_Structure_Temp=Stream_Structure.begin();
+ if (!Stream_Structure.empty())
+ GoTo(Stream_Structure_Temp->first);
+ NeedOldIndex=false;
+ SecondPass=true;
+ Index_Pos.clear(); //We didn't succeed to find theses indexes :(
+ return true;
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Riff::TimeCode_Fill(const Ztring &Name, const Ztring &Value)
+{
+ float64 FrameRate=Retrieve(Stream_Video, 0, Video_FrameRate).To_float64();
+ if (Value.size()==11 && FrameRate)
+ {
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Count_Get((stream_t)StreamKind); StreamPos++)
+ {
+ int64u Delay=0;
+ Delay+=(Value[0]-_T('0'))*10*60*60*1000;
+ Delay+=(Value[1]-_T('0')) *60*60*1000;
+ Delay+=(Value[3]-_T('0')) *10*60*1000;
+ Delay+=(Value[4]-_T('0')) *60*1000;
+ Delay+=(Value[6]-_T('0')) *10*1000;
+ Delay+=(Value[7]-_T('0')) *1000;
+
+ int64u Frames=0;
+ Frames+=(Value[ 9]-_T('0'))*10;
+ Frames+=(Value[10]-_T('0'));
+ Delay+=float64_int64s((1000/FrameRate)*Frames);
+
+ Fill((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_Delay), Delay);
+ Fill((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_Delay_Source), _T("Container (")+Name+_T(")"));
+ Fill((stream_t)StreamKind, StreamPos, Fill_Parameter((stream_t)StreamKind, Generic_Delay_String4), Value);
+ }
+ }
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_RIFF_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff.h
new file mode 100644
index 000000000..2618ea04a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff.h
@@ -0,0 +1,328 @@
+// File_Riff - Info for RIFF files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about RIFF files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_RiffH
+#define MediaInfo_File_RiffH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#if defined(MEDIAINFO_ANCILLARY_YES)
+ #include <MediaInfo/Multiple/File_Ancillary.h>
+#endif //defined(MEDIAINFO_ANCILLARY_YES)
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Riff
+//***************************************************************************
+
+class File_Riff : public File__Analyze
+{
+public :
+ //In/Out
+ #if defined(MEDIAINFO_ANCILLARY_YES)
+ File_Ancillary** Ancillary;
+ #endif //defined(MEDIAINFO_ANCILLARY_YES)
+
+protected :
+ //Streams management
+ void Streams_Finish();
+
+public :
+ File_Riff();
+ ~File_Riff();
+
+private :
+ //Buffer - Global
+ void Read_Buffer_Init();
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Per element
+ bool Header_Begin();
+ void Header_Parse();
+ void Data_Parse();
+
+ bool BookMark_Needed();
+
+ //Data
+ struct stream
+ {
+ std::vector<File__Analyze*> Parsers;
+ int32u fccType;
+ int32u fccHandler;
+ int32u Scale;
+ int32u Rate;
+ int32u Start;
+ int32u Length;
+ int32u Compression;
+ stream_t StreamKind;
+ size_t StreamPos;
+ int32u AvgBytesPerSec;
+ size_t PacketPos;
+ size_t PacketCount;
+ int64u StreamSize;
+ int64u indx_Duration;
+ bool SearchingPayload;
+ bool Specific_IsMpeg4v;
+ bool ChunksAreComplete;
+
+ stream()
+ {
+ fccType=0x00000000;
+ fccHandler=0x00000000;
+ Scale=0;
+ Rate=0;
+ Start=0;
+ Length=0;
+ Compression=0x00000000;
+ StreamKind=Stream_Max;
+ StreamPos=0;
+ AvgBytesPerSec=0;
+ PacketPos=0;
+ PacketCount=0;
+ StreamSize=0;
+ indx_Duration=0;
+ SearchingPayload=true;
+ Specific_IsMpeg4v=false;
+ ChunksAreComplete=true;
+ }
+
+ ~stream()
+ {
+ for (size_t Pos=0; Pos<Parsers.size(); Pos++)
+ delete Parsers[Pos]; //Parser=NULL;
+ }
+ };
+ std::map<int32u, stream> Stream;
+ int32u Stream_ID;
+
+ struct stream_structure
+ {
+ int64u Name;
+ int64u Size;
+ };
+ std::map<int64u, stream_structure> Stream_Structure;
+ std::map<int64u, stream_structure>::iterator Stream_Structure_Temp;
+ std::map<int64u, int64u> Index_Pos;
+ int64u Interleaved0_1;
+ int64u Interleaved0_10;
+ int64u Interleaved1_1;
+ int64u Interleaved1_10;
+
+ //Temp
+ Ztring INFO_ISMP;
+ Ztring Tdat_tc_A;
+ Ztring Tdat_tc_O;
+ ZtringList MD5s;
+ int64u WAVE_data_Size; //RF64 WAVE_data real chunk size
+ int64u WAVE_fact_samplesCount; //RF64 WAVE_fact real samplesCount
+ int64u Alignement_ExtraByte; //Padding from the container
+ int64u Buffer_DataToParse_Begin;
+ int64u Buffer_DataToParse_End;
+ int32u AvgBytesPerSec;
+ int16u BlockAlign;
+ float64 Demux_Rate;
+ float64 avih_FrameRate; //FrameRate of the first video stream in one MOVI chunk
+ int32u avih_TotalFrame; //Count of frames in one MOVI chunk
+ int32u dmlh_TotalFrame; //Count of frames in the whole AVI file (with odml too)
+ int64u Idx1_Offset; //Pos of the data part (AVI) for Idx1 chunk
+ int64u movi_Size; //Size of the data part (AVI and AVIX)
+ int64u TimeReference; //Only used by Brodcast extension
+ int32u SMV_BlockSize; //Size of a SMV block, 0 if not SMV
+ int32u SMV_FrameCount; //Frame count of a SMV block, 0 if not SMV
+ int32u SamplesPerSec; //For bext
+ int16u BitsPerSample; //For PCM only
+ int8u stream_Count; //How many stream we have to parse
+ bool rec__Present; //True if synchro element is present
+ bool NeedOldIndex;
+ bool IsBigEndian;
+ bool IsWave64;
+ bool IsRIFF64;
+ bool IsWaveBroken;
+ bool IsNotWordAligned;
+ bool IsNotWordAligned_Tested;
+ bool SecondPass; //Second pass for streams
+ File__Analyze* DV_FromHeader;
+ enum kind
+ {
+ Kind_None,
+ Kind_Avi,
+ Kind_Wave,
+ Kind_Aiff,
+ Kind_Rmp3,
+ };
+ kind Kind;
+
+ void TimeCode_Fill(const Ztring &Name, const Ztring &Value);
+
+ //Chunks
+ void AIFC ();
+ void AIFC_COMM ();
+ void AIFC_COMT ();
+ void AIFC_FVER ();
+ void AIFC_SSND ();
+ void AIFF_SSND_Continue();
+ void AIFC_xxxx ();
+ void AIFF ();
+ void AIFF_COMM ();
+ void AIFF_COMT ();
+ void AIFF_ID3_ () {WAVE_ID3_();}
+ void AIFF_SSND ();
+ void AIFF_xxxx ();
+ void AVI_ ();
+ void AVI__cset ();
+ void AVI__Cr8r ();
+ void AVI__exif ();
+ void AVI__exif_xxxx ();
+ void AVI__goog ();
+ void AVI__goog_GDAT ();
+ void AVI__hdlr ();
+ void AVI__hdlr_avih ();
+ void AVI__hdlr_JUNK ();
+ void AVI__hdlr_strl ();
+ void AVI__hdlr_strl_indx ();
+ void AVI__hdlr_strl_indx_StandardIndex (int32u Entry_Count, int32u ChunkId);
+ void AVI__hdlr_strl_indx_FieldIndex (int32u Entry_Count, int32u ChunkId);
+ void AVI__hdlr_strl_indx_SuperIndex (int32u Entry_Count, int32u ChunkId);
+ void AVI__hdlr_strl_JUNK ();
+ void AVI__hdlr_strl_strd ();
+ void AVI__hdlr_strl_strf ();
+ void AVI__hdlr_strl_strf_auds ();
+ void AVI__hdlr_strl_strf_auds_Mpega();
+ void AVI__hdlr_strl_strf_auds_Aac();
+ void AVI__hdlr_strl_strf_auds_Vorbis();
+ void AVI__hdlr_strl_strf_auds_Vorbis2();
+ void AVI__hdlr_strl_strf_auds_ExtensibleWave();
+ void AVI__hdlr_strl_strf_iavs ();
+ void AVI__hdlr_strl_strf_mids ();
+ void AVI__hdlr_strl_strf_txts ();
+ void AVI__hdlr_strl_strf_vids ();
+ void AVI__hdlr_strl_strf_vids_Avc ();
+ void AVI__hdlr_strl_strh ();
+ void AVI__hdlr_strl_strn ();
+ void AVI__hdlr_strl_vprp ();
+ void AVI__hdlr_odml ();
+ void AVI__hdlr_odml_dmlh ();
+ void AVI__hdlr_ON2h ();
+ void AVI__hdlr_xxxx ();
+ void AVI__idx1 ();
+ void AVI__INFO ();
+ void AVI__INFO_IID3 ();
+ void AVI__INFO_ILYC ();
+ void AVI__INFO_IMP3 ();
+ void AVI__INFO_JUNK ();
+ void AVI__INFO_xxxx ();
+ void AVI__JUNK ();
+ void AVI__MD5_ ();
+ void AVI__movi ();
+ void AVI__movi_xxxx ();
+ void AVI__movi_xxxx___dc ();
+ void AVI__movi_xxxx___tx ();
+ void AVI__movi_xxxx___wb ();
+ void AVI__movi_rec_ ();
+ void AVI__movi_rec__xxxx ();
+ void AVI__movi_StreamJump ();
+ void AVI__PrmA ();
+ void AVI__Tdat ();
+ void AVI__Tdat_rn_A ();
+ void AVI__Tdat_rn_O ();
+ void AVI__Tdat_tc_A ();
+ void AVI__Tdat_tc_O ();
+ void AVI__GMET ();
+ void AVI__xxxx ();
+ void AVIX ();
+ void AVIX_idx1 ();
+ void AVIX_movi ();
+ void AVIX_movi_xxxx ();
+ void AVIX_movi_rec_ ();
+ void AVIX_movi_rec__xxxx ();
+ void CADP ();
+ void CDDA ();
+ void CDDA_fmt_ ();
+ void CMJP ();
+ void CMP4 ();
+ void IDVX ();
+ void INDX ();
+ void INDX_xxxx ();
+ void JUNK ();
+ void menu ();
+ void MThd ();
+ void MTrk ();
+ void PAL_ ();
+ void QLCM ();
+ void QLCM_fmt_ ();
+ #if defined(MEDIAINFO_GXF_YES)
+ void rcrd ();
+ void rcrd_desc ();
+ void rcrd_fld_ ();
+ void rcrd_fld__anc_ ();
+ void rcrd_fld__anc__pos_ ();
+ void rcrd_fld__anc__pyld ();
+ void rcrd_fld__finf ();
+ #endif //defined(MEDIAINFO_GXF_YES)
+ void RDIB ();
+ void RMID ();
+ void RMMP ();
+ void RMP3 ();
+ void RMP3_data ();
+ void RMP3_data_Continue();
+ void RMP3_INFO() {AVI__INFO();}
+ void RMP3_INFO_IID3() {AVI__INFO_IID3();}
+ void RMP3_INFO_ILYC() {AVI__INFO_ILYC();}
+ void RMP3_INFO_IMP3() {AVI__INFO_IMP3();}
+ void RMP3_INFO_JUNK() {AVI__INFO_JUNK ();}
+ void RMP3_INFO_xxxx() {AVI__INFO_xxxx ();}
+ void SMV0 ();
+ void SMV0_xxxx ();
+ void WAVE ();
+ void WAVE__pmx ();
+ void WAVE_aXML ();
+ void WAVE_bext ();
+ void WAVE_cue_ ();
+ void WAVE_data ();
+ void WAVE_data_Continue ();
+ void WAVE_ds64 ();
+ void WAVE_fact ();
+ void WAVE_fmt_ ();
+ void WAVE_ID3_ ();
+ void WAVE_id3_ () {WAVE_ID3_();}
+ void WAVE_INFO() {AVI__INFO();}
+ void WAVE_INFO_xxxx() {AVI__INFO_xxxx ();}
+ void WAVE_iXML ();
+ void wave ();
+ void wave_data () {WAVE_data();}
+ void wave_fmt_ () {WAVE_fmt_();}
+ void W3DI();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff_Elements.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff_Elements.cpp
new file mode 100644
index 000000000..45cb52f47
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Riff_Elements.cpp
@@ -0,0 +1,3538 @@
+// File_Riff - Info for RIFF files
+// Copyright (C) 2011-2011 Lionel Duchateau, kurtnoise@free.fr
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Elements part
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_RIFF_YES
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Riff.h"
+#if defined(MEDIAINFO_DVDIF_YES)
+ #include "MediaInfo/Multiple/File_DvDif.h"
+#endif
+#if defined(MEDIAINFO_OGG_YES)
+ #include "MediaInfo/Multiple/File_Ogg.h"
+ #include "MediaInfo/Multiple/File_Ogg_SubElement.h"
+#endif
+#if defined(MEDIAINFO_MPEG4V_YES)
+ #include "MediaInfo/Video/File_Mpeg4v.h"
+#endif
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_AVC_YES)
+ #include "MediaInfo/Video/File_Avc.h"
+#endif
+#if defined(MEDIAINFO_FRAPS_YES)
+ #include "MediaInfo/Video/File_Fraps.h"
+#endif
+#if defined(MEDIAINFO_LAGARITH_YES)
+ #include "MediaInfo/Video/File_Lagarith.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if defined(MEDIAINFO_AAC_YES)
+ #include "MediaInfo/Audio/File_Aac.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_AES3_YES)
+ #include "MediaInfo/Audio/File_Aes3.h"
+#endif
+#if defined(MEDIAINFO_DTS_YES)
+ #include "MediaInfo/Audio/File_Dts.h"
+#endif
+#if defined(MEDIAINFO_JPEG_YES)
+ #include "MediaInfo/Image/File_Jpeg.h"
+#endif
+#if defined(MEDIAINFO_OTHERTEXT_YES)
+ #include "MediaInfo/Text/File_OtherText.h"
+#endif
+#if defined(MEDIAINFO_ADPCM_YES)
+ #include "MediaInfo/Audio/File_Adpcm.h"
+#endif
+#if defined(MEDIAINFO_PCM_YES)
+ #include "MediaInfo/Audio/File_Pcm.h"
+#endif
+#if defined(MEDIAINFO_ID3_YES)
+ #include "MediaInfo/Tag/File_Id3.h"
+#endif
+#if defined(MEDIAINFO_ID3V2_YES)
+ #include "MediaInfo/Tag/File_Id3v2.h"
+#endif
+#if defined(MEDIAINFO_GXF_YES)
+ #if defined(MEDIAINFO_CDP_YES)
+ #include "MediaInfo/Text/File_Cdp.h"
+ #include <cstring>
+ #endif
+#endif //MEDIAINFO_GXF_YES
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+std::string ExtensibleWave_ChannelMask (int32u ChannelMask)
+{
+ std::string Text;
+ if ((ChannelMask&0x0007)!=0x0000)
+ Text+="Front:";
+ if (ChannelMask&0x0001)
+ Text+=" L";
+ if (ChannelMask&0x0004)
+ Text+=" C";
+ if (ChannelMask&0x0002)
+ Text+=" R";
+
+ if ((ChannelMask&0x0600)!=0x0000)
+ Text+=", Side:";
+ if (ChannelMask&0x0200)
+ Text+=" L";
+ if (ChannelMask&0x0400)
+ Text+=" R";
+
+ if ((ChannelMask&0x0130)!=0x0000)
+ Text+=", Back:";
+ if (ChannelMask&0x0010)
+ Text+=" L";
+ if (ChannelMask&0x0100)
+ Text+=" C";
+ if (ChannelMask&0x0020)
+ Text+=" R";
+
+ if ((ChannelMask&0x0008)!=0x0000)
+ Text+=", LFE";
+
+ return Text;
+}
+
+//---------------------------------------------------------------------------
+std::string ExtensibleWave_ChannelMask2 (int32u ChannelMask)
+{
+ std::string Text;
+ int8u Count=0;
+ if (ChannelMask&0x0001)
+ Count++;
+ if (ChannelMask&0x0004)
+ Count++;
+ if (ChannelMask&0x0002)
+ Count++;
+ Text+=Ztring::ToZtring(Count).To_UTF8();
+ Count=0;
+
+ if (ChannelMask&0x0200)
+ Count++;
+ if (ChannelMask&0x0400)
+ Count++;
+ Text+="/"+Ztring::ToZtring(Count).To_UTF8();
+ Count=0;
+
+ if (ChannelMask&0x0010)
+ Count++;
+ if (ChannelMask&0x0100)
+ Count++;
+ if (ChannelMask&0x0020)
+ Count++;
+ Text+="/"+Ztring::ToZtring(Count).To_UTF8();
+ Count=0;
+
+ if (ChannelMask&0x0008)
+ Text+=".1";
+
+ return Text;
+}
+
+//***************************************************************************
+// Const
+//***************************************************************************
+
+namespace Elements
+{
+ const int32u FORM=0x464F524D;
+ const int32u LIST=0x4C495354;
+ const int32u ON2_=0x4F4E3220;
+ const int32u RIFF=0x52494646;
+ const int32u RF64=0x52463634;
+
+ const int32u AIFC=0x41494643;
+ const int32u AIFC_COMM=0x434F4D4D;
+ const int32u AIFC_COMT=0x434F4D54;
+ const int32u AIFC_FVER=0x46564552;
+ const int32u AIFC_SSND=0x53534E44;
+ const int32u AIFF=0x41494646;
+ const int32u AIFF_COMM=0x434F4D4D;
+ const int32u AIFF_COMT=0x434F4D54;
+ const int32u AIFF_SSND=0x53534E44;
+ const int32u AIFF__c__=0x28632920;
+ const int32u AIFF_ANNO=0x414E4E4F;
+ const int32u AIFF_AUTH=0x41555448;
+ const int32u AIFF_NAME=0x4E414D45;
+ const int32u AIFF_ID3_=0x49443320;
+ const int32u AVI_=0x41564920;
+ const int32u AVI__cset=0x63736574;
+ const int32u AVI__Cr8r=0x43723872;
+ const int32u AVI__exif=0x65786966;
+ const int32u AVI__exif_ecor=0x65636F72;
+ const int32u AVI__exif_emdl=0x656D646C;
+ const int32u AVI__exif_emnt=0x656D6E74;
+ const int32u AVI__exif_erel=0x6572656C;
+ const int32u AVI__exif_etim=0x6574696D;
+ const int32u AVI__exif_eucm=0x6575636D;
+ const int32u AVI__exif_ever=0x65766572;
+ const int32u AVI__goog=0x676F6F67;
+ const int32u AVI__goog_GDAT=0x47444154;
+ const int32u AVI__GMET=0x474D4554;
+ const int32u AVI__hdlr=0x6864726C;
+ const int32u AVI__hdlr_avih=0x61766968;
+ const int32u AVI__hdlr_JUNK=0x4A554E4B;
+ const int32u AVI__hdlr_strl=0x7374726C;
+ const int32u AVI__hdlr_strl_indx=0x696E6478;
+ const int32u AVI__hdlr_strl_JUNK=0x4A554E4B;
+ const int32u AVI__hdlr_strl_strd=0x73747264;
+ const int32u AVI__hdlr_strl_strf=0x73747266;
+ const int32u AVI__hdlr_strl_strh=0x73747268;
+ const int32u AVI__hdlr_strl_strh_auds=0x61756473;
+ const int32u AVI__hdlr_strl_strh_iavs=0x69617673;
+ const int32u AVI__hdlr_strl_strh_mids=0x6D696473;
+ const int32u AVI__hdlr_strl_strh_vids=0x76696473;
+ const int32u AVI__hdlr_strl_strh_txts=0x74787473;
+ const int32u AVI__hdlr_strl_strn=0x7374726E;
+ const int32u AVI__hdlr_strl_vprp=0x76707270;
+ const int32u AVI__hdlr_odml=0x6F646D6C;
+ const int32u AVI__hdlr_odml_dmlh=0x646D6C68;
+ const int32u AVI__hdlr_ON2h=0x4F4E3268;
+ const int32u AVI__idx1=0x69647831;
+ const int32u AVI__INFO=0x494E464F;
+ const int32u AVI__INFO_IARL=0x4941524C;
+ const int32u AVI__INFO_IART=0x49415254;
+ const int32u AVI__INFO_IAS1=0x49415331;
+ const int32u AVI__INFO_IAS2=0x49415332;
+ const int32u AVI__INFO_IAS3=0x49415333;
+ const int32u AVI__INFO_IAS4=0x49415334;
+ const int32u AVI__INFO_IAS5=0x49415335;
+ const int32u AVI__INFO_IAS6=0x49415336;
+ const int32u AVI__INFO_IAS7=0x49415337;
+ const int32u AVI__INFO_IAS8=0x49415338;
+ const int32u AVI__INFO_IAS9=0x49415339;
+ const int32u AVI__INFO_ICDS=0x49434453;
+ const int32u AVI__INFO_ICMS=0x49434D53;
+ const int32u AVI__INFO_ICMT=0x49434D54;
+ const int32u AVI__INFO_ICNT=0x49434E54;
+ const int32u AVI__INFO_ICOP=0x49434F50;
+ const int32u AVI__INFO_ICNM=0x49434E4D;
+ const int32u AVI__INFO_ICRD=0x49435244;
+ const int32u AVI__INFO_ICRP=0x49435250;
+ const int32u AVI__INFO_IDIM=0x4944494D;
+ const int32u AVI__INFO_IDIT=0x49444954;
+ const int32u AVI__INFO_IDPI=0x49445049;
+ const int32u AVI__INFO_IDST=0x49445354;
+ const int32u AVI__INFO_IEDT=0x49454454;
+ const int32u AVI__INFO_IENG=0x49454E47;
+ const int32u AVI__INFO_IFRM=0x4946524D;
+ const int32u AVI__INFO_IGNR=0x49474E52;
+ const int32u AVI__INFO_IID3=0x49494433;
+ const int32u AVI__INFO_IKEY=0x494B4559;
+ const int32u AVI__INFO_ILGT=0x494C4754;
+ const int32u AVI__INFO_ILNG=0x494C4E47;
+ const int32u AVI__INFO_ILYC=0x494C5943;
+ const int32u AVI__INFO_IMED=0x494D4544;
+ const int32u AVI__INFO_IMP3=0x494D5033;
+ const int32u AVI__INFO_IMUS=0x494D5553;
+ const int32u AVI__INFO_INAM=0x494E414D;
+ const int32u AVI__INFO_IPLT=0x49504C54;
+ const int32u AVI__INFO_IPDS=0x49504453;
+ const int32u AVI__INFO_IPRD=0x49505244;
+ const int32u AVI__INFO_IPRT=0x49505254;
+ const int32u AVI__INFO_IPRO=0x4950524F;
+ const int32u AVI__INFO_IRTD=0x49525444;
+ const int32u AVI__INFO_ISBJ=0x4953424A;
+ const int32u AVI__INFO_ISGN=0x4953474E;
+ const int32u AVI__INFO_ISTD=0x49535444;
+ const int32u AVI__INFO_ISTR=0x49535452;
+ const int32u AVI__INFO_ISFT=0x49534654;
+ const int32u AVI__INFO_ISHP=0x49534850;
+ const int32u AVI__INFO_ISMP=0x49534D50;
+ const int32u AVI__INFO_ISRC=0x49535243;
+ const int32u AVI__INFO_ISRF=0x49535246;
+ const int32u AVI__INFO_ITCH=0x49544348;
+ const int32u AVI__INFO_IWEB=0x49574542;
+ const int32u AVI__INFO_IWRI=0x49575249;
+ const int32u AVI__INFO_JUNK=0x4A554E4B;
+ const int32u AVI__JUNK=0x4A554E4B;
+ const int32u AVI__MD5_=0x4D443520;
+ const int32u AVI__movi=0x6D6F7669;
+ const int32u AVI__movi_rec_=0x72656320;
+ const int32u AVI__movi_xxxx_____=0x00005F5F;
+ const int32u AVI__movi_xxxx___db=0x00006462;
+ const int32u AVI__movi_xxxx___dc=0x00006463;
+ const int32u AVI__movi_xxxx___sb=0x00007362;
+ const int32u AVI__movi_xxxx___tx=0x00007478;
+ const int32u AVI__movi_xxxx___wb=0x00007762;
+ const int32u AVI__PrmA=0x50726D41;
+ const int32u AVI__Tdat=0x54646174;
+ const int32u AVI__Tdat_rn_A=0x726E5F41;
+ const int32u AVI__Tdat_rn_O=0x726E5F4F;
+ const int32u AVI__Tdat_tc_A=0x74635F41;
+ const int32u AVI__Tdat_tc_O=0x74635F4F;
+ const int32u AVIX=0x41564958;
+ const int32u AVIX_idx1=0x69647831;
+ const int32u AVIX_movi=0x6D6F7669;
+ const int32u AVIX_movi_rec_=0x72656320;
+ const int32u CADP=0x43414450;
+ const int32u CDDA=0x43444441;
+ const int32u CDDA_fmt_=0x666D7420;
+ const int32u CMJP=0x434D4A50;
+ const int32u CMP4=0x434D5034;
+ const int32u IDVX=0x49445658;
+ const int32u INDX=0x494E4458;
+ const int32u JUNK=0x4A554E4B;
+ const int32u menu=0x6D656E75;
+ const int32u MThd=0x4D546864;
+ const int32u MTrk=0x4D54726B;
+ const int32u PAL_=0x50414C20;
+ const int32u QLCM=0x514C434D;
+ const int32u QLCM_fmt_=0x666D7420;
+ const int32u rcrd=0x72637264;
+ const int32u rcrd_desc=0x64657363;
+ const int32u rcrd_fld_=0x666C6420;
+ const int32u rcrd_fld__anc_=0x616E6320;
+ const int32u rcrd_fld__anc__pos_=0x706F7320;
+ const int32u rcrd_fld__anc__pyld=0x70796C64;
+ const int32u rcrd_fld__finf=0x66696E66;
+ const int32u RDIB=0x52444942;
+ const int32u RMID=0x524D4944;
+ const int32u RMMP=0x524D4D50;
+ const int32u RMP3=0x524D5033;
+ const int32u RMP3_data=0x64617461;
+ const int32u RMP3_INFO=0x494E464F;
+ const int32u RMP3_INFO_IID3=0x49494433;
+ const int32u RMP3_INFO_ILYC=0x494C5943;
+ const int32u RMP3_INFO_IMP3=0x494D5033;
+ const int32u RMP3_INFO_JUNK=0x4A554E4B;
+ const int32u SMV0=0x534D5630;
+ const int32u SMV0_xxxx=0x534D563A;
+ const int32u WAVE=0x57415645;
+ const int32u WAVE__pmx=0x20786D70;
+ const int32u WAVE_aXML=0x61584D4C;
+ const int32u WAVE_bext=0x62657874;
+ const int32u WAVE_cue_=0x63756520;
+ const int32u WAVE_data=0x64617461;
+ const int32u WAVE_ds64=0x64733634;
+ const int32u WAVE_fact=0x66616374;
+ const int32u WAVE_fmt_=0x666D7420;
+ const int32u WAVE_ID3_=0x49443320;
+ const int32u WAVE_id3_=0x69643320;
+ const int32u WAVE_INFO=0x494E464F;
+ const int32u WAVE_iXML=0x69584D4C;
+ const int32u wave=0x77617665;
+ const int32u wave_data=0x64617461;
+ const int32u wave_fmt_=0x666D7420;
+ const int32u W3DI=0x57334449;
+
+ #define UUID(NAME, PART1, PART2, PART3, PART4, PART5) \
+ const int64u NAME =0x##PART3##PART2##PART1##ULL; \
+ const int64u NAME##2=0x##PART4##PART5##ULL; \
+
+ UUID(QLCM_QCELP1, 5E7F6D41, B115, 11D0, BA91, 00805FB4B97E)
+ UUID(QLCM_QCELP2, 5E7F6D42, B115, 11D0, BA91, 00805FB4B97E)
+ UUID(QLCM_EVRC, E689D48D, 9076, 46B5, 91EF, 736A5100CEB4)
+ UUID(QLCM_SMV, 8D7C2B75, A797, ED49, 985E, D53C8CC75F84)
+}
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Riff::Data_Parse()
+{
+ //Alignement specific
+ Element_Size-=Alignement_ExtraByte;
+
+ DATA_BEGIN
+ LIST(AIFC)
+ ATOM_BEGIN
+ ATOM(AIFC_COMM)
+ ATOM(AIFC_COMT)
+ ATOM(AIFC_FVER)
+ ATOM(AIFC_SSND)
+ ATOM_DEFAULT(AIFC_xxxx)
+ ATOM_END_DEFAULT
+ LIST(AIFF)
+ ATOM_BEGIN
+ ATOM(AIFF_COMM)
+ ATOM(AIFF_COMT)
+ ATOM(AIFF_ID3_)
+ LIST_SKIP(AIFF_SSND)
+ ATOM_DEFAULT(AIFF_xxxx)
+ ATOM_END_DEFAULT
+ LIST(AVI_)
+ ATOM_BEGIN
+ ATOM(AVI__Cr8r);
+ ATOM(AVI__cset)
+ LIST(AVI__exif)
+ ATOM_DEFAULT_ALONE(AVI__exif_xxxx)
+ LIST(AVI__goog)
+ ATOM_BEGIN
+ ATOM(AVI__goog_GDAT)
+ ATOM_END
+ ATOM(AVI__GMET)
+ LIST(AVI__hdlr)
+ ATOM_BEGIN
+ ATOM(AVI__hdlr_avih)
+ ATOM(AVI__hdlr_JUNK)
+ LIST(AVI__hdlr_strl)
+ ATOM_BEGIN
+ ATOM(AVI__hdlr_strl_indx)
+ ATOM(AVI__hdlr_strl_JUNK)
+ ATOM(AVI__hdlr_strl_strd)
+ ATOM(AVI__hdlr_strl_strf)
+ ATOM(AVI__hdlr_strl_strh)
+ ATOM(AVI__hdlr_strl_strn)
+ ATOM(AVI__hdlr_strl_vprp)
+ ATOM_END
+ LIST(AVI__hdlr_odml)
+ ATOM_BEGIN
+ ATOM(AVI__hdlr_odml_dmlh)
+ ATOM_END
+ ATOM(AVI__hdlr_ON2h)
+ LIST(AVI__INFO)
+ ATOM_BEGIN
+ ATOM(AVI__INFO_IID3)
+ ATOM(AVI__INFO_ILYC)
+ ATOM(AVI__INFO_IMP3)
+ ATOM(AVI__INFO_JUNK)
+ ATOM_DEFAULT(AVI__INFO_xxxx)
+ ATOM_END_DEFAULT
+ ATOM_DEFAULT(AVI__hdlr_xxxx)
+ ATOM_END_DEFAULT
+ ATOM(AVI__idx1)
+ LIST(AVI__INFO)
+ ATOM_BEGIN
+ ATOM(AVI__INFO_IID3)
+ ATOM(AVI__INFO_ILYC)
+ ATOM(AVI__INFO_IMP3)
+ ATOM(AVI__INFO_JUNK)
+ ATOM_DEFAULT(AVI__INFO_xxxx)
+ ATOM_END_DEFAULT
+ ATOM(AVI__JUNK)
+ ATOM(AVI__MD5_)
+ LIST(AVI__movi)
+ ATOM_BEGIN
+ LIST(AVI__movi_rec_)
+ ATOM_DEFAULT_ALONE(AVI__movi_xxxx)
+ ATOM_DEFAULT(AVI__movi_xxxx)
+ ATOM_END_DEFAULT
+ ATOM(AVI__PrmA);
+ LIST(AVI__Tdat)
+ ATOM_BEGIN
+ ATOM(AVI__Tdat_rn_A)
+ ATOM(AVI__Tdat_rn_O)
+ ATOM(AVI__Tdat_tc_A)
+ ATOM(AVI__Tdat_tc_O)
+ ATOM_END
+ ATOM_DEFAULT(AVI__xxxx)
+ ATOM_END_DEFAULT
+ LIST(AVIX) //OpenDML
+ ATOM_BEGIN
+ ATOM(AVIX_idx1)
+ LIST(AVIX_movi)
+ ATOM_BEGIN
+ LIST(AVIX_movi_rec_)
+ ATOM_DEFAULT_ALONE(AVIX_movi_xxxx)
+ ATOM_DEFAULT(AVIX_movi_xxxx)
+ ATOM_END_DEFAULT
+ ATOM_END
+ ATOM_PARTIAL(CADP)
+ LIST(CDDA)
+ ATOM_BEGIN
+ ATOM(CDDA_fmt_)
+ ATOM_END
+ ATOM_PARTIAL(CMJP)
+ ATOM(CMP4)
+ ATOM(IDVX)
+ LIST(INDX)
+ ATOM_DEFAULT_ALONE(INDX_xxxx)
+ LIST_SKIP(JUNK)
+ LIST_SKIP(menu)
+ ATOM(MThd)
+ LIST_SKIP(MTrk)
+ LIST_SKIP(PAL_)
+ LIST(QLCM)
+ ATOM_BEGIN
+ ATOM(QLCM_fmt_)
+ ATOM_END
+ #if defined(MEDIAINFO_GXF_YES)
+ LIST(rcrd)
+ ATOM_BEGIN
+ ATOM(rcrd_desc)
+ LIST(rcrd_fld_)
+ ATOM_BEGIN
+ LIST(rcrd_fld__anc_)
+ ATOM_BEGIN
+ ATOM(rcrd_fld__anc__pos_)
+ ATOM(rcrd_fld__anc__pyld)
+ ATOM_END
+ ATOM(rcrd_fld__finf)
+ ATOM_END
+ ATOM_END
+ #endif //defined(MEDIAINFO_GXF_YES)
+ LIST_SKIP(RDIB)
+ LIST_SKIP(RMID)
+ LIST_SKIP(RMMP)
+ LIST(RMP3)
+ ATOM_BEGIN
+ LIST(RMP3_data)
+ break;
+ LIST(RMP3_INFO)
+ ATOM_BEGIN
+ ATOM(RMP3_INFO_IID3)
+ ATOM(RMP3_INFO_ILYC)
+ ATOM(RMP3_INFO_IMP3)
+ ATOM(RMP3_INFO_JUNK)
+ ATOM_DEFAULT(RMP3_INFO_xxxx)
+ ATOM_END_DEFAULT
+ ATOM_END
+ ATOM(SMV0)
+ ATOM(SMV0_xxxx)
+ ATOM(W3DI)
+ LIST(WAVE)
+ ATOM_BEGIN
+ ATOM(WAVE__pmx)
+ ATOM(WAVE_aXML)
+ ATOM(WAVE_bext)
+ LIST(WAVE_data)
+ break;
+ ATOM(WAVE_cue_)
+ ATOM(WAVE_ds64)
+ ATOM(WAVE_fact)
+ ATOM(WAVE_fmt_)
+ ATOM(WAVE_ID3_)
+ ATOM(WAVE_id3_)
+ LIST(WAVE_INFO)
+ ATOM_DEFAULT_ALONE(WAVE_INFO_xxxx)
+ ATOM(WAVE_iXML)
+ ATOM_END
+ LIST(wave)
+ ATOM_BEGIN
+ LIST(wave_data)
+ break;
+ ATOM(wave_fmt_)
+ ATOM_END
+ DATA_END
+
+ if (Alignement_ExtraByte)
+ {
+ Element_Size+=Alignement_ExtraByte;
+ if (Element_Offset+Alignement_ExtraByte==Element_Size)
+ Skip_XX(Alignement_ExtraByte, "Alignement");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFC()
+{
+ Data_Accept("AIFF Compressed");
+ Element_Name("AIFF Compressed");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "AIFF");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFC_COMM()
+{
+ AIFF_COMM();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFC_COMT()
+{
+ AIFF_COMT();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFC_FVER()
+{
+ Element_Name("Format Version");
+
+ //Parsing
+ Skip_B4( "Version");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFC_SSND()
+{
+ AIFF_SSND();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFC_xxxx()
+{
+ AIFF_xxxx();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFF()
+{
+ Data_Accept("AIFF");
+ Element_Name("AIFF");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "AIFF");
+ Kind=Kind_Aiff;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFF_COMM()
+{
+ Element_Name("Common");
+ Stream_Prepare(Stream_Audio);
+
+ int32u numSampleFrames;
+ int16u numChannels, sampleSize;
+ float80 sampleRate;
+ //Parsing
+ Get_B2 (numChannels, "numChannels");
+ Get_B4 (numSampleFrames, "numSampleFrames");
+ Get_B2 (sampleSize, "sampleSize");
+ Get_BF10(sampleRate, "sampleRate");
+ if (Data_Remain()) //AIFC
+ {
+ int32u compressionType;
+ Get_C4 (compressionType, "compressionType");
+ Skip_PA( "compressionName");
+
+ //Filling
+ CodecID_Fill(Ztring().From_CC4(compressionType), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Mpeg4);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Ztring().From_CC4(compressionType));
+ }
+ else
+ {
+ //Filling
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format, "PCM");
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, "PCM");
+ }
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate_Mode, "CBR");
+
+ //Filling
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, numChannels);
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, sampleSize);
+ if (sampleRate)
+ Fill(Stream_Audio, StreamPos_Last, Audio_Duration, numSampleFrames/sampleRate*1000);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, sampleRate, 0);
+
+ BlockAlign=numChannels*sampleSize/8;
+ AvgBytesPerSec=(int32u)float64_int64s(BlockAlign*(float64)sampleRate);
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFF_COMT()
+{
+ //Parsing
+ int16u numComments;
+ Get_B2(numComments, "numComments");
+ for (int16u Pos=0; Pos<=numComments; Pos++)
+ {
+ Ztring text;
+ int16u count;
+ Element_Begin1("Comment");
+ Skip_B4( "timeStamp");
+ Skip_B4( "marker");
+ Get_B2 (count, "count");
+ count+=count%1; //always even
+ Get_Local(count, text, "text");
+ Element_End0();
+
+ //Filling
+ Fill(Stream_General, 0, General_Comment, text);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFF_SSND()
+{
+ Element_Name("Sound Data");
+
+ Skip_XX(Buffer_DataToParse_End-Buffer_DataToParse_Begin, "Data");
+
+ //Filling
+ Fill(Stream_Audio, 0, Audio_StreamSize, Buffer_DataToParse_End-Buffer_DataToParse_Begin);
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, "Big");
+
+ #if MEDIAINFO_DEMUX
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ Config->Demux_EventWasSent=true; //First set is to indicate the user that header is parsed
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFF_SSND_Continue()
+{
+ #if MEDIAINFO_DEMUX
+ if (Element_Size)
+ {
+ Demux_random_access=true;
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ }
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AIFF_xxxx()
+{
+ #define ELEMENT_CASE(_ELEMENT, _NAME) \
+ case Elements::_ELEMENT : Element_Name(_NAME); Name=_NAME; break;
+
+ //Known?
+ std::string Name;
+ switch(Element_Code)
+ {
+ ELEMENT_CASE(AIFF__c__, "Copyright");
+ ELEMENT_CASE(AIFF_ANNO, "Comment");
+ ELEMENT_CASE(AIFF_AUTH, "Performer");
+ ELEMENT_CASE(AIFF_NAME, "Title");
+ default : Skip_XX(Element_Size, "Unknown");
+ return;
+ }
+
+ //Parsing
+ Ztring text;
+ Get_Local(Element_Size, text, "text");
+
+ //Filling
+ Fill(Stream_General, 0, Name.c_str(), text);
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI_()
+{
+ Element_Name("AVI");
+
+ //Test if there is only one AVI chunk
+ if (Status[IsAccepted])
+ {
+ Element_Info1("Problem: 2 AVI chunks, this is not normal");
+ Skip_XX(Element_TotalSize_Get(), "Data");
+ return;
+ }
+
+ Data_Accept("AVI");
+ Buffer_MaximumSize*=16;
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "AVI");
+ Kind=Kind_Avi;
+
+ //Configuring
+ Buffer_MaximumSize=32*1024*1024;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__Cr8r()
+{
+ Element_Name("Adobe Premiere Cr8r");
+
+ //Parsing
+ Skip_C4( "FourCC");
+ Skip_B4( "Size");
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__cset()
+{
+ Element_Name("Regional settings");
+
+ //Parsing
+ Skip_L2( "CodePage"); //TODO: take a look about IBM/MS RIFF/MCI Specification 1.0
+ Skip_L2( "CountryCode");
+ Skip_L2( "LanguageCode");
+ Skip_L2( "Dialect");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__exif()
+{
+ Element_Name("Exif (Exchangeable Image File Format)");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__exif_xxxx()
+{
+ Element_Name("Value");
+
+ //Parsing
+ Ztring Value;
+ Get_Local(Element_Size, Value, "Value");
+
+ //Filling
+ switch (Element_Code)
+ {
+ case Elements::AVI__exif_ecor : Fill(Stream_General, 0, "Make", Value); break;
+ case Elements::AVI__exif_emdl : Fill(Stream_General, 0, "Model", Value); break;
+ case Elements::AVI__exif_emnt : Fill(Stream_General, 0, "MakerNotes", Value); break;
+ case Elements::AVI__exif_erel : Fill(Stream_General, 0, "RelatedImageFile", Value); break;
+ case Elements::AVI__exif_etim : Fill(Stream_General, 0, "Written_Date", Value); break;
+ case Elements::AVI__exif_eucm : Fill(Stream_General, 0, General_Comment, Value); break;
+ case Elements::AVI__exif_ever : break; //Exif version
+ default: Fill(Stream_General, 0, Ztring().From_CC4((int32u)Element_Code).To_Local().c_str(), Value);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__goog()
+{
+ Element_Name("Google specific");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "Google Video", Unlimited, false, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__goog_GDAT()
+{
+ Element_Name("Google datas");
+}
+
+//---------------------------------------------------------------------------
+// Google Metadata
+//
+void File_Riff::AVI__GMET()
+{
+ Element_Name("Google Metadatas");
+
+ //Parsing
+ Ztring Value; Value.From_Local((const char*)(Buffer+Buffer_Offset+0), (size_t)Element_Size);
+ ZtringListList List;
+ List.Separator_Set(0, _T("\n"));
+ List.Separator_Set(1, _T(":"));
+ List.Max_Set(1, 2);
+ List.Write(Value);
+
+ //Details
+ #if MEDIAINFO_TRACE
+ if (Config_Trace_Level)
+ {
+ //for (size_t Pos=0; Pos<List.size(); Pos++)
+ // Details_Add_Info(Pos, List(Pos, 0).To_Local().c_str(), List(Pos, 1));
+ }
+ #endif //MEDIAINFO_TRACE
+
+ //Filling
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ if (List(Pos, 0)==_T("title")) Fill(Stream_General, 0, General_Title, List(Pos, 1));
+ if (List(Pos, 0)==_T("description")) Fill(Stream_General, 0, General_Title_More, List(Pos, 1));
+ if (List(Pos, 0)==_T("url")) Fill(Stream_General, 0, General_Title_Url, List(Pos, 1));
+ if (List(Pos, 0)==_T("docid")) Fill(Stream_General, 0, General_UniqueID, List(Pos, 1));
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr()
+{
+ Element_Name("AVI Header");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_avih()
+{
+ Element_Name("File header");
+
+ //Parsing
+ int32u MicrosecPerFrame, Flags;
+ Get_L4 (MicrosecPerFrame, "MicrosecPerFrame");
+ Skip_L4( "MaxBytesPerSec");
+ Skip_L4( "PaddingGranularity");
+ Get_L4 (Flags, "Flags");
+ Skip_Flags(Flags, 4, "HasIndex");
+ Skip_Flags(Flags, 5, "MustUseIndex");
+ Skip_Flags(Flags, 8, "IsInterleaved");
+ Skip_Flags(Flags, 9, "UseCKTypeToFindKeyFrames");
+ Skip_Flags(Flags, 11, "TrustCKType");
+ Skip_Flags(Flags, 16, "WasCaptureFile");
+ Skip_Flags(Flags, 17, "Copyrighted");
+ Get_L4 (avih_TotalFrame, "TotalFrames");
+ Skip_L4( "InitialFrames");
+ Skip_L4( "StreamsCount");
+ Skip_L4( "SuggestedBufferSize");
+ Skip_L4( "Width");
+ Skip_L4( "Height");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ if(Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+
+ //Filling
+ if (MicrosecPerFrame>0)
+ avih_FrameRate=1000000.0/MicrosecPerFrame;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_JUNK()
+{
+ Element_Name("Garbage");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_odml()
+{
+ Element_Name("OpenDML");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_odml_dmlh()
+{
+ Element_Name("OpenDML Header");
+
+ //Parsing
+ Get_L4(dmlh_TotalFrame, "GrandFrames");
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_ON2h()
+{
+ Element_Name("On2 header");
+
+ //Parsing
+ Skip_XX(Element_Size, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl()
+{
+ Element_Name("Stream info");
+ Element_Info1(stream_Count);
+
+ //Clean up
+ StreamKind_Last=Stream_Max;
+ StreamPos_Last=(size_t)-1;
+
+ //Compute the current codec ID
+ Stream_ID=(('0'+stream_Count/10)*0x01000000
+ +('0'+stream_Count )*0x00010000);
+ stream_Count++;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_indx()
+{
+ Element_Name("Index");
+
+ int32u Entry_Count, ChunkId;
+ int16u LongsPerEntry;
+ int8u IndexType, IndexSubType;
+ Get_L2 (LongsPerEntry, "LongsPerEntry"); //Size of each entry in aIndex array
+ Get_L1 (IndexSubType, "IndexSubType");
+ Get_L1 (IndexType, "IndexType");
+ Get_L4 (Entry_Count, "EntriesInUse"); //Index of first unused member in aIndex array
+ Get_C4 (ChunkId, "ChunkId"); //FCC of what is indexed
+
+ //Depends of size of structure...
+ switch (IndexType)
+ {
+ case 0x01 : //AVI_INDEX_OF_CHUNKS
+ switch (IndexSubType)
+ {
+ case 0x00 : AVI__hdlr_strl_indx_StandardIndex(Entry_Count, ChunkId); break;
+ case 0x01 : AVI__hdlr_strl_indx_FieldIndex(Entry_Count, ChunkId); break; //AVI_INDEX_2FIELD
+ default: Skip_XX(Element_Size-Element_Offset, "Unknown");
+ }
+ break;
+ case 0x0 : //AVI_INDEX_OF_INDEXES
+ switch (IndexSubType)
+ {
+ case 0x00 :
+ case 0x01 : AVI__hdlr_strl_indx_SuperIndex(Entry_Count, ChunkId); break; //AVI_INDEX_2FIELD
+ default: Skip_XX(Element_Size-Element_Offset, "Unknown");
+ }
+ break;
+ default: Skip_XX(Element_Size-Element_Offset, "Unknown");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_indx_StandardIndex(int32u Entry_Count, int32u ChunkId)
+{
+ Element_Name("Standard Index");
+
+ //Parsing
+ int64u BaseOffset, StreamSize=0;
+ Get_L8 (BaseOffset, "BaseOffset");
+ Skip_L4( "Reserved3");
+ for (int32u Pos=0; Pos<Entry_Count; Pos++)
+ {
+ //Is too slow
+ /*
+ Element_Begin1("Index");
+ int32u Offset, Size;
+ Get_L4 (Offset, "Offset"); //BaseOffset + this is absolute file offset
+ Get_L4 (Size, "Size"); //Bit 31 is set if this is NOT a keyframe
+ Element_Info1(Size&0x7FFFFFFF);
+ if (Size)
+ Element_Info1("KeyFrame");
+ Element_End0();
+ */
+
+ //Faster method
+ if (Element_Offset+8>Element_Size)
+ break; //Malformed index
+ int32u Offset=LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset );
+ int32u Size =LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset+4)&0x7FFFFFFF;
+ Element_Offset+=8;
+
+ //Stream Position and size
+ if (Pos<300 || MediaInfoLib::Config.ParseSpeed_Get()==1.00)
+ {
+ Stream_Structure[BaseOffset+Offset-8].Name=ChunkId&0xFFFF0000;
+ Stream_Structure[BaseOffset+Offset-8].Size=Size;
+ }
+ StreamSize+=(Size&0x7FFFFFFF);
+ Stream[ChunkId&0xFFFF0000].PacketCount++;
+
+ //Interleaved
+ if (Pos== 0 && (ChunkId&0xFFFF0000)==0x30300000 && Interleaved0_1 ==0)
+ Interleaved0_1 =BaseOffset+Offset-8;
+ if (Pos==Entry_Count/10 && (ChunkId&0xFFFF0000)==0x30300000 && Interleaved0_10==0)
+ Interleaved0_10=BaseOffset+Offset-8;
+ if (Pos== 0 && (ChunkId&0xFFFF0000)==0x30310000 && Interleaved1_1 ==0)
+ Interleaved1_1 =BaseOffset+Offset-8;
+ if (Pos==Entry_Count/10 && (ChunkId&0xFFFF0000)==0x30310000 && Interleaved1_10==0)
+ Interleaved1_10=BaseOffset+Offset-8;
+ }
+ Stream[ChunkId&0xFFFF0000].StreamSize+=StreamSize;
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Garbage");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_indx_FieldIndex(int32u Entry_Count, int32u)
+{
+ Element_Name("Field Index");
+
+ //Parsing
+ Skip_L8( "Offset");
+ Skip_L4( "Reserved2");
+ for (int32u Pos=0; Pos<Entry_Count; Pos++)
+ {
+ Element_Begin1("Index");
+ Skip_L4( "Offset"); //BaseOffset + this is absolute file offset
+ Skip_L4( "Size"); //Bit 31 is set if this is NOT a keyframe
+ Skip_L4( "OffsetField2"); //Offset to second field
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_indx_SuperIndex(int32u Entry_Count, int32u ChunkId)
+{
+ Element_Name("Index of Indexes");
+
+ //Parsing
+ int64u Offset;
+ Skip_L4( "Reserved0");
+ Skip_L4( "Reserved1");
+ Skip_L4( "Reserved2");
+ for (int32u Pos=0; Pos<Entry_Count; Pos++)
+ {
+ int32u Duration;
+ Element_Begin1("Index of Indexes");
+ Get_L8 (Offset, "Offset");
+ Skip_L4( "Size"); //Size of index chunk at this offset
+ Get_L4 (Duration, "Duration"); //time span in stream ticks
+ Index_Pos[Offset]=ChunkId;
+ Stream[Stream_ID].indx_Duration+=Duration;
+ Element_End0();
+ }
+
+ //We needn't anymore Old version
+ NeedOldIndex=false;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_JUNK()
+{
+ Element_Name("Garbage");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strd()
+{
+ Element_Name("Stream datas");
+
+ //Parsing
+ Skip_XX(Element_Size, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf()
+{
+ Element_Name("Stream format");
+
+ //Parse depending of kind of stream
+ switch (Stream[Stream_ID].fccType)
+ {
+ case Elements::AVI__hdlr_strl_strh_auds : AVI__hdlr_strl_strf_auds(); break;
+ case Elements::AVI__hdlr_strl_strh_iavs : AVI__hdlr_strl_strf_iavs(); break;
+ case Elements::AVI__hdlr_strl_strh_mids : AVI__hdlr_strl_strf_mids(); break;
+ case Elements::AVI__hdlr_strl_strh_txts : AVI__hdlr_strl_strf_txts(); break;
+ case Elements::AVI__hdlr_strl_strh_vids : AVI__hdlr_strl_strf_vids(); break;
+ default : Element_Info1("Unknown");
+ }
+
+ //Registering stream
+ Stream[Stream_ID].StreamKind=StreamKind_Last;
+ Stream[Stream_ID].StreamPos=StreamPos_Last;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf_auds()
+{
+ Element_Info1("Audio");
+
+ //Parsing
+ #if !MEDIAINFO_DEMUX
+ int32u AvgBytesPerSec;
+ #endif //!MEDIAINFO_DEMUX
+ int16u FormatTag, Channels;
+ BitsPerSample=0;
+ Get_L2 (FormatTag, "FormatTag");
+ Get_L2 (Channels, "Channels");
+ Get_L4 (SamplesPerSec, "SamplesPerSec");
+ Get_L4 (AvgBytesPerSec, "AvgBytesPerSec");
+ #if MEDIAINFO_DEMUX
+ Get_L2 (BlockAlign, "BlockAlign");
+ #else //MEDIAINFO_DEMUX
+ Skip_L2( "BlockAlign");
+ #endif //MEDIAINFO_DEMUX
+ if (Element_Offset+2<=Element_Size)
+ Get_L2 (BitsPerSample, "BitsPerSample");
+
+ //Coherency
+ if (Channels==0 || SamplesPerSec==0 || AvgBytesPerSec==0)
+ return;
+
+ //Filling
+ Stream_Prepare(Stream_Audio);
+ Stream[Stream_ID].Compression=FormatTag;
+ Ztring Codec; Codec.From_Number(FormatTag, 16);
+ Codec.MakeUpperCase();
+ CodecID_Fill(Codec, Stream_Audio, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Codec); //May be replaced by codec parser
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec_CC, Codec);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, (Channels!=5 || FormatTag==0xFFFE)?Channels:6);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, SamplesPerSec);
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate, AvgBytesPerSec*8);
+ if (BitsPerSample)
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, BitsPerSample);
+ Stream[Stream_ID].AvgBytesPerSec=AvgBytesPerSec; //Saving bitrate for each stream
+ if (SamplesPerSec && TimeReference!=(int64u)-1)
+ {
+ Fill(Stream_Audio, 0, Audio_Delay, float64_int64s(((float64)TimeReference)*1000/SamplesPerSec));
+ Fill(Stream_Audio, 0, Audio_Delay_Source, "Container (bext)");
+ }
+
+ //Creating the parser
+ if (0);
+ #if defined(MEDIAINFO_MPEGA_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Riff, Codec)==_T("MPEG Audio"))
+ {
+ File_Mpega* Parser=new File_Mpega;
+ Parser->CalculateDelay=true;
+ Parser->ShouldContinueParsing=true;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ #endif
+ #if defined(MEDIAINFO_AC3_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Riff, Codec)==_T("AC-3"))
+ {
+ File_Ac3* Parser=new File_Ac3;
+ Parser->Frame_Count_Valid=2;
+ Parser->CalculateDelay=true;
+ Parser->ShouldContinueParsing=true;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ #endif
+ #if defined(MEDIAINFO_DTS_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Riff, Codec)==_T("DTS")
+ || (FormatTag==0x1 && Retrieve(Stream_General, 0, General_Format)==_T("Wave"))) //Some DTS streams are coded "1"
+ {
+ {
+ File_Dts* Parser=new File_Dts;
+ Parser->Frame_Count_Valid=2;
+ Parser->ShouldContinueParsing=true;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+
+ {
+ File_Aes3* Parser=new File_Aes3;
+ Parser->SampleRate=SamplesPerSec;
+ Parser->ByteSize=AvgBytesPerSec/SamplesPerSec;
+ Parser->QuantizationBits=AvgBytesPerSec*8/SamplesPerSec/Channels;
+ Parser->ShouldContinueParsing=true;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ }
+ #endif
+ #if defined(MEDIAINFO_AAC_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Riff, Codec)==_T("AAC"))
+ {
+ File_Aac* Parser=new File_Aac;
+ Parser->Mode=File_Aac::Mode_ADTS;
+ Parser->Frame_Count_Valid=1;
+ Parser->ShouldContinueParsing=true;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ #endif
+ #if defined(MEDIAINFO_PCM_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Riff, Codec)==_T("PCM"))
+ {
+ //Creating the parser
+ File_Pcm MI;
+ MI.Codec=Codec;
+ MI.BitDepth=BitsPerSample;
+
+ //Parsing
+ Open_Buffer_Init(&MI);
+ Open_Buffer_Continue(&MI, 0);
+
+ //Filling
+ Finish(&MI);
+ Merge(MI, StreamKind_Last, 0, StreamPos_Last);
+ }
+ #endif
+ #if defined(MEDIAINFO_ADPCM_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Riff, Codec)==_T("ADPCM"))
+ {
+ //Creating the parser
+ File_Adpcm MI;
+ MI.Codec=Codec;
+
+ //Parsing
+ Open_Buffer_Init(&MI);
+ Open_Buffer_Continue(&MI, 0);
+
+ //Filling
+ Finish(&MI);
+ Merge(MI, StreamKind_Last, 0, StreamPos_Last);
+ }
+ #endif
+ #if defined(MEDIAINFO_OGG_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Riff, Codec)==_T("Vorbis")
+ && FormatTag!=0x566F) //0x566F has config in this chunk
+ {
+ File_Ogg* Parser=new File_Ogg;
+ Parser->ShouldContinueParsing=true;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ #endif
+ for (size_t Pos=0; Pos<Stream[Stream_ID].Parsers.size(); Pos++)
+ Open_Buffer_Init(Stream[Stream_ID].Parsers[Pos]);
+
+ //Options
+ if (Element_Offset+2>Element_Size)
+ return; //No options
+
+ //Parsing
+ int16u Option_Size;
+ Get_L2 (Option_Size, "cbSize");
+
+ //Filling
+ if (Option_Size>0)
+ {
+ if (0);
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Riff, Codec)==_T("MPEG Audio"))
+ {
+ if (Option_Size==12)
+ AVI__hdlr_strl_strf_auds_Mpega();
+ else
+ Skip_XX(Option_Size, "MPEG Audio - Uknown");
+ }
+ else if (Codec==_T("AAC") || Codec==_T("FF") || Codec==_T("8180"))
+ AVI__hdlr_strl_strf_auds_Aac();
+ else if (FormatTag==0x566F) //Vorbis with Config in this chunk
+ AVI__hdlr_strl_strf_auds_Vorbis();
+ else if (FormatTag==0x6750) //Vorbis with Config in this chunk
+ AVI__hdlr_strl_strf_auds_Vorbis2();
+ else if (FormatTag==0xFFFE) //Extensible Wave
+ AVI__hdlr_strl_strf_auds_ExtensibleWave();
+ else if (Element_Offset+Option_Size<=Element_Size)
+ Skip_XX(Option_Size, "Unknown");
+ else if (Element_Offset!=Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Error");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf_auds_Mpega()
+{
+ //Parsing
+ Element_Begin1("MPEG Audio options");
+ Skip_L2( "ID");
+ Skip_L4( "Flags");
+ Skip_L2( "BlockSize");
+ Skip_L2( "FramesPerBlock");
+ Skip_L2( "CodecDelay");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf_auds_Aac()
+{
+ //Parsing
+ Element_Begin1("AAC options");
+ #if defined(MEDIAINFO_AAC_YES)
+ File_Aac* MI=new File_Aac();
+ MI->Mode=File_Aac::Mode_AudioSpecificConfig;
+ Open_Buffer_Init(MI);
+ Open_Buffer_Continue(MI);
+ Finish(MI);
+ Merge(*MI, StreamKind_Last, 0, StreamPos_Last);
+ delete MI; //MI=NULL;
+ #else //MEDIAINFO_MPEG4_YES
+ Skip_XX(Element_Size-Element_Offset, "(AudioSpecificConfig)");
+ #endif
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf_auds_Vorbis()
+{
+ //Parsing
+ Element_Begin1("Vorbis options");
+ #if defined(MEDIAINFO_OGG_YES)
+ File_Ogg_SubElement MI;
+ Open_Buffer_Init(&MI);
+ Element_Begin1("Element sizes");
+ //All elements parsing, except last one
+ std::vector<size_t> Elements_Size;
+ size_t Elements_TotalSize=0;
+ int8u Elements_Count;
+ Get_L1(Elements_Count, "Element count");
+ Elements_Size.resize(Elements_Count+1); //+1 for the last block
+ for (int8u Pos=0; Pos<Elements_Count; Pos++)
+ {
+ int8u Size;
+ Get_L1(Size, "Size");
+ Elements_Size[Pos]=Size;
+ Elements_TotalSize+=Size;
+ }
+ Element_End0();
+ if (Element_Offset+Elements_TotalSize>Element_Size)
+ return;
+ //Adding the last block
+ Elements_Size[Elements_Count]=(size_t)(Element_Size-(Element_Offset+Elements_TotalSize));
+ Elements_Count++;
+ //Parsing blocks
+ for (int8u Pos=0; Pos<Elements_Count; Pos++)
+ {
+ Open_Buffer_Continue(&MI, Elements_Size[Pos]);
+ Open_Buffer_Continue(&MI, 0);
+ Element_Offset+=Elements_Size[Pos];
+ }
+ //Finalizing
+ Finish(&MI);
+ Merge(MI, StreamKind_Last, 0, StreamPos_Last);
+ Clear(Stream_Audio, StreamPos_Last, Audio_BitDepth); //Resolution is not valid for Vorbis
+ Element_Show();
+ #else //MEDIAINFO_MPEG4_YES
+ Skip_XX(Element_Size-Element_Offset, "(Vorbis headers)");
+ #endif
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf_auds_Vorbis2()
+{
+ //Parsing
+ Skip_XX(8, "Vorbis Unknown");
+ Element_Begin1("Vorbis options");
+ #if defined(MEDIAINFO_OGG_YES)
+ Open_Buffer_Continue(Stream[Stream_ID].Parsers[0]);
+ Open_Buffer_Continue(Stream[Stream_ID].Parsers[0], 0);
+ Finish(Stream[Stream_ID].Parsers[0]);
+ Merge(*Stream[Stream_ID].Parsers[0], StreamKind_Last, 0, StreamPos_Last);
+ Element_Show();
+ #else //MEDIAINFO_MPEG4_YES
+ Skip_XX(Element_Size-Element_Offset, "(Vorbis headers)");
+ #endif
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf_auds_ExtensibleWave()
+{
+ //Parsing
+ int128u SubFormat;
+ int32u ChannelMask;
+ Skip_L2( "ValidBitsPerSample / SamplesPerBlock");
+ Get_L4 (ChannelMask, "ChannelMask");
+ Get_GUID(SubFormat, "SubFormat");
+
+ FILLING_BEGIN();
+ if ((SubFormat.hi&0xFFFFFFFFFFFF0000LL)==0x0010000000000000LL && SubFormat.lo==0x800000AA00389B71LL)
+ {
+ CodecID_Fill(Ztring().From_Number((int16u)SubFormat.hi, 16), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Audio, StreamPos_Last, Audio_CodecID, Ztring().From_GUID(SubFormat), true);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, MediaInfoLib::Config.Codec_Get(Ztring().From_Number((int16u)SubFormat.hi, 16)), true);
+
+ //Creating the parser
+ if (0);
+ #if defined(MEDIAINFO_PCM_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Riff, Ztring().From_Number((int16u)SubFormat.hi, 16))==_T("PCM"))
+ {
+ //Creating the parser
+ File_Pcm MI;
+ MI.Codec=Ztring().From_Number((int16u)SubFormat.hi, 16);
+ MI.BitDepth=BitsPerSample;
+
+ //Parsing
+ Open_Buffer_Init(&MI);
+ Open_Buffer_Continue(&MI, 0);
+
+ //Filling
+ Finish(&MI);
+ Merge(MI, StreamKind_Last, 0, StreamPos_Last);
+ }
+ #endif
+ }
+ else
+ {
+ CodecID_Fill(Ztring().From_GUID(SubFormat), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Riff);
+ }
+ Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions, ExtensibleWave_ChannelMask(ChannelMask));
+ Fill(Stream_Audio, StreamPos_Last, Audio_ChannelPositions_String2, ExtensibleWave_ChannelMask2(ChannelMask));
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf_iavs()
+{
+ //Standard video header before Iavs?
+ if (Element_Size==72)
+ {
+ Element_Begin0();
+ AVI__hdlr_strl_strf_vids();
+ Element_End0();
+ }
+
+ Element_Info1("Interleaved Audio/Video");
+
+ #ifdef MEDIAINFO_DVDIF_YES
+ if (Element_Size<8*4)
+ return;
+
+ //Parsing
+ DV_FromHeader=new File_DvDif();
+ Open_Buffer_Init(DV_FromHeader);
+
+ //DVAAuxSrc
+ ((File_DvDif*)DV_FromHeader)->AuxToAnalyze=0x50; //Audio source
+ Open_Buffer_Continue(DV_FromHeader, 4);
+ //DVAAuxCtl
+ ((File_DvDif*)DV_FromHeader)->AuxToAnalyze=0x51; //Audio control
+ Open_Buffer_Continue(DV_FromHeader, Buffer+Buffer_Offset+(size_t)Element_Offset, 4);
+ Element_Offset+=4;
+ //DVAAuxSrc1
+ Skip_L4( "DVAAuxSrc1");
+ //DVAAuxCtl1
+ Skip_L4( "DVAAuxCtl1");
+ //DVVAuxSrc
+ ((File_DvDif*)DV_FromHeader)->AuxToAnalyze=0x60; //Video source
+ Open_Buffer_Continue(DV_FromHeader, 4);
+ //DVAAuxCtl
+ ((File_DvDif*)DV_FromHeader)->AuxToAnalyze=0x61; //Video control
+ Open_Buffer_Continue(DV_FromHeader, 4);
+ //Reserved
+ if (Element_Offset<Element_Size)
+ {
+ Skip_L4( "DVReserved");
+ Skip_L4( "DVReserved");
+ }
+
+ Finish(DV_FromHeader);
+
+ Stream_Prepare(Stream_Video);
+ Stream[Stream_ID].Parsers.push_back(new File_DvDif);
+ Open_Buffer_Init(Stream[Stream_ID].Parsers[0]);
+
+ #else //MEDIAINFO_DVDIF_YES
+ //Parsing
+ Skip_L4( "DVAAuxSrc");
+ Skip_L4( "DVAAuxCtl");
+ Skip_L4( "DVAAuxSrc1");
+ Skip_L4( "DVAAuxCtl1");
+ Skip_L4( "DVVAuxSrc");
+ Skip_L4( "DVVAuxCtl");
+ Skip_L4( "DVReserved");
+ Skip_L4( "DVReserved");
+
+ //Filling
+ Ztring Codec; Codec.From_CC4(Stream[Stream_ID].fccHandler);
+ Stream_Prepare(Stream_Video);
+ float32 FrameRate=Retrieve(Stream_Video, StreamPos_Last, Video_FrameRate).To_float32();
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, Codec); //May be replaced by codec parser
+ Fill(Stream_Video, StreamPos_Last, Video_Codec_CC, Codec);
+ if (Codec==_T("dvsd")
+ || Codec==_T("dvsl"))
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Width, 720);
+ if (FrameRate==25.000) Fill(Stream_Video, StreamPos_Last, Video_Height, 576);
+ else if (FrameRate==29.970) Fill(Stream_Video, StreamPos_Last, Video_Height, 480);
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, 4.0/3, 3, true);
+ }
+ else if (Codec==_T("dvhd"))
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Width, 1440);
+ if (FrameRate==25.000) Fill(Stream_Video, StreamPos_Last, Video_Height, 1152);
+ else if (FrameRate==30.000) Fill(Stream_Video, StreamPos_Last, Video_Height, 960);
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, 4.0/3, 3, true);
+ }
+ Stream_Prepare(Stream_Audio);
+ CodecID_Fill(Codec, Stream_Audio, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Codec); //May be replaced by codec parser
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec_CC, Codec);
+ #endif //MEDIAINFO_DVDIF_YES
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf_mids()
+{
+ Element_Info1("Midi");
+
+ //Filling
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format, "MIDI");
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, "Midi");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf_txts()
+{
+ Element_Info1("Text");
+
+ //Parsing
+ Ztring Format;
+ if (Element_Size)
+ {
+ Get_Local(10, Format, "Format");
+ Skip_XX(22, "Unknown");
+ }
+
+ FILLING_BEGIN_PRECISE()
+ Stream_Prepare(Stream_Text);
+
+ if (Element_Size==0)
+ {
+ //Creating the parser
+ #if defined(MEDIAINFO_OTHERTEXT_YES)
+ Stream[Stream_ID].Parsers.push_back(new File_OtherText);
+ Open_Buffer_Init(Stream[Stream_ID].Parsers[0]);
+ #endif
+ }
+ else
+ {
+ Fill(Stream_Text, StreamPos_Last, Text_Format, Format);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf_vids()
+{
+ Element_Info1("Video");
+
+ //Parsing
+ int32u Compression, Width, Height;
+ int16u Resolution;
+ Skip_L4( "Size");
+ Get_L4 (Width, "Width");
+ Get_L4 (Height, "Height");
+ Skip_L2( "Planes");
+ Get_L2 (Resolution, "BitCount"); //Do not use it
+ Get_C4 (Compression, "Compression");
+ Skip_L4( "SizeImage");
+ Skip_L4( "XPelsPerMeter");
+ Skip_L4( "YPelsPerMeter");
+ Skip_L4( "ClrUsed");
+ Skip_L4( "ClrImportant");
+
+ //Filling
+ Stream[Stream_ID].Compression=Compression;
+ if (((Compression&0x000000FF)>=0x00000020 && (Compression&0x000000FF)<=0x0000007E
+ && (Compression&0x0000FF00)>=0x00002000 && (Compression&0x0000FF00)<=0x00007E00
+ && (Compression&0x00FF0000)>=0x00200000 && (Compression&0x00FF0000)<=0x007E0000
+ && (Compression&0xFF000000)>=0x20000000 && (Compression&0xFF000000)<=0x7E000000)
+ || Compression==0x00000000
+ || Compression==0x01000000
+ || Compression==0x02000000
+ || Compression==0x03000000
+ ) //Sometimes this value is wrong, we have to test this
+ {
+ if (Compression==CC4("DXSB"))
+ {
+ //Divx.com hack for subtitle, this is a text stream in a DivX Format
+ Fill(Stream_General, 0, General_Format, "DivX", Unlimited, true, true);
+ Stream_Prepare(Stream_Text);
+ }
+ else
+ Stream_Prepare(Stream_Video);
+
+ //Filling
+ if (Compression==0x00000000 || Compression==0x01000000 || Compression==0x02000000 || Compression==0x03000000)
+ {
+ Ztring CodecID=_T("0x0000000")+Ztring::ToZtring(Compression>>24);
+ CodecID_Fill(CodecID, StreamKind_Last, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), CodecID); //FormatTag, may be replaced by codec parser
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec_CC), CodecID); //FormatTag
+ }
+ else
+ {
+ CodecID_Fill(Ztring().From_CC4(Compression), StreamKind_Last, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec), Ztring().From_CC4(Compression).To_Local().c_str()); //FormatTag, may be replaced by codec parser
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Codec_CC), Ztring().From_CC4(Compression).To_Local().c_str()); //FormatTag
+ }
+ Fill(StreamKind_Last, StreamPos_Last, "Width", Width, 10, true);
+ Fill(StreamKind_Last, StreamPos_Last, "Height", Height, 10, true);
+ if (Resolution==32 && Compression==0x74736363) //tscc
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", 8);
+ else if (Compression==0x44495633) //DIV3
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", 8);
+ else if (Compression==0x44585342) //DXSB
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", Resolution);
+ else if (MediaInfoLib::Config.CodecID_Get(StreamKind_Last, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_ColorSpace).find(_T("RGBA"))!=std::string::npos) //RGB codecs
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", Resolution/4);
+ else if (Compression==0x00000000 //RGB
+ || MediaInfoLib::Config.CodecID_Get(StreamKind_Last, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_ColorSpace).find(_T("RGB"))!=std::string::npos) //RGB codecs
+ {
+ if (Resolution==32)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Format), "RGBA", Unlimited, true, true);
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", Resolution/4); //With Alpha
+ }
+ else
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", Resolution<=16?8:(Resolution/3)); //indexed or normal
+ }
+ else if (Compression==0x56503632 //VP62
+ || MediaInfoLib::Config.CodecID_Get(StreamKind_Last, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_Format)==_T("H.263") //H.263
+ || MediaInfoLib::Config.CodecID_Get(StreamKind_Last, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_Format)==_T("VC-1")) //VC-1
+ Fill(StreamKind_Last, StreamPos_Last, "BitDepth", Resolution/3);
+ }
+ else
+ {
+ //Some Stream headers are broken, must use AVISTREAMINFOA structure instead of AVIFILEINFOA
+ Stream_Prepare(Stream_Video);
+ }
+ Stream[Stream_ID].StreamKind=StreamKind_Last;
+
+ //Creating the parser
+ if (0);
+ #if defined(MEDIAINFO_MPEGV_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_Format)==_T("MPEG Video"))
+ {
+ File_Mpegv* Parser=new File_Mpegv;
+ Parser->FrameIsAlwaysComplete=true;
+ Parser->TimeCodeIsNotTrustable=true;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ #endif
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression))==_T("MPEG-4 Visual"))
+ {
+ File_Mpeg4v* Parser=new File_Mpeg4v;
+ Stream[Stream_ID].Specific_IsMpeg4v=true;
+ Parser->FrameIsAlwaysComplete=true;
+ if (MediaInfoLib::Config.ParseSpeed_Get()>=0.5)
+ Parser->ShouldContinueParsing=true;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ #endif
+ #if defined(MEDIAINFO_AVC_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression))==_T("AVC"))
+ {
+ File_Avc* Parser=new File_Avc;
+ Parser->FrameIsAlwaysComplete=true;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ #endif
+ #if defined(MEDIAINFO_JPEG_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression))==_T("JPEG"))
+ {
+ File_Jpeg* Parser=new File_Jpeg;
+ Parser->StreamKind=Stream_Video;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ #endif
+ #if defined(MEDIAINFO_DVDIF_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression))==_T("DV"))
+ {
+ File_DvDif* Parser=new File_DvDif;
+ Parser->IgnoreAudio=true;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ #endif
+ #if defined(MEDIAINFO_FRAPS_YES)
+ else if (Compression==0x46505331) //"FPS1"
+ {
+ File_Fraps* Parser=new File_Fraps;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ #endif
+ else if (Compression==0x48465955) //"HFUY"
+ {
+ switch (Resolution)
+ {
+ case 16 : Fill(Stream_Video, StreamPos_Last, Video_ColorSpace, "YUV"); Fill(Stream_Video, StreamPos_Last, Video_ChromaSubsampling, "4:2:2"); Fill(Stream_Video, StreamPos_Last, Video_BitDepth, 8); break;
+ case 24 : Fill(Stream_Video, StreamPos_Last, Video_ColorSpace, "RGB"); Fill(Stream_Video, StreamPos_Last, Video_BitDepth, 8); break;
+ case 32 : Fill(Stream_Video, StreamPos_Last, Video_ColorSpace, "RGBA"); Fill(Stream_Video, StreamPos_Last, Video_BitDepth, 8); break;
+ default : ;
+ }
+ }
+ #if defined(MEDIAINFO_LAGARITH_YES)
+ else if (Compression==0x4C414753) //"LAGS"
+ {
+ File_Lagarith* Parser=new File_Lagarith;
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ }
+ #endif
+ for (size_t Pos=0; Pos<Stream[Stream_ID].Parsers.size(); Pos++)
+ Open_Buffer_Init(Stream[Stream_ID].Parsers[Pos]);
+
+ //Options
+ if (Element_Offset>=Element_Size)
+ return; //No options
+
+ //Filling
+ if (0);
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression))==_T("AVC"))
+ AVI__hdlr_strl_strf_vids_Avc();
+ else Skip_XX(Element_Size-Element_Offset, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strf_vids_Avc()
+{
+ //Parsing
+ Element_Begin1("AVC options");
+ #if defined(MEDIAINFO_AVC_YES)
+ //Can be sized block or with 000001
+ File_Avc* Parser=(File_Avc*)Stream[Stream_ID].Parsers[0];
+ Parser->MustParse_SPS_PPS=false;
+ Parser->SizedBlocks=false;
+ Parser->MustSynchronize=true;
+ int64u Element_Offset_Save=Element_Offset;
+ Open_Buffer_Continue(Parser);
+ if (!Parser->Status[IsAccepted])
+ {
+ Element_Offset=Element_Offset_Save;
+ delete Stream[Stream_ID].Parsers[0]; Stream[Stream_ID].Parsers[0]=new File_Avc;
+ Parser=(File_Avc*)Stream[Stream_ID].Parsers[0];
+ Open_Buffer_Init(Parser);
+ Parser->FrameIsAlwaysComplete=true;
+ Parser->MustParse_SPS_PPS=true;
+ Parser->SizedBlocks=true;
+ Parser->MustSynchronize=false;
+ Open_Buffer_Continue(Parser);
+ Element_Show();
+ }
+ #else //MEDIAINFO_AVC_YES
+ Skip_XX(Element_Size-Element_Offset, "(AVC headers)");
+ #endif
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strh()
+{
+ Element_Name("Stream header");
+
+ //Parsing
+ int32u fccType, fccHandler, Scale, Rate, Start, Length;
+ int16u Left, Top, Right, Bottom;
+ Get_C4 (fccType, "fccType");
+ switch (fccType)
+ {
+ case Elements::AVI__hdlr_strl_strh_auds :
+ Get_L4 (fccHandler, "fccHandler");
+ break;
+ default:
+ Get_C4 (fccHandler, "fccHandler");
+ }
+ Skip_L4( "Flags");
+ Skip_L2( "Priority");
+ Skip_L2( "Language");
+ Skip_L4( "InitialFrames");
+ Get_L4 (Scale, "Scale");
+ Get_L4 (Rate, "Rate"); //Rate/Scale is stream tick rate in ticks/sec
+ Get_L4 (Start, "Start");
+ Get_L4 (Length, "Length");
+ Skip_L4( "SuggestedBufferSize");
+ Skip_L4( "Quality");
+ Skip_L4( "SampleSize");
+ Get_L2 (Left, "Frame_Left");
+ Get_L2 (Top, "Frame_Top");
+ Get_L2 (Right, "Frame_Right");
+ Get_L2 (Bottom, "Frame_Bottom");
+ if(Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+
+ //Filling
+ float32 FrameRate=0;
+ if (Rate>0 && Scale>0)
+ {
+ //FrameRate (without known value detection)
+ FrameRate=((float32)Rate)/Scale;
+ if (FrameRate>1)
+ {
+ float32 Rest=FrameRate-(int32u)FrameRate;
+ if (Rest<0.01)
+ FrameRate-=Rest;
+ else if (Rest>0.99)
+ FrameRate+=1-Rest;
+ else
+ {
+ float32 Rest1001=FrameRate*1001/1000-(int32u)(FrameRate*1001/1000);
+ if (Rest1001<0.001)
+ FrameRate=(float32)((int32u)(FrameRate*1001/1000))*1000/1001;
+ if (Rest1001>0.999)
+ FrameRate=(float32)((int32u)(FrameRate*1001/1000)+1)*1000/1001;
+ }
+ }
+
+ //Duration
+ if (FrameRate)
+ {
+ int64u Duration=float32_int64s((1000*(float32)Length)/FrameRate);
+ if (avih_TotalFrame>0 //avih_TotalFrame is here because some files have a wrong Audio Duration if TotalFrame==0 (which is a bug, of course!)
+ && (avih_FrameRate==0 || Duration<((float32)avih_TotalFrame)/avih_FrameRate*1000*1.10) //Some file have a nearly perfect header, except that the value is false, trying to detect it (false if 10% more than 1st video)
+ && (avih_FrameRate==0 || Duration>((float32)avih_TotalFrame)/avih_FrameRate*1000*0.90)) //Some file have a nearly perfect header, except that the value is false, trying to detect it (false if 10% less than 1st video)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, "Duration", Duration);
+ }
+ }
+ }
+ switch (fccType)
+ {
+ case Elements::AVI__hdlr_strl_strh_vids :
+ if (FrameRate>0) Fill(Stream_Video, StreamPos_Last, "FrameRate", FrameRate, 3);
+ case Elements::AVI__hdlr_strl_strh_txts :
+ if (Right-Left>0) Fill(Stream_Text, StreamPos_Last, "Width", Right-Left, 10, true);
+ if (Bottom-Top>0) Fill(Stream_Text, StreamPos_Last, "Height", Bottom-Top, 10, true);
+ break;
+ default: ;
+ }
+ Stream[Stream_ID].fccType=fccType;
+ Stream[Stream_ID].fccHandler=fccHandler;
+ Stream[Stream_ID].Scale=Scale;
+ Stream[Stream_ID].Rate=Rate;
+ Stream[Stream_ID].Start=Start;
+ Stream[Stream_ID].Length=Length;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_strn()
+{
+ Element_Name("Stream name");
+
+ //Parsing
+ Ztring Title;
+ Get_Local(Element_Size, Title, "StreamName");
+
+ //Filling
+ Fill(StreamKind_Last, StreamPos_Last, "Title", Title);
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_strl_vprp()
+{
+ Element_Name("Video properties");
+
+ //Parsing
+ int32u FieldPerFrame;
+ int16u FrameAspectRatio_H, FrameAspectRatio_W;
+ Skip_L4( "VideoFormatToken");
+ Skip_L4( "VideoStandard");
+ Skip_L4( "VerticalRefreshRate");
+ Skip_L4( "HTotalInT");
+ Skip_L4( "VTotalInLines");
+ Get_L2 (FrameAspectRatio_H, "FrameAspectRatio Height");
+ Get_L2 (FrameAspectRatio_W, "FrameAspectRatio Width");
+ Skip_L4( "FrameWidthInPixels");
+ Skip_L4( "FrameHeightInLines");
+ Get_L4 (FieldPerFrame, "FieldPerFrame");
+ for (int32u Pos=0; Pos<FieldPerFrame; Pos++)
+ {
+ Skip_L4( "CompressedBMHeight");
+ Skip_L4( "CompressedBMWidth");
+ Skip_L4( "ValidBMHeight");
+ Skip_L4( "ValidBMWidth");
+ Skip_L4( "ValidBMXOffset");
+ Skip_L4( "ValidBMYOffset");
+ Skip_L4( "VideoXOffsetInT");
+ Skip_L4( "VideoYValidStartLine");
+ }
+ if(Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+
+ FILLING_BEGIN();
+ if (FrameAspectRatio_H && FrameAspectRatio_W)
+ Fill(Stream_Video, 0, Video_DisplayAspectRatio, ((float32)FrameAspectRatio_W)/FrameAspectRatio_H, 3);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__hdlr_xxxx()
+{
+ AVI__INFO_xxxx();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__idx1()
+{
+ Element_Name("Index (old)");
+
+ //Tests
+ if (!NeedOldIndex || Idx1_Offset==(int64u)-1)
+ {
+ Skip_XX(Element_Size, "Data");
+ return;
+ }
+
+ //Testing malformed index (index is based on start of the file, wrong)
+ if (16<=Element_Size && Idx1_Offset+4==LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset+ 8))
+ Idx1_Offset=0; //Fixing base of movi atom, the index think it is the start of the file
+
+ //Parsing
+ std::map <int64u, size_t> Stream_Count;
+ while (Element_Offset+16<=Element_Size)
+ {
+ //Is too slow
+ /*
+ int32u ChunkID, Offset, Size;
+ Element_Begin1("Index");
+ Get_C4 (ChunkID, "ChunkID"); //Bit 31 is set if this is NOT a keyframe
+ Info_L4(Flags, "Flags");
+ Skip_Flags(Flags, 0, "NoTime");
+ Skip_Flags(Flags, 1, "Lastpart");
+ Skip_Flags(Flags, 2, "Firstpart");
+ Skip_Flags(Flags, 3, "Midpart");
+ Skip_Flags(Flags, 4, "KeyFrame");
+ Get_L4 (Offset, "Offset"); //qwBaseOffset + this is absolute file offset
+ Get_L4 (Size, "Size"); //Bit 31 is set if this is NOT a keyframe
+ Element_Info1(Ztring().From_CC4(ChunkID));
+ Element_Info1(Size);
+
+ //Stream Pos and Size
+ int32u StreamID=(ChunkID&0xFFFF0000);
+ Stream[StreamID].StreamSize+=Size;
+ Stream[StreamID].PacketCount++;
+ Stream_Structure[Idx1_Offset+Offset].Name=StreamID;
+ Stream_Structure[Idx1_Offset+Offset].Size=Size;
+ Element_End0();
+ */
+
+ //Faster method
+ int32u StreamID=BigEndian2int32u (Buffer+Buffer_Offset+(size_t)Element_Offset )&0xFFFF0000;
+ int32u Offset =LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset+ 8);
+ int32u Size =LittleEndian2int32u(Buffer+Buffer_Offset+(size_t)Element_Offset+12);
+ Stream[StreamID].StreamSize+=Size;
+ Stream[StreamID].PacketCount++;
+ Stream_Structure[Idx1_Offset+Offset].Name=StreamID;
+ Stream_Structure[Idx1_Offset+Offset].Size=Size;
+ Element_Offset+=16;
+ }
+
+ //Interleaved
+ size_t Pos0=0;
+ size_t Pos1=0;
+ for (std::map<int64u, stream_structure>::iterator Temp=Stream_Structure.begin(); Temp!=Stream_Structure.end(); Temp++)
+ {
+ switch (Temp->second.Name)
+ {
+ case 0x30300000 :
+ if (Interleaved0_1==0) Interleaved0_1=Temp->first;
+ if (Interleaved0_10==0)
+ {
+ Pos0++;
+ if (Pos0>1)
+ Interleaved0_10=Temp->first;
+ }
+ break;
+ case 0x30310000 :
+ if (Interleaved1_1==0) Interleaved1_1=Temp->first;
+ if (Interleaved1_10==0)
+ {
+ Pos1++;
+ if (Pos1>1)
+ Interleaved1_10=Temp->first;
+ }
+ break;
+ default:;
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__INFO()
+{
+ Element_Name("Tags");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__INFO_IID3()
+{
+ Element_Name("ID3 Tag");
+
+ //Parsing
+ #if defined(MEDIAINFO_ID3_YES)
+ File_Id3 MI;
+ Open_Buffer_Init(&MI);
+ Open_Buffer_Continue(&MI);
+ Finish(&MI);
+ Merge(MI, Stream_General, 0, 0);
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__INFO_ILYC()
+{
+ Element_Name("Lyrics");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__INFO_IMP3()
+{
+ Element_Name("MP3 Information");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__INFO_JUNK()
+{
+ Element_Name("Garbage");
+}
+
+//---------------------------------------------------------------------------
+// List of information atoms
+// Name X bytes, Pos=0
+//
+void File_Riff::AVI__INFO_xxxx()
+{
+ //Parsing
+ Ztring Value;
+ Get_Local(Element_Size, Value, "Value");
+
+ //Filling
+ stream_t StreamKind=Stream_General;
+ size_t StreamPos=0;
+ size_t Parameter=(size_t)-1;
+ switch (Element_Code)
+ {
+ case 0x00000000 : Parameter=General_Comment; break;
+ case Elements::AVI__INFO_IARL : Parameter=General_Archival_Location; break;
+ case Elements::AVI__INFO_IART : Parameter=General_Director; break;
+ case Elements::AVI__INFO_IAS1 : Parameter=Audio_Language; StreamKind=Stream_Audio; StreamPos=0; break;
+ case Elements::AVI__INFO_IAS2 : Parameter=Audio_Language; StreamKind=Stream_Audio; StreamPos=1; break;
+ case Elements::AVI__INFO_IAS3 : Parameter=Audio_Language; StreamKind=Stream_Audio; StreamPos=2; break;
+ case Elements::AVI__INFO_IAS4 : Parameter=Audio_Language; StreamKind=Stream_Audio; StreamPos=3; break;
+ case Elements::AVI__INFO_IAS5 : Parameter=Audio_Language; StreamKind=Stream_Audio; StreamPos=4; break;
+ case Elements::AVI__INFO_IAS6 : Parameter=Audio_Language; StreamKind=Stream_Audio; StreamPos=5; break;
+ case Elements::AVI__INFO_IAS7 : Parameter=Audio_Language; StreamKind=Stream_Audio; StreamPos=6; break;
+ case Elements::AVI__INFO_IAS8 : Parameter=Audio_Language; StreamKind=Stream_Audio; StreamPos=7; break;
+ case Elements::AVI__INFO_IAS9 : Parameter=Audio_Language; StreamKind=Stream_Audio; StreamPos=8; break;
+ case Elements::AVI__INFO_ICDS : Parameter=General_CostumeDesigner; break;
+ case Elements::AVI__INFO_ICMS : Parameter=General_CommissionedBy; break;
+ case Elements::AVI__INFO_ICMT : Parameter=General_Comment; break;
+ case Elements::AVI__INFO_ICNM : Parameter=General_DirectorOfPhotography; break;
+ case Elements::AVI__INFO_ICNT : Parameter=General_Movie_Country; break;
+ case Elements::AVI__INFO_ICOP : Parameter=General_Copyright; break;
+ case Elements::AVI__INFO_ICRD : Parameter=General_Recorded_Date; Value.Date_From_String(Value.To_Local().c_str()); break;
+ case Elements::AVI__INFO_ICRP : Parameter=General_Cropped; break;
+ case Elements::AVI__INFO_IDIM : Parameter=General_Dimensions; break;
+ case Elements::AVI__INFO_IDIT : Parameter=General_Mastered_Date; Value.Date_From_String(Value.To_Local().c_str()); break;
+ case Elements::AVI__INFO_IDPI : Parameter=General_DotsPerInch; break;
+ case Elements::AVI__INFO_IDST : Parameter=General_DistributedBy; break;
+ case Elements::AVI__INFO_IEDT : Parameter=General_EditedBy; break;
+ case Elements::AVI__INFO_IENG : Parameter=General_EncodedBy; break;
+ case Elements::AVI__INFO_IGNR : Parameter=General_Genre; break;
+ case Elements::AVI__INFO_IFRM : Parameter=General_Part_Position_Total; break;
+ case Elements::AVI__INFO_IKEY : Parameter=General_Keywords; break;
+ case Elements::AVI__INFO_ILGT : Parameter=General_Lightness; break;
+ case Elements::AVI__INFO_ILNG : Parameter=Audio_Language; StreamKind=Stream_Audio; break;
+ case Elements::AVI__INFO_IMED : Parameter=General_OriginalSourceMedium; break;
+ case Elements::AVI__INFO_IMUS : Parameter=General_MusicBy; break;
+ case Elements::AVI__INFO_INAM : Parameter=General_Title; break;
+ case Elements::AVI__INFO_IPDS : Parameter=General_ProductionDesigner; break;
+ case Elements::AVI__INFO_IPLT : Parameter=General_OriginalSourceForm_NumColors; break;
+ case Elements::AVI__INFO_IPRD : Parameter=General_OriginalSourceForm_Name; break;
+ case Elements::AVI__INFO_IPRO : Parameter=General_Producer; break;
+ case Elements::AVI__INFO_IPRT : Parameter=General_Part_Position; break;
+ case Elements::AVI__INFO_IRTD : Parameter=General_LawRating; break;
+ case Elements::AVI__INFO_ISBJ : Parameter=General_Subject; break;
+ case Elements::AVI__INFO_ISFT : Parameter=General_Encoded_Application; break;
+ case Elements::AVI__INFO_ISGN : Parameter=General_Genre; break;
+ case Elements::AVI__INFO_ISHP : Parameter=General_OriginalSourceForm_Sharpness; break;
+ case Elements::AVI__INFO_ISRC : Parameter=General_OriginalSourceForm_DistributedBy; break;
+ case Elements::AVI__INFO_ISRF : Parameter=General_OriginalSourceForm; break;
+ case Elements::AVI__INFO_ISTD : Parameter=General_ProductionStudio; break;
+ case Elements::AVI__INFO_ISTR : Parameter=General_Performer; break;
+ case Elements::AVI__INFO_ITCH : Parameter=General_EncodedBy; break;
+ case Elements::AVI__INFO_IWEB : Parameter=General_Movie_Url; break;
+ case Elements::AVI__INFO_IWRI : Parameter=General_WrittenBy; break;
+ default : ;
+ }
+ Element_Name(MediaInfoLib::Config.Info_Get(StreamKind, Parameter, Info_Name));
+ Element_Info1(Value);
+
+ if (Element_Code==Elements::AVI__INFO_ISMP)
+ INFO_ISMP=Value;
+ else if (!Value.empty())
+ {
+ if (Parameter!=(size_t)-1)
+ Fill(StreamKind, StreamPos, Parameter, Value);
+ else
+ Fill(StreamKind, StreamPos, Ztring().From_CC4((int32u)Element_Code).To_Local().c_str(), Value, true);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__JUNK()
+{
+ Element_Name("Garbage"); //Library defined size for padding, often used to store library name
+
+ if (Element_Size<8)
+ {
+ Skip_XX(Element_Size, "Junk");
+ return;
+ }
+
+ //Detect DivX files
+ if (CC5(Buffer+Buffer_Offset)==CC5("DivX "))
+ {
+ Fill(Stream_General, 0, General_Format, "DivX", Unlimited, true, true);
+ }
+ //MPlayer
+ else if (CC8(Buffer+Buffer_Offset)==CC8("[= MPlay") && Retrieve(Stream_General, 0, General_Encoded_Library).empty())
+ Fill(Stream_General, 0, General_Encoded_Library, "MPlayer");
+ //Scenalyzer
+ else if (CC8(Buffer+Buffer_Offset)==CC8("scenalyz") && Retrieve(Stream_General, 0, General_Encoded_Library).empty())
+ Fill(Stream_General, 0, General_Encoded_Library, "Scenalyzer");
+ //FFMpeg broken files detection
+ else if (CC8(Buffer+Buffer_Offset)==CC8("odmldmlh"))
+ dmlh_TotalFrame=0; //this is not normal to have this string in a JUNK block!!! and in files tested, in this case TotalFrame is broken too
+ //VirtualDubMod
+ else if (CC8(Buffer+Buffer_Offset)==CC8("INFOISFT"))
+ {
+ int32u Size=LittleEndian2int32u(Buffer+Buffer_Offset+8);
+ if (Size>Element_Size-12)
+ Size=(int32u)Element_Size-12;
+ Fill(Stream_General, 0, General_Encoded_Library, (const char*)(Buffer+Buffer_Offset+12), Size);
+ }
+ else if (CC8(Buffer+Buffer_Offset)==CC8("INFOIENG"))
+ {
+ int32u Size=LittleEndian2int32u(Buffer+Buffer_Offset+8);
+ if (Size>Element_Size-12)
+ Size=(int32u)Element_Size-12;
+ Fill(Stream_General, 0, General_Encoded_Library, (const char*)(Buffer+Buffer_Offset+12), Size);
+ }
+ //Other libraries?
+ else if (CC1(Buffer+Buffer_Offset)>=CC1("A") && CC1(Buffer+Buffer_Offset)<=CC1("z") && Retrieve(Stream_General, 0, General_Encoded_Library).empty())
+ Fill(Stream_General, 0, General_Encoded_Library, (const char*)(Buffer+Buffer_Offset), (size_t)Element_Size);
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__MD5_()
+{
+ //Parsing
+ while (Element_Offset<Element_Size)
+ {
+ int128u MD5Stored;
+ Get_L16 (MD5Stored, "MD5");
+ Ztring MD5_PerItem;
+ MD5_PerItem.From_Number(MD5Stored, 16);
+ while (MD5_PerItem.size()<32)
+ MD5_PerItem.insert(MD5_PerItem.begin(), '0'); //Padding with 0, this must be a 32-byte string
+ MD5_PerItem.MakeLowerCase();
+ MD5s.push_back(MD5_PerItem);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__movi()
+{
+ Element_Name("Datas");
+
+ //Only the first time, no need in AVIX
+ if (movi_Size==0)
+ {
+ Idx1_Offset=File_Offset+Buffer_Offset-4;
+ BookMark_Set(); //Remenbering this place, for stream parsing in phase 2
+
+ //For each stream
+ std::map<int32u, stream>::iterator Temp=Stream.begin();
+ while (Temp!=Stream.end())
+ {
+ if ((Temp->second.Parsers.empty() || Temp->second.Parsers[0]==NULL) && Temp->second.fccType!=Elements::AVI__hdlr_strl_strh_txts)
+ {
+ Temp->second.SearchingPayload=false;
+ stream_Count--;
+ }
+ Temp++;
+ }
+ }
+
+ //Filling
+ movi_Size+=Element_TotalSize_Get();
+
+ //Probing rec (with index, this is not always tested in the flow
+ if (Element_Size<12)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ if (CC4(Buffer+Buffer_Offset+8)==0x72656320) //"rec "
+ rec__Present=true;
+
+ //We must parse moov?
+ if (NeedOldIndex || (stream_Count==0 && Index_Pos.empty()))
+ {
+ //Jumping
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ Param("Data", Ztring("(")+Ztring::ToZtring(Element_TotalSize_Get())+Ztring(" bytes)"));
+ #endif //MEDIAINFO_TRACE
+ Element_Offset=Element_TotalSize_Get(); //Not using Skip_XX() because we want to skip data we don't have, and Skip_XX() does a test on size of buffer
+ return;
+ }
+
+ //Jump to next useful data
+ AVI__movi_StreamJump();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__movi_rec_()
+{
+ Element_Name("Syncronisation");
+
+ rec__Present=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__movi_rec__xxxx()
+{
+ AVI__movi_xxxx();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__movi_xxxx()
+{
+ if (Element_Code==Elements::AVI__JUNK)
+ {
+ Skip_XX(Element_Size, "Junk");
+ AVI__movi_StreamJump();
+ return;
+ }
+
+ Stream_ID=(int32u)(Element_Code&0xFFFF0000);
+
+ if (Stream_ID==0x69780000) //ix..
+ {
+ //AVI Standard Index Chunk
+ AVI__hdlr_strl_indx();
+ Stream_ID=(int32u)(Element_Code&0x0000FFFF)<<16;
+ AVI__movi_StreamJump();
+ return;
+ }
+ if ((Element_Code&0x0000FFFF)==0x00006978) //..ix (Out of specs, but found in a Adobe After Effects CS4 DV file
+ {
+ //AVI Standard Index Chunk
+ AVI__hdlr_strl_indx();
+ Stream_ID=(int32u)(Element_Code&0xFFFF0000);
+ AVI__movi_StreamJump();
+ return;
+ }
+
+ #if MEDIAINFO_DEMUX
+ if (Stream[Stream_ID].Rate) //AVI
+ {
+ int64u Element_Code_Old=Element_Code;
+ Element_Code=((Element_Code_Old>>24)&0xF)*10+((Element_Code_Old>>16)&0xF);
+ Frame_Count_NotParsedIncluded=Stream[Stream_ID].PacketPos;
+ FrameInfo.DTS=Frame_Count_NotParsedIncluded*1000000000*Stream[Stream_ID].Scale/Stream[Stream_ID].Rate;
+ Element_Code=Stream_ID;
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ Element_Code=Element_Code_Old;
+ }
+ else //WAV
+ {
+ //TODO
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ Stream[Stream_ID].PacketPos++;
+
+ //Finished?
+ if (!Stream[Stream_ID].SearchingPayload)
+ {
+ Element_DoNotShow();
+ AVI__movi_StreamJump();
+ return;
+ }
+
+ #if MEDIAINFO_TRACE
+ if (Config_Trace_Level)
+ {
+ switch (Element_Code&0x0000FFFF) //2 last bytes
+ {
+ case Elements::AVI__movi_xxxx_____ : Element_Info1("DV"); break;
+ case Elements::AVI__movi_xxxx___db :
+ case Elements::AVI__movi_xxxx___dc : Element_Info1("Video"); break;
+ case Elements::AVI__movi_xxxx___sb :
+ case Elements::AVI__movi_xxxx___tx : Element_Info1("Text"); break;
+ case Elements::AVI__movi_xxxx___wb : Element_Info1("Audio"); break;
+ default : Element_Info1("Unknown"); break;
+ }
+ Element_Info1(Stream[Stream_ID].PacketPos);
+ }
+ #endif //MEDIAINFO_TRACE
+
+ //Some specific stuff
+ switch (Element_Code&0x0000FFFF) //2 last bytes
+ {
+ case Elements::AVI__movi_xxxx___tx : AVI__movi_xxxx___tx(); break;
+ default : ;
+ }
+
+ //Parsing
+ for (size_t Pos=0; Pos<Stream[Stream_ID].Parsers.size(); Pos++)
+ if (Stream[Stream_ID].Parsers[Pos])
+ {
+ Open_Buffer_Continue(Stream[Stream_ID].Parsers[Pos], Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+ Element_Show();
+ if (Stream[Stream_ID].Parsers.size()==1 && Stream[Stream_ID].Parsers[Pos]->Buffer_Size>0)
+ Stream[Stream_ID].ChunksAreComplete=false;
+
+ if (Stream[Stream_ID].Parsers.size()>1)
+ {
+ if (!Stream[Stream_ID].Parsers[Pos]->Status[IsAccepted] && Stream[Stream_ID].Parsers[Pos]->Status[IsFinished])
+ {
+ delete *(Stream[Stream_ID].Parsers.begin()+Pos);
+ Stream[Stream_ID].Parsers.erase(Stream[Stream_ID].Parsers.begin()+Pos);
+ Pos--;
+ }
+ else if (Stream[Stream_ID].Parsers.size()>1 && Stream[Stream_ID].Parsers[Pos]->Status[IsAccepted])
+ {
+ File__Analyze* Parser=Stream[Stream_ID].Parsers[Pos];
+ for (size_t Pos2=0; Pos2<Stream[Stream_ID].Parsers.size(); Pos2++)
+ {
+ if (Pos2!=Pos)
+ delete *(Stream[Stream_ID].Parsers.begin()+Pos2);
+ }
+ Stream[Stream_ID].Parsers.clear();
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ Pos=0;
+ }
+ }
+ }
+
+ //Some specific stuff
+ switch (Element_Code&0x0000FFFF) //2 last bytes
+ {
+ case Elements::AVI__movi_xxxx_____ :
+ case Elements::AVI__movi_xxxx___db :
+ case Elements::AVI__movi_xxxx___dc : AVI__movi_xxxx___dc(); break;
+ case Elements::AVI__movi_xxxx___wb : AVI__movi_xxxx___wb(); break;
+ default : ;
+ }
+
+ //We must always parse moov?
+ AVI__movi_StreamJump();
+
+ Element_Show();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__movi_xxxx___dc()
+{
+ //Finish (if requested)
+ if (Stream[Stream_ID].Parsers.empty()
+ || Stream[Stream_ID].Parsers[0]->Status[IsFinished]
+ || (Stream[Stream_ID].PacketPos>=300 && MediaInfoLib::Config.ParseSpeed_Get()<1.00))
+ {
+ Stream[Stream_ID].SearchingPayload=false;
+ stream_Count--;
+ return;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__movi_xxxx___tx()
+{
+ //Parsing
+ int32u Name_Size;
+ Ztring Value;
+ Skip_C4( "GAB2");
+ Skip_L1( "Zero");
+ Skip_L2( "CodePage"); //2=Unicode
+ Get_L4 (Name_Size, "Name_Size");
+ Skip_UTF16L(Name_Size, "Name");
+ Skip_L2( "Four");
+ Skip_L4( "File_Size");
+
+ //Skip it
+ Stream[Stream_ID].SearchingPayload=false;
+ stream_Count--;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__movi_xxxx___wb()
+{
+ //Finish (if requested)
+ if ((Stream[Stream_ID].PacketPos>=4 //For having the chunk alignement
+ && (Stream[Stream_ID].Parsers.empty()
+ || Stream[Stream_ID].Parsers[0]->Status[IsFinished]
+ || (Stream[Stream_ID].PacketPos>=300 && MediaInfoLib::Config.ParseSpeed_Get()<1.00)))
+ || Element_Size>50000) //For PCM, we disable imediatly
+ {
+ Stream[Stream_ID].SearchingPayload=false;
+ stream_Count--;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__movi_StreamJump()
+{
+ //Jump to next useful data
+ if (!Index_Pos.empty())
+ {
+ if (Index_Pos.begin()->first<=File_Offset+Buffer_Offset && Element_Code!=Elements::AVI__movi)
+ Index_Pos.erase(Index_Pos.begin());
+ int64u ToJump=File_Size;
+ if (!Index_Pos.empty())
+ ToJump=Index_Pos.begin()->first;
+ if (ToJump>File_Size)
+ ToJump=File_Size;
+ if (ToJump>=File_Offset+Buffer_Offset+Element_TotalSize_Get(Element_Level-2)) //We want always Element movi
+ GoTo(File_Offset+Buffer_Offset+Element_TotalSize_Get(Element_Level-2), "AVI"); //Not in this chunk
+ else if (ToJump!=File_Offset+Buffer_Offset+(Element_Code==Elements::AVI__movi?0:Element_Size))
+ GoTo(ToJump, "AVI"); //Not just after
+ }
+ else if (stream_Count==0)
+ {
+ //Jumping
+ Element_Show();
+ if (rec__Present)
+ Element_End0();
+ Info("movi, Jumping to end of chunk");
+ if (SecondPass)
+ {
+ std::map<int32u, stream>::iterator Temp=Stream.begin();
+ while (Temp!=Stream.end())
+ {
+ for (size_t Pos=0; Pos<Temp->second.Parsers.size(); Pos++)
+ Temp->second.Parsers[Pos]->Open_Buffer_Unsynch();
+ Temp++;
+ }
+ Finish("AVI"); //The rest is already parsed
+ }
+ else
+ GoTo(File_Offset+Buffer_Offset+Element_TotalSize_Get(), "AVI");
+ }
+ else if (Stream_Structure_Temp!=Stream_Structure.end())
+ {
+ do
+ Stream_Structure_Temp++;
+ while (Stream_Structure_Temp!=Stream_Structure.end() && !Stream[(int32u)Stream_Structure_Temp->second.Name].SearchingPayload);
+ if (Stream_Structure_Temp!=Stream_Structure.end())
+ {
+ int64u ToJump=Stream_Structure_Temp->first;
+ if (ToJump>=File_Offset+Buffer_Offset+Element_TotalSize_Get(Element_Level-2))
+ GoTo(File_Offset+Buffer_Offset+Element_TotalSize_Get(Element_Level-2), "AVI"); //Not in this chunk
+ else if (ToJump!=File_Offset+Buffer_Offset+Element_Size)
+ GoTo(ToJump, "AVI"); //Not just after
+ }
+ else
+ Finish("AVI");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__PrmA()
+{
+ Element_Name("Adobe Premiere PrmA");
+
+ //Parsing
+ Skip_C4( "FourCC");
+ Skip_B4( "Size");
+ Skip_B4( "Unknown");
+ Skip_B4( "Width");
+ Skip_B4( "Height");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__Tdat()
+{
+ Element_Name("Adobe Premiere Tdat");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__Tdat_tc_A()
+{
+ Element_Name("tc_A");
+
+ //Parsing
+ Ztring Value;
+ Get_Local(Element_Size, Value, "Unknown");
+
+ if (Value.find_first_not_of(_T("0123456789:;"))==string::npos)
+ Tdat_tc_A=Value;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__Tdat_tc_O()
+{
+ Element_Name("tc_O");
+
+ //Parsing
+ Ztring Value;
+ Get_Local(Element_Size, Value, "Unknown");
+
+ if (Value.find_first_not_of(_T("0123456789:;"))==string::npos)
+ Tdat_tc_O=Value;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__Tdat_rn_A()
+{
+ Element_Name("rn_A");
+
+ //Parsing
+ Skip_Local(Element_Size, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__Tdat_rn_O()
+{
+ Element_Name("rn_O");
+
+ //Parsing
+ Skip_Local(Element_Size, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVI__xxxx()
+{
+ Stream_ID=(int32u)(Element_Code&0xFFFF0000);
+
+ if (Stream_ID==0x69780000) //ix..
+ {
+ //AVI Standard Index Chunk
+ AVI__hdlr_strl_indx();
+ Stream_ID=(int32u)(Element_Code&0x0000FFFF)<<16;
+ AVI__movi_StreamJump();
+ return;
+ }
+ if ((Element_Code&0x0000FFFF)==0x00006978) //..ix (Out of specs, but found in a Adobe After Effects CS4 DV file
+ {
+ //AVI Standard Index Chunk
+ AVI__hdlr_strl_indx();
+ Stream_ID=(int32u)(Element_Code&0xFFFF0000);
+ AVI__movi_StreamJump();
+ return;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVIX()
+{
+ //Filling
+ Fill(Stream_General, 0, General_Format_Profile, "OpenDML", Unlimited, true, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVIX_idx1()
+{
+ AVI__idx1();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVIX_movi()
+{
+ AVI__movi();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVIX_movi_rec_()
+{
+ AVI__movi_rec_();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVIX_movi_rec__xxxx()
+{
+ AVIX_movi_xxxx();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::AVIX_movi_xxxx()
+{
+ AVI__movi_xxxx();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::CADP()
+{
+ Element_Name("CMP4 - ADPCM");
+
+ //Testing if we have enough data
+ if (Element_Size<4)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ //Parsing
+ int32u Codec;
+ Get_C4 (Codec, "Codec");
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ Param("Data", Ztring("(")+Ztring::ToZtring(Element_TotalSize_Get()-Element_Offset)+Ztring(" bytes)"));
+ #endif //MEDIAINFO_TRACE
+ Element_Offset=Element_TotalSize_Get(); //Not using Skip_XX() because we want to skip data we don't have, and Skip_XX() does a test on size of buffer
+
+ FILLING_BEGIN();
+ Stream_Prepare(Stream_Audio);
+ if (Codec==0x41647063) //Adpc
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format, "ADPCM");
+ Fill(Stream_Audio, StreamPos_Last, Audio_StreamSize, Element_TotalSize_Get());
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::CDDA()
+{
+ Element_Name("Compact Disc for Digital Audio");
+
+ //Filling
+ Accept("CDDA");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::CDDA_fmt_()
+{
+ //Specs: http://fr.wikipedia.org/wiki/Compact_Disc_Audio_track
+ //Specs: http://www.moon-soft.com/program/FORMAT/sound/cda.htm
+
+ Element_Name("Stream format");
+
+ //Parsing
+ int32u id;
+ int16u Version, tracknb=1;
+ int8u TPositionF=0, TPositionS=0, TPositionM=0, TDurationF=0, TDurationS=0, TDurationM=0;
+ Get_L2 (Version, "Version"); // Always 1
+ if (Version!=1)
+ {
+ //Not supported
+ Skip_XX(Element_Size-2, "Data");
+ return;
+ }
+ Get_L2 (tracknb, "Number"); // Start at 1
+ Get_L4 (id, "id");
+ Skip_L4( "offset"); // in frames //Priority of FSM format
+ Skip_L4( "Duration"); // in frames //Priority of FSM format
+ Get_L1 (TPositionF, "Track_PositionF"); // in frames
+ Get_L1 (TPositionS, "Track_PositionS"); // in seconds
+ Get_L1 (TPositionM, "Track_PositionM"); // in minutes
+ Skip_L1( "empty");
+ Get_L1 (TDurationF, "Track_DurationF"); // in frames
+ Get_L1 (TDurationS, "Track_DurationS"); // in seconds
+ Get_L1 (TDurationM, "Track_DurationM"); // in minutes
+ Skip_L1( "empty");
+
+ FILLING_BEGIN();
+ int32u TPosition=TPositionM*60*75+TPositionS*75+TPositionF;
+ int32u TDuration=TDurationM*60*75+TDurationS*75+TDurationF;
+
+ Fill(Stream_General, 0, General_Track_Position, tracknb);
+ Fill(Stream_General, 0, General_Format, "CDDA");
+ Fill(Stream_General, 0, General_Format_Info, "Compact Disc for Digital Audio");
+ Fill(Stream_General, 0, General_UniqueID, id);
+ Fill(Stream_General, 0, General_FileSize, File_Size+TDuration*2352, 10, true);
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, 0, Audio_Format, "PCM");
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, "Little");
+ Fill(Stream_Audio, 0, Audio_BitDepth, 16);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, 2);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, 44100);
+ Fill(Stream_Audio, 0, Audio_FrameRate, 75);
+ Fill(Stream_Audio, 0, Audio_BitRate, 1411200);
+ Fill(Stream_Audio, 0, Audio_Compression_Mode, "Lossless");
+ Fill(Stream_Audio, 0, Audio_FrameCount, TDuration);
+ Fill(Stream_Audio, 0, Audio_Duration, float32_int32s(((float32)TDuration)*1000/75));
+ Fill(Stream_Audio, 0, Audio_Delay, float32_int32s(((float32)TPosition)*1000/75));
+
+ //No more need data
+ Finish("CDDA");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::CMJP()
+{
+ Element_Name("CMP4 - JPEG");
+
+ //Parsing
+ #ifdef MEDIAINFO_JPEG_YES
+ Stream_ID=0;
+ File_Jpeg* Parser=new File_Jpeg;
+ Open_Buffer_Init(Parser);
+ Parser->StreamKind=Stream_Video;
+ Open_Buffer_Continue(Parser);
+ Element_Offset=Element_TotalSize_Get(); //Not using Skip_XX() because we want to skip data we don't have, and Skip_XX() does a test on size of buffer
+
+ FILLING_BEGIN();
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, StreamPos_Last, Video_StreamSize, Element_TotalSize_Get());
+ Finish(Parser);
+ Merge(*Parser, StreamKind_Last, 0, StreamPos_Last);
+ FILLING_END();
+
+ Stream[Stream_ID].Parsers.push_back(Parser);
+ #else
+ Element_Offset=Element_TotalSize_Get(); //Not using Skip_XX() because we want to skip data we don't have, and Skip_XX() does a test on size of buffer
+
+ FILLING_BEGIN();
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, StreamPos_Last, Video_Format, "JPEG");
+ Fill(Stream_Video, StreamPos_Last, Video_StreamSize, Element_TotalSize_Get());
+ FILLING_END();
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::CMP4()
+{
+ Accept("CMP4");
+ Element_Name("CMP4 - Header");
+
+ //Parsing
+ Ztring Title;
+ Get_Local(Element_Size, Title, "Title");
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_Format, "CMP4");
+ Fill(Stream_General, 0, "Title", Title);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::IDVX()
+{
+ Element_Name("Tags");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::INDX()
+{
+ Element_Name("Index (from which spec?)");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::INDX_xxxx()
+{
+ Stream_ID=(int32u)(Element_Code&0xFFFF0000);
+
+ if (Stream_ID==0x69780000) //ix..
+ {
+ //Index
+ int32u Entry_Count, ChunkId;
+ int16u LongsPerEntry;
+ int8u IndexType, IndexSubType;
+ Get_L2 (LongsPerEntry, "LongsPerEntry"); //Size of each entry in aIndex array
+ Get_L1 (IndexSubType, "IndexSubType");
+ Get_L1 (IndexType, "IndexType");
+ Get_L4 (Entry_Count, "EntriesInUse"); //Index of first unused member in aIndex array
+ Get_C4 (ChunkId, "ChunkId"); //FCC of what is indexed
+
+ Skip_L4( "Unknown");
+ Skip_L4( "Unknown");
+ Skip_L4( "Unknown");
+
+ for (int32u Pos=0; Pos<Entry_Count; Pos++)
+ {
+ Skip_L8( "Offset");
+ Skip_L4( "Size");
+ Skip_L4( "Frame number?");
+ Skip_L4( "Frame number?");
+ Skip_L4( "Zero");
+ }
+ }
+
+ //Currently, we do not use the index
+ //TODO: use the index
+ Stream_Structure.clear();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::JUNK()
+{
+ Element_Name("Junk");
+
+ //Parse
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ Param("Junk", Ztring("(")+Ztring::ToZtring(Element_TotalSize_Get())+Ztring(" bytes)"));
+ #endif //MEDIAINFO_TRACE
+ Element_Offset=Element_TotalSize_Get(); //Not using Skip_XX() because we want to skip data we don't have, and Skip_XX() does a test on size of buffer
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::menu()
+{
+ Element_Name("DivX Menu");
+
+ //Filling
+ Stream_Prepare(Stream_Menu);
+ Fill(Stream_Menu, StreamPos_Last, Menu_Format, "DivX Menu");
+ Fill(Stream_Menu, StreamPos_Last, Menu_Codec, "DivX");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::MThd()
+{
+ Element_Name("MIDI header");
+
+ //Parsing
+ Skip_B2( "format");
+ Skip_B2( "ntrks");
+ Skip_B2( "division");
+
+ FILLING_BEGIN_PRECISE();
+ Accept("MIDI");
+ Fill(Stream_General, 0, General_Format, "MIDI");
+ FILLING_ELSE();
+ Reject("MIDI");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::MTrk()
+{
+ Element_Name("MIDI Track");
+
+ //Parsing
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ Param("Data", Ztring("(")+Ztring::ToZtring(Element_TotalSize_Get())+Ztring(" bytes)"));
+ #endif //MEDIAINFO_TRACE
+ Element_Offset=Element_TotalSize_Get(); //Not using Skip_XX() because we want to skip data we don't have, and Skip_XX() does a test on size of buffer
+
+ FILLING_BEGIN();
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format, "MIDI");
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, "Midi");
+
+ Finish("MIDI");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::PAL_()
+{
+ Data_Accept("RIFF Palette");
+ Element_Name("RIFF Palette");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "RIFF Palette");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::QLCM()
+{
+ Data_Accept("QLCM");
+ Element_Name("QLCM");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "QLCM");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::QLCM_fmt_()
+{
+ //Parsing
+ Ztring codec_name;
+ int128u codec_guid;
+ int32u num_rates;
+ int16u codec_version, average_bps, packet_size, block_size, sampling_rate, sample_size;
+ int8u major, minor;
+ Get_L1 (major, "major");
+ Get_L1 (minor, "minor");
+ Get_GUID(codec_guid, "codec-guid");
+ Get_L2 (codec_version, "codec-version");
+ Get_Local(80, codec_name, "codec-name");
+ Get_L2 (average_bps, "average-bps");
+ Get_L2 (packet_size, "packet-size");
+ Get_L2 (block_size, "block-size");
+ Get_L2 (sampling_rate, "sampling-rate");
+ Get_L2 (sample_size, "sample-size");
+ Element_Begin1("rate-map-table");
+ Get_L4 (num_rates, "num-rates");
+ for (int32u rate=0; rate<num_rates; rate++)
+ {
+ Skip_L2( "rate-size");
+ Skip_L2( "rate-octet");
+ }
+ Element_End0();
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ if (Element_Offset<Element_Size)
+ Skip_L4( "Reserved"); //Some files don't have the 5th reserved dword
+
+ FILLING_BEGIN_PRECISE();
+ Stream_Prepare (Stream_Audio);
+ switch (codec_guid.hi)
+ {
+ case Elements::QLCM_QCELP1 :
+ case Elements::QLCM_QCELP2 : Fill(Stream_Audio, 0, Audio_Format, "QCELP"); Fill(Stream_Audio, 0, Audio_Codec, "QCELP"); break;
+ case Elements::QLCM_EVRC : Fill(Stream_Audio, 0, Audio_Format, "EVRC"); Fill(Stream_Audio, 0, Audio_Codec, "EVRC"); break;
+ case Elements::QLCM_SMV : Fill(Stream_Audio, 0, Audio_Format, "SMV"); Fill(Stream_Audio, 0, Audio_Codec, "SMV"); break;
+ default : ;
+ }
+ Fill(Stream_Audio, 0, Audio_BitRate, average_bps);
+ Fill(Stream_Audio, 0, Audio_SamplingRate, sampling_rate);
+ Fill(Stream_Audio, 0, Audio_BitDepth, sample_size);
+ Fill(Stream_Audio, 0, Audio_Channel_s_, 1);
+ FILLING_END();
+}
+
+#if defined(MEDIAINFO_GXF_YES)
+//---------------------------------------------------------------------------
+void File_Riff::rcrd()
+{
+ Data_Accept("Ancillary media packets");
+ Element_Name("Ancillary media packets");
+
+ //Filling
+ if (Retrieve(Stream_General, 0, General_Format).empty())
+ Fill(Stream_General, 0, General_Format, "Ancillary media packets"); //GXF, RDD14-2007
+
+ //Clearing old data
+ if (Ancillary)
+ Open_Buffer_Continue(*Ancillary, Buffer, 0);
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::rcrd_desc()
+{
+ Element_Name("Ancillary media packet description");
+
+ //Parsing
+ int32u Version;
+ Get_L4 (Version, "Version");
+ if (Version==2)
+ {
+ Skip_L4( "Number of fields");
+ Skip_L4( "Length of the ancillary data field descriptions");
+ Skip_L4( "Byte size of the complete ancillary media packet");
+ Skip_L4( "Format of the video");
+ }
+ else
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::rcrd_fld_()
+{
+ Element_Name("Ancillary data field description");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::rcrd_fld__anc_()
+{
+ Element_Name("Ancillary data sample description");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::rcrd_fld__anc__pos_()
+{
+ Element_Name("Ancillary data sample description");
+
+ //Parsing
+ Skip_L4( "Video line number");
+ Skip_L4( "Ancillary video color difference or luma space");
+ Skip_L4( "Ancillary video space");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::rcrd_fld__anc__pyld()
+{
+ Element_Name("Ancillary data sample payload");
+
+ if (Ancillary)
+ {
+ (*Ancillary)->FrameInfo.DTS=FrameInfo.DTS;
+ Open_Buffer_Continue(*Ancillary);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::rcrd_fld__finf()
+{
+ Element_Name("Data field description");
+
+ //Parsing
+ Skip_L4( "Video field identifier");
+}
+#endif //MEDIAINFO_GXF_YES
+
+//---------------------------------------------------------------------------
+void File_Riff::RDIB()
+{
+ Data_Accept("RIFF DIB");
+ Element_Name("RIFF DIB");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "RIFF DIB");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::RMID()
+{
+ Data_Accept("RIFF MIDI");
+ Element_Name("RIFF MIDI");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "RIFF MIDI");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::RMMP()
+{
+ Data_Accept("RIFF MMP");
+ Element_Name("RIFF MMP");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "RIFF MMP");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::RMP3()
+{
+ Data_Accept("RMP3");
+ Element_Name("RMP3");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "RMP3");
+ Kind=Kind_Rmp3;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::RMP3_data()
+{
+ Element_Name("Raw datas");
+
+ FILLING_BEGIN();
+ Fill(Stream_Audio, 0, Audio_StreamSize, Buffer_DataToParse_End-Buffer_DataToParse_Begin);
+ FILLING_END();
+
+ //Parsing
+ Element_Code=0x30307762; //00wb
+
+ //Creating parser
+ File_Mpega* Parser=new File_Mpega;
+ Parser->CalculateDelay=true;
+ Parser->ShouldContinueParsing=true;
+ Open_Buffer_Init(Parser);
+ Stream[0x30300000].StreamKind=Stream_Audio;
+ Stream[0x30300000].StreamPos=0;
+ Stream[0x30300000].Parsers.push_back(Parser);
+ Stream_Prepare(Stream_Audio);
+
+ #if MEDIAINFO_DEMUX
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ Config->Demux_EventWasSent=true; //First set is to indicate the user that header is parsed
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::RMP3_data_Continue()
+{
+ #if MEDIAINFO_DEMUX
+ if (Element_Size)
+ {
+ Demux_random_access=true;
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ AVI__movi_xxxx();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::SMV0()
+{
+ Accept("SMV");
+
+ //Parsing
+ int8u Version;
+ Skip_C1( "Identifier (continuing)");
+ Get_C1 (Version, "Version");
+ Skip_C3( "Identifier (continuing)");
+ if (Version=='1')
+ {
+ int32u Width, Height, FrameRate, BlockSize, FrameCount;
+ Get_B3 (Width, "Width");
+ Get_B3 (Height, "Height");
+ Skip_B3( "0x000010");
+ Skip_B3( "0x000001");
+ Get_B3 (BlockSize, "Block size");
+ Get_B3 (FrameRate, "Frame rate");
+ Get_B3 (FrameCount, "Frame count");
+ Skip_B3( "0x000000");
+ Skip_B3( "0x000000");
+ Skip_B3( "0x000000");
+ Skip_B3( "0x010101");
+ Skip_B3( "0x010101");
+ Skip_B3( "0x010101");
+ Skip_B3( "0x010101");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format_Profile, "SMV v1");
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_MuxingMode, "SMV v1");
+ Fill(Stream_Video, 0, Video_Width, Width);
+ Fill(Stream_Video, 0, Video_Height, Height);
+ Fill(Stream_Video, 0, Video_FrameRate, (float)FrameRate);
+ Fill(Stream_Video, 0, Video_FrameCount, FrameCount);
+
+ Finish("SMV");
+ }
+ else if (Version=='2')
+ {
+ int32u Width, Height, FrameRate;
+ Get_L3 (Width, "Width");
+ Get_L3 (Height, "Height");
+ Skip_L3( "0x000010");
+ Skip_L3( "0x000001");
+ Get_L3 (SMV_BlockSize, "Block size");
+ Get_L3 (FrameRate, "Frame rate");
+ Get_L3 (SMV_FrameCount, "Frame count");
+ Skip_L3( "0x000001");
+ Skip_L3( "0x000000");
+ Skip_L3( "Frame rate");
+ Skip_L3( "0x010101");
+ Skip_L3( "0x010101");
+ Skip_L3( "0x010101");
+ Skip_L3( "0x010101");
+
+ //Filling
+ SMV_BlockSize+=3;
+ SMV_FrameCount++;
+ Fill(Stream_General, 0, General_Format_Profile, "SMV v2");
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "JPEG");
+ Fill(Stream_Video, 0, Video_Codec, "JPEG");
+ Fill(Stream_Video, 0, Video_MuxingMode, "SMV v2");
+ Fill(Stream_Video, 0, Video_Width, Width);
+ Fill(Stream_Video, 0, Video_Height, Height);
+ Fill(Stream_Video, 0, Video_FrameRate, FrameRate);
+ Fill(Stream_Video, 0, Video_FrameCount, SMV_FrameCount);
+ Fill(Stream_Video, 0, Video_StreamSize, SMV_BlockSize*SMV_FrameCount);
+ }
+ else
+ Finish("SMV");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::SMV0_xxxx()
+{
+ //Parsing
+ int32u Size;
+ Get_L3 (Size, "Size");
+ #if defined(MEDIAINFO_JPEG_YES)
+ //Creating the parser
+ File_Jpeg MI;
+ Open_Buffer_Init(&MI);
+
+ //Parsing
+ Open_Buffer_Continue(&MI, Size);
+
+ //Filling
+ Finish(&MI);
+ Merge(MI, Stream_Video, 0, StreamPos_Last);
+
+ //Positioning
+ Element_Offset+=Size;
+ #else
+ //Parsing
+ Skip_XX(Size, "JPEG data");
+ #endif
+ Skip_XX(Element_Size-Element_Offset, "Padding");
+
+ //Filling
+ Data_GoTo(File_Offset+Buffer_Offset+(size_t)Element_Size+(SMV_FrameCount-1)*SMV_BlockSize, "SMV");
+ SMV_BlockSize=0;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE()
+{
+ Data_Accept("Wave");
+ Element_Name("Wave");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "Wave");
+ Fill(Stream_Audio, 0, Audio_Format_Settings_Endianness, "Little");
+ Kind=Kind_Wave;
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE__pmx()
+{
+ Element_Name("XMP");
+
+ //Parsing
+ Ztring XML_Data;
+ Get_Local(Element_Size, XML_Data, "XML data");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE_aXML()
+{
+ Element_Name("aXML");
+
+ //Parsing
+ Skip_Local(Element_Size, "XML data");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE_bext()
+{
+ Element_Name("Broadcast extension");
+
+ //Parsing
+ Ztring Description, Originator, OriginatorReference, OriginationDate, OriginationTime, History;
+ int16u Version;
+ Get_Local(256, Description, "Description");
+ Get_Local( 32, Originator, "Originator");
+ Get_Local( 32, OriginatorReference, "OriginatorReference");
+ Get_Local( 10, OriginationDate, "OriginationDate");
+ Get_Local( 8, OriginationTime, "OriginationTime");
+ Get_L8 ( TimeReference, "TimeReference"); //To be divided by SamplesPerSec
+ Get_L2 ( Version, "Version");
+ if (Version==1)
+ Skip_UUID( "UMID");
+ Skip_XX (602-Element_Offset, "Reserved");
+ if (Element_Offset<Element_Size)
+ Get_Local(Element_Size-Element_Offset, History, "History");
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_Description, Description);
+ Fill(Stream_General, 0, General_Producer, Originator);
+ Fill(Stream_General, 0, "Producer_Reference", OriginatorReference);
+ Fill(Stream_General, 0, General_Encoded_Date, OriginationDate+_T(' ')+OriginationTime);
+ Fill(Stream_General, 0, General_Encoded_Library_Settings, History);
+ if (SamplesPerSec && TimeReference!=(int64u)-1)
+ {
+ Fill(Stream_Audio, 0, Audio_Delay, float64_int64s(((float64)TimeReference)*1000/SamplesPerSec));
+ Fill(Stream_Audio, 0, Audio_Delay_Source, "Container (bext)");
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE_cue_()
+{
+ Element_Name("Cue points");
+
+ //Parsing
+ int32u numCuePoints;
+ Get_L4(numCuePoints, "numCuePoints");
+ for (int32u Pos=0; Pos<numCuePoints; Pos++)
+ {
+ Element_Begin1("Cue point");
+ Skip_L4( "ID");
+ Skip_L4( "Position");
+ Skip_C4( "DataChunkID");
+ Skip_L4( "ChunkStart");
+ Skip_L4( "BlockStart");
+ Skip_L4( "SampleOffset");
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE_data()
+{
+ Element_Name("Raw datas");
+
+ /*
+ if (Element_TotalSize_Get()<100)
+ {
+ Skip_XX(Element_Size, "Unknown");
+ return; //This is maybe embeded in another container, and there is only the header (What is the junk?)
+ }
+ */
+
+ FILLING_BEGIN();
+ Fill(Stream_Audio, 0, Audio_StreamSize, Buffer_DataToParse_End-Buffer_DataToParse_Begin);
+ FILLING_END();
+
+ //Parsing
+ Element_Code=CC4("00wb");
+
+ FILLING_BEGIN();
+ int64u Duration=Retrieve(Stream_Audio, 0, Audio_Duration).To_int64u();
+ int64u BitRate=Retrieve(Stream_Audio, 0, Audio_BitRate).To_int64u();
+ if (Duration)
+ {
+ int64u BitRate_New=(Buffer_DataToParse_End-Buffer_DataToParse_Begin)*8*1000/Duration;
+ if (BitRate_New<BitRate*0.95 || BitRate_New>BitRate*1.05)
+ Fill(Stream_Audio, 0, Audio_BitRate, BitRate_New, 10, true); //Correcting the bitrate, it was false in the header
+ }
+ else if (BitRate)
+ {
+ if (IsSub)
+ //Retrieving "data" real size, in case of truncated files and/or wave header in another container
+ Duration=((int64u)LittleEndian2int32u(Buffer+Buffer_Offset-4))*8*1000/BitRate; //TODO: RF64 is not handled
+ else
+ Duration=(Buffer_DataToParse_End-Buffer_DataToParse_Begin)*8*1000/BitRate;
+ Fill(Stream_General, 0, General_Duration, Duration, 10, true);
+ Fill(Stream_Audio, 0, Audio_Duration, Duration, 10, true);
+ }
+ FILLING_END();
+
+ #if MEDIAINFO_DEMUX
+ if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
+ Config->Demux_EventWasSent=true; //First set is to indicate the user that header is parsed
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE_data_Continue()
+{
+ #if MEDIAINFO_DEMUX
+ if (Element_Size)
+ {
+ Demux_random_access=true;
+ Demux(Buffer+Buffer_Offset, (size_t)Element_Size, ContentType_MainStream);
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ AVI__movi_xxxx();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE_ds64()
+{
+ Element_Name("DataSize64");
+
+ //Parsing
+ int32u tableLength;
+ Skip_L8( "riffSize"); //Is directly read from the header parser
+ Get_L8 (WAVE_data_Size, "dataSize");
+ Get_L8 (WAVE_fact_samplesCount, "sampleCount");
+ Get_L4 (tableLength, "tableLength");
+ for (int32u Pos=0; Pos<tableLength; Pos++)
+ Skip_L8( "table[]");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE_fact()
+{
+ Element_Name("Sample count");
+
+ //Parsing
+ int64u SamplesCount64;
+ int32u SamplesCount;
+ Get_L4 (SamplesCount, "SamplesCount");
+ SamplesCount64=SamplesCount;
+ if (SamplesCount64==0xFFFFFFFF)
+ SamplesCount64=SamplesCount64;
+
+ FILLING_BEGIN();
+ int32u SamplingRate=Retrieve(Stream_Audio, 0, Audio_SamplingRate).To_int32u();
+ if (SamplingRate)
+ {
+ //Calculating
+ int64u Duration=(SamplesCount64*1000)/SamplingRate;
+
+ //Coherency test
+ bool IsOK=true;
+ if (File_Size!=(int64u)-1)
+ {
+ int64u BitRate=Retrieve(Stream_Audio, 0, Audio_BitRate).To_int64u();
+ int64u Duration_FromBitRate=File_Size*8*1000/BitRate;
+ if (Duration_FromBitRate>Duration*1.10 || Duration_FromBitRate<Duration*0.9)
+ IsOK=false;
+ }
+
+ //Filling
+ if (IsOK)
+ Fill(Stream_Audio, 0, Audio_Duration, Duration);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE_fmt_()
+{
+ //Compute the current codec ID
+ Stream_ID=0x30300000;
+ stream_Count=1;
+
+ Stream[0x30300000].fccType=Elements::AVI__hdlr_strl_strh_auds;
+ AVI__hdlr_strl_strf();
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE_ID3_()
+{
+ Element_Name("ID3v2 tags");
+
+ //Parsing
+ #if defined(MEDIAINFO_ID3V2_YES)
+ File_Id3v2 MI;
+ Open_Buffer_Init(&MI);
+ Open_Buffer_Continue(&MI);
+ Finish(&MI);
+ Merge(MI, Stream_General, 0, 0);
+ #endif
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::WAVE_iXML()
+{
+ Element_Name("iXML");
+
+ //Parsing
+ Skip_Local(Element_Size, "XML data");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::wave()
+{
+ Data_Accept("Wave64");
+ Element_Name("Wave64");
+
+ //Filling
+ Fill(Stream_General, 0, General_Format, "Wave64");
+}
+
+//---------------------------------------------------------------------------
+void File_Riff::W3DI()
+{
+ Element_Name("IDVX tags (Out of specs!)");
+
+ //Parsing
+ int32u Size=(int32u)Element_Size;
+ Ztring Title, Artist, Album, Unknown, Genre, Comment;
+ int32u TrackPos;
+ Get_Local(Size, Title, "Title");
+ Element_Offset=(int32u)Title.size();
+ Size-=(int32u)Title.size();
+ if (Size==0) return;
+ Skip_L1( "Zero"); Size--; //NULL char
+ Get_Local(Size, Artist, "Artist");
+ Element_Offset=(int32u)Title.size()+1+(int32u)Artist.size();
+ Size-=(int32u)Artist.size();
+ if (Size==0) return;
+ Skip_L1( "Zero"); Size--; //NULL char
+ Get_Local(Size, Album, "Album");
+ Element_Offset=(int32u)Title.size()+1+(int32u)Artist.size()+1+(int32u)Album.size();
+ Size-=(int32u)Album.size();
+ if (Size==0) return;
+ Skip_L1( "Zero"); Size--; //NULL char
+ Get_Local(Size, Unknown, "Unknown");
+ Element_Offset=(int32u)Title.size()+1+(int32u)Artist.size()+1+(int32u)Album.size()+1+(int32u)Unknown.size();
+ Size-=(int32u)Unknown.size();
+ if (Size==0) return;
+ Skip_L1( "Zero"); Size--; //NULL char
+ Get_Local(Size, Genre, "Genre");
+ Element_Offset=(int32u)Title.size()+1+(int32u)Artist.size()+1+(int32u)Album.size()+1+(int32u)Unknown.size()+1+(int32u)Genre.size();
+ Size-=(int32u)Genre.size();
+ if (Size==0) return;
+ Skip_L1( "Zero"); Size--; //NULL char
+ Get_Local(Size, Comment, "Comment");
+ Element_Offset=(int32u)Title.size()+1+(int32u)Artist.size()+1+(int32u)Album.size()+1+(int32u)Unknown.size()+1+(int32u)Genre.size()+1+(int32u)Comment.size();
+ Size-=(int32u)Comment.size();
+ if (Size==0) return;
+ Skip_L1( "Zero"); Size--; //NULL char
+ Get_L4 (TrackPos, "Track_Position");
+ if(Element_Offset+8<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ Element_Begin1("Footer");
+ Skip_L4( "Size");
+ Skip_C4( "Name");
+ Element_End0();
+
+ //Filling
+ Fill(Stream_General, 0, General_Track, Title);
+ Fill(Stream_General, 0, General_Performer, Artist);
+ Fill(Stream_General, 0, General_Album, Album);
+ Fill(Stream_General, 0, "Unknown", Unknown);
+ Fill(Stream_General, 0, General_Genre, Genre);
+ Fill(Stream_General, 0, General_Comment, Comment);
+ Fill(Stream_General, 0, General_Track_Position, TrackPos);
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_RIFF_YES
+
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Rm.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Rm.cpp
new file mode 100644
index 000000000..0b49f98d0
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Rm.cpp
@@ -0,0 +1,794 @@
+// File_Rm - Info for Real Media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_RM_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include <ZenLib/ZtringListList.h>
+#include <ZenLib/Utils.h>
+#include "MediaInfo/Multiple/File_Rm.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+// https://common.helixcommunity.org/2003/HCS_SDK_r5/htmfiles/rmff.htm
+// http://wiki.multimedia.cx/index.php?title=RealMedia
+
+//***************************************************************************
+// Const
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+namespace Elements
+{
+ const int32u RMF=0x2E524D46;
+ const int32u CONT=0x434F4E54;
+ const int32u DATA=0x44415441;
+ const int32u INDX=0x494E4458;
+ const int32u MDPR=0x4D445052;
+ const int32u PROP=0x50524F50;
+ const int32u RJMD=0x524A4D44;
+ const int32u RMJE=0x524D4A45;
+ const int32u RMMD=0x524D4D44;
+ const int32u TAG =0x54414700;
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Rm::File_Rm()
+:File__Analyze()
+{
+ //In
+ FromMKV_StreamType=Stream_Max;
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Rm::Header_Parse()
+{
+ //Specific case
+ if (FromMKV_StreamType!=Stream_Max)
+ {
+ //Filling
+ Header_Fill_Code(0, _T("Real Media Header"));
+ Header_Fill_Size(Element_Size);
+ return;
+ }
+
+ //Parsing
+ int32u Name, Size;
+ Get_C4 (Name, "Name");
+
+ if (Name==Elements::RMMD)
+ {
+ Size=8; //Name + Size of the Metadata section (after Version) in bytes.
+ }
+ else if (Name==Elements::RJMD)
+ {
+ Skip_B4( "Version");
+ Get_B4 (Size, "Size");
+ Size+=8; //Name + Version + Size of the section (after Version) in bytes.
+ if (Element_Size>=12)
+ Element_Offset-=8; //Is valid, so we must keep Version and size in the stream
+ }
+ else if (Name==Elements::RMJE)
+ {
+ Size=12;
+ }
+ else if ((Name&0xFFFFFF00)==Elements::TAG)
+ {
+ Name=Elements::TAG;
+ Element_Offset-=4;
+ Size=0;
+ }
+ else
+ {
+ Get_B4 (Size, "Size");
+ }
+
+ //Filling
+ Header_Fill_Code(Name, Ztring().From_CC4(Name));
+ Header_Fill_Size(Size);
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::Data_Parse()
+{
+ //Specific case
+ if (FromMKV_StreamType!=Stream_Max)
+ {
+ switch (FromMKV_StreamType)
+ {
+ case Stream_Video : MDPR_realvideo(); break;
+ case Stream_Audio : MDPR_realaudio(); break;
+ default : ;
+ }
+
+ Finish("RealMedia");
+ return;
+ }
+
+ //Parsing
+ DATA_BEGIN
+ ATOM( RMF)
+ ATOM(CONT)
+ LIST_SKIP(DATA)
+ ATOM(INDX)
+ ATOM(MDPR)
+ ATOM(PROP)
+ ATOM(RJMD)
+ ATOM(RMJE)
+ ATOM(RMMD)
+ ATOM(TAG)
+ DATA_END
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+#define NAME_VERSION(ELEMENT_NAME) \
+ Element_Name(ELEMENT_NAME); \
+ int16u Version; \
+ { \
+ Get_B2(Version, "ObjectVersion"); \
+ } \
+
+#define INTEGRITY_VERSION(_VERSION) \
+ if (Version>_VERSION) \
+ { \
+ Skip_XX(Element_Size-Element_Offset, "Data"); \
+ return; \
+ } \
+
+//---------------------------------------------------------------------------
+void File_Rm::RMF()
+{
+ NAME_VERSION("Real Media Format");
+ INTEGRITY_VERSION(1);
+
+ //Parsing
+ if (Element_Size==4)
+ Skip_B2( "file_version"); //The version of the RealMedia file.
+ else
+ Skip_B4( "file_version"); //The version of the RealMedia file.
+ Skip_B4( "num_headers"); //The number of headers in the header section that follow the RealMedia File Header.
+
+ //Filling
+ Accept("RealMedia");
+ Fill(Stream_General, 0, General_Format, "RealMedia");
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::CONT()
+{
+ NAME_VERSION("Content");
+ INTEGRITY_VERSION(0);
+
+ //Parsing
+ Ztring title, author, copyright, comment;
+ int16u title_len, author_len, copyright_len, comment_len;
+ Get_B2 (title_len, "title_len"); //The length of the title data in bytes.
+ Get_Local(title_len, title, "title"); //An array of ASCII characters that represents the title information for the RealMedia file.
+ Get_B2 (author_len, "author_len"); //The length of the author data in bytes.
+ Get_Local(author_len, author, "author"); //An array of ASCII characters that represents the author information for the RealMedia file.
+ Get_B2 (copyright_len, "copyright_len"); //The length of the copyright data in bytes.
+ Get_Local(copyright_len, copyright, "copyright"); //An array of ASCII characters that represents the copyright information for the RealMedia file.
+ Get_B2 (comment_len, "comment_len"); //The length of the comment data in bytes.
+ Get_Local(comment_len, comment, "comment"); //An array of ASCII characters that represents the comment information for the RealMedia file.
+
+ //Filling
+ Fill(Stream_General, 0, General_Title, title);
+ Fill(Stream_General, 0, General_Performer, author);
+ Fill(Stream_General, 0, General_Copyright, copyright);
+ Fill(Stream_General, 0, General_Comment, comment);
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::DATA()
+{
+ NAME_VERSION("Data");
+
+ //Currently, we stop here, enough info
+ Finish("RealMedia");
+ return;
+
+ /*
+ //Parsing
+ int32u num_packets;
+ int16u length;
+ int8u flags;
+ Get_B4 (num_packets, "num_packets"); //Number of packets in the data chunk.
+ Skip_B4( "next_data_header"); //Offset from start of file to the next data chunk. A non-zero value refers to the file offset of the next data chunk. A value of zero means there are no more data chunks in this file. This field is not typically used.
+ for (int32u Pos=0; Pos<num_packets; Pos++)
+ {
+ Element_Begin1("packet");
+ Get_B2 (Version, "object_version");
+ INTEGRITY_VERSION(1);
+ Get_B2 (length, "length"); //The length of the packet in bytes.
+ if (Version==0)
+ Element_Info1("Media_Packet_Header");
+ else
+ Element_Info1("Media_Packet_Header");
+ Skip_B2( "stream_number"); //The 16-bit alias used to associate data packets with their associated Media Properties Header.
+ Skip_B4( "timestamp"); //The time stamp of the packet in milliseconds.
+ if (Version==0)
+ {
+ Skip_B1( "packet_group"); //The packet group to which the packet belongs. If packet grouping is not used, set this field to 0 (zero).
+ Get_B1 (flags, "flags"); //Flags describing the properties of the packet.
+ Skip_Flags(flags, 0, "reliable"); //If this flag is set, the packet is delivered reliably.
+ Skip_Flags(flags, 1, "keyframe"); //If this flag is set, the packet is part of a key frame or in some way marks a boundary in your data stream.
+ }
+ if (Version==1)
+ {
+ Skip_B2( "asm_rule"); //The ASM rule assigned to this packet.
+ Skip_B1( "asm_Flags"); //Contains HX_ flags that dictate stream switching points.
+ }
+ if (Version==0)
+ Skip_XX(length-12, "data");
+ else
+ Skip_XX(length-13, "data");
+
+ //Stopping if too far
+ if (Pos>10)
+ {
+ Pos=num_packets;
+ Element_Info1("(...)");
+ }
+
+ Element_End0();
+ }
+ */
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::INDX()
+{
+ NAME_VERSION("INDeX");
+
+ //Parsing
+ int32u num_indices;
+ Get_B4 (num_indices, "num_indices"); //Number of index records in the index chunk.
+ Skip_B2( "stream_number"); //The stream number for which the index records in this index chunk are associated.
+ Skip_B4( "next_index_header"); //Offset from start of file to the next index chunk. This member enables RealMedia file format readers to find all the index chunks quickly. A value of zero for this member indicates there are no more index headers in this file.
+ for (int32u Pos=0; Pos<num_indices; Pos++)
+ {
+ Element_Begin1("index");
+ Get_B2 (Version, "object_version");
+ INTEGRITY_VERSION(0);
+ Element_Info1("Media_Packet_Header");
+ Skip_B4( "timestamp"); //The time stamp (in milliseconds) associated with this record.
+ Skip_B4( "offset"); //The offset from the start of the file at which this packet can be found.
+ Skip_B4( "packet_count_for_this_packet"); //The packet number of the packet for this record. This is the same number of packets that would have been seen had the file been played from the beginning to this point.
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::MDPR()
+{
+ NAME_VERSION("MeDia PRoperties");
+ INTEGRITY_VERSION(0);
+
+ //Parsing
+ Ztring stream_name;
+ std::string mime_type;
+ int32u avg_bit_rate, start_time, duration, type_specific_len;
+ int16u stream_number;
+ int8u stream_name_size, mime_type_size;
+ Get_B2 (stream_number, "stream_number"); //Unique value that identifies a physical stream
+ Skip_B4( "max_bit_rate"); //The maximum bit rate required to deliver this stream over a network.
+ Get_B4 (avg_bit_rate, "avg_bit_rate"); //The average bit rate required to deliver this stream over a network.
+ Skip_B4( "max_packet_size"); //The largest packet size (in bytes) in the stream of media data.
+ Skip_B4( "avg_packet_size"); //The average packet size (in bytes) in the stream of media data.
+ Get_B4 (start_time, "start_time"); //The time offset in milliseconds to add to the time stamp of each packet in a physical stream.
+ Skip_B4( "preroll"); //The time offset in milliseconds to subtract from the time stamp of each packet in a physical stream.
+ Get_B4 (duration, "duration"); //The duration of the stream in milliseconds.
+ Get_B1 (stream_name_size, "stream_name_size"); //The length of the following stream_name member in bytes.
+ Get_Local(stream_name_size, stream_name, "stream_name"); //A nonunique alias or name for the stream.
+ Get_B1 (mime_type_size, "mime_type_size"); //The length of the following mime_type field in bytes.
+ Get_String(mime_type_size, mime_type, "mime_type"); //A nonunique MIME style type/subtype string for data associated with the stream.
+ Get_B4 (type_specific_len, "type_specific_len"); //The length of the following type_specific_data in bytes
+
+ //Parsing TypeSpecific
+ Element_Info1(mime_type.c_str());
+ MDPR_IsStream=true;
+ if (mime_type=="audio/x-pn-multirate-realaudio")
+ MDPR_IsStream=false; //What do we with this?
+ else if (mime_type=="audio/X-MP3-draft-00")
+ {
+ Stream_Prepare(Stream_Audio);
+ CodecID_Fill(Ztring(mime_type.c_str()), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Real);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, "MPEG1AL3");
+ }
+ else if (mime_type=="audio/x-pn-realaudio")
+ MDPR_realaudio();
+ else if (mime_type=="audio/x-pn-realaudio-encrypted")
+ {
+ MDPR_realaudio();
+ Fill(Stream_Audio, StreamPos_Last, Audio_Encryption, "Y");
+ }
+ else if (mime_type=="audio/x-ralf-mpeg4")
+ {
+ Stream_Prepare(Stream_Audio);
+ CodecID_Fill(Ztring(mime_type.c_str()), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Real);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, "ralf");
+ }
+ else if (mime_type=="audio/x-ralf-mpeg4-generic")
+ {
+ Stream_Prepare(Stream_Audio);
+ CodecID_Fill(Ztring(mime_type.c_str()), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Real);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, "ralf");
+ }
+ else if (mime_type.find("audio/")==0)
+ Stream_Prepare(Stream_Audio);
+ else if (mime_type=="video/text")
+ Stream_Prepare(Stream_Text);
+ else if (mime_type=="video/x-pn-multirate-realvideo")
+ MDPR_IsStream=false; //What do we with this?
+ else if (mime_type=="video/x-pn-realvideo")
+ MDPR_realvideo();
+ else if (mime_type=="video/x-pn-realvideo-encrypted")
+ {
+ MDPR_realvideo();
+ Fill(Stream_Video, StreamPos_Last, Video_Encryption, "Y");
+ }
+ else if (mime_type.find("video/")==0)
+ Stream_Prepare(Stream_Video);
+ else if (mime_type=="logical-audio/x-pn-multirate-realaudio")
+ MDPR_IsStream=false; //What do we with this?
+ else if (mime_type.find("logical-audio/")==0)
+ MDPR_IsStream=false; //What do we with this?
+ else if (mime_type=="logical-fileinfo")
+ MDPR_fileinfo();
+ else if (mime_type=="logical-video/x-pn-multirate-realvideo")
+ MDPR_IsStream=false; //What do we with this?
+ else if (mime_type.find("logical-video/")==0)
+ MDPR_IsStream=false; //What do we with this?
+ else
+ MDPR_IsStream=false;
+
+ //Filling
+ FILLING_BEGIN();
+ if (MDPR_IsStream)
+ {
+ Fill(StreamKind_Last, StreamPos_Last, General_ID, stream_number);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_BitRate), avg_bit_rate, 10, true);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay), start_time);
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Delay_Source), "Container");
+ Fill(StreamKind_Last, StreamPos_Last, Fill_Parameter(StreamKind_Last, Generic_Duration), duration);
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::MDPR_realvideo()
+{
+ //Parsing
+ int32u Codec;
+ int16u Width, Height, FrameRate;
+ Skip_B4( "Size");
+ Skip_C4( "FCC");
+ Get_C4 (Codec, "Compression");
+ Get_B2 (Width, "Width");
+ Get_B2 (Height, "Height");
+ Skip_B2( "bpp"); //Do not use it
+ Skip_B4( "Unknown");
+ Get_B2 (FrameRate, "fps");
+ Skip_B2( "Unknown");
+ Skip_C4( "Type1");
+ Skip_C4( "Type2");
+
+ //Filling
+ if (!Status[IsAccepted])
+ Accept("RealMedia"); //Is subs
+
+ Stream_Prepare(Stream_Video);
+ if (FromMKV_StreamType==Stream_Max) //Using the one from the container
+ CodecID_Fill(Ztring().From_CC4(Codec), Stream_Video, StreamPos_Last, InfoCodecID_Format_Real);
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, Ztring().From_CC4(Codec));
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Width); //Width
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Height); //Height
+ switch (FrameRate)
+ {
+ case 23 : Fill(Stream_Video, StreamPos_Last, Video_FrameRate, ((float)24)*1000/1001); break; //Hard-coded frame rate?
+ case 29 : Fill(Stream_Video, StreamPos_Last, Video_FrameRate, ((float)30)*1000/1001); break; //Hard-coded frame rate?
+ default : Fill(Stream_Video, StreamPos_Last, Video_FrameRate, (float)FrameRate);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::MDPR_realaudio()
+{
+ //Parsing
+ Ztring FourCC3="lpcJ"; //description of this codec : http://focus.ti.com/lit/an/spra136/spra136.pdf http://en.wikipedia.org/wiki/VSELP
+ Ztring FourCC4;
+ int32u FourCC5=0, BytesPerMinute=0;
+ int16u Version, Samplerate=8000, Samplesize=16, Channels=0;
+ Skip_C4( "Header signature");
+ Get_B2 (Version, "Version");
+ INTEGRITY_VERSION(5);
+ if (Version==3)
+ {
+ Ztring title, author, copyright, comment;
+ int32u length;
+ int8u title_len, author_len, copyright_len, comment_len;
+ Skip_B2( "Header size"); //Header size, after this tag.
+ Get_B2 (Channels, "Channels");
+ Skip_B4( "Uknown");
+ Skip_B4( "Uknown");
+ Skip_B4( "Data size");
+ Get_B1 (title_len, "title_len"); //The length of the title data in bytes.
+ Get_Local(title_len, title, "title"); //An array of ASCII characters that represents the title information for the RealMedia file.
+ Get_B1 (author_len, "author_len"); //The length of the author data in bytes.
+ Get_Local(author_len, author, "author"); //An array of ASCII characters that represents the author information for the RealMedia file.
+ Get_B1 (copyright_len, "copyright_len"); //The length of the copyright data in bytes.
+ Get_Local(copyright_len, copyright, "copyright"); //An array of ASCII characters that represents the copyright information for the RealMedia file.
+ Get_B1 (comment_len, "comment_len"); //The length of the comment data in bytes.
+ Get_Local(comment_len, comment, "comment"); //An array of ASCII characters that represents the comment information for the RealMedia file.
+ if (Element_Offset<Element_Size) //Optional
+ {
+ Skip_B1( "Uknown");
+ Get_B4 (length, "Fourcc string length");
+ Get_Local(length, FourCC3, "Fourcc string");
+ }
+
+ //Filling
+ Fill(Stream_General, 0, General_Duration, title);
+ Fill(Stream_General, 0, General_Performer, author);
+ Fill(Stream_General, 0, General_Copyright, copyright);
+ Fill(Stream_General, 0, General_Comment, comment);
+ }
+ if (Version==4 || Version==5)
+ {
+ Skip_B2( "Unused");
+ Skip_C4( "ra signature");
+ Skip_B4( "AudioFileSize");
+ Skip_B2( "Version2");
+ Skip_B4( "Header size");
+ Skip_B2( "Codec flavor");
+ Skip_B4( "Coded frame size");
+ Skip_B4( "AudioBytes");
+ Get_B4 (BytesPerMinute, "BytesPerMinute");
+ Skip_B4( "Unknown");
+ Skip_B2( "Sub packet h");
+ Skip_B2( "Frame size");
+ Skip_B2( "Subpacket size");
+ Skip_B2( "Unknown");
+ }
+ if (Version==5)
+ {
+ Skip_B2( "Unknown");
+ Skip_B2( "Unknown");
+ Skip_B2( "Unknown");
+ }
+ if (Version==4 || Version==5)
+ {
+ Get_B2 (Samplerate, "Samplerate");
+ Skip_B2( "Unknown");
+ Get_B2 (Samplesize, "Samplesize");
+ Get_B2 (Channels, "Channels");
+ }
+ if (Version==4)
+ {
+ int8u length;
+ Get_B1 (length, "Interleaver ID string lengt");
+ Skip_Local(length, "Interleaver ID string");
+ Get_B1 (length, "FourCC string lengt");
+ Get_Local(length, FourCC4, "FourCC string");
+ }
+ if (Version==5)
+ {
+ Skip_C4( "Interleaver ID");
+ Get_C4 (FourCC5, "FourCC");
+ }
+ if (Version==4 || Version==5)
+ {
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ Skip_B1( "Unknown");
+ }
+ if (Version==5)
+ {
+ Skip_B1( "Unknown");
+ }
+ if (Version==4 || Version==5)
+ {
+ int32u length;
+ Get_B4 (length, "Codec extradata length");
+ Skip_XX(length, "Codec extradata");
+ }
+
+ //Filling
+ if (!Status[IsAccepted])
+ Accept("RealMedia"); //Is subs
+
+ Stream_Prepare(Stream_Audio);
+ if (Version==3)
+ {
+ if (FromMKV_StreamType==Stream_Max) //Using the one from the container
+ CodecID_Fill(FourCC3, Stream_Audio, StreamPos_Last, InfoCodecID_Format_Real);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, FourCC3);
+ }
+ if (Version==4)
+ {
+ if (FromMKV_StreamType==Stream_Max) //Using the one from the container
+ CodecID_Fill(FourCC4, Stream_Audio, StreamPos_Last, InfoCodecID_Format_Real);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, FourCC4);
+ }
+ if (Version==5)
+ {
+ if (FromMKV_StreamType==Stream_Max) //Using the one from the container
+ CodecID_Fill(Ztring().From_CC4(FourCC5), Stream_Audio, StreamPos_Last, InfoCodecID_Format_Real);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Ztring().From_CC4(FourCC5));
+ }
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, Samplerate);
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, Samplesize);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels);
+ if (BytesPerMinute)
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate, BytesPerMinute*8/60, 10, true);
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::MDPR_fileinfo()
+{
+ MDPR_IsStream=false;
+
+ //Parsing
+ int16u Version, num_physical_streams, num_rules, num_properties;
+ Skip_B4( "size");
+ Get_B2 (Version, "object_version");
+ INTEGRITY_VERSION(0);
+ Get_B2 (num_physical_streams, "num_physical_streams"); //The number of physical streams that make up this logical stream.
+ for (int16u Pos=0; Pos<num_physical_streams; Pos++)
+ {
+ Skip_B2( "physical_stream_numbers"); //The list of physical stream numbers that comprise this logical stream.
+ Skip_B4( "data_offsets"); //The list of data offsets indicating the start of the data section for each physical stream.
+ }
+ Get_B2 (num_rules, "num_rules"); //The number of ASM rules for the logical stream. Each physical stream in the logical stream has at least one ASM rule associated with it or it will never get played. The mapping of ASM rule numbers to physical stream numbers is stored in a list immediately following this member. These physical stream numbers refer to the stream_number field found in the Media Properties Object for each physical stream belonging to this logical stream.
+ for (int16u Pos=0; Pos<num_physical_streams; Pos++)
+ Skip_B2( "rule_to_physical_stream_number_map"); //The list of physical stream numbers that map to each rule. Each entry in the map corresponds to a 0-based rule number. The value in each entry is set to the physical stream number for the rule.
+ Get_B2 (num_properties, "num_properties"); //The number of NameValueProperty structures contained in this structure. These name/value structures can be used to identify properties of this logical stream (for example, language).
+
+ //Parsing
+ for (int16u Pos=0; Pos<num_properties; Pos++)
+ {
+ Element_Begin1("property");
+ std::string name;
+ int32u size, type;
+ int16u value_length;
+ int8u name_length;
+ Peek_B4(size);
+ Skip_B4( "size");
+ Skip_B2( "object_version");
+ Get_B1 (name_length, "name_length"); //The length of the name data.
+ Get_String(name_length, name, "name"); //The name string data.
+ Get_B4 (type, "type"); //The type of the value data.
+ Get_B2 (value_length, "value_length"); //value_length
+ switch (type)
+ {
+ case 0 : //Unsigned integer
+ Skip_B4( "value_data"); break; //unsigned integer
+ case 2 : //String
+ Skip_Local(value_length, "value_data"); break; //string
+ default : Skip_XX(value_length, "unknown");
+ }
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::PROP()
+{
+ NAME_VERSION("PROPerties");
+ INTEGRITY_VERSION(0);
+
+ //Parsing
+ int32u avg_bit_rate, duration;
+ int16u flags;
+ Skip_B4( "max_bit_rate"); //The maximum bit rate required to deliver this file over a network.
+ Get_B4 (avg_bit_rate, "avg_bit_rate"); //The average bit rate required to deliver this file over a network.
+ Skip_B4( "max_packet_size"); //The largest packet size (in bytes) in the media data.
+ Skip_B4( "avg_packet_size"); //The average packet size (in bytes) in the media data.
+ Skip_B4( "num_packets"); //The number of packets in the media data.
+ Get_B4 (duration, "duration"); //The duration of the file in milliseconds.
+ Skip_B4( "preroll"); //The number of milliseconds to prebuffer before starting playback.
+ Skip_B4( "index_offset"); //The offset in bytes from the start of the file to the start of the index header object.
+ Skip_B4( "data_offset"); //The offset in bytes from the start of the file to the start of the Data Section. \n Note: There can be a number of Data_Chunk_Headers in a RealMedia file. The data_offset value specifies the offset in bytes to the first Data_Chunk_Header. The offsets to the other Data_Chunk_Headers can be derived from the next_data_header field in a Data_Chunk_Header.
+ Skip_B2( "num_streams"); //The total number of media properties headers in the main headers section.
+ Get_B2 (flags, "flags"); //Bit mask containing information about this file.
+ Skip_Flags(flags, 0, "Save_Enabled"); //If 1, clients are allowed to save this file to disk.
+ Skip_Flags(flags, 1, "Perfect_Play"); //If 1, clients are instructed to use extra buffering.
+ Skip_Flags(flags, 2, "Live_Broadcast"); //If 1, these streams are from a live broadcast.
+ Skip_Flags(flags, 3, "Allow_Download");
+
+ //Filling
+ Fill(Stream_General, 0, General_OverallBitRate, avg_bit_rate);
+ Fill(Stream_General, 0, General_Duration, duration);
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::RJMD()
+{
+ Element_Name("Metadata Tag");
+
+ //Parsing
+ Skip_B4( "object_version");
+
+ //Parsing
+ RJMD_property(std::string());
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::RJMD_property(std::string Name)
+{
+ //Element_Name("Property");
+
+ //Parsing
+ Ztring value;
+ std::string name;
+ int32u type, flags, num_subproperties, name_length, value_length;
+ Element_Begin1("MetadataProperty");
+ Skip_B4( "size");
+ Get_B4 (type, "type");
+ Get_B4 (flags, "flags");
+ Skip_Flags(flags, 0, "readonly"); //Read only, cannot be modified.
+ Skip_Flags(flags, 1, "private"); //Private, do not expose to users.
+ Skip_Flags(flags, 2, "type_dexcriptor"); //Type descriptor used to further define type of value.
+ Skip_B4( "value_offset"); //The offset to the value_length , relative to the beginning of the MetadataProperty structure.
+ Skip_B4( "subproperties_offset"); //The offset to the subproperties_list , relative to the beginning of the MetadataProperty structure.
+ Get_B4 (num_subproperties, "num_subproperties"); //The number of subproperties for this MetadataProperty structure.
+ Get_B4 (name_length, "name_length"); //The length of the name data, including the null-terminator.
+ Get_String(name_length, name, "name"); //The name of the property (string data).
+ Get_B4 (value_length, "value_length"); //The length of the value data.
+ switch(type)
+ {
+ case 0x00 : //Nothing
+ Skip_XX(value_length, "Junk");
+ break;
+ case 0x01 : //String (text).
+ Get_Local(value_length, value, "value"); //String.
+ break;
+ case 0x02 : //Separated list of strings, separator specified as sub-property/type descriptor.
+ Get_Local(value_length, value, "value"); //String.
+ break;
+ case 0x03 : //Boolean flag—either 1 byte or 4 bytes, check size value.
+ switch(value_length)
+ {
+ case 1 : {
+ int8u valueI;
+ Get_L1(valueI, "value"); //1-byte boolean.
+ value.From_Number(valueI);
+ }
+ break;
+ case 4 : {
+ int32u valueI;
+ Get_L4(valueI, "value"); //4-byte boolean.
+ value.From_Number(valueI);
+ }
+ break;
+ default: Skip_XX(value_length, "Unknown");
+ }
+ break;
+ case 0x04 : //Four-byte integer.
+ {
+ int32u valueI;
+ Get_L4(valueI, "value");
+ value.From_Number(valueI);
+ }
+ break;
+ case 0x05 : //Byte stream.
+ Skip_XX(value_length, "Byte stream");
+ break;
+ case 0x06 : //String (URL).
+ Get_Local(value_length, value, "value"); //String.
+ break;
+ case 0x07 : //String representation of the date in the form: YYYYmmDDHHMMSS (m = month, M = minutes).
+ Get_Local(value_length, value, "value"); //String.
+ break;
+ case 0x08 : //String (file name)
+ Get_Local(value_length, value, "value"); //String.
+ break;
+ case 0x09 : //This property has subproperties, but its own value is empty.
+ Skip_XX(value_length, "junk");
+ break;
+ case 0x0A : //Large buffer of data, use sub-properties/type descriptors to identify mime-type.
+ Skip_XX(value_length, "data");
+ break;
+ default : //Unknown
+ Skip_XX(value_length, "unknown");
+ break;
+ }
+
+ //Filling
+ if (!Name.empty())
+ Name+='/';
+ Name+=name;
+ if (Name!="Track/Comments/DataSize"
+ && Name!="Track/Comments/MimeType"
+ )
+ Fill(Stream_General, 0, Name.c_str(), value);
+
+ //Parsing
+ for (int32u Pos=0; Pos<num_subproperties; Pos++)
+ {
+ Element_Begin1("PropListEntry");
+ Skip_B4( "offset"); //The offset for this indexed sub-property, relative to the beginning of the containing MetadataProperty.
+ Skip_B4( "num_props_for_name"); //The number of sub-properties that share the same name. For example, a lyrics property could have multiple versions as differentiated by the language sub-property type descriptor.
+ Element_End0();
+ }
+ for (int32u Pos=0; Pos<num_subproperties; Pos++)
+ {
+ RJMD_property(Name);
+ }
+
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::RMJE()
+{
+ Element_Name("Metadata Section Footer");
+
+ //Parsing
+ Skip_B4( "object_version");
+ Skip_B4( "size"); //The size of the preceding metadata tag.
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::RMMD()
+{
+ Element_Name("Metadata Section Header");
+
+ //Parsing
+ Skip_B4( "size"); //The size of the full metadata section in bytes.
+}
+
+//---------------------------------------------------------------------------
+void File_Rm::TAG()
+{
+ Element_Name("Id3v1 Tag");
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_RM_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Rm.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Rm.h
new file mode 100644
index 000000000..ff4d428f2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Rm.h
@@ -0,0 +1,76 @@
+// File_Rm - Info for Real Media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Real Media files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_RmH
+#define MediaInfo_File_RmH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Classe File_Rm
+//***************************************************************************
+
+class File_Rm : public File__Analyze
+{
+public :
+ //In
+ stream_t FromMKV_StreamType;
+
+public :
+ File_Rm();
+
+private :
+ //Buffer
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void RMF();
+ void CONT();
+ void DATA();
+ void INDX();
+ void MDPR();
+ void MDPR_realvideo();
+ void MDPR_realaudio();
+ void MDPR_fileinfo();
+ void PROP();
+ void RJMD();
+ void RJMD_property(std::string Name);
+ void RMJE();
+ void RMMD();
+ void TAG ();
+
+ //Temp
+ bool MDPR_IsStream;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_SequenceInfo.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_SequenceInfo.cpp
new file mode 100644
index 000000000..de2776684
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_SequenceInfo.cpp
@@ -0,0 +1,258 @@
+// File_SequenceInfo - Info for XML files starting with SEQUENCEINFO
+// Copyright (C) 2012-2012 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_SEQUENCEINFO_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_SequenceInfo.h"
+#include "MediaInfo/MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "MediaInfo/Multiple/File__ReferenceFilesHelper.h"
+#include "ZenLib/File.h"
+#include "ZenLib/Dir.h"
+#include "ZenLib/FileName.h"
+#include "ZenLib/Format/Http/Http_Utils.h"
+#include "tinyxml2.h"
+using namespace tinyxml2;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_SequenceInfo::File_SequenceInfo()
+:File__Analyze()
+{
+ #if MEDIAINFO_DEMUX
+ Demux_EventWasSent_Accept_Specific=true;
+ #endif //MEDIAINFO_DEMUX
+
+ //Temp
+ ReferenceFiles=NULL;
+}
+
+//---------------------------------------------------------------------------
+File_SequenceInfo::~File_SequenceInfo()
+{
+ delete ReferenceFiles; //ReferenceFiles=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_SequenceInfo::Streams_Finish()
+{
+ if (ReferenceFiles==NULL)
+ return;
+
+ ReferenceFiles->ParseReferences();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File_SequenceInfo::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ if (ReferenceFiles==NULL)
+ return 0;
+
+ return ReferenceFiles->Read_Buffer_Seek(Method, Value, ID);
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_SequenceInfo::FileHeader_Begin()
+{
+ XMLDocument document;
+ if (!FileHeader_Begin_XML(document))
+ return false;
+
+ {
+ XMLElement* Root=document.FirstChildElement("SEQUENCEINFO");
+ if (Root)
+ {
+ Accept("SequenceInfo");
+ Fill(Stream_General, 0, General_Format, "SequenceInfo");
+
+ ReferenceFiles=new File__ReferenceFilesHelper(this, Config);
+
+ File__ReferenceFilesHelper::reference ReferenceFile;
+ ReferenceFile.StreamKind=Stream_Video;
+
+ FileName FN(File_Name);
+ Ztring Base=FN.Path_Get();
+ size_t Pos=Base.rfind(PathSeparator);
+ if (Pos!=string::npos)
+ {
+ Ztring ToAdd=Base.substr(Pos, string::npos);
+ Pos=ToAdd.rfind(_T('_'));
+ Ztring DirectoryBase=Base;
+ DirectoryBase+=ToAdd;
+ DirectoryBase+=_T('_');
+
+ size_t DirNumberCount=1;
+ Ztring Directory=DirectoryBase;
+ for (; DirNumberCount<9; DirNumberCount++)
+ {
+ Directory+=_T('0');
+ if (Dir::Exists(Directory))
+ break;
+ }
+
+ if (DirNumberCount<9)
+ {
+ int32u DirNumber=0;
+ do
+ {
+ Ztring Number=Ztring::ToZtring(DirNumber);
+ if (Number.size()<DirNumberCount)
+ Number.insert(0, DirNumberCount-Number.size(), _T('0'));
+
+ Directory=DirectoryBase;
+ Directory+=Number;
+ if (!Dir::Exists(Directory))
+ break;
+
+ Ztring FileBase=Directory;
+ FileBase+=ToAdd;
+ FileBase+=_T('_');
+ FileBase+=_T('.');
+
+ size_t FileNumberCount=1;
+ Ztring FullFile=FileBase;
+ Ztring Extension;;
+ for (; FileNumberCount<10; FileNumberCount++)
+ {
+ FullFile.insert(FullFile.begin()+FullFile.size()-Extension.size()-1, _T('0'));
+ if (Extension.empty())
+ {
+ ZtringList List=Dir::GetAllFileNames(FullFile+_T('*'));
+ if (List.size()>=2)
+ {
+ FileNumberCount=(size_t)-1; //Problem, which one to choose?
+ break;
+ }
+ else if (List.size()==1)
+ {
+ FileName Temp(List[0]);
+ Extension=Temp.Extension_Get();
+ FileBase+=Extension;
+ FullFile=FileBase;
+ break;
+ }
+ }
+ else if (File::Exists(FullFile))
+ break;
+ }
+ bool FromZero=true;
+ if (FileNumberCount>=9)
+ {
+ //Trying with consecutive file numbers betweens dirs
+ Number=Ztring::ToZtring(ReferenceFile.FileNames.size());
+ FullFile=FileBase;
+ FullFile.insert(FullFile.size()-Extension.size()-1, Number);
+ FileNumberCount=Number.size();
+ if (!File::Exists(FullFile))
+ {
+ FileNumberCount++;
+ for (; FileNumberCount<10; FileNumberCount++)
+ {
+ FullFile.insert(FullFile.begin()+FullFile.size()-Extension.size()-Number.size()-1, _T('0'));
+ if (File::Exists(FullFile))
+ {
+ FromZero=false;
+ break;
+ }
+ }
+ }
+ else
+ FromZero=false;
+ }
+
+ if (FileNumberCount<9)
+ {
+ size_t FileNumber=FromZero?0:ReferenceFile.FileNames.size();
+ do
+ {
+ Number=Ztring::ToZtring(FileNumber);
+ if (Number.size()<FileNumberCount)
+ Number.insert(0, FileNumberCount-Number.size(), _T('0'));
+
+ FullFile=FileBase;
+ FullFile.insert(FullFile.size()-Extension.size()-1, Number);
+ if (!File::Exists(FullFile))
+ break;
+
+ ReferenceFile.FileNames.push_back(FullFile);
+
+ FileNumber++;
+ }
+ while (FileNumber<1000000000);
+ }
+
+ DirNumber++;
+ }
+ while (DirNumber<1000000000);
+
+ if (!ReferenceFile.FileNames.empty())
+ ReferenceFiles->References.push_back(ReferenceFile);
+ }
+ }
+ }
+ else
+ {
+ Reject("SequenceInfo");
+ return false;
+ }
+ }
+
+ //All should be OK...
+ return true;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_SEQUENCEINFO_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_SequenceInfo.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_SequenceInfo.h
new file mode 100644
index 000000000..4cc1dc9c0
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_SequenceInfo.h
@@ -0,0 +1,69 @@
+// File_SequenceInfo - Info for XML files starting with SEQUENCEINFO
+// Copyright (C) 2012-2012 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about XML files starting with SEQUENCEINFO
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_SequenceInfoH
+#define MediaInfo_File_SequenceInfoH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+class File__ReferenceFilesHelper;
+
+//***************************************************************************
+// Class File_SequenceInfo
+//***************************************************************************
+
+class File_SequenceInfo : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_SequenceInfo();
+ ~File_SequenceInfo();
+
+private :
+ //Streams management
+ void Streams_Finish ();
+
+ //Buffer - Global
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Temp
+ File__ReferenceFilesHelper* ReferenceFiles;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Skm.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Skm.cpp
new file mode 100644
index 000000000..68f2e3f71
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Skm.cpp
@@ -0,0 +1,201 @@
+// File_Skm - Info for Skm files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_SKM_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Skm.h"
+#if defined(MEDIAINFO_MPEG4V_YES)
+ #include "MediaInfo/Video/File_Mpeg4v.h"
+#endif
+#include "ZenLib/Utils.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Skm::File_Skm()
+:File__Analyze()
+{
+ //Configuration
+ MustSynchronize=true;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Skm::Streams_Finish()
+{
+ if (Stream.Parser)
+ {
+ Finish(Stream.Parser);
+ Merge(*Stream.Parser);
+ }
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Skm::FileHeader_Begin()
+{
+ if (Buffer_Size<5)
+ return false;
+ if (CC5(Buffer)!=0x444D534B4DLL) //DMSKM
+ {
+ Reject("SKM");
+ return false;
+ }
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Skm::FileHeader_Parse()
+{
+ Skip_C5( "Signature");
+
+ FILLING_BEGIN();
+ Accept("SKM");
+
+ Fill(Stream_General, 0, General_Format, "SKM");
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Skm::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (CC3(Buffer+Buffer_Offset)!=0x000001)
+ Synched=false;
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Skm::Header_Parse()
+{
+ //Parsing
+ int32u BodyLength;
+ int8u Type;
+ Skip_B4( "PreviousTagSize");
+ if (File_Offset+Buffer_Offset+4<File_Size)
+ {
+ Get_B1 (Type, "Type"); //Param_Info1(Type<19?Flv_Type[Type]:_T("Unknown"));
+ Get_B3 (BodyLength, "BodyLength");
+ Skip_B3( "Timestamp_Base"); //in ms
+ Skip_B1( "Timestamp_Extended"); //TimeStamp = Timestamp_Extended*0x01000000+Timestamp_Base
+ Skip_B3( "StreamID");
+ }
+ else
+ {
+ Type=0;
+ BodyLength=0;
+ }
+
+ //Filling
+ Header_Fill_Code(Type, Ztring().From_Number(Type, 16));
+ Header_Fill_Size(Element_Offset+BodyLength);
+}
+
+//---------------------------------------------------------------------------
+bool File_Skm::Header_Parse_Fill_Size()
+{
+ //Look for next Sync word
+ if (Buffer_Offset_Temp==0) //Buffer_Offset_Temp is not 0 if Header_Parse_Fill_Size() has already parsed first frames
+ Buffer_Offset_Temp=Buffer_Offset+4;
+ while (Buffer_Offset_Temp+4<=Buffer_Size
+ && CC3(Buffer+Buffer_Offset_Temp)!=0x000001)
+ {
+ Buffer_Offset_Temp+=2;
+ while(Buffer_Offset_Temp<Buffer_Size && Buffer[Buffer_Offset_Temp]!=0x00)
+ Buffer_Offset_Temp+=2;
+ if (Buffer[Buffer_Offset_Temp-1]==0x00)
+ Buffer_Offset_Temp--;
+ }
+
+ //Must wait more data?
+ if (Buffer_Offset_Temp+4>Buffer_Size)
+ {
+ if (File_Offset+Buffer_Size==File_Size)
+ Buffer_Offset_Temp=Buffer_Size; //We are sure that the next bytes are a start
+ else
+ return false;
+ }
+
+ //OK, we continue
+ Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset);
+ Buffer_Offset_Temp=0;
+ return true;
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Skm::Data_Parse()
+{
+ #if defined(MEDIAINFO_MPEG4V_YES)
+ Stream.Parser=new File_Mpeg4v();
+ ((File_Mpeg4v*)Stream.Parser)->FrameIsAlwaysComplete=true;
+ ((File_Mpeg4v*)Stream.Parser)->OnlyVOP();
+ Open_Buffer_Init(Stream.Parser);
+ Open_Buffer_Continue(Stream.Parser);
+ Finish("SKM");
+ #endif
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_SKM_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Skm.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Skm.h
new file mode 100644
index 000000000..0b049428a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Skm.h
@@ -0,0 +1,83 @@
+// File_Skm - Info for SKM files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about SKM (Korean mobilphoner) files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_SkmH
+#define MediaInfo_File_SkmH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Skm
+//***************************************************************************
+
+class File_Skm : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Skm();
+
+private :
+ //Streams management
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Synchro
+ bool Synchronize() {return Synchronize_0x000001();}
+ bool Synched_Test();
+
+ //Buffer - Per element
+ void Header_Parse();
+ bool Header_Parse_Fill_Size();
+ void Data_Parse();
+
+ //Streams
+ struct stream
+ {
+ File__Analyze* Parser;
+
+ stream()
+ {
+ Parser=NULL;
+ }
+
+ ~stream()
+ {
+ delete Parser; //Parser=NULL;
+ }
+ };
+ stream Stream;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Swf.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Swf.cpp
new file mode 100644
index 000000000..a6d1ea120
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Swf.cpp
@@ -0,0 +1,706 @@
+// File_Swf - Info for SWF files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_SWF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Swf.h"
+#include <zlib.h>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const int8u Swf_SoundType[]=
+{
+ 1,
+ 2,
+};
+
+//---------------------------------------------------------------------------
+const int8u Swf_SoundSize[]=
+{
+ 8,
+ 16,
+};
+
+//---------------------------------------------------------------------------
+const int16u Swf_SoundRate[]=
+{
+ 5500,
+ 11025,
+ 22050,
+ 44100,
+};
+
+//---------------------------------------------------------------------------
+const char* Swf_Format_Audio[]=
+{
+ "PCM",
+ "ADPCM",
+ "MPEG Audio",
+ "PCM",
+ "Nellymoser",
+ "Nellymoser",
+ "Nellymoser",
+ "",
+ "",
+ "",
+ "",
+ "Speex",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Swf_Format_Version_Audio[]=
+{
+ "",
+ "",
+ "Version 1",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Swf_Format_Profile_Audio[]=
+{
+ "",
+ "",
+ "Layer 3",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Swf_SoundFormat[]=
+{
+ "Uncompressed",
+ "SWF ADPCM",
+ "MPEG-1L3",
+ "Uncompressed Little Endian",
+ "",
+ "",
+ "Nellymoser",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Swf_Format_Video[]=
+{
+ "",
+ "",
+ "H.263",
+ "Screen video",
+ "VP6",
+ "VP6",
+ "Screen video 2",
+ "AVC",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Swf_Format_Profile_Video[]=
+{
+ "",
+ "",
+ "",
+ "",
+ "",
+ "Alpha channel",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Swf_Codec_Video[]=
+{
+ "",
+ "",
+ "Sorenson H263",
+ "Screen video",
+ "On2 VP6",
+ "On2 VP6 with alpha channel",
+ "Screen video 2",
+ "AVC",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+namespace Elements
+{
+ const int16u End = 0; //V1+
+ const int16u ShowFrame = 1; //V1+
+ const int16u DefineShape = 2; //V1+
+ const int16u PlaceObject = 4; //V1+
+ const int16u RemoveObject = 5; //V1+
+ const int16u DefineBits = 6; //V1+
+ const int16u DefineButton = 7; //V1+
+ const int16u JPEGTables = 8; //V1+
+ const int16u SetBackgroundColor = 9; //V1+
+ const int16u DefineFont = 10; //V1+
+ const int16u DefineText = 11; //V1+
+ const int16u DoAction = 12; //V3+
+ const int16u DefineFontInfo = 13; //V1+
+ const int16u DefineSound = 14; //V1+
+ const int16u StartSound = 15; //V1+
+ const int16u DefineButtonSound = 17; //V2+
+ const int16u SoundStreamHead = 18; //V1+
+ const int16u SoundStreamBlock = 19; //V1+
+ const int16u DefineBitsLossless = 20; //V2+
+ const int16u DefineBitsJPEG2 = 21; //V2+
+ const int16u DefineShape2 = 22; //V2+
+ const int16u DefineCxform = 23; //V2+
+ const int16u Protect = 24; //V2+
+ const int16u PlaceObject2 = 26; //V3+
+ const int16u RemoveObject2 = 28; //V3+
+ const int16u DefineShape3 = 32; //V3+
+ const int16u DefineText2 = 33; //V3+
+ const int16u DefineButton2 = 34; //V3+
+ const int16u DefineBitsJPEG3 = 35; //V3+
+ const int16u DefineBitsLossless2 = 36; //V3+
+ const int16u DefineEditText = 37; //V4+
+ const int16u DefineSprite = 39; //V3+
+ const int16u FrameLabel = 43; //V3+
+ const int16u SoundStreamHead2 = 45; //V3+
+ const int16u DefineMorphShape = 46; //V3+
+ const int16u DefineFont2 = 48; //V3+
+ const int16u ExportAssets = 56; //V5+
+ const int16u ImportAssets = 57; //V5+
+ const int16u EnableDebugger = 58; //V5
+ const int16u DoInitAction = 59; //V6+
+ const int16u DefineVideoStream = 60; //V6+
+ const int16u DefineVideoFrame = 61; //V6+
+ const int16u DefineFontInfo2 = 62; //V6+
+ const int16u EnableDebugger2 = 64; //V6+
+ const int16u ScriptLimits = 65; //V6+
+ const int16u SetTabIndex = 66; //V7+
+ const int16u FileAttributes = 69; //V1+
+ const int16u PlaceObject3 = 70; //V8+
+ const int16u ImportAssets2 = 71; //V8+
+ const int16u DefineFontAlignZones = 73; //V8+
+ const int16u CSMTextSettings = 74; //V8+
+ const int16u DefineFont3 = 75; //V8+
+ const int16u SymbolClass = 76; //V9+
+ const int16u Metadata = 77; //V1+
+ const int16u DefineScalingGrid = 78; //V8+
+ const int16u DoABC = 82; //V9+
+ const int16u DefineShape4 = 83; //V8+
+ const int16u DefineMorphShape2 = 84; //V8+
+ const int16u DefineSceneAndFrameLabelData = 86; //V9+
+ const int16u DefineBinaryData = 87; //V9+
+ const int16u DefineFontName = 88; //V9+
+ const int16u StartSound2 = 89; //V9+
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Swf::File_Swf()
+:File__Analyze()
+{
+ //In
+ Frame_Count_Valid=1024;
+ FileLength=0;
+ Version=0;
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Swf::FileHeader_Begin()
+{
+ //Parsing
+ if (Buffer_Size<8)
+ return false;
+
+ if (CC3(Buffer)!=0x435753) //CWS
+ return true;
+
+ //Compressed file
+ if (File_Size>16*1024*1024)
+ return true; //The file is too big, we will not parse all, only say this is SWF
+ if (CC4(Buffer+4)<4*16*1024*1024) //FileLength
+ return true; //The file is too big, we will not parse all, only say this is SWF
+ Buffer_MaximumSize=(size_t)File_Size;
+ if (Buffer_Size!=File_Size)
+ return false;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Swf::FileHeader_Parse()
+{
+ //Parsing
+ int32u Signature;
+ if (FileLength==0 && Version==0)
+ {
+ Element_Begin1("SWF header");
+ Get_C3 (Signature, "Signature");
+ Get_L1 (Version, "Version");
+ Get_L4 (FileLength, "FileLength");
+ Element_End0();
+ }
+ else
+ {
+ //Was already done by compressed file handling
+ Signature=0x465753;
+ }
+
+ //Compressed file handling
+ if (Signature==0x435753) //CWS
+ {
+ Decompress();
+ return;
+ }
+
+ //Parsing
+ //Parsing - BitStream
+ float32 FrameRate;
+ int32u Xmin, Xmax, Ymin, Ymax;
+ int16u FrameCount;
+ int8u Nbits;
+ BS_Begin();
+ Get_S1 (5, Nbits, "Nbits");
+ Get_BS (Nbits, Xmin, "Xmin");
+ Get_BS (Nbits, Xmax, "Xmax"); Param_Info2((Xmax-Xmin)/20, " pixels");
+ Get_BS (Nbits, Ymin, "Ymin");
+ Get_BS (Nbits, Ymax, "Ymax"); Param_Info2((Ymax-Ymin)/20, " pixels");
+ BS_End();
+ if (Version<=7)
+ {
+ int8u FrameRate_8;
+ Skip_L1( "Ignored");
+ Get_L1 (FrameRate_8, "FrameRate");
+ FrameRate=FrameRate_8;
+ }
+ else
+ {
+ int16u FrameRate_8_8;
+ Get_L2(FrameRate_8_8, "FrameRate");
+ FrameRate=FrameRate_8_8/0x0100+(((float32)(FrameRate_8_8&0x00FF))/0x0100); //8.8 format
+ Param_Info1(FrameRate);
+ }
+ Get_L2 (FrameCount, "FrameCount");
+
+ FILLING_BEGIN();
+ //Integrity
+ if (Signature!=0x465753 && Signature!=0x435753) //FWS or CWS
+ {
+ Reject("SWF");
+ return;
+ }
+
+ //Filling
+ Accept("SWF");
+
+ if (!IsSub)
+ Fill(Stream_General, 0, General_Format, "ShockWave");
+
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Width, (Xmax-Xmin)/20);
+ Fill(Stream_Video, 0, Video_Height, (Ymax-Ymin)/20);
+ if (FrameRate)
+ Fill(Stream_Video, 0, Video_FrameRate, FrameRate);
+ if (FrameCount)
+ Fill(Stream_Video, 0, Video_FrameCount, FrameCount);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Swf::Header_Parse()
+{
+ //Parsing
+ int16u TagCodeAndLength;
+ Get_L2 (TagCodeAndLength, "TagCodeAndLength");
+
+ //Filling
+ int16u Tag=(TagCodeAndLength&0xFFC0)>>6; Param_Info1(Tag);
+ Header_Fill_Code(Tag, Ztring().From_Number(Tag, 16));
+
+ //Size
+ int16u Length=TagCodeAndLength&0x003F;
+ if (Length<0x003F)
+ {
+ Param_Info2(Length, " bytes");
+
+ //Filling
+ Header_Fill_Size(Element_Offset+Length);
+ }
+ else
+ {
+ int32u Length2;
+ Get_L4(Length2, "Length"); Param_Info2(Length2, " bytes");
+
+ //Filling
+ Header_Fill_Size(Element_Offset+Length2);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Swf::Data_Parse()
+{
+ #define LIS2(_ATOM, _NAME) \
+ case Elements::_ATOM : \
+ if (Level==Element_Level) \
+ { \
+ Element_Name(_NAME); \
+ _ATOM(); \
+ Element_ThisIsAList(); \
+ } \
+
+ #define ATO2(_ATOM, _NAME) \
+ case Elements::_ATOM : \
+ if (Level==Element_Level) \
+ { \
+ if (Element_IsComplete_Get()) \
+ { \
+ Element_Name(_NAME); \
+ _ATOM(); \
+ } \
+ else \
+ { \
+ Element_WaitForMoreData(); \
+ return; \
+ } \
+ } \
+ break; \
+
+ //Parsing
+ DATA_BEGIN
+ ATO2(End, "End");
+ ATO2(ShowFrame, "ShowFrame");
+ ATO2(DefineShape, "DefineShape");
+ ATO2(PlaceObject, "PlaceObject");
+ ATO2(RemoveObject, "RemoveObject");
+ ATO2(DefineBits, "DefineBits");
+ ATO2(DefineButton, "DefineButton");
+ ATO2(JPEGTables, "JPEGTables");
+ ATO2(SetBackgroundColor, "SetBackgroundColor");
+ ATO2(DefineFont, "DefineFont");
+ ATO2(DefineText, "DefineText");
+ ATO2(DoAction, "DoAction");
+ ATO2(DefineFontInfo, "DefineFontInfo");
+ ATO2(DefineSound, "DefineSound");
+ ATO2(StartSound, "StartSound");
+ ATO2(DefineButtonSound, "DefineButtonSound");
+ ATO2(SoundStreamHead, "SoundStreamHead");
+ ATO2(SoundStreamBlock, "SoundStreamBlock");
+ ATO2(DefineBitsLossless, "DefineBitsLossless");
+ ATO2(DefineBitsJPEG2, "DefineBitsJPEG2");
+ ATO2(DefineShape2, "DefineShape2");
+ ATO2(DefineCxform, "DefineCxform");
+ ATO2(Protect, "Protect");
+ ATO2(PlaceObject2, "PlaceObject2");
+ ATO2(RemoveObject2, "RemoveObject2");
+ ATO2(DefineShape3, "DefineShape3");
+ ATO2(DefineText2, "DefineText2");
+ ATO2(DefineButton2, "DefineButton2");
+ ATO2(DefineBitsJPEG3, "DefineBitsJPEG3");
+ ATO2(DefineBitsLossless2, "DefineBitsLossless2");
+ ATO2(DefineEditText, "DefineEditText");
+ LIS2(DefineSprite, "DefineSprite");
+ ATOM_BEGIN
+ ATO2(ShowFrame, "ShowFrame");
+ ATO2(PlaceObject, "PlaceObject");
+ ATO2(RemoveObject, "RemoveObject");
+ ATO2(StartSound, "StartSound");
+ ATO2(SoundStreamHead, "SoundStreamHead");
+ ATO2(SoundStreamBlock, "SoundStreamBlock");
+ ATO2(PlaceObject2, "PlaceObject2");
+ ATO2(RemoveObject2, "RemoveObject2");
+ ATO2(FrameLabel, "FrameLabel");
+ ATO2(SoundStreamHead2, "SoundStreamHead2");
+ ATO2(End, "End");
+ ATOM_END
+ ATO2(FrameLabel, "FrameLabel");
+ ATO2(DefineMorphShape, "DefineMorphShape");
+ ATO2(SoundStreamHead2, "SoundStreamHead2");
+ ATO2(DefineFont2, "DefineFont2");
+ ATO2(ExportAssets, "ExportAssets");
+ ATO2(ImportAssets, "ImportAssets");
+ ATO2(EnableDebugger, "EnableDebugger");
+ ATO2(DoInitAction, "DoInitAction");
+ ATO2(DefineVideoStream, "DefineVideoStream");
+ ATO2(DefineVideoFrame, "DefineVideoFrame");
+ ATO2(DefineFontInfo2, "DefineFontInfo2");
+ ATO2(EnableDebugger2, "EnableDebugger2");
+ ATO2(ScriptLimits, "ScriptLimits");
+ ATO2(SetTabIndex, "SetTabIndex");
+ ATO2(FileAttributes, "FileAttributes");
+ ATO2(PlaceObject3, "PlaceObject3");
+ ATO2(ImportAssets2, "ImportAssets2");
+ ATO2(DefineFontAlignZones, "DefineFontAlignZones");
+ ATO2(CSMTextSettings, "CSMTextSettings");
+ ATO2(DefineFont3, "DefineFont3");
+ ATO2(SymbolClass, "SymbolClass");
+ ATO2(Metadata, "Metadata");
+ ATO2(DefineScalingGrid, "DefineScalingGrid");
+ ATO2(DoABC, "DoABC");
+ ATO2(DefineShape4, "DefineShape4");
+ ATO2(DefineMorphShape2, "DefineMorphShape2");
+ ATO2(DefineSceneAndFrameLabelData, "DefineSceneAndFrameLabelData");
+ ATO2(DefineBinaryData, "DefineBinaryData");
+ ATO2(DefineFontName, "DefineFontName");
+ ATO2(StartSound2, "StartSound2");
+ DATA_END
+
+ Frame_Count++;
+ if (Frame_Count>=Frame_Count_Valid)
+ Data_Finish("SWF");
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Swf::DefineSound()
+{
+ //Parsing
+ int16u SoundId;
+ int8u SoundFormat, SoundRate, SoundSize, SoundType;
+ Get_L2 (SoundId, "SoundId");
+ BS_Begin();
+ Get_S1 (4, SoundFormat, "SoundFormat"); Param_Info1(Swf_SoundFormat[SoundFormat]);
+ Get_S1 (2, SoundRate, "SoundRate"); Param_Info2(Swf_SoundRate[SoundRate], " Hz");
+ Get_S1 (1, SoundSize, "SoundSize"); Param_Info2(Swf_SoundSize[SoundSize], " bits");
+ Get_S1 (1, SoundType, "SoundType"); Param_Info2(Swf_SoundType[SoundType], " channel(s)");
+ BS_End();
+ Skip_L4( "SoundSampleCount");
+ Skip_XX(Element_Size-Element_Offset, "SoundData");
+
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, StreamPos_Last, Audio_ID, SoundId);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format, Swf_Format_Audio[SoundFormat]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Version, Swf_Format_Version_Audio[SoundFormat]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, Swf_Format_Profile_Audio[SoundFormat]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Swf_SoundFormat[SoundFormat]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, Swf_SoundRate[SoundRate]);
+ if (SoundFormat!=2) //SoundSize is not valid for MPEG Audio
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, Swf_SoundSize[SoundSize]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Swf_SoundType[SoundType]);
+}
+
+//---------------------------------------------------------------------------
+void File_Swf::SoundStreamHead()
+{
+ //Parsing
+ int16u StreamSoundSampleCount;
+ int8u StreamSoundCompression, StreamSoundRate, StreamSoundType, StreamSoundSize;
+ BS_Begin();
+ Skip_S1(4, "Reserved");
+ Info_S1(2, PlaybackSoundRate, "PlaybackSoundRate"); Param_Info2(Swf_SoundRate[PlaybackSoundRate], " Hz");
+ Info_S1(1, PlaybackSoundSize, "PlaybackSoundSize"); Param_Info2(Swf_SoundSize[PlaybackSoundSize], " bits");
+ Info_S1(1, PlaybackSoundType, "PlaybackSoundType"); Param_Info2(Swf_SoundType[PlaybackSoundType], " channel(s)");
+ Get_S1 (4, StreamSoundCompression, "StreamSoundCompression"); Param_Info1(Swf_SoundFormat[StreamSoundCompression]);
+ Get_S1 (2, StreamSoundRate, "StreamSoundRate"); Param_Info2(Swf_SoundRate[StreamSoundRate], " Hz");
+ Get_S1 (1, StreamSoundSize, "StreamSoundSize"); Param_Info2(Swf_SoundSize[StreamSoundSize], " bits");
+ Get_S1 (1, StreamSoundType, "StreamSoundType"); Param_Info2(Swf_SoundType[StreamSoundType], " channel(s)");
+ BS_End();
+ Get_L2 (StreamSoundSampleCount, "StreamSoundSampleCount");
+ if (StreamSoundCompression==2)
+ Skip_L2( "LatencySeek");
+
+ if (StreamSoundSampleCount>0)
+ {
+ Stream_Prepare(Stream_Audio);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format, Swf_Format_Audio[StreamSoundCompression]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Version, Swf_Format_Version_Audio[StreamSoundCompression]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Format_Profile, Swf_Format_Profile_Audio[StreamSoundCompression]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Swf_SoundFormat[StreamSoundCompression]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, Swf_SoundRate[StreamSoundRate]);
+ if (StreamSoundCompression!=2) //SoundSize is not valid for MPEG Audio
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, Swf_SoundSize[StreamSoundSize]);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Swf_SoundType[StreamSoundType]);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Swf::DefineSprite()
+{
+ //Parsing
+ Skip_B2( "Character ID of sprite");
+ Skip_B2( "Number of frames in sprite");
+}
+
+//---------------------------------------------------------------------------
+void File_Swf::DefineVideoStream()
+{
+ //Parsing
+ int16u CharacterID, NumFrames, Width, Height;
+ int8u CodecID;
+ Get_L2 (CharacterID, "CharacterID");
+ Get_L2 (NumFrames, "NumFrames");
+ Get_L2 (Width, "Width");
+ Get_L2 (Height, "Height");
+ BS_Begin();
+ Skip_BS(4, "VideoFlagsReserved");
+ Skip_BS(3, "VideoFlagsDeblocking");
+ Skip_BS(1, "VideoFlagsSmoothing");
+ BS_End();
+ Get_L1 (CodecID, "CodecID"); Param_Info1(Swf_Format_Video[CodecID]);
+ if (CodecID>=16)
+ CodecID=0; //Should never happen (FLV is only 4-bit sized)
+
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, StreamPos_Last, Video_ID, CharacterID);
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Width);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Height);
+ Fill(Stream_Video, StreamPos_Last, Video_Format, Swf_Format_Video[CodecID]);
+ Fill(Stream_Video, StreamPos_Last, Video_Format_Profile, Swf_Format_Profile_Video[CodecID]);
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, Swf_Codec_Video[CodecID]);
+ Fill(Stream_Video, StreamPos_Last, Video_FrameCount, NumFrames);
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Swf::Decompress()
+{
+ if (Buffer_Size!=File_Size)
+ {
+ //We must have the complete file in memory, but this is too big (not handled by FileHeader_Begin()), only saying this is SWF
+ Fill(Stream_General, 0, General_Format, "ShockWave");
+
+ Stream_Prepare(Stream_Video);
+
+ Finish("SWF");
+ return true;
+ }
+
+ //Sizes
+ unsigned long Source_Size=(unsigned long)(File_Size-8);
+ unsigned long Dest_Size=(unsigned long)(FileLength-8);
+
+ //Uncompressing
+ int8u* Dest=new int8u[Dest_Size];
+ if (uncompress((Bytef*)Dest, &Dest_Size, (const Bytef*)Buffer+Buffer_Offset+8, Source_Size)<0)
+ {
+ delete[] Dest; //Dest=NULL
+ Trusted_IsNot("Error while decompressing");
+ Reject("SWF");
+ return false;
+ }
+
+ Accept("SWF");
+
+ Fill(Stream_General, 0, General_Format, "ShockWave");
+
+ File_Swf MI;
+ MI.FileLength=FileLength;
+ MI.Version=Version;
+ Open_Buffer_Init(&MI);
+ MI.Open_Buffer_Continue(Dest, FileLength-8);
+ MI.Open_Buffer_Finalize();
+ Merge(MI, Stream_General, 0, 0);
+ Merge(MI);
+ delete[] Dest; //Dest=NULL;
+
+ Finish("SWF");
+ return true;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_SWF_*
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Swf.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Swf.h
new file mode 100644
index 000000000..870cdfe89
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Swf.h
@@ -0,0 +1,130 @@
+// File_Swf - Info for SWF Audio files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about SWF files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_SwfH
+#define MediaInfo_File_SwfH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Swf
+//***************************************************************************
+
+class File_Swf : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ int32u FileLength;;
+ int8u Version;
+
+public :
+ File_Swf();
+
+private :
+ //Buffer
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Header();
+ void Header_Continue();
+ void End() {};
+ void ShowFrame() {};
+ void DefineShape() {};
+ void PlaceObject() {};
+ void RemoveObject() {};
+ void DefineBits() {};
+ void DefineButton() {};
+ void JPEGTables() {};
+ void SetBackgroundColor() {};
+ void DefineFont() {};
+ void DefineText() {};
+ void DoAction() {};
+ void DefineFontInfo() {};
+ void DefineSound();
+ void StartSound() {};
+ void DefineButtonSound() {};
+ void SoundStreamHead();
+ void SoundStreamBlock() {};
+ void DefineBitsLossless() {};
+ void DefineBitsJPEG2() {};
+ void DefineShape2() {};
+ void DefineCxform() {};
+ void Protect() {};
+ void PlaceObject2() {};
+ void RemoveObject2() {};
+ void DefineShape3() {};
+ void DefineText2() {};
+ void DefineButton2() {};
+ void DefineBitsJPEG3() {};
+ void DefineBitsLossless2() {};
+ void DefineEditText() {};
+ void DefineSprite();
+ void FrameLabel() {};
+ void DefineMorphShape() {};
+ void SoundStreamHead2() {SoundStreamHead();};
+ void DefineFont2() {};
+ void ExportAssets() {};
+ void ImportAssets() {};
+ void EnableDebugger() {};
+ void DoInitAction() {};
+ void DefineVideoStream();
+ void DefineVideoFrame() {};
+ void DefineFontInfo2() {};
+ void EnableDebugger2() {};
+ void ScriptLimits() {};
+ void SetTabIndex() {};
+ void FileAttributes() {};
+ void PlaceObject3() {};
+ void ImportAssets2() {};
+ void DefineFontAlignZones() {};
+ void CSMTextSettings() {};
+ void DefineFont3() {};
+ void SymbolClass() {};
+ void Metadata() {};
+ void DefineScalingGrid() {};
+ void DoABC() {};
+ void DefineShape4() {};
+ void DefineMorphShape2() {};
+ void DefineSceneAndFrameLabelData() {};
+ void DefineBinaryData() {};
+ void DefineFontName() {};
+ void StartSound2() {};
+
+ //Helpers
+ bool Decompress();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Umf.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Umf.cpp
new file mode 100644
index 000000000..32ea848de
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Umf.cpp
@@ -0,0 +1,253 @@
+// File_Flv - Info for GXF (SMPTE 360M) files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_GXF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Umf.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Umf::File_Umf()
+:File__Analyze()
+{
+ //In
+ #if MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+ GopSize=(int64u)-1;
+ #endif //MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Umf::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<2)
+ return false; //Must wait for more data
+
+ int16u Length=LittleEndian2int16u(Buffer);
+ if (Buffer_Size<Length)
+ return false; //Must wait for more data
+
+ //All should be OK...
+ Accept("UMF");
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Umf::Read_Buffer_Continue()
+{
+ //Parsing
+ int32u Tracks, Segments;
+ Element_Begin1("Payload description");
+ Skip_L4( "Total length of the UMF data");
+ Skip_L4( "Version of this file");
+ Get_L4 (Tracks, "Number of tracks in the material");
+ Skip_L4( "Offset to track description section");
+ Skip_L4( "Size of the track description section");
+ Get_L4 (Segments, "Number of segments");
+ Skip_L4( "Offset to media description section");
+ Skip_L4( "Size of the media description section");
+ Skip_L4( "Offset to the user data section");
+ Skip_L4( "Size of the user data section");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Element_End0();
+
+ Element_Begin1("Material description");
+ Skip_L4( "Attributes");
+ Skip_L4( "Maximum length of the material in fields");
+ Skip_L4( "Minimum length of the material in fields");
+ Skip_L4( "Material mark in value in fields");
+ Skip_L4( "Material mark out value in fields");
+ Skip_L4( "Time code at mark in value");
+ Skip_L4( "Time code at mark out value");
+ Skip_L4( "last modified time (Most)");
+ Skip_L4( "last modified time (Least)");
+ Skip_L4( "creation time (Most)");
+ Skip_L4( "creation time (Least)");
+ Skip_L2( "Reserved");
+ Skip_L2( "Reserved");
+ Skip_L2( "Number of audio tracks");
+ Skip_L2( "Number of time code tracks");
+ Skip_L2( "Reserved");
+ Skip_L2( "Number of MPEG-1, MPEG-2, and MPEG-2 HD video tracks");
+ Element_End0();
+
+ for (int32u Pos=0; Pos<Tracks; Pos++)
+ {
+ Element_Begin1("Track description");
+ Skip_C1( "Track information - Track type");
+ Skip_C1( "Track information - Track logical number");
+ Skip_L2( "Number of segments on this track");
+ Element_End0();
+
+ if (Element_Offset>=Element_Size)
+ break;
+ }
+
+ for (int32u Pos=0; Pos<Segments; Pos++)
+ {
+ Element_Begin1("Media description");
+ int32u Type;
+ int16u Length;
+ Get_L2 (Length, "Length of this media description");
+ int64u End=Element_Offset+Length-2;
+ Skip_C1( "Track information - Track type");
+ Skip_C1( "Track information - Track logical number");
+ Skip_L2( "Media Sequence number");
+ Skip_L2( "Reserved");
+ Skip_L4( "Number of fields in segment");
+ Skip_L4( "Reserved");
+ Skip_L4( "Mark in value for the media file in fields");
+ Skip_L4( "Mark out value for the media file in fields");
+ Skip_Local(88, "Source device media file name");
+ Get_L4 (Type, "Type of media track");
+ Skip_L4( "Sampling rates for this track");
+ Skip_L4( "Size of sample for audio and time codes");
+ Skip_L4( "Reserved");
+ switch (Type)
+ {
+ case 0x00000004 :
+ case 0x00000007 :
+ case 0x00000009 : //MPEG-Video
+ {
+ #if MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+ int32u P, B;
+ #endif //MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+ Skip_L4( "Color difference format");
+ Skip_L4( "GoP structure");
+ Skip_L4( "Frame/field structure");
+ Skip_L4( "Target I-pictures per GoP");
+ #if MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+ Get_L4 (P, "Target P-pictures per I-picture");
+ Get_L4 (B, "Target B-pictures per P-picture or I-picture");
+ #else //MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+ Skip_L4( "Target P-pictures per I-picture");
+ Skip_L4( "Target B-pictures per P-picture or I-picture");
+ #endif //MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+ Skip_L4( "MPEG video attributes");
+ Skip_L4( "Reserved");
+ #if MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+ GopSize=(1+P)*(1+B);
+ #endif //MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+ }
+ break;
+ case 0x00000003 : //TimeCode
+ Skip_L4( "Time code attributes");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ break;
+ case 0x00000002 : //Audio
+ //Skip_LF8( "Level at which to play this segment");
+ //Skip_LF8( "Level at which to terminate this segment");
+ Skip_L8( "Level at which to play this segment");
+ Skip_L8( "Level at which to terminate this segment");
+ Skip_L4( "Number of fields over which to ramp up");
+ Skip_L4( "Number of fields over which to ramp down");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ break;
+ case 0x00000005 : //DV25
+ case 0x00000006 : //DV50
+ Skip_L4( "Attributes"); //With Aspect ratio
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ #if MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+ GopSize=1;
+ #endif //MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+ break;
+ default :
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ Skip_L4( "Reserved");
+ }
+ if (Element_Offset<End)
+ Skip_XX(End-Element_Offset, "Unknown");
+ Element_End0();
+
+ if (Element_Offset>=Element_Size)
+ break;
+ }
+
+ while (Element_Offset<Element_Size)
+ {
+ Element_Begin1("User data");
+ int32u Length;
+ Get_L4 (Length, "The length of this user data record");
+ Skip_L4( "Position on the material time line");
+ Skip_L2( "Track associated with the user data record");
+ Skip_L2( "Media Sequence Numbe");
+ Skip_L4( "User-defined key");
+ if (Length>18)
+ Skip_XX(Length-18, "User data");
+ else
+ Skip_XX(Element_Size-Element_Offset-2, "User data");
+ Skip_L1( "NULL byte");
+ Skip_L1( "Reserved byte");
+ Element_End0();
+ }
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_UMF_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Umf.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Umf.h
new file mode 100644
index 000000000..f13b8a84b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Umf.h
@@ -0,0 +1,63 @@
+// File_Umf - Info for UMF files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about UMF files
+// Unified Material Format
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_UmfH
+#define MediaInfo_File_UmfH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Umf
+//***************************************************************************
+
+class File_Umf : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Umf();
+
+ //Out
+ #if MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+ int64u GopSize;
+ #endif //MEDIAINFO_SEEK || MEDIAINFO_DEMUX
+
+protected :
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm.cpp
new file mode 100644
index 000000000..0a70b5f7d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm.cpp
@@ -0,0 +1,257 @@
+// File_Wm - Info for Windows Media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Main part
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_WM_YES
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Wm.h"
+#if defined(MEDIAINFO_MPEGPS_YES)
+ #include "MediaInfo/Multiple/File_MpegPs.h"
+#endif
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Wm::File_Wm()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("Wm");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Wm;
+ StreamIDs_Width[0]=2;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ Demux_Level=2; //Container
+ #endif //MEDIAINFO_DEMUX
+ DataMustAlwaysBeComplete=false;
+
+ //Stream
+ Packet_Count=0;
+ MaximumDataPacketSize=(int32u)-1;
+ Header_ExtendedContentDescription_AspectRatioX=0;
+ Header_ExtendedContentDescription_AspectRatioY=0;
+ SizeOfMediaObject_BytesAlreadyParsed=0;
+ FileProperties_Preroll=0;
+ Codec_Description_Count=0;
+ Stream_Number=0;
+ Data_Parse_Padding=0;
+ NumberPayloads=1;
+ NumberPayloads_Pos=0;
+ Data_Parse_Begin=true;
+ IsDvrMs=false;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Wm::Streams_Finish()
+{
+ //Encryption management
+ /*const Ztring& Encryption=Retrieve(Stream_General, 0, General_Encryption);
+ if (!Encryption.empty())
+ {
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
+ for (size_t Pos=0; Pos<(*Stream[StreamKind]).size(); Pos++)
+ Fill ((stream_t)StreamKind, 0, "Encryption", Encryption);
+ }
+
+ Fill("BitRate", CurrentBitRate[StreamNumber]);
+ */
+
+ std::map<int16u, stream>::iterator Temp=Stream.begin();
+ while (Temp!=Stream.end())
+ {
+ for (std::map<std::string, ZenLib::Ztring>::iterator Info_Temp=Temp->second.Info.begin(); Info_Temp!=Temp->second.Info.end(); Info_Temp++)
+ Fill(Temp->second.StreamKind, Temp->second.StreamPos, Info_Temp->first.c_str(), Info_Temp->second, true);
+
+ //Codec Info
+ for (size_t Pos=0; Pos<CodecInfos.size(); Pos++)
+ {
+ if ((CodecInfos[Pos].Type==1 && Temp->second.StreamKind==Stream_Video)
+ || (CodecInfos[Pos].Type==2 && Temp->second.StreamKind==Stream_Audio))
+ {
+ Fill(Temp->second.StreamKind, Temp->second.StreamPos, "CodecID_Description", CodecInfos[Pos].Info, true);
+ Fill(Temp->second.StreamKind, Temp->second.StreamPos, "Codec_Description", CodecInfos[Pos].Info, true);
+ }
+ }
+
+ if (Temp->second.StreamKind==Stream_Video)
+ {
+ //Some tests about the frame rate
+ std::map<int32u, int32u> PresentationTime_Deltas_Problem;
+ std::map<int32u, int32u> PresentationTime_Deltas_Most;
+ for (std::map<ZenLib::int32u, ZenLib::int32u>::iterator PresentationTime_Delta=Temp->second.PresentationTime_Deltas.begin(); PresentationTime_Delta!=Temp->second.PresentationTime_Deltas.end(); PresentationTime_Delta++)
+ {
+ if (PresentationTime_Delta->second>=5)
+ PresentationTime_Deltas_Problem[PresentationTime_Delta->first]=PresentationTime_Delta->second;
+ if (PresentationTime_Delta->second>=30)
+ PresentationTime_Deltas_Most[PresentationTime_Delta->first]=PresentationTime_Delta->second;
+ }
+
+ if (PresentationTime_Deltas_Most.size()==0
+ || (PresentationTime_Deltas_Most.size()==1 && PresentationTime_Deltas_Problem.size()>1)
+ || (PresentationTime_Deltas_Most.size()==2 && PresentationTime_Deltas_Problem.size()>2))
+ {
+ if (Temp->second.AverageTimePerFrame>0)
+ Fill(Stream_Video, Temp->second.StreamPos, Video_FrameRate, ((float)10000000)/Temp->second.AverageTimePerFrame, 3, true);
+ }
+ else if (PresentationTime_Deltas_Most.size()==1)
+ {
+ if (PresentationTime_Deltas_Most.begin()->first>1) //Not 0, we want to remove Delta incremented 1 per 1
+ Fill(Stream_Video, Temp->second.StreamPos, Video_FrameRate, 1000/((float64)PresentationTime_Deltas_Most.begin()->first), 3, true);
+ if (Temp->second.AverageTimePerFrame>0)
+ Fill(Stream_Video, Temp->second.StreamPos, Video_FrameRate_Nominal, ((float)10000000)/Temp->second.AverageTimePerFrame, 3, true);
+ }
+ else if (PresentationTime_Deltas_Most.size()==2)
+ {
+ std::map<int32u, int32u>::iterator PresentationTime_Delta_Most=PresentationTime_Deltas_Most.begin();
+ float64 PresentationTime_Deltas_1_Value=(float64)PresentationTime_Delta_Most->first;
+ float64 PresentationTime_Deltas_1_Count=(float64)PresentationTime_Delta_Most->second;
+ PresentationTime_Delta_Most++;
+ float64 PresentationTime_Deltas_2_Value=(float64)PresentationTime_Delta_Most->first;
+ float64 PresentationTime_Deltas_2_Count=(float64)PresentationTime_Delta_Most->second;
+ float64 FrameRate_Real=1000/(((PresentationTime_Deltas_1_Value*PresentationTime_Deltas_1_Count)+(PresentationTime_Deltas_2_Value*PresentationTime_Deltas_2_Count))/(PresentationTime_Deltas_1_Count+PresentationTime_Deltas_2_Count));
+ Fill(Temp->second.StreamKind, Temp->second.StreamPos, Video_FrameRate, FrameRate_Real, 3, true);
+ if (Temp->second.AverageTimePerFrame>0)
+ Fill(Stream_Video, Temp->second.StreamPos, Video_FrameRate_Nominal, ((float)10000000)/Temp->second.AverageTimePerFrame, 3, true);
+ }
+ else
+ {
+ Fill(Stream_Video, Temp->second.StreamPos, Video_FrameRate_Mode, "VFR");
+ if (Temp->second.AverageTimePerFrame>0)
+ Fill(Stream_Video, Temp->second.StreamPos, Video_FrameRate_Nominal, ((float)10000000)/Temp->second.AverageTimePerFrame, 3, true);
+ }
+ }
+ if (Temp->second.AverageBitRate>0)
+ Fill(Temp->second.StreamKind, Temp->second.StreamPos, "BitRate", Temp->second.AverageBitRate, 10, true);
+ if (Temp->second.LanguageID!=(int16u)-1 && Temp->second.LanguageID<(int16u)Languages.size())
+ Fill(Temp->second.StreamKind, Temp->second.StreamPos, "Language", Languages[Temp->second.LanguageID]);
+ else if (!Language_ForAll.empty())
+ Fill(Temp->second.StreamKind, Temp->second.StreamPos, "Language", Language_ForAll);
+ if (Temp->second.Parser)
+ {
+ if (Temp->second.StreamKind==Stream_Max)
+ if (Temp->second.Parser->Count_Get(Stream_Audio))
+ {
+ Stream_Prepare(Stream_Audio);
+ Temp->second.StreamKind=StreamKind_Last;
+ Temp->second.StreamPos=StreamPos_Last;
+ }
+ Ztring Format_Profile;
+ if (Temp->second.StreamKind==Stream_Video)
+ Format_Profile=Retrieve(Stream_Video, Temp->second.StreamPos, Video_Format_Profile);
+ Finish(Temp->second.Parser);
+ if (Temp->second.Parser->Get(Stream_Video, 0, Video_Format)==_T("MPEG Video"))
+ {
+ //Width/Height are junk
+ Clear(Stream_Video, Temp->second.StreamPos, Video_Width);
+ Clear(Stream_Video, Temp->second.StreamPos, Video_Height);
+ Clear(Stream_Video, Temp->second.StreamPos, Video_PixelAspectRatio);
+ Clear(Stream_Video, Temp->second.StreamPos, Video_DisplayAspectRatio);
+ }
+
+ //Delay (in case of MPEG-PS)
+ if (Temp->second.TimeCode_First!=(int64u)-1)
+ {
+ Fill(Temp->second.StreamKind, Temp->second.StreamPos, Fill_Parameter(Temp->second.StreamKind, Generic_Delay), Temp->second.TimeCode_First, 10);
+ Fill(Temp->second.StreamKind, Temp->second.StreamPos, Fill_Parameter(Temp->second.StreamKind, Generic_Delay_Source), "Container");
+ }
+
+
+ Merge(*Temp->second.Parser, Temp->second.StreamKind, 0, Temp->second.StreamPos);
+ if (!Format_Profile.empty() && Format_Profile.find(Retrieve(Stream_Video, Temp->second.StreamPos, Video_Format_Profile))==0)
+ Fill(Stream_Video, Temp->second.StreamPos, Video_Format_Profile, Format_Profile, true);
+ }
+
+ Temp++;
+ }
+
+ if (Count_Get(Stream_Video)==0 && Count_Get(Stream_Image)==0)
+ Fill(Stream_General, 0, General_InternetMediaType, "audio/x-ms-wma", Unlimited, true, true);
+
+ //Purge what is not needed anymore
+ if (!File_Name.empty()) //Only if this is not a buffer, with buffer we can have more data
+ Stream.clear();
+}
+
+//***************************************************************************
+// Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_Parse()
+{
+ if (!MustUseAlternativeParser)
+ {
+ //Parsing
+ int128u Name;
+ int64u Size;
+ Get_GUID(Name, "Name");
+ Get_L8 (Size, "Size");
+
+ //Filling
+ Header_Fill_Code(Name.hi, Ztring().From_GUID(Name));
+ Header_Fill_Size(Size);
+ }
+ else
+ {
+ Header_Fill_Code(0, "Packet");
+ Header_Fill_Size(MaximumDataPacketSize);
+ }
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_WM_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm.h
new file mode 100644
index 000000000..ce91a153c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm.h
@@ -0,0 +1,190 @@
+// File_Wm - Info for Windows Media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_WmH
+#define MediaInfo_File_WmH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Wm
+//***************************************************************************
+
+class File_Wm : public File__Analyze
+{
+public :
+ File_Wm();
+
+protected :
+ //Streams management
+ void Streams_Finish();
+
+private :
+ //Buffer
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Header();
+ void Header_FileProperties();
+ void Header_StreamProperties();
+ void Header_StreamProperties_Audio();
+ void Header_StreamProperties_Audio_WMA();
+ void Header_StreamProperties_Audio_AMR();
+ void Header_StreamProperties_Video();
+ void Header_StreamProperties_JFIF();
+ void Header_StreamProperties_DegradableJPEG();
+ void Header_StreamProperties_Binary();
+ void Header_HeaderExtension();
+ void Header_HeaderExtension_ExtendedStreamProperties();
+ void Header_HeaderExtension_AdvancedMutualExclusion();
+ void Header_HeaderExtension_GroupMutualExclusion();
+ void Header_HeaderExtension_StreamPrioritization();
+ void Header_HeaderExtension_BandwidthSharing();
+ void Header_HeaderExtension_LanguageList();
+ void Header_HeaderExtension_Metadata();
+ void Header_HeaderExtension_MetadataLibrary();
+ void Header_HeaderExtension_IndexParameters();
+ void Header_HeaderExtension_MediaIndexParameters();
+ void Header_HeaderExtension_TimecodeIndexParameters();
+ void Header_HeaderExtension_Compatibility();
+ void Header_HeaderExtension_AdvancedContentEncryption();
+ void Header_HeaderExtension_IndexPlaceholder();
+ void Header_CodecList();
+ void Header_ScriptCommand();
+ void Header_Marker();
+ void Header_BitRateMutualExclusion();
+ void Header_ErrorCorrection();
+ void Header_ContentDescription();
+ void Header_ExtendedContentDescription();
+ void Header_ExtendedContentDescription_ASFLeakyBucketPairs(int16u Value_Length);
+ void Header_StreamBitRate();
+ void Header_ContentBranding();
+ void Header_ContentEncryption();
+ void Header_ExtendedContentEncryption();
+ void Header_DigitalSignature();
+ void Header_Padding();
+ void Data();
+ void Data_Packet();
+ void Data_Packet_ReplicatedData(int32u Size);
+ void Data_Packet_ReplicatedData_TimeStamp();
+ void SimpleIndex();
+ void Index();
+ void MediaIndex();
+ void TimecodeIndex();
+
+ //Data
+ struct stream
+ {
+ struct payload_extension_system
+ {
+ int128u ID;
+ int16u Size;
+ };
+
+ File__Analyze* Parser;
+ File__Analyze* Parser2;
+ File__Analyze* Parser3;
+ stream_t StreamKind;
+ size_t StreamPos;
+ size_t PacketCount;
+ int64u AverageTimePerFrame;
+ int32u AverageBitRate;
+ int16u LanguageID;
+ std::map<std::string, ZenLib::Ztring> Info;
+ bool IsCreated; //if Stream_Prepare() is done
+ bool SearchingPayload;
+ int32u PresentationTime_Old;
+ int32u PresentationTime_Count;
+ std::map<int32u, int32u> PresentationTime_Deltas;
+ std::vector<payload_extension_system> Payload_Extension_Systems;
+ int64u TimeCode_First;
+
+ stream()
+ {
+ Parser=NULL;
+ Parser2=NULL;
+ Parser3=NULL;
+ StreamKind=Stream_Max;
+ StreamPos=0;
+ PacketCount=0;
+ AverageTimePerFrame=0;
+ AverageBitRate=0;
+ LanguageID=(int16u)-1;
+ IsCreated=false;
+ SearchingPayload=false;
+ PresentationTime_Old=0;
+ PresentationTime_Count=0;
+ TimeCode_First=(int64u)-1;
+ }
+
+ ~stream()
+ {
+ delete Parser; //Parser=NULL;
+ delete Parser2; //Parser2=NULL
+ delete Parser3; //Parser3=NULL
+ }
+ };
+ struct codecinfo
+ {
+ int16u Type;
+ Ztring Info;
+ };
+ std::map<int16u, stream> Stream;
+ int16u Stream_Number; //In header: current pos, in Data: Count of enabled parsers
+ std::vector<ZenLib::Ztring> Languages;
+ std::vector<codecinfo> CodecInfos;
+ Ztring Language_ForAll;
+ int32u Data_Parse_Padding;
+ int32u MaximumDataPacketSize;
+ bool Data_Parse_Begin;
+ bool Data_Parse_MultiplePayloads;
+ bool Data_Parse_CompressedPayload;
+ bool IsDvrMs; //Is DVR-Ms format (for finding MPEG Audio)
+
+ //From Data headers
+ size_t Codec_Description_Count;
+ size_t Packet_Count;
+ size_t Streams_Count;
+ int64u Header_ExtendedContentDescription_AspectRatioX;
+ int64u Header_ExtendedContentDescription_AspectRatioY;
+ int64u Data_AfterTheDataChunk;
+ int32u SizeOfMediaObject_BytesAlreadyParsed;
+ int32u FileProperties_Preroll;
+ int8u ReplicatedDataLengthType;
+ int8u OffsetIntoMediaObjectLengthType;
+ int8u MediaObjectNumberLengthType;
+ int8u StreamNumberLengthType;
+ int8u PayloadLengthType;
+ int8u NumberPayloads;
+ int8u NumberPayloads_Pos;
+ bool MultiplePayloadsPresent;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm_Elements.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm_Elements.cpp
new file mode 100644
index 000000000..5f417a2cb
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Wm_Elements.cpp
@@ -0,0 +1,1730 @@
+// File_Wm - Info for Windows Media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Elements part
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_WM_YES
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Wm.h"
+#if defined(MEDIAINFO_VC1_YES)
+ #include "MediaInfo/Video/File_Vc1.h"
+#endif
+#if defined(MEDIAINFO_MPEGV_YES)
+ #include "MediaInfo/Video/File_Mpegv.h"
+#endif
+#if defined(MEDIAINFO_AC3_YES)
+ #include "MediaInfo/Audio/File_Ac3.h"
+#endif
+#if defined(MEDIAINFO_MPEGA_YES)
+ #include "MediaInfo/Audio/File_Mpega.h"
+#endif
+#if MEDIAINFO_DEMUX
+ #include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+ #include "base64.h"
+#endif //MEDIAINFO_DEMUX
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+const char* Wm_CodecList_Kind(int32u Kind)
+{
+ switch (Kind)
+ {
+ case 0x01 : return "Video";
+ case 0x02 : return "Audio";
+ default : return "Unknown";
+ }
+}
+
+const char* Wm_BannerImageData_Type(int32u Type)
+{
+ switch (Type)
+ {
+ case 0x00 : return "";
+ case 0x01 : return "Bitmap";
+ case 0x02 : return "JPEG";
+ case 0x03 : return "GIF";
+ default : return "Unknown";
+ }
+}
+
+#define UUID(NAME, PART1, PART2, PART3, PART4, PART5) \
+ const int64u NAME =0x##PART3##PART2##PART1##ULL; \
+ const int64u NAME##2=0x##PART4##PART5##ULL; \
+
+namespace Elements
+{
+ UUID(Header, 75B22630, 668E, 11CF, A6D9, 00AA0062CE6C)
+ UUID(Header_FileProperties, 8CABDCA1, A947, 11CF, 8EE4, 00C00C205365)
+ UUID(Header_StreamProperties, B7DC0791, A9B7, 11CF, 8EE6, 00C00C205365)
+ UUID(Header_StreamProperties_Audio, F8699E40, 5B4D, 11CF, A8FD, 00805F5C442B)
+ UUID(Header_StreamProperties_Video, BC19EFC0, 5B4D, 11CF, A8FD, 00805F5C442B)
+ UUID(Header_StreamProperties_Command, 59DACFC0, 59E6, 11D0, A3AC, 00A0C90348F6)
+ UUID(Header_StreamProperties_JFIF, B61BE100, 5B4E, 11CF, A8FD, 00805F5C442B)
+ UUID(Header_StreamProperties_DegradableJPEG, 35907DE0, E415, 11CF, A917, 00805F5C442B)
+ UUID(Header_StreamProperties_FileTransfer, 91BD222C, F21C, 497A, 8B6D, 5AA86BFC0185)
+ UUID(Header_StreamProperties_Binary, 3AFB65E2, 47EF, 40F2, AC2C, 70A90D71D343)
+ UUID(Header_StreamProperties_Binary_WebStreamMediaSubType, 776257D4, C627, 41CB, 8F81, 7AC7FF1C40CC)
+ UUID(Header_StreamProperties_Binary_WebStreamFormat, DA1E6B13, 8359, 4050, B398, 388E965BF00C)
+ UUID(Header_HeaderExtension, 5FBF03B5, A92E, 11CF, 8EE3, 00C00C205365)
+ UUID(Header_HeaderExtension_ExtendedStreamProperties, 14E6A5CB, C672, 4332, 8399, A96952065B5A)
+ UUID(Header_HeaderExtension_AdvancedMutualExclusion, A08649CF, 4775, 4670, 8A16, 6E35357566CD)
+ UUID(Header_HeaderExtension_GroupMutualExclusion, D1465A40, 5A79, 4338, B71B, E36B8FD6C249)
+ UUID(Header_HeaderExtension_StreamPrioritization, D4FED15B, 88D3, 454F, 81F0, ED5C45999E24)
+ UUID(Header_HeaderExtension_BandwidthSharing, A69609E6, 517B, 11D2, B6AF, 00C04FD908E9)
+ UUID(Header_HeaderExtension_LanguageList, 7C4346A9, EFE0, 4BFC, B229, 393EDE415C85)
+ UUID(Header_HeaderExtension_Metadata, C5F8CBEA, 5BAF, 4877, 8467, AA8C44FA4CCA)
+ UUID(Header_HeaderExtension_MetadataLibrary, 44231C94, 9498, 49D1, A141, 1D134E457054)
+ UUID(Header_HeaderExtension_IndexParameters, D6E229DF, 35DA, 11D1, 9034, 00A0C90349BE)
+ UUID(Header_HeaderExtension_MediaIndexParameters, 6B203BAD, 3F11, 48E4, ACA8, D7613DE2CFA7)
+ UUID(Header_HeaderExtension_TimecodeIndexParameters, F55E496D, 9797, 4B5D, 8C8B, 604DFE9BFB24)
+ UUID(Header_HeaderExtension_Compatibility, 26F18B5D, 4584, 47EC, 9F5F, 0E651F0452C9)
+ UUID(Header_HeaderExtension_AdvancedContentEncryption, 43058533, 6981, 49E6, 9B74, AD12CB86D58C)
+ UUID(Header_HeaderExtension_IndexPlaceholder, D9AADE20, 7C17, 4F9C, BC28, 8555DD98E2A2)
+ UUID(Header_CodecList, 86D15240, 311D, 11D0, A3A4, 00ACC90348F6)
+ UUID(Header_ScriptCommand, 1EFB1A30, 0B62, 11D0, A39B, 00A0C90348F6)
+ UUID(Header_Marker, F487CD01, A951, 11CF, 8EE6, 00C00C205365)
+ UUID(Header_BitRateMutualExclusion, D6E229DC, 35DA, 11D1, 9034, 00A0C90349BE)
+ UUID(Header_ErrorCorrection, 75B22635, 668E, 11CF, A6D9, 00AA0062CE6C)
+ UUID(Header_ContentDescription, 75B22633, 668E, 11CF, A6D9, 00AA0062CE6C)
+ UUID(Header_ExtendedContentDescription, D2D0A440, E307, 11D2, 97F0, 00A0C95EA850)
+ UUID(Header_StreamBitRate, 7BF875CE, 468D, 11D1, 8D82, 006097C9A2B2)
+ UUID(Header_ContentBranding, 2211B3FA, BD23, 11D2, B4B7, 00A0C955FC6E)
+ UUID(Header_ContentEncryption, 2211B3FB, BD23, 11D2, B4B7, 00A0C955FC6E)
+ UUID(Header_ExtendedContentEncryption, 298AE614, 2622, 4C17, B935, DAE07EE9289C)
+ UUID(Header_DigitalSignature, 2211B3FC, BD23, 11D2, B4B7, 00A0C955FC6E)
+ UUID(Header_Padding, 1806D474, CADF, 4509, A4BA, 9AABCB96AAE8)
+ UUID(Data, 75B22636, 668E, 11CF, A6D9, 00AA0062CE6C)
+ UUID(SimpleIndex, 33000890, E5B1, 11CF, 89F4, 00A0C90349CB)
+ UUID(Index, D6E229D3, 35DA, 11D1, 9034, 00A0C90349BE)
+ UUID(MediaIndex, FEB103F8, 12AD, 4C64, 840F, 2A1D2F7AD48C)
+ UUID(TimecodeIndex, 3CB73FD0, 0C4A, 4803, 953D, EDF7B6228F0C)
+
+ UUID(Payload_Extension_System_TimeStamp, 1135BEB7, 3A39, 478A, 98D9, 15C76B00EB69);
+ UUID(Mutex_Language, D6E22A00, 35DA, 11D1, 9034, 00A0C90349BE);
+ UUID(Mutex_Bitrate, D6E22A01, 35DA, 11D1, 9034, 00A0C90349BE);
+}
+
+const char* Wm_StreamType(int128u Kind)
+{
+ switch (Kind.hi)
+ {
+ case Elements::Header_StreamProperties_Audio : return "Audio";
+ case Elements::Header_StreamProperties_Video : return "Video";
+ case Elements::Header_StreamProperties_Command : return "Command";
+ case Elements::Header_StreamProperties_JFIF : return "JFIF";
+ case Elements::Header_StreamProperties_DegradableJPEG : return "Degradable JPEG";
+ case Elements::Header_StreamProperties_FileTransfer : return "File Transfer";
+ case Elements::Header_StreamProperties_Binary : return "Binary";
+ default : return "Unknown";
+ }
+}
+
+const char* Wm_ExclusionType(int128u ExclusionType)
+{
+ switch (ExclusionType.hi)
+ {
+ case Elements::Header_StreamProperties_Audio : return "Language";
+ case Elements::Header_StreamProperties_Video : return "Bitrate";
+ default : return "Unknown";
+ }
+}
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Element parse
+//
+void File_Wm::Data_Parse()
+{
+ //Parsing
+ DATA_BEGIN
+ LIST(Header)
+ ATOM_BEGIN
+ ATOM(Header_FileProperties)
+ ATOM(Header_StreamProperties)
+ LIST(Header_HeaderExtension)
+ ATOM_BEGIN
+ ATOM(Header_HeaderExtension_ExtendedStreamProperties)
+ ATOM(Header_HeaderExtension_AdvancedMutualExclusion)
+ ATOM(Header_HeaderExtension_GroupMutualExclusion)
+ ATOM(Header_HeaderExtension_StreamPrioritization)
+ ATOM(Header_HeaderExtension_BandwidthSharing)
+ ATOM(Header_HeaderExtension_LanguageList)
+ ATOM(Header_HeaderExtension_Metadata)
+ ATOM(Header_HeaderExtension_MetadataLibrary)
+ ATOM(Header_HeaderExtension_IndexParameters)
+ ATOM(Header_HeaderExtension_MediaIndexParameters)
+ ATOM(Header_HeaderExtension_TimecodeIndexParameters)
+ ATOM(Header_HeaderExtension_Compatibility)
+ ATOM(Header_HeaderExtension_AdvancedContentEncryption)
+ ATOM(Header_HeaderExtension_IndexPlaceholder)
+ ATOM(Header_Padding)
+ ATOM_END
+ ATOM(Header_CodecList)
+ ATOM(Header_ScriptCommand)
+ ATOM(Header_Marker)
+ ATOM(Header_BitRateMutualExclusion)
+ ATOM(Header_ErrorCorrection)
+ ATOM(Header_ContentDescription)
+ ATOM(Header_ExtendedContentDescription)
+ ATOM(Header_StreamBitRate)
+ ATOM(Header_ContentBranding)
+ ATOM(Header_ContentEncryption)
+ ATOM(Header_ExtendedContentEncryption)
+ ATOM(Header_DigitalSignature)
+ ATOM(Header_Padding)
+ ATOM_END
+ LIST(Data)
+ ATOM_DEFAULT_ALONE(Data_Packet)
+ LIST_SKIP(SimpleIndex)
+ LIST_SKIP(Index)
+ ATOM(MediaIndex)
+ ATOM(TimecodeIndex)
+ DATA_END
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Wm::Header()
+{
+ Data_Accept("Windows Media");
+ Element_Name("Header");
+
+ //Parsing
+ Skip_L4( "Number of Header Objects");
+ Skip_L1( "Alignment");
+ Skip_L1( "Architecture");
+
+ FILLING_BEGIN();
+ Fill(Stream_General, 0, General_Format, "Windows Media");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_FileProperties()
+{
+ Element_Name("File Properties");
+
+ //Parsing
+ int64u CreationDate, PlayDuration, SendDuration, Preroll;
+ int32u Flags, MaximumBitRate;
+ Skip_GUID( "File ID");
+ Skip_L8( "File Size");
+ Get_L8 (CreationDate, "Creation Date"); Param_Info1(Ztring().Date_From_Milliseconds_1601(CreationDate/10000));
+ Skip_L8( "Data Packets Count");
+ Get_L8 (PlayDuration, "Play Duration"); Param_Info_From_Milliseconds(PlayDuration/10000);
+ Get_L8 (SendDuration, "Send Duration"); Param_Info_From_Milliseconds(SendDuration/10000);
+ Get_L8 (Preroll, "Preroll"); Param_Info_From_Milliseconds(Preroll);
+ Get_L4 (Flags, "Flags");
+ Skip_Flags(Flags, 0, "Broadcast");
+ Skip_Flags(Flags, 1, "Seekable");
+ Skip_Flags(Flags, 2, "Use Packet Template");
+ Skip_Flags(Flags, 3, "Live");
+ Skip_Flags(Flags, 4, "Recordable");
+ Skip_Flags(Flags, 5, "Unknown Data Size");
+ Skip_L4( "Minimum Data Packet Size");
+ Get_L4 (MaximumDataPacketSize, "Maximum Data Packet Size");
+ Get_L4 (MaximumBitRate, "Maximum Bitrate");
+
+ //Filling
+ if (MaximumBitRate)
+ Fill(Stream_General, 0, General_OverallBitRate_Maximum, MaximumBitRate);
+ Fill(Stream_General, 0, General_Encoded_Date, Ztring().Date_From_Milliseconds_1601(CreationDate/10000));
+ if (PlayDuration/1000>Preroll)
+ Fill(Stream_General, 0, General_Duration, PlayDuration/10000-Preroll);
+ FileProperties_Preroll=(int32u)(Preroll);
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_StreamProperties ()
+{
+ Element_Name("Stream Properties");
+
+ //Parsing
+ int128u StreamType;
+ int32u StreamTypeLength, ErrorCorrectionTypeLength;
+ Get_GUID(StreamType, "StreamType"); Param_Info1(Wm_StreamType(StreamType)); Element_Info1(Wm_StreamType(StreamType));
+ Skip_GUID( "Error Correction Type");
+ Skip_L8( "Time Offset");
+ Get_L4 (StreamTypeLength, "Type-Specific Data Length");
+ Get_L4 (ErrorCorrectionTypeLength, "Error Correction Data Length");
+ Get_L2 (Stream_Number, "Stream Number");
+ if (Stream_Number&0x8000)
+ {
+ Param_Info1("Encrypted Content");
+ Stream[Stream_Number&0x007F].Info["Encryption"]=_T("Encrypted");
+ }
+ Stream_Number&=0x007F; //Only 7bits
+ Element_Info1(Stream_Number);
+ Skip_L4( "Reserved");
+ switch (StreamType.hi)
+ {
+ case Elements::Header_StreamProperties_Audio : Element_Begin0(); //size is StreamTypeLength
+ Header_StreamProperties_Audio();
+ Element_End0(); break;
+ case Elements::Header_StreamProperties_Video : Element_Begin0(); //size is StreamTypeLength
+ Header_StreamProperties_Video();
+ Element_End0(); break;
+ case Elements::Header_StreamProperties_JFIF : Element_Begin0(); //size is StreamTypeLength
+ Header_StreamProperties_JFIF();
+ Element_End0(); break;
+ case Elements::Header_StreamProperties_DegradableJPEG : Element_Begin0(); //size is StreamTypeLength
+ Header_StreamProperties_DegradableJPEG();
+ Element_End0(); break;
+ case Elements::Header_StreamProperties_FileTransfer :
+ case Elements::Header_StreamProperties_Binary : Element_Begin0(); //size is StreamTypeLength
+ Header_StreamProperties_Binary();
+ StreamKind_Last=Stream_Max; StreamPos_Last=(size_t)-1;
+ Element_End0(); break;
+ default : if (StreamTypeLength>0)
+ Skip_XX(StreamTypeLength, "Type-Specific Data");
+ StreamKind_Last=Stream_Max; StreamPos_Last=(size_t)-1;
+ }
+ if (ErrorCorrectionTypeLength)
+ Skip_XX(ErrorCorrectionTypeLength, "Error Correction Data");
+
+ //Filling
+ Stream[Stream_Number].StreamKind=StreamKind_Last;
+ Stream[Stream_Number].StreamPos=StreamPos_Last;
+ Stream[Stream_Number].Info["ID"].From_Number(Stream_Number);
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_StreamProperties_Audio ()
+{
+ Element_Name("Audio");
+
+ //Parsing
+ int32u SamplingRate, BytesPerSec;
+ int16u CodecID, Channels, Data_Size, Resolution;
+ Get_L2 (CodecID, "Codec ID");
+ Get_L2 (Channels, "Number of Channels");
+ Get_L4 (SamplingRate, "Samples Per Second");
+ Get_L4 (BytesPerSec, "Average Number of Bytes Per Second");
+ Skip_L2( "Block Alignment");
+ Get_L2 (Resolution, "Bits / Sample");
+ Get_L2 (Data_Size, "Codec Specific Data Size");
+
+ //Filling
+ Stream_Prepare(Stream_Audio);
+ Stream[Stream_Number].IsCreated=true;
+ Ztring Codec; Codec.From_Number(CodecID, 16);
+ Codec.MakeUpperCase();
+ CodecID_Fill(Codec, Stream_Audio, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec, Codec); //May be replaced by codec parser
+ Fill(Stream_Audio, StreamPos_Last, Audio_Codec_CC, Codec);
+ Fill(Stream_Audio, StreamPos_Last, Audio_Channel_s_, Channels);
+ Fill(Stream_Audio, StreamPos_Last, Audio_SamplingRate, SamplingRate);
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate, BytesPerSec*8);
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitDepth, Resolution);
+
+ FILLING_BEGIN();
+ //Creating the parser
+ if (0);
+ #if defined(MEDIAINFO_MPEGA_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Audio, InfoCodecID_Format_Riff, Ztring::ToZtring(CodecID, 16))==_T("MPEG Audio"))
+ {
+ Stream[Stream_Number].Parser=new File_Mpega;
+ ((File_Mpega*)Stream[Stream_Number].Parser)->Frame_Count_Valid=8;
+ Stream[Stream_Number].Parser->ShouldContinueParsing=true;
+ }
+ #endif
+ Open_Buffer_Init(Stream[Stream_Number].Parser);
+ FILLING_END();
+
+ //Parsing
+ if (Data_Size>0)
+ {
+ Element_Begin1("Codec Specific Data");
+ switch (CodecID)
+ {
+ case 0x0161 :
+ case 0x0162 :
+ case 0x0163 : Header_StreamProperties_Audio_WMA(); break;
+ case 0x7A21 :
+ case 0x7A22 : Header_StreamProperties_Audio_AMR(); break;
+ default : Skip_XX(Data_Size, "Unknown");
+ }
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_StreamProperties_Audio_WMA ()
+{
+ Element_Info1("WMA");
+
+ //Parsing
+ Skip_L4( "SamplesPerBlock");
+ Skip_L2( "EncodeOptions");
+ Skip_L4( "SuperBlockAlign");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_StreamProperties_Audio_AMR ()
+{
+ Element_Info1("AMR");
+
+ //Parsing
+ int32u Flags;
+ bool VBR;
+ Get_L4 (Flags, "Flags");
+ Skip_Flags(Flags, 0, "SID is used");
+ Get_Flags (Flags, 1, VBR, "Varying bitrate");
+
+ //Filling
+ Fill(Stream_Audio, StreamPos_Last, Audio_BitRate_Mode, VBR?"VBR":"CBR");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_StreamProperties_Video ()
+{
+ Element_Name("Video");
+
+ //Parsing
+ int32u Width, Height, Compression;
+ int16u Data_Size, Resolution;
+ Get_L4 (Width, "Width");
+ Get_L4 (Height, "Height");
+ Skip_L1( "Flags");
+ Get_L2 (Data_Size, "Format Data Size");
+ Skip_L4( "Size");
+ Get_L4 (Width, "Width");
+ Get_L4 (Height, "Height");
+ Skip_L2( "Planes");
+ Get_L2 (Resolution, "BitCount");
+ Get_C4 (Compression, "Compression");
+ Skip_L4( "SizeImage");
+ Skip_L4( "XPelsPerMeter");
+ Skip_L4( "YPelsPerMeter");
+ Skip_L4( "ClrUsed");
+ Skip_L4( "ClrImportant");
+
+ //Filling
+ Stream_Prepare(Stream_Video);
+ Stream[Stream_Number].IsCreated=true;
+ CodecID_Fill(Ztring().From_CC4(Compression), Stream_Video, StreamPos_Last, InfoCodecID_Format_Riff);
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, Ztring().From_CC4(Compression)); //May be replaced by codec parser
+ Fill(Stream_Video, StreamPos_Last, Video_Codec_CC, Ztring().From_CC4(Compression));
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Width);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Height);
+ if (Resolution>0)
+ Fill(Stream_Video, StreamPos_Last, Video_BitDepth, (Resolution%3)?Resolution:(Resolution/3)); //If not a multiple of 3, the total resolution is filled
+ if (Compression==CC4("DVR "))
+ IsDvrMs=true;
+
+ //From Content description (we imagine that data is for all video streams...)
+ if (Header_ExtendedContentDescription_AspectRatioX && Header_ExtendedContentDescription_AspectRatioY)
+ {
+ if (Header_ExtendedContentDescription_AspectRatioX==16 && Header_ExtendedContentDescription_AspectRatioY==9)
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, ((float32)16)/9, 3);
+ else if (Header_ExtendedContentDescription_AspectRatioX==4 && Header_ExtendedContentDescription_AspectRatioY==3)
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, ((float32)4)/3, 3);
+ else
+ Fill(Stream_Video, StreamPos_Last, Video_PixelAspectRatio, ((float32)Header_ExtendedContentDescription_AspectRatioX)/Header_ExtendedContentDescription_AspectRatioY, 3, true);
+ }
+
+ //Creating the parser
+ if (0);
+ #if defined(MEDIAINFO_VC1_YES)
+ else if (MediaInfoLib::Config.CodecID_Get(Stream_Video, InfoCodecID_Format_Riff, Ztring().From_CC4(Compression), InfoCodecID_Format)==_T("VC-1"))
+ {
+ Stream[Stream_Number].Parser=new File_Vc1;
+ if (Compression==CC4("WMV3"))
+ {
+ ((File_Vc1*)Stream[Stream_Number].Parser)->From_WMV3=true;
+ ((File_Vc1*)Stream[Stream_Number].Parser)->MustSynchronize=false;
+ }
+ ((File_Vc1*)Stream[Stream_Number].Parser)->FrameIsAlwaysComplete=true; //Warning: this is not always the case, see data parsing
+ Open_Buffer_Init(Stream[Stream_Number].Parser);
+ if (Data_Size>40)
+ {
+
+ //Demux
+ #if MEDIAINFO_DEMUX
+ switch (Config->Demux_InitData_Get())
+ {
+ case 0 : //In demux event
+ Element_Code=Stream_Number;
+ Demux_Level=2; //Container
+ Demux(Buffer+(size_t)Element_Offset, (size_t)(Data_Size-40), ContentType_Header);
+ break;
+ case 1 : //In field
+ {
+ std::string Data_Raw((const char*)(Buffer+(size_t)Element_Offset), (size_t)(Data_Size-40));
+ std::string Data_Base64(Base64::encode(Data_Raw));
+ Fill(Stream_Video, StreamPos_Last, "Demux_InitBytes", Data_Base64);
+ }
+ break;
+ default : ;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ Open_Buffer_Continue(Stream[Stream_Number].Parser, (size_t)(Data_Size-40));
+ if (Stream[Stream_Number].Parser->Status[IsFinished])
+ {
+ Finish(Stream[Stream_Number].Parser);
+ Merge(*Stream[Stream_Number].Parser, Stream_Video, 0, StreamPos_Last);
+ delete Stream[Stream_Number].Parser; Stream[Stream_Number].Parser=NULL;
+ }
+ else
+ {
+ ((File_Vc1*)Stream[Stream_Number].Parser)->Only_0D=true;
+ ((File_Vc1*)Stream[Stream_Number].Parser)->MustSynchronize=false;
+ }
+ }
+ }
+ #endif
+ #if defined(MEDIAINFO_MPEGV_YES)
+ else if (MediaInfoLib::Config.Codec_Get(Ztring().From_CC4(Compression), InfoCodec_KindofCodec).find(_T("MPEG-2"))==0)
+ {
+ Stream[Stream_Number].Parser=new File_Mpegv;
+ ((File_Mpegv*)Stream[Stream_Number].Parser)->Frame_Count_Valid=30; //For searching Pulldown
+ Open_Buffer_Init(Stream[Stream_Number].Parser);
+ }
+ #endif
+ else if (Data_Size>40) //TODO: see "The Mummy_e"
+ Skip_XX(Data_Size-40, "Codec Specific Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_StreamProperties_JFIF ()
+{
+ Element_Name("JFIF");
+
+ //Parsing
+ int32u Width, Height;
+ Get_L4 (Width, "Width");
+ Get_L4 (Height, "Height");
+ Skip_L4( "Reserved");
+
+ //Filling
+ Stream_Prepare(Stream_Image);
+ Fill(Stream_Video, StreamPos_Last, Video_Format, "JPEG");
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, "JPEG");
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Width);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Height);
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_StreamProperties_DegradableJPEG ()
+{
+ Element_Name("Degradable JPEG");
+
+ int32u Width, Height;
+ int16u InterchangeDataLength;
+ Get_L4 (Width, "Width");
+ Get_L4 (Height, "Height");
+ Skip_L2( "Reserved");
+ Skip_L2( "Reserved");
+ Skip_L2( "Reserved");
+ Get_L2 (InterchangeDataLength, "Interchange data length");
+ if (InterchangeDataLength>0)
+ Skip_XX(InterchangeDataLength, "Interchange data");
+ else
+ Skip_L1( "Zero");
+
+ //Filling
+ Stream_Prepare(Stream_Image);
+ Fill(Stream_Video, StreamPos_Last, Video_Format, "JPEG");
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, "JPEG");
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Width);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Height);
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_StreamProperties_Binary ()
+{
+ Element_Name("Binary");
+
+ //Parsing
+ int32u FormatDataLength;
+ Skip_GUID( "Major media type");
+ Skip_GUID( "Media subtype");
+ Skip_L4( "Fixed-size samples");
+ Skip_L4( "Temporal compression");
+ Skip_L4( "Sample size");
+ Skip_GUID( "Format type");
+ Get_L4 (FormatDataLength, "Format data size");
+ if (FormatDataLength>0)
+ Skip_XX(FormatDataLength, "Format data");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension()
+{
+ Element_Name("Header Extension");
+
+ //Parsing
+ int32u Size;
+ Skip_GUID( "ClockType");
+ Skip_L2( "ClockSize");
+ Get_L4 (Size, "Extension Data Size");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_ExtendedStreamProperties()
+{
+ Element_Name("Extended Stream Properties");
+
+ //Parsing
+ int64u AverageTimePerFrame;
+ int32u DataBitrate, Flags;
+ int16u StreamNumber, LanguageID, StreamNameCount, PayloadExtensionSystemCount;
+ Info_L8(StartTime, "Start Time"); Param_Info_From_Milliseconds(StartTime);
+ Info_L8(EndTime, "End Time"); Param_Info_From_Milliseconds(EndTime);
+ Get_L4 (DataBitrate, "Data Bitrate");
+ Skip_L4( "Buffer Size");
+ Skip_L4( "Initial Buffer Fullness");
+ Skip_L4( "Alternate Data Bitrate");
+ Skip_L4( "Alternate Buffer Size");
+ Skip_L4( "Alternate Initial Buffer Fullness");
+ Skip_L4( "Maximum Object Size");
+ Get_L4 (Flags, "Flags");
+ Skip_Flags(Flags, 0, "Reliable");
+ Skip_Flags(Flags, 1, "Seekable");
+ Skip_Flags(Flags, 2, "No Cleanpoints");
+ Skip_Flags(Flags, 3, "Resend Live Cleanpoints");
+ Get_L2 (StreamNumber, "Stream Number"); Element_Info1(StreamNumber);
+ Get_L2 (LanguageID, "Stream Language ID Index");
+ Get_L8 (AverageTimePerFrame, "Average Time Per Frame");
+ Get_L2 (StreamNameCount, "Stream Name Count");
+ Get_L2 (PayloadExtensionSystemCount, "Payload Extension System Count");
+ for (int16u Pos=0; Pos<StreamNameCount; Pos++)
+ {
+ Element_Begin1("Stream Name");
+ int16u StreamNameLength;
+ Skip_L2( "Language ID Index");
+ Get_L2 (StreamNameLength, "Stream Name Length");
+ Skip_UTF16L(StreamNameLength, "Stream Name");
+ Element_End0();
+ }
+ for (int16u Pos=0; Pos<PayloadExtensionSystemCount; Pos++)
+ {
+ Element_Begin1("Payload Extension System");
+ stream::payload_extension_system Payload_Extension_System;
+ int32u ExtensionSystemInfoLength;
+ Get_GUID(Payload_Extension_System.ID, "Extension System ID");
+ Get_L2 (Payload_Extension_System.Size, "Extension Data Size");
+ Get_L4 (ExtensionSystemInfoLength, "Extension System Info Length");
+ if (ExtensionSystemInfoLength>0)
+ Skip_XX(ExtensionSystemInfoLength, "Extension System Info");
+ Element_End0();
+
+ //Filling
+ Stream[StreamNumber].Payload_Extension_Systems.push_back(Payload_Extension_System);
+ }
+
+ //Header_StreamProperties
+ if (Element_Offset<Element_Size)
+ {
+ //This could be everything, but in theory this is only Header_StreamProperties
+ int128u Name;
+ int64u Size;
+ Element_Begin1("Stream Properties Object");
+ Element_Begin1("Header");
+ Get_GUID(Name, "Name");
+ Get_L8 (Size, "Size");
+ Element_End0();
+ if (Size>=24 && Element_Offset+Size-24==Element_Size)
+ {
+ switch (Name.hi)
+ {
+ case Elements::Header_StreamProperties : Header_StreamProperties(); break;
+ default : Skip_XX(Size-24, "Unknown");
+ }
+ }
+ else
+ Skip_XX(Element_Size-Element_Offset, "Problem");
+ Element_End0();
+ }
+
+ //Filling
+ Stream[StreamNumber].LanguageID=LanguageID;
+ Stream[StreamNumber].AverageBitRate=DataBitrate;
+ Stream[StreamNumber].AverageTimePerFrame=AverageTimePerFrame;
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_AdvancedMutualExclusion()
+{
+ Element_Name("Advanced Mutual Exclusion");
+
+ //Parsing
+ int16u Count;
+ Info_GUID(ExclusionType, "Exclusion Type"); Param_Info1(Wm_ExclusionType(ExclusionType));
+ Get_L2 (Count, "Stream Numbers Count");
+ for (int16u Pos=0; Pos<Count; Pos++)
+ {
+ Info_L2(StreamNumber, "Stream Number"); Element_Info1(StreamNumber);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_GroupMutualExclusion()
+{
+ Element_Name("Group Mutual Exclusion");
+
+ //Parsing
+ Skip_XX(Element_Size, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_StreamPrioritization()
+{
+ Element_Name("Stream Prioritization");
+
+ //Parsing
+ int16u Count;
+ Get_L2 (Count, "Stream Numbers Count");
+ for (int16u Pos=0; Pos<Count; Pos++)
+ {
+ int16u Flags;
+ Element_Begin1("Stream");
+ Info_L2(StreamNumber, "Stream Number"); Element_Info1(StreamNumber);
+ Get_L2 (Flags, "Flags");
+ Skip_Flags(Flags, 0, "Mandatory");
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_BandwidthSharing()
+{
+ Element_Name("Bandwidth Sharing");
+
+ //Parsing
+ Skip_XX(Element_Size, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_LanguageList()
+{
+ Element_Name("Language List");
+
+ //Parsing
+ Ztring LanguageID;
+ int16u Count;
+ int8u LanguageID_Length;
+ Get_L2 (Count, "Count");
+ for (int16u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("Language ID");
+ Get_L1 (LanguageID_Length, "Language ID Length");
+ if (LanguageID_Length>0)
+ {
+ Get_UTF16L(LanguageID_Length, LanguageID, "Language ID");
+ Element_Info1(LanguageID);
+ }
+ Element_End0();
+
+ //Filling
+ Languages.push_back(LanguageID);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_MetadataLibrary()
+{
+ Element_Name("Metadata Library");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_Metadata()
+{
+ Element_Name("Metadata");
+
+ //Parsing
+ float32 AspectRatioX=0, AspectRatioY=0;
+ int16u Count;
+ Get_L2 (Count, "Description Records Count");
+ for (int16u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("Description Record");
+ Ztring Name, Data;
+ int64u Data_Int64=0;
+ int32u Data_Length;
+ int16u StreamNumber, Name_Length, Data_Type;
+ Skip_L2( "Reserved");
+ Get_L2 (StreamNumber, "Stream Number");
+ Get_L2 (Name_Length, "Name Length");
+ Get_L2 (Data_Type, "Data Type");
+ Get_L4 (Data_Length, "Data Length");
+ Get_UTF16L(Name_Length, Name, "Name Length");
+ switch (Data_Type)
+ {
+ case 0x00 : Get_UTF16L(Data_Length, Data, "Data"); break;
+ case 0x01 : Skip_XX(Data_Length, "Data"); Data=_T("(Binary)"); break;
+ case 0x02 : {int16u Data_Int; Get_L2 (Data_Int, "Data"); Data=(Data_Int==0)?_T("No"):_T("Yes"); Data_Int64=Data_Int;} break;
+ case 0x03 : {int32u Data_Int; Get_L4 (Data_Int, "Data"); Data.From_Number(Data_Int); Data_Int64=Data_Int;} break;
+ case 0x04 : {int64u Data_Int; Get_L8 (Data_Int, "Data"); Data.From_Number(Data_Int); Data_Int64=Data_Int;} break;
+ case 0x05 : {int16u Data_Int; Get_L2 (Data_Int, "Data"); Data.From_Number(Data_Int); Data_Int64=Data_Int;} break;
+ default : Skip_XX(Data_Length, "Data"); Data=_T("(Unknown)"); break;
+ }
+ Element_Info1(Name);
+ Element_Info1(Data);
+ Element_End0();
+
+ if (Name==_T("IsVBR"))
+ Stream[StreamNumber].Info["BitRate_Mode"]=(Data_Int64==0)?"CBR":"VBR";
+ else if (Name==_T("AspectRatioX"))
+ {
+ AspectRatioX=Data.To_float32();
+ if (AspectRatioX && AspectRatioY)
+ Stream[StreamNumber].Info["PixelAspectRatio"].From_Number(AspectRatioX/AspectRatioY, 3);
+ }
+ else if (Name==_T("AspectRatioY"))
+ {
+ AspectRatioY=Data.To_float32();
+ if (AspectRatioX && AspectRatioY)
+ Stream[StreamNumber].Info["PixelAspectRatio"].From_Number(AspectRatioX/AspectRatioY, 3);
+ }
+ else if (Name==_T("DeviceConformanceTemplate"))
+ {
+ if (Data!=_T("@") && Data.find(_T('@'))!=std::string::npos)
+ Stream[StreamNumber].Info["Format_Profile"]=Data;
+ }
+ else if (Name==_T("WM/WMADRCPeakReference")) {}
+ else if (Name==_T("WM/WMADRCAverageReference")) {}
+ else if (Name==_T("WM/WMADRCAverageTarget")) {}
+ else if (Name==_T("WM/WMADRCPeakTarget")) {}
+ else
+ Stream[StreamNumber].Info[Name.To_Local()]=Data;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_IndexParameters()
+{
+ Element_Name("Index Parameters");
+
+ //Parsing
+ int16u Count;
+ Skip_L4( "Index Entry Time Interval");
+ Get_L2 (Count, "Index Specifiers Count");
+ for (int16u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("Index Specifier");
+ int16u IndexType;
+ Skip_L2( "Stream Number");
+ Get_L2 (IndexType, "Index Type");
+ Element_Info1(IndexType);
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_MediaIndexParameters()
+{
+ Element_Name("MediaIndex Parameters");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_TimecodeIndexParameters()
+{
+ Element_Name("Timecode Index Parameters");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_Compatibility()
+{
+ Element_Name("Compatibility");
+
+ //Parsing
+ Skip_L1( "Profile");
+ Skip_L1( "Mode");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_AdvancedContentEncryption()
+{
+ Element_Name("Advanced Content Encryption");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_HeaderExtension_IndexPlaceholder()
+{
+ Element_Name("Index Placeholder");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_CodecList()
+{
+ Element_Name("Codec List");
+
+ //Parsing
+ Ztring CodecName, CodecDescription;
+ int32u Count32;
+ int16u Count, Type, CodecNameLength, CodecDescriptionLength, CodecInformationLength;
+ Skip_GUID( "Reserved");
+ Get_L4 (Count32, "Codec Entries Count");
+ Count=(int16u)Count32;
+ CodecInfos.resize(Count);
+ for (int16u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("Codec Entry");
+ Get_L2 (Type, "Type"); Param_Info1(Wm_CodecList_Kind(Type));
+ Get_L2 (CodecNameLength, "Codec Name Length");
+ Get_UTF16L(CodecNameLength*2, CodecName, "Codec Name");
+ Get_L2 (CodecDescriptionLength, "Codec Description Length");
+ Get_UTF16L(CodecDescriptionLength*2, CodecDescription, "Codec Description");
+ Get_L2 (CodecInformationLength, "Codec Information Length");
+ if (Type==2 && CodecInformationLength==2) //Audio and 2CC
+ Skip_L2( "2CC"); //Not used, we have it elsewhere
+ else if (Type==1 && CodecInformationLength==4) //Video and 4CC
+ Skip_C4( "4CC"); //Not used, we have it elsewhere
+ else
+ Skip_XX(CodecInformationLength, "Codec Information");
+ Element_End0();
+
+ FILLING_BEGIN();
+ CodecInfos[Pos].Type=Type;
+ CodecInfos[Pos].Info=CodecName;
+ if (!CodecDescription.empty())
+ {
+ CodecInfos[Pos].Info+=_T(" - ");
+ CodecInfos[Pos].Info+=CodecDescription;
+ }
+
+ Codec_Description_Count++;
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_ScriptCommand()
+{
+ Element_Name("Script Command");
+
+ //Parsing
+ Skip_GUID( "Reserved");
+ int16u Commands_Count, CommandTypes_Count;
+ Get_L2 (Commands_Count, "Commands Count");
+ Get_L2 (CommandTypes_Count, "Command Types Count");
+ for (int16u Pos=0; Pos<CommandTypes_Count; Pos++)
+ {
+ Element_Begin1("Command Type");
+ int16u Length;
+ Get_L2 (Length, "Command Type Length");
+ if (Length>0)
+ Skip_UTF16L(Length*2, "Command Type");
+ Element_End0();
+ }
+ for (int16u Pos=0; Pos<Commands_Count; Pos++)
+ {
+ Element_Begin1("Command");
+ int16u Length;
+ Skip_L2( "Type Index");
+ Get_L2 (Length, "Command Length");
+ if (Length>0)
+ Skip_UTF16L(Length*2, "Command");
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_Marker()
+{
+ Element_Name("Markers");
+
+ //Parsing
+ Skip_GUID( "Reserved");
+ int32u Markers_Count;
+ int16u Name_Length;
+ Get_L4 (Markers_Count, "Markers Count");
+ Skip_L2( "Reserved");
+ Get_L2 (Name_Length, "Name Length");
+ if (Name_Length>0)
+ Skip_UTF16L(Name_Length, "Name");
+
+ //Filling
+ if (Markers_Count>0)
+ Stream_Prepare(Stream_Menu);
+
+ //Parsing
+ for (int32u Pos=0; Pos<Markers_Count; Pos++)
+ {
+ Element_Begin1("Marker");
+ Ztring Marker;
+ int32u Marker_Length;
+ Skip_L8( "Offset");
+ Info_L8(PresentationTime, "Presentation Time"); Param_Info_From_Milliseconds(PresentationTime/10000);
+ Skip_L2( "Entry Length");
+ Info_L4(SendTime, "Send Time"); Param_Info_From_Milliseconds(SendTime);
+ Skip_L4( "Flags");
+ Get_L4 (Marker_Length, "Marker Description Length");
+ if (Marker_Length>0)
+ Get_UTF16L(Marker_Length*2, Marker, "Marker Description");
+ Element_End0();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_BitRateMutualExclusion()
+{
+ Element_Name("BitRate Mutual Exclusion");
+
+ //Parsing
+ int16u Count;
+ Skip_GUID( "Exclusion Type");
+ Get_L2 (Count, "Stream Numbers Count");
+ for (int16u Pos=0; Pos<Count; Pos++)
+ Skip_L2( "Stream Number");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_ErrorCorrection()
+{
+ Element_Name("Error Correction");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_ContentDescription()
+{
+ Element_Name("Content Description");
+
+ //Parsing
+ Ztring Title, Author, Copyright, Description, Rating;
+ int16u TitleLength, AuthorLength, CopyrightLength, DescriptionLength, RatingLength;
+ Get_L2 (TitleLength, "TitleLength");
+ Get_L2 (AuthorLength, "AuthorLength");
+ Get_L2 (CopyrightLength, "CopyrightLength");
+ Get_L2 (DescriptionLength, "DescriptionLength");
+ Get_L2 (RatingLength, "RatingLength");
+ if (TitleLength>0)
+ Get_UTF16L(TitleLength, Title, "Title");
+ if (AuthorLength>0)
+ Get_UTF16L(AuthorLength, Author, "Author");
+ if (CopyrightLength>0)
+ Get_UTF16L(CopyrightLength, Copyright, "Copyright");
+ if (DescriptionLength>0)
+ Get_UTF16L(DescriptionLength, Description, "Description");
+ if (RatingLength>0)
+ Get_UTF16L(RatingLength, Rating, "Rating");
+
+ //Filling
+ Fill(Stream_General, 0, General_Title, Title);
+ Fill(Stream_General, 0, General_Performer, Author);
+ Fill(Stream_General, 0, General_Copyright, Copyright);
+ Fill(Stream_General, 0, General_Comment, Description);
+ Fill(Stream_General, 0, General_Rating, Rating);
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_ExtendedContentDescription()
+{
+ Element_Name("Extended Content Description");
+
+ //Parsing
+ int16u Count;
+ Get_L2 (Count, "Content Descriptors Count");
+ for (int16u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("Content Descriptor");
+ Ztring Name, Value;
+ int64u Value_Int64=0;
+ int16u Name_Length, Value_Type, Value_Length;
+ Get_L2 (Name_Length, "Name Length");
+ Get_UTF16L(Name_Length, Name, "Name");
+ Get_L2 (Value_Type, "Value Data Type");
+ Get_L2 (Value_Length, "Value Length");
+ switch (Value_Type)
+ {
+ case 0x00 : Get_UTF16L(Value_Length, Value, "Value"); break;
+ case 0x01 :
+ if (Name==_T("ASFLeakyBucketPairs")) Header_ExtendedContentDescription_ASFLeakyBucketPairs(Value_Length);
+ else {Skip_XX(Value_Length, "Value"); Value=_T("(Binary)");} break;
+ case 0x02 : {int32u Value_Int; Get_L4 (Value_Int, "Value"); Value=(Value_Int==0)?_T("No"):_T("Yes"); Value_Int64=Value_Int;} break;
+ case 0x03 : {int32u Value_Int; Get_L4 (Value_Int, "Value"); Value.From_Number(Value_Int); Value_Int64=Value_Int;} break;
+ case 0x04 : {int64u Value_Int; Get_L8 (Value_Int, "Value"); Value.From_Number(Value_Int); Value_Int64=Value_Int;} break;
+ case 0x05 : {int16u Value_Int; Get_L2 (Value_Int, "Value"); Value.From_Number(Value_Int); Value_Int64=Value_Int;} break;
+ default : Skip_XX(Value_Length, "Value"); Value=_T("(Unknown)"); break;
+ }
+ Element_Info1(Name);
+ Element_Info1(Value);
+ Element_End0();
+
+ //Filling
+ if (!Value.empty())
+ {
+ if (Name==_T("Agility FPS")) {}
+ else if (Name==_T("ASFLeakyBucketPairs")) {} //Already done elsewhere
+ else if (Name==_T("AspectRatioX")) Header_ExtendedContentDescription_AspectRatioX=Value_Int64;
+ else if (Name==_T("AspectRatioY")) Header_ExtendedContentDescription_AspectRatioY=Value_Int64;
+ else if (Name==_T("Buffer Average")) {}
+ else if (Name==_T("DVR Index Granularity")) {}
+ else if (Name==_T("DVR File Version")) {}
+ else if (Name==_T("IsVBR"))
+ Fill(Stream_General, 0, General_OverallBitRate_Mode, Value_Int64==0?"CBR":"VBR");
+ else if (Name==_T("VBR Peak")) {} //Already in "Stream Bitrate" chunk
+ else if (Name==_T("WMFSDKVersion")) {}
+ else if (Name==_T("WMFSDKNeeded")) {}
+ else if (Name==_T("WM/AlbumTitle"))
+ Fill(Stream_General, 0, General_Album, Value);
+ else if (Name==_T("WM/AlbumArtist"))
+ {
+ Fill(Stream_General, 0, General_Performer, "");
+ Fill(Stream_General, 0, General_Performer, Value, true); //Clear last value, like Author (Content Description)
+ }
+ else if (Name==_T("WM/ArtistSortOrder"))
+ Fill(Stream_General, 0, General_Performer_Sort, Value);
+ else if (Name==_T("WM/AuthorURL"))
+ Fill(Stream_General, 0, "Author/Url", Value);
+ else if (Name==_T("WM/BeatsPerMinute"))
+ Fill(Stream_General, 0, General_BPM, Value);
+ else if (Name==_T("WM/Binary"))
+ Fill(Stream_General, 0, General_Cover, "Y");
+ else if (Name==_T("WM/Comments"))
+ Fill(Stream_General, 0, General_Comment, Value, true); //Clear last value
+ else if (Name==_T("WM/Composer"))
+ Fill(Stream_General, 0, General_Composer, Value);
+ else if (Name==_T("WM/Conductor"))
+ Fill(Stream_General, 0, General_Conductor, Value);
+ else if (Name==_T("WM/EncodedBy"))
+ Fill(Stream_General, 0, General_EncodedBy, Value);
+ else if (Name==_T("WM/EncoderSettings"))
+ Fill(Stream_General, 0, General_Encoded_Library_Settings, Value);
+ else if (Name==_T("WM/EncodingTime"))
+ Fill(Stream_General, 0, General_Encoded_Date, Ztring().Date_From_Seconds_1601(Value_Int64));
+ else if (Name==_T("WM/Genre"))
+ Fill(Stream_General, 0, General_Genre, Value, true); //Clear last value
+ else if (Name==_T("WM/GenreID"))
+ {
+ if (Retrieve(Stream_General, 0, General_Genre).empty())
+ Fill(Stream_General, 0, General_Genre, Value);
+ }
+ else if (Name==_T("WM/Language"))
+ Language_ForAll=Value;
+ else if (Name==_T("WM/MediaCredits"))
+ Fill(Stream_General, 0, General_ThanksTo, Value);
+ else if (Name==_T("WM/MediaPrimaryClassID")) {}
+ else if (Name==_T("WM/MCDI")) {}
+ else if (Name==_T("WM/ModifiedBy"))
+ Fill(Stream_General, 0, General_RemixedBy, Value);
+ else if (Name==_T("WM/OriginalAlbumTitle"))
+ Fill(Stream_General, 0, "Original/Album", Value);
+ else if (Name==_T("WM/OriginalReleaseTime"))
+ Fill(Stream_General, 0, "Original/Released_Date", Value);
+ else if (Name==_T("WM/ParentalRating"))
+ Fill(Stream_General, 0, General_LawRating, Value);
+ else if (Name==_T("WM/ParentalRatingReason"))
+ Fill(Stream_General, 0, General_LawRating_Reason, Value);
+ else if (Name==_T("WM/Picture"))
+ Fill(Stream_General, 0, General_Cover, "Y");
+ else if (Name==_T("WM/Provider"))
+ Fill(Stream_General, 0, "Provider", Value);
+ else if (Name==_T("WM/Publisher"))
+ Fill(Stream_General, 0, General_Publisher, Value);
+ else if (Name==_T("WM/RadioStationName"))
+ Fill(Stream_General, 0, General_ServiceName, Value);
+ else if (Name==_T("WM/RadioStationOwner"))
+ Fill(Stream_General, 0, General_ServiceProvider, Value);
+ else if (Name==_T("WM/SubTitle"))
+ Fill(Stream_General, 0, General_Title_More, Value);
+ else if (Name==_T("WM/SubTitleDescription"))
+ Fill(Stream_General, 0, General_Title_More, Value);
+ else if (Name==_T("WM/ToolName"))
+ Fill(Stream_General, 0, General_Encoded_Application, Value);
+ else if (Name==_T("WM/ToolVersion"))
+ Fill(Stream_General, 0, General_Encoded_Application, Retrieve(Stream_General, 0, General_Encoded_Application)+_T(" ")+Value, true);
+ else if (Name==_T("WM/TrackNumber"))
+ Fill(Stream_General, 0, General_Track_Position, Value, true); //Clear last value, like WM/Track
+ else if (Name==_T("WM/Track"))
+ {
+ if (Retrieve(Stream_General, 0, General_Track_Position).empty())
+ Fill(Stream_General, 0, General_Track_Position, Value.To_int32u()+1);
+ }
+ else if (Name==_T("WM/UniqueFileIdentifier"))
+ {
+ if (Value.empty() || Value[0]!=_T(';')) //Test if there is only the separator
+ {
+ Value.FindAndReplace(_T(";"), MediaInfoLib::Config.TagSeparator_Get());
+ Fill(Stream_General, 0, General_UniqueID, Value);
+ }
+ }
+ else if (Name==_T("WM/Writer"))
+ Fill(Stream_General, 0, General_WrittenBy, Value);
+ else if (Name==_T("WM/Year"))
+ Fill(Stream_General, 0, General_Recorded_Date, Value);
+ else
+ Fill(Stream_General, 0, Name.To_Local().c_str(), Value);
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_ExtendedContentDescription_ASFLeakyBucketPairs(int16u Value_Length)
+{
+ Element_Begin1("ASFLeakyBucketPairs");
+ Skip_L2( "Reserved");
+ for (int16u Pos=2; Pos<Value_Length; Pos+=8)
+ {
+ Element_Begin1("Bucket");
+ Skip_L4( "BitRate");
+ Skip_L4( "msBufferWindow");
+ Element_End0();
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_StreamBitRate()
+{
+ Element_Name("Stream Bitrate");
+
+ //Parsing
+ int16u Count;
+ Get_L2 (Count, "Count");
+ for (int16u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("Stream");
+ int32u AverageBitRate;
+ int16u StreamNumber;
+ Get_L2 (StreamNumber, "Stream Number"); Element_Info1(StreamNumber);
+ Get_L4 (AverageBitRate, "Average Bitrate"); Element_Info1(AverageBitRate);
+ Element_End0();
+
+ //Filling
+ if (Stream[StreamNumber].AverageBitRate==0) //Prefere Average bitrate of Extended Stream Properties if present
+ Stream[StreamNumber].AverageBitRate=AverageBitRate;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_ContentBranding()
+{
+ Element_Name("Content Branding");
+
+ //Parsing
+ Ztring CopyrightURL, BannerImageURL;
+ int32u BannerImageData_Type, BannerImageData_Length, BannerImageURL_Length, CopyrightURL_Length;
+ Get_L4 (BannerImageData_Type, "Banner Image Data Type"); Param_Info1(Wm_BannerImageData_Type(BannerImageData_Type));
+ Get_L4 (BannerImageData_Length, "Banner Image Data Length");
+ if (BannerImageData_Length>0)
+ Skip_XX(BannerImageData_Length, "Banner Image Data");
+ Get_L4 (BannerImageURL_Length, "Banner Image URL Length");
+ if (BannerImageURL_Length>0)
+ Get_Local(BannerImageURL_Length, BannerImageURL, "Banner Image URL");
+ Get_L4 (CopyrightURL_Length, "Copyright URL Length");
+ if (CopyrightURL_Length>0)
+ Get_Local(CopyrightURL_Length, CopyrightURL, "Copyright URL");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_ContentEncryption()
+{
+ Element_Name("Content Encryption");
+
+ //Parsing
+ Ztring LicenseURL;
+ int32u SecretDataLength, ProtectionTypeLength, KeyIDLength, LicenseURLLength;
+ Get_L4 (SecretDataLength, "Secret Data Length");
+ Skip_XX(SecretDataLength, "Secret Data");
+ Get_L4 (ProtectionTypeLength, "Protection Type Length");
+ Skip_Local(ProtectionTypeLength, "Protection Type");
+ Get_L4 (KeyIDLength, "Key ID Length");
+ Skip_Local(KeyIDLength, "Key ID Type");
+ Get_L4 (LicenseURLLength, "License URL Length");
+ Get_Local(LicenseURLLength, LicenseURL, "License URL");
+
+ //Filling
+ Fill(Stream_General, 0, "Encryption", LicenseURL);
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_ExtendedContentEncryption()
+{
+ Element_Name("Extended Content Encryption");
+
+ //Parsing
+ int32u DataLength;
+ Get_L4 (DataLength, "Data Length");
+ Skip_XX(DataLength, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_DigitalSignature()
+{
+ Element_Name("Digital Signature");
+
+ //Parsing
+ int32u DataLength;
+ Skip_L4( "Signature Type");
+ Get_L4 (DataLength, "Signature Data Length");
+ Skip_XX(DataLength, "Signature Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Header_Padding()
+{
+ Element_Name("Padding");
+
+ //Parsing
+ Skip_XX(Element_Size, "Padding");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Data()
+{
+ Element_Name("Data");
+
+ //Parsing
+ Skip_GUID( "File ID");
+ Skip_L8( "Total Data Packets");
+ Skip_L1( "Alignment");
+ Skip_L1( "Packet Alignment");
+
+ //Filling
+ Fill(Stream_General, 0, General_HeaderSize, File_Offset+Buffer_Offset-24);
+ Fill(Stream_General, 0, General_DataSize, Element_TotalSize_Get()+24);
+
+ //For each stream
+ Streams_Count=0;
+ std::map<int16u, stream>::iterator Temp=Stream.begin();
+ while (Temp!=Stream.end())
+ {
+ #if defined(MEDIAINFO_MPEGA_YES)
+ if (IsDvrMs && !Temp->second.Parser && Temp->second.AverageBitRate>=32768)
+ {
+ Temp->second.Parser=new File_Mpega; //No stream properties, trying to detect it in datas...
+ ((File_Mpega*)Temp->second.Parser)->Frame_Count_Valid=8;
+ Open_Buffer_Init(Temp->second.Parser);
+ }
+ #endif
+ if (Temp->second.Parser || Temp->second.StreamKind==Stream_Video) //We need Stream_Video for Frame_Rate computing
+ {
+ Temp->second.SearchingPayload=true;
+ Streams_Count++;
+ }
+ Temp++;
+ }
+
+ //Enabling the alternative parser
+ MustUseAlternativeParser=true;
+ Data_AfterTheDataChunk=File_Offset+Buffer_Offset+Element_TotalSize_Get();
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Data_Packet()
+{
+ //Counting
+ Packet_Count++;
+ Element_Info1(Packet_Count);
+ size_t Element_Show_Count=0;
+
+ //Parsing
+ int32u PacketLength=0, SizeOfMediaObject=0;
+ int8u Flags, ErrorCorrectionData_Length, ErrorCorrectionLengthType, SequenceType, PaddingLengthType, PacketLengthType;
+ bool ErrorCorrectionPresent;
+ Element_Begin1("Error Correction");
+ Get_L1 (Flags, "Flags");
+ Get_FlagsM(Flags&0x0F, ErrorCorrectionData_Length, "Error Correction Data Length"); //4 lowest bits
+ Skip_Flags(Flags, 4, "Opaque Data Present");
+ Get_FlagsM((Flags>>5)&0x03, ErrorCorrectionLengthType, "Error Correction Length Type"); //bits 6 and 7
+ Get_Flags (Flags, 7, ErrorCorrectionPresent, "Error Correction Present");
+ if (ErrorCorrectionPresent && ErrorCorrectionLengthType==0 && ErrorCorrectionData_Length==2)
+ {
+ int8u TypeNumber;
+ Get_L1 (TypeNumber, "Type/Number");
+ Skip_FlagsM((TypeNumber>>4)&0x0F, "Type");
+ Skip_FlagsM( TypeNumber &0x0F, "Number");
+ Skip_L1( "Cycle");
+ }
+ Element_End0();
+
+ Element_Begin1("Payload Parsing Information");
+ Get_L1 (Flags, "Length Type Flags");
+ Get_Flags (Flags, 0, MultiplePayloadsPresent, "Multiple Payloads Present");
+ Get_FlagsM((Flags>>1)&0x3, SequenceType, "Sequence Type");
+ Get_FlagsM((Flags>>3)&0x3, PaddingLengthType, "Padding Length Type");
+ Get_FlagsM((Flags>>5)&0x3, PacketLengthType, "Packet Length Type");
+ Skip_Flags(Flags, 7, "Error Correction Present");
+ Get_L1 (Flags, "Property Flags");
+ Get_FlagsM( Flags &0x3, ReplicatedDataLengthType, "Replicated Data Length Type");
+ Get_FlagsM((Flags>>2)&0x3, OffsetIntoMediaObjectLengthType, "Offset Into Media Object Length Type");
+ Get_FlagsM((Flags>>4)&0x3, MediaObjectNumberLengthType, "Media Object Number Length Type");
+ Get_FlagsM((Flags>>6)&0x3, StreamNumberLengthType, "Stream Number Length Type");
+ switch (PacketLengthType)
+ {
+ case 1 : {int8u Data; Get_L1(Data, "Packet Length"); PacketLength=Data;} break;
+ case 2 : {int16u Data; Get_L2(Data, "Packet Length"); PacketLength=Data;} break;
+ case 3 : Get_L4(PacketLength, "Packet Length"); break;
+ default: ;
+ }
+ switch (SequenceType)
+ {
+ case 1 : Skip_L1( "Sequence"); break;
+ case 2 : Skip_L2( "Sequence"); break;
+ case 3 : Skip_L4( "Sequence"); break;
+ default: ;
+ }
+ switch (PaddingLengthType)
+ {
+ case 1 : {int8u Data; Get_L1(Data, "Padding Length"); Data_Parse_Padding=Data;} break;
+ case 2 : {int16u Data; Get_L2(Data, "Padding Length"); Data_Parse_Padding=Data;} break;
+ case 3 : Get_L4(Data_Parse_Padding, "Padding Length"); break;
+ default: Data_Parse_Padding=0;
+ }
+ Skip_L4( "Send Time");
+ Skip_L2( "Duration");
+ Element_End0();
+
+ if (MultiplePayloadsPresent)
+ {
+ //Parsing
+ Element_Begin1("Multiple Payloads additional flags");
+ int8u AdditionalFlags;
+ Get_L1 (AdditionalFlags, "Flags");
+ Get_FlagsM( AdditionalFlags &0x3F, NumberPayloads, "Number of Payloads"); //6 bits
+ Get_FlagsM((AdditionalFlags>>6)&0x03, PayloadLengthType, "Payload Length Type"); //bits 6 and 7
+ Element_End0();
+ }
+ else
+ {
+ SizeOfMediaObject=(int32u)(Element_Size-Element_Offset-Data_Parse_Padding);
+ NumberPayloads=1;
+ }
+
+ for (NumberPayloads_Pos=0; NumberPayloads_Pos<NumberPayloads; NumberPayloads_Pos++)
+ {
+ Element_Begin1("Payload");
+ int32u ReplicatedDataLength=0, PayloadLength=0;
+ int8u StreamNumber;
+ Get_L1 (StreamNumber, "Stream Number");
+ Stream_Number=StreamNumber&0x7F; //For KeyFrame
+ Element_Info1(Stream_Number);
+ switch (MediaObjectNumberLengthType)
+ {
+ case 1 : Skip_L1( "Media Object Number"); break;
+ case 2 : Skip_L2( "Media Object Number"); break;
+ case 3 : Skip_L4( "Media Object Number"); break;
+ default: Trusted_IsNot("Media Object Number"); return; //Problem
+ }
+ switch (OffsetIntoMediaObjectLengthType)
+ {
+ case 1 : Skip_L1( "Offset Into Media Object"); break;
+ case 2 : Skip_L2( "Offset Into Media Object"); break;
+ case 3 : Skip_L4( "Offset Into Media Object"); break;
+ default: Trusted_IsNot("Offset Into Media Object"); return; //Problem
+ }
+ switch (ReplicatedDataLengthType)
+ {
+ case 1 : {int8u Data; Get_L1(Data, "Replicated Data Length"); ReplicatedDataLength=Data;} break;
+ case 2 : {int16u Data; Get_L2(Data, "Replicated Data Length"); ReplicatedDataLength=Data;} break;
+ case 3 : Get_L4(ReplicatedDataLength, "Replicated Data Length"); break;
+ default: Trusted_IsNot("Replicated Data Length"); return; //Problem
+ }
+ if (ReplicatedDataLengthType!=0 && ReplicatedDataLength>0)
+ {
+ if (ReplicatedDataLength>=8)
+ {
+ int32u PresentationTime;
+ Get_L4 (SizeOfMediaObject, "Size Of Media Object");
+ Get_L4 (PresentationTime, "Presentation Time");
+ if (ReplicatedDataLength>8)
+ Data_Packet_ReplicatedData(ReplicatedDataLength-8);
+
+ //Presentation time delta
+ std::map<int16u, stream>::iterator Strea=Stream.find(Stream_Number);
+ if (Strea!=Stream.end() && Strea->second.StreamKind==Stream_Video)
+ {
+ if (Strea->second.PresentationTime_Old==0)
+ Strea->second.PresentationTime_Old=FileProperties_Preroll;
+ if (PresentationTime!=Strea->second.PresentationTime_Old)
+ {
+ Strea->second.PresentationTime_Deltas[PresentationTime-Strea->second.PresentationTime_Old]++;
+ Strea->second.PresentationTime_Old=PresentationTime;
+ Strea->second.PresentationTime_Count++;
+ }
+ }
+ }
+ else if (ReplicatedDataLength==1)
+ {
+ Skip_L1( "Presentation Time Delta");
+ //TODO
+ }
+ else
+ {
+ Skip_XX(ReplicatedDataLength, "Replicated Data");
+ }
+ }
+
+ if (MultiplePayloadsPresent)
+ {
+ switch (PayloadLengthType)
+ {
+ case 1 : {int8u Data; Get_L1(Data, "Payload Length"); PayloadLength=Data;} break;
+ case 2 : {int16u Data; Get_L2(Data, "Payload Length"); PayloadLength=Data;} break;
+ case 3 : Get_L4(PayloadLength, "Payload Length"); break;
+ default: Trusted_IsNot("Payload Length"); return; //Problem
+ }
+ }
+ else if (Element_Size-Element_Offset>Data_Parse_Padding)
+ PayloadLength=(int32u)(Element_Size-(Element_Offset+Data_Parse_Padding));
+ else
+ {
+ Trusted_IsNot("Padding size problem");
+ return; //Problem
+ }
+ if (Element_Offset+PayloadLength+Data_Parse_Padding>Element_Size)
+ {
+ Trusted_IsNot("Payload Length problem");
+ return; //problem
+ }
+
+ //Analyzing
+ if (Stream[Stream_Number].Parser && Stream[Stream_Number].SearchingPayload)
+ {
+ //Handling of spanned on multiple chunks
+ bool FrameIsAlwaysComplete=true;
+ if (PayloadLength!=SizeOfMediaObject)
+ {
+ if (SizeOfMediaObject_BytesAlreadyParsed==0)
+ SizeOfMediaObject_BytesAlreadyParsed=SizeOfMediaObject-PayloadLength;
+ else
+ SizeOfMediaObject_BytesAlreadyParsed-=PayloadLength;
+ if (SizeOfMediaObject_BytesAlreadyParsed!=0)
+ FrameIsAlwaysComplete=false;
+ else
+ Element_Show_Count++;
+ }
+ else
+ Element_Show_Count++;
+
+ //Codec specific
+ #if defined(MEDIAINFO_VC1_YES)
+ if (Retrieve(Stream[Stream_Number].StreamKind, Stream[Stream_Number].StreamPos, Fill_Parameter(Stream[Stream_Number].StreamKind, Generic_Format))==_T("VC-1"))
+ ((File_Vc1*)Stream[Stream_Number].Parser)->FrameIsAlwaysComplete=FrameIsAlwaysComplete;
+ #endif
+
+ Element_Code=Stream_Number;
+ Demux(Buffer+(size_t)Element_Offset, (size_t)PayloadLength, ContentType_MainStream);
+
+ Open_Buffer_Continue(Stream[Stream_Number].Parser, (size_t)PayloadLength);
+ if (Stream[Stream_Number].Parser->Status[IsFinished]
+ || (Stream[Stream_Number].PresentationTime_Count>=300 && MediaInfoLib::Config.ParseSpeed_Get()<1))
+ {
+ Stream[Stream_Number].Parser->Open_Buffer_Unsynch();
+ Stream[Stream_Number].SearchingPayload=false;
+ Streams_Count--;
+ }
+
+ Element_Show();
+ }
+ else
+ {
+ Skip_XX(PayloadLength, "Data");
+ if (Stream[Stream_Number].SearchingPayload
+ && (Stream[Stream_Number].StreamKind==Stream_Video && Stream[Stream_Number].PresentationTime_Count>=300))
+ {
+ Stream[Stream_Number].SearchingPayload=false;
+ Streams_Count--;
+ }
+ }
+ Element_End0();
+ }
+
+ if (Data_Parse_Padding)
+ Skip_XX(Data_Parse_Padding, "Padding");
+
+ //Jumping if needed
+ if (Streams_Count==0 || (Packet_Count>=1000 && MediaInfoLib::Config.ParseSpeed_Get()<1))
+ {
+ Info("Data, Jumping to end of chunk");
+ GoTo(Data_AfterTheDataChunk, "Windows Media");
+ }
+
+ if (Element_Show_Count>0)
+ Element_Show();
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Data_Packet_ReplicatedData(int32u Size)
+{
+ Element_Begin1("Replicated Data");
+ int64u Element_Offset_Final=Element_Offset+Size;
+ for (size_t Pos=0; Pos<Stream[Stream_Number].Payload_Extension_Systems.size(); Pos++)
+ {
+ Element_Begin0();
+ switch (Stream[Stream_Number].Payload_Extension_Systems[Pos].ID.hi)
+ {
+ case Elements::Payload_Extension_System_TimeStamp : Data_Packet_ReplicatedData_TimeStamp(); break;
+ default : //Not enough info to validate this algorithm
+ //if (Stream[Stream_Number].Payload_Extension_Systems[Pos].Size!=(int16u)-1)
+ //{
+ // Element_Name("Unknown");
+ // Skip_XX(Stream[Stream_Number].Payload_Extension_Systems[Pos].Size, "Unknown");
+ //}
+ //else
+ Pos=Stream[Stream_Number].Payload_Extension_Systems.size(); //Disabling the rest, all is unknown
+ }
+ Element_End0();
+ }
+
+ if (Element_Offset<Element_Offset_Final)
+ {
+ Element_Begin1("Other chunks");
+ Skip_XX(Element_Offset_Final-Element_Offset, "Unknown");
+ Element_End0();
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Data_Packet_ReplicatedData_TimeStamp()
+{
+ Element_Name("TimeStamp");
+
+ //Parsing
+ int64u TS0;
+ Skip_L2( "Unknown");
+ Skip_L4( "Unknown");
+ Skip_L4( "Unknown");
+ Get_L8 (TS0, "TS0");
+ #if MEDIAINFO_TRACE
+ if (TS0!=(int64u)-1) Param_Info1(TS0/10000);
+ #endif //MEDIAINFO_TRACE
+ Info_L8(TS1, "TS1");
+ #if MEDIAINFO_TRACE
+ if (TS1!=(int64u)-1) Param_Info1(TS1/10000);
+ #endif //MEDIAINFO_TRACE
+ Skip_L4( "Unknown");
+ Skip_L4( "Unknown");
+ Skip_L4( "Unknown");
+ Skip_L4( "Unknown");
+
+ if (Stream[Stream_Number].TimeCode_First==(int64u)-1 && TS0!=(int64u)-1)
+ Stream[Stream_Number].TimeCode_First=TS0/10000;
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::SimpleIndex()
+{
+ Element_Name("Simple Index");
+
+ //Parsing
+ /*
+ int32u Count;
+ Skip_GUID( "File ID");
+ Skip_L8( "Index Entry Time Interval");
+ Skip_L4( "Maximum Packet Count");
+ Get_L4 (Count, "Index Entries Count");
+ for (int32u Pos=0; Pos<Count; Pos++)
+ {
+ Element_Begin1("Index Entry", 6);
+ int32u PacketNumber;
+ int16u PacketCount;
+ Get_L4 (PacketNumber, "Packet Number");
+ Get_L2 (PacketCount, "Packet Count");
+ Element_End0();
+ }
+ */
+ Skip_XX(Element_TotalSize_Get()-Element_Offset, "Indexes");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::Index()
+{
+ Element_Name("Index");
+
+ //Parsing
+ /*
+ int32u Blocks_Count;
+ int16u Specifiers_Count;
+ Skip_L4( "Index Entry Time Interval");
+ Get_L2 (Specifiers_Count, "Index Specifiers Count");
+ Get_L4 (Blocks_Count, "Index Blocks Count");
+ for (int16u Pos=0; Pos<Specifiers_Count; Pos++)
+ {
+ Element_Begin1("Specifier");
+ Skip_L2( "Stream Number");
+ Skip_L2( "Index Type");
+ Element_End0();
+ }
+ for (int32u Pos=0; Pos<Blocks_Count; Pos++)
+ {
+ Element_Begin1("Block");
+ int32u Entry_Count;
+ Get_L4 (Entry_Count, "Index Entry Count");
+ Element_Begin1("Block Positions");
+ for (int16u Pos=0; Pos<Specifiers_Count; Pos++)
+ Skip_L4( "Position");
+ Element_End0();
+ for (int32u Pos=0; Pos<Entry_Count; Pos++)
+ {
+ Element_Begin1("Entry");
+ for (int16u Pos=0; Pos<Specifiers_Count; Pos++)
+ Skip_L4( "Offset");
+ Element_End0();
+ }
+ Element_End0();
+ }
+ */
+ Skip_XX(Element_TotalSize_Get()-Element_Offset, "Indexes");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::MediaIndex()
+{
+ Element_Name("MediaIndex");
+}
+
+//---------------------------------------------------------------------------
+void File_Wm::TimecodeIndex()
+{
+ Element_Name("TimecodeIndex");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_WM_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Xdcam_Clip.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Xdcam_Clip.cpp
new file mode 100644
index 000000000..0a9371eb3
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Xdcam_Clip.cpp
@@ -0,0 +1,160 @@
+// File_Xdcam_Clip - Info for XDCAM XML files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_XDCAM_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File_Xdcam_Clip.h"
+#include "MediaInfo/MediaInfo.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "ZenLib/Dir.h"
+#include "ZenLib/File.h"
+#include "ZenLib/FileName.h"
+#include "tinyxml2.h"
+using namespace tinyxml2;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Xdcam_Clip::FileHeader_Begin()
+{
+ XMLDocument document;
+ if (!FileHeader_Begin_XML(document))
+ return false;
+
+ {
+ XMLElement* Root=document.FirstChildElement("NonRealTimeMeta");
+ if (Root)
+ {
+ Accept("Xdcam_Clip");
+ Fill(Stream_General, 0, General_Format, "XDCAM Clip");
+
+ XMLElement* Element;
+
+ //CreationDate
+ Element=Root->FirstChildElement("CreationDate");
+ string A=Element->Attribute("value");
+ if (Element)
+ Fill(Stream_General, 0, General_Recorded_Date, Element->Attribute("value"));
+
+ //CreationDate
+ Element=Root->FirstChildElement("LastUpdate");
+ if (Element)
+ Fill(Stream_General, 0, General_Tagged_Date, Element->Attribute("value"));
+
+ //Duration
+ Ztring Duration, EditUnit;
+ Element=Root->FirstChildElement("Duration");
+ if (Element)
+ Duration=Element->Attribute("value");
+ Element=Root->FirstChildElement("LtcChangeTable");
+ if (Element)
+ EditUnit=Element->Attribute("tcFps");
+ int64u Duration_Frames=Duration.To_int64u();
+ int64u EditUnit_Denominator=EditUnit.To_int64u();
+ if (Duration_Frames && EditUnit_Denominator)
+ Fill(Stream_General, 0, General_Duration, ((float32)Duration_Frames)*1000/EditUnit_Denominator, 0);
+
+ int64u File_Size_Total=File_Size;
+
+ #if defined(MEDIAINFO_MXF_YES)
+ if (File_Name.size()>12
+ && File_Name[File_Name.size()-7]==_T('M')
+ && File_Name[File_Name.size()-6]==_T('0')
+ && File_Name[File_Name.size()-5]==_T('1')
+ && File_Name[File_Name.size()-4]==_T('.')
+ && File_Name[File_Name.size()-3]==_T('X')
+ && File_Name[File_Name.size()-2]==_T('M')
+ && File_Name[File_Name.size()-1]==_T('L'))
+ {
+ Ztring file=File_Name.substr(File_Name.size()-12, 5);
+ Ztring MXF_File=File_Name;
+ MXF_File.resize(MXF_File.size()-12);
+ MXF_File+=file;
+ if (File::Exists(MXF_File+_T(".MXF")))
+ MXF_File+=_T(".MXF");
+ if (File::Exists(MXF_File+_T(".MP4")))
+ MXF_File+=_T(".MP4");
+
+ //int8u ReadByHuman=Ztring(MediaInfo::Option_Static(_T("ReadByHuman_Get"))).To_int8u();
+ //MediaInfo::Option_Static(_T("ReadByHuman"), _T("0"));
+ MediaInfo_Internal MI;
+ if (MI.Open(MXF_File))
+ {
+ //MediaInfo::Option_Static(_T("ReadByHuman"), ReadByHuman?_T("1"):_T("0"));
+ Merge(MI);
+ Fill(Stream_Video, StreamPos_Last, "Source", MXF_File);
+ File_Size_Total+=Ztring(MI.Get(Stream_General, 0, General_FileSize)).To_int64u();
+
+ //Commercial names
+ Fill(Stream_General, 0, General_Format_Commercial_IfAny, MI.Get(Stream_General, 0, General_Format_Commercial_IfAny));
+ Ztring Format_Commercial=MI.Get(Stream_General, 0, General_Format_Commercial_IfAny);
+ if (!Format_Commercial.empty())
+ {
+ Format_Commercial.FindAndReplace(_T("XDCAM "), Ztring());
+ Fill(Stream_General, 0, General_Format_Commercial, _T("XDCAM Clip ")+Format_Commercial, true);
+ }
+ }
+ //else
+ // MediaInfo::Option_Static(_T("ReadByHuman"), ReadByHuman?_T("1"):_T("0"));
+ }
+ #endif //defined(MEDIAINFO_MXF_YES)
+
+ //Device
+ Element=Root->FirstChildElement("Device");
+ if (Element)
+ Fill(Stream_General, 0, General_Encoded_Application, string(Element->Attribute("manufacturer"))+" "+Element->Attribute("modelName"), true, true);
+
+ if (File_Size_Total!=File_Size)
+ Fill(Stream_General, 0, General_FileSize, File_Size_Total, 10, true);
+ }
+ else
+ {
+ Reject("Xdcam_Clip");
+ return false;
+ }
+ }
+
+ //All should be OK...
+ return true;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_XDCAM_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Xdcam_Clip.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Xdcam_Clip.h
new file mode 100644
index 000000000..361d042e6
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File_Xdcam_Clip.h
@@ -0,0 +1,50 @@
+// File_Xdcam_Clip - Info for XDCAM Clip files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about XDCAM Clip Movie files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Xdcam_ClipH
+#define MediaInfo_File_Xdcam_ClipH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Xdcam_Clip
+//***************************************************************************
+
+class File_Xdcam_Clip : public File__Analyze
+{
+private :
+ //Buffer - File header
+ bool FileHeader_Begin();
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File__ReferenceFilesHelper.cpp b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File__ReferenceFilesHelper.cpp
new file mode 100644
index 000000000..83e825dc3
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File__ReferenceFilesHelper.cpp
@@ -0,0 +1,888 @@
+// File__ReferenceFilesHelper - class for analyzing/demuxing reference files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_REFERENCES_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Multiple/File__ReferenceFilesHelper.h"
+#include "MediaInfo/MediaInfo_Internal.h"
+#include "ZenLib/Dir.h"
+#include "ZenLib/File.h"
+#include "ZenLib/FileName.h"
+#include "ZenLib/Format/Http/Http_Utils.h"
+#include <set>
+#include <algorithm>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File__ReferenceFilesHelper::File__ReferenceFilesHelper(File__Analyze* MI_, MediaInfo_Config_MediaInfo* Config_)
+{
+ //Temp
+ MI=MI_;
+ Config=Config_;
+ Reference=References.end();
+ Init_Done=false;
+ TestContinuousFileNames=false;
+ FrameRate=0;
+ Duration=0;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File__ReferenceFilesHelper_Algo1 (const File__ReferenceFilesHelper::reference &Ref1, const File__ReferenceFilesHelper::reference &Ref2) { return (Ref1.StreamID<Ref2.StreamID);}
+bool File__ReferenceFilesHelper_Algo2 (const File__ReferenceFilesHelper::reference &Ref1, const File__ReferenceFilesHelper::reference &Ref2) { return (Ref1.StreamPos<Ref2.StreamPos);}
+bool File__ReferenceFilesHelper_Algo3 (const File__ReferenceFilesHelper::reference &Ref1, const File__ReferenceFilesHelper::reference &Ref2) { return (Ref1.StreamKind<Ref2.StreamKind);}
+void File__ReferenceFilesHelper::ParseReferences()
+{
+ if (!Init_Done)
+ {
+ //Testing IDs
+ std::sort(References.begin(), References.end(), File__ReferenceFilesHelper_Algo1);
+ std::sort(References.begin(), References.end(), File__ReferenceFilesHelper_Algo2);
+ std::sort(References.begin(), References.end(), File__ReferenceFilesHelper_Algo3);
+ std::set<int64u> StreamList;
+ bool StreamList_DuplicatedIds=false;
+ for (Reference=References.begin(); Reference<References.end(); Reference++)
+ if (StreamList.find((*Reference).StreamID)==StreamList.end())
+ StreamList.insert((*Reference).StreamID);
+ else
+ {
+ StreamList_DuplicatedIds=true;
+ break;
+ }
+ if (StreamList_DuplicatedIds)
+ for (Reference=References.begin(); Reference<References.end(); Reference++)
+ (*Reference).StreamID=Reference-References.begin()+1;
+
+ //Configuring file names
+ Reference=References.begin();
+ while (Reference!=References.end())
+ {
+ ZtringList Names=Reference->FileNames;
+ ZtringList AbsoluteNames; AbsoluteNames.Separator_Set(0, ",");
+ for (size_t Pos=0; Pos<Names.size(); Pos++)
+ {
+ if (Names[Pos].find(_T("file:///"))==0)
+ {
+ Names[Pos].erase(0, 8); //Removing "file:///", this is the default behaviour and this makes comparison easier
+ Names[Pos]=ZenLib::Format::Http::URL_Encoded_Decode(Names[Pos]);
+ }
+ if (Names[Pos].find(_T("file://"))==0)
+ {
+ Names[Pos].erase(0, 7); //Removing "file://", this is the default behaviour and this makes comparison easier
+ Names[Pos]=ZenLib::Format::Http::URL_Encoded_Decode(Names[Pos]);
+ }
+ if (Names[Pos].find(_T("file:"))==0)
+ {
+ Names[Pos].erase(0, 5); //Removing "file:", this is the default behaviour and this makes comparison easier
+ Names[Pos]=ZenLib::Format::Http::URL_Encoded_Decode(Names[Pos]);
+ }
+ Ztring AbsoluteName;
+ if (Names[Pos].find(_T(':'))!=1 && Names[Pos].find(_T("/"))!=0 && Names[Pos].find(_T("\\\\"))!=0) //If absolute patch
+ {
+ AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name);
+ if (!AbsoluteName.empty())
+ AbsoluteName+=ZenLib::PathSeparator;
+ }
+ AbsoluteName+=Names[Pos];
+ #ifdef __WINDOWS__
+ AbsoluteName.FindAndReplace(_T("/"), _T("\\"), 0, Ztring_Recursive); //Names[Pos] normalization
+ #endif //__WINDOWS__
+ AbsoluteNames.push_back(AbsoluteName);
+ }
+ if (!File::Exists(AbsoluteNames[0]))
+ {
+ AbsoluteNames.clear();
+
+ //Configuring file name (this time, we try to force URL decode in all cases)
+ for (size_t Pos=0; Pos<Names.size(); Pos++)
+ {
+ Names[Pos]=ZenLib::Format::Http::URL_Encoded_Decode(Names[Pos]);
+ Ztring AbsoluteName;
+ if (Names[Pos].find(_T(':'))!=1 && Names[Pos].find(_T("/"))!=0 && Names[Pos].find(_T("\\\\"))!=0) //If absolute patch
+ {
+ AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name);
+ if (!AbsoluteName.empty())
+ AbsoluteName+=ZenLib::PathSeparator;
+ }
+ AbsoluteName+=Names[Pos];
+ #ifdef __WINDOWS__
+ AbsoluteName.FindAndReplace(_T("/"), _T("\\"), 0, Ztring_Recursive); //Names[Pos] normalization
+ #endif //__WINDOWS__
+ AbsoluteNames.push_back(AbsoluteName);
+ }
+
+ if (!File::Exists(AbsoluteNames[0]))
+ {
+ AbsoluteNames.clear();
+ Names=Reference->FileNames;
+
+ //Configuring file name (this time, we try to test local files)
+ size_t PathSeparator_Pos=Names[0].find_last_of(_T("\\/"));
+ if (PathSeparator_Pos!=string::npos && PathSeparator_Pos)
+ {
+ Ztring PathToRemove=Names[0].substr(0, PathSeparator_Pos);
+ bool IsOk=true;
+ for (size_t Pos=0; Pos<Names.size(); Pos++)
+ if (Names[Pos].find(PathToRemove))
+ {
+ IsOk=false;
+ break;
+ }
+ if (IsOk)
+ {
+ for (size_t Pos=0; Pos<Names.size(); Pos++)
+ {
+ Names[Pos].erase(0, PathSeparator_Pos+1);
+ Ztring AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name);
+ if (!AbsoluteName.empty())
+ AbsoluteName+=ZenLib::PathSeparator;
+ AbsoluteName+=Names[Pos];
+ #ifdef __WINDOWS__
+ AbsoluteName.FindAndReplace(_T("/"), _T("\\"), 0, Ztring_Recursive); //Names[Pos] normalization
+ #endif //__WINDOWS__
+ AbsoluteNames.push_back(AbsoluteName);
+ }
+
+ if (!File::Exists(AbsoluteNames[0]))
+ {
+ AbsoluteNames.clear();
+ Names=Reference->FileNames;
+
+ //Configuring file name (this time, we try to test local files)
+ size_t PathSeparator_Pos=Names[0].find_last_of(_T("\\/"));
+ if (PathSeparator_Pos!=string::npos && PathSeparator_Pos)
+ PathSeparator_Pos=Names[0].find_last_of(_T("\\/"), PathSeparator_Pos-1);
+ if (PathSeparator_Pos!=string::npos && PathSeparator_Pos)
+ {
+ Ztring PathToRemove=Names[0].substr(0, PathSeparator_Pos);
+ bool IsOk=true;
+ for (size_t Pos=0; Pos<Names.size(); Pos++)
+ if (Names[Pos].find(PathToRemove))
+ {
+ IsOk=false;
+ break;
+ }
+ if (IsOk)
+ for (size_t Pos=0; Pos<Names.size(); Pos++)
+ {
+ Names[Pos].erase(0, PathSeparator_Pos+1);
+ Ztring AbsoluteName=ZenLib::FileName::Path_Get(MI->File_Name);
+ if (!AbsoluteName.empty())
+ AbsoluteName+=ZenLib::PathSeparator;
+ AbsoluteName+=Names[Pos];
+ #ifdef __WINDOWS__
+ AbsoluteName.FindAndReplace(_T("/"), _T("\\"), 0, Ztring_Recursive); //Names[Pos] normalization
+ #endif //__WINDOWS__
+ AbsoluteNames.push_back(AbsoluteName);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ Reference->Source=Reference->FileNames.Read(0);
+ if (Reference->StreamKind!=Stream_Max)
+ {
+ if (Reference->StreamPos==(size_t)-1)
+ Reference->StreamPos=Stream_Prepare(Reference->StreamKind);
+ MI->Fill(Reference->StreamKind, Reference->StreamPos, "Source", Reference->Source);
+ }
+ if (!AbsoluteNames.empty())
+ Reference->FileNames=AbsoluteNames;
+
+ if (!AbsoluteNames.empty() && AbsoluteNames[0]==MI->File_Name)
+ {
+ Reference->IsCircular=true;
+ Reference->FileNames.clear();
+ }
+ else if (!AbsoluteNames.empty())
+ Reference->FileNames=AbsoluteNames;
+ else
+ {
+ Reference->FileNames.clear();
+ MI->Fill(Reference->StreamKind, Reference->StreamPos, "Source_Info", "Missing");
+ }
+
+ if (TestContinuousFileNames)
+ File__Analyze::Streams_Accept_TestContinuousFileNames_Static(Reference->FileNames, true);
+
+ Reference++;
+ }
+
+ #if MEDIAINFO_DEMUX
+ if (Config->NextPacket_Get())
+ {
+ Demux_Interleave=Config->File_Demux_Interleave_Get();
+ if (Demux_Interleave)
+ CountOfReferencesToParse=References.size();
+ }
+
+ //Using the frame rate from the first stream having a frame rate
+ if (!FrameRate)
+ for (references::iterator ReferenceFrameRate=References.begin(); ReferenceFrameRate!=References.end(); ReferenceFrameRate++)
+ if (ReferenceFrameRate->FrameRate)
+ {
+ FrameRate=ReferenceFrameRate->FrameRate;
+ break;
+ }
+
+ if (Config->NextPacket_Get() && MI->Demux_EventWasSent_Accept_Specific)
+ {
+ Reference=References.begin();
+ while (Reference!=References.end())
+ {
+ ParseReference(); //Init
+ Reference++;
+ }
+
+ //Cleanup
+ for (size_t Pos=0; Pos<References.size(); Pos++)
+ if (References[Pos].Status[File__Analyze::IsFinished])
+ {
+ References.erase(References.begin()+Pos);
+ Pos--;
+ }
+ if (References.empty())
+ return;
+
+ //File size handling
+ if (MI->Config->File_Size!=MI->File_Size)
+ {
+ MI->Fill(Stream_General, 0, General_FileSize, MI->Config->File_Size, 10, true);
+ MI->Fill(Stream_General, 0, General_StreamSize, MI->File_Size, 10, true);
+ }
+
+ FileSize_Compute();
+ Reference=References.begin();
+ Init_Done=true;
+
+ MI->Config->Demux_EventWasSent=true;
+ return;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ FileSize_Compute();
+ Reference=References.begin();
+ Init_Done=true;
+ }
+
+ while (Reference!=References.end())
+ {
+ ParseReference();
+
+ //State
+ int64u FileSize_Parsed=0;
+ for (references::iterator ReferenceTemp=References.begin(); ReferenceTemp!=References.end(); ReferenceTemp++)
+ {
+ if (ReferenceTemp->MI)
+ {
+ if (ReferenceTemp->State<10000)
+ {
+ if (ReferenceTemp->MI)
+ ReferenceTemp->State=ReferenceTemp->MI->State_Get();
+ if (ReferenceTemp->State && ReferenceTemp->MI->Config.File_Size!=(int64u)-1)
+ FileSize_Parsed+=(int64u)(ReferenceTemp->MI->Config.File_Size*(((float)ReferenceTemp->State)/10000));
+ }
+ else
+ FileSize_Parsed+=ReferenceTemp->MI->Config.File_Size;
+ }
+ }
+ Config->State_Set(((float)FileSize_Parsed)/MI->Config->File_Size);
+
+ #if MEDIAINFO_DEMUX
+ if (Demux_Interleave)
+ {
+ references::iterator Reference_Next=Reference; Reference_Next++;
+ if (Reference_Next==References.end() && Config->NextPacket_Get() && CountOfReferencesToParse)
+ Reference=References.begin();
+ else
+ Reference=Reference_Next;
+
+ if (Config->Demux_EventWasSent)
+ return;
+ }
+ else
+ {
+ if (Config->Demux_EventWasSent)
+ return;
+
+ Reference++;
+ }
+ #else //MEDIAINFO_DEMUX
+ Reference++;
+ #endif //MEDIAINFO_DEMUX
+ }
+
+ //File size handling
+ FileSize_Compute();
+ if (MI->Config->File_Size!=MI->File_Size)
+ {
+ MI->Fill(Stream_General, 0, General_FileSize, MI->Config->File_Size, 10, true);
+ MI->Fill(Stream_General, 0, General_StreamSize, MI->File_Size, 10, true);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__ReferenceFilesHelper::ParseReference()
+{
+ if (Reference->MI==NULL && !Reference->FileNames.empty())
+ {
+ //Configuration
+ Reference->MI=new MediaInfo_Internal();
+ Reference->MI->Option(_T("File_IsReferenced"), _T("1"));
+ Reference->MI->Option(_T("File_FileNameFormat"), _T("CSV"));
+ Reference->MI->Option(_T("File_KeepInfo"), _T("1"));
+ Reference->MI->Option(_T("File_ID_OnlyRoot"), Config->File_ID_OnlyRoot_Get()?_T("1"):_T("0"));
+ Reference->MI->Option(_T("File_DvDif_DisableAudioIfIsInContainer"), Config->File_DvDif_DisableAudioIfIsInContainer_Get()?_T("1"):_T("0"));
+ if (References.size()>1 || Config->File_MpegTs_ForceMenu_Get())
+ Reference->MI->Option(_T("File_MpegTs_ForceMenu"), _T("1"));
+ #if MEDIAINFO_NEXTPACKET
+ if (Config->NextPacket_Get())
+ Reference->MI->Option(_T("File_NextPacket"), _T("1"));
+ #endif //MEDIAINFO_NEXTPACKET
+ #if MEDIAINFO_EVENTS
+ if (Config->Event_CallBackFunction_IsSet())
+ Reference->MI->Option(_T("File_Event_CallBackFunction"), Config->Event_CallBackFunction_Get());
+ ZtringListList SubFile_IDs;
+ for (size_t Pos=0; Pos<MI->StreamIDs_Size; Pos++)
+ {
+ ZtringList ID;
+ if (MI->StreamIDs_Width[Pos]==0)
+ ID.push_back(Ztring::ToZtring(-1));
+ else if (Pos+1==MI->StreamIDs_Size)
+ ID.push_back(Ztring::ToZtring(Reference->StreamID));
+ else
+ ID.push_back(Ztring::ToZtring(MI->StreamIDs[Pos]));
+ ID.push_back(Ztring::ToZtring(MI->StreamIDs_Width[Pos]));
+ ID.push_back(Ztring::ToZtring(MI->ParserIDs[Pos]));
+ SubFile_IDs.push_back(ID);
+ }
+ if (!SubFile_IDs.empty())
+ {
+ SubFile_IDs.Separator_Set(0, EOL);
+ SubFile_IDs.Separator_Set(1, _T(","));
+ Reference->MI->Option(_T("File_SubFile_IDs_Set"), SubFile_IDs.Read());
+ }
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_DEMUX
+ if (Config->Demux_Unpacketize_Get())
+ Reference->MI->Option(_T("File_Demux_Unpacketize"), _T("1"));
+ if (FrameRate)
+ Reference->MI->Option(_T("File_Demux_Rate"), Ztring::ToZtring(FrameRate, 25));
+ switch (Config->Demux_InitData_Get())
+ {
+ case 0 : Reference->MI->Option(_T("File_Demux_InitData"), _T("Event")); break;
+ case 1 : Reference->MI->Option(_T("File_Demux_InitData"), _T("Field")); break;
+ default: ;
+ }
+ #endif //MEDIAINFO_DEMUX
+ #if MEDIAINFO_IBI
+ if (!Reference->IbiStream.Infos.empty())
+ {
+ ibi Ibi;
+ Ibi.Streams[(int64u)-1]=new ibi::stream(Reference->IbiStream);
+
+ //IBI Creation
+ File_Ibi_Creation IbiCreation(Ibi);
+ Ztring IbiText=IbiCreation.Finish();
+ if (!IbiText.empty())
+ Reference->MI->Option(_T("File_Ibi"), IbiText);
+ }
+ #endif //MEDIAINFO_IBI
+
+ if (Reference->IsCircular)
+ {
+ MI->Fill(Reference->StreamKind, Reference->StreamPos, "Source_Info", "Circular");
+ if (!Config->File_KeepInfo_Get())
+ {
+ #if MEDIAINFO_DEMUX
+ if (CountOfReferencesToParse)
+ CountOfReferencesToParse--;
+ #endif //MEDIAINFO_DEMUX
+ Reference->StreamKind=Stream_Max;
+ Reference->StreamPos=(size_t)-1;
+ Reference->FileSize=Reference->MI->Config.File_Size;
+ delete Reference->MI; Reference->MI=NULL;
+ }
+ Reference->FileNames.clear();
+ }
+ else
+ {
+ //Run
+ if (!Reference->MI->Open(Reference->FileNames.Read()))
+ {
+ MI->Fill(Reference->StreamKind, Reference->StreamPos, "Source_Info", "Missing");
+ if (!Config->File_KeepInfo_Get())
+ {
+ #if MEDIAINFO_DEMUX
+ if (CountOfReferencesToParse)
+ CountOfReferencesToParse--;
+ #endif //MEDIAINFO_DEMUX
+ Reference->StreamKind=Stream_Max;
+ Reference->StreamPos=(size_t)-1;
+ Reference->FileSize=Reference->MI->Config.File_Size;
+ delete Reference->MI; Reference->MI=NULL;
+ }
+ Reference->FileNames.clear();
+ }
+
+ #if MEDIAINFO_NEXTPACKET && MEDIAINFO_DEMUX
+ if (Config->NextPacket_Get() && MI->Demux_EventWasSent_Accept_Specific)
+ return;
+ #endif //MEDIAINFO_NEXTPACKET
+ }
+ }
+
+ if (Reference->MI)
+ {
+ #if MEDIAINFO_EVENTS && MEDIAINFO_NEXTPACKET
+ if (Config->Event_CallBackFunction_IsSet() && !Reference->Status[File__Analyze::IsFinished])
+ {
+ #if MEDIAINFO_DEMUX
+ while ((Reference->Status=Reference->MI->Open_NextPacket())[8])
+ {
+ if (Config->Event_CallBackFunction_IsSet())
+ {
+ Config->Demux_EventWasSent=true;
+ return;
+ }
+ }
+ if (CountOfReferencesToParse)
+ CountOfReferencesToParse--;
+ #endif //MEDIAINFO_DEMUX
+ }
+ #endif //MEDIAINFO_EVENTS && MEDIAINFO_NEXTPACKET
+ ParseReference_Finalize();
+ if (!Config->File_KeepInfo_Get())
+ {
+ Reference->StreamKind=Stream_Max;
+ Reference->StreamPos=(size_t)-1;
+ Reference->State=10000;
+ Reference->FileSize=Reference->MI->Config.File_Size;
+ delete Reference->MI; Reference->MI=NULL;
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__ReferenceFilesHelper::ParseReference_Finalize ()
+{
+ bool StreamFound=false;
+ for (size_t StreamKind=Stream_General+1; StreamKind<Stream_Max; StreamKind++)
+ for (size_t StreamPos=0; StreamPos<Reference->MI->Count_Get((stream_t)StreamKind); StreamPos++)
+ {
+ StreamKind_Last=(stream_t)StreamKind;
+ if (Reference->StreamPos!=(size_t)-1 && StreamKind_Last==Reference->StreamKind && StreamPos==0)
+ {
+ StreamPos_To=Reference->StreamPos;
+ StreamFound=true;
+ }
+ else
+ {
+ size_t ToInsert=(size_t)-1;
+ for (references::iterator ReferencePos=References.begin(); ReferencePos!=References.end(); ReferencePos++)
+ if (ReferencePos->StreamKind==StreamKind_Last && Reference->StreamID<ReferencePos->StreamID)
+ {
+ ToInsert=ReferencePos->StreamPos;
+ break;
+ }
+
+ StreamPos_To=Stream_Prepare((stream_t)StreamKind, ToInsert);
+ }
+ StreamPos_From=StreamPos;
+
+ ParseReference_Finalize_PerStream();
+ }
+
+ if (!StreamFound && Reference->StreamKind!=Stream_Max && Reference->StreamPos!=(size_t)-1)
+ {
+ Ztring MuxingMode=MI->Retrieve(Reference->StreamKind, Reference->StreamPos, "MuxingMode");
+ if (!MuxingMode.empty())
+ MuxingMode.insert(0, _T(" / "));
+ MI->Fill(Reference->StreamKind, Reference->StreamPos, "MuxingMode", Reference->MI->Info->Get(Stream_General, 0, General_Format)+MuxingMode, true);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__ReferenceFilesHelper::ParseReference_Finalize_PerStream ()
+{
+ //Hacks - Before
+ Ztring CodecID=MI->Retrieve(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_CodecID));
+ Ztring ID_Base;
+ if (Reference->StreamID!=(int64u)-1)
+ ID_Base=Ztring::ToZtring(Reference->StreamID);
+ Ztring ID=ID_Base;
+ Ztring ID_String=ID_Base;
+ Ztring MenuID;
+ Ztring MenuID_String;
+
+ MI->Clear(StreamKind_Last, StreamPos_To, General_ID);
+
+ MI->Merge(*Reference->MI->Info, StreamKind_Last, StreamPos_From, StreamPos_To);
+
+ //Frame rate if available from container
+ if (StreamKind_Last==Stream_Video && Reference->FrameRate)
+ MI->Fill(Stream_Video, StreamPos_To, Video_FrameRate, Reference->FrameRate, 3 , true);
+
+ //Hacks - After
+ if (CodecID!=MI->Retrieve(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_CodecID)))
+ {
+ if (!CodecID.empty())
+ CodecID+=_T(" / ");
+ CodecID+=MI->Retrieve(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_CodecID));
+ MI->Fill(StreamKind_Last, StreamPos_To, MI->Fill_Parameter(StreamKind_Last, Generic_CodecID), CodecID, true);
+ }
+ if (Reference->MI->Count_Get(Stream_Video)+Reference->MI->Count_Get(Stream_Audio)>1 && Reference->MI->Get(Stream_Video, 0, Video_Format)!=_T("DV"))
+ {
+ if (StreamKind_Last==Stream_Menu)
+ {
+ ZtringList List; List.Separator_Set(0, _T(" / ")); List.Write(MI->Retrieve(StreamKind_Last, StreamPos_To, "List"));
+ ZtringList List_String; List_String.Separator_Set(0, _T(" / ")); List_String.Write(MI->Retrieve(StreamKind_Last, StreamPos_To, "List/String"));
+ if (!ID_Base.empty())
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ List[Pos].insert(0, ID_Base+_T("-"));
+ List_String[Pos].insert(0, ID_Base+_T("-"));
+ }
+ MI->Fill(Stream_Menu, StreamPos_To, Menu_List, List.Read(), true);
+ MI->Fill(Stream_Menu, StreamPos_To, Menu_List_String, List_String.Read(), true);
+ }
+ else if (References.size()>1 && Reference->MI->Count_Get(Stream_Menu)==0)
+ {
+ if (Reference->MenuPos==(size_t)-1)
+ {
+ Reference->MenuPos=MI->Stream_Prepare(Stream_Menu);
+ MI->Fill(Stream_Menu, Reference->MenuPos, General_ID, ID_Base);
+ }
+ Ztring List=Reference->MI->Get(StreamKind_Last, StreamPos_From, General_ID);
+ Ztring List_String=Reference->MI->Get(StreamKind_Last, StreamPos_From, General_ID_String);
+ if (!ID_Base.empty())
+ {
+ List.insert(0, ID_Base+_T("-"));
+ List_String.insert(0, ID_Base+_T("-"));
+ }
+ MI->Fill(Stream_Menu, Reference->MenuPos, Menu_List, List);
+ MI->Fill(Stream_Menu, Reference->MenuPos, Menu_List_String, List_String);
+ }
+ }
+ if ((!Config->File_ID_OnlyRoot_Get() || Reference->MI->Count_Get(Stream_Video)+Reference->MI->Count_Get(Stream_Audio)>1) && !MI->Retrieve(StreamKind_Last, StreamPos_To, General_ID).empty())
+ {
+ if (!ID.empty())
+ ID+=_T('-');
+ ID+=MI->Retrieve(StreamKind_Last, StreamPos_To, General_ID);
+ if (!ID_String.empty())
+ ID_String+=_T('-');
+ ID_String+=MI->Retrieve(StreamKind_Last, StreamPos_To, General_ID_String);
+ if (!MI->Retrieve(StreamKind_Last, StreamPos_To, "MenuID").empty())
+ {
+ if (!ID_Base.empty())
+ MenuID=ID_Base+_T('-');
+ MenuID+=MI->Retrieve(StreamKind_Last, StreamPos_To, "MenuID");
+ if (!ID_Base.empty())
+ MenuID_String=ID_Base+_T('-');
+ MenuID_String+=MI->Retrieve(StreamKind_Last, StreamPos_To, "MenuID/String");
+ }
+ else if (Reference->MenuPos!=(size_t)-1)
+ {
+ MenuID=ID_Base;
+ MenuID_String=ID_Base;
+ }
+ }
+ MI->Fill(StreamKind_Last, StreamPos_To, General_ID, ID, true);
+ MI->Fill(StreamKind_Last, StreamPos_To, General_ID_String, ID_String, true);
+ MI->Fill(StreamKind_Last, StreamPos_To, "MenuID", MenuID, true);
+ MI->Fill(StreamKind_Last, StreamPos_To, "MenuID/String", MenuID_String, true);
+ if (MI->Retrieve(StreamKind_Last, StreamPos_To, "Source").empty())
+ MI->Fill(StreamKind_Last, StreamPos_To, "Source", Reference->Source);
+
+ //Others
+ if (Reference->MI->Info && MI->Retrieve(StreamKind_Last, StreamPos_To, Reference->MI->Info->Fill_Parameter(StreamKind_Last, Generic_Format))!=Reference->MI->Info->Get(Stream_General, 0, General_Format))
+ {
+ Ztring MuxingMode=MI->Retrieve(StreamKind_Last, StreamPos_To, "MuxingMode");
+ if (!MuxingMode.empty())
+ MuxingMode.insert(0, _T(" / "));
+ MI->Fill(StreamKind_Last, StreamPos_To, "MuxingMode", Reference->MI->Info->Get(Stream_General, 0, General_Format)+MuxingMode, true);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File__ReferenceFilesHelper::Read_Buffer_Unsynched()
+{
+ MI->Open_Buffer_Unsynch();
+ for (references::iterator Reference=References.begin(); Reference!=References.end(); Reference++)
+ if (Reference->MI)
+ Reference->MI->Open_Buffer_Unsynch();
+
+ #if MEDIAINFO_DEMUX
+ Config->Demux_EventWasSent=true; //We want not try to read new data from the file
+ #endif //MEDIAINFO_DEMUX
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t File__ReferenceFilesHelper::Read_Buffer_Seek (size_t Method, int64u Value, int64u ID)
+{
+ //Parsing
+ switch (Method)
+ {
+ case 0 :
+ #if MEDIAINFO_DEMUX
+ {
+ if (Value)
+ {
+ if (Value>MI->Config->File_Size)
+ return 2; //Invalid value
+
+ //Init
+ if (!Duration)
+ {
+ MediaInfo_Internal MI2;
+ MI2.Option(_T("File_KeepInfo"), _T("1"));
+ Ztring ParseSpeed_Save=MI2.Option(_T("ParseSpeed_Get"), _T(""));
+ Ztring Demux_Save=MI2.Option(_T("Demux_Get"), _T(""));
+ MI2.Option(_T("ParseSpeed"), _T("0"));
+ MI2.Option(_T("Demux"), Ztring());
+ size_t MiOpenResult=MI2.Open(MI->File_Name);
+ MI2.Option(_T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value
+ MI2.Option(_T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value
+ if (!MiOpenResult)
+ return (size_t)-1;
+ Duration=MI2.Get(Stream_General, 0, General_Duration).To_float64()/1000;
+ }
+
+ //Time percentage
+ float64 DurationF=Duration;
+ DurationF*=Value;
+ DurationF/=MI->Config->File_Size;
+ size_t DurationM=(size_t)(DurationF*1000);
+ Ztring DurationS;
+ DurationS+=L'0'+(wchar_t)(DurationM/(10*60*60*1000)); DurationM%=10*60*60*1000;
+ DurationS+=L'0'+(wchar_t)(DurationM/( 60*60*1000)); DurationM%= 60*60*1000;
+ DurationS+=L':';
+ DurationS+=L'0'+(wchar_t)(DurationM/( 10*60*1000)); DurationM%= 10*60*1000;
+ DurationS+=L'0'+(wchar_t)(DurationM/( 60*1000)); DurationM%= 60*1000;
+ DurationS+=L':';
+ DurationS+=L'0'+(wchar_t)(DurationM/( 10*1000)); DurationM%= 10*1000;
+ DurationS+=L'0'+(wchar_t)(DurationM/( 1000)); DurationM%= 1000;
+ DurationS+=L'.';
+ DurationS+=L'0'+(wchar_t)(DurationM/( 100)); DurationM%= 100;
+ DurationS+=L'0'+(wchar_t)(DurationM/( 10)); DurationM%= 10;
+ DurationS+=L'0'+(wchar_t)(DurationM);
+
+ CountOfReferencesToParse=References.size();
+ bool HasProblem=false;
+ for (Reference=References.begin(); Reference!=References.end(); Reference++)
+ {
+ if (Reference->MI)
+ {
+ Ztring Result=Reference->MI->Option(_T("File_Seek"), DurationS);
+ if (!Result.empty())
+ HasProblem=true;
+ }
+ Reference->Status.reset();
+ }
+ Reference=References.begin();
+ Open_Buffer_Unsynch();
+ return HasProblem?(size_t)-1:1; //Not supported value if there is a problem (TODO: better info)
+ }
+
+ CountOfReferencesToParse=References.size();
+ bool HasProblem=false;
+ for (Reference=References.begin(); Reference!=References.end(); Reference++)
+ {
+ if (Reference->MI)
+ {
+ Ztring Result=Reference->MI->Option(_T("File_Seek"), Ztring::ToZtring(Value));
+ if (!Result.empty())
+ HasProblem=true;
+ }
+ Reference->Status.reset();
+ }
+ Reference=References.begin();
+ Open_Buffer_Unsynch();
+ return HasProblem?(size_t)-1:1; //Not supported value if there is a problem (TODO: better info)
+ }
+ #else //MEDIAINFO_DEMUX
+ return (size_t)-1; //Not supported
+ #endif //MEDIAINFO_DEMUX
+ case 1 :
+ {
+ //Time percentage
+ int64u Duration=MI->Get(Stream_General, 0, General_Duration).To_int64u();
+ Ztring DurationS;
+ if (Duration)
+ {
+ Duration*=Value;
+ Duration/=10000;
+ DurationS+=L'0'+(wchar_t)(Duration/(10*60*60*1000)); Duration%=10*60*60*1000;
+ DurationS+=L'0'+(wchar_t)(Duration/( 60*60*1000)); Duration%= 60*60*1000;
+ DurationS+=L':';
+ DurationS+=L'0'+(wchar_t)(Duration/( 10*60*1000)); Duration%= 10*60*1000;
+ DurationS+=L'0'+(wchar_t)(Duration/( 60*1000)); Duration%= 60*1000;
+ DurationS+=L':';
+ DurationS+=L'0'+(wchar_t)(Duration/( 10*1000)); Duration%= 10*1000;
+ DurationS+=L'0'+(wchar_t)(Duration/( 1000)); Duration%= 1000;
+ DurationS+=L'.';
+ DurationS+=L'0'+(wchar_t)(Duration/( 100)); Duration%= 100;
+ DurationS+=L'0'+(wchar_t)(Duration/( 10)); Duration%= 10;
+ DurationS+=L'0'+(wchar_t)(Duration);
+ }
+ else
+ DurationS=Ztring::ToZtring(((float64)Value)/100)+_T('%');
+
+ CountOfReferencesToParse=References.size();
+ bool HasProblem=false;
+ for (Reference=References.begin(); Reference!=References.end(); Reference++)
+ {
+ if (Reference->MI)
+ {
+ Ztring Result=Reference->MI->Option(_T("File_Seek"), DurationS);
+ if (!Result.empty())
+ HasProblem=true;
+ }
+ Reference->Status.reset();
+ }
+ Reference=References.begin();
+ Open_Buffer_Unsynch();
+ return HasProblem?2:1; //Invalid value if there is a problem (TODO: better info)
+ }
+ case 2 : //Timestamp
+ #if MEDIAINFO_DEMUX
+ {
+ CountOfReferencesToParse=References.size();
+ Ztring Time; Time.Duration_From_Milliseconds(Value/1000000);
+ for (Reference=References.begin(); Reference!=References.end(); Reference++)
+ {
+ if (Reference->MI)
+ {
+ Ztring Result=Reference->MI->Option(_T("File_Seek"), Time);
+ if (!Result.empty())
+ return 2; //Invalid value
+ }
+ else
+ {
+ //There was a problem, removing Reference
+ References.clear();
+ return Read_Buffer_Seek(Method, Value, ID);
+ }
+ Reference->Status.reset();
+ }
+ Reference=References.begin();
+ Open_Buffer_Unsynch();
+ return 1;
+ }
+ #else //MEDIAINFO_DEMUX
+ return (size_t)-1; //Not supported
+ #endif //MEDIAINFO_DEMUX
+ case 3 : //FrameNumber
+ #if MEDIAINFO_DEMUX
+ CountOfReferencesToParse=References.size();
+ for (Reference=References.begin(); Reference!=References.end(); Reference++)
+ {
+ if (Reference->MI)
+ {
+ Ztring Result=Reference->MI->Option(_T("File_Seek"), _T("Frame=")+Ztring::ToZtring(Value));
+ if (!Result.empty())
+ return 2; //Invalid value
+ }
+ else
+ {
+ //There was a problem, removing Reference
+ References.clear();
+ return Read_Buffer_Seek(Method, Value, ID);
+ }
+ Reference->Status.reset();
+ }
+ Reference=References.begin();
+ Open_Buffer_Unsynch();
+ return 1;
+ #else //MEDIAINFO_DEMUX
+ return (size_t)-1; //Not supported
+ #endif //MEDIAINFO_DEMUX
+ default : return 0;
+ }
+}
+#endif //MEDIAINFO_SEEK
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t File__ReferenceFilesHelper::Stream_Prepare (stream_t StreamKind, size_t StreamPos)
+{
+ size_t StreamPos_Last=MI->Stream_Prepare(StreamKind, StreamPos);
+
+ for (references::iterator ReferencePos=References.begin(); ReferencePos!=References.end(); ReferencePos++)
+ if (ReferencePos->StreamKind==StreamKind && ReferencePos->StreamPos>=StreamPos_Last)
+ if (ReferencePos->StreamPos!=(size_t)-1)
+ ReferencePos->StreamPos++;
+
+ return StreamPos_Last;
+}
+
+//---------------------------------------------------------------------------
+void File__ReferenceFilesHelper::FileSize_Compute ()
+{
+ if (MI->Config==NULL)
+ return;
+
+ MI->Config->File_Size=MI->File_Size;
+
+ for (references::iterator Reference=References.begin(); Reference!=References.end(); Reference++)
+ {
+ if (Reference->FileSize!=(int64u)-1)
+ MI->Config->File_Size+=Reference->FileSize;
+ else if (Reference->MI && Reference->MI->Config.File_Size!=(int64u)-1)
+ MI->Config->File_Size+=Reference->MI->Config.File_Size;
+ else
+ for (size_t Pos=0; Pos<Reference->FileNames.size(); Pos++)
+ MI->Config->File_Size+=File::Size_Get(Reference->FileNames[Pos]);
+ }
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_REFERENCES_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Multiple/File__ReferenceFilesHelper.h b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File__ReferenceFilesHelper.h
new file mode 100644
index 000000000..ee56a1454
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Multiple/File__ReferenceFilesHelper.h
@@ -0,0 +1,128 @@
+// File__ReferenceFilesHelper - class for analyzing/demuxing reference files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef File__ReferenceFilesHelperH
+#define File__ReferenceFilesHelperH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File__ReferenceFilesHelper
+//***************************************************************************
+
+class File__ReferenceFilesHelper
+{
+public :
+ //In
+ struct reference
+ {
+ ZtringList FileNames;
+ Ztring Source; //Source file name (relative path)
+ stream_t StreamKind;
+ size_t StreamPos;
+ size_t MenuPos;
+ int64u StreamID;
+ float64 FrameRate;
+ int64u Delay;
+ int64u FileSize;
+ bool IsCircular;
+ size_t State;
+ MediaInfo_Internal* MI;
+ #if MEDIAINFO_FILTER
+ int64u Enabled;
+ #endif //MEDIAINFO_FILTER
+ #if MEDIAINFO_NEXTPACKET
+ std::bitset<32> Status;
+ ibi::stream IbiStream;
+ #endif //MEDIAINFO_NEXTPACKET
+
+ reference()
+ {
+ FileNames.Separator_Set(0, _T(","));
+ StreamKind=Stream_Max;
+ StreamPos=(size_t)-1;
+ MenuPos=(size_t)-1;
+ StreamID=(int64u)-1;
+ FrameRate=0;
+ Delay=0;
+ FileSize=(int64u)-1;
+ IsCircular=false;
+ State=0;
+ MI=NULL;
+ #if MEDIAINFO_FILTER
+ Enabled=true;
+ #endif //MEDIAINFO_FILTER
+ }
+ };
+ typedef std::vector<reference> references;
+ references References;
+ bool TestContinuousFileNames;
+
+ //Streams management
+ void ParseReferences();
+
+ //Constructor / Destructor
+ File__ReferenceFilesHelper(File__Analyze* MI, MediaInfo_Config_MediaInfo* Config);
+
+ #if MEDIAINFO_SEEK
+ size_t Read_Buffer_Seek (size_t Method, int64u Value, int64u ID);
+ #endif //MEDIAINFO_SEEK
+
+private :
+ //Streams management
+ void ParseReference ();
+ void ParseReference_Finalize ();
+ void ParseReference_Finalize_PerStream ();
+ void Open_Buffer_Unsynch() {Read_Buffer_Unsynched();}
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched();
+
+ //temp
+ File__Analyze* MI;
+ MediaInfo_Config_MediaInfo* Config;
+ references::iterator Reference;
+ bool Init_Done;
+ bool Demux_Interleave;
+ size_t CountOfReferencesToParse;
+ float64 FrameRate;
+ float64 Duration;
+ stream_t StreamKind_Last;
+ size_t StreamPos_From;
+ size_t StreamPos_To;
+
+ //Helpers
+ size_t Stream_Prepare(stream_t StreamKind, size_t StreamPos=(size_t)-1);
+ void FileSize_Compute();
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/PreComp.cpp b/src/thirdparty/MediaInfo/MediaInfo/PreComp.cpp
new file mode 100644
index 000000000..c676c07df
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/PreComp.cpp
@@ -0,0 +1,27 @@
+// PreComp - PreComp file for MediaInfo
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Helpers for compilers (precompilation)
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/PreComp.h"
+//---------------------------------------------------------------------------
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/PreComp.h b/src/thirdparty/MediaInfo/MediaInfo/PreComp.h
new file mode 100644
index 000000000..555c00094
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/PreComp.h
@@ -0,0 +1,39 @@
+// PreComp - PreComp file for MediaInfo
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Helpers for compilers (precompilation)
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_PreCompH
+#define MediaInfo_PreCompH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+ #include "MediaInfo/Setup.h"
+ #include "MediaInfo/File__Analyze.h"
+#endif //_MSC_VER
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_Directory.cpp b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_Directory.cpp
new file mode 100644
index 000000000..7627e6f39
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_Directory.cpp
@@ -0,0 +1,244 @@
+// Reader_Directory - All info about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DIRECTORY_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Reader/Reader_Directory.h"
+#include "ZenLib/Dir.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+size_t Reader_Directory::Format_Test(MediaInfo_Internal* MI, const String &File_Name)
+{
+ #ifdef MEDIAINFO_BDMV_YES
+ if (Dir::Exists(File_Name) && File_Name.find(Ztring(1, PathSeparator)+_T("BDMV"))+5==File_Name.size())
+ return Bdmv_Format_Test(MI, File_Name);
+ #endif //MEDIAINFO_BDMV_YES
+
+ #ifdef MEDIAINFO_P2_YES
+ if (Dir::Exists(File_Name) && File_Name.rfind(Ztring(1, PathSeparator)+_T("CONTENT"))+8==File_Name.size())
+ return P2_Format_Test(MI, File_Name);
+ #endif //MEDIAINFO_P2_YES
+
+ #ifdef MEDIAINFO_XDCAM_YES
+ if (Dir::Exists(File_Name) && File_Name.rfind(Ztring(1, PathSeparator)+_T("XDCAM"))+5==File_Name.size())
+ return Xdcam_Format_Test(MI, File_Name);
+ #endif //MEDIAINFO_XDCAM_YES
+
+ return 0;
+}
+
+//---------------------------------------------------------------------------
+void Reader_Directory::Directory_Cleanup(ZtringList &List)
+{
+ #ifdef MEDIAINFO_BDMV_YES
+ Bdmv_Directory_Cleanup(List);
+ #endif //MEDIAINFO_BDMV_YES
+
+ #ifdef MEDIAINFO_P2_YES
+ P2_Directory_Cleanup(List);
+ #endif //MEDIAINFO_P2_YES
+
+ #ifdef MEDIAINFO_XDCAM_YES
+ Xdcam_Directory_Cleanup(List);
+ #endif //MEDIAINFO_XDCAM_YES
+}
+
+//***************************************************************************
+// Blu-ray stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_BDMV_YES
+int Reader_Directory::Bdmv_Format_Test(MediaInfo_Internal* MI, const String &File_Name)
+{
+ if (!MI->SelectFromExtension(_T("Bdmv")))
+ return 0;
+
+ MI->Open_Buffer_Init(0, File_Name);
+
+ MI->Open_Buffer_Continue(NULL, 0);
+
+ MI->Open_Buffer_Finalize();
+
+ return 1;
+}
+#endif //MEDIAINFO_BDMV_YES
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_BDMV_YES
+void Reader_Directory::Bdmv_Directory_Cleanup(ZtringList &List)
+{
+ //if there is a BDMV folder, this is blu-ray
+ Ztring ToSearch=Ztring(1, PathSeparator)+_T("BDMV")+PathSeparator+_T("index.bdmv"); //"\BDMV\index.bdmv"
+ for (size_t File_Pos=0; File_Pos<List.size(); File_Pos++)
+ {
+ size_t BDMV_Pos=List[File_Pos].find(ToSearch);
+ if (BDMV_Pos!=string::npos && BDMV_Pos!=0 && BDMV_Pos+16==List[File_Pos].size())
+ {
+ //This is a BDMV index, parsing the directory only if index and movie objects are BOTH present
+ ToSearch=List[File_Pos];
+ ToSearch.resize(ToSearch.size()-10);
+ ToSearch+=_T("MovieObject.bdmv"); //"%CompletePath%\BDMV\MovieObject.bdmv"
+ if (List.Find(ToSearch)!=string::npos)
+ {
+ //We want the folder instead of the files
+ List[File_Pos].resize(List[File_Pos].size()-11); //only %CompletePath%\BDMV
+ ToSearch=List[File_Pos];
+
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ if (List[Pos].find(ToSearch)==0 && List[Pos]!=ToSearch) //Remove all subdirs of ToSearch but not ToSearch
+ {
+ //Removing the file in the blu-ray directory
+ List.erase(List.begin()+Pos);
+ Pos--;
+ }
+ }
+ }
+ }
+ }
+}
+#endif //MEDIAINFO_BDMV_YES
+
+//***************************************************************************
+// P2 stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_P2_YES
+int Reader_Directory::P2_Format_Test(MediaInfo_Internal* MI, const String &File_Name)
+{
+ if (!MI->SelectFromExtension(_T("P2_Clip")))
+ return 0;
+
+ MI->Open(File_Name+_T("CLIP")+PathSeparator+_T("0013MM.XML"));
+
+ return 1;
+}
+#endif //MEDIAINFO_P2_YES
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_P2_YES
+void Reader_Directory::P2_Directory_Cleanup(ZtringList &List)
+{
+ //if there is a CONTENTS/CLIP folder, this is P2
+ Ztring ToSearch=Ztring(1, PathSeparator)+_T("CONTENTS")+PathSeparator+_T("CLIP")+PathSeparator; //"/CONTENTS/CLIP/"
+ for (size_t File_Pos=0; File_Pos<List.size(); File_Pos++)
+ {
+ size_t P2_Pos=List[File_Pos].find(ToSearch);
+ if (P2_Pos!=string::npos && P2_Pos!=0 && P2_Pos+1+8+1+4+1+10==List[File_Pos].size())
+ {
+ //This is a P2 CLIP
+ Ztring Path_Begin=List[File_Pos];
+ Path_Begin.resize(Path_Begin.size()-(1+8+1+4+1+10));
+ Path_Begin+=Ztring(1, PathSeparator);
+ bool HasChanged=false;
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ if (List[Pos].find(Path_Begin)==0 && List[Pos].find(Path_Begin+_T("CONTENTS")+PathSeparator+_T("CLIP")+PathSeparator)==string::npos) //Remove all subdirs of Path_Begin but not with CLIP
+ {
+ //Removing the file in the P2 directory
+ List.erase(List.begin()+Pos);
+ Pos--;
+ HasChanged=true;
+ }
+ }
+ if (HasChanged)
+ File_Pos=0;
+ }
+ }
+}
+#endif //MEDIAINFO_P2_YES
+
+//***************************************************************************
+// P2 stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_XDCAM_YES
+int Reader_Directory::Xdcam_Format_Test(MediaInfo_Internal* MI, const String &File_Name)
+{
+ if (!MI->SelectFromExtension(_T("Xdcam_Clip")))
+ return 0;
+
+ MI->Open(File_Name+_T("CLIP")+PathSeparator+_T("0013MM.XML"));
+
+ return 1;
+}
+#endif //MEDIAINFO_XDCAM_YES
+
+//---------------------------------------------------------------------------
+#ifdef MEDIAINFO_XDCAM_YES
+void Reader_Directory::Xdcam_Directory_Cleanup(ZtringList &List)
+{
+ //if there is a XDCAM/Clip folder, this is Xdcam
+ Ztring ToSearch=Ztring(1, PathSeparator)+_T("Clip")+PathSeparator; //"/Clip/"
+ for (size_t File_Pos=0; File_Pos<List.size(); File_Pos++)
+ {
+ size_t Xdcam_Pos=List[File_Pos].find(ToSearch);
+ if (Xdcam_Pos!=string::npos && Xdcam_Pos!=0 && Xdcam_Pos+1+4+1+12==List[File_Pos].size())
+ {
+ //This is a XDCAM CLIP
+ Ztring Path_Begin=List[File_Pos];
+ Path_Begin.resize(Path_Begin.size()-(1+4+1+12));
+ Path_Begin+=Ztring(1, PathSeparator);
+ if (Dir::Exists(Path_Begin+_T("Edit")) && Dir::Exists(Path_Begin+_T("General")) && Dir::Exists(Path_Begin+_T("Sub")))
+ {
+ bool HasChanged=false;
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ if (List[Pos].find(Path_Begin)==0 && (List[Pos].find(Path_Begin+_T("Clip")+PathSeparator)==string::npos || (List[Pos].find(_T(".XML"))!=List[Pos].size()-4))) //Remove all subdirs of Path_Begin but not with the right XML
+ {
+ //Removing the file in the XDCAM directory
+ List.erase(List.begin()+Pos);
+ Pos--;
+ HasChanged=true;
+ }
+ }
+ if (HasChanged)
+ File_Pos=0;
+ }
+ }
+ }
+}
+#endif //MEDIAINFO_XDCAM_YES
+
+} //NameSpace
+
+#endif //MEDIAINFO_DIRECTORY_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_Directory.h b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_Directory.h
new file mode 100644
index 000000000..1a79ed19f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_Directory.h
@@ -0,0 +1,68 @@
+// Reader_Directory - All information about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Give information about a lot of media files
+// Dispatch the file to be tested by all containers
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef Reader_DirectoryH
+#define Reader_DirectoryH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Reader/Reader__Base.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+/// @brief Reader_Directory
+//***************************************************************************
+
+class Reader_Directory : public Reader__Base
+{
+public :
+ //Constructor/Destructor
+ virtual ~Reader_Directory() {}
+
+ //Format testing
+ size_t Format_Test(MediaInfo_Internal* MI, const String &File_Name);
+
+ //For the list
+ void Directory_Cleanup(ZtringList &List);
+
+private :
+ //Bdmv
+ int Bdmv_Format_Test(MediaInfo_Internal* MI, const String &File_Name);
+ void Bdmv_Directory_Cleanup(ZtringList &List);
+
+ //P2
+ int P2_Format_Test(MediaInfo_Internal* MI, const String &File_Name);
+ void P2_Directory_Cleanup(ZtringList &List);
+
+ //XDCAM
+ int Xdcam_Format_Test(MediaInfo_Internal* MI, const String &File_Name);
+ void Xdcam_Directory_Cleanup(ZtringList &List);
+};
+
+} //NameSpace
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_File.cpp b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_File.cpp
new file mode 100644
index 000000000..4801e69e6
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_File.cpp
@@ -0,0 +1,419 @@
+// MediaInfo_Internal - All info about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// For user: you can disable or enable it
+//#define MEDIAINFO_DEBUG
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Reader/Reader_File.h"
+#include "MediaInfo/File__Analyze.h"
+#include "ZenLib/FileName.h"
+#ifdef WINDOWS
+ #undef __TEXT
+ #include "Windows.h"
+#endif //WINDOWS
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+// Debug stuff
+#ifdef MEDIAINFO_DEBUG
+ int64u Reader_File_Offset=0;
+ int64u Reader_File_BytesRead_Total=0;
+ int64u Reader_File_BytesRead=0;
+ int64u Reader_File_Count=1;
+ #include <iostream>
+#endif // MEDIAINFO_DEBUG
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+const size_t Buffer_NoJump=128*1024;
+
+//---------------------------------------------------------------------------
+size_t Reader_File::Format_Test(MediaInfo_Internal* MI, const String &File_Name)
+{
+ //std::cout<<Ztring(File_Name).To_Local().c_str()<<std::endl;
+ #if MEDIAINFO_EVENTS
+ {
+ struct MediaInfo_Event_General_Start_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_Start, 0);
+ Event.Stream_Size=File::Size_Get(File_Name);
+ MI->Config.Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_General_Start_0));
+ }
+ #endif //MEDIAINFO_EVENTS
+
+ //With Parser MultipleParsing
+ /*
+ MI->Open_Buffer_Init((int64u)-1, File_Name);
+ if (Format_Test_PerParser(MI, File_Name))
+ return 1;
+ return 0; //There is a problem
+ */
+
+ //Get the Extension
+ Ztring Extension=FileName::Extension_Get(File_Name);
+ Extension.MakeLowerCase();
+
+ //Search the theorical format from extension
+ InfoMap &FormatList=MediaInfoLib::Config.Format_Get();
+ InfoMap::iterator Format=FormatList.end();
+ if (!MI->Config.File_ForceParser_Get().empty())
+ Format=FormatList.find(MI->Config.File_ForceParser_Get());
+ if (Format==FormatList.end())
+ {
+ Format=FormatList.begin();
+ while (Format!=FormatList.end())
+ {
+ const Ztring &Extensions=FormatList.Get(Format->first, InfoFormat_Extensions);
+ if (Extensions.find(Extension)!=Error)
+ {
+ if(Extension.size()==Extensions.size())
+ break; //Only one extenion in the list
+ if(Extensions.find(Extension+_T(" "))!=Error
+ || Extensions.find(_T(" ")+Extension)!=Error)
+ break;
+ }
+ Format++;
+ }
+ }
+ if (Format!=FormatList.end())
+ {
+ const Ztring &Parser=Format->second(InfoFormat_Parser);
+ if (MI->SelectFromExtension(Parser))
+ {
+ //Test the theorical format
+ if (Format_Test_PerParser(MI, File_Name)>0)
+ return 1;
+ }
+ }
+
+ size_t ToReturn=MI->ListFormats(File_Name);
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+size_t Reader_File::Format_Test_PerParser(MediaInfo_Internal* MI, const String &File_Name)
+{
+ //Opening the file
+ F.Open(File_Name);
+ if (!F.Opened_Get())
+ return 0;
+
+ //Info
+ Status=0;
+ MI->Config.File_Size=F.Size_Get();
+ MI->Config.File_Current_Offset=0;
+ MI->Config.File_Current_Size=MI->Config.File_Size;
+ MI->Config.File_Sizes.clear();
+ MI->Config.File_Sizes.push_back(MI->Config.File_Size);
+ if (MI->Config.File_Names.size()>1)
+ {
+ for (size_t Pos=1; Pos<MI->Config.File_Names.size(); Pos++)
+ {
+ int64u Size=File::Size_Get(MI->Config.File_Names[Pos]);
+ MI->Config.File_Sizes.push_back(Size);
+ MI->Config.File_Size+=Size;
+ }
+ }
+
+ //Partial file handling
+ Ztring Config_Partial_Begin=MI->Config.File_Partial_Begin_Get();
+ if (!Config_Partial_Begin.empty() && Config_Partial_Begin[0]>=_T('0') && Config_Partial_Begin[0]<=_T('9'))
+ {
+ if (Config_Partial_Begin.find(_T('%'))==Config_Partial_Begin.size()-1)
+ Partial_Begin=float64_int64s(MI->Config.File_Size*Config_Partial_Begin.To_float64()/100);
+ else
+ Partial_Begin=Config_Partial_Begin.To_int64u();
+ if (Partial_Begin)
+ F.GoTo(Partial_Begin);
+ }
+ else
+ Partial_Begin=0;
+ Ztring Config_Partial_End=MI->Config.File_Partial_End_Get();
+ if (!Config_Partial_End.empty() && Config_Partial_End[0]>=_T('0') && Config_Partial_End[0]<=_T('9'))
+ {
+ if (Config_Partial_End.find(_T('%'))==Config_Partial_End.size()-1)
+ Partial_End=float64_int64s(MI->Config.File_Size*Config_Partial_End.To_float64()/100);
+ else
+ Partial_End=Config_Partial_End.To_int64u();
+ }
+ else
+ Partial_End=(int64u)-1;
+ if (Partial_Begin>MI->Config.File_Size)
+ Partial_Begin=0; //Wrong value
+ if (Partial_Begin>Partial_End)
+ Partial_Begin=0; //Wrong value
+
+ //Parser
+ MI->Open_Buffer_Init((Partial_End<=MI->Config.File_Size?Partial_End:MI->Config.File_Size)-Partial_Begin, File_Name);
+
+ //Buffer
+ MI->Option(_T("File_Buffer_Size_Hint_Pointer"), Ztring::ToZtring((size_t)(&MI->Config.File_Buffer_Size_ToRead)));
+ MI->Config.File_Buffer_Repeat_IsSupported=true;
+
+ //Test the format with buffer
+ return Format_Test_PerParser_Continue(MI);
+}
+
+//---------------------------------------------------------------------------
+size_t Reader_File::Format_Test_PerParser_Continue (MediaInfo_Internal* MI)
+{
+ bool StopAfterFilled=MI->Config.File_StopAfterFilled_Get();
+ bool ShouldContinue=true;
+
+ //Previous data
+ if (MI->Config.File_Buffer_Repeat)
+ {
+ MI->Config.File_Buffer_Repeat=false;
+ #if MEDIAINFO_DEMUX
+ MI->Config.Demux_EventWasSent=false;
+ #endif //MEDIAINFO_DEMUX
+
+ Status=MI->Open_Buffer_Continue(MI->Config.File_Buffer, MI->Config.File_Buffer_Size);
+
+ #if MEDIAINFO_DEMUX
+ //Demux
+ if (MI->Config.Demux_EventWasSent)
+ return 2; //Must return immediately
+ #endif //MEDIAINFO_DEMUX
+
+ //Threading
+ if (MI->IsTerminating())
+ return 1; //Termination is requested
+
+ if (Status[File__Analyze::IsFinished] || (StopAfterFilled && Status[File__Analyze::IsFilled]))
+ ShouldContinue=false;
+ }
+
+ #if MEDIAINFO_DEMUX
+ //PerPacket
+ if (ShouldContinue && MI->Config.Demux_EventWasSent)
+ {
+ MI->Config.Demux_EventWasSent=false;
+
+ Status=MI->Open_Buffer_Continue(NULL, 0);
+
+ //Demux
+ if (MI->Config.Demux_EventWasSent)
+ return 2; //Must return immediately
+
+ //Threading
+ if (MI->IsTerminating())
+ return 1; //Termination is requested
+
+ if (Status[File__Analyze::IsFinished] || (StopAfterFilled && Status[File__Analyze::IsFilled]))
+ ShouldContinue=false;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ if (ShouldContinue)
+ {
+ //Test the format with buffer
+ while (!(Status[File__Analyze::IsFinished] || (StopAfterFilled && Status[File__Analyze::IsFilled])))
+ {
+ //Seek (if needed)
+ if (MI->Open_Buffer_Continue_GoTo_Get()!=(int64u)-1)
+ {
+ #ifdef MEDIAINFO_DEBUG
+ std::cout<<std::hex<<Reader_File_Offset<<" - "<<Reader_File_Offset+Reader_File_BytesRead<<" : "<<std::dec<<Reader_File_BytesRead<<" bytes"<<std::endl;
+ Reader_File_Offset=MI->Open_Buffer_Continue_GoTo_Get();
+ Reader_File_BytesRead=0;
+ Reader_File_Count++;
+ #endif //MEDIAINFO_DEBUG
+
+ int64u GoTo=Partial_Begin+MI->Open_Buffer_Continue_GoTo_Get();
+ MI->Config.File_Current_Offset=0;
+ int64u Buffer_NoJump_Temp=Buffer_NoJump;
+ if (MI->Config.File_Names.size()>1)
+ {
+ size_t Pos;
+ for (Pos=0; Pos<MI->Config.File_Sizes.size(); Pos++)
+ {
+ if (GoTo>=MI->Config.File_Sizes[Pos])
+ {
+ GoTo-=MI->Config.File_Sizes[Pos];
+ MI->Config.File_Current_Offset+=MI->Config.File_Sizes[Pos];
+ }
+ else
+ break;
+ }
+ if (Pos>=MI->Config.File_Sizes.size())
+ break;
+ if (Pos!=MI->Config.File_Names_Pos)
+ {
+ F.Close();
+ F.Open(MI->Config.File_Names[Pos]);
+ MI->Config.File_Names_Pos=Pos+1;
+ MI->Config.File_Current_Size=MI->Config.File_Current_Offset+F.Size_Get();
+ Buffer_NoJump_Temp=0;
+ }
+ }
+
+ if (GoTo>=F.Size_Get())
+ break; //Seek requested, but on a file bigger in theory than what is in the real file, we can't do this
+ if (!(GoTo>F.Position_Get() && GoTo<F.Position_Get()+Buffer_NoJump_Temp)) //No smal jumps
+ {
+ if (!F.GoTo(GoTo))
+ break; //File is not seekable
+
+ MI->Open_Buffer_Init((int64u)-1, MI->Config.File_Current_Offset+F.Position_Get()-Partial_Begin);
+ }
+ }
+
+ //Handling of hints
+ if (MI->Config.File_Buffer_Size_ToRead==0)
+ break; //Problem while config
+ if (MI->Config.File_Buffer_Size_ToRead>MI->Config.File_Buffer_Size_Max)
+ {
+ delete[] MI->Config.File_Buffer;
+ if (MI->Config.File_Buffer_Size_Max==0)
+ MI->Config.File_Buffer_Size_Max=1;
+ while (MI->Config.File_Buffer_Size_ToRead>MI->Config.File_Buffer_Size_Max)
+ MI->Config.File_Buffer_Size_Max*=2;
+ MI->Config.File_Buffer=new int8u[MI->Config.File_Buffer_Size_Max];
+ }
+
+ MI->Config.File_Buffer_Size=F.Read(MI->Config.File_Buffer, (F.Position_Get()+MI->Config.File_Buffer_Size_ToRead<(Partial_End<=MI->Config.File_Size?Partial_End:MI->Config.File_Size))?MI->Config.File_Buffer_Size_ToRead:((size_t)((Partial_End<=MI->Config.File_Size?Partial_End:MI->Config.File_Size)-F.Position_Get())));
+
+ //Testing growing files
+ if (!MI->Config.File_IsGrowing && F.Position_Get()>=MI->Config.File_Size)
+ {
+ if (MediaInfoLib::Config.ParseSpeed_Get()>=1.0) //Only if full parsing
+ {
+ int64u FileSize_New=F.Size_Get();
+ if (MI->Config.File_Size!=FileSize_New)
+ MI->Config.File_IsGrowing=true;
+ }
+ }
+ if (MI->Config.File_IsNotGrowingAnymore)
+ {
+ MI->Config.File_Current_Size=MI->Config.File_Size=F.Size_Get();;
+ MI->Open_Buffer_Init(MI->Config.File_Size, F.Position_Get()-MI->Config.File_Buffer_Size);
+ MI->Config.File_IsGrowing=false;
+ MI->Config.File_IsNotGrowingAnymore=false;
+ }
+ if (MI->Config.File_IsGrowing && F.Position_Get()>=MI->Config.File_Size)
+ {
+ for (size_t CountOfSeconds=0; CountOfSeconds<(size_t)MI->Config.File_GrowingFile_Delay_Get(); CountOfSeconds++)
+ {
+ int64u FileSize_New=F.Size_Get();
+ if (MI->Config.File_Size!=FileSize_New)
+ {
+ MI->Config.File_Current_Size=MI->Config.File_Size=FileSize_New;
+ MI->Open_Buffer_Init(MI->Config.File_Size, F.Position_Get()-MI->Config.File_Buffer_Size);
+ break;
+ }
+ #ifdef WINDOWS
+ Sleep(1000);
+ #endif //WINDOWS
+ }
+ }
+
+ #ifdef MEDIAINFO_DEBUG
+ Reader_File_BytesRead_Total+=MI->Config.File_Buffer_Size;
+ Reader_File_BytesRead+=MI->Config.File_Buffer_Size;
+ #endif //MEDIAINFO_DEBUG
+
+ //Parser
+ Status=MI->Open_Buffer_Continue(MI->Config.File_Buffer, MI->Config.File_Buffer_Size);
+
+ //Testing multiple file per stream
+ if (F.Position_Get()>=F.Size_Get())
+ {
+ if (MI->Config.File_Names_Pos<MI->Config.File_Names.size())
+ {
+ MI->Config.File_Current_Offset+=F.Size_Get();
+ F.Close();
+ F.Open(MI->Config.File_Names[MI->Config.File_Names_Pos]);
+ MI->Config.File_Names_Pos++;
+ MI->Config.File_Current_Size+=F.Size_Get();
+ }
+ }
+
+ if (MI->Config.File_Buffer_Size==0)
+ break;
+
+ #if MEDIAINFO_DEMUX
+ if (MI->Config.Demux_EventWasSent)
+ return 2; //Must return immediately
+ #endif //MEDIAINFO_DEMUX
+
+ //Threading
+ if (MI->IsTerminating())
+ break; //Termination is requested
+ }
+ }
+
+ #ifdef MEDIAINFO_DEBUG
+ std::cout<<std::hex<<Reader_File_Offset<<" - "<<Reader_File_Offset+Reader_File_BytesRead<<" : "<<std::dec<<Reader_File_BytesRead<<" bytes"<<std::endl;
+ std::cout<<"Total: "<<std::dec<<Reader_File_BytesRead_Total<<" bytes in "<<Reader_File_Count<<" blocks"<<std::endl;
+ #endif //MEDIAINFO_DEBUG
+
+ if (MI==NULL || !MI->Config.File_KeepInfo_Get())
+ {
+ //File
+ F.Close();
+ }
+
+ //Is this file detected?
+ if (!Status[File__Analyze::IsAccepted])
+ return 0;
+
+ MI->Open_Buffer_Finalize();
+
+ #if MEDIAINFO_DEMUX
+ if (MI->Config.Demux_EventWasSent)
+ return 2; //Must return immediately
+ #endif //MEDIAINFO_DEMUX
+
+ return 1;
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t Reader_File::Format_Test_PerParser_Seek (MediaInfo_Internal* MI, size_t Method, int64u Value, int64u ID)
+{
+ size_t ToReturn=MI->Open_Buffer_Seek(Method, Value, ID);
+
+ if (ToReturn==0 || ToReturn==1)
+ {
+ //Reset
+ Status=0;
+ }
+
+ return ToReturn;
+}
+#endif //MEDIAINFO_SEEK
+
+} //NameSpace
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_File.h b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_File.h
new file mode 100644
index 000000000..900addb72
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_File.h
@@ -0,0 +1,62 @@
+// Reader_File - All information about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Give information about a lot of media files
+// Dispatch the file to be tested by all containers
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef Reader_FileH
+#define Reader_FileH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Reader/Reader__Base.h"
+#include "ZenLib/File.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+/// @brief Reader_File
+//***************************************************************************
+
+class Reader_File : public Reader__Base
+{
+public :
+ //Constructor/Destructor
+ virtual ~Reader_File() {}
+
+ //Format testing
+ size_t Format_Test(MediaInfo_Internal* MI, const String &File_Name);
+ size_t Format_Test_PerParser(MediaInfo_Internal* MI, const String &File_Name);
+ size_t Format_Test_PerParser_Continue (MediaInfo_Internal* MI);
+ size_t Format_Test_PerParser_Seek (MediaInfo_Internal* MI, size_t Method, int64u Value, int64u ID);
+
+ ZenLib::File F;
+ std::bitset<32> Status;
+ int64u Partial_Begin;
+ int64u Partial_End;
+};
+
+} //NameSpace
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader__Base.h b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader__Base.h
new file mode 100644
index 000000000..5015e6317
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader__Base.h
@@ -0,0 +1,56 @@
+// Reader_File - All information about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Give information about a lot of media files
+// Dispatch the file to be tested by all containers
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef Reader__BaseH
+#define Reader__BaseH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/MediaInfo_Internal.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+/// @brief Reader__Base
+//***************************************************************************
+
+class Reader__Base
+{
+public :
+ //Constructor/Destructor
+ virtual ~Reader__Base() {}
+
+ //Format testing
+ virtual size_t Format_Test(MediaInfo_Internal* MI, const String &File_Name)=0;
+ virtual size_t Format_Test_PerParser_Continue (MediaInfo_Internal* /*MI*/) {return 0;};
+ #if MEDIAINFO_SEEK
+ virtual size_t Format_Test_PerParser_Seek (MediaInfo_Internal*, size_t, int64u, int64u) {return 0;};
+ #endif //MEDIAINFO_SEEK
+};
+
+} //NameSpace
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl.cpp b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl.cpp
new file mode 100644
index 000000000..c4913d6ec
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl.cpp
@@ -0,0 +1,814 @@
+// Reader_libcurl - All info about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// For user: you can disable or enable it
+//#define MEDIAINFO_DEBUG
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_LIBCURL_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Reader/Reader_libcurl.h"
+#include "MediaInfo/File__Analyze.h"
+#if defined MEDIAINFO_LIBCURL_DLL_RUNTIME
+ //Copy of cURL include files
+ #include "MediaInfo/Reader/Reader_libcurl_Include.h"
+#else
+ #define CURL_STATICLIB
+ #undef __TEXT
+ #include "curl/curl.h"
+#endif
+#include <ctime>
+#include "ZenLib/File.h"
+using namespace ZenLib;
+using namespace std;
+#ifdef MEDIAINFO_DEBUG
+ #include <iostream>
+#endif // MEDIAINFO_DEBUG
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// libcurl stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+struct Reader_libcurl::curl_data
+{
+ MediaInfo_Internal* MI;
+ CURL* Curl;
+ char ErrorBuffer[CURL_ERROR_SIZE];
+ #if MEDIAINFO_NEXTPACKET
+ CURLM* CurlM;
+ #endif MEDIAINFO_NEXTPACKET
+ struct curl_slist* HttpHeader;
+ std::bitset<32> Status;
+ String File_Name;
+ std::string Ssl_CertificateFileName;
+ std::string Ssl_CertificateFormat;
+ std::string Ssl_PrivateKeyFileName;
+ std::string Ssl_PrivateKeyFormat;
+ std::string Ssl_CertificateAuthorityFileName;
+ std::string Ssl_CertificateAuthorityPath;
+ std::string Ssl_CertificateRevocationListFileName;
+ bool Ssl_IgnoreSecurity;
+ std::string Ssh_KnownHostsFileName;
+ std::string Ssh_PublicKeyFileName;
+ std::string Ssh_PrivateKeyFileName;
+ bool Ssh_IgnoreSecurity;
+ bool Init_AlreadyDone;
+ #if MEDIAINFO_NEXTPACKET
+ bool NextPacket;
+ #endif MEDIAINFO_NEXTPACKET
+ time_t Time_Max;
+ #ifdef MEDIAINFO_DEBUG
+ int64u Debug_BytesRead_Total;
+ int64u Debug_BytesRead;
+ int64u Debug_Count;
+ #endif // MEDIAINFO_DEBUG
+
+ curl_data()
+ {
+ MI=NULL;
+ Curl=NULL;
+ ErrorBuffer[0]='\0';
+ #if MEDIAINFO_NEXTPACKET
+ CurlM=NULL;
+ #endif MEDIAINFO_NEXTPACKET
+ HttpHeader=NULL;
+ Ssl_IgnoreSecurity=false;
+ Ssh_IgnoreSecurity=false;
+ Init_AlreadyDone=false;
+ #if MEDIAINFO_NEXTPACKET
+ NextPacket=false;
+ #endif MEDIAINFO_NEXTPACKET
+ Time_Max=0;
+ #ifdef MEDIAINFO_DEBUG
+ Debug_BytesRead_Total=0;
+ Debug_BytesRead=0;
+ Debug_Count=1;
+ #endif // MEDIAINFO_DEBUG
+ }
+};
+
+//---------------------------------------------------------------------------
+size_t libcurl_WriteData_CallBack(void *ptr, size_t size, size_t nmemb, void *data)
+{
+ #ifdef MEDIAINFO_DEBUG
+ ((Reader_libcurl::curl_data*)data)->Debug_BytesRead_Total+=size*nmemb;
+ ((Reader_libcurl::curl_data*)data)->Debug_BytesRead+=size*nmemb;
+ #endif //MEDIAINFO_DEBUG
+
+ //Init
+ if (!((Reader_libcurl::curl_data*)data)->Init_AlreadyDone)
+ {
+ double File_SizeD;
+ CURLcode Result=curl_easy_getinfo(((Reader_libcurl::curl_data*)data)->Curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &File_SizeD);
+ if (Result==CURLE_OK && File_SizeD!=-1)
+ {
+ ((Reader_libcurl::curl_data*)data)->MI->Open_Buffer_Init((int64u)File_SizeD, ((Reader_libcurl::curl_data*)data)->File_Name);
+ }
+ else
+ ((Reader_libcurl::curl_data*)data)->MI->Open_Buffer_Init((int64u)-1, ((Reader_libcurl::curl_data*)data)->File_Name);
+ ((Reader_libcurl::curl_data*)data)->Init_AlreadyDone=true;
+ }
+
+ //Continue
+ ((Reader_libcurl::curl_data*)data)->Status=((Reader_libcurl::curl_data*)data)->MI->Open_Buffer_Continue((int8u*)ptr, size*nmemb);
+ time_t CurrentTime = time(0);
+
+ if (((Reader_libcurl::curl_data*)data)->Status[File__Analyze::IsFinished] || (((Reader_libcurl::curl_data*)data)->Time_Max && CurrentTime>=((Reader_libcurl::curl_data*)data)->Time_Max))
+ {
+ return 0;
+ }
+
+ //GoTo
+ if (((Reader_libcurl::curl_data*)data)->MI->Open_Buffer_Continue_GoTo_Get()!=(int64u)-1)
+ {
+ return 0;
+ }
+
+ //Continue parsing
+ return size*nmemb;
+}
+
+Ztring Reader_libcurl_FileNameWithoutPassword(const Ztring &FileName)
+{
+ Ztring FileName_Modified(FileName);
+ size_t Begin=FileName_Modified.find(_T(':'), 6);
+ size_t End=FileName_Modified.find(_T('@'));
+ if (Begin!=string::npos && End!=string::npos && Begin<End)
+ FileName_Modified.erase(Begin, End-Begin);
+ return FileName_Modified;
+}
+
+bool Reader_libcurl_HomeIsSet()
+{
+ return getenv("HOME")?true:false;
+}
+
+Ztring Reader_libcurl_ExpandFileName(const Ztring &FileName)
+{
+ Ztring FileName_Modified(FileName);
+ if (FileName_Modified.find(_T("$HOME"))==0)
+ {
+ char* env=getenv("HOME");
+ if (env)
+ FileName_Modified.FindAndReplace(_T("$HOME"), Ztring().From_Local(env));
+ }
+ if (FileName_Modified.find(_T("~"))==0)
+ {
+ char* env=getenv("HOME");
+ if (env)
+ FileName_Modified.FindAndReplace(_T("~"), Ztring().From_Local(env));
+ }
+ return FileName_Modified;
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Reader_libcurl::Reader_libcurl ()
+{
+ Curl_Data=NULL;
+}
+
+//---------------------------------------------------------------------------
+Reader_libcurl::~Reader_libcurl ()
+{
+ if (Curl_Data==NULL)
+ return;
+
+ //Cleanup
+ #if MEDIAINFO_NEXTPACKET
+ if (Curl_Data->CurlM)
+ {
+ curl_multi_remove_handle(Curl_Data->CurlM, Curl_Data->Curl);
+ curl_multi_cleanup(Curl_Data->CurlM);
+ }
+ #endif //MEDIAINFO_NEXTPACKET
+ if (Curl_Data->Curl)
+ curl_easy_cleanup(Curl_Data->Curl);
+ if (Curl_Data->HttpHeader)
+ curl_slist_free_all(Curl_Data->HttpHeader);
+ delete Curl_Data; //Curl_Data=NULL;
+}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t Reader_libcurl::Format_Test(MediaInfo_Internal* MI, const String &File_Name)
+{
+ #if defined MEDIAINFO_LIBCURL_DLL_RUNTIME
+ if (libcurl_Module_Count==0)
+ {
+ size_t Errors=0;
+
+ /* Load library */
+ #ifdef MEDIAINFO_GLIBC
+ libcurl_Module=g_module_open(MEDIAINFODLL_NAME, G_MODULE_BIND_LAZY);
+ #elif defined (_WIN32) || defined (WIN32)
+ libcurl_Module=LoadLibrary(_T(MEDIAINFODLL_NAME));
+ #else
+ libcurl_Module=dlopen(MEDIAINFODLL_NAME, RTLD_LAZY);
+ if (!libcurl_Module)
+ libcurl_Module=dlopen("./" MEDIAINFODLL_NAME, RTLD_LAZY);
+ if (!libcurl_Module)
+ libcurl_Module=dlopen("/usr/local/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
+ if (!libcurl_Module)
+ libcurl_Module=dlopen("/usr/local/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
+ if (!libcurl_Module)
+ libcurl_Module=dlopen("/usr/lib/" MEDIAINFODLL_NAME, RTLD_LAZY);
+ if (!libcurl_Module)
+ libcurl_Module=dlopen("/usr/lib64/" MEDIAINFODLL_NAME, RTLD_LAZY);
+ #endif
+ if (!libcurl_Module)
+ {
+ #if MEDIAINFO_EVENTS
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", Libcurl library is not found"));
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+
+ /* Load methods */
+ MEDIAINFO_ASSIGN (curl_easy_init, "curl_easy_init")
+ MEDIAINFO_ASSIGN (curl_easy_setopt, "curl_easy_setopt")
+ MEDIAINFO_ASSIGN (curl_easy_perform, "curl_easy_perform")
+ MEDIAINFO_ASSIGN (curl_easy_cleanup, "curl_easy_cleanup")
+ MEDIAINFO_ASSIGN (curl_easy_getinfo, "curl_easy_getinfo")
+ MEDIAINFO_ASSIGN (curl_slist_append, "curl_slist_append")
+ MEDIAINFO_ASSIGN (curl_slist_free_all, "curl_slist_free_all")
+ MEDIAINFO_ASSIGN (curl_easy_duphandle, "curl_easy_duphandle")
+ MEDIAINFO_ASSIGN (curl_easy_strerror, "curl_easy_strerror")
+ MEDIAINFO_ASSIGN (curl_version_info, "curl_version_info")
+ MEDIAINFO_ASSIGN (curl_multi_init, "curl_multi_init")
+ MEDIAINFO_ASSIGN (curl_multi_add_handle, "curl_multi_add_handle")
+ MEDIAINFO_ASSIGN (curl_multi_remove_handle, "curl_multi_remove_handle")
+ MEDIAINFO_ASSIGN (curl_multi_perform, "curl_multi_perform")
+ MEDIAINFO_ASSIGN (curl_multi_cleanup, "curl_multi_cleanup")
+ if (Errors>0)
+ {
+ #if MEDIAINFO_EVENTS
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", Libcurl library is not correctly loaded"));
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+
+ libcurl_Module_Count++;
+ }
+ #endif //defined MEDIAINFO_LIBCURL_DLL_RUNTIME
+
+ #if MEDIAINFO_EVENTS
+ {
+ struct MediaInfo_Event_General_Start_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_Start, 0);
+ Event.Stream_Size=(int64u)-1;
+ MI->Config.Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_General_Start_0));
+ }
+ #endif //MEDIAINFO_EVENTS
+
+ //With Parser MultipleParsing
+ return Format_Test_PerParser(MI, File_Name);
+}
+
+//---------------------------------------------------------------------------
+size_t Reader_libcurl::Format_Test_PerParser(MediaInfo_Internal* MI, const String &File_Name)
+{
+ #if defined MEDIAINFO_LIBCURL_DLL_RUNTIME
+ if (libcurl_Module_Count==0)
+ return 0; //No libcurl library
+ #endif //defined MEDIAINFO_LIBCURL_DLL_RUNTIME
+
+ Curl_Data=new curl_data();
+ Curl_Data->Ssl_CertificateFileName=MediaInfoLib::Config.Ssl_CertificateFileName_Get().To_Local();
+ Curl_Data->Ssl_CertificateFormat=MediaInfoLib::Config.Ssl_CertificateFormat_Get().To_Local();
+ Curl_Data->Ssl_PrivateKeyFileName=MediaInfoLib::Config.Ssl_PrivateKeyFileName_Get().To_Local();
+ Curl_Data->Ssl_PrivateKeyFormat=MediaInfoLib::Config.Ssl_PrivateKeyFormat_Get().To_Local();
+ Curl_Data->Ssl_CertificateAuthorityFileName=MediaInfoLib::Config.Ssl_CertificateAuthorityFileName_Get().To_Local();
+ Curl_Data->Ssl_CertificateAuthorityPath=MediaInfoLib::Config.Ssl_CertificateAuthorityPath_Get().To_Local();
+ Curl_Data->Ssl_CertificateRevocationListFileName=MediaInfoLib::Config.Ssl_CertificateRevocationListFileName_Get().To_Local();
+ Curl_Data->Ssl_IgnoreSecurity=MediaInfoLib::Config.Ssl_IgnoreSecurity_Get();
+ Curl_Data->Ssh_PublicKeyFileName=Reader_libcurl_ExpandFileName(MediaInfoLib::Config.Ssh_PublicKeyFileName_Get()).To_Local();
+ if (Curl_Data->Ssh_PublicKeyFileName.empty())
+ {
+ if (Reader_libcurl_HomeIsSet())
+ {
+ Ztring Temp=Reader_libcurl_ExpandFileName(_T("$HOME/.ssh/id_rsa.pub"));
+ if (File::Exists(Temp))
+ Curl_Data->Ssh_PublicKeyFileName=Temp.To_Local();
+ }
+ else
+ {
+ if (File::Exists(_T("id_rsa.pub")))
+ Curl_Data->Ssh_PublicKeyFileName="id_rsa.pub";
+ }
+ }
+ Curl_Data->Ssh_PrivateKeyFileName=Reader_libcurl_ExpandFileName(MediaInfoLib::Config.Ssh_PrivateKeyFileName_Get()).To_Local();
+ if (Curl_Data->Ssh_PrivateKeyFileName.empty())
+ {
+ if (Reader_libcurl_HomeIsSet())
+ {
+ Ztring Temp=Reader_libcurl_ExpandFileName(_T("$HOME/.ssh/id_rsa"));
+ if (File::Exists(Temp))
+ Curl_Data->Ssh_PrivateKeyFileName=Temp.To_Local();
+ }
+ else
+ {
+ if (File::Exists(_T("id_rsa")))
+ Curl_Data->Ssh_PublicKeyFileName="id_rsa";
+ }
+ }
+ Curl_Data->Ssh_KnownHostsFileName=Reader_libcurl_ExpandFileName(MediaInfoLib::Config.Ssh_KnownHostsFileName_Get()).To_Local(); if (Curl_Data->Ssh_KnownHostsFileName.empty())
+ {
+ if (Reader_libcurl_HomeIsSet())
+ Curl_Data->Ssh_KnownHostsFileName=Reader_libcurl_ExpandFileName(_T("$HOME/.ssh/known_hosts")).To_Local();
+ else
+ Curl_Data->Ssh_KnownHostsFileName="known_hosts";
+ }
+ Curl_Data->Ssh_IgnoreSecurity=MediaInfoLib::Config.Ssh_IgnoreSecurity_Get();
+ Curl_Data->Curl=curl_easy_init();
+ if (Curl_Data->Curl==NULL)
+ return 0;
+ #if MEDIAINFO_NEXTPACKET
+ if (MI->Config.NextPacket_Get())
+ {
+ Curl_Data->CurlM=curl_multi_init( );
+ if (Curl_Data->CurlM==NULL)
+ return 0;
+ CURLMcode CodeM=curl_multi_add_handle(Curl_Data->CurlM, Curl_Data->Curl);
+ if (CodeM!=CURLM_OK)
+ return 0;
+ Curl_Data->NextPacket=true;
+ }
+ #endif //MEDIAINFO_NEXTPACKET
+ Curl_Data->MI=MI;
+ Curl_Data->File_Name=File_Name;
+ string FileName_String=Ztring(Curl_Data->File_Name).To_Local();
+ if (MI->Config.File_TimeToLive_Get())
+ Curl_Data->Time_Max=time(0)+(time_t)MI->Config.File_TimeToLive_Get();
+ if (!MI->Config.File_Curl_Get(_T("UserAgent")).empty())
+ curl_easy_setopt(Curl_Data->Curl, CURLOPT_USERAGENT, MI->Config.File_Curl_Get(_T("UserAgent")).To_Local().c_str());
+ if (!MI->Config.File_Curl_Get(_T("Proxy")).empty())
+ curl_easy_setopt(Curl_Data->Curl, CURLOPT_PROXY, MI->Config.File_Curl_Get(_T("Proxy")).To_Local().c_str());
+ if (!MI->Config.File_Curl_Get(_T("HttpHeader")).empty())
+ {
+ ZtringList HttpHeaderStrings; HttpHeaderStrings.Separator_Set(0, EOL); //End of line is set depending of the platform: \n on Linux, \r on Mac, or \r\n on Windows
+ HttpHeaderStrings.Write(MI->Config.File_Curl_Get(_T("HttpHeader")));
+ for (size_t Pos=0; Pos<HttpHeaderStrings.size(); Pos++)
+ curl_slist_append(Curl_Data->HttpHeader, HttpHeaderStrings[Pos].To_Local().c_str());
+ curl_easy_setopt(Curl_Data->Curl, CURLOPT_HTTPHEADER, Curl_Data->HttpHeader);
+ }
+ curl_easy_setopt(Curl_Data->Curl, CURLOPT_URL, FileName_String.c_str());
+ curl_easy_setopt(Curl_Data->Curl, CURLOPT_FOLLOWLOCATION, 1);
+ curl_easy_setopt(Curl_Data->Curl, CURLOPT_MAXREDIRS, 3);
+ curl_easy_setopt(Curl_Data->Curl, CURLOPT_WRITEFUNCTION, &libcurl_WriteData_CallBack);
+ curl_easy_setopt(Curl_Data->Curl, CURLOPT_WRITEDATA, Curl_Data);
+ curl_easy_setopt(Curl_Data->Curl, CURLOPT_ERRORBUFFER, Curl_Data->ErrorBuffer);
+ size_t Protocol_Limit=File_Name.find(_T(":"));
+ if (Protocol_Limit!=string::npos)
+ {
+ Ztring Protocol=File_Name;
+ Protocol.resize(Protocol_Limit);
+ Protocol.MakeLowerCase();
+
+ if (Protocol==_T("sftp") || Protocol==_T("scp"))
+ {
+ if (!Curl_Data->Ssh_PublicKeyFileName.empty())
+ {
+ CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_SSH_PUBLIC_KEYFILE, Curl_Data->Ssh_PublicKeyFileName.c_str());
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ if (Result==CURLE_UNKNOWN_TELNET_OPTION)
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0xF1010101, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", The Curl library you use has no support for secure connections."));
+ else
+ {
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ }
+ Curl_Data->ErrorBuffer[0]='\0';
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+ }
+
+ if (!Curl_Data->Ssh_PrivateKeyFileName.empty())
+ {
+ CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_SSH_PRIVATE_KEYFILE, Curl_Data->Ssh_PrivateKeyFileName.c_str());
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ if (Result==CURLE_UNKNOWN_TELNET_OPTION)
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0xF1010101, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", The Curl library you use has no support for secure connections."));
+ else
+ {
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ }
+ Curl_Data->ErrorBuffer[0]='\0';
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+ }
+
+ if (!Curl_Data->Ssh_IgnoreSecurity)
+ {
+ CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_SSH_KNOWNHOSTS, Curl_Data->Ssh_KnownHostsFileName.c_str());
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ if (Result==CURLE_UNKNOWN_TELNET_OPTION)
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0xF1010102, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", The Curl library you use has no support for known_host security file, transfer would not be secure."));
+ else
+ {
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ }
+ Curl_Data->ErrorBuffer[0]='\0';
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+ }
+ }
+
+ if (Protocol==_T("ftps"))
+ {
+ if (!Curl_Data->Ssl_CertificateFileName.empty())
+ {
+ CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_SSLCERT, Curl_Data->Ssl_CertificateFileName.c_str());
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ Curl_Data->ErrorBuffer[0]='\0';
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+ }
+
+ if (!Curl_Data->Ssl_CertificateFormat.empty())
+ {
+ CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_SSLCERTTYPE, Curl_Data->Ssl_CertificateFormat.c_str());
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ Curl_Data->ErrorBuffer[0]='\0';
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+ }
+
+ if (!Curl_Data->Ssl_PrivateKeyFileName.empty())
+ {
+ CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_SSLKEY, Curl_Data->Ssl_PrivateKeyFileName.c_str());
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ Curl_Data->ErrorBuffer[0]='\0';
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+ }
+
+ if (!Curl_Data->Ssl_PrivateKeyFormat.empty())
+ {
+ CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_SSLKEYTYPE, Curl_Data->Ssl_PrivateKeyFormat.c_str());
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ Curl_Data->ErrorBuffer[0]='\0';
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+ }
+
+ if (!Curl_Data->Ssl_CertificateAuthorityFileName.empty())
+ {
+ CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_CAINFO, Curl_Data->Ssl_CertificateAuthorityFileName.c_str());
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ Curl_Data->ErrorBuffer[0]='\0';
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+ }
+
+ if (!Curl_Data->Ssl_CertificateAuthorityPath.empty())
+ {
+ CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_CAPATH, Curl_Data->Ssl_CertificateAuthorityPath.c_str());
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ Curl_Data->ErrorBuffer[0]='\0';
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+ }
+
+ if (!Curl_Data->Ssl_CertificateRevocationListFileName.empty())
+ {
+ CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_CRLFILE, Curl_Data->Ssl_CertificateRevocationListFileName.c_str());
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ Curl_Data->ErrorBuffer[0]='\0';
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+ }
+
+ if (Curl_Data->Ssl_IgnoreSecurity)
+ {
+ CURLcode Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_SSL_VERIFYPEER, 0);
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ Curl_Data->ErrorBuffer[0]='\0';
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+
+ Result=curl_easy_setopt(Curl_Data->Curl, CURLOPT_SSL_VERIFYHOST, 0);
+ if (Result)
+ {
+ #if MEDIAINFO_EVENTS
+ Ztring MessageString;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ Curl_Data->ErrorBuffer[0]='\0';
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, 0, Reader_libcurl_FileNameWithoutPassword(File_Name)+_T(", ")+MessageString);
+ #endif //MEDIAINFO_EVENTS
+ return 0;
+ }
+ }
+ }
+ }
+
+ //Test the format with buffer
+ return Format_Test_PerParser_Continue(MI);
+}
+
+//---------------------------------------------------------------------------
+size_t Reader_libcurl::Format_Test_PerParser_Continue (MediaInfo_Internal* MI)
+{
+ bool StopAfterFilled=MI->Config.File_StopAfterFilled_Get();
+ bool ShouldContinue=true;
+
+ #if MEDIAINFO_DEMUX
+ //PerPacket
+ if (ShouldContinue && MI->Config.Demux_EventWasSent)
+ {
+ MI->Config.Demux_EventWasSent=false;
+
+ Curl_Data->Status=MI->Open_Buffer_Continue(NULL, 0);
+
+ //Demux
+ if (MI->Config.Demux_EventWasSent)
+ return 2; //Must return immediately
+
+ //Threading
+ if (MI->IsTerminating())
+ return 1; //Termination is requested
+
+ if (Curl_Data->Status[File__Analyze::IsFinished] || (StopAfterFilled && Curl_Data->Status[File__Analyze::IsFilled]))
+ ShouldContinue=false;
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ if (ShouldContinue)
+ {
+ CURLcode Result=CURLE_WRITE_ERROR;
+ while ((!(Curl_Data->Status[File__Analyze::IsFinished] || (StopAfterFilled && Curl_Data->Status[File__Analyze::IsFilled]))) && Result==CURLE_WRITE_ERROR)
+ {
+ //GoTo
+ if (Curl_Data->MI->Open_Buffer_Continue_GoTo_Get()!=(int64u)-1)
+ {
+ #ifdef MEDIAINFO_DEBUG
+ std::cout<<std::hex<<Curl_Data->File_Offset-Curl_Data->Debug_BytesRead<<" - "<<Curl_Data->File_Offset<<" : "<<std::dec<<Curl_Data->Debug_BytesRead<<" bytes"<<std::endl;
+ Curl_Data->Debug_BytesRead=0;
+ Curl_Data->Debug_Count++;
+ #endif //MEDIAINFO_DEBUG
+ CURLcode Code;
+ CURL* Temp=curl_easy_duphandle(Curl_Data->Curl);
+ if (Temp==0)
+ return 0;
+ #if MEDIAINFO_NEXTPACKET
+ if (Curl_Data->CurlM)
+ curl_multi_remove_handle(Curl_Data->CurlM, Curl_Data->Curl);
+ #endif //MEDIAINFO_NEXTPACKET
+ curl_easy_cleanup(Curl_Data->Curl); Curl_Data->Curl=Temp;
+ #if MEDIAINFO_NEXTPACKET
+ if (Curl_Data->CurlM)
+ curl_multi_add_handle(Curl_Data->CurlM, Curl_Data->Curl);
+ #endif //MEDIAINFO_NEXTPACKET
+ if (Curl_Data->MI->Open_Buffer_Continue_GoTo_Get()<0x80000000)
+ {
+ //We do NOT use large version if we can, because some version (tested: 7.15 linux) do NOT like large version (error code 18)
+ long File_GoTo_Long=(long)Curl_Data->MI->Open_Buffer_Continue_GoTo_Get();
+ Code=curl_easy_setopt(Curl_Data->Curl, CURLOPT_RESUME_FROM, File_GoTo_Long);
+ }
+ else
+ {
+ curl_off_t File_GoTo_Off=(curl_off_t)Curl_Data->MI->Open_Buffer_Continue_GoTo_Get();
+ Code=curl_easy_setopt(Curl_Data->Curl, CURLOPT_RESUME_FROM_LARGE, File_GoTo_Off);
+ }
+ if (Code==CURLE_OK)
+ MI->Open_Buffer_Init((int64u)-1, Curl_Data->MI->Open_Buffer_Continue_GoTo_Get());
+ }
+
+ //Parsing
+ #if MEDIAINFO_NEXTPACKET
+ if (Curl_Data->NextPacket)
+ {
+ int running_handles=0;
+ do
+ {
+ CURLMcode CodeM=curl_multi_perform(Curl_Data->CurlM, &running_handles);
+ if (CodeM!=CURLM_OK && CodeM!=CURLM_CALL_MULTI_PERFORM)
+ break; //There is a problem
+ #if MEDIAINFO_DEMUX
+ if (MI->Config.Demux_EventWasSent)
+ return 2; //Must return immediately
+ #endif //MEDIAINFO_DEMUX
+ if (running_handles==0)
+ break; //cUrl has finished
+ }
+ while (running_handles);
+ if (running_handles==0 && Curl_Data->MI->Open_Buffer_Continue_GoTo_Get()==(int64u)-1)
+ break; //cUrl has finished
+ Result=CURLE_WRITE_ERROR; //Configuring as if classic method is used
+ }
+ else
+ #endif //MEDIAINFO_NEXTPACKET
+ Result=curl_easy_perform(Curl_Data->Curl);
+
+ if (Result!=CURLE_OK && Result!=CURLE_WRITE_ERROR)
+ {
+ #if MEDIAINFO_EVENTS
+ Ztring MessageString;
+ int32u MessageCode=0;
+ MessageString.From_Local(Curl_Data->ErrorBuffer);
+ if (MessageString.empty())
+ MessageString.From_Local(curl_easy_strerror(Result));
+ if (Result==CURLE_PEER_FAILED_VERIFICATION)
+ {
+ size_t Protocol_Limit=Curl_Data->File_Name.find(_T(":"));
+ if (Protocol_Limit!=string::npos)
+ {
+ Ztring Protocol=Curl_Data->File_Name;
+ Protocol.resize(Protocol_Limit);
+ Protocol.MakeLowerCase();
+ if (Protocol==_T("sftp") || Protocol==_T("scp"))
+ {
+ MessageString=_T("The remote server's SSH fingerprint was deemed not OK (not in your known_host file).");
+ MessageCode=0xF1010103;
+ }
+ else if (Protocol==_T("https") || Protocol==_T("ftps"))
+ {
+ MessageString=_T("The remote server's SSL certificate was deemed not OK.");
+ MessageCode=0xF1010104;
+ }
+ }
+ }
+ Curl_Data->ErrorBuffer[0]='\0';
+ MediaInfoLib::Config.Log_Send(0xC0, 0xFF, MessageCode, Reader_libcurl_FileNameWithoutPassword(Curl_Data->File_Name)+_T(", ")+MessageString);
+ #endif //MEDIAINFO_EVENTS
+ }
+
+ #if MEDIAINFO_DEMUX
+ if (MI->Config.Demux_EventWasSent)
+ return 2; //Must return immediately
+ #endif //MEDIAINFO_DEMUX
+
+ //Threading
+ if (MI->IsTerminating())
+ break; //Termination is requested
+ }
+ }
+
+ #ifdef MEDIAINFO_DEBUG
+ std::cout<<std::hex<<Curl_Data->File_Offset-Curl_Data->Debug_BytesRead<<" - "<<Curl_Data->File_Offset<<" : "<<std::dec<<Curl_Data->Debug_BytesRead<<" bytes"<<std::endl;
+ std::cout<<"Total: "<<std::dec<<Curl_Data->Debug_BytesRead_Total<<" bytes in "<<Curl_Data->Debug_Count<<" blocks"<<std::endl;
+ #endif //MEDIAINFO_DEBUG
+
+ //Is this file detected?
+ if (!Curl_Data->Status[File__Analyze::IsAccepted])
+ return 0;
+
+ MI->Open_Buffer_Finalize();
+
+ #if MEDIAINFO_DEMUX
+ if (MI->Config.Demux_EventWasSent)
+ return 2; //Must return immediately
+ #endif //MEDIAINFO_DEMUX
+
+ return 1;
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_SEEK
+size_t Reader_libcurl::Format_Test_PerParser_Seek (MediaInfo_Internal* MI, size_t Method, int64u Value, int64u ID)
+{
+ size_t ToReturn=MI->Open_Buffer_Seek(Method, Value, ID);
+
+ if (ToReturn==0 || ToReturn==1)
+ {
+ //Reset
+ Curl_Data->Status=0;
+ }
+
+ return ToReturn;
+}
+#endif //MEDIAINFO_SEEK
+
+} //NameSpace
+
+#endif //MEDIAINFO_LIBCURL_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl.h b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl.h
new file mode 100644
index 000000000..72e17a9e8
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl.h
@@ -0,0 +1,63 @@
+// Reader_libcurl - All information about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Give information about a lot of media files
+// Dispatch the file to be tested by all containers
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef Reader_libcurlH
+#define Reader_libcurlH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Reader/Reader__Base.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+/// @brief Reader_libcurl
+//***************************************************************************
+
+class Reader_libcurl : public Reader__Base
+{
+public :
+ //Constructor/Destructor
+ Reader_libcurl ();
+ virtual ~Reader_libcurl();
+
+ //Format testing
+ size_t Format_Test(MediaInfo_Internal* MI, const String &File_Name);
+ size_t Format_Test_PerParser(MediaInfo_Internal* MI, const String &File_Name);
+ size_t Format_Test_PerParser_Continue (MediaInfo_Internal* MI);
+ size_t Format_Test_PerParser_Seek (MediaInfo_Internal* MI, size_t Method, int64u Value, int64u ID);
+
+public:
+ struct curl_data;
+
+private :
+ curl_data* Curl_Data;
+};
+
+} //NameSpace
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl_Include.h b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl_Include.h
new file mode 100644
index 000000000..6e57baca5
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libcurl_Include.h
@@ -0,0 +1,984 @@
+// Reader_libcurl - All info about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Reader_libcurl_IncludeH
+#define MediaInfo_Reader_libcurl_IncludeH
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Copy of curl include files - Easy interface
+//***************************************************************************
+
+typedef void CURL;
+
+typedef enum {
+ CURLE_OK = 0,
+ CURLE_UNSUPPORTED_PROTOCOL, /* 1 */
+ CURLE_FAILED_INIT, /* 2 */
+ CURLE_URL_MALFORMAT, /* 3 */
+ CURLE_OBSOLETE4, /* 4 - NOT USED */
+ CURLE_COULDNT_RESOLVE_PROXY, /* 5 */
+ CURLE_COULDNT_RESOLVE_HOST, /* 6 */
+ CURLE_COULDNT_CONNECT, /* 7 */
+ CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */
+ CURLE_REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server
+ due to lack of access - when login fails
+ this is not returned. */
+ CURLE_OBSOLETE10, /* 10 - NOT USED */
+ CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */
+ CURLE_OBSOLETE12, /* 12 - NOT USED */
+ CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */
+ CURLE_FTP_WEIRD_227_FORMAT, /* 14 */
+ CURLE_FTP_CANT_GET_HOST, /* 15 */
+ CURLE_OBSOLETE16, /* 16 - NOT USED */
+ CURLE_FTP_COULDNT_SET_TYPE, /* 17 */
+ CURLE_PARTIAL_FILE, /* 18 */
+ CURLE_FTP_COULDNT_RETR_FILE, /* 19 */
+ CURLE_OBSOLETE20, /* 20 - NOT USED */
+ CURLE_QUOTE_ERROR, /* 21 - quote command failure */
+ CURLE_HTTP_RETURNED_ERROR, /* 22 */
+ CURLE_WRITE_ERROR, /* 23 */
+ CURLE_OBSOLETE24, /* 24 - NOT USED */
+ CURLE_UPLOAD_FAILED, /* 25 - failed upload "command" */
+ CURLE_READ_ERROR, /* 26 - couldn't open/read from file */
+ CURLE_OUT_OF_MEMORY, /* 27 */
+ /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error
+ instead of a memory allocation error if CURL_DOES_CONVERSIONS
+ is defined
+ */
+ CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */
+ CURLE_OBSOLETE29, /* 29 - NOT USED */
+ CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */
+ CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */
+ CURLE_OBSOLETE32, /* 32 - NOT USED */
+ CURLE_RANGE_ERROR, /* 33 - RANGE "command" didn't work */
+ CURLE_HTTP_POST_ERROR, /* 34 */
+ CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */
+ CURLE_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */
+ CURLE_FILE_COULDNT_READ_FILE, /* 37 */
+ CURLE_LDAP_CANNOT_BIND, /* 38 */
+ CURLE_LDAP_SEARCH_FAILED, /* 39 */
+ CURLE_OBSOLETE40, /* 40 - NOT USED */
+ CURLE_FUNCTION_NOT_FOUND, /* 41 */
+ CURLE_ABORTED_BY_CALLBACK, /* 42 */
+ CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */
+ CURLE_OBSOLETE44, /* 44 - NOT USED */
+ CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */
+ CURLE_OBSOLETE46, /* 46 - NOT USED */
+ CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */
+ CURLE_UNKNOWN_TELNET_OPTION, /* 48 - User specified an unknown option */
+ CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */
+ CURLE_OBSOLETE50, /* 50 - NOT USED */
+ CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint
+ wasn't verified fine */
+ CURLE_GOT_NOTHING, /* 52 - when this is a specific error */
+ CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */
+ CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as
+ default */
+ CURLE_SEND_ERROR, /* 55 - failed sending network data */
+ CURLE_RECV_ERROR, /* 56 - failure in receiving network data */
+ CURLE_OBSOLETE57, /* 57 - NOT IN USE */
+ CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */
+ CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */
+ CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */
+ CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized transfer encoding */
+ CURLE_LDAP_INVALID_URL, /* 62 - Invalid LDAP URL */
+ CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */
+ CURLE_USE_SSL_FAILED, /* 64 - Requested FTP SSL level failed */
+ CURLE_SEND_FAIL_REWIND, /* 65 - Sending the data requires a rewind
+ that failed */
+ CURLE_SSL_ENGINE_INITFAILED, /* 66 - failed to initialise ENGINE */
+ CURLE_LOGIN_DENIED, /* 67 - user, password or similar was not
+ accepted and we failed to login */
+ CURLE_TFTP_NOTFOUND, /* 68 - file not found on server */
+ CURLE_TFTP_PERM, /* 69 - permission problem on server */
+ CURLE_REMOTE_DISK_FULL, /* 70 - out of disk space on server */
+ CURLE_TFTP_ILLEGAL, /* 71 - Illegal TFTP operation */
+ CURLE_TFTP_UNKNOWNID, /* 72 - Unknown transfer ID */
+ CURLE_REMOTE_FILE_EXISTS, /* 73 - File already exists */
+ CURLE_TFTP_NOSUCHUSER, /* 74 - No such user */
+ CURLE_CONV_FAILED, /* 75 - conversion failed */
+ CURLE_CONV_REQD, /* 76 - caller must register conversion
+ callbacks using curl_easy_setopt options
+ CURLOPT_CONV_FROM_NETWORK_FUNCTION,
+ CURLOPT_CONV_TO_NETWORK_FUNCTION, and
+ CURLOPT_CONV_FROM_UTF8_FUNCTION */
+ CURLE_SSL_CACERT_BADFILE, /* 77 - could not load CACERT file, missing
+ or wrong format */
+ CURLE_REMOTE_FILE_NOT_FOUND, /* 78 - remote file not found */
+ CURLE_SSH, /* 79 - error from the SSH layer, somewhat
+ generic so the error message will be of
+ interest when this has happened */
+
+ CURLE_SSL_SHUTDOWN_FAILED, /* 80 - Failed to shut down the SSL
+ connection */
+ CURLE_AGAIN, /* 81 - socket is not ready for send/recv,
+ wait till it's ready and try again (Added
+ in 7.18.2) */
+ CURLE_SSL_CRL_BADFILE, /* 82 - could not load CRL file, missing or
+ wrong format (Added in 7.19.0) */
+ CURLE_SSL_ISSUER_ERROR, /* 83 - Issuer check failed. (Added in
+ 7.19.0) */
+ CURL_LAST /* never use! */
+} CURLcode;
+
+#define CURLINFO_STRING 0x100000
+#define CURLINFO_LONG 0x200000
+#define CURLINFO_DOUBLE 0x300000
+#define CURLINFO_SLIST 0x400000
+#define CURLINFO_MASK 0x0fffff
+#define CURLINFO_TYPEMASK 0xf00000
+
+typedef enum {
+ CURLINFO_NONE, /* first, never use this */
+ CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1,
+ CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2,
+ CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3,
+ CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4,
+ CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5,
+ CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6,
+ CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7,
+ CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8,
+ CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9,
+ CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10,
+ CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11,
+ CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12,
+ CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13,
+ CURLINFO_FILETIME = CURLINFO_LONG + 14,
+ CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15,
+ CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16,
+ CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17,
+ CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18,
+ CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19,
+ CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20,
+ CURLINFO_PRIVATE = CURLINFO_STRING + 21,
+ CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG + 22,
+ CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23,
+ CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24,
+ CURLINFO_OS_ERRNO = CURLINFO_LONG + 25,
+ CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26,
+ CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27,
+ CURLINFO_COOKIELIST = CURLINFO_SLIST + 28,
+ CURLINFO_LASTSOCKET = CURLINFO_LONG + 29,
+ CURLINFO_FTP_ENTRY_PATH = CURLINFO_STRING + 30,
+ CURLINFO_REDIRECT_URL = CURLINFO_STRING + 31,
+ CURLINFO_PRIMARY_IP = CURLINFO_STRING + 32,
+ CURLINFO_APPCONNECT_TIME = CURLINFO_DOUBLE + 33,
+ CURLINFO_CERTINFO = CURLINFO_SLIST + 34,
+ CURLINFO_CONDITION_UNMET = CURLINFO_LONG + 35,
+ /* Fill in new entries below here! */
+
+ CURLINFO_LASTONE = 35
+} CURLINFO;
+
+/* CURLPROTO_ defines are for the CURLOPT_*PROTOCOLS options */
+#define CURLPROTO_HTTP (1<<0)
+#define CURLPROTO_HTTPS (1<<1)
+#define CURLPROTO_FTP (1<<2)
+#define CURLPROTO_FTPS (1<<3)
+#define CURLPROTO_SCP (1<<4)
+#define CURLPROTO_SFTP (1<<5)
+#define CURLPROTO_TELNET (1<<6)
+#define CURLPROTO_LDAP (1<<7)
+#define CURLPROTO_LDAPS (1<<8)
+#define CURLPROTO_DICT (1<<9)
+#define CURLPROTO_FILE (1<<10)
+#define CURLPROTO_TFTP (1<<11)
+#define CURLPROTO_ALL (~0) /* enable everything */
+
+/* long may be 32 or 64 bits, but we should never depend on anything else
+ but 32 */
+#define CURLOPTTYPE_LONG 0
+#define CURLOPTTYPE_OBJECTPOINT 10000
+#define CURLOPTTYPE_FUNCTIONPOINT 20000
+#define CURLOPTTYPE_OFF_T 30000
+
+#define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number
+
+/*
+ * This macro-mania below setups the CURLOPT_[what] enum, to be used with
+ * curl_easy_setopt(). The first argument in the CINIT() macro is the [what]
+ * word.
+ */
+
+typedef enum {
+ /* This is the FILE * or void * the regular output should be written to. */
+ CINIT(FILE, OBJECTPOINT, 1),
+
+ /* The full URL to get/put */
+ CINIT(URL, OBJECTPOINT, 2),
+
+ /* Port number to connect to, if other than default. */
+ CINIT(PORT, LONG, 3),
+
+ /* Name of proxy to use. */
+ CINIT(PROXY, OBJECTPOINT, 4),
+
+ /* "name:password" to use when fetching. */
+ CINIT(USERPWD, OBJECTPOINT, 5),
+
+ /* "name:password" to use with proxy. */
+ CINIT(PROXYUSERPWD, OBJECTPOINT, 6),
+
+ /* Range to get, specified as an ASCII string. */
+ CINIT(RANGE, OBJECTPOINT, 7),
+
+ /* not used */
+
+ /* Specified file stream to upload from (use as input): */
+ CINIT(INFILE, OBJECTPOINT, 9),
+
+ /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE
+ * bytes big. If this is not used, error messages go to stderr instead: */
+ CINIT(ERRORBUFFER, OBJECTPOINT, 10),
+
+ /* Function that will be called to store the output (instead of fwrite). The
+ * parameters will use fwrite() syntax, make sure to follow them. */
+ CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11),
+
+ /* Function that will be called to read the input (instead of fread). The
+ * parameters will use fread() syntax, make sure to follow them. */
+ CINIT(READFUNCTION, FUNCTIONPOINT, 12),
+
+ /* Time-out the read operation after this amount of seconds */
+ CINIT(TIMEOUT, LONG, 13),
+
+ /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about
+ * how large the file being sent really is. That allows better error
+ * checking and better verifies that the upload was successful. -1 means
+ * unknown size.
+ *
+ * For large file support, there is also a _LARGE version of the key
+ * which takes an off_t type, allowing platforms with larger off_t
+ * sizes to handle larger files. See below for INFILESIZE_LARGE.
+ */
+ CINIT(INFILESIZE, LONG, 14),
+
+ /* POST static input fields. */
+ CINIT(POSTFIELDS, OBJECTPOINT, 15),
+
+ /* Set the referrer page (needed by some CGIs) */
+ CINIT(REFERER, OBJECTPOINT, 16),
+
+ /* Set the FTP PORT string (interface name, named or numerical IP address)
+ Use i.e '-' to use default address. */
+ CINIT(FTPPORT, OBJECTPOINT, 17),
+
+ /* Set the User-Agent string (examined by some CGIs) */
+ CINIT(USERAGENT, OBJECTPOINT, 18),
+
+ /* If the download receives less than "low speed limit" bytes/second
+ * during "low speed time" seconds, the operations is aborted.
+ * You could i.e if you have a pretty high speed connection, abort if
+ * it is less than 2000 bytes/sec during 20 seconds.
+ */
+
+ /* Set the "low speed limit" */
+ CINIT(LOW_SPEED_LIMIT, LONG, 19),
+
+ /* Set the "low speed time" */
+ CINIT(LOW_SPEED_TIME, LONG, 20),
+
+ /* Set the continuation offset.
+ *
+ * Note there is also a _LARGE version of this key which uses
+ * off_t types, allowing for large file offsets on platforms which
+ * use larger-than-32-bit off_t's. Look below for RESUME_FROM_LARGE.
+ */
+ CINIT(RESUME_FROM, LONG, 21),
+
+ /* Set cookie in request: */
+ CINIT(COOKIE, OBJECTPOINT, 22),
+
+ /* This points to a linked list of headers, struct curl_slist kind */
+ CINIT(HTTPHEADER, OBJECTPOINT, 23),
+
+ /* This points to a linked list of post entries, struct curl_httppost */
+ CINIT(HTTPPOST, OBJECTPOINT, 24),
+
+ /* name of the file keeping your private SSL-certificate */
+ CINIT(SSLCERT, OBJECTPOINT, 25),
+
+ /* password for the SSL or SSH private key */
+ CINIT(KEYPASSWD, OBJECTPOINT, 26),
+
+ /* send TYPE parameter? */
+ CINIT(CRLF, LONG, 27),
+
+ /* send linked-list of QUOTE commands */
+ CINIT(QUOTE, OBJECTPOINT, 28),
+
+ /* send FILE * or void * to store headers to, if you use a callback it
+ is simply passed to the callback unmodified */
+ CINIT(WRITEHEADER, OBJECTPOINT, 29),
+
+ /* point to a file to read the initial cookies from, also enables
+ "cookie awareness" */
+ CINIT(COOKIEFILE, OBJECTPOINT, 31),
+
+ /* What version to specifically try to use.
+ See CURL_SSLVERSION defines below. */
+ CINIT(SSLVERSION, LONG, 32),
+
+ /* What kind of HTTP time condition to use, see defines */
+ CINIT(TIMECONDITION, LONG, 33),
+
+ /* Time to use with the above condition. Specified in number of seconds
+ since 1 Jan 1970 */
+ CINIT(TIMEVALUE, LONG, 34),
+
+ /* 35 = OBSOLETE */
+
+ /* Custom request, for customizing the get command like
+ HTTP: DELETE, TRACE and others
+ FTP: to use a different list command
+ */
+ CINIT(CUSTOMREQUEST, OBJECTPOINT, 36),
+
+ /* HTTP request, for odd commands like DELETE, TRACE and others */
+ CINIT(STDERR, OBJECTPOINT, 37),
+
+ /* 38 is not used */
+
+ /* send linked-list of post-transfer QUOTE commands */
+ CINIT(POSTQUOTE, OBJECTPOINT, 39),
+
+ /* Pass a pointer to string of the output using full variable-replacement
+ as described elsewhere. */
+ CINIT(WRITEINFO, OBJECTPOINT, 40),
+
+ CINIT(VERBOSE, LONG, 41), /* talk a lot */
+ CINIT(HEADER, LONG, 42), /* throw the header out too */
+ CINIT(NOPROGRESS, LONG, 43), /* shut off the progress meter */
+ CINIT(NOBODY, LONG, 44), /* use HEAD to get http document */
+ CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 300 */
+ CINIT(UPLOAD, LONG, 46), /* this is an upload */
+ CINIT(POST, LONG, 47), /* HTTP POST method */
+ CINIT(DIRLISTONLY, LONG, 48), /* return bare names when listing directories */
+
+ CINIT(APPEND, LONG, 50), /* Append instead of overwrite on upload! */
+
+ /* Specify whether to read the user+password from the .netrc or the URL.
+ * This must be one of the CURL_NETRC_* enums below. */
+ CINIT(NETRC, LONG, 51),
+
+ CINIT(FOLLOWLOCATION, LONG, 52), /* use Location: Luke! */
+
+ CINIT(TRANSFERTEXT, LONG, 53), /* transfer data in text/ASCII format */
+ CINIT(PUT, LONG, 54), /* HTTP PUT */
+
+ /* 55 = OBSOLETE */
+
+ /* Function that will be called instead of the internal progress display
+ * function. This function should be defined as the curl_progress_callback
+ * prototype defines. */
+ CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56),
+
+ /* Data passed to the progress callback */
+ CINIT(PROGRESSDATA, OBJECTPOINT, 57),
+
+ /* We want the referrer field set automatically when following locations */
+ CINIT(AUTOREFERER, LONG, 58),
+
+ /* Port of the proxy, can be set in the proxy string as well with:
+ "[host]:[port]" */
+ CINIT(PROXYPORT, LONG, 59),
+
+ /* size of the POST input data, if strlen() is not good to use */
+ CINIT(POSTFIELDSIZE, LONG, 60),
+
+ /* tunnel non-http operations through a HTTP proxy */
+ CINIT(HTTPPROXYTUNNEL, LONG, 61),
+
+ /* Set the interface string to use as outgoing network interface */
+ CINIT(INTERFACE, OBJECTPOINT, 62),
+
+ /* Set the krb4/5 security level, this also enables krb4/5 awareness. This
+ * is a string, 'clear', 'safe', 'confidential' or 'private'. If the string
+ * is set but doesn't match one of these, 'private' will be used. */
+ CINIT(KRBLEVEL, OBJECTPOINT, 63),
+
+ /* Set if we should verify the peer in ssl handshake, set 1 to verify. */
+ CINIT(SSL_VERIFYPEER, LONG, 64),
+
+ /* The CApath or CAfile used to validate the peer certificate
+ this option is used only if SSL_VERIFYPEER is true */
+ CINIT(CAINFO, OBJECTPOINT, 65),
+
+ /* 66 = OBSOLETE */
+ /* 67 = OBSOLETE */
+
+ /* Maximum number of http redirects to follow */
+ CINIT(MAXREDIRS, LONG, 68),
+
+ /* Pass a long set to 1 to get the date of the requested document (if
+ possible)! Pass a zero to shut it off. */
+ CINIT(FILETIME, LONG, 69),
+
+ /* This points to a linked list of telnet options */
+ CINIT(TELNETOPTIONS, OBJECTPOINT, 70),
+
+ /* Max amount of cached alive connections */
+ CINIT(MAXCONNECTS, LONG, 71),
+
+ /* What policy to use when closing connections when the cache is filled
+ up */
+ CINIT(CLOSEPOLICY, LONG, 72),
+
+ /* 73 = OBSOLETE */
+
+ /* Set to explicitly use a new connection for the upcoming transfer.
+ Do not use this unless you're absolutely sure of this, as it makes the
+ operation slower and is less friendly for the network. */
+ CINIT(FRESH_CONNECT, LONG, 74),
+
+ /* Set to explicitly forbid the upcoming transfer's connection to be re-used
+ when done. Do not use this unless you're absolutely sure of this, as it
+ makes the operation slower and is less friendly for the network. */
+ CINIT(FORBID_REUSE, LONG, 75),
+
+ /* Set to a file name that contains random data for libcurl to use to
+ seed the random engine when doing SSL connects. */
+ CINIT(RANDOM_FILE, OBJECTPOINT, 76),
+
+ /* Set to the Entropy Gathering Daemon socket pathname */
+ CINIT(EGDSOCKET, OBJECTPOINT, 77),
+
+ /* Time-out connect operations after this amount of seconds, if connects
+ are OK within this time, then fine... This only aborts the connect
+ phase. [Only works on unix-style/SIGALRM operating systems] */
+ CINIT(CONNECTTIMEOUT, LONG, 78),
+
+ /* Function that will be called to store headers (instead of fwrite). The
+ * parameters will use fwrite() syntax, make sure to follow them. */
+ CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79),
+
+ /* Set this to force the HTTP request to get back to GET. Only really usable
+ if POST, PUT or a custom request have been used first.
+ */
+ CINIT(HTTPGET, LONG, 80),
+
+ /* Set if we should verify the Common name from the peer certificate in ssl
+ * handshake, set 1 to check existence, 2 to ensure that it matches the
+ * provided hostname. */
+ CINIT(SSL_VERIFYHOST, LONG, 81),
+
+ /* Specify which file name to write all known cookies in after completed
+ operation. Set file name to "-" (dash) to make it go to stdout. */
+ CINIT(COOKIEJAR, OBJECTPOINT, 82),
+
+ /* Specify which SSL ciphers to use */
+ CINIT(SSL_CIPHER_LIST, OBJECTPOINT, 83),
+
+ /* Specify which HTTP version to use! This must be set to one of the
+ CURL_HTTP_VERSION* enums set below. */
+ CINIT(HTTP_VERSION, LONG, 84),
+
+ /* Specifically switch on or off the FTP engine's use of the EPSV command. By
+ default, that one will always be attempted before the more traditional
+ PASV command. */
+ CINIT(FTP_USE_EPSV, LONG, 85),
+
+ /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */
+ CINIT(SSLCERTTYPE, OBJECTPOINT, 86),
+
+ /* name of the file keeping your private SSL-key */
+ CINIT(SSLKEY, OBJECTPOINT, 87),
+
+ /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */
+ CINIT(SSLKEYTYPE, OBJECTPOINT, 88),
+
+ /* crypto engine for the SSL-sub system */
+ CINIT(SSLENGINE, OBJECTPOINT, 89),
+
+ /* set the crypto engine for the SSL-sub system as default
+ the param has no meaning...
+ */
+ CINIT(SSLENGINE_DEFAULT, LONG, 90),
+
+ /* Non-zero value means to use the global dns cache */
+ CINIT(DNS_USE_GLOBAL_CACHE, LONG, 91), /* To become OBSOLETE soon */
+
+ /* DNS cache timeout */
+ CINIT(DNS_CACHE_TIMEOUT, LONG, 92),
+
+ /* send linked-list of pre-transfer QUOTE commands */
+ CINIT(PREQUOTE, OBJECTPOINT, 93),
+
+ /* set the debug function */
+ CINIT(DEBUGFUNCTION, FUNCTIONPOINT, 94),
+
+ /* set the data for the debug function */
+ CINIT(DEBUGDATA, OBJECTPOINT, 95),
+
+ /* mark this as start of a cookie session */
+ CINIT(COOKIESESSION, LONG, 96),
+
+ /* The CApath directory used to validate the peer certificate
+ this option is used only if SSL_VERIFYPEER is true */
+ CINIT(CAPATH, OBJECTPOINT, 97),
+
+ /* Instruct libcurl to use a smaller receive buffer */
+ CINIT(BUFFERSIZE, LONG, 98),
+
+ /* Instruct libcurl to not use any signal/alarm handlers, even when using
+ timeouts. This option is useful for multi-threaded applications.
+ See libcurl-the-guide for more background information. */
+ CINIT(NOSIGNAL, LONG, 99),
+
+ /* Provide a CURLShare for mutexing non-ts data */
+ CINIT(SHARE, OBJECTPOINT, 100),
+
+ /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default),
+ CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A and CURLPROXY_SOCKS5. */
+ CINIT(PROXYTYPE, LONG, 101),
+
+ /* Set the Accept-Encoding string. Use this to tell a server you would like
+ the response to be compressed. */
+ CINIT(ENCODING, OBJECTPOINT, 102),
+
+ /* Set pointer to private data */
+ CINIT(PRIVATE, OBJECTPOINT, 103),
+
+ /* Set aliases for HTTP 200 in the HTTP Response header */
+ CINIT(HTTP200ALIASES, OBJECTPOINT, 104),
+
+ /* Continue to send authentication (user+password) when following locations,
+ even when hostname changed. This can potentially send off the name
+ and password to whatever host the server decides. */
+ CINIT(UNRESTRICTED_AUTH, LONG, 105),
+
+ /* Specifically switch on or off the FTP engine's use of the EPRT command ( it
+ also disables the LPRT attempt). By default, those ones will always be
+ attempted before the good old traditional PORT command. */
+ CINIT(FTP_USE_EPRT, LONG, 106),
+
+ /* Set this to a bitmask value to enable the particular authentications
+ methods you like. Use this in combination with CURLOPT_USERPWD.
+ Note that setting multiple bits may cause extra network round-trips. */
+ CINIT(HTTPAUTH, LONG, 107),
+
+ /* Set the ssl context callback function, currently only for OpenSSL ssl_ctx
+ in second argument. The function must be matching the
+ curl_ssl_ctx_callback proto. */
+ CINIT(SSL_CTX_FUNCTION, FUNCTIONPOINT, 108),
+
+ /* Set the userdata for the ssl context callback function's third
+ argument */
+ CINIT(SSL_CTX_DATA, OBJECTPOINT, 109),
+
+ /* FTP Option that causes missing dirs to be created on the remote server.
+ In 7.19.4 we introduced the convenience enums for this option using the
+ CURLFTP_CREATE_DIR prefix.
+ */
+ CINIT(FTP_CREATE_MISSING_DIRS, LONG, 110),
+
+ /* Set this to a bitmask value to enable the particular authentications
+ methods you like. Use this in combination with CURLOPT_PROXYUSERPWD.
+ Note that setting multiple bits may cause extra network round-trips. */
+ CINIT(PROXYAUTH, LONG, 111),
+
+ /* FTP option that changes the timeout, in seconds, associated with
+ getting a response. This is different from transfer timeout time and
+ essentially places a demand on the FTP server to acknowledge commands
+ in a timely manner. */
+ CINIT(FTP_RESPONSE_TIMEOUT, LONG, 112),
+
+ /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to
+ tell libcurl to resolve names to those IP versions only. This only has
+ affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */
+ CINIT(IPRESOLVE, LONG, 113),
+
+ /* Set this option to limit the size of a file that will be downloaded from
+ an HTTP or FTP server.
+
+ Note there is also _LARGE version which adds large file support for
+ platforms which have larger off_t sizes. See MAXFILESIZE_LARGE below. */
+ CINIT(MAXFILESIZE, LONG, 114),
+
+ /* See the comment for INFILESIZE above, but in short, specifies
+ * the size of the file being uploaded. -1 means unknown.
+ */
+ CINIT(INFILESIZE_LARGE, OFF_T, 115),
+
+ /* Sets the continuation offset. There is also a LONG version of this;
+ * look above for RESUME_FROM.
+ */
+ CINIT(RESUME_FROM_LARGE, OFF_T, 116),
+
+ /* Sets the maximum size of data that will be downloaded from
+ * an HTTP or FTP server. See MAXFILESIZE above for the LONG version.
+ */
+ CINIT(MAXFILESIZE_LARGE, OFF_T, 117),
+
+ /* Set this option to the file name of your .netrc file you want libcurl
+ to parse (using the CURLOPT_NETRC option). If not set, libcurl will do
+ a poor attempt to find the user's home directory and check for a .netrc
+ file in there. */
+ CINIT(NETRC_FILE, OBJECTPOINT, 118),
+
+ /* Enable SSL/TLS for FTP, pick one of:
+ CURLFTPSSL_TRY - try using SSL, proceed anyway otherwise
+ CURLFTPSSL_CONTROL - SSL for the control connection or fail
+ CURLFTPSSL_ALL - SSL for all communication or fail
+ */
+ CINIT(USE_SSL, LONG, 119),
+
+ /* The _LARGE version of the standard POSTFIELDSIZE option */
+ CINIT(POSTFIELDSIZE_LARGE, OFF_T, 120),
+
+ /* Enable/disable the TCP Nagle algorithm */
+ CINIT(TCP_NODELAY, LONG, 121),
+
+ /* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
+ /* 123 OBSOLETE. Gone in 7.16.0 */
+ /* 124 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
+ /* 125 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
+ /* 126 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
+ /* 127 OBSOLETE. Gone in 7.16.0 */
+ /* 128 OBSOLETE. Gone in 7.16.0 */
+
+ /* When FTP over SSL/TLS is selected (with CURLOPT_USE_SSL), this option
+ can be used to change libcurl's default action which is to first try
+ "AUTH SSL" and then "AUTH TLS" in this order, and proceed when a OK
+ response has been received.
+
+ Available parameters are:
+ CURLFTPAUTH_DEFAULT - let libcurl decide
+ CURLFTPAUTH_SSL - try "AUTH SSL" first, then TLS
+ CURLFTPAUTH_TLS - try "AUTH TLS" first, then SSL
+ */
+ CINIT(FTPSSLAUTH, LONG, 129),
+
+ CINIT(IOCTLFUNCTION, FUNCTIONPOINT, 130),
+ CINIT(IOCTLDATA, OBJECTPOINT, 131),
+
+ /* 132 OBSOLETE. Gone in 7.16.0 */
+ /* 133 OBSOLETE. Gone in 7.16.0 */
+
+ /* zero terminated string for pass on to the FTP server when asked for
+ "account" info */
+ CINIT(FTP_ACCOUNT, OBJECTPOINT, 134),
+
+ /* feed cookies into cookie engine */
+ CINIT(COOKIELIST, OBJECTPOINT, 135),
+
+ /* ignore Content-Length */
+ CINIT(IGNORE_CONTENT_LENGTH, LONG, 136),
+
+ /* Set to non-zero to skip the IP address received in a 227 PASV FTP server
+ response. Typically used for FTP-SSL purposes but is not restricted to
+ that. libcurl will then instead use the same IP address it used for the
+ control connection. */
+ CINIT(FTP_SKIP_PASV_IP, LONG, 137),
+
+ /* Select "file method" to use when doing FTP, see the curl_ftpmethod
+ above. */
+ CINIT(FTP_FILEMETHOD, LONG, 138),
+
+ /* Local port number to bind the socket to */
+ CINIT(LOCALPORT, LONG, 139),
+
+ /* Number of ports to try, including the first one set with LOCALPORT.
+ Thus, setting it to 1 will make no additional attempts but the first.
+ */
+ CINIT(LOCALPORTRANGE, LONG, 140),
+
+ /* no transfer, set up connection and let application use the socket by
+ extracting it with CURLINFO_LASTSOCKET */
+ CINIT(CONNECT_ONLY, LONG, 141),
+
+ /* Function that will be called to convert from the
+ network encoding (instead of using the iconv calls in libcurl) */
+ CINIT(CONV_FROM_NETWORK_FUNCTION, FUNCTIONPOINT, 142),
+
+ /* Function that will be called to convert to the
+ network encoding (instead of using the iconv calls in libcurl) */
+ CINIT(CONV_TO_NETWORK_FUNCTION, FUNCTIONPOINT, 143),
+
+ /* Function that will be called to convert from UTF8
+ (instead of using the iconv calls in libcurl)
+ Note that this is used only for SSL certificate processing */
+ CINIT(CONV_FROM_UTF8_FUNCTION, FUNCTIONPOINT, 144),
+
+ /* if the connection proceeds too quickly then need to slow it down */
+ /* limit-rate: maximum number of bytes per second to send or receive */
+ CINIT(MAX_SEND_SPEED_LARGE, OFF_T, 145),
+ CINIT(MAX_RECV_SPEED_LARGE, OFF_T, 146),
+
+ /* Pointer to command string to send if USER/PASS fails. */
+ CINIT(FTP_ALTERNATIVE_TO_USER, OBJECTPOINT, 147),
+
+ /* callback function for setting socket options */
+ CINIT(SOCKOPTFUNCTION, FUNCTIONPOINT, 148),
+ CINIT(SOCKOPTDATA, OBJECTPOINT, 149),
+
+ /* set to 0 to disable session ID re-use for this transfer, default is
+ enabled (== 1) */
+ CINIT(SSL_SESSIONID_CACHE, LONG, 150),
+
+ /* allowed SSH authentication methods */
+ CINIT(SSH_AUTH_TYPES, LONG, 151),
+
+ /* Used by scp/sftp to do public/private key authentication */
+ CINIT(SSH_PUBLIC_KEYFILE, OBJECTPOINT, 152),
+ CINIT(SSH_PRIVATE_KEYFILE, OBJECTPOINT, 153),
+
+ /* Send CCC (Clear Command Channel) after authentication */
+ CINIT(FTP_SSL_CCC, LONG, 154),
+
+ /* Same as TIMEOUT and CONNECTTIMEOUT, but with ms resolution */
+ CINIT(TIMEOUT_MS, LONG, 155),
+ CINIT(CONNECTTIMEOUT_MS, LONG, 156),
+
+ /* set to zero to disable the libcurl's decoding and thus pass the raw body
+ data to the application even when it is encoded/compressed */
+ CINIT(HTTP_TRANSFER_DECODING, LONG, 157),
+ CINIT(HTTP_CONTENT_DECODING, LONG, 158),
+
+ /* Permission used when creating new files and directories on the remote
+ server for protocols that support it, SFTP/SCP/FILE */
+ CINIT(NEW_FILE_PERMS, LONG, 159),
+ CINIT(NEW_DIRECTORY_PERMS, LONG, 160),
+
+ /* Set the behaviour of POST when redirecting. Values must be set to one
+ of CURL_REDIR* defines below. This used to be called CURLOPT_POST301 */
+ CINIT(POSTREDIR, LONG, 161),
+
+ /* used by scp/sftp to verify the host's public key */
+ CINIT(SSH_HOST_PUBLIC_KEY_MD5, OBJECTPOINT, 162),
+
+ /* Callback function for opening socket (instead of socket(2)). Optionally,
+ callback is able change the address or refuse to connect returning
+ CURL_SOCKET_BAD. The callback should have type
+ curl_opensocket_callback */
+ CINIT(OPENSOCKETFUNCTION, FUNCTIONPOINT, 163),
+ CINIT(OPENSOCKETDATA, OBJECTPOINT, 164),
+
+ /* POST volatile input fields. */
+ CINIT(COPYPOSTFIELDS, OBJECTPOINT, 165),
+
+ /* set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy */
+ CINIT(PROXY_TRANSFER_MODE, LONG, 166),
+
+ /* Callback function for seeking in the input stream */
+ CINIT(SEEKFUNCTION, FUNCTIONPOINT, 167),
+ CINIT(SEEKDATA, OBJECTPOINT, 168),
+
+ /* CRL file */
+ CINIT(CRLFILE, OBJECTPOINT, 169),
+
+ /* Issuer certificate */
+ CINIT(ISSUERCERT, OBJECTPOINT, 170),
+
+ /* (IPv6) Address scope */
+ CINIT(ADDRESS_SCOPE, LONG, 171),
+
+ /* Collect certificate chain info and allow it to get retrievable with
+ CURLINFO_CERTINFO after the transfer is complete. (Unfortunately) only
+ working with OpenSSL-powered builds. */
+ CINIT(CERTINFO, LONG, 172),
+
+ /* "name" and "pwd" to use when fetching. */
+ CINIT(USERNAME, OBJECTPOINT, 173),
+ CINIT(PASSWORD, OBJECTPOINT, 174),
+
+ /* "name" and "pwd" to use with Proxy when fetching. */
+ CINIT(PROXYUSERNAME, OBJECTPOINT, 175),
+ CINIT(PROXYPASSWORD, OBJECTPOINT, 176),
+
+ /* Comma separated list of hostnames defining no-proxy zones. These should
+ match both hostnames directly, and hostnames within a domain. For
+ example, local.com will match local.com and www.local.com, but NOT
+ notlocal.com or www.notlocal.com. For compatibility with other
+ implementations of this, .local.com will be considered to be the same as
+ local.com. A single * is the only valid wildcard, and effectively
+ disables the use of proxy. */
+ CINIT(NOPROXY, OBJECTPOINT, 177),
+
+ /* block size for TFTP transfers */
+ CINIT(TFTP_BLKSIZE, LONG, 178),
+
+ /* Socks Service */
+ CINIT(SOCKS5_GSSAPI_SERVICE, OBJECTPOINT, 179),
+
+ /* Socks Service */
+ CINIT(SOCKS5_GSSAPI_NEC, LONG, 180),
+
+ /* set the bitmask for the protocols that are allowed to be used for the
+ transfer, which thus helps the app which takes URLs from users or other
+ external inputs and want to restrict what protocol(s) to deal
+ with. Defaults to CURLPROTO_ALL. */
+ CINIT(PROTOCOLS, LONG, 181),
+
+ /* set the bitmask for the protocols that libcurl is allowed to follow to,
+ as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs
+ to be set in both bitmasks to be allowed to get redirected to. Defaults
+ to all protocols except FILE and SCP. */
+ CINIT(REDIR_PROTOCOLS, LONG, 182),
+
+ /* set the SSH knownhost file name to use */
+ CINIT(SSH_KNOWNHOSTS, OBJECTPOINT, 183),
+
+ /* set the SSH host key callback, must point to a curl_sshkeycallback
+ function */
+ CINIT(SSH_KEYFUNCTION, FUNCTIONPOINT, 184),
+
+ /* set the SSH host key callback custom pointer */
+ CINIT(SSH_KEYDATA, OBJECTPOINT, 185),
+
+ CURLOPT_LASTENTRY /* the last unused */
+} CURLoption;
+
+ /* three convenient "aliases" that follow the name scheme better */
+#define CURLOPT_WRITEDATA CURLOPT_FILE
+#define CURLOPT_READDATA CURLOPT_INFILE
+#define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER
+
+typedef int64u curl_off_t;
+
+//***************************************************************************
+// Copy of curl include files - Multi interface
+//***************************************************************************
+
+typedef void CURLM;
+
+typedef enum {
+ CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
+ curl_multi_socket*() soon */
+ CURLM_OK,
+ CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
+ CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
+ CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
+ CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
+ CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
+ CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
+ CURLM_LAST
+} CURLMcode;
+
+typedef enum {
+ CURLVERSION_FIRST,
+ CURLVERSION_SECOND,
+ CURLVERSION_THIRD,
+ CURLVERSION_FOURTH,
+ CURLVERSION_LAST /* never actually use this */
+} CURLversion;
+
+#define CURLVERSION_NOW CURLVERSION_FOURTH
+
+typedef struct {
+ CURLversion age; /* age of the returned struct */
+ const char *version; /* LIBCURL_VERSION */
+ unsigned int version_num; /* LIBCURL_VERSION_NUM */
+ const char *host; /* OS/host/cpu/machine when configured */
+ int features; /* bitmask, see defines below */
+ const char *ssl_version; /* human readable string */
+ long ssl_version_num; /* not used anymore, always 0 */
+ const char *libz_version; /* human readable string */
+ /* protocols is terminated by an entry with a NULL protoname */
+ const char * const *protocols;
+
+ /* The fields below this were added in CURLVERSION_SECOND */
+ const char *ares;
+ int ares_num;
+
+ /* This field was added in CURLVERSION_THIRD */
+ const char *libidn;
+
+ /* These field were added in CURLVERSION_FOURTH */
+
+ /* Same as '_libiconv_version' if built with HAVE_ICONV */
+ int iconv_ver_num;
+
+ const char *libssh_version; /* human readable string */
+
+} curl_version_info_data;
+
+#define CURL_ERROR_SIZE 256
+
+//***************************************************************************
+// Dynamic load stuff
+//***************************************************************************
+
+extern "C"
+{
+
+#if defined (_WIN32) || defined (WIN32)
+ #define MEDIAINFODLL_NAME "libcurl.dll"
+#elif defined(__APPLE__) && defined(__MACH__)
+ #define MEDIAINFODLL_NAME "libcurl.0.dylib"
+ #define __stdcall
+#else
+ #define MEDIAINFODLL_NAME "libcurl.so.0"
+ #define __stdcall
+#endif //!defined(_WIN32) || defined (WIN32)
+
+#ifdef MEDIAINFO_GLIBC
+ #include <gmodule.h>
+ static GModule* libcurl_Module=NULL;
+#elif defined (_WIN32) || defined (WIN32)
+ #undef __TEXT
+ #include <windows.h>
+ static HMODULE libcurl_Module=NULL;
+#else
+ #include <dlfcn.h>
+ static void* libcurl_Module=NULL;
+#endif
+
+size_t libcurl_Module_Count=0;
+
+#ifdef MEDIAINFO_GLIBC
+#define MEDIAINFO_ASSIGN(_Name,_Name2) \
+ if (!g_module_symbol (libcurl_Module, _Name2, (gpointer*)&_Name)) \
+ Errors++;
+#elif defined (_WIN32) || defined (WIN32)
+#define MEDIAINFO_ASSIGN(_Name,_Name2) \
+ _Name=(LIBCURL_##_Name)GetProcAddress(libcurl_Module, _Name2); \
+ if (_Name==NULL) Errors++;
+#else
+#define MEDIAINFO_ASSIGN(_Name,_Name2) \
+ _Name=(LIBCURL_##_Name)dlsym(libcurl_Module, _Name2); \
+ if (_Name==NULL) Errors++;
+#endif
+
+//---------------------------------------------------------------------------
+// Easy interface
+typedef CURL* (*LIBCURL_curl_easy_init) (); static LIBCURL_curl_easy_init curl_easy_init;
+typedef CURLcode (*LIBCURL_curl_easy_setopt) (CURL *curl, CURLoption option, ...); static LIBCURL_curl_easy_setopt curl_easy_setopt;
+typedef CURLcode (*LIBCURL_curl_easy_perform)(CURL *curl); static LIBCURL_curl_easy_perform curl_easy_perform;
+typedef void (*LIBCURL_curl_easy_cleanup)(CURL *curl); static LIBCURL_curl_easy_cleanup curl_easy_cleanup;
+typedef CURLcode (*LIBCURL_curl_easy_getinfo)(CURL *curl, CURLINFO info, ...); static LIBCURL_curl_easy_getinfo curl_easy_getinfo;
+typedef struct curl_slist* (*LIBCURL_curl_slist_append) (struct curl_slist *, const char *); static LIBCURL_curl_slist_append curl_slist_append;
+typedef void (*LIBCURL_curl_slist_free_all) (struct curl_slist *); static LIBCURL_curl_slist_free_all curl_slist_free_all;
+typedef CURL* (*LIBCURL_curl_easy_duphandle)(CURL *curl); static LIBCURL_curl_easy_duphandle curl_easy_duphandle;
+typedef const char* (*LIBCURL_curl_easy_strerror)(CURLcode curlcode); static LIBCURL_curl_easy_strerror curl_easy_strerror;
+typedef curl_version_info_data* (*LIBCURL_curl_version_info)(CURLversion version); static LIBCURL_curl_version_info curl_version_info;
+
+//---------------------------------------------------------------------------
+// Multi interface
+typedef CURLM* (*LIBCURL_curl_multi_init) (); static LIBCURL_curl_multi_init curl_multi_init;
+typedef CURLMcode (*LIBCURL_curl_multi_add_handle) (CURLM *multi_handle, CURL *curl_handle); static LIBCURL_curl_multi_add_handle curl_multi_add_handle;
+typedef CURLMcode (*LIBCURL_curl_multi_remove_handle) (CURLM *multi_handle, CURL *curl_handle); static LIBCURL_curl_multi_remove_handle curl_multi_remove_handle;
+typedef CURLMcode (*LIBCURL_curl_multi_perform)(CURLM *curl, int *running_handles); static LIBCURL_curl_multi_perform curl_multi_perform;
+typedef void (*LIBCURL_curl_multi_cleanup)(CURLM *curl); static LIBCURL_curl_multi_cleanup curl_multi_cleanup;
+
+}
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libmms.cpp b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libmms.cpp
new file mode 100644
index 000000000..5ffe27d17
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libmms.cpp
@@ -0,0 +1,175 @@
+// Reader_libmms - All info about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+// Config
+#ifndef MEDIAINFO_LIBMMS_DESCRIBE_SUPPORT //If not defined by the compiler
+ #define MEDIAINFO_LIBMMS_DESCRIBE_SUPPORT 0 //0=without, 1=with libmms customized version containing DESCRIBE only API
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_LIBMMS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Reader/Reader_libmms.h"
+#include "MediaInfo/File__Analyze.h"
+#if defined LIBMMS_DLL_RUNTIME
+#elif defined LIBMMS_DLL_STATIC
+#else
+ #ifdef MEDIAINFO_LIBMMS_FROMSOURCE
+ #include "mmsx.h"
+ #include "mmsh.h"
+ #else //MEDIAINFO_LIBMMS_FROMSOURCE
+ #include "libmms/mmsx.h"
+ #include "libmms/mmsh.h"
+ #endif //MEDIAINFO_LIBMMS_FROMSOURCE
+#endif
+#include <iostream>
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+const size_t Buffer_NormalSize=64*1024;
+
+//***************************************************************************
+// libmms stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t Reader_libmms::Format_Test(MediaInfo_Internal* MI, const String &File_Name)
+{
+ mmsx_t* Handle;
+
+ //Opening the file
+ #if MEDIAINFO_LIBMMS_DESCRIBE_SUPPORT
+ if (MI->Config.File_Mmsh_Describe_Only_Get())
+ {
+ // Use MMSH & Send a DESCRIBE request
+ mmsh_t* MmshHandle;
+
+ MmshHandle=mmsh_describe_request(0, 0, Ztring(File_Name).To_Local().c_str());
+ if (MmshHandle==NULL)
+ return 0;
+
+ Handle=mmsx_set_mmsh_handle(MmshHandle);
+ if (Handle==NULL)
+ {
+ mmsh_close(MmshHandle);
+ return 0;
+ }
+ }
+ else
+ #endif //MEDIAINFO_LIBMMS_DESCRIBE_SUPPORT
+ {
+ // Use MMS or MMSH (Send a DESCRIBE & PLAY request)
+ Handle=mmsx_connect(0, 0, Ztring(File_Name).To_Local().c_str(), (int)-1);
+ if (Handle==NULL)
+ return 0;
+ }
+
+ //Init
+ size_t Buffer_Size_Max;
+ uint32_t Length;
+ if (!MI->Config.File_Mmsh_Describe_Only_Get())
+ {
+ //Buffer
+ Buffer_Size_Max=Buffer_NormalSize;
+
+ //MediaInfo init
+ mms_off_t Offset=mmsx_seek(0, Handle, 0, SEEK_SET);
+ uint32_t Length=mmsx_get_length(Handle);
+ MI->Open_Buffer_Init(Length, File_Name);
+ }
+ else
+ {
+ //Buffer
+ Buffer_Size_Max=mmsx_get_asf_header_len(Handle);
+
+ //MediaInfo init
+ Length=(uint32_t)-1;
+ MI->Open_Buffer_Init((int64u)-1, File_Name);
+ }
+ int8u* Buffer=new int8u[Buffer_Size_Max];
+
+ //Test the format with buffer
+ bool StopAfterFilled=MI->Config.File_StopAfterFilled_Get();
+ std::bitset<32> Status;
+ do
+ {
+ //Seek (if needed)
+ if (MI->Open_Buffer_Continue_GoTo_Get()!=(int64u)-1)
+ {
+ if (MI->Open_Buffer_Continue_GoTo_Get()>=Length)
+ break; //Seek requested, but on a file bigger in theory than what is in the real file, we can't do this
+ if (mmsx_seek(0, Handle, mms_off_t(MI->Open_Buffer_Continue_GoTo_Get()), SEEK_SET)!=MI->Open_Buffer_Continue_GoTo_Get())
+ break; //File is not seekable
+
+ MI->Open_Buffer_Init((int64u)-1, MI->Open_Buffer_Continue_GoTo_Get());
+ }
+
+ //Buffering
+ size_t Buffer_Size;
+ if (!MI->Config.File_Mmsh_Describe_Only_Get())
+ Buffer_Size=mmsx_read(0, Handle, (char*)Buffer, (int)Buffer_Size_Max);
+ else
+ Buffer_Size=mmsx_peek_header(Handle, (char*)Buffer, (int)Buffer_Size_Max);
+
+ //Parser
+ Status=MI->Open_Buffer_Continue(Buffer, Buffer_Size);
+ if (Buffer_Size==0 || MI->Config.File_Mmsh_Describe_Only_Get())
+ break;
+ }
+ while (!(Status[File__Analyze::IsFinished] || (StopAfterFilled && Status[File__Analyze::IsFilled])));
+
+ //File
+ mmsx_close(Handle);
+
+ //Buffer
+ delete[] Buffer; //Buffer=NULL;
+
+ //Is this file detected?
+ if (!Status[File__Analyze::IsAccepted])
+ return 0;
+
+ MI->Open_Buffer_Finalize();
+
+ return 1;
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_LIBMMS_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libmms.h b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libmms.h
new file mode 100644
index 000000000..41fcb0fc2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Reader/Reader_libmms.h
@@ -0,0 +1,52 @@
+// Reader_libmms - All information about media files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Give information about a lot of media files
+// Dispatch the file to be tested by all containers
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef Reader_libmmsH
+#define Reader_libmmsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Reader/Reader__Base.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+/// @brief Reader_libmms
+//***************************************************************************
+
+class Reader_libmms : public Reader__Base
+{
+public :
+ //Constructor/Destructor
+ virtual ~Reader_libmms() {}
+
+ //Format testing
+ size_t Format_Test(MediaInfo_Internal* MI, const String &File_Name);
+};
+
+} //NameSpace
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Setup.h b/src/thirdparty/MediaInfo/MediaInfo/Setup.h
new file mode 100644
index 000000000..f30041630
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Setup.h
@@ -0,0 +1,675 @@
+// Config - Config file for MediaInfo
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// All compilation definitions
+// Helpers for compilers (precompilation)
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_SetupH
+#define MediaInfo_SetupH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+//Needed in the whole library
+#include "ZenLib/Conf.h"
+
+//***************************************************************************
+// General configuration
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Legacy
+#if defined(MEDIAINFO_MINIMIZESIZE)
+ #if !defined (MEDIAINFO_TRACE_NO) && !defined (MEDIAINFO_TRACE_YES)
+ #define MEDIAINFO_TRACE_NO
+ #endif
+ //#if !defined (MEDIAINFO_FILTER_NO) && !defined (MEDIAINFO_FILTER_YES)
+ // #define MEDIAINFO_FILTER_NO
+ //#endif
+ //#if !defined (MEDIAINFO_DUPLICATE_NO) && !defined (MEDIAINFO_DUPLICATE_YES)
+ // #define MEDIAINFO_DUPLICATE_NO
+ //#endif
+ #if !defined (MEDIAINFO_MACROBLOCKS_NO) && !defined (MEDIAINFO_MACROBLOCKS_YES)
+ #define MEDIAINFO_MACROBLOCKS_NO
+ #endif
+ #if !defined (MEDIAINFO_NEXTPACKET_NO) && !defined (MEDIAINFO_NEXTPACKET_YES)
+ #define MEDIAINFO_NEXTPACKET_NO
+ #endif
+ #if !defined (MEDIAINFO_SEEK_NO) && !defined (MEDIAINFO_SEEK_YES)
+ #define MEDIAINFO_SEEK_NO
+ #endif
+ #if !defined (MEDIAINFO_EVENTS_NO) && !defined (MEDIAINFO_EVENTS_YES)
+ #define MEDIAINFO_EVENTS_NO
+ #endif
+ #if !defined (MEDIAINFO_DEMUX_NO) && !defined (MEDIAINFO_DEMUX_YES)
+ #define MEDIAINFO_DEMUX_NO
+ #endif
+ #if !defined (MEDIAINFO_IBI_NO) && !defined (MEDIAINFO_IBI_YES)
+ #define MEDIAINFO_IBI_NO
+ #endif
+#endif
+#if defined(MEDIAINFO_EVENTS)
+ #undef MEDIAINFO_EVENTS
+ #if !defined (MEDIAINFO_EVENTS_NO) && !defined (MEDIAINFO_EVENTS_YES)
+ #define MEDIAINFO_EVENTS_YES
+ #endif
+#endif
+
+//---------------------------------------------------------------------------
+// Special configurations
+#if defined(MEDIAINFO_MINIMAL_YES)
+ #if !defined (MEDIAINFO_TRACE_NO) && !defined (MEDIAINFO_TRACE_YES)
+ #define MEDIAINFO_TRACE_NO
+ #endif
+ #if !defined (MEDIAINFO_FILTER_NO) && !defined (MEDIAINFO_FILTER_YES)
+ #define MEDIAINFO_FILTER_NO
+ #endif
+ #if !defined (MEDIAINFO_DUPLICATE_NO) && !defined (MEDIAINFO_DUPLICATE_YES)
+ #define MEDIAINFO_DUPLICATE_NO
+ #endif
+ #if !defined (MEDIAINFO_MACROBLOCKS_NO) && !defined (MEDIAINFO_MACROBLOCKS_YES)
+ #define MEDIAINFO_MACROBLOCKS_NO
+ #endif
+ #if !defined (MEDIAINFO_NEXTPACKET_NO) && !defined (MEDIAINFO_NEXTPACKET_YES)
+ #define MEDIAINFO_NEXTPACKET_NO
+ #endif
+ #if !defined (MEDIAINFO_SEEK_NO) && !defined (MEDIAINFO_SEEK_YES)
+ #define MEDIAINFO_SEEK_NO
+ #endif
+ #if !defined (MEDIAINFO_EVENTS_NO) && !defined (MEDIAINFO_EVENTS_YES)
+ #define MEDIAINFO_EVENTS_NO
+ #endif
+ #if !defined (MEDIAINFO_DEMUX_NO) && !defined (MEDIAINFO_DEMUX_YES)
+ #define MEDIAINFO_DEMUX_NO
+ #endif
+ #if !defined (MEDIAINFO_IBI_NO) && !defined (MEDIAINFO_IBI_YES)
+ #define MEDIAINFO_IBI_NO
+ #endif
+ #if !defined (MEDIAINFO_DIRECTORY_NO) && !defined (MEDIAINFO_DIRECTORY_YES)
+ #define MEDIAINFO_DIRECTORY_NO
+ #endif
+ #if !defined (MEDIAINFO_LIBCURL_NO) && !defined (MEDIAINFO_LIBCURL_YES)
+ #define MEDIAINFO_LIBCURL_NO
+ #endif
+ #if !defined (MEDIAINFO_LIBMMS_NO) && !defined (MEDIAINFO_LIBMM_YES)
+ #define MEDIAINFO_LIBMMS_NO
+ #endif
+ #if !defined (MEDIAINFO_DVDIF_ANALYZE_NO) && !defined (MEDIAINFO_DVDIF_ANALYZE_YES)
+ #define MEDIAINFO_DVDIF_ANALYZE_NO
+ #endif
+ #if !defined (MEDIAINFO_MPEGTS_DUPLICATE_NO) && !defined (MEDIAINFO_MPEGTS_DUPLICATE_YES)
+ #define MEDIAINFO_MPEGTS_DUPLICATE_NO
+ #endif
+#endif
+
+//---------------------------------------------------------------------------
+// Optional features
+#if !defined(MEDIAINFO_TRACE)
+ #if defined(MEDIAINFO_TRACE_NO) && defined(MEDIAINFO_TRACE_YES)
+ #undef MEDIAINFO_TRACE_NO //MEDIAINFO_TRACE_YES has priority
+ #endif
+ #if defined(MEDIAINFO_TRACE_NO)
+ #define MEDIAINFO_TRACE 0
+ #else
+ #define MEDIAINFO_TRACE 1
+ #endif
+#endif
+#if !defined(MEDIAINFO_FILTER)
+ #if defined(MEDIAINFO_FILTER_NO) && defined(MEDIAINFO_FILTER_YES)
+ #undef MEDIAINFO_FILTER_NO //MEDIAINFO_FILTER_YES has priority
+ #endif
+ #if defined(MEDIAINFO_FILTER_NO)
+ #define MEDIAINFO_FILTER 0
+ #else
+ #define MEDIAINFO_FILTER 1
+ #endif
+#endif
+#if !defined(MEDIAINFO_DUPLICATE)
+ #if defined(MEDIAINFO_DUPLICATE_NO) && defined(MEDIAINFO_DUPLICATE_YES)
+ #undef MEDIAINFO_DUPLICATE_NO //MEDIAINFO_DUPLICATE_YES has priority
+ #endif
+ #if defined(MEDIAINFO_DUPLICATE_NO)
+ #define MEDIAINFO_DUPLICATE 0
+ #else
+ #define MEDIAINFO_DUPLICATE 1
+ #endif
+#endif
+#if !defined(MEDIAINFO_MACROBLOCKS)
+ #if defined(MEDIAINFO_MACROBLOCKS_NO) && defined(MEDIAINFO_MACROBLOCKS_YES)
+ #undef MEDIAINFO_MACROBLOCKS_NO //MEDIAINFO_MACROBLOCKS_YES has priority
+ #endif
+ #if defined(MEDIAINFO_MACROBLOCKS_NO)
+ #define MEDIAINFO_MACROBLOCKS 0
+ #else
+ #define MEDIAINFO_MACROBLOCKS 1
+ #endif
+#endif
+#if !defined(MEDIAINFO_NEXTPACKET)
+ #if defined(MEDIAINFO_NEXTPACKET_NO) && defined(MEDIAINFO_NEXTPACKET_YES)
+ #undef MEDIAINFO_NEXTPACKET_NO //MEDIAINFO_NEXTPACKET_YES has priority
+ #endif
+ #if defined(MEDIAINFO_NEXTPACKET_NO)
+ #define MEDIAINFO_NEXTPACKET 0
+ #else
+ #define MEDIAINFO_NEXTPACKET 1
+ #endif
+#endif
+#if !defined(MEDIAINFO_SEEK)
+ #if defined(MEDIAINFO_SEEK_NO) && defined(MEDIAINFO_SEEK_YES)
+ #undef MEDIAINFO_SEEK_NO //MEDIAINFO_SEEK_YES has priority
+ #endif
+ #if defined(MEDIAINFO_SEEK_NO)
+ #define MEDIAINFO_SEEK 0
+ #else
+ #define MEDIAINFO_SEEK 1
+ #endif
+#endif
+#if !defined(MEDIAINFO_EVENTS)
+ #if defined(MEDIAINFO_EVENTS_NO) && defined(MEDIAINFO_EVENTS_YES)
+ #undef MEDIAINFO_EVENTS_NO //MEDIAINFO_EVENTS_YES has priority
+ #endif
+ #if defined(MEDIAINFO_EVENTS_NO)
+ #define MEDIAINFO_EVENTS 0
+ #else
+ #define MEDIAINFO_EVENTS 1
+ #endif
+#endif
+#if !defined(MEDIAINFO_DEMUX)
+ #if !defined(MEDIAINFO_DEMUX_NO) && !defined(MEDIAINFO_DEMUX_YES) && !MEDIAINFO_EVENTS
+ #define MEDIAINFO_DEMUX_NO //MEDIAINFO_DEMUX is disabled by default if MEDIAINFO_EVENTS is set to 0
+ #endif
+ #if defined(MEDIAINFO_DEMUX_NO) && defined(MEDIAINFO_DEMUX_YES)
+ #undef MEDIAINFO_DEMUX_NO //MEDIAINFO_DEMUX_YES has priority
+ #endif
+ #if defined(MEDIAINFO_DEMUX_NO)
+ #define MEDIAINFO_DEMUX 0
+ #else
+ #define MEDIAINFO_DEMUX 1
+ #endif
+#endif
+#if MEDIAINFO_DEMUX && !MEDIAINFO_EVENTS
+ pragma error MEDIAINFO_DEMUX can be set to 1 only if MEDIAINFO_EVENTS is set to 1
+#endif
+#if !defined(MEDIAINFO_IBI)
+ #if defined(MEDIAINFO_IBI_NO) && defined(MEDIAINFO_IBI_YES)
+ #undef MEDIAINFO_IBI_NO //MEDIAINFO_IBI_YES has priority
+ #endif
+ #if defined(MEDIAINFO_IBI_NO)
+ #define MEDIAINFO_IBI 0
+ #else
+ #define MEDIAINFO_IBI 1
+ #endif
+#endif
+
+//***************************************************************************
+// Precise configuration
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Readers
+#if !defined(MEDIAINFO_READER_NO) && !defined(MEDIAINFO_DIRECTORY_NO) && !defined(MEDIAINFO_DIRECTORY_YES)
+ #define MEDIAINFO_DIRECTORY_YES
+#endif
+#if !defined(MEDIAINFO_READER_NO) && !defined(MEDIAINFO_FILE_NO) && !defined(MEDIAINFO_FILE_YES)
+ #define MEDIAINFO_FILE_YES
+#endif
+#if !defined(MEDIAINFO_READER_NO) && !defined(MEDIAINFO_LIBCURL_NO) && !defined(MEDIAINFO_LIBCURL_YES)
+ #define MEDIAINFO_LIBCURL_YES
+#endif
+#if !defined(MEDIAINFO_READER_NO) && !defined(MEDIAINFO_LIBMMS_NO) && !defined(MEDIAINFO_LIBMMS_YES)
+ #ifndef WINDOWS
+ #define MEDIAINFO_LIBMMS_YES
+ #endif //WINDOWS
+#endif
+
+//---------------------------------------------------------------------------
+// All in one for no parsers
+#if defined(MEDIAINFO_ALL_NO) && !defined(MEDIAINFO_MULTI_NO)
+ #define MEDIAINFO_MULTI_NO
+#endif
+#if defined(MEDIAINFO_ALL_NO) && !defined(MEDIAINFO_VIDEO_NO)
+ #define MEDIAINFO_VIDEO_NO
+#endif
+#if defined(MEDIAINFO_ALL_NO) && !defined(MEDIAINFO_AUDIO_NO)
+ #define MEDIAINFO_AUDIO_NO
+#endif
+#if defined(MEDIAINFO_ALL_NO) && !defined(MEDIAINFO_TEXT_NO)
+ #define MEDIAINFO_TEXT_NO
+#endif
+#if defined(MEDIAINFO_ALL_NO) && !defined(MEDIAINFO_IMAGE_NO)
+ #define MEDIAINFO_IMAGE_NO
+#endif
+#if defined(MEDIAINFO_ALL_NO) && !defined(MEDIAINFO_ARCHIVE_NO)
+ #define MEDIAINFO_ARCHIVE_NO
+#endif
+#if defined(MEDIAINFO_ALL_NO) && !defined(MEDIAINFO_TAG_NO)
+ #define MEDIAINFO_TAG_NO
+#endif
+
+//---------------------------------------------------------------------------
+// Multiple
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_REFERENCES_NO) && !defined(MEDIAINFO_REFERENCES_YES)
+ #define MEDIAINFO_REFERENCES_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_ANCILLARY_NO) && !defined(MEDIAINFO_ANCILLARY_YES)
+ #define MEDIAINFO_ANCILLARY_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_BDAV_NO) && !defined(MEDIAINFO_BDAV_YES)
+ #define MEDIAINFO_BDAV_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_BDMV_NO) && !defined(MEDIAINFO_BDMV_YES)
+ #define MEDIAINFO_BDMV_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_CDXA_NO) && !defined(MEDIAINFO_CDXA_YES)
+ #define MEDIAINFO_CDXA_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_DCP_NO) && !defined(MEDIAINFO_DCP_YES)
+ #define MEDIAINFO_DCP_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_DVDIF_NO) && !defined(MEDIAINFO_DVDIF_YES)
+ #define MEDIAINFO_DVDIF_YES
+#endif
+#if defined(MEDIAINFO_DVDIF_YES) && !defined(MEDIAINFO_DVDIF_ANALYZE_NO) && !defined(MEDIAINFO_DVDIF_ANALYZE_YES)
+ #define MEDIAINFO_DVDIF_ANALYZE_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_DVDV_NO) && !defined(MEDIAINFO_DVDV_YES)
+ #define MEDIAINFO_DVDV_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_DXW_NO) && !defined(MEDIAINFO_DXW_YES)
+ #define MEDIAINFO_DXW_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_FLV_NO) && !defined(MEDIAINFO_FLV_YES)
+ #define MEDIAINFO_FLV_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_GXF_NO) && !defined(MEDIAINFO_GXF_YES)
+ #define MEDIAINFO_GXF_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_HLS_NO) && !defined(MEDIAINFO_HLS_YES)
+ #define MEDIAINFO_HLS_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_ISM_NO) && !defined(MEDIAINFO_ISM_YES)
+ #define MEDIAINFO_ISM_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_IVF_NO) && !defined(MEDIAINFO_IVF_YES)
+ #define MEDIAINFO_IVF_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_IBI_NO) && !defined(MEDIAINFO_IBI_YES)
+ #define MEDIAINFO_IBI_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_LXF_NO) && !defined(MEDIAINFO_LXF_YES)
+ #define MEDIAINFO_LXF_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_MK_NO) && !defined(MEDIAINFO_MK_YES)
+ #define MEDIAINFO_MK_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_MPEG4_NO) && !defined(MEDIAINFO_MPEG4_YES)
+ #define MEDIAINFO_MPEG4_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_MPEGPS_NO) && !defined(MEDIAINFO_MPEGPS_YES)
+ #define MEDIAINFO_MPEGPS_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_MPEGTS_NO) && !defined(MEDIAINFO_MPEGTS_YES)
+ #define MEDIAINFO_MPEGTS_YES
+#endif
+#if defined(MEDIAINFO_MPEGTS_YES) && !defined(MEDIAINFO_MPEGTS_PCR_NO) && !defined(MEDIAINFO_MPEGTS_PCR_YES)
+ #define MEDIAINFO_MPEGTS_PCR_YES
+#endif
+#if defined(MEDIAINFO_MPEGTS_YES) && !defined(MEDIAINFO_MPEGTS_PESTIMESTAMP_NO) && !defined(MEDIAINFO_MPEGTS_PESTIMESTAMP_YES)
+ #define MEDIAINFO_MPEGTS_PESTIMESTAMP_YES
+#endif
+#if defined(MEDIAINFO_MPEGTS_YES) && !defined(MEDIAINFO_MPEGTS_DUPLICATE_NO) && !defined(MEDIAINFO_MPEGTS_DUPLICATE_YES)
+ #define MEDIAINFO_MPEGTS_DUPLICATE_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_MXF_NO) && !defined(MEDIAINFO_MXF_YES)
+ #define MEDIAINFO_MXF_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_NUT_NO) && !defined(MEDIAINFO_NUT_YES)
+ #define MEDIAINFO_NUT_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_OGG_NO) && !defined(MEDIAINFO_OGG_YES)
+ #define MEDIAINFO_OGG_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_P2_NO) && !defined(MEDIAINFO_P2_YES)
+ #define MEDIAINFO_P2_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_RIFF_NO) && !defined(MEDIAINFO_RIFF_YES)
+ #define MEDIAINFO_RIFF_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_RM_NO) && !defined(MEDIAINFO_RM_YES)
+ #define MEDIAINFO_RM_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_SEQUENCEINFO_NO) && !defined(MEDIAINFO_SEQUENCEINFO_YES)
+ #define MEDIAINFO_SEQUENCEINFO_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_SKM_NO) && !defined(MEDIAINFO_SKM_YES)
+ #define MEDIAINFO_SKM_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_SWF_NO) && !defined(MEDIAINFO_SWF_YES)
+ #define MEDIAINFO_SWF_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_TSP_NO) && !defined(MEDIAINFO_TSP_YES)
+ #define MEDIAINFO_TSP_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_UMF_NO) && !defined(MEDIAINFO_UMF_YES)
+ #define MEDIAINFO_UMF_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_WM_NO) && !defined(MEDIAINFO_WM_YES)
+ #define MEDIAINFO_WM_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_XDCAM_NO) && !defined(MEDIAINFO_XDCAM_YES)
+ #define MEDIAINFO_XDCAM_YES
+#endif
+#if !defined(MEDIAINFO_MULTI_NO) && !defined(MEDIAINFO_DPG_NO) && !defined(MEDIAINFO_DPG_YES)
+ #define MEDIAINFO_DPG_YES
+#endif
+
+//---------------------------------------------------------------------------
+// Video
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_AFDBARDATA_NO) && !defined(MEDIAINFO_AFDBARDATA_YES)
+ #define MEDIAINFO_AFDBARDATA_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_AVC_NO) && !defined(MEDIAINFO_AVC_YES)
+ #define MEDIAINFO_AVC_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_AVSV_NO) && !defined(MEDIAINFO_AVSV_YES)
+ #define MEDIAINFO_AVSV_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_DIRAC_NO) && !defined(MEDIAINFO_DIRAC_YES)
+ #define MEDIAINFO_DIRAC_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_FLIC_NO) && !defined(MEDIAINFO_FLIC_YES)
+ #define MEDIAINFO_FLIC_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_FRAPS_NO) && !defined(MEDIAINFO_FRAPS_YES)
+ #define MEDIAINFO_FRAPS_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_H263_NO) && !defined(MEDIAINFO_H263_YES)
+ #define MEDIAINFO_H263_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_LAGARITH_NO) && !defined(MEDIAINFO_LAGARITH_YES)
+ #define MEDIAINFO_LAGARITH_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_MPEG4V_NO) && !defined(MEDIAINFO_MPEG4V_YES)
+ #define MEDIAINFO_MPEG4V_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_MPEGV_NO) && !defined(MEDIAINFO_MPEGV_YES)
+ #define MEDIAINFO_MPEGV_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_VC1_NO) && !defined(MEDIAINFO_VC1_YES)
+ #define MEDIAINFO_VC1_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_VC3_NO) && !defined(MEDIAINFO_VC3_YES)
+ #define MEDIAINFO_VC3_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_THEORA_NO) && !defined(MEDIAINFO_THEORA_YES)
+ #define MEDIAINFO_THEORA_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_VP8_NO) && !defined(MEDIAINFO_VP8_YES)
+ #define MEDIAINFO_VP8_YES
+#endif
+#if !defined(MEDIAINFO_VIDEO_NO) && !defined(MEDIAINFO_Y4M_NO) && !defined(MEDIAINFO_Y4M_YES)
+ #define MEDIAINFO_Y4M_YES
+#endif
+
+//---------------------------------------------------------------------------
+// Audio
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_AAC_NO) && !defined(MEDIAINFO_AAC_YES)
+ #define MEDIAINFO_AAC_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_AC3_NO) && !defined(MEDIAINFO_AC3_YES)
+ #define MEDIAINFO_AC3_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_ADPCM_NO) && !defined(MEDIAINFO_ADPCM_YES)
+ #define MEDIAINFO_ADPCM_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_ALS_NO) && !defined(MEDIAINFO_ALS_YES)
+ #define MEDIAINFO_ALS_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_LATM_NO) && !defined(MEDIAINFO_LATM_YES)
+ #define MEDIAINFO_LATM_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_AES3_NO) && !defined(MEDIAINFO_AES3_YES)
+ #define MEDIAINFO_AES3_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_AMR_NO) && !defined(MEDIAINFO_AMR_YES)
+ #define MEDIAINFO_AMR_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_AMV_NO) && !defined(MEDIAINFO_AMV_YES)
+ #define MEDIAINFO_AMV_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_APE_NO) && !defined(MEDIAINFO_APE_YES)
+ #define MEDIAINFO_APE_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_AU_NO) && !defined(MEDIAINFO_AU_YES)
+ #define MEDIAINFO_AU_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_CELT_NO) && !defined(MEDIAINFO_CELT_YES)
+ #define MEDIAINFO_CELT_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_DOLBYE_NO) && !defined(MEDIAINFO_DOLBYE_YES)
+ #define MEDIAINFO_DOLBYE_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_DTS_NO) && !defined(MEDIAINFO_DTS_YES)
+ #define MEDIAINFO_DTS_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_FLAC_NO) && !defined(MEDIAINFO_FLAC_YES)
+ #define MEDIAINFO_FLAC_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_IT_NO) && !defined(MEDIAINFO_IT_YES)
+ #define MEDIAINFO_IT_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_LA_NO) && !defined(MEDIAINFO_LA_YES)
+ #define MEDIAINFO_LA_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_MIDO_NO) && !defined(MEDIAINFO_MIDO_YES)
+ #define MEDIAINFO_MIDI_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_MOD_NO) && !defined(MEDIAINFO_MOD_YES)
+ #define MEDIAINFO_MOD_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_MPC_NO) && !defined(MEDIAINFO_MPC_YES)
+ #define MEDIAINFO_MPC_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_MPCSV8_NO) && !defined(MEDIAINFO_MPCSV8_YES)
+ #define MEDIAINFO_MPCSV8_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_MPEGA_NO) && !defined(MEDIAINFO_MPEGA_YES)
+ #define MEDIAINFO_MPEGA_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_PCM_NO) && !defined(MEDIAINFO_PCM_YES)
+ #define MEDIAINFO_PCM_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_PS2A_NO) && !defined(MEDIAINFO_PS2A_YES)
+ #define MEDIAINFO_PS2A_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_RKAU_NO) && !defined(MEDIAINFO_RKAU_YES)
+ #define MEDIAINFO_RKAU_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_S3M_NO) && !defined(MEDIAINFO_S3M_YES)
+ #define MEDIAINFO_S3M_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_SPEEX_NO) && !defined(MEDIAINFO_SPEEX_YES)
+ #define MEDIAINFO_SPEEX_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_TAK_NO) && !defined(MEDIAINFO_TAK_YES)
+ #define MEDIAINFO_TAK_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_TTA_NO) && !defined(MEDIAINFO_TTA_YES)
+ #define MEDIAINFO_TTA_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_TWINVQ_NO) && !defined(MEDIAINFO_TWINVQ_YES)
+ #define MEDIAINFO_TWINVQ_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_VORBIS_NO) && !defined(MEDIAINFO_VORBIS_YES)
+ #define MEDIAINFO_VORBIS_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_WVPK_NO) && !defined(MEDIAINFO_WVPK_YES)
+ #define MEDIAINFO_WVPK_YES
+#endif
+#if !defined(MEDIAINFO_AUDIO_NO) && !defined(MEDIAINFO_XM_NO) && !defined(MEDIAINFO_XM_YES)
+ #define MEDIAINFO_XM_YES
+#endif
+
+//---------------------------------------------------------------------------
+// Text
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_CDP_NO) && !defined(MEDIAINFO_CDP_YES)
+ #define MEDIAINFO_CDP_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_CMML_NO) && !defined(MEDIAINFO_CMML_YES)
+ #define MEDIAINFO_CMML_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_DVBSUBTITLE_NO) && !defined(MEDIAINFO_DVBSUBTITLE_YES)
+ #define MEDIAINFO_DVBSUBTITLE_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_DTVCCTRANSPORT_NO) && !defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ #define MEDIAINFO_DTVCCTRANSPORT_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_EIA608_NO) && !defined(MEDIAINFO_EIA608_YES)
+ #define MEDIAINFO_EIA608_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_EIA708_NO) && !defined(MEDIAINFO_EIA708_YES)
+ #define MEDIAINFO_EIA708_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_N19_NO) && !defined(MEDIAINFO_N19_YES)
+ #define MEDIAINFO_N19_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_KATE_NO) && !defined(MEDIAINFO_KATE_YES)
+ #define MEDIAINFO_KATE_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_PGS_NO) && !defined(MEDIAINFO_PGS_YES)
+ #define MEDIAINFO_PGS_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_SCC_NO) && !defined(MEDIAINFO_SCC_YES)
+ #define MEDIAINFO_SCC_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_SCTE20_NO) && !defined(MEDIAINFO_SCTE20_YES)
+ #define MEDIAINFO_SCTE20_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_TELETEXT_NO) && !defined(MEDIAINFO_TELETEXT_YES)
+ #define MEDIAINFO_TELETEXT_YES
+#endif
+#if !defined(MEDIAINFO_TEXT_NO) && !defined(MEDIAINFO_OTHERTEXT_NO) && !defined(MEDIAINFO_OTHERTEXT_YES)
+ #define MEDIAINFO_OTHERTEXT_YES
+#endif
+
+//---------------------------------------------------------------------------
+// Image
+#if !defined(MEDIAINFO_IMAGE_NO) && !defined(MEDIAINFO_BMP_NO) && !defined(MEDIAINFO_BMP_YES)
+ #define MEDIAINFO_BMP_YES
+#endif
+#if !defined(MEDIAINFO_IMAGE_NO) && !defined(MEDIAINFO_DPX_NO) && !defined(MEDIAINFO_DPX_YES)
+ #define MEDIAINFO_DPX_YES
+#endif
+#if !defined(MEDIAINFO_IMAGE_NO) && !defined(MEDIAINFO_EXR_NO) && !defined(MEDIAINFO_EXR_YES)
+ #define MEDIAINFO_EXR_YES
+#endif
+#if !defined(MEDIAINFO_IMAGE_NO) && !defined(MEDIAINFO_GIF_NO) && !defined(MEDIAINFO_GIF_YES)
+ #define MEDIAINFO_GIF_YES
+#endif
+#if !defined(MEDIAINFO_IMAGE_NO) && !defined(MEDIAINFO_ICO_NO) && !defined(MEDIAINFO_ICO_YES)
+ #define MEDIAINFO_ICO_YES
+#endif
+#if !defined(MEDIAINFO_IMAGE_NO) && !defined(MEDIAINFO_JPEG_NO) && !defined(MEDIAINFO_JPEG_YES)
+ #define MEDIAINFO_JPEG_YES
+#endif
+#if !defined(MEDIAINFO_IMAGE_NO) && !defined(MEDIAINFO_PNG_NO) && !defined(MEDIAINFO_PNG_YES)
+ #define MEDIAINFO_PNG_YES
+#endif
+#if !defined(MEDIAINFO_IMAGE_NO) && !defined(MEDIAINFO_RLE_NO) && !defined(MEDIAINFO_RLE_YES)
+ #define MEDIAINFO_RLE_YES
+#endif
+#if !defined(MEDIAINFO_IMAGE_NO) && !defined(MEDIAINFO_TIFF_NO) && !defined(MEDIAINFO_TIFF_YES)
+ #define MEDIAINFO_TIFF_YES
+#endif
+#if !defined(MEDIAINFO_IMAGE_NO) && !defined(MEDIAINFO_TGA_NO) && !defined(MEDIAINFO_TGA_YES)
+ #define MEDIAINFO_TGA_YES
+#endif
+
+//---------------------------------------------------------------------------
+// Archive
+#if !defined(MEDIAINFO_ARCHIVE_NO) && !defined(MEDIAINFO_7Z_NO) && !defined(MEDIAINFO_7Z_YES)
+ #define MEDIAINFO_7Z_YES
+#endif
+#if !defined(MEDIAINFO_ARCHIVE_NO) && !defined(MEDIAINFO_ACE_NO) && !defined(MEDIAINFO_ACE_YES)
+ #define MEDIAINFO_ACE_YES
+#endif
+#if !defined(MEDIAINFO_ARCHIVE_NO) && !defined(MEDIAINFO_BZIP2_NO) && !defined(MEDIAINFO_BZIP2_YES)
+ #define MEDIAINFO_BZIP2_YES
+#endif
+#if !defined(MEDIAINFO_ARCHIVE_NO) && !defined(MEDIAINFO_ELF_NO) && !defined(MEDIAINFO_ELF_YES)
+ #define MEDIAINFO_ELF_YES
+#endif
+#if !defined(MEDIAINFO_ARCHIVE_NO) && !defined(MEDIAINFO_GZIP_NO) && !defined(MEDIAINFO_GZIP_YES)
+ #define MEDIAINFO_GZIP_YES
+#endif
+#if !defined(MEDIAINFO_ARCHIVE_NO) && !defined(MEDIAINFO_ISO9660_NO) && !defined(MEDIAINFO_ISO9660_YES)
+ #define MEDIAINFO_ISO9660_YES
+#endif
+#if !defined(MEDIAINFO_ARCHIVE_NO) && !defined(MEDIAINFO_MZ_NO) && !defined(MEDIAINFO_MZ_YES)
+ #define MEDIAINFO_MZ_YES
+#endif
+#if !defined(MEDIAINFO_ARCHIVE_NO) && !defined(MEDIAINFO_RAR_NO) && !defined(MEDIAINFO_RAR_YES)
+ #define MEDIAINFO_RAR_YES
+#endif
+#if !defined(MEDIAINFO_ARCHIVE_NO) && !defined(MEDIAINFO_TAR_NO) && !defined(MEDIAINFO_TAR_YES)
+ #define MEDIAINFO_TAR_YES
+#endif
+#if !defined(MEDIAINFO_ARCHIVE_NO) && !defined(MEDIAINFO_ZIP_NO) && !defined(MEDIAINFO_ZIP_YES)
+ #define MEDIAINFO_ZIP_YES
+#endif
+
+//---------------------------------------------------------------------------
+// Tag
+#if !defined(MEDIAINFO_TAG_NO) && !defined(MEDIAINFO_TAG_NO) && !defined(MEDIAINFO_TAG_YES)
+ #define MEDIAINFO_TAG_YES
+#endif
+#if !defined(MEDIAINFO_TAG_NO) && !defined(MEDIAINFO_APETAG_NO) && !defined(MEDIAINFO_APETAG_YES)
+ #define MEDIAINFO_APETAG_YES
+#endif
+#if !defined(MEDIAINFO_TAG_NO) && !defined(MEDIAINFO_ID3_NO) && !defined(MEDIAINFO_ID3_YES)
+ #define MEDIAINFO_ID3_YES
+#endif
+#if !defined(MEDIAINFO_TAG_NO) && !defined(MEDIAINFO_ID3V2_NO) && !defined(MEDIAINFO_ID3V2_YES)
+ #define MEDIAINFO_ID3V2_YES
+#endif
+#if !defined(MEDIAINFO_TAG_NO) && !defined(MEDIAINFO_LYRICS3_NO) && !defined(MEDIAINFO_LYRICS3_YES)
+ #define MEDIAINFO_LYRICS3_YES
+#endif
+#if !defined(MEDIAINFO_TAG_NO) && !defined(MEDIAINFO_LYRICS3V2_NO) && !defined(MEDIAINFO_LYRICS3V2_YES)
+ #define MEDIAINFO_LYRICS3V2_YES
+#endif
+#if !defined(MEDIAINFO_TAG_NO) && !defined(MEDIAINFO_VORBISCOM_NO) && !defined(MEDIAINFO_VORBISCOM_YES)
+ #define MEDIAINFO_VORBISCOM_YES
+#endif
+
+//---------------------------------------------------------------------------
+// Other
+#if !defined(MEDIAINFO_DUMMY_NO)
+ //#define MEDIAINFO_DUMMY_YES
+#endif
+#if !defined(MEDIAINFO_OTHER_NO)
+ #define MEDIAINFO_OTHER_YES
+#endif
+#if !defined(MEDIAINFO_UNKNOWN_NO)
+ #define MEDIAINFO_UNKNOWN_YES
+#endif
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_ApeTag.cpp b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_ApeTag.cpp
new file mode 100644
index 000000000..aa0efa059
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_ApeTag.cpp
@@ -0,0 +1,214 @@
+// File_ApeTag - Info for ApeTag tagged files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_APETAG_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Tag/File_ApeTag.h"
+#include <algorithm>
+#include <ctime>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_ApeTag::FileHeader_Parse()
+{
+ //Parsing
+ int64u Signature;
+ Peek_B8(Signature);
+ if (Signature==0x4150455441474558LL) //"APETAGEX"
+ HeaderFooter(); //v2
+
+ FILLING_BEGIN();
+ Accept("ApeTag");
+
+ Stream_Prepare(Stream_General);
+
+ Stream_Prepare(Stream_Audio);
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_ApeTag::Header_Begin()
+{
+ if (Buffer_Size<0x20)
+ return false; //At least 32 bytes are needed for footer
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_ApeTag::Header_Parse()
+{
+ //Testing if begin or end of tags
+ if (CC8(Buffer+Buffer_Offset)==0x4150455441474558LL) //"APETAGEX"
+ {
+ //Filling
+ Header_Fill_Code((int64u)-1, "File Footer");
+ Header_Fill_Size(0x20);
+ return;
+ }
+
+ //Parsing
+ Ztring Value;
+ int32u Flags, Length;
+ Get_L4 (Length, "Length");
+ Get_L4 (Flags, "Flags");
+ Skip_Flags(Flags, 0, "Read Only");
+ Skip_Flags(Flags, 1, "Binary");
+ Skip_Flags(Flags, 2, "Locator of external stored information");
+ Skip_Flags(Flags, 29, "Is the header");
+ Skip_Flags(Flags, 30, "Contains a footer");
+ Skip_Flags(Flags, 31, "Contains a header");
+ size_t Pos=(size_t)Element_Offset;
+ for (; Pos<Element_Size; Pos++)
+ if (Buffer[Buffer_Offset+Pos]==0x00)
+ break;
+ if (Pos==Element_Size)
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ Get_String(Pos-Element_Offset, Key, "Key");
+ Skip_L1( "0x00");
+
+ //Filling
+ Header_Fill_Code(0, Key.c_str());
+ Header_Fill_Size(Element_Offset+Length);
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_ApeTag::HeaderFooter()
+{
+ //Parsing
+ int32u Flags;
+ Skip_C8( "Preamble");
+ Skip_L4( "Version");
+ Skip_L4( "Size");
+ Skip_L4( "Count");
+ Get_L4 (Flags, "Flags");
+ Skip_Flags(Flags, 0, "Read Only");
+ Skip_Flags(Flags, 1, "Binary");
+ Skip_Flags(Flags, 2, "Locator of external stored information");
+ Skip_Flags(Flags, 29, "Is the header");
+ Skip_Flags(Flags, 30, "Contains a footer");
+ Skip_Flags(Flags, 31, "Contains a header");
+ Skip_L8( "Reserved");
+}
+
+//---------------------------------------------------------------------------
+void File_ApeTag::Data_Parse()
+{
+ //If footer
+ if (Element_Code==(int64u)-1)
+ {
+ HeaderFooter();
+ Finish("ApeTag");
+ return;
+ }
+
+ //Parsing
+ Ztring Value;
+ Get_UTF8(Element_Size, Value, "Value"); Element_Info1(Value);
+
+ //Filling
+ transform(Key.begin(), Key.end(), Key.begin(), (int(*)(int))toupper); //(int(*)(int)) is a patch for unix
+ if (Key=="ALBUM") Fill(Stream_General, 0, General_Album, Value);
+ else if (Key=="ARTIST") Fill(Stream_General, 0, General_Performer, Value);
+ else if (Key=="AUTHOR") Fill(Stream_General, 0, General_WrittenBy, Value);
+ else if (Key=="BAND") Fill(Stream_General, 0, General_Performer, Value);
+ else if (Key=="COMMENT") Fill(Stream_General, 0, General_Comment, Value);
+ else if (Key=="COMMENTS") Fill(Stream_General, 0, General_Comment, Value);
+ else if (Key=="COMPOSER") Fill(Stream_General, 0, General_Composer, Value);
+ else if (Key=="CONTENTGROUP") Fill(Stream_General, 0, General_Genre, Value);
+ else if (Key=="COPYRIGHT") Fill(Stream_General, 0, General_Copyright, Value);
+ else if (Key=="DISK")
+ {
+ if (Value.find(_T("/"))!=Error)
+ {
+ Fill(Stream_General, 0, General_Part_Position_Total, Value.SubString(_T("/"), _T("")));
+ Fill(Stream_General, 0, General_Part_Position, Value.SubString(_T(""), _T("/")));
+ }
+ else
+ Fill(Stream_General, 0, General_Track_Position, Value);
+ }
+ else if (Key=="ENCODEDBY") Fill(Stream_General, 0, General_EncodedBy, Value);
+ else if (Key=="GENRE") Fill(Stream_General, 0, General_Genre, Value);
+ else if (Key=="ORIGARTIST") Fill(Stream_General, 0, General_Original_Performer, Value);
+ else if (Key=="TITLE") Fill(Stream_General, 0, General_Title, Value);
+ else if (Key=="TRACK")
+ {
+ if (Value.find(_T("/"))!=Error)
+ {
+ Fill(Stream_General, 0, General_Track_Position_Total, Value.SubString(_T("/"), _T("")));
+ Fill(Stream_General, 0, General_Track_Position, Value.SubString(_T(""), _T("/")));
+ }
+ else
+ Fill(Stream_General, 0, General_Track_Position, Value);
+ }
+ else if (Key=="UNSYNCEDLYRICS") Fill(Stream_General, 0, General_Lyrics, Value);
+ else if (Key=="WWW") Fill(Stream_General, 0, General_Title_Url, Value);
+ else if (Key=="YEAR") Fill(Stream_General, 0, General_Recorded_Date, Value);
+ else if (Key=="CONTENT GROUP DESCRIPTION") Fill(Stream_General, 0, General_Title, Value);
+ else if (Key=="ORIGINAL ALBUM/MOVIE/SHOW TITLE") Fill(Stream_General, 0, General_Original_Album, Value);
+ else if (Key=="ORIGINAL ARTIST(S)/PERFORMER(S)") Fill(Stream_General, 0, General_Original_Performer, Value);
+ else if (Key=="MP3GAIN_MINMAX") Fill(Stream_Audio, 0, "MP3Gain, Min/Max", Value);
+ else if (Key=="MP3GAIN_UNDO") Fill(Stream_Audio, 0, "MP3Gain, Undo", Value);
+ else if (Key=="REPLAYGAIN_TRACK_GAIN") Fill(Stream_Audio, 0, Audio_ReplayGain_Gain, Value.To_float64(), 2, true);
+ else if (Key=="REPLAYGAIN_TRACK_PEAK") Fill(Stream_Audio, 0, Audio_ReplayGain_Peak, Value.To_float64(), 6, true);
+ else Fill(Stream_General, 0, Key.c_str(), Value);
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_APETAG_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_ApeTag.h b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_ApeTag.h
new file mode 100644
index 000000000..b08781be6
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_ApeTag.h
@@ -0,0 +1,60 @@
+// File_ApeTag - Info for APETAG tagged files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about APETAG tagged files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_ApeTagH
+#define MediaInfo_File_ApeTagH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_ApeTag
+//***************************************************************************
+
+class File_ApeTag : public File__Analyze
+{
+private :
+ //Buffer - File header
+ void FileHeader_Parse();
+
+ //Buffer - Per element
+ bool Header_Begin();
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void HeaderFooter();
+
+ //Temp
+ std::string Key;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3.cpp b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3.cpp
new file mode 100644
index 000000000..ff115fab7
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3.cpp
@@ -0,0 +1,140 @@
+// File_Id3 - Info for ID3 tagged files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_ID3_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Tag/File_Id3.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Id3::Read_Buffer_Continue()
+{
+ //Buffer size
+ if (Buffer_Size<128)
+ return;
+
+ int32u Magic;
+ Peek_B4(Magic);
+ Ztring TitleAddition;
+ Ztring ArtistAddition;
+ Ztring AlbumAddition;
+ Ztring GenreAddition;
+ if (Magic==0x5441472B)
+ {
+ if (Buffer_Size<227+128)
+ return;
+
+ Skip_C4 ( "ID");
+ Get_Local (60, TitleAddition, "Title");
+ Get_Local (60, ArtistAddition, "Artist");
+ Get_Local (60, AlbumAddition, "Album");
+ Skip_B1 ( "Speed");
+ Get_Local (30, GenreAddition, "Genre");
+ Skip_Local(6, "Start time"); //mmm:ss
+ Skip_Local(6, "End time"); //mmm:ss
+
+ TitleAddition.TrimRight();
+ ArtistAddition.TrimRight();
+ AlbumAddition.TrimRight();
+ GenreAddition.TrimRight();
+ }
+
+ //Parsing
+ Ztring Title, Artist, Album, Year, Comment;
+ int8u Track=0, Genre;
+ Skip_C3 ( "ID");
+ Get_Local (30, Title, "Title");
+ Get_Local (30, Artist, "Artist");
+ Get_Local (30, Album, "Album");
+ Get_Local ( 4, Year, "Year");
+ Get_Local (30, Comment, "Comment");
+ if (Comment.size()<29) //Id3v1.1 specifications : Track number addition
+ {
+ Element_Offset-=2;
+ int8u Zero;
+ Peek_B1(Zero);
+ if (Zero==0)
+ {
+ Skip_B1( "Zero");
+ Get_B1 (Track, "Track");
+ }
+ else
+ Element_Offset+=2;
+ }
+ Get_B1 (Genre, "Genre");
+
+ FILLING_BEGIN();
+ if (TitleAddition.empty())
+ Title.TrimRight();
+ if (ArtistAddition.empty())
+ Artist.TrimRight();
+ if (AlbumAddition.empty())
+ Album.TrimRight();
+ Year.TrimRight();
+ Comment.TrimRight();
+
+ Accept("Id3");
+
+ Stream_Prepare(Stream_General);
+ Fill(Stream_General, 0, General_Album, Album+AlbumAddition);
+ Fill(Stream_General, 0, General_Track, Title+TitleAddition);
+ Fill(Stream_General, 0, General_Performer, Artist+ArtistAddition);
+ Fill(Stream_General, 0, General_Comment, Comment);
+ Fill(Stream_General, 0, General_Recorded_Date, Year);
+ if (GenreAddition.empty())
+ Fill(Stream_General, 0, General_Genre, GenreAddition);
+ if (Genre && Genre!=(int8u)-1)
+ Fill(Stream_General, 0, General_Genre, Genre);
+ if (Track)
+ Fill(Stream_General, 0, General_Track_Position, Track);
+
+ Finish("Id3");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_ID3_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3.h b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3.h
new file mode 100644
index 000000000..26ab81092
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3.h
@@ -0,0 +1,49 @@
+// File_Id3 - Info for Id3 tagged files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about ID3 tagged files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Id3H
+#define MediaInfo_File_Id3H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Id3
+//***************************************************************************
+
+class File_Id3 : public File__Analyze
+{
+private :
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3v2.cpp b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3v2.cpp
new file mode 100644
index 000000000..11c0cb964
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3v2.cpp
@@ -0,0 +1,1350 @@
+// File_Id3 - Info for ID3v2 tagged files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos (Common)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_ID3V2_YES) || defined(MEDIAINFO_FLAC_YES) || defined(MEDIAINFO_VORBISCOM_YES) || defined(MEDIAINFO_OGG_YES)
+//---------------------------------------------------------------------------
+
+#include "ZenLib/Conf.h"
+using namespace ZenLib;
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+extern const char* Id3v2_PictureType(int8u Type)
+{
+ switch (Type)
+ {
+ case 0x01 :
+ case 0x02 : return "File icon";
+ case 0x03 : return "Cover (front)";
+ case 0x04 : return "Cover (back)";
+ case 0x05 : return "Leaflet page";
+ case 0x06 : return "Media";
+ case 0x07 :
+ case 0x08 : return "Performer";
+ case 0x09 : return "Conductor";
+ case 0x0A : return "Performer";
+ case 0x0B : return "Composer";
+ case 0x0C : return "Lyricist";
+ case 0x0D : return "Recording Location";
+ case 0x0E : return "During recording";
+ case 0x0F : return "During performance";
+ case 0x10 : return "Screen capture";
+ case 0x12 : return "Illustration";
+ case 0x13 : return "Performer logo";
+ case 0x14 : return "Publisher logo";
+ default : return "";
+ }
+}
+
+} //NameSpace
+
+//---------------------------------------------------------------------------
+#endif //...
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+//
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_ID3V2_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Tag/File_Id3v2.h"
+#include "ZenLib/ZtringListList.h"
+#include "ZenLib/Utils.h"
+#include "base64.h"
+#include <cstring>
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Id3v2_TextEnc[]=
+{
+ "ISO 8859-1",
+ "UTF-16",
+ "UTF-16BE",
+ "UTF-8",
+};
+
+//---------------------------------------------------------------------------
+const char* Id3v2_RGAD_Name_code[]=
+{
+ "",
+ "Radio Gain Adjustment",
+ "Audiophile Gain Adjustment",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Id3v2_RGAD_Originator_code[]=
+{
+ "",
+ "Pre-set by artist/producer/mastering engineer",
+ "Set by user",
+ "Determined automatically",
+ "",
+ "",
+ "",
+ "",
+};
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+namespace Elements
+{
+ const int32u AENC=0x41454E47;
+ const int32u APIC=0x41504943;
+ const int32u ASPI=0x41535049;
+ const int32u COMM=0x434F4D4D;
+ const int32u COMR=0x434F4D52;
+ const int32u ENCR=0x454E4352;
+ const int32u EQU2=0x45515532;
+ const int32u EQUA=0x45515541;
+ const int32u ETCO=0x4554434F;
+ const int32u GEOB=0x47454F42;
+ const int32u GRID=0x47524944;
+ const int32u IPLS=0x49504C53;
+ const int32u LINK=0x4C494E4B;
+ const int32u MCDI=0x4D434449;
+ const int32u MLLT=0x4D4C4C54;
+ const int32u OWNE=0x4F574E45;
+ const int32u PCNT=0x50434E58;
+ const int32u POPM=0x504F504D;
+ const int32u POSS=0x504F5353;
+ const int32u PRIV=0x50524956;
+ const int32u RBUF=0x52425546;
+ const int32u RGAD=0x52474144;
+ const int32u RVA2=0x52564132;
+ const int32u RVRB=0x52565242;
+ const int32u SEEK=0x5345454B;
+ const int32u SIGN=0x5349474E;
+ const int32u SYLT=0x53594C54;
+ const int32u SYTC=0x53595443;
+ const int32u TALB=0x54414C42;
+ const int32u TBPM=0x5442504D;
+ const int32u TCMP=0x54434D50;
+ const int32u TCOM=0x54434F4D;
+ const int32u TCON=0x54434F4E;
+ const int32u TCOP=0x54434F50;
+ const int32u TDAT=0x54444154;
+ const int32u TDEN=0x5444454E;
+ const int32u TDLY=0x54444C59;
+ const int32u TDOR=0x54444F52;
+ const int32u TDRC=0x54445243;
+ const int32u TDRL=0x5444524C;
+ const int32u TDTG=0x54445447;
+ const int32u TENC=0x54454E43;
+ const int32u TEXT=0x54455854;
+ const int32u TFLT=0x54464C54;
+ const int32u TIME=0x54494D45;
+ const int32u TIPL=0x5449504C;
+ const int32u TIT1=0x54495431;
+ const int32u TIT2=0x54495432;
+ const int32u TIT3=0x54495433;
+ const int32u TKEY=0x544B4559;
+ const int32u TLAN=0x544C414E;
+ const int32u TLEN=0x544C454E;
+ const int32u TMCL=0x544D434C;
+ const int32u TMED=0x544D4544;
+ const int32u TMOO=0x544D4F4F;
+ const int32u TOAL=0x544F414C;
+ const int32u TOFN=0x544F464E;
+ const int32u TOLY=0x544F4C59;
+ const int32u TOPE=0x544F5045;
+ const int32u TORY=0x544F5259;
+ const int32u TOWN=0x544F574E;
+ const int32u TPE1=0x54504531;
+ const int32u TPE2=0x54504532;
+ const int32u TPE3=0x54504533;
+ const int32u TPE4=0x54504534;
+ const int32u TPOS=0x54504F53;
+ const int32u TPRO=0x5450524F;
+ const int32u TPUB=0x54505542;
+ const int32u TRCK=0x5452434B;
+ const int32u TRDA=0x54524441;
+ const int32u TRSN=0x5452534E;
+ const int32u TRSO=0x5452534F;
+ const int32u TSIZ=0x5453495A;
+ const int32u TSO2=0x54534F32;
+ const int32u TSOA=0x54534F41;
+ const int32u TSOC=0x54534F43;
+ const int32u TSOP=0x54534F50;
+ const int32u TSOT=0x54534F54;
+ const int32u TSRC=0x54535243;
+ const int32u TSSE=0x54535345;
+ const int32u TSST=0x54535354;
+ const int32u TXXX=0x54585858;
+ const int32u TYER=0x54594552;
+ const int32u UFID=0x55464944;
+ const int32u USER=0x55534552;
+ const int32u USLT=0x55534C54;
+ const int32u WCOM=0x57434F4D;
+ const int32u WCOP=0x57434F50;
+ const int32u WOAF=0x574F4146;
+ const int32u WOAR=0x574F4152;
+ const int32u WOAS=0x574F4153;
+ const int32u WORS=0x574F5253;
+ const int32u WPAY=0x57504159;
+ const int32u WPUB=0x57505542;
+ const int32u WXXX=0x57585858;
+ const int32u XRVA=0x58525641;
+ const int32u BUF=0x425546;
+ const int32u CNT=0x434E56;
+ const int32u COM=0x434F4D;
+ const int32u CRA=0x435241;
+ const int32u CRM=0x43524D;
+ const int32u EQU=0x455155;
+ const int32u ETC=0x455443;
+ const int32u GEO=0x47454F;
+ const int32u IPL=0x49504C;
+ const int32u LNK=0x4C4E4B;
+ const int32u MCI=0x4D4349;
+ const int32u MLL=0x4D4C4C;
+ const int32u PIC_=0x504943; //PIC is used by shared libs in GCC
+ const int32u POP=0x504F50;
+ const int32u REV=0x524556;
+ const int32u RVA=0x525641;
+ const int32u SLT=0x534C54;
+ const int32u STC=0x535443;
+ const int32u TAL=0x54414C;
+ const int32u TBP=0x544250;
+ const int32u TCM=0x54434D;
+ const int32u TCO=0x54434F;
+ const int32u TCP=0x544350;
+ const int32u TCR=0x544352;
+ const int32u TDA=0x544441;
+ const int32u TDY=0x544459;
+ const int32u TEN=0x54454E;
+ const int32u TFT=0x544654;
+ const int32u TIM=0x54494D;
+ const int32u TKE=0x544B45;
+ const int32u TLA=0x544C41;
+ const int32u TLE=0x544C45;
+ const int32u TMT=0x544D54;
+ const int32u TOA=0x544F41;
+ const int32u TOF=0x544F46;
+ const int32u TOL=0x544F4C;
+ const int32u TOR=0x544F52;
+ const int32u TOT=0x544F54;
+ const int32u TP1=0x545031;
+ const int32u TP2=0x545032;
+ const int32u TP3=0x545033;
+ const int32u TP4=0x545034;
+ const int32u TPA=0x545041;
+ const int32u TPB=0x545042;
+ const int32u TRC=0x545243;
+ const int32u TRD=0x545244;
+ const int32u TRK=0x54524B;
+ const int32u TSI=0x545349;
+ const int32u TSS=0x545353;
+ const int32u TT1=0x545431;
+ const int32u TT2=0x545432;
+ const int32u TT3=0x545433;
+ const int32u TXT=0x545854;
+ const int32u TXX=0x545858;
+ const int32u TYE=0x545945;
+ const int32u UFI=0x554649;
+ const int32u ULT=0x554C54;
+ const int32u WAF=0x574146;
+ const int32u WAR=0x574152;
+ const int32u WAS=0x574153;
+ const int32u WCM=0x57434D;
+ const int32u WCP=0x574350;
+ const int32u WPB=0x575042;
+ const int32u WXX=0x575858;
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Id3v2::File_Id3v2()
+:File__Analyze()
+{
+ //Configuration
+ Buffer_MaximumSize=8*1024*1024;
+
+ //Temp
+ Id3v2_Size=0;
+}
+
+//***************************************************************************
+// Static stuff
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Id3v2::Static_Synchronize_Tags(const int8u* Buffer, size_t Buffer_Offset, size_t Buffer_Size, bool &Tag_Found)
+{
+ //Buffer size
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ //ID
+ Tag_Found=CC3(Buffer+Buffer_Offset)==0x494433; //"ID3"
+
+ //Continue
+ return true;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Id3v2::Streams_Fill()
+{
+ if (Count_Get(Stream_General)==0)
+ return;
+
+ //Specific formats (multiple Id3v2 tags for one MI tag)
+ if (Retrieve(Stream_General, 0, General_Recorded_Date).empty() && !Year.empty())
+ {
+ Ztring Recorded_Date=Year;
+ if (!Month.empty())
+ {
+ Recorded_Date+=_T('-');
+ Recorded_Date+=Month;
+ if (!Day.empty())
+ {
+ Recorded_Date+=_T('-');
+ Recorded_Date+=Day;
+ if (!Hour.empty())
+ {
+ Recorded_Date+=_T(' ');
+ Recorded_Date+=Hour;
+ if (Minute.empty())
+ {
+ Recorded_Date+=_T(':');
+ Recorded_Date+=Minute;
+ }
+ }
+ }
+ }
+ Fill(Stream_General, 0, General_Recorded_Date, Recorded_Date);
+ }
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Id3v2::FileHeader_Parse()
+{
+ //Parsing
+ int32u Size;
+ int8u Flags;
+ bool ExtendedHeader;
+ Skip_C3( "identifier");
+ Get_B1 (Id3v2_Version, "version_major");
+ Skip_B1( "version_revision");
+ Get_B1 (Flags, "flags");
+ Get_Flags (Flags, 7, Unsynchronisation_Global, "Unsynchronisation");
+ Get_Flags (Flags, 6, ExtendedHeader, "Extended header");
+ Skip_Flags(Flags, 5, "Experimental indicator");
+ Get_B4 (Size, "Size");
+ Id3v2_Size=((Size>>0)&0x7F)
+ | ((Size>>1)&0x3F80)
+ | ((Size>>2)&0x1FC000)
+ | ((Size>>3)&0x0FE00000);
+ Param_Info1(Id3v2_Size);
+ if (ExtendedHeader)
+ {
+ Element_Begin1("Extended header");
+ int32u Size_Extended;
+ Get_B4 (Size_Extended, "Size");
+ Skip_XX(Size_Extended, "Extended header");
+ Element_End0();
+ }
+
+ FILLING_BEGIN();
+ //Versions
+ switch (Id3v2_Version)
+ {
+ case 2 : break;
+ case 3 : break;
+ case 4 : break;
+ default :
+ Skip_XX(Id3v2_Size, "Data");
+ return;
+ }
+
+ Accept("Id3v2");
+ Stream_Prepare(Stream_General);
+
+ Stream_Prepare(Stream_Audio);
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Id3v2::Header_Parse()
+{
+ Unsynchronisation_Frame=false;
+ DataLengthIndicator=false;
+
+ if (Id3v2_Size<10) //first 10 is minimum size of a tag, Second 10 is ID3v2 header size
+ {
+ //Not enough place for a tag, must be padding
+ Header_Fill_Code((int64u)-1, "Padding");
+ Header_Fill_Size(Id3v2_Size);
+ return;
+ }
+
+ if (Buffer_Offset+10>Buffer_Size)
+ {
+ Element_WaitForMoreData();
+ return; //Not enough buffer
+ }
+
+ //Testing padding
+ int32u Frame_ID, Size;
+ Frame_ID=CC1(Buffer+Buffer_Offset);
+ if (Frame_ID==0x00)
+ {
+ //This is the padding
+ Header_Fill_Code(0xFFFFFFFF, "Padding");
+ Header_Fill_Size(Id3v2_Size);
+ return;
+ }
+
+ //Parsing
+ if (Id3v2_Version==2)
+ {
+ Get_C3 (Frame_ID, "Frame ID");
+ Get_B3 (Size, "Size");
+ }
+ else
+ {
+ int16u Flags;
+ Get_C4 (Frame_ID, "Frame ID");
+ Get_B4 (Size, "Size");
+ if (Id3v2_Version!=3)
+ {
+ Size=((Size>>0)&0x7F)
+ | ((Size>>1)&0x3F80)
+ | ((Size>>2)&0x1FC000)
+ | ((Size>>3)&0x0FE00000);
+ Param_Info2(Size, " bytes");
+ }
+ Get_B2 (Flags, "Flags");
+ if (Id3v2_Version==3)
+ {
+ Skip_Flags(Flags, 15, "Tag alter preservation");
+ Skip_Flags(Flags, 14, "File alter preservation");
+ Skip_Flags(Flags, 13, "Read only");
+ Skip_Flags(Flags, 7, "Compression");
+ Skip_Flags(Flags, 6, "Encryption");
+ Skip_Flags(Flags, 5, "Grouping identity");
+ }
+ if (Id3v2_Version==4)
+ {
+ Skip_Flags(Flags, 14, "Tag alter preservation");
+ Skip_Flags(Flags, 13, "File alter preservation");
+ Skip_Flags(Flags, 12, "Read only");
+ Skip_Flags(Flags, 6, "Grouping identity");
+ Skip_Flags(Flags, 3, "Compression");
+ Skip_Flags(Flags, 2, "Encryption");
+ Get_Flags (Flags, 1, Unsynchronisation_Frame, "Unsynchronisation");
+ Get_Flags (Flags, 0, DataLengthIndicator, "Data length indicator");
+ }
+ }
+
+ //Filling
+ Ztring ToShow;
+ if (Id3v2_Version==2)
+ ToShow.From_CC3(Frame_ID);
+ else
+ ToShow.From_CC4(Frame_ID);
+ Header_Fill_Code(Frame_ID, ToShow);
+ Header_Fill_Size(Element_Offset+Size);
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::Data_Parse()
+{
+ Id3v2_Size-=Header_Size+Element_Size;
+
+ int32u DataLength=(int32u)-1;
+ if (DataLengthIndicator)
+ {
+ Get_B4 (DataLength, "Data length");
+ DataLength=((DataLength>>0)&0x7F)
+ | ((DataLength>>1)&0x3F80)
+ | ((DataLength>>2)&0x1FC000)
+ | ((DataLength>>3)&0x0FE00000);
+ Param_Info2(DataLength, " bytes");
+ }
+
+ //Unsynchronisation
+ int8u* Buffer_Unsynch=NULL;
+ const int8u* Save_Buffer=Buffer;
+ int64u Save_File_Offset=File_Offset;
+ size_t Save_Buffer_Offset=Buffer_Offset;
+ int64u Save_Element_Size=Element_Size;
+ int64u Element_Offset_Unsynch=Element_Offset;
+ std::vector<size_t> Unsynch_List;
+ if (Unsynchronisation_Global || Unsynchronisation_Frame)
+ {
+ while (Element_Offset_Unsynch+2<Element_Size)
+ {
+ if (CC2(Buffer+Buffer_Offset+(size_t)Element_Offset_Unsynch)==0xFF00)
+ Unsynch_List.push_back((size_t)(Element_Offset_Unsynch+1));
+ Element_Offset_Unsynch++;
+ }
+ if (DataLength!=(int32u)-1 && 4+DataLength!=Element_Size-Unsynch_List.size())
+ {
+ Skip_XX(Element_Size-Element_Offset, "Size coherency issue");
+ return;
+ }
+ if (!Unsynch_List.empty())
+ {
+ //We must change the buffer for keeping out
+ File_Offset=Save_File_Offset+Buffer_Offset;
+ Element_Size=Save_Element_Size-Unsynch_List.size();
+ Buffer_Offset=0;
+ Buffer_Unsynch=new int8u[(size_t)Element_Size];
+ for (size_t Pos=0; Pos<=Unsynch_List.size(); Pos++)
+ {
+ size_t Pos0=(Pos==Unsynch_List.size())?(size_t)Save_Element_Size:(Unsynch_List[Pos]);
+ size_t Pos1=(Pos==0)?0:(Unsynch_List[Pos-1]+1);
+ size_t Buffer_Unsynch_Begin=Pos1-Pos;
+ size_t Save_Buffer_Begin =Pos1;
+ size_t Size= Pos0-Pos1;
+ std::memcpy(Buffer_Unsynch+Buffer_Unsynch_Begin, Save_Buffer+Save_Buffer_Offset+Save_Buffer_Begin, Size);
+ }
+ Buffer=Buffer_Unsynch;
+ }
+ }
+
+ #define CASE_INFO(_NAME, _DETAIL) \
+ case Elements::_NAME : Element_Info1(_DETAIL); _NAME(); break;
+
+ //Parsing
+ Element_Value.clear();
+ Element_Values.clear();
+ switch (Element_Code)
+ {
+ CASE_INFO(AENC, "Audio encryption");
+ CASE_INFO(APIC, "Attached picture");
+ CASE_INFO(ASPI, "Audio seek point index");
+ CASE_INFO(COMM, "Comments");
+ CASE_INFO(COMR, "Commercial frame");
+ CASE_INFO(ENCR, "Encryption method registration");
+ CASE_INFO(EQU2, "Equalisation (2)");
+ CASE_INFO(EQUA, "Equalization");
+ CASE_INFO(ETCO, "Event timing codes");
+ CASE_INFO(GEOB, "General encapsulated object");
+ CASE_INFO(GRID, "Group identification registration");
+ CASE_INFO(IPLS, "Involved people list");
+ CASE_INFO(LINK, "Linked information");
+ CASE_INFO(MCDI, "Music CD identifier");
+ CASE_INFO(MLLT, "MPEG location lookup table");
+ CASE_INFO(OWNE, "Ownership frame");
+ CASE_INFO(PCNT, "Play counter");
+ CASE_INFO(POPM, "Popularimeter");
+ CASE_INFO(POSS, "Position synchronisation frame");
+ CASE_INFO(PRIV, "Private frame");
+ CASE_INFO(RBUF, "Recommended buffer size");
+ CASE_INFO(RGAD, "Replay Gain Adjustment");
+ CASE_INFO(RVA2, "Relative volume adjustment (2)");
+ CASE_INFO(RVRB, "Reverb");
+ CASE_INFO(SEEK, "Seek frame");
+ CASE_INFO(SIGN, "Signature frame");
+ CASE_INFO(SYLT, "Synchronised lyric/text");
+ CASE_INFO(SYTC, "Synchronised tempo codes");
+ CASE_INFO(TALB, "Album/Movie/Show title");
+ CASE_INFO(TBPM, "BPM (beats per minute)");
+ CASE_INFO(TCMP, "iTunes Compilation Flag");
+ CASE_INFO(TCOM, "Composer");
+ CASE_INFO(TCON, "Content type");
+ CASE_INFO(TCOP, "Copyright message");
+ CASE_INFO(TDAT, "Date");
+ CASE_INFO(TDEN, "Encoding time");
+ CASE_INFO(TDLY, "Playlist delay");
+ CASE_INFO(TDOR, "Original release time");
+ CASE_INFO(TDRC, "Recording time");
+ CASE_INFO(TDRL, "Release time");
+ CASE_INFO(TDTG, "Tagging time");
+ CASE_INFO(TENC, "Encoded by");
+ CASE_INFO(TEXT, "Lyricist/Text writer");
+ CASE_INFO(TFLT, "File type");
+ CASE_INFO(TIME, "Time");
+ CASE_INFO(TIPL, "Involved people list");
+ CASE_INFO(TIT1, "Content group description");
+ CASE_INFO(TIT2, "Title/songname/content description");
+ CASE_INFO(TIT3, "Subtitle/Description refinement");
+ CASE_INFO(TKEY, "Initial key");
+ CASE_INFO(TLAN, "Language(s)");
+ CASE_INFO(TLEN, "Length");
+ CASE_INFO(TMCL, "Musician credits list");
+ CASE_INFO(TMED, "Media type");
+ CASE_INFO(TMOO, "Mood");
+ CASE_INFO(TOAL, "Original album/movie/show title");
+ CASE_INFO(TOFN, "Original filename");
+ CASE_INFO(TOLY, "Original lyricist(s)/text writer(s)");
+ CASE_INFO(TOPE, "Original artist(s)/performer(s)");
+ CASE_INFO(TORY, "Original release year");
+ CASE_INFO(TOWN, "File owner/licensee");
+ CASE_INFO(TPE1, "Lead performer(s)/Soloist(s)");
+ CASE_INFO(TPE2, "Band/orchestra/accompaniment");
+ CASE_INFO(TPE3, "Conductor/performer refinement");
+ CASE_INFO(TPE4, "Interpreted, remixed, or otherwise modified by");
+ CASE_INFO(TPOS, "Part of a set");
+ CASE_INFO(TPRO, "Produced notice");
+ CASE_INFO(TPUB, "Publisher");
+ CASE_INFO(TRCK, "Track number/Position in set");
+ CASE_INFO(TRDA, "Recording dates");
+ CASE_INFO(TRSN, "Internet radio station name");
+ CASE_INFO(TRSO, "Internet radio station owner");
+ CASE_INFO(TSIZ, "Size");
+ CASE_INFO(TSO2, "Performer order");
+ CASE_INFO(TSOA, "Album sort order");
+ CASE_INFO(TSOC, "Composer sort order");
+ CASE_INFO(TSOP, "Performer sort order");
+ CASE_INFO(TSOT, "Title sort order");
+ CASE_INFO(TSRC, "ISRC (international standard recording code)");
+ CASE_INFO(TSSE, "Software/Hardware and settings used for encoding");
+ CASE_INFO(TSST, "Set subtitle");
+ CASE_INFO(TXXX, "User defined text information frame");
+ CASE_INFO(TYER, "Year");
+ CASE_INFO(UFID, "Unique file identifier");
+ CASE_INFO(USER, "Terms of use");
+ CASE_INFO(USLT, "Unsynchronised lyric/text transcription");
+ CASE_INFO(WCOM, "Commercial information");
+ CASE_INFO(WCOP, "Copyright/Legal information");
+ CASE_INFO(WOAF, "Official audio file webpage");
+ CASE_INFO(WOAR, "Official artist/performer webpage");
+ CASE_INFO(WOAS, "Official audio source webpage");
+ CASE_INFO(WORS, "Official Internet radio station homepage");
+ CASE_INFO(WPAY, "Payment");
+ CASE_INFO(WPUB, "Publishers official webpage");
+ CASE_INFO(WXXX, "User defined URL link frame");
+ CASE_INFO(XRVA, "Relative volume adjustment (2)");
+ CASE_INFO(BUF, "Recommended buffer size");
+ CASE_INFO(CNT, "Play counter");
+ CASE_INFO(COM, "Comments");
+ CASE_INFO(CRA, "Audio encryption");
+ CASE_INFO(CRM, "Encrypted meta frame");
+ CASE_INFO(EQU, "Equalization");
+ CASE_INFO(ETC, "Event timing codes");
+ CASE_INFO(GEO, "General encapsulated object");
+ CASE_INFO(IPL, "Involved people list");
+ CASE_INFO(LNK, "Linked information");
+ CASE_INFO(MCI, "Music CD Identifier");
+ CASE_INFO(MLL, "MPEG location lookup table");
+ CASE_INFO(PIC_, "Attached picture");
+ CASE_INFO(POP, "Popularimeter");
+ CASE_INFO(REV, "Reverb");
+ CASE_INFO(RVA, "Relative volume adjustment");
+ CASE_INFO(SLT, "Synchronized lyric/text");
+ CASE_INFO(STC, "Synced tempo codes");
+ CASE_INFO(TAL, "Album/Movie/Show title");
+ CASE_INFO(TBP, "BPM (Beats Per Minute)");
+ CASE_INFO(TCM, "Composer");
+ CASE_INFO(TCO, "Content type");
+ CASE_INFO(TCP, "iTunes Compilation Flag");
+ CASE_INFO(TCR, "Copyright message");
+ CASE_INFO(TDA, "Date");
+ CASE_INFO(TDY, "Playlist delay");
+ CASE_INFO(TEN, "Encoded by");
+ CASE_INFO(TFT, "File type");
+ CASE_INFO(TIM, "Time");
+ CASE_INFO(TKE, "Initial key");
+ CASE_INFO(TLA, "Language(s)");
+ CASE_INFO(TLE, "Length");
+ CASE_INFO(TMT, "Media type");
+ CASE_INFO(TOA, "Original artist(s)/performer(s)");
+ CASE_INFO(TOF, "Original filename");
+ CASE_INFO(TOL, "Original Lyricist(s)/text writer(s)");
+ CASE_INFO(TOR, "Original release year");
+ CASE_INFO(TOT, "Original album/Movie/Show title");
+ CASE_INFO(TP1, "Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group");
+ CASE_INFO(TP2, "Band/Orchestra/Accompaniment");
+ CASE_INFO(TP3, "Conductor/Performer refinement");
+ CASE_INFO(TP4, "Interpreted, remixed, or otherwise modified by");
+ CASE_INFO(TPA, "Part of a set");
+ CASE_INFO(TPB, "Publisher");
+ CASE_INFO(TRC, "ISRC (International Standard Recording Code)");
+ CASE_INFO(TRD, "Recording dates");
+ CASE_INFO(TRK, "Track number/Position in set");
+ CASE_INFO(TSI, "Size");
+ CASE_INFO(TSS, "Software/hardware and settings used for encoding");
+ CASE_INFO(TT1, "Content group description");
+ CASE_INFO(TT2, "Title/Songname/Content description");
+ CASE_INFO(TT3, "Subtitle/Description refinement");
+ CASE_INFO(TXT, "Lyricist/text writer");
+ CASE_INFO(TXX, "User defined text information frame");
+ CASE_INFO(TYE, "Year");
+ CASE_INFO(UFI, "Unique file identifier");
+ CASE_INFO(ULT, "Unsychronized lyric/text transcription");
+ CASE_INFO(WAF, "Official audio file webpage");
+ CASE_INFO(WAR, "Official artist/performer webpage");
+ CASE_INFO(WAS, "Official audio source webpage");
+ CASE_INFO(WCM, "Commercial information");
+ CASE_INFO(WCP, "Copyright/Legal information");
+ CASE_INFO(WPB, "Publishers official webpage");
+ CASE_INFO(WXX, "User defined URL link frame");
+ default : Skip_XX(Element_Size, "Data");
+ }
+
+ if (!Unsynch_List.empty())
+ {
+ //We must change the buffer for keeping out
+ File_Offset=Save_File_Offset;
+ Element_Size=Save_Element_Size;
+ Buffer_Offset=Save_Buffer_Offset;
+ delete[] Buffer; Buffer=Save_Buffer;
+ Buffer_Unsynch=NULL; //Same as Buffer...
+ Element_Offset+=Unsynch_List.size();
+ }
+
+ if (!Id3v2_Size)
+ Finish("Id3v2");
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//
+void File_Id3v2::T___()
+{
+ int8u Encoding;
+ Get_B1 (Encoding, "Text_encoding");
+ switch (Encoding)
+ {
+ case 0 : Get_ISO_8859_1 (Element_Size-Element_Offset, Element_Value, "Information"); break;
+ case 1 : Get_UTF16 (Element_Size-Element_Offset, Element_Value, "Information"); break;
+ case 2 : Get_UTF16B (Element_Size-Element_Offset, Element_Value, "Information"); break;
+ case 3 : Get_UTF8 (Element_Size-Element_Offset, Element_Value, "Information"); break;
+ default : ;
+ }
+
+ //Exceptions
+ if (Element_Code==Elements::TCMP || Element_Code==Elements::TCP)
+ {
+ if (Element_Value==_T("0")) Element_Value.clear(); //This is usually set to 0 even if the user did not explicitely indicated something (default)
+ if (Element_Value==_T("1")) Element_Value=_T("Yes");
+ }
+
+ //Filling
+ if (Element_Value.empty())
+ return;
+ Fill_Name();
+}
+
+//---------------------------------------------------------------------------
+//
+void File_Id3v2::T__X()
+{
+ //Integrity
+ if (Element_Size<(Elements::TXXX?4:1))
+ {
+ Element_Values(1).clear();
+ Element_Values(0).clear();
+ return;
+ }
+
+ int8u Encoding;
+ Get_B1 (Encoding, "Text_encoding");
+ if (Element_Code!=Elements::TXXX)
+ Skip_C3( "Language");
+ size_t Value0_Size=0;
+ switch (Encoding)
+ {
+ case 0 :
+ case 3 : //1-byte char
+ while (Element_Offset+Value0_Size<Element_Size && Buffer[Buffer_Offset+(size_t)Element_Offset+Value0_Size]!='\0')
+ Value0_Size++;
+ if (Element_Offset+Value0_Size>=Element_Size)
+ return; //Problem
+ switch (Encoding)
+ {
+ case 0 : Get_ISO_8859_1 (Value0_Size, Element_Values(0), "Short_content_descrip"); break;
+ case 3 : Get_UTF8 (Value0_Size, Element_Values(0), "Short_content_descrip"); break;
+ default : ;
+ }
+ Skip_B1( "Null");
+ switch (Encoding)
+ {
+ case 0 : Get_ISO_8859_1 (Element_Size-Element_Offset, Element_Values(1), "The_actual_text"); break;
+ case 3 : Get_UTF8 (Element_Size-Element_Offset, Element_Values(1), "The_actual_text"); break;
+ default : ;
+ }
+ break;
+ case 1 :
+ case 2 : //2-byte char
+ while (Element_Offset+Value0_Size+1<Element_Size
+ && !(Buffer[Buffer_Offset+(size_t)Element_Offset+Value0_Size ]=='\0'
+ && Buffer[Buffer_Offset+(size_t)Element_Offset+Value0_Size+1]=='\0')) //2-byte zero
+ Value0_Size+=2;
+ if (Element_Offset+Value0_Size>=Element_Size)
+ return; //Problem
+ switch (Encoding)
+ {
+ case 1 : Get_UTF16 (Value0_Size, Element_Values(0), "Short_content_descrip"); break;
+ case 2 : Get_UTF16B(Value0_Size, Element_Values(0), "Short_content_descrip"); break;
+ default : ;
+ }
+ Skip_B2( "Null");
+ switch (Encoding)
+ {
+ case 1 : Get_UTF16 (Element_Size-Element_Offset, Element_Values(1), "The_actual_text"); break;
+ case 2 : Get_UTF16B(Element_Size-Element_Offset, Element_Values(1), "The_actual_text"); break;
+ default : ;
+ }
+ break;
+ default: //Unknown
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::W___()
+{
+ Get_ISO_8859_1(Element_Size, Element_Value, "URL");
+
+ //Filling
+ Fill_Name();
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::W__X()
+{
+ if (Element_Size<1)
+ return; //Problem
+
+ int8u Encoding;
+ Get_B1 (Encoding, "Text_encoding");
+ switch (Encoding)
+ {
+ case 0 : Get_ISO_8859_1 (Element_Size-1, Element_Values(0), "Description"); break;
+ case 1 : Get_UTF16 (Element_Size-1, Element_Values(0), "Description"); break;
+ case 2 : Get_UTF16B (Element_Size-1, Element_Values(0), "Description"); break;
+ case 3 : Get_UTF8 (Element_Size-1, Element_Values(0), "Description"); break;
+ default : ;
+ }
+ Element_Offset=1;
+ switch (Encoding)
+ {
+ case 0 : Element_Offset+=Element_Values(0).size()+1; break; //NULL
+ case 1 : Element_Offset+=Element_Values(0).size()*2+4; break; //UTF-16 BOM + UTF-16 NULL
+ case 2 : Element_Offset+=Element_Values(0).size()*2+2; break; //UTF-16 NULL
+ case 3 : Element_Offset+=Element_Values(0).To_UTF8().size()+1; break; //UTF-8 NULL
+ default : ;
+ }
+ if (Element_Offset<Element_Size)
+ Get_ISO_8859_1(Element_Size-Element_Offset, Element_Values(1), "URL");
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::APIC()
+{
+ int8u Encoding, PictureType;
+ Ztring Mime, Description;
+ Get_B1 (Encoding, "Text_encoding");
+ if (Id3v2_Version==2)
+ {
+ int32u Image_format;
+ Get_C3(Image_format, "Image_format");
+ switch (Image_format)
+ {
+ case 0x504E47 : Mime="image/png";
+ case 0x4A5047 : Mime="image/jpeg";
+ default : ;
+ }
+ }
+ else
+ {
+ int64u Element_Offset_Real=Element_Offset;
+ Get_ISO_8859_1(Element_Size-Element_Offset, Mime, "MIME_type");
+ Element_Offset=Element_Offset_Real+Mime.size()+1;
+ }
+ Get_B1 (PictureType, "Picture_type"); Element_Info1(Id3v2_PictureType(PictureType));
+ int64u Element_Offset_Real=Element_Offset;
+ switch (Encoding)
+ {
+ case 0 : Get_ISO_8859_1 (Element_Size-Element_Offset, Description, "Description"); break;
+ case 1 : Get_UTF16 (Element_Size-Element_Offset, Description, "Description"); break;
+ case 2 : Get_UTF16B (Element_Size-Element_Offset, Description, "Description"); break;
+ case 3 : Get_UTF8 (Element_Size-Element_Offset, Description, "Description"); break;
+ default : ;
+ }
+ Element_Offset=Element_Offset_Real;
+ switch (Encoding)
+ {
+ case 0 : Element_Offset+=Description.size()+1; break; //NULL
+ case 1 : Element_Offset+=Description.size()*2+4; break; //UTF-16 BOM + UTF-16 NULL
+ case 2 : Element_Offset+=Description.size()*2+2; break; //UTF-16 NULL
+ case 3 : Element_Offset+=Description.To_UTF8().size()+1; break; //UTF-8 NULL
+ default : ;
+ }
+ if (Element_Offset>Element_Size)
+ return; //There is a problem
+ std::string Data_Raw((const char*)(Buffer+(size_t)(Buffer_Offset+Element_Offset)), (size_t)(Element_Size-Element_Offset));
+ std::string Data_Base64(Base64::encode(Data_Raw));
+
+ //Filling
+ Fill_Name();
+ Fill(Stream_General, 0, General_Cover_Description, Description);
+ Fill(Stream_General, 0, General_Cover_Type, Id3v2_PictureType(PictureType));
+ Fill(Stream_General, 0, General_Cover_Mime, Mime);
+ Fill(Stream_General, 0, General_Cover_Data, Data_Base64);
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::COMM()
+{
+ T__X();
+
+ //Testing
+ if (Element_Values(0)==_T("iTunes_CDDB_IDs")) return;
+ else if (Element_Values(0)==_T("iTunNORM")) return;
+ else if (Element_Values(0)==_T("iTunSMPB")) return;
+ else if (Element_Values(0)==_T("Songs-DB_Tempo")) return;
+ else if (Element_Values(0)==_T("Songs-DB_Preference")) return;
+ else if (Element_Values(0)==_T("MusicMatch_Tempo")) return;
+ else if (Element_Values(0)==_T("MusicMatch_Mood"))
+ {
+ if (Retrieve(Stream_General, 0, General_Mood).empty())
+ Element_Values(0)==_T("Mood");
+ else
+ return;
+ }
+ else if (Element_Values(0)==_T("MusicMatch_Preference")) return;
+
+ //Filling
+ if (Element_Values(0).empty())
+ Element_Values(0)=_T("Comment");
+ Fill_Name();
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::RGAD()
+{
+ //Parsing
+ float32 Peak_Amplitude;
+ Get_BF4 (Peak_Amplitude, "Peak Amplitude");
+ while (Element_Offset+2<=Element_Size)
+ {
+ Element_Begin1("Gain Adjustement");
+ int16u Replay_Gain_Adjustment;
+ int8u Name_code;
+ bool Sign_bit;
+ BS_Begin();
+ Get_S1 (3, Name_code, "Name code"); Param_Info1(Id3v2_RGAD_Name_code[Name_code]);
+ Info_S1(3, Originator_code, "Originator code"); Param_Info1(Id3v2_RGAD_Originator_code[Originator_code]);
+ Get_SB (Sign_bit, "Sign bit");
+ Get_S2 (9, Replay_Gain_Adjustment, "Replay Gain Adjustment"); Param_Info3 ((Sign_bit?-1:1)*(float)Replay_Gain_Adjustment/10, 1, " dB");
+ BS_End();
+ Element_End0();
+
+ FILLING_BEGIN();
+ switch (Name_code)
+ {
+ case 1 : if (Retrieve(Stream_Audio, 0, Audio_ReplayGain_Gain).empty()) //this tag is not precise, we prefer other RG tags
+ Fill(Stream_Audio, 0, Audio_ReplayGain_Gain, (Sign_bit?-1:1)*(float)Replay_Gain_Adjustment/10, 1);
+ case 2 : if (Retrieve(Stream_General, 0, General_Album_ReplayGain_Gain).empty()) //this tag is not precise, we prefer other RG tags
+ Fill(Stream_General, 0, General_Album_ReplayGain_Gain, (Sign_bit?-1:1)*(float)Replay_Gain_Adjustment/10, 1);
+ }
+ FILLING_END();
+ }
+
+ FILLING_BEGIN();
+ if (Peak_Amplitude && Retrieve(Stream_Audio, 0, Audio_ReplayGain_Peak).empty()) //this tag is not precise, we prefer other RG tags
+ Fill(Stream_Audio, 0, Audio_ReplayGain_Peak, Peak_Amplitude, 6);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::PRIV()
+{
+ //Parsing
+ Ztring Owner;
+ Get_ISO_8859_1(Element_Size, Owner, "Owner identifier");
+ Element_Offset=Owner.size()+1;
+ Skip_XX(Element_Size-Element_Offset, "Data");
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::USLT()
+{
+ T__X();
+
+ //Filling
+ if (!Element_Values(0).empty())
+ Element_Values(1)=Element_Values(0)+MediaInfoLib::Config.Language_Get(_T(": "))+Element_Values(1);
+ Element_Values(0)=_T("Lyrics");
+
+ Fill_Name();
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::TXXX()
+{
+ T__X();
+
+ //Filling
+ if (Element_Values(0).empty())
+ Element_Values(0)=_T("Comment");
+ Fill_Name();
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::SYLT()
+{
+ int8u Encoding;
+ Get_B1 (Encoding, "Text encoding");
+ Skip_C3( "Language");
+ Skip_B1( "Time_stamp_format");
+ Skip_B1( "Content_type");
+ switch (Encoding)
+ {
+ case 0 : Get_ISO_8859_1 (Element_Size-6, Element_Value, "Short_content_descrip"); break;
+ case 1 : Get_UTF16 (Element_Size-6, Element_Value, "Short_content_descrip"); break;
+ case 2 : Get_UTF16B (Element_Size-6, Element_Value, "Short_content_descrip"); break;
+ case 3 : Get_UTF8 (Element_Size-6, Element_Value, "Short_content_descrip"); break;
+ default : ;
+ }
+
+ //Filling
+ Fill_Name();
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::WXXX()
+{
+ W__X();
+
+ //Filling
+ if (Element_Values(1).empty())
+ return;
+ if (Element_Values(0).empty())
+ Element_Values(0)=_T("URL");
+ Fill_Name();
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Id3v2::Fill_Name()
+{
+ Ztring Value=Ztring().From_CC4((int32u)Element_Code);
+ if (MediaInfoLib::Config.CustomMapping_IsPresent(_T("Id3v2"), Value))
+ {
+ Fill(Stream_General, 0, MediaInfoLib::Config.CustomMapping_Get(_T("Id3v2"), Value).To_Local().c_str(), Element_Value);
+ return;
+ }
+
+ switch (Element_Code)
+ {
+ case Elements::AENC : break;
+ case Elements::APIC : Fill(Stream_General, 0, General_Cover, "Yes"); break;
+ case Elements::ASPI : break;
+ case Elements::COMM : Fill(Stream_General, 0, Element_Values(0).To_UTF8().c_str(), Element_Values(1)); break;
+ case Elements::COMR : Fill(Stream_General, 0, "Commercial frame", Element_Value); break;
+ case Elements::ENCR : break;
+ case Elements::EQU2 : break;
+ case Elements::EQUA : break;
+ case Elements::ETCO : break;
+ case Elements::GEOB : break;
+ case Elements::GRID : Fill(Stream_General, 0, "Group identification registration", Element_Value); break;
+ case Elements::IPLS : Fill(Stream_General, 0, "Involved people list", Element_Value); break;
+ case Elements::LINK : Fill(Stream_General, 0, "Linked information", Element_Value); break;
+ case Elements::MCDI : Fill(Stream_General, 0, "MCDI", "Yes"); break;
+ case Elements::MLLT : break;
+ case Elements::OWNE : Fill(Stream_General, 0, General_Owner, Element_Value); break;
+ case Elements::PCNT : break;
+ case Elements::POPM : break;
+ case Elements::POSS : break;
+ case Elements::PRIV : break;
+ case Elements::RBUF : break;
+ case Elements::RVA2 : break;
+ case Elements::RVRB : break;
+ case Elements::SEEK : break;
+ case Elements::SIGN : break;
+ case Elements::SYLT : Fill(Stream_General, 0, General_Lyrics, Element_Value); break;
+ case Elements::SYTC : break;
+ case Elements::TALB : Fill(Stream_General, 0, General_Album, Element_Value); break;
+ case Elements::TBPM : Fill(Stream_General, 0, General_BPM, Element_Value); break;
+ case Elements::TCMP : Fill(Stream_General, 0, General_Compilation, Element_Value); break;
+ case Elements::TCOM : Fill(Stream_General, 0, General_Composer, Element_Value); break;
+ case Elements::TCON :
+ {
+ if (Element_Value.find(_T("("))==0)
+ Element_Value=Element_Value.SubString(_T("("), _T(")")); //Replace (nn) by nn
+ if (Element_Value==_T("0") || Element_Value==_T("255"))
+ Element_Value.clear();
+ Fill(Stream_General, 0, General_Genre, Element_Value);
+ }
+ break;
+ case Elements::TCOP : Fill(Stream_General, 0, General_Copyright, Element_Value); break;
+ case Elements::TDA :
+ case Elements::TDAT : if (Element_Value.size()==4)
+ {
+ Month.assign(Element_Value.c_str(), 0, 2);
+ Day.assign (Element_Value.c_str(), 2, 2); break;
+ }
+ case Elements::TDEN : Normalize_Date(Element_Value); Fill(Stream_General, 0, "Encoded_Date", Element_Value); break;
+ case Elements::TDLY : break;
+ case Elements::TDOR : Normalize_Date(Element_Value); Fill(Stream_General, 0, "Original/Released_Date", Element_Value); break;
+ case Elements::TDRC : Normalize_Date(Element_Value); Fill(Stream_General, 0, General_Recorded_Date, Element_Value); break;
+ case Elements::TDRL : Normalize_Date(Element_Value); Fill(Stream_General, 0, General_Released_Date, Element_Value); break;
+ case Elements::TDTG : Normalize_Date(Element_Value); Fill(Stream_General, 0, General_Tagged_Date, Element_Value); break;
+ case Elements::TENC : Fill(Stream_General, 0, General_EncodedBy, Element_Value); break;
+ case Elements::TEXT : Fill(Stream_General, 0, General_Lyricist, Element_Value); break;
+ case Elements::TFLT : Fill(Stream_General, 0, "File type", Element_Value); break;
+ case Elements::TIM :
+ case Elements::TIME : if (Element_Value.size()==4)
+ {
+ Hour.assign (Element_Value.c_str(), 0, 2);
+ Minute.assign(Element_Value.c_str(), 2, 2); break;
+ }
+ case Elements::TIPL : Fill(Stream_General, 0, General_ThanksTo, Element_Value); break;
+ case Elements::TIT1 : Fill(Stream_General, 0, General_Grouping, Element_Value); break;
+ case Elements::TIT2 : Fill(Stream_General, 0, General_Track, Element_Value); break;
+ case Elements::TIT3 : Fill(Stream_General, 0, General_Track_More, Element_Value); break;
+ case Elements::TKEY : Fill(Stream_General, 0, "Initial key", Element_Value); break;
+ case Elements::TLAN : Fill(Stream_Audio, 0, Audio_Language, Element_Value); break;
+ case Elements::TLEN : break; //Fill(Stream_General, 0, "Length", Element_Value); break;
+ case Elements::TMCL : Fill(Stream_General, 0, "Musician Credit List", Element_Value); break;
+ case Elements::TMED : Fill(Stream_General, 0, "Media Type", Element_Value); break;
+ case Elements::TMOO : Fill(Stream_General, 0, "Mood", Element_Value); break;
+ case Elements::TOAL : Fill(Stream_General, 0, "Original/Album", Element_Value); break;
+ case Elements::TOFN : Fill(Stream_General, 0, "Original/FileName", Element_Value); break;
+ case Elements::TOLY : Fill(Stream_General, 0, "Original/Lyricist", Element_Value); break;
+ case Elements::TOPE : Fill(Stream_General, 0, "Original/Performer", Element_Value); break;
+ case Elements::TORY : Normalize_Date(Element_Value); Fill(Stream_General, 0, "Original/Released_Date", Element_Value); break;
+ case Elements::TOWN : Fill(Stream_General, 0, General_Owner, Element_Value); break;
+ case Elements::TPE1 : Fill(Stream_General, 0, General_Performer, Element_Value); break;
+ case Elements::TPE2 : Fill(Stream_General, 0, General_Album_Performer, Element_Value); break;
+ case Elements::TPE3 : Fill(Stream_General, 0, General_Conductor, Element_Value); break;
+ case Elements::TPE4 : Fill(Stream_General, 0, General_RemixedBy, Element_Value); break;
+ case Elements::TPOS :
+ {
+ ZtringList List; List.Separator_Set(0, _T("/")); List.Write(Element_Value);
+ if (!List(0).empty())
+ Fill(Stream_General, 0, General_Part_Position, List(0));
+ if (!List(1).empty())
+ Fill(Stream_General, 0, General_Part_Position_Total, List(1));
+ }
+ break;
+ case Elements::TPRO : Fill(Stream_General, 0, General_Producer_Copyright, Element_Value); break;
+ case Elements::TPUB : Fill(Stream_General, 0, General_Publisher, Element_Value); break;
+ case Elements::TRCK :
+ {
+ ZtringList List; List.Separator_Set(0, _T("/")); List.Write(Element_Value);
+ if (!List(0).empty())
+ Fill(Stream_General, 0, General_Track_Position, List(0));
+ if (!List(1).empty())
+ Fill(Stream_General, 0, General_Track_Position_Total, List(1));
+ }
+ break;
+ case Elements::TRDA : Normalize_Date(Element_Value); Fill(Stream_General, 0, "Recorded_Date", Element_Value); break;
+ case Elements::TRSN : Fill(Stream_General, 0, General_ServiceName, Element_Value); break;
+ case Elements::TRSO : Fill(Stream_General, 0, General_ServiceProvider, Element_Value); break;
+ case Elements::TSIZ : Fill(Stream_General, 0, "Size", Element_Value); break;
+ case Elements::TSO2 : Fill(Stream_General, 0, General_Performer_Sort, Element_Value); break;
+ case Elements::TSOA : Fill(Stream_General, 0, General_Album_Sort, Element_Value); break;
+ case Elements::TSOC : Fill(Stream_General, 0, "Composer/Sort", Element_Value); break;
+ case Elements::TSOP : Fill(Stream_General, 0, General_Performer_Sort, Element_Value); break;
+ case Elements::TSOT : Fill(Stream_General, 0, General_Track_Sort, Element_Value); break;
+ case Elements::TSRC : Fill(Stream_General, 0, General_ISRC, Element_Value); break;
+ case Elements::TSSE : Fill(Stream_General, 0, General_Encoded_Library, Element_Value); break;
+ case Elements::TSST : Fill(Stream_General, 0, "Set subtitle", Element_Value); break;
+ case Elements::TXXX : if (Element_Values(0)==_T("AccurateRipResult")) ;
+ else if (Element_Values(0)==_T("AccurateRipDiscID")) ;
+ else if (Element_Values(0)==_T("CT_GAPLESS_DATA")) ;
+ else if (Element_Values(0)==_T("DISCNUMBER")) Fill(Stream_General, 0, General_Part_Position, Element_Values(1), true);
+ else if (Element_Values(0)==_T("DISCTOTAL")) Fill(Stream_General, 0, General_Part_Position_Total, Element_Values(1), true);
+ else if (Element_Values(0)==_T("first_played_timestamp")) Fill(Stream_General, 0, General_Played_First_Date, Ztring().Date_From_Milliseconds_1601(Element_Values(1).To_int64u()/10000));
+ else if (Element_Values(0)==_T("last_played_timestamp")) Fill(Stream_General, 0, General_Played_Last_Date, Ztring().Date_From_Milliseconds_1601(Element_Values(1).To_int64u()/10000));
+ else if (Element_Values(0)==_T("play_count")) Fill(Stream_General, 0, General_Played_Count, Element_Values(1).To_int64u());
+ else if (Element_Values(0)==_T("added_timestamp")) Fill(Stream_General, 0, General_Added_Date, Ztring().Date_From_Milliseconds_1601(Element_Values(1).To_int64u()/10000));
+ else if (Element_Values(0)==_T("replaygain_album_gain")) Fill(Stream_General, 0, General_Album_ReplayGain_Gain, Element_Values(1).To_float64(), 2, true);
+ else if (Element_Values(0)==_T("replaygain_album_peak")) Fill(Stream_General, 0, General_Album_ReplayGain_Peak, Element_Values(1).To_float64(), 6, true);
+ else if (Element_Values(0)==_T("replaygain_track_gain")) Fill(Stream_Audio, 0, Audio_ReplayGain_Gain, Element_Values(1).To_float64(), 2, true);
+ else if (Element_Values(0)==_T("replaygain_track_peak")) Fill(Stream_Audio, 0, Audio_ReplayGain_Peak, Element_Values(1).To_float64(), 6, true);
+ else if (Element_Values(0)==_T("TRACKTOTAL")) Fill(Stream_General, 0, General_Track_Position_Total, Element_Values(1), true);
+ else
+ Fill(Stream_General, 0, Element_Values(0).To_UTF8().c_str(), Element_Values(1));
+ break;
+ case Elements::TYER : Year=Element_Value; break;
+ case Elements::UFID : Fill(Stream_Audio, 0, "UID", Element_Value); break;
+ case Elements::USER : Fill(Stream_General, 0, General_TermsOfUse, Element_Value); break;
+ case Elements::USLT : Fill(Stream_General, 0, Element_Values(0).To_UTF8().c_str(), Element_Values(1)); break;
+ case Elements::WCOM : Fill(Stream_General, 0, "Commercial information", Element_Value); break;
+ case Elements::WCOP : Fill(Stream_General, 0, "Copyright/Legal information", Element_Value); break;
+ case Elements::WOAF : Fill(Stream_General, 0, "Official audio file webpage", Element_Value); break;
+ case Elements::WOAR : Fill(Stream_General, 0, "Performer/Url", Element_Value); break;
+ case Elements::WOAS : Fill(Stream_General, 0, "Official audio source webpage", Element_Value); break;
+ case Elements::WORS : Fill(Stream_General, 0, General_Service_Url, Element_Value); break;
+ case Elements::WPAY : Fill(Stream_General, 0, "Payment", Element_Value); break;
+ case Elements::WPUB : Fill(Stream_General, 0, "Publisher/Url", Element_Value); break;
+ case Elements::WXXX : Fill(Stream_General, 0, Element_Values(0).To_UTF8().c_str(), Element_Values(1)); break;
+ case Elements::BUF : break;
+ case Elements::CNT : break;
+ case Elements::COM : Fill(Stream_General, 0, "Comment", Element_Value); break;
+ case Elements::CRA : break;
+ case Elements::CRM : break;
+ case Elements::EQU : break;
+ case Elements::ETC : break;
+ case Elements::GEO : break;
+ case Elements::IPL : Fill(Stream_General, 0, "Involved people list", Element_Value); break;
+ case Elements::LNK : Fill(Stream_General, 0, "Linked information,", Element_Value); break;
+ case Elements::MCI : Fill(Stream_General, 0, "MCDI", Element_Value); break;
+ case Elements::MLL : break;
+ case Elements::PIC_ : Fill(Stream_General, 0, "Cover", "Yes"); break;
+ case Elements::POP : break;
+ case Elements::REV : break;
+ case Elements::RVA : break;
+ case Elements::SLT : break;
+ case Elements::STC : break;
+ case Elements::TAL : Fill(Stream_General, 0, "Album", Element_Value); break;
+ case Elements::TBP : Fill(Stream_General, 0, "BPM", Element_Value); break;
+ case Elements::TCM : Fill(Stream_General, 0, "Composer", Element_Value); break;
+ case Elements::TCO :
+ {
+ if (Element_Value.find(_T("("))==0)
+ Element_Value=Element_Value.SubString(_T("("), _T(")")); //Replace (nn) by nn
+ if (Element_Value==_T("0") || Element_Value==_T("255"))
+ Element_Value.clear();
+ if (!Element_Value.empty())
+ Fill(Stream_General, 0, General_Genre, Element_Value);
+ }
+ break;
+ case Elements::TCR : Fill(Stream_General, 0, "Copyright", Element_Value); break;
+ case Elements::TDY : break;
+ case Elements::TEN : Fill(Stream_General, 0, "Encoded_Library", Element_Value); break;
+ case Elements::TFT : Fill(Stream_General, 0, "File type", Element_Value); break;
+ case Elements::TKE : Fill(Stream_General, 0, "Initial key", Element_Value); break;
+ case Elements::TLA : Fill(Stream_Audio, 0, Audio_Language, Element_Value); break;
+ case Elements::TLE : break;
+ case Elements::TMT : Fill(Stream_General, 0, "Media type", Element_Value); break;
+ case Elements::TOA : Fill(Stream_General, 0, "Original/Performer", Element_Value); break;
+ case Elements::TOF : Fill(Stream_General, 0, "Original/FileName", Element_Value); break;
+ case Elements::TOL : Fill(Stream_General, 0, "Original/Lyricist", Element_Value); break;
+ case Elements::TOR : Normalize_Date(Element_Value); Fill(Stream_General, 0, "Original/Released_Date", Element_Value); break;
+ case Elements::TOT : Fill(Stream_General, 0, "Original/Album", Element_Value); break;
+ case Elements::TP1 : Fill(Stream_General, 0, "Performer", Element_Value); break;
+ case Elements::TP2 : Fill(Stream_General, 0, "Accompaniment", Element_Value); break;
+ case Elements::TP3 : Fill(Stream_General, 0, "Conductor", Element_Value); break;
+ case Elements::TP4 : Fill(Stream_General, 0, "RemixedBy", Element_Value); break;
+ case Elements::TPA :
+ {
+ ZtringList List; List.Separator_Set(0, _T("/")); List.Write(Element_Value);
+ if (!List(0).empty())
+ Fill(Stream_General, 0, General_Part_Position, List(0));
+ if (!List(1).empty())
+ Fill(Stream_General, 0, General_Part_Position_Total, List(1));
+ }
+ break;
+ case Elements::TPB : Fill(Stream_General, 0, "Publisher", Element_Value); break;
+ case Elements::TRC : Fill(Stream_General, 0, "ISRC", Element_Value); break;
+ case Elements::TRD : Normalize_Date(Element_Value); Fill(Stream_General, 0, "Recorded_Date", Element_Value); break;
+ case Elements::TRK :
+ {
+ ZtringList List; List.Separator_Set(0, _T("/")); List.Write(Element_Value);
+ if (!List(0).empty())
+ Fill(Stream_General, 0, General_Track_Position, List(0));
+ if (!List(1).empty())
+ Fill(Stream_General, 0, General_Track_Position_Total, List(1));
+ }
+ break;
+ case Elements::TSI : break;
+ case Elements::TSS : break;
+ case Elements::TT1 : Fill(Stream_General, 0, "Grouping", Element_Value); break;
+ case Elements::TT2 : Fill(Stream_General, 0, "Track", Element_Value); break;
+ case Elements::TT3 : Fill(Stream_General, 0, "Track/More", Element_Value); break;
+ case Elements::TXT : Fill(Stream_General, 0, "Lyricist", Element_Value); break;
+ case Elements::TXX : Fill(Stream_General, 0, Element_Values(0).To_UTF8().c_str(), Element_Values(1)); break;
+ case Elements::TYE : Year=Element_Value; break;
+ case Elements::UFI : Fill(Stream_Audio, 0, "UID", Element_Value); break;
+ case Elements::ULT : break;
+ case Elements::WAF : break;
+ case Elements::WAR : Fill(Stream_General, 0, General_Service_Url, Element_Value); break;
+ case Elements::WAS : Fill(Stream_General, 0, "Official audio source webpage", Element_Value); break;
+ case Elements::WCM : Fill(Stream_General, 0, "Commercial information", Element_Value); break;
+ case Elements::WCP : Fill(Stream_General, 0, "Copyright/Legal information", Element_Value); break;
+ case Elements::WPB : Fill(Stream_General, 0, "Publisher/Url", Element_Value); break;
+ case Elements::WXX : Fill(Stream_General, 0, Element_Values(0).To_UTF8().c_str(), Element_Values(1)); break;
+ default : ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Id3v2::Normalize_Date(Ztring& Date)
+{
+ if (Date.size()<=8)
+ return; //Format unknown
+ Date[8]=_T(' '); //could be "T"
+ Date=Ztring(_T("UTC "))+Date; //Id3v2 specify a UTC date
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPEGA_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3v2.h b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3v2.h
new file mode 100644
index 000000000..0d4f5f753
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Id3v2.h
@@ -0,0 +1,248 @@
+// File_Id3v2 - Info for ID3v2 tagged files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about ID3v2 tagged files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Id3v2H
+#define MediaInfo_File_Id3v2H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+///***************************************************************************
+// Class File_Id3v2
+//***************************************************************************
+
+class File_Id3v2 : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Id3v2();
+
+ //Static stuff
+ static bool Static_Synchronize_Tags (const int8u* Buffer, size_t Buffer_Offset, size_t Buffer_Size, bool &Tag_Found);
+
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - File header
+ void FileHeader_Parse ();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ #ifdef TEXT
+ #undef TEXT
+ #endif
+ void T___();
+ void T__X();
+ void W___();
+ void W__X();
+ void AENC() {Skip_XX(Element_Size, "Data");}
+ void APIC();
+ void ASPI() {Skip_XX(Element_Size, "Data");}
+ void COMM();
+ void COMR() {Skip_XX(Element_Size, "Data");}
+ void ENCR() {Skip_XX(Element_Size, "Data");}
+ void EQU2() {Skip_XX(Element_Size, "Data");}
+ void EQUA() {Skip_XX(Element_Size, "Data");}
+ void ETCO() {Skip_XX(Element_Size, "Data");}
+ void GEOB() {Skip_XX(Element_Size, "Data");}
+ void GRID() {Skip_XX(Element_Size, "Data");}
+ void IPLS() {Skip_XX(Element_Size, "Data");}
+ void LINK() {Skip_XX(Element_Size, "Data");}
+ void MCDI() {T___();}
+ void MLLT() {Skip_XX(Element_Size, "Data");}
+ void OWNE() {Skip_XX(Element_Size, "Data");}
+ void PCNT() {Skip_XX(Element_Size, "Data");}
+ void POPM() {Skip_XX(Element_Size, "Data");}
+ void POSS() {Skip_XX(Element_Size, "Data");}
+ void PRIV();
+ void RBUF() {Skip_XX(Element_Size, "Data");}
+ void RGAD();
+ void RVA2() {Skip_XX(Element_Size, "Data");}
+ void RVRB() {Skip_XX(Element_Size, "Data");}
+ void SEEK() {Skip_XX(Element_Size, "Data");}
+ void SIGN() {Skip_XX(Element_Size, "Data");}
+ void SYLT();
+ void SYTC() {Skip_XX(Element_Size, "Data");}
+ void TALB() {T___();}
+ void TBPM() {T___();}
+ void TCMP() {T___();}
+ void TCOM() {T___();}
+ void TCON() {T___();}
+ void TCOP() {T___();}
+ void TDAT() {T___();}
+ void TDEN() {T___();}
+ void TDLY() {T___();}
+ void TDOR() {T___();}
+ void TDRC() {T___();}
+ void TDRL() {T___();}
+ void TDTG() {T___();}
+ void TENC() {T___();}
+ void TEXT() {T___();}
+ void TFLT() {T___();}
+ void TIME() {T___();}
+ void TIPL() {T___();}
+ void TIT1() {T___();}
+ void TIT2() {T___();}
+ void TIT3() {T___();}
+ void TKEY() {T___();}
+ void TLAN() {T___();}
+ void TLEN() {T___();}
+ void TMCL() {T___();}
+ void TMED() {T___();}
+ void TMOO() {T___();}
+ void TOAL() {T___();}
+ void TOFN() {T___();}
+ void TOLY() {T___();}
+ void TOPE() {T___();}
+ void TORY() {T___();}
+ void TOWN() {T___();}
+ void TPE1() {T___();}
+ void TPE2() {T___();}
+ void TPE3() {T___();}
+ void TPE4() {T___();}
+ void TPOS() {T___();}
+ void TPRO() {T___();}
+ void TPUB() {T___();}
+ void TRCK() {T___();}
+ void TRDA() {T___();}
+ void TRSN() {T___();}
+ void TRSO() {T___();}
+ void TSIZ() {T___();}
+ void TSO2() {T___();}
+ void TSOA() {T___();}
+ void TSOC() {T___();}
+ void TSOP() {T___();}
+ void TSOT() {T___();}
+ void TSRC() {T___();}
+ void TSSE() {T___();}
+ void TSST() {T___();}
+ void TXXX();
+ void TYER() {T___();}
+ void UFID() {Skip_XX(Element_Size, "Data");}
+ void USER() {Skip_XX(Element_Size, "Data");}
+ void USLT();
+ void WCOM() {W___();}
+ void WCOP() {W___();}
+ void WOAF() {W___();}
+ void WOAR() {W___();}
+ void WOAS() {W___();}
+ void WORS() {W___();}
+ void WPAY() {W___();}
+ void WPUB() {W___();}
+ void WXXX();
+ void BUF() {Skip_XX(Element_Size, "Data");}
+ void CNT() {Skip_XX(Element_Size, "Data");}
+ void COM() {COMM();}
+ void CRA() {Skip_XX(Element_Size, "Data");}
+ void CRM() {Skip_XX(Element_Size, "Data");}
+ void EQU() {Skip_XX(Element_Size, "Data");}
+ void ETC() {Skip_XX(Element_Size, "Data");}
+ void GEO() {Skip_XX(Element_Size, "Data");}
+ void IPL() {Skip_XX(Element_Size, "Data");}
+ void LNK() {Skip_XX(Element_Size, "Data");}
+ void MCI() {Skip_XX(Element_Size, "Data");}
+ void MLL() {Skip_XX(Element_Size, "Data");}
+ void PIC_() {APIC();}
+ void POP() {Skip_XX(Element_Size, "Data");}
+ void REV() {Skip_XX(Element_Size, "Data");}
+ void RVA() {Skip_XX(Element_Size, "Data");}
+ void SLT() {Skip_XX(Element_Size, "Data");}
+ void STC() {Skip_XX(Element_Size, "Data");}
+ void TAL() {T___();}
+ void TBP() {T___();}
+ void TCM() {T___();}
+ void TCO() {T___();}
+ void TCP() {Skip_XX(Element_Size, "Data");}
+ void TCR() {T___();}
+ void TDA() {T___();}
+ void TDY() {T___();}
+ void TEN() {T___();}
+ void TFT() {T___();}
+ void TIM() {T___();}
+ void TKE() {T___();}
+ void TLA() {T___();}
+ void TLE() {T___();}
+ void TMT() {T___();}
+ void TOA() {T___();}
+ void TOF() {T___();}
+ void TOL() {T___();}
+ void TOR() {T___();}
+ void TOT() {T___();}
+ void TP1() {T___();}
+ void TP2() {T___();}
+ void TP3() {T___();}
+ void TP4() {T___();}
+ void TPA() {T___();}
+ void TPB() {T___();}
+ void TRC() {T___();}
+ void TRD() {T___();}
+ void TRK() {T___();}
+ void TSI() {T___();}
+ void TSS() {T___();}
+ void TT1() {T___();}
+ void TT2() {T___();}
+ void TT3() {T___();}
+ void TXT() {T___();}
+ void TXX() {TXXX();}
+ void TYE() {T___();}
+ void UFI() {Skip_XX(Element_Size, "Data");}
+ void ULT() {Skip_XX(Element_Size, "Data");}
+ void WAF() {W___();}
+ void WAR() {W___();}
+ void WAS() {W___();}
+ void WCM() {W___();}
+ void WCP() {W___();}
+ void WPB() {W___();}
+ void WXX() {WXXX();}
+ void XRVA() {RVA2();}
+
+ //Temp
+ ZtringList Element_Values;
+ Ztring Element_Value;
+ Ztring Year, Month, Day, Hour, Minute;
+ stream_t StreamKind;
+ int64u Id3v2_Size;
+ int8u Id3v2_Version;
+ bool Unsynchronisation_Global;
+ bool Unsynchronisation_Frame;
+ bool DataLengthIndicator;
+
+ //Helpers
+ void Fill_Name();
+ void Normalize_Date (Ztring& Date);
+};
+
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3.cpp b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3.cpp
new file mode 100644
index 000000000..e7d7bddf0
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3.cpp
@@ -0,0 +1,99 @@
+// File_Lyrics3 - Info for Lyrics3 tagged files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_LYRICS3_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Tag/File_Lyrics3.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Lyrics3::File_Lyrics3()
+:File__Analyze()
+{
+ //Configuration
+ TotalSize=(int64u)-1;
+}
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Lyrics3::Read_Buffer_Continue()
+{
+ if (TotalSize==(int64u)-1)
+ TotalSize=Buffer_Size;
+
+ //Coherency
+ if (TotalSize<20)
+ {
+ Reject("Lyrics3");
+ return;
+ }
+
+ //Buffer size
+ if (Buffer_Size<TotalSize)
+ return;
+
+ //Parsing
+ Element_Offset=0;
+ Element_Size=TotalSize;
+ Skip_Local(11, "Signature");
+ Skip_Local(TotalSize-20, "Lyrics");
+ Skip_Local(9, "Signature");
+
+ //Filling
+ Accept("Lyric3");
+
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Codec, "Lyrics3");
+
+ Finish("Lyrics3");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_LYRICS3_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3.h b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3.h
new file mode 100644
index 000000000..1dce89de6
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3.h
@@ -0,0 +1,56 @@
+// File_Lyrics3 - Info for Lyrics3 tagged files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Lyrics3 tagged files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Lyrics3H
+#define MediaInfo_File_Lyrics3H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Lyrics3
+//***************************************************************************
+
+class File_Lyrics3 : public File__Analyze
+{
+public :
+ //In
+ int64u TotalSize;
+
+ //Constructor/Destructor
+ File_Lyrics3();
+
+private :
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3v2.cpp b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3v2.cpp
new file mode 100644
index 000000000..52d4e5da8
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3v2.cpp
@@ -0,0 +1,237 @@
+// File_Lyrics3v2 - Info for Lyrics3v2 tagged files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_LYRICS3V2_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Tag/File_Lyrics3v2.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+namespace Elements
+{
+ const int32u AUT=0x415554;
+ const int32u CRC=0x435243;
+ const int32u EAL=0x45414C;
+ const int32u EAR=0x454152;
+ const int32u ETT=0x455454;
+ const int32u IMG=0x494D47;
+ const int32u IND=0x494E44;
+ const int32u INF=0x494E46;
+ const int32u LYR=0x4C5952;
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Lyrics3v2::File_Lyrics3v2()
+:File__Analyze()
+{
+ //Configuration
+ TotalSize=(int64u)-1;
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Lyrics3v2::FileHeader_Parse()
+{
+ if (TotalSize==(int64u)-1)
+ TotalSize=Buffer_Size;
+
+ //Parsing
+ Skip_Local(11, "Signature");
+
+ FILLING_BEGIN();
+ Accept("Lyrics3v2");
+
+ TotalSize-=11;
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Lyrics3v2::Header_Parse()
+{
+ if (TotalSize<=15) //First 10 is minimum size of a tag, Second 10 is ID3v2 header size
+ {
+ //Place for footer
+ Header_Fill_Code((int64u)-1, "File Footer");
+ Header_Fill_Size(TotalSize);
+ return;
+ }
+
+ //Parsing
+ Ztring SizeT;
+ int64u Size;
+ int32u Field;
+ Get_C3 (Field, "Field");
+ Get_Local(5, SizeT, "Size");
+ Size=8+SizeT.To_int64u();
+
+ //Filling
+ if (Size+15>TotalSize)
+ Size=TotalSize-15;
+ Header_Fill_Code(Field, Ztring().From_CC3(Field));
+ Header_Fill_Size(Size);
+ TotalSize-=Size;
+}
+
+//---------------------------------------------------------------------------
+void File_Lyrics3v2::Data_Parse()
+{
+ #define CASE_INFO(_NAME, _DETAIL) \
+ case Elements::_NAME : Element_Info1(_DETAIL); _NAME(); break;
+
+ //Parsing
+ switch (Element_Code)
+ {
+ CASE_INFO(AUT, "Lyrics Author Name");
+ CASE_INFO(CRC, "CRC");
+ CASE_INFO(EAL, "Extended Album name");
+ CASE_INFO(EAR, "Extended Artist name");
+ CASE_INFO(ETT, "Extended Track Title");
+ CASE_INFO(IMG, "Image location");
+ CASE_INFO(IND, "Indications field");
+ CASE_INFO(INF, "Additional information");
+ CASE_INFO(LYR, "Lyrics");
+ case (int64u)-1 : Footer(); break;
+ default : Skip_XX(Element_Size, "Data");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Lyrics3v2::Footer()
+{
+ //Parsing
+ Skip_Local(6, "Size");
+ Skip_Local(9, "Signature");
+
+ Finish("Lyrics3v2");
+}
+
+//---------------------------------------------------------------------------
+void File_Lyrics3v2::EAL()
+{
+ //Parsing
+ Ztring Value;
+ Get_Local(Element_Size, Value, "Value");
+
+ //Filling
+ Fill(Stream_General, 0, General_Album, Value);
+}
+
+//---------------------------------------------------------------------------
+void File_Lyrics3v2::EAR()
+{
+ //Parsing
+ Ztring Value;
+ Get_Local(Element_Size, Value, "Value");
+
+ //Filling
+ Fill(Stream_General, 0, General_Performer, Value);
+}
+
+//---------------------------------------------------------------------------
+void File_Lyrics3v2::ETT()
+{
+ //Parsing
+ Ztring Value;
+ Get_Local(Element_Size, Value, "Value");
+
+ //Filling
+ Fill(Stream_General, 0, General_Title, Value);
+}
+
+//---------------------------------------------------------------------------
+void File_Lyrics3v2::IND()
+{
+ //Parsing
+ if (Element_Size>=1)
+ Skip_Local(1, "lyrics present");
+ if (Element_Size>=2)
+ Skip_Local(1, "timestamp in lyrics");
+ if (Element_Size>=3)
+ Skip_Local(1, "inhibits tracks for random selection");
+ while (Element_Offset<Element_Size)
+ Skip_Local(1, "unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Lyrics3v2::INF()
+{
+ //Parsing
+ Ztring Value;
+ Get_Local(Element_Size, Value, "Value");
+
+ //Filling
+ Fill(Stream_General, 0, General_Comment, Value);
+}
+
+//---------------------------------------------------------------------------
+void File_Lyrics3v2::LYR()
+{
+ //Parsing
+ Skip_XX(Element_Size, "Value");
+
+ //Filling
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Codec, "Lyrics3v2");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_LYRICS3V2_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3v2.h b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3v2.h
new file mode 100644
index 000000000..8b606b21c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_Lyrics3v2.h
@@ -0,0 +1,73 @@
+// File_Lyrics3v2 - Info for Lyrics3v2 tagged files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Lyrics3v2 tagged files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Lyrics3v2H
+#define MediaInfo_File_Lyrics3v2H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Lyrics3v2
+//***************************************************************************
+
+class File_Lyrics3v2 : public File__Analyze
+{
+public :
+ //In
+ int64u TotalSize;
+
+ //Constructor/Destructor
+ File_Lyrics3v2();
+
+private :
+ //Buffer - File header
+ void FileHeader_Parse();
+
+ //Buffer - Per element
+ void Header_Parse ();
+ void Data_Parse ();
+
+ //Elements
+ void Header();
+ void Footer();
+ void AUT() {Skip_Local(Element_Size, "Value");}
+ void CRC() {Skip_Local(Element_Size, "Value");}
+ void EAL();
+ void EAR();
+ void ETT();
+ void IMG() {Skip_Local(Element_Size, "Value");}
+ void IND();
+ void INF();
+ void LYR();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_VorbisCom.cpp b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_VorbisCom.cpp
new file mode 100644
index 000000000..27347cdc1
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_VorbisCom.cpp
@@ -0,0 +1,356 @@
+// File_VorbisCom - Info for VorbisComments tagged files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_VORBISCOM_YES) || defined(MEDIAINFO_OGG_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Tag/File_VorbisCom.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+extern const char* Id3v2_PictureType(int8u Type); //In Tag/File_Id3v2.cpp
+extern std::string ExtensibleWave_ChannelMask (int32u ChannelMask); //In Multiple/File_Riff_Elements.cpp
+extern std::string ExtensibleWave_ChannelMask2 (int32u ChannelMask); //In Multiple/File_Riff_Elements.cpp
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_VorbisCom::File_VorbisCom()
+:File__Analyze()
+{
+ //In
+ StreamKind_Specific=Stream_General;
+ StreamKind_Multiple=Stream_General;
+ StreamKind_Common =Stream_General;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_VorbisCom::Streams_Fill()
+{
+ if (!Performers.empty())
+ {
+ Artists.Separator_Set(0, _T(" / "));
+ Fill(StreamKind_Common, 0, "Performer", Performers.Read());
+ }
+
+ if (!Artists.empty() && Artists!=Performers)
+ {
+ Artists.Separator_Set(0, _T(" / "));
+ Fill(StreamKind_Common, 0, Performers.empty()?"Performer":"Composer", Artists.Read());
+ }
+
+ if (!Accompaniments.empty() && Accompaniments!=Artists && Accompaniments!=Performers)
+ {
+ Artists.Separator_Set(0, _T(" / "));
+ Fill(StreamKind_Common, 0, "Accompaniment", Accompaniments.Read());
+ }
+
+ if (!AlbumArtists.empty())
+ {
+ AlbumArtists.Separator_Set(0, _T(" / "));
+ Fill(StreamKind_Common, 0, (Performers==Artists || Performers.empty())?"Album/Performer":"Album/Composer", AlbumArtists.Read());
+ }
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_VorbisCom::FileHeader_Parse()
+{
+ //Parsing
+ Ztring vendor_string;
+ int32u vendor_length;
+ Get_L4 (vendor_length, "vendor_length");
+ Get_Local(vendor_length, vendor_string, "vendor_string");
+ Get_L4 (user_comment_list_length, "user_comment_list_length");
+
+ FILLING_BEGIN();
+ Accept("VorbisCom");
+
+ if (Count_Get(Stream_General)==0)
+ Stream_Prepare(Stream_General);
+ if (StreamKind_Specific!=Stream_General)
+ Stream_Prepare(StreamKind_Specific);
+ if (StreamKind_Multiple!=Stream_General && StreamKind_Multiple!=StreamKind_Specific)
+ Stream_Prepare(StreamKind_Multiple);
+
+ //vendor_string
+ if (StreamKind_Specific!=Stream_Audio && vendor_string.find(_T("Xiph.Org libVorbis"))==0)
+ vendor_string.clear(); //string was set "by default"
+ Ztring Library_Name, Library_Version, Library_Date;
+ Ztring vendor_string_Without=vendor_string; vendor_string_Without.FindAndReplace(_T(";"), _T(""), 0, Ztring_Recursive);
+ Library_Version=MediaInfoLib::Config.Library_Get(InfoLibrary_Format_VorbisCom, vendor_string_Without, InfoLibrary_Version);
+ Library_Date=MediaInfoLib::Config.Library_Get(InfoLibrary_Format_VorbisCom, vendor_string_Without, InfoLibrary_Date);
+ if (Library_Version.empty())
+ {
+ if (vendor_string.find(_T(" I "))!=std::string::npos)
+ {
+ Library_Name=vendor_string.SubString(_T(""), _T(" I "));
+ Library_Date=vendor_string.SubString(_T(" I "), _T(""));
+ if (Library_Date.size()>9)
+ {
+ Library_Version=Library_Date.substr(9, std::string::npos);
+ if (Library_Version.find(_T("("))==std::string::npos)
+ {
+ Library_Version.FindAndReplace(_T(" "), _T("."), 0, Ztring_Recursive);
+ Library_Date.resize(8);
+ }
+ }
+ }
+ else if (vendor_string.size()>9 && Ztring(vendor_string.substr(vendor_string.size()-8, std::string::npos)).To_int32u()>20000000)
+ {
+ Library_Name=vendor_string.substr(0, vendor_string.size()-9);
+ Library_Date=vendor_string.substr(vendor_string.size()-8, std::string::npos);
+ if (!Library_Name.empty())
+ {
+ std::string::size_type Pos=Library_Name.rfind(_T(' '));
+ if (Pos<Library_Name.size()-2 && Library_Name[Pos+1]>=_T('0') && Library_Name[Pos+1]<=_T('9'))
+ {
+ Library_Version=Library_Name.substr(Pos+1, std::string::npos);
+ Library_Name.resize(Pos);
+ }
+ }
+ }
+ else if (vendor_string.find(_T("aoTuV "))!=std::string::npos)
+ {
+ Library_Name=_T("aoTuV");
+ Library_Version=vendor_string.SubString(_T("aoTuV "), _T("["));
+ Library_Date=vendor_string.SubString(_T("["), _T("]"));
+ }
+ else if (vendor_string.find(_T("Lancer "))!=std::string::npos)
+ {
+ Library_Name=_T("Lancer");
+ Library_Date=vendor_string.SubString(_T("["), _T("]"));
+ }
+ if (Library_Version.empty())
+ Library_Version=Library_Date;
+ if (Library_Date.size()==8)
+ {
+ Library_Date.insert(6, 1, _T('-'));
+ Library_Date.insert(4, 1, _T('-'));
+ Library_Date.insert(0, _T("UTC "));
+ }
+ }
+ if (vendor_string.find(_T("libFLAC"))!=std::string::npos) Library_Name="libFLAC";
+ if (vendor_string.find(_T("libVorbis I"))!=std::string::npos) Library_Name="libVorbis";
+ if (vendor_string.find(_T("libTheora I"))!=std::string::npos) Library_Name="libTheora";
+ if (vendor_string.find(_T("AO; aoTuV"))==0) Library_Name="aoTuV";
+ if (vendor_string.find(_T("BS; Lancer"))==0) Library_Name="Lancer";
+
+ Fill(StreamKind_Specific, 0, "Encoded_Library", vendor_string);
+ Fill(StreamKind_Specific, 0, "Encoded_Library/Name", Library_Name);
+ Fill(StreamKind_Specific, 0, "Encoded_Library/Version", Library_Version);
+ Fill(StreamKind_Specific, 0, "Encoded_Library/Date", Library_Date);
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_VorbisCom::Header_Parse()
+{
+ //Parsing
+ int32u user_comment_length;
+ Get_L4 (user_comment_length, "length");
+
+ //Filling
+ Header_Fill_Size(Element_Offset+user_comment_length);
+}
+
+//---------------------------------------------------------------------------
+void File_VorbisCom::Data_Parse()
+{
+ user_comment_list_length--;
+
+ //Parsing
+ Ztring comment;
+ Get_UTF8(Element_Size, comment, "comment");
+ if (Element_Size && comment.empty())
+ {
+ Element_Offset=0; //Retry
+ Get_Local(Element_Size, comment, "comment");
+ }
+ Element_Name(comment);
+
+ FILLING_BEGIN_PRECISE();
+ Ztring Key=comment.SubString(_T(""), _T("="));
+ Key.MakeUpperCase();
+ Ztring Value=comment.SubString(_T("="), _T(""));
+
+ if (Key==_T("ADDED_TIMESTAMP")) Fill(StreamKind_Common, 0, "Added_Date", Ztring().Date_From_Milliseconds_1601(Value.To_int64u()/1000));
+ else if (Key==_T("ALBUM ARTIST")) AlbumArtists.push_back(Value);
+ else if (Key==_T("ALBUM")) Fill(StreamKind_Common, 0, "Album", Value);
+ else if (Key==_T("ALBUM_COMMENT")) Fill(StreamKind_Common, 0, "Comment", Value);
+ else if (Key==_T("ALBUMARTIST")) AlbumArtists.push_back(Value);
+ else if (Key==_T("ARTIST")) Artists.push_back(Value);
+ else if (Key==_T("AUTHOR")) Fill(StreamKind_Common, 0, "WrittenBy", Value);
+ else if (Key==_T("BUYCDURL")) {}
+ else if (Key==_T("CLASS")) Fill(StreamKind_Common, 0, "ContentType", Value);
+ else if (Key==_T("COMPOSER")) Fill(StreamKind_Common, 0, "Composer", Value);
+ else if (Key==_T("COMMENT")) Fill(StreamKind_Common, 0, "Comment", Value);
+ else if (Key==_T("COMMENTS")) Fill(StreamKind_Common, 0, "Comment", Value);
+ else if (Key==_T("CONDUCTOR")) Fill(StreamKind_Common, 0, "Conductor", Value);
+ else if (Key==_T("CONTACT")) Fill(StreamKind_Common, 0, "Publisher", Value);
+ else if (Key==_T("COPYRIGHT")) Fill(StreamKind_Common, 0, "Copyright", Value);
+ else if (Key==_T("DATE")) Fill(StreamKind_Common, 0, "Recorded_Date", Value, true);
+ else if (Key==_T("DESCRIPTION")) Fill(StreamKind_Common, 0, "Description", Value);
+ else if (Key==_T("DISC")) Fill(StreamKind_Common, 0, "Part", Value, true);
+ else if (Key==_T("DISCID")) {}
+ else if (Key==_T("DISCNUMBER")) Fill(StreamKind_Common, 0, "Part", Value, true);
+ else if (Key==_T("ENCODEDBY")) Fill(StreamKind_Common, 0, "EncodedBy", Value);
+ else if (Key==_T("ENCODED-BY")) Fill(StreamKind_Common, 0, "EncodedBy", Value);
+ else if (Key==_T("ENCODER")) Fill(StreamKind_Common, 0, "Encoded_Application", Value);
+ else if (Key==_T("ENCODED_USING")) Fill(StreamKind_Common, 0, "Encoded_Application", Value);
+ else if (Key==_T("ENCODER_URL")) Fill(StreamKind_Common, 0, "Encoded_Application/Url", Value);
+ else if (Key==_T("ENSEMBLE")) Accompaniments.push_back(Value);
+ else if (Key==_T("GENRE")) Fill(StreamKind_Common, 0, "Genre", Value);
+ else if (Key==_T("FIRST_PLAYED_TIMESTAMP")) Fill(StreamKind_Common, 0, "Played_First_Date", Ztring().Date_From_Milliseconds_1601(Value.To_int64u()/10000));
+ else if (Key==_T("ISRC")) Fill(StreamKind_Multiple, 0, "ISRC", Value);
+ else if (Key==_T("LABEL")) Fill(StreamKind_Common, 0, "Label", Value);
+ else if (Key==_T("LANGUAGE")) {if (Value.find(_T("Director"))==0) Fill(StreamKind_Specific, 0, "Language_More", Value); else if (!Value.SubString(_T("["), _T("]")).empty()) Fill(StreamKind_Specific, 0, "Language", Value.SubString(_T("["), _T("]"))); else Fill(StreamKind_Specific, 0, "Language", Value);}
+ else if (Key==_T("LAST_PLAYED_TIMESTAMP")) Fill(StreamKind_Multiple, 0, "Played_Last_Date", Ztring().Date_From_Milliseconds_1601(Value.To_int64u()/10000));
+ else if (Key==_T("LICENCE")) Fill(StreamKind_Common, 0, "TermsOfUse", Value);
+ else if (Key==_T("LICENSE")) Fill(StreamKind_Common, 0, "TermsOfUse", Value);
+ else if (Key==_T("LYRICS")) Fill(StreamKind_Common, 0, "Lyrics", Value);
+ else if (Key==_T("LWING_GAIN")) Fill(StreamKind_Multiple, 0, "ReplayGain_Gain", Value.To_float64(), 2);
+ else if (Key==_T("LOCATION")) Fill(StreamKind_Common, 0, "Recorded/Location", Value);
+ else if (Key==_T("MUSICBRAINZ_ALBUMID")) {}
+ else if (Key==_T("MUSICBRAINZ_ALBUMARTISTID")) {}
+ else if (Key==_T("MUSICBRAINZ_ARTISTID")) {}
+ else if (Key==_T("MUSICBRAINZ_TRACKID")) {}
+ else if (Key==_T("MUSICBRAINZ_SORTNAME")) Fill(StreamKind_Common, 0, "Performer/Sort", Value);
+ else if (Key==_T("MUSICBRAINZ_DISCID")) {}
+ else if (Key==_T("ORGANIZATION")) Fill(StreamKind_Common, 0, "Producer", Value);
+ else if (Key==_T("PERFORMER")) Performers.push_back(Value);
+ else if (Key==_T("PLAY_COUNT")) Fill(StreamKind_Multiple, 0, "Played_Count", Value.To_int64u());
+ else if (Key==_T("RATING")) Fill(StreamKind_Multiple, 0, "Rating", Value);
+ else if (Key==_T("REPLAYGAIN_ALBUM_GAIN")) Fill(StreamKind_Common, 0, "Album_ReplayGain_Gain", Value.To_float64(), 2);
+ else if (Key==_T("REPLAYGAIN_ALBUM_PEAK")) Fill(StreamKind_Common, 0, "Album_ReplayGain_Peak", Value.To_float64(), 6);
+ else if (Key==_T("REPLAYGAIN_REFERENCE_LOUDNESS")) {}
+ else if (Key==_T("REPLAYGAIN_TRACK_GAIN")) Fill(StreamKind_Specific, 0, "ReplayGain_Gain", Value.To_float64(), 2);
+ else if (Key==_T("REPLAYGAIN_TRACK_PEAK")) Fill(StreamKind_Specific, 0, "ReplayGain_Peak", Value.To_float64(), 6);
+ else if (Key==_T("TITLE")) Fill(StreamKind_Common, 0, "Title", Value);
+ else if (Key==_T("TOTALTRACKS")) Fill(StreamKind_Common, 0, "Track/Position_Total", Value);
+ else if (Key==_T("TOTALDISCS")) Fill(StreamKind_Common, 0, "Part/Position_Total", Value);
+ else if (Key==_T("TRACK_COMMENT")) Fill(StreamKind_Multiple, 0, "Comment", Value);
+ else if (Key==_T("TRACKNUMBER")) Fill(StreamKind_Multiple, 0, "Track/Position", Value);
+ else if (Key==_T("TRACKTOTAL")) Fill(StreamKind_Multiple, 0, "Track/Position_Total", Value);
+ else if (Key==_T("VERSION")) Fill(StreamKind_Common, 0, "Track/More", Value);
+ else if (Key==_T("BPM")) Fill(StreamKind_Common, 0, "BPM", Value);
+ else if (Key==_T("WAVEFORMATEXTENSIBLE_CHANNEL_MASK"))
+ {
+ //This is an hexadecimal value
+ if (Value.size()>2 && Value[0]==_T('0') && Value[1]==_T('x'))
+ {
+ int16u ValueI=0;
+ for (size_t Pos=2; Pos<Value.size(); Pos++)
+ {
+ ValueI*=16;
+ if (Value[Pos]>=_T('0') && Value[Pos]<=_T('9'))
+ ValueI+=Value[Pos]-_T('0');
+ else if (Value[Pos]>=_T('A') && Value[Pos]<=_T('F'))
+ ValueI+=10+Value[Pos]-_T('A');
+ else if (Value[Pos]>=_T('a') && Value[Pos]<=_T('f'))
+ ValueI+=10+Value[Pos]-_T('a');
+ else
+ break;
+ }
+ Fill(Stream_Audio, 0, Audio_ChannelPositions, ExtensibleWave_ChannelMask(ValueI));
+ Fill(Stream_Audio, 0, Audio_ChannelPositions_String2, ExtensibleWave_ChannelMask2(ValueI));
+ }
+ }
+ else if (Key==_T("YEAR")) {if (Value!=Retrieve(StreamKind_Common, 0, "Recorded_Date")) Fill(StreamKind_Common, 0, "Recorded_Date", Value);}
+ else if (Key.find(_T("COVERART"))==0)
+ {
+ if (Key==_T("COVERARTCOUNT"))
+ ;
+ else if (Key.find(_T("COVERARTMIME"))==0)
+ Fill(Stream_General, 0, General_Cover_Mime, Value);
+ else if (Key.find(_T("COVERARTFILELINK"))==0)
+ Fill(Stream_General, 0, General_Cover_Data, _T("file://")+Value);
+ else if (Key.find(_T("COVERARTTYPE"))==0)
+ Fill(Stream_General, 0, General_Cover_Type, Id3v2_PictureType(Value.To_int8u()));
+ }
+ else if (Key.find(_T("CHAPTER"))==0)
+ {
+ if (Count_Get(Stream_Menu)==0)
+ {
+ Stream_Prepare(Stream_Menu);
+ Fill(Stream_Menu, StreamPos_Last, Menu_Chapters_Pos_Begin, Count_Get(Stream_Menu, StreamPos_Last), 10, true);
+ }
+ if (Key.find(_T("NAME"))==Error)
+ {
+ Chapter_Pos=Key.SubString(_T("CHAPTER"), _T(""));
+ Chapter_Time=Value;
+ }
+ else
+ {
+ Value.FindAndReplace(_T("\n"), _T(""), Count_Get(Stream_Text)-1); //Some chapters names have extra characters, not needed
+ Value.FindAndReplace(_T("\r"), _T(""), Count_Get(Stream_Text)-1); //Some chapters names have extra characters, not needed
+ Value.FindAndReplace(_T(" "), _T(""), Count_Get(Stream_Text)-1); //Some chapters names have extra characters, not needed
+ Fill(Stream_Menu, 0, Chapter_Time.To_UTF8().c_str(), Value);
+ }
+ Fill(Stream_Menu, StreamPos_Last, Menu_Chapters_Pos_End, Count_Get(Stream_Menu, StreamPos_Last), 10, true);
+ }
+ else Fill(Stream_General, 0, comment.SubString(_T(""), _T("=")).To_Local().c_str(), Value);
+ FILLING_END();
+
+ if (user_comment_list_length==0)
+ Finish("VorbisCom");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_VORBISCOM_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File_VorbisCom.h b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_VorbisCom.h
new file mode 100644
index 000000000..a870f4051
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File_VorbisCom.h
@@ -0,0 +1,75 @@
+// File_VorbisCom - Info for VorbisComments tagged files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Vorbis comments
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_VorbisComH
+#define MediaInfo_File_VorbisComH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "ZenLib/ZtringList.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_VorbisCom
+//***************************************************************************
+
+class File_VorbisCom : public File__Analyze
+{
+public :
+ //In
+ stream_t StreamKind_Specific; //Always in this stream kind whatever is the configuration
+ stream_t StreamKind_Multiple; //Specific stream kind depend if there is multiple streams or not
+ stream_t StreamKind_Common; //Stream kind for common values
+
+ //Constructor/Destructor
+ File_VorbisCom();
+
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - File header
+ void FileHeader_Parse();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Temp
+ int32u user_comment_list_length;
+ Ztring Chapter_Pos;
+ Ztring Chapter_Time;
+ ZtringList Performers;
+ ZtringList Artists;
+ ZtringList Accompaniments;
+ ZtringList AlbumArtists;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File__Tags.cpp b/src/thirdparty/MediaInfo/MediaInfo/Tag/File__Tags.cpp
new file mode 100644
index 000000000..587ed678a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File__Tags.cpp
@@ -0,0 +1,604 @@
+// File__Tags - Info for all kind of framed tags tagged files
+// Copyright (C) 2005-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Tag/File__Tags.h"
+#if defined(MEDIAINFO_APETAG_YES)
+ #include "MediaInfo/Tag/File_ApeTag.h"
+#endif //MEDIAINFO_APETAG_YES
+#if defined(MEDIAINFO_ID3_YES)
+ #include "MediaInfo/Tag/File_Id3.h"
+#endif //MEDIAINFO_ID3_YES
+#if defined(MEDIAINFO_ID3V2_YES)
+ #include "MediaInfo/Tag/File_Id3v2.h"
+#endif //MEDIAINFO_ID3V2_YES
+#if defined(MEDIAINFO_LYRICS3_YES)
+ #include "MediaInfo/Tag/File_Lyrics3.h"
+#endif //MEDIAINFO_LYRICS3_YES
+#if defined(MEDIAINFO_LYRICS3V2_YES)
+ #include "MediaInfo/Tag/File_Lyrics3v2.h"
+#endif //MEDIAINFO_LYRICS3V2_YES
+ #include "MediaInfo/File_Unknown.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File__Tags_Helper::File__Tags_Helper()
+{
+ //In
+ Base=NULL;
+
+ //Out
+ TagsSize=0;
+ File_BeginTagSize=0;
+ File_EndTagSize=0;
+
+ //Temp
+ Parser=NULL;
+ Parser_Streams_Fill=NULL;
+ Id3v1_Offset=(int64u)-1;
+ Lyrics3_Offset=(int64u)-1;
+ Lyrics3v2_Offset=(int64u)-1;
+ ApeTag_Offset=(int64u)-1;
+ JumpTo_WantedByParser=(int64u)-1;
+ Id3v1_Size=0;
+ Lyrics3_Size=0;
+ Lyrics3v2_Size=0;
+ ApeTag_Size=0;
+ TagSizeIsFinal=false;
+ SearchingForEndTags=false;
+}
+
+//---------------------------------------------------------------------------
+File__Tags_Helper::~File__Tags_Helper()
+{
+ delete Parser; //Parser=NULL;
+ delete Parser_Streams_Fill; //Parser_Streams_Fill=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Tags_Helper::Streams_Fill()
+{
+ if (Parser_Streams_Fill && Parser_Streams_Fill->Status[File__Analyze::IsAccepted])
+ {
+ Parser_Streams_Fill->Read_Buffer_Finalize();
+ Base->Merge(*Parser_Streams_Fill, Stream_General, 0, 0, false);
+ Base->Merge(*Parser_Streams_Fill, Stream_Audio , 0, 0, false);
+ }
+ delete Parser_Streams_Fill; Parser_Streams_Fill=NULL;
+}
+
+//---------------------------------------------------------------------------
+void File__Tags_Helper::Streams_Finish()
+{
+ if (!Base->IsSub)
+ {
+ Base->Fill(Stream_General, 0, General_StreamSize, TagsSize+Base->Retrieve(Stream_General, 0, General_StreamSize).To_int64u(), 10, true);
+ if (Base->Retrieve(Stream_Audio, 0, Audio_StreamSize).empty())
+ Base->Fill(Stream_Audio, 0, Audio_StreamSize, Base->File_Size-TagsSize);
+ }
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File__Tags_Helper::Read_Buffer_Continue()
+{
+ //Tags
+ bool Tag_Found;
+ if (File__Tags_Helper::Synchronize(Tag_Found) && Tag_Found)
+ File__Tags_Helper::Synched_Test();
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File__Tags_Helper::Synchronize(bool &Tag_Found, size_t Synchro_Offset)
+{
+ //Buffer size
+ if (Parser)
+ {
+ Synched_Test();
+ if (Parser)
+ return false;
+ }
+
+ if (SearchingForEndTags)
+ {
+ GoTo(0, "Tags detected");
+ return false;
+ }
+
+ //ID
+ if (Base->Buffer_Offset+Synchro_Offset+3>Base->Buffer_Size)
+ return false;
+ switch (Base->Buffer[Base->Buffer_Offset+Synchro_Offset])
+ {
+ case 0x49 : //"ID3"
+ switch (CC3(Base->Buffer+Base->Buffer_Offset+Synchro_Offset))
+ {
+ case 0x494433 : //"ID3"
+ if (Synchro_Offset)
+ {
+ Tag_Found=true; //This is an ID3 tag after a complete chunk, waiting for the chunk to be parsed
+ return true;
+ }
+ if (!Synched_Test()) //Handling begin/intermediate Id3v2
+ return false;
+ return Synchronize(Tag_Found, Synchro_Offset);
+ default : if (Base->File_Offset+Base->Buffer_Offset==ApeTag_Offset)
+ {
+ Tag_Found=true;
+ return true;
+ };
+ }
+ break;
+ case 0x54 : //"TAG"
+ case 0x4C : //"LYR"
+ case 0x41 : //"APE"
+ switch (CC3(Base->Buffer+Base->Buffer_Offset+Synchro_Offset))
+ {
+ case 0x544147 : //"TAG"
+ case 0x4C5952 : //"LYR"
+ case 0x415045 : //"APE"
+ if (TagSizeIsFinal && Base->File_Offset+Base->Buffer_Offset==Base->File_Size-File_EndTagSize)
+ {
+ Tag_Found=true;
+ return Synched_Test();
+ }
+ else if (Base->File_Offset+Base->Buffer_Size==Base->File_Size)
+ {
+ while (!TagSizeIsFinal && DetectBeginOfEndTags_Test());
+ Tag_Found=Base->File_Offset+Base->Buffer_Offset==Base->File_Size-File_EndTagSize;
+ return true;
+ }
+ else
+ return false; //Need more data
+ default : if (Base->File_Offset+Base->Buffer_Offset==ApeTag_Offset)
+ {
+ Tag_Found=true;
+ return true;
+ };
+ }
+ break;
+ default : if (Base->File_Offset+Base->Buffer_Offset==ApeTag_Offset)
+ {
+ Tag_Found=true;
+ return true;
+ };
+ }
+
+ Tag_Found=false;
+ return Base->File_GoTo==(int64u)-1;
+}
+
+//---------------------------------------------------------------------------
+bool File__Tags_Helper::Synched_Test()
+{
+ for (;;)
+ {
+ if (!Parser)
+ {
+ //Must have enough buffer for having header
+ if (Base->Buffer_Offset+4>Base->Buffer_Size)
+ return Base->IsSub; //If IsSub, we consider this is a complete block
+
+ //Quick test of synchro
+ int32u ID=CC3(Base->Buffer+Base->Buffer_Offset);
+ int32u ID4=CC4(Base->Buffer+Base->Buffer_Offset);
+ if (ID==0x494433) //"ID3"
+ {
+ if (Base->Buffer_Offset+10>Base->Buffer_Size)
+ return false;
+ #ifdef MEDIAINFO_ID3V2_YES
+ Parser=new File_Id3v2;
+ #else
+ Parser=new File_Unknown;
+ #endif
+ int32u Size=BigEndian2int32u(Base->Buffer+Base->Buffer_Offset+6);
+ Parser_Buffer_Size=(((Size>>0)&0x7F)
+ | ((Size>>1)&0x3F80)
+ | ((Size>>2)&0x1FC000)
+ | ((Size>>3)&0x0FE00000))
+ +10;
+ File_BeginTagSize+=Parser_Buffer_Size;
+ if (Base->File_Offset_FirstSynched==(int64u)-1)
+ Base->Buffer_TotalBytes_FirstSynched_Max+=Parser_Buffer_Size;
+ Base->Element_Begin1("Id3v2");
+ }
+ else if (ID4==0x5441472B) //"TAG+"
+ {
+ #ifdef MEDIAINFO_ID3_YES
+ Parser=new File_Id3;
+ #else
+ Parser=new File_Unknown;
+ #endif
+ Parser_Buffer_Size=227+128;
+ Base->Element_Begin1("Id3+");
+ }
+ else if (ID==0x544147) //"TAG"
+ {
+ #ifdef MEDIAINFO_ID3_YES
+ Parser=new File_Id3;
+ #else
+ Parser=new File_Unknown;
+ #endif
+ Parser_Buffer_Size=128;
+ Base->Element_Begin1("Id3");
+ }
+ else if (Base->File_Offset+Base->Buffer_Offset==Lyrics3_Offset)
+ {
+ #ifdef MEDIAINFO_LYRICS3_YES
+ Parser=new File_Lyrics3;
+ ((File_Lyrics3*)Parser)->TotalSize=Lyrics3_Size;
+ #else
+ Parser=new File__Analyze;
+ #endif
+ Parser_Buffer_Size=(size_t)Lyrics3_Size;
+ Base->Element_Begin1("Lyrics3");
+ }
+ else if (Base->File_Offset+Base->Buffer_Offset==Lyrics3v2_Offset)
+ {
+ #ifdef MEDIAINFO_LYRICS3V2_YES
+ Parser=new File_Lyrics3v2;
+ ((File_Lyrics3v2*)Parser)->TotalSize=Lyrics3v2_Size;
+ #else
+ Parser=new File_Unknown;
+ #endif
+ Parser_Buffer_Size=(size_t)Lyrics3v2_Size;
+ Base->Element_Begin1("Lyrics3v2");
+ }
+ else if (Base->File_Offset+Base->Buffer_Offset==ApeTag_Offset)
+ {
+ #ifdef MEDIAINFO_APETAG_YES
+ Parser=new File_ApeTag;
+ #else
+ Parser=new File_Unknown;
+ #endif
+ Parser_Buffer_Size=(size_t)ApeTag_Size;
+ Base->Element_Begin1("ApeTag");
+ }
+ else
+ break;
+ Base->Open_Buffer_Init(Parser);
+ }
+
+ //We continue
+ if (Parser)
+ {
+ int64u Size_ToParse=(Parser_Buffer_Size<Base->Buffer_Size-Base->Buffer_Offset)?Parser_Buffer_Size:(Base->Buffer_Size-Base->Buffer_Offset);
+ Base->Open_Buffer_Continue(Parser, Base->Buffer+Base->Buffer_Offset, (size_t)Size_ToParse);
+ Base->Buffer_Offset+=(size_t)Size_ToParse;
+ TagsSize+=Size_ToParse;
+ Parser_Buffer_Size-=(size_t)Size_ToParse;
+ if (Parser->Status[File__Analyze::IsFinished] || Parser_Buffer_Size==0)
+ {
+ if (Base->Status[File__Analyze::IsAccepted] && Parser->Count_Get(Stream_General)>0)
+ {
+ if (!Base->Status[File__Analyze::IsFilled])
+ Base->Fill();
+ Parser->Read_Buffer_Finalize();
+ Base->Merge(*Parser, Stream_General, 0, 0, false);
+ Base->Merge(*Parser, Stream_Audio , 0, 0, false);
+ delete Parser; Parser=NULL;
+ }
+ else if (Parser_Streams_Fill==NULL) //Currently using only the first detected tag
+ {
+ Parser_Streams_Fill=Parser; Parser=NULL;
+ }
+ else
+ {
+ delete Parser; Parser=NULL;
+ }
+ if (Parser_Buffer_Size)
+ Base->Skip_XX(Parser_Buffer_Size, "Data continued");
+ Base->Element_Show();
+ Base->Element_End0();
+ }
+ else
+ break;
+ }
+ }
+
+ return true;
+}
+
+//***************************************************************************
+// Streams
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t File__Tags_Helper::Stream_Prepare(stream_t StreamKind)
+{
+ if (Base->Count_Get(StreamKind))
+ return 1; //Only one is permited
+ return Base->Stream_Prepare(StreamKind);
+}
+
+//***************************************************************************
+// End
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File__Tags_Helper::GoTo (int64u GoTo, const char* ParserName)
+{
+ if (Base->IsSub)
+ {
+ Base->GoTo(GoTo, ParserName);
+ return;
+ }
+
+ //Normal Data_GoTo;
+
+ //Configuring
+ if (!SearchingForEndTags)
+ {
+ if (GoTo==(int64u)-1)
+ JumpTo_WantedByParser=Base->File_Offset+Base->Buffer_Offset;
+ else
+ JumpTo_WantedByParser=GoTo;
+ SearchingForEndTags=true;
+ }
+
+ //Trying to parse tags
+ while (!TagSizeIsFinal && DetectBeginOfEndTags_Test());
+
+ //If a jump is requested
+ if (!TagSizeIsFinal)
+ return;
+
+ //Positionning (if finnished)
+ if (TagSizeIsFinal)
+ {
+ if (JumpTo_WantedByParser!=(int64u)-1)
+ {
+ if (JumpTo_WantedByParser<Id3v1_Size+Lyrics3_Size+Lyrics3v2_Size+ApeTag_Size)
+ Base->GoTo(JumpTo_WantedByParser, ParserName);
+ else
+ Base->GoTo(JumpTo_WantedByParser-Id3v1_Size-Lyrics3_Size-Lyrics3v2_Size-ApeTag_Size, ParserName);
+ }
+ SearchingForEndTags=false;
+ }
+ else
+ Base->GoTo(GoTo, ParserName);
+}
+
+//---------------------------------------------------------------------------
+void File__Tags_Helper::GoToFromEnd (int64u GoToFromEnd, const char* ParserName)
+{
+ if (GoToFromEnd>Base->File_Size)
+ {
+ if (ParserName)
+ {
+ bool MustElementBegin=Base->Element_Level?true:false;
+ if (Base->Element_Level>0)
+ Base->Element_End0(); //Element
+ Base->Info(Ztring(ParserName)+_T(", wants to go to somewhere, but not valid"));
+ if (MustElementBegin)
+ Base->Element_Level++;
+ }
+ Finish(ParserName);
+ return;
+ }
+
+ GoTo(Base->File_Size-GoToFromEnd, ParserName);
+}
+
+//---------------------------------------------------------------------------
+void File__Tags_Helper::Accept (const char* ParserName)
+{
+ Base->Accept(ParserName);
+}
+
+//---------------------------------------------------------------------------
+void File__Tags_Helper::Reject (const char* ParserName)
+{
+ Base->Reject(ParserName);
+}
+
+//---------------------------------------------------------------------------
+void File__Tags_Helper::Finish (const char* ParserName)
+{
+ if (ParserName)
+ {
+ bool MustElementBegin=Base->Element_Level?true:false;
+ if (Base->Element_Level>0)
+ Base->Element_End0(); //Element
+ Base->Info(Ztring(ParserName)+_T(", finished but searching tags"));
+ if (MustElementBegin)
+ Base->Element_Level++;
+ }
+
+ GoToFromEnd(0, ParserName);
+}
+
+//---------------------------------------------------------------------------
+bool File__Tags_Helper::DetectBeginOfEndTags_Test()
+{
+ TagSizeIsFinal=true;
+
+ //Id3v1
+ if (Id3v1_Size==0 && File_EndTagSize==0 && Base->File_Size>=128) //Only one, at the end, larger than 128 bytes
+ {
+ if (Base->File_Offset>Base->File_Size-128-32) //Must be at least at the end less 128 bytes
+ {
+ Base->GoTo(Base->File_Size-128-32, "Tags detection"); //32 to be able to quickly see another tag system
+ TagSizeIsFinal=false;
+ return false;
+ }
+
+ if (Base->File_Offset+Base->Buffer_Size<Base->File_Size) //Must be at least at the end less 128 bytes of tags
+ {
+ if (Base->File_Offset<Base->File_Size-128-32)
+ Base->GoTo(Base->File_Size-128-32, "Tags detection");
+ TagSizeIsFinal=false;
+ return false;
+ }
+
+ if (CC3(Base->Buffer+((size_t)((Base->File_Size-128)-Base->File_Offset)))==CC3("TAG"))
+ {
+ Id3v1_Size=128;
+ File_EndTagSize+=128;
+ Id3v1_Offset=Base->File_Size-File_EndTagSize;
+ TagSizeIsFinal=false;
+ }
+ }
+
+ //Lyrics3
+ if (Lyrics3_Size==0 && Base->File_Size>=File_EndTagSize+9) //Only one, larger than File_EndTagSize+15 bytes
+ {
+ if (Base->File_Offset>Base->File_Size-File_EndTagSize-9) //Must be at the end less 15 bytes
+ {
+ Base->GoTo(Base->File_Size-File_EndTagSize-9, "Tags");
+ TagSizeIsFinal=false;
+ return false;
+ }
+
+ if (Base->File_Offset+Base->Buffer_Size<Base->File_Size-File_EndTagSize) //Must be at the end less File_EndTagSize+9 bytes plus 9 bytes of tags
+ {
+ if (Base->File_Offset!=Base->File_Size-File_EndTagSize)
+ Base->GoTo(Base->File_Size-File_EndTagSize, "Tags");
+ TagSizeIsFinal=false;
+ return false;
+ }
+
+ if (CC8(Base->Buffer+((size_t)((Base->File_Size-File_EndTagSize-9)-Base->File_Offset)))==CC8("LYRICSEN"))
+ {
+ //Must find the beginning, 5100 bytes before
+ if (Base->File_Offset>Base->File_Size-File_EndTagSize-5100) //Must be at the end less 15 bytes
+ {
+ Base->GoTo(Base->File_Size-File_EndTagSize-5100, "Tags");
+ TagSizeIsFinal=false;
+ return false;
+ }
+
+ if (Base->File_Offset+Base->Buffer_Size<Base->File_Size-File_EndTagSize) //Must be at the end less File_EndTagSize
+ {
+ if (Base->File_Offset!=Base->File_Size-File_EndTagSize)
+ Base->GoTo(Base->File_Size-File_EndTagSize, "Tags");
+ TagSizeIsFinal=false;
+ return false;
+ }
+
+ //Searching for "LYRICSBEGIN"
+ std::string Buf((const char*)(Base->Buffer+Base->Buffer_Offset), Base->Buffer_Size-Base->Buffer_Offset);
+ size_t Pos=Buf.find("LYRICSBEGIN");
+ if (Pos!=std::string::npos)
+ {
+ Lyrics3_Size=Base->File_Size-File_EndTagSize-(Base->File_Offset+Base->Buffer_Offset+Pos);
+ File_EndTagSize+=Lyrics3_Size;
+ Lyrics3_Offset=Base->File_Size-File_EndTagSize;
+ TagSizeIsFinal=false;
+ }
+ }
+ }
+
+ //Lyrics3v2
+ if (Lyrics3v2_Size==0 && Base->File_Size>=File_EndTagSize+15) //Only one, larger than File_EndTagSize+15 bytes
+ {
+ if (Base->File_Offset>Base->File_Size-File_EndTagSize-15) //Must be at the end less 15 bytes
+ {
+ Base->GoTo(Base->File_Size-File_EndTagSize-15, "Tags");
+ TagSizeIsFinal=false;
+ return false;
+ }
+
+ if (Base->File_Offset+Base->Buffer_Size<Base->File_Size-File_EndTagSize) //Must be at the end less File_EndTagSize
+ {
+ if (Base->File_Offset!=Base->File_Size-File_EndTagSize)
+ Base->GoTo(Base->File_Size-File_EndTagSize, "Tags");
+ TagSizeIsFinal=false;
+ return false;
+ }
+
+ if (CC8(Base->Buffer+((size_t)((Base->File_Size-File_EndTagSize-15+6)-Base->File_Offset)))==CC8("LYRICS20"))
+ {
+ Lyrics3v2_Size=Ztring((const char*)(Base->Buffer+((size_t)(Base->Buffer_Size-File_EndTagSize-15))), 6).To_int32u()+15;
+ File_EndTagSize+=Lyrics3v2_Size;
+ Lyrics3v2_Offset=Base->File_Size-File_EndTagSize;
+ TagSizeIsFinal=false;
+ }
+ }
+
+ //ApeTag
+ if (ApeTag_Size==0 && Base->File_Size>=File_EndTagSize+32) //Only one, larger than File_EndTagSize+32 bytes
+ {
+ if (Base->File_Offset>Base->File_Size-File_EndTagSize-32) //Must be at the end less 32 bytes
+ {
+ Base->GoTo(Base->File_Size-File_EndTagSize-32, "Tags");
+ TagSizeIsFinal=false;
+ return false;
+ }
+
+ if (Base->File_Offset+Base->Buffer_Size<Base->File_Size-File_EndTagSize) //Must be at the end less File_EndTagSize+15 bytes plus 15 bytes of tags
+ {
+ if (Base->File_Offset!=Base->File_Size-File_EndTagSize-32)
+ Base->GoTo(Base->File_Size-File_EndTagSize-32, "Tags");
+ TagSizeIsFinal=false;
+ return false;
+ }
+
+ if (CC8(Base->Buffer+((size_t)((Base->File_Size-File_EndTagSize-32)-Base->File_Offset)))==CC8("APETAGEX"))
+ {
+ ApeTag_Size=LittleEndian2int32u(Base->Buffer+((size_t)(Base->Buffer_Size-File_EndTagSize-32+12)));
+ if (LittleEndian2int32u(Base->Buffer+((size_t)(Base->Buffer_Size-File_EndTagSize-32+8)))==2000)
+ ApeTag_Size+=32;
+ File_EndTagSize+=ApeTag_Size;
+ ApeTag_Offset=Base->File_Size-File_EndTagSize;
+ TagSizeIsFinal=false;
+ }
+ }
+
+ //Finished
+ return true;
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Tag/File__Tags.h b/src/thirdparty/MediaInfo/MediaInfo/Tag/File__Tags.h
new file mode 100644
index 000000000..2473ca5f0
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Tag/File__Tags.h
@@ -0,0 +1,105 @@
+// File__Tags - Info for all kind of framed tags tagged files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about all kind of framed tags tagged files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File__TagsH
+#define MediaInfo_File__TagsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File__Tags_Helper
+//***************************************************************************
+
+class File__Tags_Helper
+{
+public :
+ //In
+ File__Analyze* Base;
+
+ //Out
+ int64u TagsSize;
+ int64u File_BeginTagSize;
+ int64u File_EndTagSize;
+
+ //Constructor/Destructor
+ File__Tags_Helper();
+ ~File__Tags_Helper();
+
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin() {return Synched_Test();}
+
+ //Buffer - Synchro
+ bool Synchronize(bool &Tag_Found, size_t Synchro_Offset=0);
+ bool Synched_Test();
+
+ //Buffer - Global
+ bool Read_Buffer_Continue ();
+
+ //Per element
+ bool Header_Begin() {return Synched_Test();}
+
+ //Streams
+ size_t Stream_Prepare(stream_t StreamKind);
+
+ //End
+ void GoTo (int64u GoTo, const char* ParserName=NULL);
+ void GoToFromEnd (int64u GoToFromEnd=0, const char* ParserName=NULL);
+ void Accept (const char* ParserName=NULL);
+ void Reject (const char* ParserName=NULL);
+ void Finish (const char* ParserName=NULL);
+
+private :
+ //Temp
+ File__Analyze* Parser;
+ File__Analyze* Parser_Streams_Fill; //Parser to merge when filling
+ size_t Parser_Buffer_Size;
+ int64u Id3v1_Offset;
+ int64u Lyrics3_Offset;
+ int64u Lyrics3v2_Offset;
+ int64u ApeTag_Offset;
+ int64u JumpTo_WantedByParser;
+ int64u Id3v1_Size;
+ int64u Lyrics3_Size;
+ int64u Lyrics3v2_Size;
+ int64u ApeTag_Size;
+ bool TagSizeIsFinal;
+ bool SearchingForEndTags;
+
+ //Helpers
+ bool DetectBeginOfEndTags(); //return true if we can continue, false if want return
+ bool DetectBeginOfEndTags_Test();
+
+};} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cdp.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cdp.cpp
new file mode 100644
index 000000000..daada736d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cdp.cpp
@@ -0,0 +1,502 @@
+// File_Cdp - Info for EIA-608 files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_CDP_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_Cdp.h"
+#if defined(MEDIAINFO_EIA708_YES)
+ #include "MediaInfo/Text/File_Eia708.h"
+#endif
+#if defined(MEDIAINFO_EIA608_YES)
+ #include "MediaInfo/Text/File_Eia608.h"
+#endif
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+using namespace std;
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+namespace MediaInfoLib
+{
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Cdp_cc_type(int8u cc_type)
+{
+ switch (cc_type)
+ {
+ case 0 : return "CEA-608 line 21 field 1 closed captions"; //closed caption 3 if this is second field
+ case 1 : return "CEA-608 line 21 field 2 closed captions"; //closed caption 4 if this is second field
+ case 2 : return "DTVCC Channel Packet Data";
+ case 3 : return "DTVCC Channel Packet Start";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+float32 Cdp_cdp_frame_rate(int8u cdp_frame_rate)
+{
+ switch (cdp_frame_rate)
+ {
+ case 1 : return (float32)23.976;
+ case 2 : return (float32)24.000;
+ case 3 : return (float32)25.000;
+ case 4 : return (float32)29.970;
+ case 5 : return (float32)30.000;
+ case 6 : return (float32)50.000;
+ case 7 : return (float32)59.940;
+ case 8 : return (float32)60.000;
+ default : return (float32) 0.000;
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Cdp::File_Cdp()
+:File__Analyze()
+{
+ //Config
+ PTS_DTS_Needed=true;
+
+ //Temp
+ ParserName=_T("CDP");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Cdp;
+ StreamIDs_Width[0]=1;
+ #endif //MEDIAINFO_EVENTS
+ Streams.resize(3); //CEA-608 Field 1, CEA-608 Field 2, CEA-708 Channel
+ Streams_Count=0;
+
+ //In
+ WithAppleHeader=false;
+ AspectRatio=0;
+}
+
+//---------------------------------------------------------------------------
+File_Cdp::~File_Cdp()
+{
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ delete Streams[Pos]; //Streams[Pos]=NULL
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Cdp::Streams_Accept()
+{
+ Fill(Stream_General, 0, General_Format, WithAppleHeader?"Final Cut CDP":"CDP");
+}
+
+//---------------------------------------------------------------------------
+void File_Cdp::Streams_Update()
+{
+ Clear(Stream_Text);
+
+ //Per stream
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ if (Streams[Pos] && Streams[Pos]->Parser && Streams[Pos]->Parser->Status[IsFilled] /*&& Streams[Pos]->Parser->Status[IsUpdated]*/ && Streams[Pos]->Parser->Count_Get(Stream_Text))
+ Streams_Update_PerStream(Pos);
+}
+
+//---------------------------------------------------------------------------
+void File_Cdp::Streams_Update_PerStream(size_t Pos)
+{
+ if (Streams[Pos]==NULL)
+ return;
+
+ Update(Streams[Pos]->Parser);
+
+ if (Streams[Pos]->Parser)
+ for (size_t Pos2=0; Pos2<Streams[Pos]->Parser->Count_Get(Stream_Text); Pos2++)
+ {
+ Stream_Prepare(Stream_Text);
+ Merge(*Streams[Pos]->Parser, Stream_Text, Pos2, StreamPos_Last);
+ if (WithAppleHeader)
+ Fill(Stream_Text, StreamPos_Last, "MuxingMode", "Final Cut");
+ Fill(Stream_Text, StreamPos_Last, "MuxingMode", "CDP");
+ Fill(Stream_Text, StreamPos_Last, Text_ID, Streams[Pos]->Parser->Retrieve(Stream_Text, Pos2, Text_ID), true);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Cdp::Streams_Finish()
+{
+ Clear(Stream_Text);
+
+ //Per stream
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ if (Streams[Pos] && Streams[Pos]->Parser && Streams[Pos]->Parser->Status[IsAccepted] /*&& Streams[Pos]->Parser->Status[IsUpdated]*/)
+ {
+ Finish(Streams[Pos]->Parser);
+ Streams_Update_PerStream(Pos);
+ }
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Cdp::Read_Buffer_Unsynched()
+{
+ //Parsing
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ if (Streams[Pos] && Streams[Pos]->Parser)
+ Streams[Pos]->Parser->Open_Buffer_Unsynch();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Cdp::Read_Buffer_Continue()
+{
+ if (Buffer_Size==0)
+ return;
+
+ if (WithAppleHeader)
+ {
+ int32u Size, Magic;
+ Get_B4 (Size, "Size");
+ Get_B4 (Magic, "Magic");
+
+ FILLING_BEGIN();
+ if (Magic!=0x63636470)
+ {
+ Reject("CDP");
+ return;
+ }
+ FILLING_END();
+ }
+
+ //CRC
+ int8u CRC=0;
+ for (size_t Pos=WithAppleHeader?8:0; Pos<Buffer_Size; Pos++)
+ CRC+=Buffer[Pos];
+ if (CRC)
+ {
+ Skip_XX(Element_Size-Element_Offset, "Invalid data (CRC fails)");
+ return;
+ }
+
+ cdp_header();
+ while(Element_Offset<Element_Size)
+ {
+ int8u section_id;
+ Peek_L1(section_id);
+ switch (section_id)
+ {
+ case 0x71 : time_code_section(); break;
+ case 0x72 : ccdata_section(); break;
+ case 0x73 : ccsvcinfo_section(); break;
+ case 0x74 : cdp_footer(); break;
+ case 0xFF : Skip_B1("Padding?"); break;
+ default : if (section_id>=0x75 && section_id<=0xEF)
+ future_section();
+ else
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ }
+ }
+}
+
+//***************************************************************************
+// Functions
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Cdp::cdp_header()
+{
+ Element_Begin1("cdp_header");
+ int16u cdp_identifier;
+ int8u cdp_frame_rate;
+ Get_B2 ( cdp_identifier, "cdp_identifier");
+ Skip_B1( "cdp_length");
+ BS_Begin();
+ Get_S1 (4, cdp_frame_rate, "cdp_frame_rate"); Param_Info1(Ztring::ToZtring(Cdp_cdp_frame_rate(cdp_frame_rate))+_T(" fps"));
+ Skip_S1(4, "Reserved");
+ Skip_SB( "time_code_present");
+ Skip_SB( "ccdata_present");
+ Skip_SB( "svcinfo_present");
+ Skip_SB( "svc_info_start");
+ Skip_SB( "svc_info_change");
+ Skip_SB( "svc_info_complete");
+ Skip_SB( "caption_service_active");
+ Skip_SB( "Reserved");
+ BS_End();
+ Skip_B2( "cdp_hdr_sequence_cntr");
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (!Status[IsAccepted])
+ {
+ if (cdp_identifier!=0x9669)
+ {
+ Reject("CDP");
+ return;
+ }
+
+ Accept("CDP");
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Cdp::time_code_section()
+{
+ Element_Begin1("time_code_section");
+ Skip_B1( "time_code_section_id");
+ BS_Begin();
+ Mark_1();
+ Mark_1();
+ Skip_S1(2, "tc_10hrs");
+ Skip_S1(4, "tc_1hrs");
+ Mark_1();
+ Skip_S1(3, "tc_10min");
+ Skip_S1(4, "tc_1min");
+ Skip_SB( "tc_field_flag");
+ Skip_S1(3, "tc_10sec");
+ Skip_S1(4, "tc_1sec");
+ Skip_SB( "drop_frame_flag");
+ Mark_0();
+ Skip_S1(2, "tc_10fr");
+ Skip_S1(4, "tc_1fr");
+ BS_End();
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Cdp::ccdata_section()
+{
+ //Parsing
+ int8u cc_count;
+ Element_Begin1("ccdata_section");
+ Skip_B1( "ccdata_id");
+ BS_Begin();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Get_S1 (5, cc_count, "cc_count");
+ BS_End();
+ for (int8u Pos=0; Pos<cc_count; Pos++)
+ {
+ Element_Begin1("cc");
+ int8u cc_type;
+ bool cc_valid;
+ BS_Begin();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Get_SB ( cc_valid, "cc_valid");
+ Get_S1 (2, cc_type, "cc_type"); Param_Info1(Cdp_cc_type(cc_type));
+ BS_End();
+ if (cc_valid)
+ {
+ Element_Begin1("cc_data");
+ //Calculating the parser position
+ int8u Parser_Pos=cc_type==3?2:cc_type; //cc_type 2 and 3 are for the same text
+
+ //Parsing
+ #if MEDIAINFO_DEMUX
+ Element_Code=Parser_Pos;
+ #endif //MEDIAINFO_DEMUX
+ if (Streams[Parser_Pos]==NULL)
+ Streams[Parser_Pos]=new stream;
+ if (Streams[Parser_Pos]->Parser==NULL)
+ {
+ if (cc_type<2)
+ {
+ #if defined(MEDIAINFO_EIA608_YES)
+ Streams[Parser_Pos]->Parser=new File_Eia608();
+ ((File_Eia608*)Streams[Parser_Pos]->Parser)->cc_type=cc_type;
+ #else //defined(MEDIAINFO_EIA608_YES)
+ Streams[Parser_Pos]->Parser=new File__Analyze();
+ #endif //defined(MEDIAINFO_EIA608_YES)
+ }
+ else
+ {
+ #if defined(MEDIAINFO_EIA708_YES)
+ Streams[Parser_Pos]->Parser=new File_Eia708();
+ #else //defined(MEDIAINFO_EIA708_YES)
+ Streams[Parser_Pos]->Parser=new File__Analyze();
+ #endif //defined(MEDIAINFO_EIA708_YES)
+ }
+ Open_Buffer_Init(Streams[Parser_Pos]->Parser);
+ }
+ Demux(Buffer+(size_t)(Buffer_Offset+Element_Offset), 2, ContentType_MainStream);
+ if (!Streams[Parser_Pos]->Parser->Status[IsFinished])
+ {
+ if (Streams[Parser_Pos]->Parser->PTS_DTS_Needed)
+ {
+ Streams[Parser_Pos]->Parser->FrameInfo.PCR=FrameInfo.PCR;
+ Streams[Parser_Pos]->Parser->FrameInfo.PTS=FrameInfo.PTS;
+ Streams[Parser_Pos]->Parser->FrameInfo.DTS=FrameInfo.DTS;
+ }
+ if (Parser_Pos==2)
+ {
+ #if defined(MEDIAINFO_EIA708_YES)
+ ((File_Eia708*)Streams[2]->Parser)->cc_type=cc_type;
+ if (AspectRatio)
+ ((File_Eia708*)Streams[2]->Parser)->AspectRatio=AspectRatio;
+ #endif //defined(MEDIAINFO_EIA708_YES)
+ }
+ else
+ {
+ }
+ Open_Buffer_Continue(Streams[Parser_Pos]->Parser, Buffer+(size_t)(Buffer_Offset+Element_Offset), 2);
+ Element_Offset+=2;
+
+ //Filled
+ if (!Streams[Parser_Pos]->IsFilled && Streams[Parser_Pos]->Parser->Status[IsFilled])
+ {
+ if (Count_Get(Stream_General)==0)
+ Accept("CDP");
+ Streams_Count++;
+ if (Streams_Count==3)
+ Fill("CDP");
+ Streams[Parser_Pos]->IsFilled=true;
+ }
+ }
+ else
+ Skip_XX(2, "Data");
+ Element_End0();
+ }
+ else
+ Skip_XX(2, "Junk");
+ Element_End0();
+ }
+ Element_End0();
+
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+}
+
+//---------------------------------------------------------------------------
+void File_Cdp::ccsvcinfo_section()
+{
+ //Parsing
+ int8u svc_count;
+ Element_Begin1("ccsvcinfo_section");
+ Skip_B1( "ccsvcinfo_id");
+ BS_Begin();
+ Skip_SB( "reserved");
+ Skip_SB( "svc_info_start");
+ Skip_SB( "svc_info_change");
+ Skip_SB( "svc_info_complete");
+ Get_S1 (4, svc_count, "svc_count");
+ BS_End();
+ for (int8u Pos=0; Pos<svc_count; Pos++)
+ {
+ Element_Begin1("svc");
+ bool csn_size;
+ BS_Begin();
+ Skip_SB( "reserved");
+ Get_SB ( csn_size, "csn_size");
+ if (csn_size)
+ {
+ Skip_SB( "reserved");
+ Skip_S1(5, "caption_service_number");
+ }
+ else
+ Skip_S1(6, "caption_service_number");
+ BS_End();
+
+ //svc_data_byte - caption_service_descriptor
+ Element_Begin1("service");
+ Ztring language;
+ bool digital_cc;
+ Get_Local(3, language, "language");
+ BS_Begin();
+ Get_SB (digital_cc, "digital_cc");
+ Skip_SB( "reserved");
+ if (digital_cc) //line21
+ {
+ Skip_S1(5, "reserved");
+ Skip_SB( "line21_field");
+ }
+ else
+ Skip_S1(6, "caption_service_number");
+ Skip_SB( "easy_reader");
+ Skip_SB( "wide_aspect_ratio");
+ Skip_S2(14, "reserved");
+ BS_End();
+ Element_End0();
+ Element_End0();
+ }
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Cdp::cdp_footer()
+{
+ Element_Begin1("cdp_footer");
+ Skip_B1( "cdp_footer_id");
+ Skip_B2( "cdp_ftr_sequence_cntr");
+ Skip_B1( "packet_checksum");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Cdp::future_section()
+{
+ //Parsing
+ int8u length;
+ Element_Begin1("future_section");
+ Skip_B1( "future_section_id");
+ Get_B1 (length, "length");
+ Skip_XX(length, "Unknown");
+ Element_End0();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_CDP_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cdp.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cdp.h
new file mode 100644
index 000000000..32cbd0d5f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cdp.h
@@ -0,0 +1,98 @@
+// File_Cdp - Info for CDP files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Caption Distribution Packet files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_CdpH
+#define MediaInfo_File_CdpH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Cdp
+//***************************************************************************
+
+class File_Cdp : public File__Analyze
+{
+public :
+ //In
+ bool WithAppleHeader;
+ float64 AspectRatio;
+
+ //Constructor/Destructor
+ File_Cdp();
+ ~File_Cdp();
+
+private :
+ //Streams management
+ void Streams_Accept();
+ void Streams_Update();
+ void Streams_Update_PerStream(size_t Pos);
+ void Streams_Finish();
+
+ //Synchro
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Global
+ void Read_Buffer_Continue();
+
+ //Elements
+ void cdp_header();
+ void time_code_section();
+ void ccdata_section();
+ void ccsvcinfo_section();
+ void cdp_footer();
+ void future_section();
+
+ //Stream
+ struct stream
+ {
+ File__Analyze* Parser;
+ size_t StreamPos;
+ bool IsFilled;
+
+ stream()
+ {
+ Parser=NULL;
+ StreamPos=(size_t)-1;
+ IsFilled=false;
+ }
+
+ ~stream()
+ {
+ delete Parser; //Parser=NULL;
+ }
+ };
+ std::vector<stream*> Streams;
+ size_t Streams_Count;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cmml.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cmml.cpp
new file mode 100644
index 000000000..c4c347b98
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cmml.cpp
@@ -0,0 +1,122 @@
+// File_Cmml - Info for Cmml files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Note : the buffer must be given in ONE call
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_CMML_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_Cmml.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Cmml::Header_Parse()
+{
+ //Filling
+ Header_Fill_Code(0, "Cmml");
+ Header_Fill_Size(Element_Size);
+}
+
+//---------------------------------------------------------------------------
+void File_Cmml::Data_Parse()
+{
+ //Parsing
+ if (Status[IsAccepted])
+ Configuration();
+ else
+ Identification();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Cmml::Identification()
+{
+ Element_Name("Identification");
+
+ //Parsing
+ int16u VersionMajor, VersionMinor;
+ Skip_Local(8, "Signature");
+ Get_L2 (VersionMajor, "version major");
+ Get_L2 (VersionMinor, "version minor");
+ Skip_L8( "granule rate numerator");
+ Skip_L8( "granule rate denominator");
+ Skip_L1( "granule shift");
+
+ FILLING_BEGIN();
+ Accept("CMML");
+
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Format, "CMML");
+ Fill(Stream_Text, 0, Text_Codec, "CMML");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Cmml::Configuration()
+{
+ Element_Name("Configuration");
+
+ //Parsing
+ Ztring Data;
+ Get_UTF8(Element_Size, Data, "Data");
+
+ FILLING_BEGIN();
+ Ztring Value;
+ Value=Data.SubString(_T("<head>"), _T("</head>"));
+ if (!Value.empty())
+ Fill(Stream_Text, 0, Text_Title, Value.SubString(_T("<title>"), _T("</title>")));
+ if (Data.find(_T("<clip"))!=string::npos)
+ Finish("CMML");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_CMML_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cmml.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cmml.h
new file mode 100644
index 000000000..db67069dc
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Cmml.h
@@ -0,0 +1,58 @@
+// File_Cmml - Info for Cmml files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Cmml files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_CmmlH
+#define MediaInfo_File_CmmlH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Cmml
+//***************************************************************************
+
+class File_Cmml : public File__Analyze
+{
+private :
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Identification();
+ void Configuration();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_DtvccTransport.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_DtvccTransport.cpp
new file mode 100644
index 000000000..be73b3db0
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_DtvccTransport.cpp
@@ -0,0 +1,336 @@
+// File_DtvccTransport - Info for DTVCC Transport strams
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_DtvccTransport.h"
+#if defined(MEDIAINFO_EIA608_YES)
+ #include "MediaInfo/Text/File_Eia608.h"
+#endif
+#if defined(MEDIAINFO_EIA708_YES)
+ #include "MediaInfo/Text/File_Eia708.h"
+#endif
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+namespace MediaInfoLib
+{
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* DtvccTransport_cc_type (int8u cc_type)
+{
+ switch (cc_type)
+ {
+ case 0 : return "CEA-608 line 21 field 1 closed captions"; //closed caption 3 if this is second field
+ case 1 : return "CEA-608 line 21 field 2 closed captions"; //closed caption 4 if this is second field
+ case 2 : return "DTVCC Channel Packet Data";
+ case 3 : return "DTVCC Channel Packet Start";
+ default : return "";
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_DtvccTransport::File_DtvccTransport()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("DTVCC Transport");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_DtvccTransport;
+ StreamIDs_Width[0]=1;
+ #endif //MEDIAINFO_EVENTS
+ PTS_DTS_Needed=true;
+
+ //In
+ Format=Format_Unknown;
+ AspectRatio=0;
+
+ //Temp
+ Streams.resize(3); //CEA-608 Field 1, CEA-608 Field 2, CEA-708 Channel
+}
+
+//---------------------------------------------------------------------------
+File_DtvccTransport::~File_DtvccTransport()
+{
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ delete Streams[Pos]; //Streams[Pos]=NULL
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DtvccTransport::Streams_Update()
+{
+ Clear(Stream_Text);
+
+ //Per stream
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ if (Streams[Pos] && Streams[Pos]->Parser && Streams[Pos]->Parser->Status[IsFilled] /*&& Streams[Pos]->Parser->Status[IsUpdated]*/ && Streams[Pos]->Parser->Count_Get(Stream_Text))
+ Streams_Update_PerStream(Pos);
+}
+
+//---------------------------------------------------------------------------
+void File_DtvccTransport::Streams_Update_PerStream(size_t Pos)
+{
+ if (Streams[Pos]==NULL)
+ return;
+
+ Update(Streams[Pos]->Parser);
+
+ if (Streams[Pos]->Parser)
+ for (size_t Pos2=0; Pos2<Streams[Pos]->Parser->Count_Get(Stream_Text); Pos2++)
+ {
+ Stream_Prepare(Stream_Text);
+ Merge(*Streams[Pos]->Parser, Stream_Text, Pos2, StreamPos_Last);
+ Fill(Stream_Text, StreamPos_Last, "MuxingMode", Format==Format_DVD?_T("DVD-Video"):_T("DTVCC Transport"));
+ Fill(Stream_Text, StreamPos_Last, Text_ID, Streams[Pos]->Parser->Retrieve(Stream_Text, Pos2, Text_ID), true);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_DtvccTransport::Streams_Finish()
+{
+ Clear(Stream_Text);
+
+ //Per stream
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ if (Streams[Pos] && Streams[Pos]->Parser && Streams[Pos]->Parser->Status[IsAccepted] /*&& Streams[Pos]->Parser->Status[IsUpdated]*/)
+ {
+ Finish(Streams[Pos]->Parser);
+ Streams_Update_PerStream(Pos);
+ }
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DtvccTransport::Read_Buffer_Unsynched()
+{
+ //Parsing
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ if (Streams[Pos] && Streams[Pos]->Parser)
+ Streams[Pos]->Parser->Open_Buffer_Unsynch();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DtvccTransport::Read_Buffer_Continue()
+{
+ //Parsing
+ Element_Begin1(Format==Format_DVD?"DVD Captions":"DTVCC Transport");
+ int8u cc_count;
+ bool process_cc_data_flag, additional_data_flag;
+ BS_Begin();
+ if (Format==Format_DVD)
+ {
+ //Modified DTVCC Transport from DVD
+ Skip_SB( "field 1 then field 2");
+ Get_S1 (7, cc_count, "cc_count");
+ process_cc_data_flag=true;
+ additional_data_flag=false;
+ }
+ else
+ {
+ //Normal DTVCC Transport
+ bool process_em_data_flag;
+ Get_SB (process_em_data_flag, "process_em_data_flag");
+ Get_SB (process_cc_data_flag, "process_cc_data_flag");
+ Get_SB (additional_data_flag, "additional_data_flag");
+ Get_S1 (5, cc_count, "cc_count");
+ Skip_S1(8, process_em_data_flag?"em_data":"reserved"); //Emergency message
+ }
+ BS_End();
+ if (process_cc_data_flag)
+ {
+ for (int8u Pos=0; Pos<cc_count; Pos++)
+ {
+ Element_Begin1("cc");
+ int8u cc_type;
+ bool cc_valid;
+ BS_Begin();
+ Mark_1();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ if (Format==Format_DVD)
+ {
+ //Modified DTVCC Transport from DVD
+ Mark_1();
+ Mark_1();
+ Get_S1 (1, cc_type, "cc_type"); Param_Info1(DtvccTransport_cc_type(cc_type));
+ cc_valid=true;
+ }
+ else
+ {
+ //Normal DTVCC Transport
+ Get_SB ( cc_valid, "cc_valid");
+ Get_S1 (2, cc_type, "cc_type"); Param_Info1(DtvccTransport_cc_type(cc_type));
+ }
+ BS_End();
+ if (cc_valid)
+ {
+ Element_Begin1("cc_data");
+ //Calculating the parser position
+ int8u Parser_Pos=cc_type==3?2:cc_type; //cc_type 2 and 3 are for the same text
+
+ //Parsing
+ #if MEDIAINFO_DEMUX
+ Element_Code=Parser_Pos;
+ #endif //MEDIAINFO_DEMUX
+ if (Streams[Parser_Pos]==NULL)
+ Streams[Parser_Pos]=new stream;
+ if (Streams[Parser_Pos]->Parser==NULL)
+ {
+ if (cc_type<2)
+ {
+ #if defined(MEDIAINFO_EIA608_YES)
+ Streams[Parser_Pos]->Parser=new File_Eia608();
+ ((File_Eia608*)Streams[Parser_Pos]->Parser)->cc_type=cc_type;
+ #else
+ Streams[Parser_Pos]->Parser=new File__Analyze();
+ #endif
+ }
+ else
+ {
+ #if defined(MEDIAINFO_EIA708_YES)
+ Streams[Parser_Pos]->Parser=new File_Eia708();
+ #else
+ Streams[Parser_Pos]->Parser=new File__Analyze();
+ #endif
+ }
+ Open_Buffer_Init(Streams[Parser_Pos]->Parser);
+ }
+ Demux(Buffer+(size_t)(Buffer_Offset+Element_Offset), 2, ContentType_MainStream);
+ if (!Streams[Parser_Pos]->Parser->Status[IsFinished])
+ {
+ //Parsing
+ if (Streams[Parser_Pos]->Parser->PTS_DTS_Needed)
+ {
+ Streams[Parser_Pos]->Parser->FrameInfo.PCR=FrameInfo.PCR;
+ Streams[Parser_Pos]->Parser->FrameInfo.PTS=FrameInfo.PTS;
+ Streams[Parser_Pos]->Parser->FrameInfo.DTS=FrameInfo.DTS;
+ }
+ if (Parser_Pos==2)
+ {
+ #if defined(MEDIAINFO_EIA708_YES)
+ ((File_Eia708*)Streams[2]->Parser)->cc_type=cc_type;
+ if (AspectRatio)
+ ((File_Eia708*)Streams[2]->Parser)->AspectRatio=AspectRatio;
+ #endif
+ if (cc_type==3)
+ {
+ ((File_Eia708*)Streams[2]->Parser)->cc_type=4; //Magic value saying that the buffer must be kept (this is only a point of synchro from the undelying layer)
+ Streams[2]->Parser->Open_Buffer_Continue(Streams[Parser_Pos]->Parser, Buffer+(size_t)(Buffer_Offset+Element_Offset), 0);
+ ((File_Eia708*)Streams[2]->Parser)->cc_type=3;
+ }
+ }
+ else
+ {
+ }
+ Open_Buffer_Continue(Streams[Parser_Pos]->Parser, Buffer+(size_t)(Buffer_Offset+Element_Offset), 2);
+ Element_Show();
+ Element_Offset+=2;
+
+ //Filled
+ if (!Status[IsAccepted])
+ Accept("DTVCC Transport");
+ }
+ else
+ Skip_XX(2, "Data");
+ Element_End0();
+ }
+ else
+ Skip_XX(2, "Junk");
+ Element_End0();
+ }
+ }
+ else
+ Skip_XX(cc_count*2, "Junk");
+
+ if (Format==Format_A53_4_GA94_03)
+ {
+ //Normal DTVCC Transport
+ BS_Begin();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ BS_End();
+
+ if (additional_data_flag)
+ {
+ Skip_XX(Element_Size-Element_Offset, "additional_user_data");
+ }
+
+ while (Element_Offset<Element_Size)
+ {
+ Skip_B1( "Zero"); //TODO: test Zero
+ }
+ }
+
+ Element_End0();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_DTVCCTRANSPORT_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_DtvccTransport.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_DtvccTransport.h
new file mode 100644
index 000000000..d4eb1c36b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_DtvccTransport.h
@@ -0,0 +1,91 @@
+// File_DtvccTransport - Info for DTVCC Transport strams
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Bar Data files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_DtvccTransportH
+#define MediaInfo_DtvccTransportH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_DtvccTransport
+//***************************************************************************
+
+class File_DtvccTransport : public File__Analyze
+{
+public :
+ //In
+ enum format
+ {
+ Format_Unknown,
+ Format_A53_4_GA94_03, //MPEG_cc_data
+ Format_DVD, //Unknown standard
+ };
+ format Format;
+ float64 AspectRatio;
+
+ //Constructor/Destructor
+ File_DtvccTransport();
+ ~File_DtvccTransport();
+
+private :
+ //Streams management
+ void Streams_Update();
+ void Streams_Update_PerStream(size_t Pos);
+ void Streams_Finish();
+
+ //Synchro
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Global
+ void Read_Buffer_Continue();
+
+ //Temp
+ struct stream
+ {
+ File__Analyze* Parser;
+
+ stream()
+ {
+ Parser=NULL;
+ }
+
+ ~stream()
+ {
+ delete Parser; //Parser=NULL;
+ }
+ };
+ std::vector<stream*> Streams;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_DvbSubtitle.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_DvbSubtitle.cpp
new file mode 100644
index 000000000..31805207d
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_DvbSubtitle.cpp
@@ -0,0 +1,421 @@
+// File_DvbSubtitle - Info for DVB Subtitle streams
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DVBSUBTITLE_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_DvbSubtitle.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Info
+//***************************************************************************
+
+const int8u DvbSubtitle_region_depth[8]=
+{
+ 0,
+ 2,
+ 4,
+ 8,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_DvbSubtitle::File_DvbSubtitle()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("DVB Subtitle");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_DvbSubtitle;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(8); //Stream
+ #endif //MEDIAINFO_TRACE
+ PTS_DTS_Needed=true;
+ IsRawStream=true;
+ MustSynchronize=true;
+
+ //In
+ Frame_Count_Valid=MediaInfoLib::Config.ParseSpeed_Get()>=0.3?32:2;
+
+ //Temp
+ MustFindDvbHeader=true;
+}
+
+//---------------------------------------------------------------------------
+File_DvbSubtitle::~File_DvbSubtitle()
+{
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DvbSubtitle::Streams_Fill()
+{
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Format, "DVB Subtitle");
+
+ for (std::map<int8u, subtitle_stream_data>::iterator subtitle_stream=subtitle_streams.begin(); subtitle_stream!=subtitle_streams.end(); subtitle_stream++)
+ for (std::map<int16u, page_data>::iterator page=subtitle_stream->second.pages.begin(); page!=subtitle_stream->second.pages.end(); page++)
+ for (std::map<int8u, region_data>::iterator region=page->second.regions.begin(); region!=page->second.regions.end(); region++)
+ {
+ Fill(Stream_Text, 0, "subtitle_stream_id", subtitle_stream->first);
+ (*Stream_More)[Stream_Text][0](Ztring().From_Local("subtitle_stream_id"), Info_Options)=_T("N NI");
+ Fill(Stream_Text, 0, "page_id", page->first);
+ (*Stream_More)[Stream_Text][0](Ztring().From_Local("page_id"), Info_Options)=_T("N NI");
+ Fill(Stream_Text, 0, "region_id", region->first);
+ (*Stream_More)[Stream_Text][0](Ztring().From_Local("region_id"), Info_Options)=_T("N NI");
+ Fill(Stream_Text, 0, "region_horizontal_address", region->second.page_composition_segment?Ztring::ToZtring(region->second.region_horizontal_address):Ztring());
+ (*Stream_More)[Stream_Text][0](Ztring().From_Local("region_horizontal_address"), Info_Options)=_T("N NI");
+ Fill(Stream_Text, 0, "region_vertical_address", region->second.page_composition_segment?Ztring::ToZtring(region->second.region_vertical_address):Ztring());
+ (*Stream_More)[Stream_Text][0](Ztring().From_Local("region_vertical_address"), Info_Options)=_T("N NI");
+ Fill(Stream_Text, 0, "region_width", region->second.region_composition_segment?Ztring::ToZtring(region->second.region_width):Ztring());
+ (*Stream_More)[Stream_Text][0](Ztring().From_Local("region_width"), Info_Options)=_T("N NI");
+ Fill(Stream_Text, 0, "region_height", region->second.region_composition_segment?Ztring::ToZtring(region->second.region_height):Ztring());
+ (*Stream_More)[Stream_Text][0](Ztring().From_Local("region_height"), Info_Options)=_T("N NI");
+ Fill(Stream_Text, 0, "region_depth", region->second.region_composition_segment?Ztring::ToZtring(DvbSubtitle_region_depth[region->second.region_depth]):Ztring());
+ (*Stream_More)[Stream_Text][0](Ztring().From_Local("region_depth"), Info_Options)=_T("N NI");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_DvbSubtitle::Streams_Finish()
+{
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_DvbSubtitle::Synchronize()
+{
+ //Synchronizing
+ if (MustFindDvbHeader)
+ {
+ while(Buffer_Offset+3<=Buffer_Size)
+ {
+ if (Buffer[Buffer_Offset]==0x20
+ && Buffer[Buffer_Offset+1]==0x00
+ && (Buffer[Buffer_Offset+2]==0x0F
+ || Buffer[Buffer_Offset+1]==0xFF))
+ break;
+ Buffer_Offset++;
+ }
+
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ Accept();
+ }
+ else
+ {
+ while(Buffer_Offset<Buffer_Size)
+ {
+ if (Buffer[Buffer_Offset]==0x0F
+ || Buffer[Buffer_Offset]==0xFF)
+ break;
+ Buffer_Offset++;
+ }
+
+ if (Buffer_Offset>=Buffer_Size)
+ return false;
+ }
+
+ //Synched is OK
+ Synched=true;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_DvbSubtitle::Synched_Test()
+{
+ if (MustFindDvbHeader)
+ {
+ //Must have enough buffer for having header
+ if (Buffer_Offset+1>Buffer_Size)
+ return false;
+
+ if (CC2(Buffer+Buffer_Offset)!=0x2000)
+ {
+ Synched=false;
+ return true;
+ }
+
+ //Displaying it
+ Element_Size=2;
+ Skip_B1( "data_identifier");
+ Get_B1 (subtitle_stream_id, "subtitle_stream_id");
+ Buffer_Offset+=2;
+ MustFindDvbHeader=false;
+ }
+
+ //Must have enough buffer for having header
+ if (Buffer_Offset+1>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (Buffer[Buffer_Offset]!=0x0F
+ && Buffer[Buffer_Offset]!=0xFF)
+ {
+ Synched=false;
+ return true;
+ }
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_DvbSubtitle::Read_Buffer_Unsynched()
+{
+ MustParseTheHeaderFile=true;
+ Synched=false;
+}
+
+//***************************************************************************
+// Buffer - Demux
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+bool File_DvbSubtitle::Demux_UnpacketizeContainer_Test()
+{
+ if (Demux_Offset==0)
+ {
+ Demux_Offset=Buffer_Offset;
+ }
+ while (Demux_Offset<Buffer_Size)
+ {
+ bool MustBreak;
+ switch (Buffer[Demux_Offset])
+ {
+ case 0xFF :
+ MustBreak=true; break; //0xFF is not in the demuxed frame
+ default : MustBreak=false;
+ }
+ if (MustBreak)
+ break; //while() loop
+
+ if (Demux_Offset+6>Buffer_Size)
+ return false; //No complete frame
+
+ int16u segment_length=BigEndian2int16u(Buffer+Demux_Offset+4);
+ Demux_Offset+=6+segment_length;
+
+ if (Demux_Offset>=Buffer_Size)
+ return false; //No complete frame
+ }
+
+ if (Demux_Offset>=Buffer_Size)
+ return false; //No complete frame
+
+ Demux_UnpacketizeContainer_Demux();
+
+ Demux_TotalBytes++; //0xFF is not demuxed
+
+ return true;
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DvbSubtitle::Header_Parse()
+{
+ //Parsing
+ int8u sync_byte;
+ Get_B1 (sync_byte, "sync_byte");
+ switch (sync_byte)
+ {
+ case 0xFF : //Stuffing
+ MustFindDvbHeader=true;
+
+ //Filling
+ Header_Fill_Code(0xFF, "end_of_PES_data_field_marker");
+ Header_Fill_Size(1);
+ return;
+ default : ; //Normal (0x0F)
+ }
+
+ int16u segment_length;
+ int8u segment_type;
+ Get_B1 (segment_type, "segment_type");
+ Get_B2 (page_id, "page_id");
+ Get_B2 (segment_length, "segment_length");
+
+ //Filling
+ Header_Fill_Code(segment_type);
+ Header_Fill_Size(Element_Offset+segment_length);
+}
+
+//---------------------------------------------------------------------------
+void File_DvbSubtitle::Data_Parse()
+{
+ switch (Element_Code)
+ {
+ case 0x10 : page_composition_segment(); break;
+ case 0x11 : region_composition_segment(); break;
+ case 0xFF : //end_of_PES_data_field_marker
+ Frame_Count++;
+ if (!Status[IsFilled] && Frame_Count>Frame_Count_Valid)
+ {
+ Fill();
+ Finish();
+ }
+ return;
+ default :
+ if (Element_Size)
+ Skip_XX(Element_Size, "Unknown");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_DvbSubtitle::page_composition_segment()
+{
+ Element_Name("page_composition_segment");
+
+ //Parsing
+ Skip_B1( "page_time_out");
+ BS_Begin();
+ Skip_S1(4, "page_version_number");
+ Skip_S1(2, "page_state");
+ Skip_S1(2, "reserved");
+ BS_End();
+ while(Element_Offset<Element_Size)
+ {
+ Element_Begin1("Region");
+ int16u region_horizontal_address, region_vertical_address;
+ int8u region_id;
+ Get_B1 (region_id, "region_id");
+ Skip_B1( "reserved");
+ Get_B2 (region_horizontal_address, "region_horizontal_address");
+ Get_B2 (region_vertical_address, "region_vertical_address");
+ Element_End0();
+
+ FILLING_BEGIN();
+ subtitle_streams[subtitle_stream_id].pages[page_id].regions[region_id].page_composition_segment=true;
+ subtitle_streams[subtitle_stream_id].pages[page_id].regions[region_id].region_horizontal_address=region_horizontal_address;
+ subtitle_streams[subtitle_stream_id].pages[page_id].regions[region_id].region_vertical_address=region_vertical_address;
+ FILLING_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_DvbSubtitle::region_composition_segment()
+{
+ Element_Name("region_composition_segment");
+
+ //Parsing
+ int16u region_width, region_height;
+ int8u region_id, region_depth;
+ Get_B1 ( region_id, "region_id");
+ BS_Begin();
+ Skip_S1(4, "region_version_number");
+ Skip_S1(1, "region_fill_flag");
+ Skip_S1(3, "reserved");
+ BS_End();
+ Get_B2 ( region_width, "region_width");
+ Get_B2 ( region_height, "region_height");
+ BS_Begin();
+ Skip_S1(3, "region_level_of_compatibility");
+ Get_S1 (3, region_depth, "region_depth"); Param_Info2(DvbSubtitle_region_depth[region_depth], " bits");
+ Skip_S1(2, "reserved");
+ BS_End();
+ Skip_B1( "CLUT_id");
+ Skip_B1( "region_8-bit_pixel_code");
+ BS_Begin();
+ Skip_S1(4, "region_4-bit_pixel-code");
+ Skip_S1(2, "region_2-bit_pixel-code");
+ Skip_S1(2, "reserved");
+ BS_End();
+ while(Element_Offset<Element_Size)
+ {
+ Element_Begin1("Object");
+ int8u object_type;
+ Skip_B2( "object_id");
+ BS_Begin();
+ Get_S1 ( 2, object_type, "object_type");
+ Skip_S1( 2, "object_provider_flag");
+ Skip_S1(12, "object_horizontal_position");
+ Skip_S1( 4, "reserved");
+ Skip_S1(12, "object_vertical_position");
+ BS_End();
+ switch (object_type)
+ {
+ case 0x01 :
+ case 0x02 :
+ Skip_B2( "foreground_pixel_code");
+ Skip_B2( "background_pixel_code");
+ break;
+ default : ;
+ }
+ }
+ Element_End0();
+
+ FILLING_BEGIN();
+ subtitle_streams[subtitle_stream_id].pages[page_id].regions[region_id].region_composition_segment=true;
+ subtitle_streams[subtitle_stream_id].pages[page_id].regions[region_id].region_width=region_width;
+ subtitle_streams[subtitle_stream_id].pages[page_id].regions[region_id].region_height=region_height;
+ subtitle_streams[subtitle_stream_id].pages[page_id].regions[region_id].region_depth=region_depth;
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_DVBSUBTITLE_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_DvbSubtitle.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_DvbSubtitle.h
new file mode 100644
index 000000000..24d818d5a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_DvbSubtitle.h
@@ -0,0 +1,110 @@
+// File_DvbSubtitle - Info for DVB Subtitle streams
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about DVB Subtitle streams
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_DvbSubtitleH
+#define MediaInfo_File_DvbSubtitleH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_DvbSubtitle
+//***************************************************************************
+
+class File_DvbSubtitle : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+
+ //Constructor/Destructor
+ File_DvbSubtitle();
+ ~File_DvbSubtitle();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test();
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void page_composition_segment();
+ void region_composition_segment();
+
+ //Temp
+ bool MustFindDvbHeader;
+ int16u page_id;
+ int8u subtitle_stream_id;
+ struct region_data
+ {
+ int16u region_horizontal_address;
+ int16u region_vertical_address;
+
+ int16u region_width;
+ int16u region_height;
+ int16u region_depth;
+
+ bool page_composition_segment;
+ bool region_composition_segment;
+
+ region_data()
+ {
+ page_composition_segment=false;
+ region_composition_segment=false;
+ }
+ };
+ struct page_data
+ {
+ std::map<int8u, region_data> regions; //Key is region_id
+ };
+ struct subtitle_stream_data
+ {
+ std::map<int16u, page_data> pages; //Key is page_id
+ };
+ std::map<int8u, subtitle_stream_data> subtitle_streams; //Key is subtitle_stream_id
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia608.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia608.cpp
new file mode 100644
index 000000000..17337ac12
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia608.cpp
@@ -0,0 +1,969 @@
+// File_Eia608 - Info for EIA-608 files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_EIA608_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_Eia608.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// CAE-608-E section F.1.1.5
+static const int8u Eia608_PAC_Row[]=
+{
+ 10,
+ 0, //or 1
+ 2, //or 3
+ 11, //or 12
+ 13, //or 14
+ 4, //or 5
+ 6, //or 7
+ 8 //or 9
+};
+
+//***************************************************************************
+//
+//***************************************************************************
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Eia608::File_Eia608()
+:File__Analyze()
+{
+ //Configuration
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Eia608;
+ StreamIDs_Width[0]=1;
+ #endif //MEDIAINFO_EVENTS
+ PTS_DTS_Needed=true;
+
+ //In
+ cc_type=(int8u)-1;
+
+ //Temp
+ XDS_Level=(size_t)-1;
+ TextMode=false;
+ DataChannelMode=false;
+ cc_data_1_Old=0x00;
+ cc_data_2_Old=0x00;
+ HasContent=false;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Eia608::Streams_Fill()
+{
+ if (Config->File_Eia608_DisplayEmptyStream_Get() && Streams.size()<2)
+ Streams.resize(2);
+
+ for (size_t StreamPos=0; StreamPos<Streams.size(); StreamPos++)
+ if (Streams[StreamPos] || (StreamPos<2 && Config->File_Eia608_DisplayEmptyStream_Get()))
+ {
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, StreamPos_Last, Text_Format, "EIA-608");
+ Fill(Stream_Text, StreamPos_Last, Text_StreamSize, 0);
+ Fill(Stream_Text, StreamPos_Last, Text_BitRate_Mode, "CBR");
+ if (cc_type!=(int8u)-1)
+ {
+ string ID=StreamPos<2?"CC":"T";
+ ID+='1'+(cc_type*2)+(StreamPos%2);
+ Fill(Stream_Text, StreamPos_Last, Text_ID, ID);
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Streams_Finish()
+{
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Eia608::Read_Buffer_Unsynched()
+{
+ for (size_t StreamPos=0; StreamPos<Streams.size(); StreamPos++)
+ if (Streams[StreamPos])
+ {
+ for (size_t Pos_Y=0; Pos_Y<Streams[StreamPos]->CC_Displayed.size(); Pos_Y++)
+ {
+ for (size_t Pos_X=0; Pos_X<Streams[StreamPos]->CC_Displayed[Pos_Y].size(); Pos_X++)
+ if (Streams[StreamPos])
+ {
+ Streams[StreamPos]->CC_Displayed[Pos_Y][Pos_X].Value=L' ';
+ Streams[StreamPos]->CC_Displayed[Pos_Y][Pos_X].Attribute=0;
+ if (StreamPos<2)
+ {
+ Streams[StreamPos]->CC_NonDisplayed[Pos_Y][Pos_X].Value=L' ';
+ Streams[StreamPos]->CC_NonDisplayed[Pos_Y][Pos_X].Attribute=0;
+ }
+ }
+ }
+ Streams[StreamPos]->Synched=false;
+ }
+
+ XDS_Data.clear();
+ XDS_Level=(size_t)-1;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Eia608::Read_Buffer_Init()
+{
+ #if MEDIAINFO_DEMUX
+ if (Frame_Count_NotParsedIncluded==(int64u)-1)
+ Frame_Count_NotParsedIncluded=Config->Demux_FirstFrameNumber_Get();
+ if (FrameInfo.DUR==(int64u)-1 && Config->Demux_Rate_Get())
+ FrameInfo.DUR=float64_int64s(((float64)1000000000)/Config->Demux_Rate_Get());
+ if (FrameInfo.DTS==(int64u)-1)
+ FrameInfo.DTS=Config->Demux_FirstDts_Get();
+ #endif //MEDIAINFO_DEMUX
+ if (FrameInfo.DUR!=(int64u)-1)
+ {
+ if (FrameInfo.DTS==(int64u)-1)
+ FrameInfo.DTS=0;
+ if (FrameInfo.PTS==(int64u)-1)
+ FrameInfo.PTS=0;
+ }
+
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Read_Buffer_AfterParsing()
+{
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ if (FrameInfo.DUR!=(int64u)-1)
+ {
+ FrameInfo.DTS+=FrameInfo.DUR;
+ FrameInfo.PTS=FrameInfo.DTS;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Read_Buffer_Continue()
+{
+ FrameInfo.PTS=FrameInfo.DTS;
+
+ if (!Status[IsAccepted])
+ Accept("EIA-608");
+
+ int8u cc_data_1, cc_data_2;
+ Get_B1 (cc_data_1, "cc_data");
+ Get_B1 (cc_data_2, "cc_data");
+
+ //Removing checksume
+ cc_data_1&=0x7F;
+ cc_data_2&=0x7F;
+
+ //Test if non-printing chars (0x10-0x1F) are repeated (CEA-608-E section D.2)
+ if (cc_data_1_Old)
+ {
+ if (cc_data_1_Old==cc_data_1 && cc_data_2_Old==cc_data_2)
+ {
+ //This is duplicate
+ cc_data_1_Old=0x00;
+ cc_data_2_Old=0x00;
+ return; //Nothing to do
+ }
+ else if (cc_type==0) // Field 1 only
+ {
+ //They should be duplicated, there is a problem
+ }
+ cc_data_1_Old=0x00;
+ cc_data_2_Old=0x00;
+ }
+
+ if ((cc_data_1 && cc_data_1<0x10) || (XDS_Level!=(size_t)-1 && cc_data_1>=0x20)) //XDS
+ {
+ XDS(cc_data_1, cc_data_2);
+ }
+ else if (cc_data_1>=0x20) //Basic characters
+ {
+ size_t StreamPos=TextMode*2+DataChannelMode;
+ if (StreamPos>=Streams.size() || Streams[StreamPos]==NULL || !Streams[StreamPos]->Synched)
+ return; //Not synched
+
+ Standard(cc_data_1);
+ if ((cc_data_2&0x7F)>=0x20)
+ Standard(cc_data_2);
+ }
+ else if (cc_data_1) //Special
+ Special(cc_data_1, cc_data_2);
+}
+
+//***************************************************************************
+// Functions
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Eia608::XDS(int8u cc_data_1, int8u cc_data_2)
+{
+ if (cc_data_1 && cc_data_1<0x10 && cc_data_1%2==0)
+ {
+ // Continue
+ cc_data_1--;
+ for (XDS_Level=0; XDS_Level<XDS_Data.size(); XDS_Level++)
+ if (XDS_Data[XDS_Level].size()>=2 && XDS_Data[XDS_Level][0]==cc_data_1 && XDS_Data[XDS_Level][1]==cc_data_2)
+ break;
+ if (XDS_Level>=XDS_Data.size())
+ XDS_Level=(size_t)-1; // There is a problem
+
+ return;
+ }
+ else if (cc_data_1 && cc_data_1<0x0F)
+ {
+ // Start
+ for (XDS_Level=0; XDS_Level<XDS_Data.size(); XDS_Level++)
+ if (XDS_Data[XDS_Level].size()>=2 && XDS_Data[XDS_Level][0]==cc_data_1 && XDS_Data[XDS_Level][1]==cc_data_2)
+ break;
+ if (XDS_Level>=XDS_Data.size())
+ {
+ XDS_Level=XDS_Data.size();
+ XDS_Data.resize(XDS_Level+1);
+ }
+ else
+ XDS_Data[XDS_Level].clear(); // There is a problem, erasing the previous item
+ }
+
+ if (XDS_Level==(size_t)-1)
+ return; //There is a problem
+
+ XDS_Data[XDS_Level].push_back(cc_data_1);
+ XDS_Data[XDS_Level].push_back(cc_data_2);
+ if (cc_data_1==0x0F)
+ XDS();
+ if (XDS_Level!=(size_t)-1 && XDS_Data[XDS_Level].size()>=36)
+ XDS_Data[XDS_Level].clear(); // Clear, this is a security
+ TextMode=0; // This is CC
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::XDS()
+{
+ if (XDS_Data[XDS_Level].size()<4)
+ {
+ XDS_Data.erase(XDS_Data.begin()+XDS_Level);
+ XDS_Level=(size_t)-1;
+ return; //There is a problem
+ }
+
+ switch (XDS_Data[XDS_Level][0])
+ {
+ case 0x01 : XDS_Current(); break;
+ case 0x05 : XDS_Channel(); break;
+ case 0x09 : XDS_PublicService(); break;
+ default : ;
+ }
+
+ XDS_Data.erase(XDS_Data.begin()+XDS_Level);
+ XDS_Level=(size_t)-1;
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::XDS_Current()
+{
+ switch (XDS_Data[XDS_Level][1])
+ {
+ case 0x03 : XDS_Current_ProgramName(); break;
+ case 0x05 : XDS_Current_ContentAdvisory(); break;
+ case 0x08 : XDS_Current_CopyAndRedistributionControlPacket(); break;
+ default : ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::XDS_Current_ContentAdvisory()
+{
+ if (XDS_Data[XDS_Level].size()!=6)
+ {
+ return; //There is a problem
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::XDS_Current_ProgramName()
+{
+ string ValueS;
+ for (size_t Pos=2; Pos<XDS_Data[XDS_Level].size()-2; Pos++)
+ ValueS.append(1, (const char)(XDS_Data[XDS_Level][Pos]));
+ Ztring Value;
+ Value.From_UTF8(ValueS.c_str());
+ Element_Info1(_T("Program Name=")+Value);
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::XDS_Current_CopyAndRedistributionControlPacket()
+{
+ if (XDS_Data[XDS_Level].size()!=6)
+ {
+ return; //There is a problem
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::XDS_Channel()
+{
+ switch (XDS_Data[XDS_Level][1])
+ {
+ case 0x01 : XDS_Channel_NetworkName(); break;
+ default : ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::XDS_Channel_NetworkName()
+{
+ string ValueS;
+ for (size_t Pos=2; Pos<XDS_Data[XDS_Level].size()-2; Pos++)
+ ValueS.append(1, (const char)(XDS_Data[XDS_Level][Pos]));
+ Ztring Value;
+ Value.From_UTF8(ValueS.c_str());
+ Element_Info1(_T("Network Name=")+Value);
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::XDS_PublicService()
+{
+ switch (XDS_Data[XDS_Level][1])
+ {
+ case 0x01 : XDS_PublicService_NationalWeatherService(); break;
+ default : ;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::XDS_PublicService_NationalWeatherService()
+{
+ if (XDS_Data[XDS_Level].size()!=20)
+ {
+ return; //There is a problem
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Special(int8u cc_data_1, int8u cc_data_2)
+{
+ //Data channel check
+ DataChannelMode=(cc_data_1&0x08)!=0; //bit3 is the Data Channel number
+
+ //Field check
+ if (cc_type==(int8u)-1)
+ {
+ if ((cc_data_1==0x14 || cc_data_1==0x1C) && (cc_data_2&0xF0)==0x20)
+ cc_type=0;
+ if ((cc_data_1==0x15 || cc_data_1==0x1D) && (cc_data_2&0xF0)==0x20)
+ cc_type=1;
+ }
+
+ cc_data_1&=0xF7;
+ if (cc_data_1==0x15 && (cc_data_2&0xF0)==0x20)
+ cc_data_1=0x14;
+
+ if (cc_data_1>=0x10 && cc_data_1<=0x17 && cc_data_2>=0x40)
+ {
+ PreambleAddressCode(cc_data_1, cc_data_2);
+ }
+ else
+ {
+ switch (cc_data_1)
+ {
+ case 0x10 : Special_10(cc_data_2); break;
+ case 0x11 : Special_11(cc_data_2); break;
+ case 0x12 : Special_12(cc_data_2); break;
+ case 0x13 : Special_13(cc_data_2); break;
+ case 0x14 : Special_14(cc_data_2); break;
+ case 0x17 : Special_17(cc_data_2); break;
+ default : Illegal(cc_data_1, cc_data_2);
+ }
+ }
+
+ //Saving data, for repetition of the code
+ cc_data_1_Old=cc_data_1;
+ cc_data_2_Old=cc_data_2;
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::PreambleAddressCode(int8u cc_data_1, int8u cc_data_2)
+{
+ //CEA-608-E, Section F.1.1.5
+
+ size_t StreamPos=TextMode*2+DataChannelMode;
+ if (StreamPos>=Streams.size() || Streams[StreamPos]==NULL || !Streams[StreamPos]->Synched)
+ return; //Not synched
+ Streams[StreamPos]->x=0; //I am not sure of this, specifications are not precise
+
+ //Horizontal position
+ if (!TextMode)
+ {
+ Streams[StreamPos]->y=Eia608_PAC_Row[cc_data_1&0x0F]+((cc_data_2&0x20)?1:0);
+ if (Streams[StreamPos]->y>=Eia608_Rows)
+ {
+ Streams[StreamPos]->y=Eia608_Rows-1;
+ }
+ }
+
+ //Attributes (except Underline)
+ if (cc_data_2&0x10) //0x5x and 0x7x
+ {
+ Streams[StreamPos]->x=(cc_data_2&0x0E)<<1;
+ Streams[StreamPos]->Attribute_Current=Attribute_Color_White;
+ }
+ else if ((cc_data_2&0x0E)==0x0E) //0x4E, 0x4F, 0x6E, 0x6F
+ {
+ Streams[StreamPos]->Attribute_Current=Attribute_Color_White|Attribute_Italic;
+ }
+ else //0x40-0x4D, 0x60-0x6D
+ Streams[StreamPos]->Attribute_Current=(cc_data_2&0x0E)>>1;
+
+ //Underline
+ if (cc_data_2&0x01)
+ Streams[StreamPos]->Attribute_Current|=Attribute_Underline;
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Special_10(int8u cc_data_2)
+{
+ switch (cc_data_2)
+ {
+ //CEA-608-E, Section 6.2
+ case 0x20 : break; //Background White, Opaque
+ case 0x21 : break; //Background White, Semi-transparent
+ case 0x22 : break; //
+ case 0x23 : break; //
+ case 0x24 : break; //
+ case 0x25 : break; //
+ case 0x26 : break; //
+ case 0x27 : break; //
+ case 0x28 : break; //
+ case 0x29 : break; //
+ case 0x2A : break; //
+ case 0x2B : break; //
+ case 0x2C : break; //
+ case 0x2D : break; //
+ case 0x2E : break; //
+ case 0x2F : break; //
+ default : Illegal(0x10, cc_data_2);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Special_11(int8u cc_data_2)
+{
+ size_t StreamPos=TextMode*2+DataChannelMode;
+ if (StreamPos>=Streams.size() || Streams[StreamPos]==NULL || !Streams[StreamPos]->Synched)
+ return; //Not synched
+
+ switch (cc_data_2)
+ {
+ //CEA-608-E, Section F.1.1.3
+ case 0x20 : //White
+ case 0x21 : //White Underline
+ case 0x22 : //
+ case 0x23 : //
+ case 0x24 : //
+ case 0x25 : //
+ case 0x26 : //
+ case 0x27 : //
+ case 0x28 : //
+ case 0x29 : //
+ case 0x2A : //
+ case 0x2B : //
+ case 0x2C : //
+ case 0x2D : //
+ case 0x2E : //
+ case 0x2F : //
+ //Color or Italic
+ if ((cc_data_2&0xFE)==0x2E) //Italic
+ Streams[StreamPos]->Attribute_Current|=Attribute_Italic;
+ else //Other attributes
+ Streams[StreamPos]->Attribute_Current=(cc_data_2&0x0F)>>1;
+
+ //Underline
+ if (cc_data_2&0x01)
+ Streams[StreamPos]->Attribute_Current|=Attribute_Underline;
+
+ break;
+ //CEA-608-E, Section F.1.1.1
+ case 0x30 : Character_Fill(L'\x2122'); break; //Registered mark symbol
+ case 0x31 : Character_Fill(L'\xB0' ); break; //Degree sign
+ case 0x32 : Character_Fill(L'\xBD' ); break; //1/2
+ case 0x33 : Character_Fill(L'\xBF' ); break; //interogation mark inverted
+ case 0x34 : Character_Fill(L'\xA9' ); break; //Trademark symbol
+ case 0x35 : Character_Fill(L'\xA2' ); break; //Cents sign
+ case 0x36 : Character_Fill(L'\xA3' ); break; //Pounds Sterling sign
+ case 0x37 : Character_Fill(L'\x266A'); break; //Music note
+ case 0x38 : Character_Fill(L'\xE0' ); break; //a grave
+ case 0x39 : Character_Fill(L' ' ); break; //Transparent space
+ case 0x3A : Character_Fill(L'\xE8' ); break; //e grave
+ case 0x3B : Character_Fill(L'\xE2' ); break; //a circumflex
+ case 0x3C : Character_Fill(L'\xEA' ); break; //e circumflex
+ case 0x3D : Character_Fill(L'\xEE' ); break; //i circumflex
+ case 0x3E : Character_Fill(L'\xF4' ); break; //o circumflex
+ case 0x3F : Character_Fill(L'\xFB' ); break; //u circumflex
+ default : Illegal(0x11, cc_data_2);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Special_12(int8u cc_data_2)
+{
+ size_t StreamPos=TextMode*2+DataChannelMode;
+ if (StreamPos>=Streams.size() || Streams[StreamPos]==NULL || !Streams[StreamPos]->Synched)
+ return; //Not synched
+
+ if (Streams[StreamPos]->x && cc_data_2>=0x20 && cc_data_2<0x40)
+ Streams[StreamPos]->x--; //Erasing previous character
+
+ switch (cc_data_2)
+ {
+ //CEA-608-E, Section 6.4.2
+ case 0x20 : Character_Fill(L'A' ); break; //A with acute
+ case 0x21 : Character_Fill(L'E' ); break; //E with acute
+ case 0x22 : Character_Fill(L'O' ); break; //O with acute
+ case 0x23 : Character_Fill(L'U' ); break; //U with acute
+ case 0x24 : Character_Fill(L'U' ); break; //U withdiaeresis or umlaut
+ case 0x25 : Character_Fill(L'u' ); break; //u with diaeresis or umlaut
+ case 0x26 : Character_Fill(L'\'' ); break; //opening single quote
+ case 0x27 : Character_Fill(L'!' ); break; //inverted exclamation mark
+ case 0x28 : Character_Fill(L'*' ); break; //Asterisk
+ case 0x29 : Character_Fill(L'\'' ); break; //plain single quote
+ case 0x2A : Character_Fill(L'_' ); break; //em dash
+ case 0x2B : Character_Fill(L'C' ); break; //Copyright
+ case 0x2C : Character_Fill(L'S' ); break; //Servicemark
+ case 0x2D : Character_Fill(L'x' ); break; //round bullet
+ case 0x2E : Character_Fill(L'\"' ); break; //opening double quotes
+ case 0x2F : Character_Fill(L'\"' ); break; //closing double quotes
+ case 0x30 : Character_Fill(L'A' ); break; //A with grave accent
+ case 0x31 : Character_Fill(L'A' ); break; //A with circumflex accent
+ case 0x32 : Character_Fill(L'C' ); break; //C with cedilla
+ case 0x33 : Character_Fill(L'E' ); break; //E with grave accent
+ case 0x34 : Character_Fill(L'E' ); break; //E with circumflex accent
+ case 0x35 : Character_Fill(L'E' ); break; //E with diaeresis or umlaut mark
+ case 0x36 : Character_Fill(L'e' ); break; //e with diaeresis or umlaut mark
+ case 0x37 : Character_Fill(L'I' ); break; //I with circumflex accent
+ case 0x38 : Character_Fill(L'I' ); break; //I with diaeresis or umlaut mark
+ case 0x39 : Character_Fill(L'i' ); break; //i with diaeresis or umlaut mark
+ case 0x3A : Character_Fill(L'O' ); break; //O with circumflex
+ case 0x3B : Character_Fill(L'U' ); break; //U with grave accent
+ case 0x3C : Character_Fill(L'u' ); break; //u with grave accent
+ case 0x3D : Character_Fill(L'U' ); break; //U with circumflex accent
+ case 0x3E : Character_Fill(L'\"' ); break; //opening guillemets
+ case 0x3F : Character_Fill(L'\"' ); break; //closing guillemets
+ default : Illegal(0x12, cc_data_2);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Special_13(int8u cc_data_2)
+{
+ size_t StreamPos=TextMode*2+DataChannelMode;
+ if (StreamPos>=Streams.size() || Streams[StreamPos]==NULL || !Streams[StreamPos]->Synched)
+ return; //Not synched
+
+ if (Streams[StreamPos]->x && cc_data_2>=0x20 && cc_data_2<0x40)
+ Streams[StreamPos]->x--; //Erasing previous character
+
+ switch (cc_data_2)
+ {
+ //CEA-608-E, Section 6.4.2
+ case 0x20 : Character_Fill(L'A' ); break; //A with tilde
+ case 0x21 : Character_Fill(L'a' ); break; //a with tilde
+ case 0x22 : Character_Fill(L'I' ); break; //I with acute accent
+ case 0x23 : Character_Fill(L'I' ); break; //I with grave accent
+ case 0x24 : Character_Fill(L'i' ); break; //i with grave accent
+ case 0x25 : Character_Fill(L'O' ); break; //O with grave accent
+ case 0x26 : Character_Fill(L'o' ); break; //o with grave accent
+ case 0x27 : Character_Fill(L'O' ); break; //O with tilde
+ case 0x28 : Character_Fill(L'o' ); break; //o with tilde
+ case 0x29 : Character_Fill(L'{' ); break; //opening brace
+ case 0x2A : Character_Fill(L'}' ); break; //closing brace
+ case 0x2B : Character_Fill(L'\\' ); break; //backslash
+ case 0x2C : Character_Fill(L'^' ); break; //caret
+ case 0x2D : Character_Fill(L'_' ); break; //Underbar
+ case 0x2E : Character_Fill(L'|' ); break; //pipe
+ case 0x2F : Character_Fill(L'~' ); break; //tilde
+ case 0x30 : Character_Fill(L'A' ); break; //A with diaeresis or umlaut mark
+ case 0x31 : Character_Fill(L'a' ); break; //a with diaeresis or umlaut mark
+ case 0x32 : Character_Fill(L'O' ); break; //o with diaeresis or umlaut mark
+ case 0x33 : Character_Fill(L'o' ); break; //o with diaeresis or umlaut mark
+ case 0x34 : Character_Fill(L's' ); break; //eszett (mall sharp s)
+ case 0x35 : Character_Fill(L'Y' ); break; //yen
+ case 0x36 : Character_Fill(L' ' ); break; //non-specific currency sign
+ case 0x37 : Character_Fill(L'|' ); break; //Vertical bar
+ case 0x38 : Character_Fill(L'A' ); break; //I with diaeresis or umlaut mark
+ case 0x39 : Character_Fill(L'a' ); break; //i with diaeresis or umlaut mark
+ case 0x3A : Character_Fill(L'O' ); break; //O with ring
+ case 0x3B : Character_Fill(L'o' ); break; //a with ring
+ case 0x3C : Character_Fill(L' ' ); break; //upper left corner
+ case 0x3D : Character_Fill(L' ' ); break; //upper right corner
+ case 0x3E : Character_Fill(L' ' ); break; //lower left corner
+ case 0x3F : Character_Fill(L' ' ); break; //lower right corner
+ default : Illegal(0x13, cc_data_2);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Special_14(int8u cc_data_2)
+{
+ size_t StreamPos=TextMode*2+DataChannelMode;
+
+ switch (cc_data_2)
+ {
+ case 0x20 : //RCL - Resume Caption Loading
+ case 0x25 : //RU2 - Roll-Up Captions–2 Rows
+ case 0x26 : //RU3 - Roll-Up Captions–3 Rows
+ case 0x27 : //RU4 - Roll-Up Captions–4 Rows
+ case 0x29 : //RDC - Resume Direct Captioning
+ case 0x2A : //TR - Text Restart
+ case 0x2B : //RTD - Resume Text Display
+ TextMode=cc_data_2>=0x2A;
+ XDS_Level=(size_t)-1; // No more XDS
+ StreamPos=TextMode*2+DataChannelMode;
+
+ //Alloc
+ if (StreamPos>=Streams.size())
+ Streams.resize(StreamPos+1);
+ if (Streams[StreamPos]==NULL)
+ {
+ Streams[StreamPos]=new stream();
+ Streams[StreamPos]->CC_Displayed.resize(Eia608_Rows);
+ for (size_t Pos=0; Pos<Streams[StreamPos]->CC_Displayed.size(); Pos++)
+ Streams[StreamPos]->CC_Displayed[Pos].resize(Eia608_Columns);
+ if (StreamPos<2) //CC only, not in Text
+ {
+ Streams[StreamPos]->CC_NonDisplayed.resize(Eia608_Rows);
+ for (size_t Pos=0; Pos<Streams[StreamPos]->CC_NonDisplayed.size(); Pos++)
+ Streams[StreamPos]->CC_NonDisplayed[Pos].resize(Eia608_Columns);
+ }
+ }
+ Streams[StreamPos]->Synched=true;
+
+ break;
+ case 0x2F : //EOC - end of Caption
+ TextMode=false;
+ StreamPos=TextMode*2+DataChannelMode;
+ default: ;
+ }
+
+ if (StreamPos>=Streams.size() || Streams[StreamPos]==NULL || !Streams[StreamPos]->Synched)
+ return; //Not synched
+
+ switch (cc_data_2)
+ {
+ case 0x20 : TextMode=false;
+ Streams[StreamPos]->InBack=true;
+ break; //RCL - Resume Caption Loading (Select pop-on style)
+ case 0x21 : if (Streams[StreamPos]->x)
+ Streams[StreamPos]->x--;
+ (Streams[StreamPos]->InBack?Streams[StreamPos]->CC_NonDisplayed:Streams[StreamPos]->CC_Displayed)[Streams[StreamPos]->y][Streams[StreamPos]->x].Value=L' '; //Clear the character
+ if (!Streams[StreamPos]->InBack)
+ HasChanged();
+ break; //BS - Backspace
+ case 0x22 : Special_14(0x2D); //Found 1 file with AOF and non CR
+ break; //AOF - Alarm Off
+ case 0x23 : break; //AON - Alarm On
+ case 0x24 : for (size_t Pos=Streams[StreamPos]->x; Pos<Eia608_Columns; Pos++)
+ (Streams[StreamPos]->InBack?Streams[StreamPos]->CC_NonDisplayed:Streams[StreamPos]->CC_Displayed)[Streams[StreamPos]->y][Pos].Value=L' '; //Clear up to the end of line
+ if (!Streams[StreamPos]->InBack)
+ HasChanged();
+ break; //DER - Delete to End of Row
+ case 0x25 : //RU2 - Roll-Up Captions–2 Rows
+ case 0x26 : //RU3 - Roll-Up Captions–3 Rows
+ case 0x27 : //RU4 - Roll-Up Captions–4 Rows
+ Streams[StreamPos]->RollUpLines=cc_data_2-0x25+2;
+ Streams[StreamPos]->InBack=false;
+ break; //RUx - Roll-Up Captions–x Rows
+ case 0x28 : break; //FON - Flash On
+ case 0x29 : Streams[StreamPos]->InBack=false;
+ break; //RDC - Resume Direct Captioning (paint-on style)
+ case 0x2A : TextMode=true;
+ Streams[StreamPos]->RollUpLines=Eia608_Rows; //Roll up all the lines
+ Streams[StreamPos]->y=Eia608_Rows-1; //Base is the bottom line
+ Streams[StreamPos]->Attribute_Current=0; //Reset all attributes
+ Special_14(0x2D); //Next line
+ break; //TR - Text Restart (clear Text, but not boxes)
+ case 0x2B : TextMode=true;
+ break; //RTD - Resume Text Display
+ case 0x2C :
+ if (StreamPos<Streams.size() && Streams[StreamPos])
+ {
+ bool HasChanged_=false;
+ for (size_t Pos_Y=0; Pos_Y<Eia608_Rows; Pos_Y++)
+ for (size_t Pos_X=0; Pos_X<Eia608_Columns; Pos_X++)
+ if (Streams[StreamPos]->CC_Displayed[Pos_Y][Pos_X].Value!=L' ')
+ {
+ Streams[StreamPos]->CC_Displayed[Pos_Y][Pos_X].Value=L' ';
+ Streams[StreamPos]->CC_Displayed[Pos_Y][Pos_X].Attribute=0;
+ HasChanged_=true;
+ }
+ if (HasChanged_)
+ HasChanged();
+ }
+ break; //EDM - Erase Displayed Memory
+ case 0x2D : for (size_t Pos=1; Pos<Streams[StreamPos]->RollUpLines; Pos++)
+ {
+ if (Streams[StreamPos]->y>=Streams[StreamPos]->RollUpLines-Pos && Streams[StreamPos]->y-Streams[StreamPos]->RollUpLines+Pos+1<Eia608_Rows)
+ Streams[StreamPos]->CC_Displayed[Streams[StreamPos]->y-Streams[StreamPos]->RollUpLines+Pos]=Streams[StreamPos]->CC_Displayed[Streams[StreamPos]->y-Streams[StreamPos]->RollUpLines+Pos+1];
+ }
+ for (size_t Pos_X=0; Pos_X<Eia608_Columns; Pos_X++)
+ {
+ Streams[StreamPos]->CC_Displayed[Streams[StreamPos]->y][Pos_X].Value=L' ';
+ Streams[StreamPos]->CC_Displayed[Streams[StreamPos]->y][Pos_X].Attribute=0;
+ }
+ if (!Streams[StreamPos]->InBack)
+ HasChanged();
+ Streams[StreamPos]->x=0;
+ break; //CR - Carriage Return
+ case 0x2E : for (size_t Pos_Y=0; Pos_Y<Streams[StreamPos]->CC_NonDisplayed.size(); Pos_Y++)
+ for (size_t Pos_X=0; Pos_X<Streams[StreamPos]->CC_NonDisplayed[Pos_Y].size(); Pos_X++)
+ {
+ Streams[StreamPos]->CC_NonDisplayed[Pos_Y][Pos_X].Value=L' ';
+ Streams[StreamPos]->CC_NonDisplayed[Pos_Y][Pos_X].Attribute=0;
+ }
+ break; //ENM - Erase Non-Displayed Memory
+ case 0x2F : Streams[StreamPos]->CC_Displayed.swap(Streams[StreamPos]->CC_NonDisplayed);
+ HasChanged();
+ Streams[StreamPos]->Synched=false;
+ break; //EOC - End of Caption
+ default : Illegal(0x14, cc_data_2);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Special_17(int8u cc_data_2)
+{
+ size_t StreamPos=TextMode*2+DataChannelMode;
+ if (StreamPos>=Streams.size() || Streams[StreamPos]==NULL || !Streams[StreamPos]->Synched)
+ return; //Not synched
+
+ switch (cc_data_2)
+ {
+ //CEA-608-E, section B.4
+ case 0x21 : //TO1 - Tab Offset 1 Column
+ case 0x22 : //TO2 - Tab Offset 2 Columns
+ case 0x23 : //TO3 - Tab Offset 3 Columns
+ Streams[StreamPos]->x+=cc_data_2&0x03;
+ if (Streams[StreamPos]->x>=Eia608_Columns)
+ Streams[StreamPos]->x=Eia608_Columns-1;
+ break;
+ //CEA-608-E, section 6.3
+ case 0x24 : break; //Select the standard line 21 character set in normal size
+ case 0x25 : break; //Select the standard line 21 character set in double size
+ case 0x26 : break; //Select the first private character set
+ case 0x27 : break; //Select the second private character set
+ case 0x28 : break; //Select the People's Republic of China character set: GB 2312-80
+ case 0x29 : break; //Select the Korean Standard character set: KSC 5601-1987
+ case 0x2A : break; //Select the first registered character set
+ //CEA-608-E, section 6.2
+ case 0x2D : break; //Background Transparent
+ case 0x2E : break; //Foreground Black
+ case 0x2F : break; //Foreground Black Underline
+ default : Illegal(0x17, cc_data_2);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Standard(int8u Character)
+{
+ switch (Character)
+ {
+ //CEA-608-E, Section F.1.1.2
+ case 0x20 : Character_Fill(L' ' ); break;
+ case 0x21 : Character_Fill(L'!' ); break;
+ case 0x22 : Character_Fill(L'"' ); break;
+ case 0x23 : Character_Fill(L'#' ); break;
+ case 0x24 : Character_Fill(L'$' ); break;
+ case 0x25 : Character_Fill(L'%' ); break;
+ case 0x26 : Character_Fill(L'&' ); break;
+ case 0x27 : Character_Fill(L'\'' ); break;
+ case 0x28 : Character_Fill(L'(' ); break;
+ case 0x29 : Character_Fill(L')' ); break;
+ case 0x2A : Character_Fill(L'\xE1' ); break; //a acute
+ case 0x2B : Character_Fill(L'+' ); break;
+ case 0x2C : Character_Fill(L',' ); break;
+ case 0x2D : Character_Fill(L'-' ); break;
+ case 0x2E : Character_Fill(L'.' ); break;
+ case 0x2F : Character_Fill(L'/' ); break;
+ case 0x30 : Character_Fill(L'0' ); break;
+ case 0x31 : Character_Fill(L'1' ); break;
+ case 0x32 : Character_Fill(L'2' ); break;
+ case 0x33 : Character_Fill(L'3' ); break;
+ case 0x34 : Character_Fill(L'4' ); break;
+ case 0x35 : Character_Fill(L'5' ); break;
+ case 0x36 : Character_Fill(L'6' ); break;
+ case 0x37 : Character_Fill(L'7' ); break;
+ case 0x38 : Character_Fill(L'8' ); break;
+ case 0x39 : Character_Fill(L'9' ); break;
+ case 0x3A : Character_Fill(L':' ); break;
+ case 0x3B : Character_Fill(L';' ); break;
+ case 0x3C : Character_Fill(L'<' ); break;
+ case 0x3E : Character_Fill(L'>' ); break;
+ case 0x3F : Character_Fill(L'?' ); break;
+ case 0x40 : Character_Fill(L'@' ); break;
+ case 0x41 : Character_Fill(L'A' ); break;
+ case 0x42 : Character_Fill(L'B' ); break;
+ case 0x43 : Character_Fill(L'C' ); break;
+ case 0x44 : Character_Fill(L'D' ); break;
+ case 0x45 : Character_Fill(L'E' ); break;
+ case 0x46 : Character_Fill(L'F' ); break;
+ case 0x47 : Character_Fill(L'G' ); break;
+ case 0x48 : Character_Fill(L'H' ); break;
+ case 0x49 : Character_Fill(L'I' ); break;
+ case 0x4A : Character_Fill(L'J' ); break;
+ case 0x4B : Character_Fill(L'K' ); break;
+ case 0x4C : Character_Fill(L'L' ); break;
+ case 0x4D : Character_Fill(L'M' ); break;
+ case 0x4E : Character_Fill(L'N' ); break;
+ case 0x4F : Character_Fill(L'O' ); break;
+ case 0x50 : Character_Fill(L'P' ); break;
+ case 0x51 : Character_Fill(L'Q' ); break;
+ case 0x52 : Character_Fill(L'R' ); break;
+ case 0x53 : Character_Fill(L'S' ); break;
+ case 0x54 : Character_Fill(L'T' ); break;
+ case 0x55 : Character_Fill(L'U' ); break;
+ case 0x56 : Character_Fill(L'V' ); break;
+ case 0x57 : Character_Fill(L'W' ); break;
+ case 0x58 : Character_Fill(L'X' ); break;
+ case 0x59 : Character_Fill(L'Y' ); break;
+ case 0x5A : Character_Fill(L'Z' ); break;
+ case 0x5B : Character_Fill(L'[' ); break;
+ case 0x5C : Character_Fill(L'\xE9' ); break; //e acute
+ case 0x5D : Character_Fill(L']' ); break;
+ case 0x5E : Character_Fill(L'\xED' ); break; //i acute
+ case 0x5F : Character_Fill(L'\xF3' ); break; //o acute
+ case 0x60 : Character_Fill(L'\xFA' ); break; //u acute
+ case 0x61 : Character_Fill(L'a' ); break;
+ case 0x62 : Character_Fill(L'b' ); break;
+ case 0x63 : Character_Fill(L'c' ); break;
+ case 0x64 : Character_Fill(L'd' ); break;
+ case 0x65 : Character_Fill(L'e' ); break;
+ case 0x66 : Character_Fill(L'f' ); break;
+ case 0x67 : Character_Fill(L'g' ); break;
+ case 0x68 : Character_Fill(L'h' ); break;
+ case 0x69 : Character_Fill(L'i' ); break;
+ case 0x6A : Character_Fill(L'j' ); break;
+ case 0x6B : Character_Fill(L'k' ); break;
+ case 0x6C : Character_Fill(L'l' ); break;
+ case 0x6D : Character_Fill(L'm' ); break;
+ case 0x6E : Character_Fill(L'n' ); break;
+ case 0x6F : Character_Fill(L'o' ); break;
+ case 0x70 : Character_Fill(L'p' ); break;
+ case 0x71 : Character_Fill(L'q' ); break;
+ case 0x72 : Character_Fill(L'r' ); break;
+ case 0x73 : Character_Fill(L's' ); break;
+ case 0x74 : Character_Fill(L't' ); break;
+ case 0x75 : Character_Fill(L'u' ); break;
+ case 0x76 : Character_Fill(L'v' ); break;
+ case 0x77 : Character_Fill(L'w' ); break;
+ case 0x78 : Character_Fill(L'x' ); break;
+ case 0x79 : Character_Fill(L'y' ); break;
+ case 0x7A : Character_Fill(L'z' ); break;
+ case 0x7B : Character_Fill(L'\xE7' ); break; //c with cedilla
+ case 0x7C : Character_Fill(L'\xF7' ); break; //division symbol
+ case 0x7D : Character_Fill(L'\xD1' ); break; //N tilde
+ case 0x7E : Character_Fill(L'\xF1' ); break; //n tilde
+ case 0x7F : Character_Fill(L'\x25A0'); break; //Solid block
+ default : Illegal(0x00, Character);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Character_Fill(wchar_t Character)
+{
+ size_t StreamPos=TextMode*2+DataChannelMode;
+ if (StreamPos>=Streams.size() || Streams[StreamPos]==NULL || !Streams[StreamPos]->Synched)
+ return; //Not synched
+
+ if (Streams[StreamPos]->x==Eia608_Columns)
+ {
+ Streams[StreamPos]->x--; //There is a problem
+
+ //TODO: Put it at the end, for the conversion
+ //TODO: Handle special chars
+ }
+
+ if (Streams[StreamPos]->InBack)
+ Streams[StreamPos]->CC_NonDisplayed[Streams[StreamPos]->y][Streams[StreamPos]->x].Value=Character;
+ else
+ Streams[StreamPos]->CC_Displayed[Streams[StreamPos]->y][Streams[StreamPos]->x].Value=Character;
+
+ Streams[StreamPos]->x++;
+
+ if (TextMode || !Streams[StreamPos]->InBack)
+ HasChanged();
+
+ if (!HasContent)
+ HasContent=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::HasChanged()
+{
+}
+
+//---------------------------------------------------------------------------
+void File_Eia608::Illegal(int8u cc_data_1, int8u cc_data_2)
+{
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_EIA608_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia608.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia608.h
new file mode 100644
index 000000000..da0e74f4a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia608.h
@@ -0,0 +1,151 @@
+// File_Eia608 - Info for EIA-608 files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about PGS files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Eia608H
+#define MediaInfo_File_Eia608H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+#include <bitset>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Eia608
+//***************************************************************************
+
+static const int8u Eia608_Rows=15; //Screen size, specified by the standard
+static const int8u Eia608_Columns=32; //Screen size, specified by the standard
+class File_Eia608 : public File__Analyze
+{
+public :
+ //In
+ int8u cc_type;
+
+ //Constructor/Destructor
+ File_Eia608();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Synchro
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Global
+ void Read_Buffer_Init();
+ void Read_Buffer_Continue();
+ void Read_Buffer_AfterParsing();
+
+ //Function
+ void Standard (int8u Character);
+
+ std::vector<std::vector<int8u> > XDS_Data;
+ size_t XDS_Level;
+ bool TextMode; //CC or T
+ bool DataChannelMode; //if true, CC2/CC4/T2/T4
+
+ void XDS(int8u cc_data_1, int8u cc_data_2);
+ void XDS();
+ void XDS_Current();
+ void XDS_Current_ProgramName();
+ void XDS_Current_ContentAdvisory();
+ void XDS_Current_CopyAndRedistributionControlPacket();
+ void XDS_PublicService();
+ void XDS_PublicService_NationalWeatherService();
+ void XDS_Channel();
+ void XDS_Channel_NetworkName();
+ void Special(int8u cc_data_1, int8u cc_data_2);
+ void Special_10(int8u cc_data_2);
+ void Special_11(int8u cc_data_2);
+ void Special_12(int8u cc_data_2);
+ void Special_13(int8u cc_data_2);
+ void Special_14(int8u cc_data_2);
+ void Special_17(int8u cc_data_2);
+ void PreambleAddressCode(int8u cc_data_1, int8u cc_data_2);
+
+ //An attribute consists of Attribute_Color_*, optionally OR'd with Attribute_Underline and/or Attribute_Italic
+ enum attributes
+ {
+ Attribute_Color_White =0x00,
+ Attribute_Color_Green =0x01,
+ Attribute_Color_Blue =0x02,
+ Attribute_Color_Cyan =0x03,
+ Attribute_Color_Red =0x04,
+ Attribute_Color_Yellow =0x05,
+ Attribute_Color_Magenta =0x06,
+ Attribute_Underline =0x10,
+ Attribute_Italic =0x20,
+ };
+
+ struct character
+ {
+ wchar_t Value;
+ int8u Attribute;
+
+ character()
+ {
+ Value=L' ';
+ }
+ };
+ void Character_Fill(wchar_t Character);
+ void HasChanged();
+ void Illegal(int8u cc_data_1, int8u cc_data_2);
+ struct stream
+ {
+ vector<vector<character> > CC_Displayed;
+ vector<vector<character> > CC_NonDisplayed;
+ bool InBack; //The back buffer is written
+ size_t x;
+ size_t y;
+ int8u Attribute_Current;
+ size_t RollUpLines;
+ bool Synched;
+
+ stream()
+ {
+ InBack=false;
+ x=0;
+ y=Eia608_Rows-1;
+ Attribute_Current=0;
+ RollUpLines=0;
+ Synched=false;
+ }
+ };
+ std::vector<stream*> Streams;
+
+ int8u cc_data_1_Old;
+ int8u cc_data_2_Old;
+ bool HasContent;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia708.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia708.cpp
new file mode 100644
index 000000000..7ab5c37f8
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia708.cpp
@@ -0,0 +1,1367 @@
+// File_Eia708 - Info for EIA-708 files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_EIA708_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_Eia708.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Eia708::File_Eia708()
+:File__Analyze()
+{
+ //Config
+ PTS_DTS_Needed=true;
+
+ //In
+ cc_type=(int8u)-1;
+ AspectRatio=((float32)4)/3; //Default to 4:3
+
+ //Stream
+ service_number=(int8u)-1;
+
+ //Temp
+ StandAloneCommand=false;
+ HasContent=false;
+}
+
+//---------------------------------------------------------------------------
+File_Eia708::~File_Eia708()
+{
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ delete Streams[Pos]; //Streams[Pos]=NULL
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Eia708::Streams_Fill()
+{
+ if (Config->File_Eia708_DisplayEmptyStream_Get() && Streams.size()<2)
+ Streams.resize(2);
+
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ if (Streams[Pos] || (Pos && Pos<2 && Config->File_Eia708_DisplayEmptyStream_Get()))
+ {
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, StreamPos_Last, Text_ID, Pos);
+ Fill(Stream_Text, StreamPos_Last, Text_Format, "EIA-708");
+ Fill(Stream_Text, StreamPos_Last, Text_StreamSize, 0);
+ Fill(Stream_Text, StreamPos_Last, Text_BitRate_Mode, "CBR");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia708::Streams_Finish()
+{
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Eia708::Read_Buffer_Init()
+{
+}
+
+//---------------------------------------------------------------------------
+void File_Eia708::Read_Buffer_Continue()
+{
+ FrameInfo.PTS=FrameInfo.DTS;
+
+ if (!Status[IsAccepted])
+ {
+ if (cc_type!=3)
+ {
+ Skip_B2( "Waiting for header");
+ return;
+ }
+
+ Accept("EIA-708");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia708::Read_Buffer_Unsynched()
+{
+ if (cc_type==4) //Magic value saying that the buffer must be kept (this is only a point of synchro from the undelying layer)
+ return;
+
+ for (int8u service_number=1; service_number<Streams.size(); service_number++)
+ if (Streams[service_number])
+ {
+ //Per window
+ for (size_t WindowID=0; WindowID<Streams[service_number]->Windows.size(); WindowID++)
+ {
+ window* Window=Streams[service_number]->Windows[WindowID];
+ if (Window)
+ for (size_t Pos_Y=0; Pos_Y<Window->Minimal.CC.size(); Pos_Y++)
+ {
+ for (size_t Pos_X=0; Pos_X<Window->Minimal.CC[Pos_Y].size(); Pos_X++)
+ {
+ Window->Minimal.CC[Pos_Y][Pos_X].Value=L' ';;
+ Window->Minimal.CC[Pos_Y][Pos_X].Attribute=0;
+ }
+ }
+ }
+
+ //Global display
+ for (size_t Pos_Y=0; Pos_Y<Streams[service_number]->Minimal.CC.size(); Pos_Y++)
+ {
+ for (size_t Pos_X=0; Pos_X<Streams[service_number]->Minimal.CC[Pos_Y].size(); Pos_X++)
+ {
+ Streams[service_number]->Minimal.CC[Pos_Y][Pos_X].Value=L' ';
+ Streams[service_number]->Minimal.CC[Pos_Y][Pos_X].Attribute=0;
+ }
+ }
+ }
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Eia708::Header_Parse()
+{
+ //Parsing
+ int8u packet_size, sequence_number;
+ BS_Begin();
+ Get_S1(2, sequence_number, "sequence_number");
+ Get_S1(6, packet_size, "packet_size_code");
+ BS_End();
+
+ Header_Fill_Code(0, _T("DTVCC packet"));
+ Header_Fill_Size(packet_size==0?128:(packet_size*2));
+}
+
+//---------------------------------------------------------------------------
+void File_Eia708::Data_Parse()
+{
+ //Parsing
+ while (Element_Offset<Element_Size)
+ {
+ BS_Begin();
+ Get_S1(3, service_number, "service_number");
+ Get_S1(5, block_size, "block_size");
+ if (service_number==7)
+ {
+ Mark_0();
+ Mark_0();
+ Get_S1(6, service_number, "extended_service_number");
+ }
+ BS_End();
+
+ if (service_number)
+ {
+ Element_Begin1("Service Block Packet");
+ Service();
+ Element_End0();
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Eia708::Service()
+{
+ if (service_number>=Streams.size())
+ Streams.resize(service_number+1);
+ if (Streams[service_number]==NULL)
+ {
+ Streams[service_number]=new stream;
+ Streams[service_number]->Minimal.CC.resize(15);
+ for (int8u Pos_Y=0; Pos_Y<15; Pos_Y++)
+ Streams[service_number]->Minimal.CC[Pos_Y].resize((size_t)(24*AspectRatio));
+ Streams[service_number]->Windows.resize(8);
+ }
+
+ for (int8u Pos=0; Pos<block_size; Pos++)
+ {
+ int8u cc_data_1;
+ Get_B1(cc_data_1, "cc_data");
+ switch (cc_data_1)
+ {
+ //CEA-708-D, Section 7.1.4 (C0)
+ case 0x00 : NUL(); break; //NUL
+ case 0x03 : ETX(); break; //End Of Text
+ case 0x08 : BS(); break; //BackSpace
+ case 0x0C : FF(); break; //Form Feed
+ case 0x0D : CR(); break; //Carriage Return
+ case 0x0E : HCR(); break; //Horizontal Carriage Return
+ case 0x01 :
+ case 0x02 :
+ case 0x04 :
+ case 0x05 :
+ case 0x06 :
+ case 0x07 :
+ case 0x09 :
+ case 0x0A :
+ case 0x0B :
+ case 0x0F : break; //1-byte long undefined code
+ case 0x10 : //EXT1
+ {
+ int8u cc_data_2;
+ Get_B1(cc_data_2, "cc_data");
+ Pos++;
+ switch (cc_data_2)
+ {
+ //CEA-708-D, Section 7.1.8 (G2)
+ case 0x20 : Character_Fill(L' ' ); break;
+ case 0x21 : Character_Fill(L' ' ); break;
+ case 0x25 : Character_Fill(L'.' ); Character_Fill(L'.'); Character_Fill(L'.'); break;
+ case 0x2A : Character_Fill(L'S' ); break;
+ case 0x2C : Character_Fill(L'O' ); Character_Fill(L'E'); break;
+ case 0x30 : Character_Fill(L' ' ); break; //(Solid Block)
+ case 0x31 : Character_Fill(L'\'' ); break;
+ case 0x32 : Character_Fill(L'\'' ); break;
+ case 0x33 : Character_Fill(L'\'' ); break;
+ case 0x34 : Character_Fill(L'\'' ); break;
+ case 0x35 : Character_Fill(L'.' ); break;
+ case 0x39 : Character_Fill(L'_' ); break; //TM
+ case 0x3A : Character_Fill(L's' ); break;
+ case 0x3C : Character_Fill(L'_' ); break; //oe
+ case 0x3D : Character_Fill(L'_' ); break; //SM
+ case 0x3F : Character_Fill(L'Y' ); break;
+ case 0x76 : Character_Fill(L'_' ); break; //1/8
+ case 0x77 : Character_Fill(L'_' ); break; //3/8
+ case 0x78 : Character_Fill(L'_' ); break; //5/8
+ case 0x79 : Character_Fill(L'_' ); break; //7/8
+ case 0x7A : Character_Fill(L'+' ); break;
+ case 0x7B : Character_Fill(L'+' ); break;
+ case 0x7C : Character_Fill(L'+' ); break;
+ case 0x7D : Character_Fill(L'+' ); break;
+ case 0x7E : Character_Fill(L'+' ); break;
+ case 0x7F : Character_Fill(L'+' ); break;
+ //CEA-708-D, Section 7.1.9 (G3)
+ case 0x80 : Character_Fill(L'_' ); break; //(CC)
+ default :
+ //CEA-708-D, Section 7.1.10 (C2)
+ if (cc_data_2>=0x08 && cc_data_2<0x10)
+ {
+ Skip_B1( "EXT1 1 byte");
+ Pos++;
+ }
+ else if (cc_data_2>=0x10 && cc_data_2<0x18)
+ {
+ Skip_B2( "EXT1 2 byte");
+ Pos+=2;
+ }
+ else if (cc_data_2>=0x18 && cc_data_2<0x20)
+ {
+ Skip_B3( "EXT1 3 byte");
+ Pos+=3;
+ }
+ //CEA-708-D, Section 7.1.11 (C3)
+ else if (cc_data_2>=0x80 && cc_data_2<0x88)
+ {
+ Skip_B4( "EXT1 4 byte");
+ Pos+=4;
+ }
+ else if (cc_data_2>=0x88 && cc_data_2<0x90)
+ {
+ Skip_B5( "EXT1 5 byte");
+ Pos+=5;
+ }
+ else if (cc_data_2>=0x90 && cc_data_2<0xA0)
+ {
+ //CEA-708-D, Section 7.1.11.2 (Variable Length Codes)
+ int8u Length;
+ BS_Begin();
+ Skip_S1(2, "Type");
+ Mark_0();
+ Get_S1 (5, Length, "Length");
+ Skip_XX(Length, "Data");
+ Pos+=1+Length;
+ }
+ //CEA-708-D, Section 7.1.9 (G3)
+ else
+ Character_Fill(L'_' );
+ }
+ }
+ break;
+ case 0x11 :
+ case 0x12 :
+ case 0x13 :
+ case 0x14 :
+ case 0x15 :
+ case 0x16 :
+ case 0x17 : //2-byte long undefined
+ {
+ Skip_B1( "Undefined");
+ Pos++;
+ }
+ break;
+ case 0x18 : //P16
+ {
+ Skip_B2( "P16");
+ Pos+=2;
+ }
+ break;
+ case 0x19 :
+ case 0x1A :
+ case 0x1B :
+ case 0x1C :
+ case 0x1D :
+ case 0x1E :
+ case 0x1F : //3-byte long undefined
+ {
+ Skip_B2( "Undefined");
+ Pos+=2;
+ }
+ break;
+ //CEA-708-D, Section 7.1.6 (G0)
+ case 0x20 : Character_Fill(L' ' ); break;
+ case 0x21 : Character_Fill(L'!' ); break;
+ case 0x22 : Character_Fill(L'"' ); break;
+ case 0x23 : Character_Fill(L'#' ); break;
+ case 0x24 : Character_Fill(L'$' ); break;
+ case 0x25 : Character_Fill(L'%' ); break;
+ case 0x26 : Character_Fill(L'&' ); break;
+ case 0x27 : Character_Fill(L'\'' ); break;
+ case 0x28 : Character_Fill(L'(' ); break;
+ case 0x29 : Character_Fill(L')' ); break;
+ case 0x2A : Character_Fill(L'*' ); break;
+ case 0x2B : Character_Fill(L'+' ); break;
+ case 0x2C : Character_Fill(L',' ); break;
+ case 0x2D : Character_Fill(L'-' ); break;
+ case 0x2E : Character_Fill(L'.' ); break;
+ case 0x2F : Character_Fill(L'/' ); break;
+ case 0x30 : Character_Fill(L'0' ); break;
+ case 0x31 : Character_Fill(L'1' ); break;
+ case 0x32 : Character_Fill(L'2' ); break;
+ case 0x33 : Character_Fill(L'3' ); break;
+ case 0x34 : Character_Fill(L'4' ); break;
+ case 0x35 : Character_Fill(L'5' ); break;
+ case 0x36 : Character_Fill(L'6' ); break;
+ case 0x37 : Character_Fill(L'7' ); break;
+ case 0x38 : Character_Fill(L'8' ); break;
+ case 0x39 : Character_Fill(L'9' ); break;
+ case 0x3A : Character_Fill(L':' ); break;
+ case 0x3B : Character_Fill(L';' ); break;
+ case 0x3C : Character_Fill(L'<' ); break;
+ case 0x3E : Character_Fill(L'>' ); break;
+ case 0x3F : Character_Fill(L'?' ); break;
+ case 0x40 : Character_Fill(L'@' ); break;
+ case 0x41 : Character_Fill(L'A' ); break;
+ case 0x42 : Character_Fill(L'B' ); break;
+ case 0x43 : Character_Fill(L'C' ); break;
+ case 0x44 : Character_Fill(L'D' ); break;
+ case 0x45 : Character_Fill(L'E' ); break;
+ case 0x46 : Character_Fill(L'F' ); break;
+ case 0x47 : Character_Fill(L'G' ); break;
+ case 0x48 : Character_Fill(L'H' ); break;
+ case 0x49 : Character_Fill(L'I' ); break;
+ case 0x4A : Character_Fill(L'J' ); break;
+ case 0x4B : Character_Fill(L'K' ); break;
+ case 0x4C : Character_Fill(L'L' ); break;
+ case 0x4D : Character_Fill(L'M' ); break;
+ case 0x4E : Character_Fill(L'N' ); break;
+ case 0x4F : Character_Fill(L'O' ); break;
+ case 0x50 : Character_Fill(L'P' ); break;
+ case 0x51 : Character_Fill(L'Q' ); break;
+ case 0x52 : Character_Fill(L'R' ); break;
+ case 0x53 : Character_Fill(L'S' ); break;
+ case 0x54 : Character_Fill(L'T' ); break;
+ case 0x55 : Character_Fill(L'U' ); break;
+ case 0x56 : Character_Fill(L'V' ); break;
+ case 0x57 : Character_Fill(L'W' ); break;
+ case 0x58 : Character_Fill(L'X' ); break;
+ case 0x59 : Character_Fill(L'Y' ); break;
+ case 0x5A : Character_Fill(L'Z' ); break;
+ case 0x5B : Character_Fill(L'[' ); break;
+ case 0x5C : Character_Fill(L'\\' ); break;
+ case 0x5D : Character_Fill(L']' ); break;
+ case 0x5E : Character_Fill(L'^' ); break;
+ case 0x5F : Character_Fill(L'_' ); break;
+ case 0x60 : Character_Fill(L'`' ); break;
+ case 0x61 : Character_Fill(L'a' ); break;
+ case 0x62 : Character_Fill(L'b' ); break;
+ case 0x63 : Character_Fill(L'c' ); break;
+ case 0x64 : Character_Fill(L'd' ); break;
+ case 0x65 : Character_Fill(L'e' ); break;
+ case 0x66 : Character_Fill(L'f' ); break;
+ case 0x67 : Character_Fill(L'g' ); break;
+ case 0x68 : Character_Fill(L'h' ); break;
+ case 0x69 : Character_Fill(L'i' ); break;
+ case 0x6A : Character_Fill(L'j' ); break;
+ case 0x6B : Character_Fill(L'k' ); break;
+ case 0x6C : Character_Fill(L'l' ); break;
+ case 0x6D : Character_Fill(L'm' ); break;
+ case 0x6E : Character_Fill(L'n' ); break;
+ case 0x6F : Character_Fill(L'o' ); break;
+ case 0x70 : Character_Fill(L'p' ); break;
+ case 0x71 : Character_Fill(L'q' ); break;
+ case 0x72 : Character_Fill(L'r' ); break;
+ case 0x73 : Character_Fill(L's' ); break;
+ case 0x74 : Character_Fill(L't' ); break;
+ case 0x75 : Character_Fill(L'u' ); break;
+ case 0x76 : Character_Fill(L'v' ); break;
+ case 0x77 : Character_Fill(L'w' ); break;
+ case 0x78 : Character_Fill(L'x' ); break;
+ case 0x79 : Character_Fill(L'y' ); break;
+ case 0x7A : Character_Fill(L'z' ); break;
+ case 0x7B : Character_Fill(L'{' ); break;
+ case 0x7C : Character_Fill(L'|' ); break;
+ case 0x7D : Character_Fill(L'}' ); break;
+ case 0x7E : Character_Fill(L'~' ); break;
+ case 0x7F : Character_Fill(L'\x266A'); break;
+ //CEA-708-D, Section 7.1.5 (C1)
+ case 0x80 : //CW0
+ case 0x81 : //CW1
+ case 0x82 : //CW2
+ case 0x83 : //CW3
+ case 0x84 : //CW4
+ case 0x85 : //CW5
+ case 0x86 : //CW6
+ case 0x87 : //CW7
+ CWx(cc_data_1-0x80); break; //SetCurrentWindow
+ case 0x88 : CLW(); Pos+=1; break; //ClearWindows
+ case 0x89 : DSW(); Pos+=1; break; //DisplayWindows
+ case 0x8A : HDW(); Pos+=1; break; //HideWindows
+ case 0x8B : TGW(); Pos+=1; break; //ToggleWindows
+ case 0x8C : DLW(); Pos+=1; break; //DeleteWindows
+ case 0x8D : DLY(); Pos+=1; break; //Delay
+ case 0x8E : DLC(); break; //Delay Cancel
+ case 0x8F : RST(); break; //Reset
+ case 0x90 : SPA(); Pos+=2; break; //SetPenAttributes
+ case 0x91 : SPC(); Pos+=3; break; //SetPenColor
+ case 0x92 : SPL(); Pos+=2; break; //SetPenLocation
+ case 0x97 : SWA(); Pos+=5; break; //SetWindowAttributes
+ case 0x98 : //DF0
+ case 0x99 : //DF1
+ case 0x9A : //DF2
+ case 0x9B : //DF3
+ case 0x9C : //DF4
+ case 0x9D : //DF5
+ case 0x9E : //DF6
+ case 0x9F : //DF7
+ DFx(cc_data_1-0x98); Pos+=6; break; //DefineWindow
+ //CEA-708-D, Section 7.1.6 (G1)
+ case 0xA0 : Character_Fill(L'\xA0' ); break;
+ case 0xA1 : Character_Fill(L'\xA1' ); break;
+ case 0xA2 : Character_Fill(L'\xA2' ); break;
+ case 0xA3 : Character_Fill(L'\xA3' ); break;
+ case 0xA4 : Character_Fill(L'\xA4' ); break;
+ case 0xA5 : Character_Fill(L'\xA5' ); break;
+ case 0xA6 : Character_Fill(L'\xA6' ); break;
+ case 0xA7 : Character_Fill(L'\xA7' ); break;
+ case 0xA8 : Character_Fill(L'\xA8' ); break;
+ case 0xA9 : Character_Fill(L'\xA9' ); break;
+ case 0xAA : Character_Fill(L'\xAA' ); break;
+ case 0xAB : Character_Fill(L'\xAB' ); break;
+ case 0xAC : Character_Fill(L'\xAC' ); break;
+ case 0xAD : Character_Fill(L'\xAD' ); break;
+ case 0xAE : Character_Fill(L'\xAE' ); break;
+ case 0xAF : Character_Fill(L'\xAF' ); break;
+ case 0xB0 : Character_Fill(L'\xB0' ); break;
+ case 0xB1 : Character_Fill(L'\xB1' ); break;
+ case 0xB2 : Character_Fill(L'\xB2' ); break;
+ case 0xB3 : Character_Fill(L'\xB3' ); break;
+ case 0xB4 : Character_Fill(L'\xB4' ); break;
+ case 0xB5 : Character_Fill(L'\xB5' ); break;
+ case 0xB6 : Character_Fill(L'\xB6' ); break;
+ case 0xB7 : Character_Fill(L'\xB7' ); break;
+ case 0xB8 : Character_Fill(L'\xB8' ); break;
+ case 0xB9 : Character_Fill(L'\xB9' ); break;
+ case 0xBA : Character_Fill(L'\xBA' ); break;
+ case 0xBB : Character_Fill(L'\xBB' ); break;
+ case 0xBC : Character_Fill(L'\xBC' ); break;
+ case 0xBD : Character_Fill(L'\xBD' ); break;
+ case 0xBE : Character_Fill(L'\xBE' ); break;
+ case 0xBF : Character_Fill(L'\xBF' ); break;
+ case 0xC0 : Character_Fill(L'\xC0' ); break;
+ case 0xC1 : Character_Fill(L'\xC1' ); break;
+ case 0xC2 : Character_Fill(L'\xC2' ); break;
+ case 0xC3 : Character_Fill(L'\xC3' ); break;
+ case 0xC4 : Character_Fill(L'\xC4' ); break;
+ case 0xC5 : Character_Fill(L'\xC5' ); break;
+ case 0xC6 : Character_Fill(L'\xC6' ); break;
+ case 0xC7 : Character_Fill(L'\xC7' ); break;
+ case 0xC8 : Character_Fill(L'\xC8' ); break;
+ case 0xC9 : Character_Fill(L'\xC9' ); break;
+ case 0xCA : Character_Fill(L'\xCA' ); break;
+ case 0xCB : Character_Fill(L'\xCB' ); break;
+ case 0xCC : Character_Fill(L'\xCC' ); break;
+ case 0xCD : Character_Fill(L'\xCD' ); break;
+ case 0xCE : Character_Fill(L'\xCE' ); break;
+ case 0xCF : Character_Fill(L'\xCF' ); break;
+ case 0xD0 : Character_Fill(L'\xD0' ); break;
+ case 0xD1 : Character_Fill(L'\xD1' ); break;
+ case 0xD2 : Character_Fill(L'\xD2' ); break;
+ case 0xD3 : Character_Fill(L'\xD3' ); break;
+ case 0xD4 : Character_Fill(L'\xD4' ); break;
+ case 0xD5 : Character_Fill(L'\xD5' ); break;
+ case 0xD6 : Character_Fill(L'\xD6' ); break;
+ case 0xD7 : Character_Fill(L'\xD7' ); break;
+ case 0xD8 : Character_Fill(L'\xD8' ); break;
+ case 0xD9 : Character_Fill(L'\xD9' ); break;
+ case 0xDA : Character_Fill(L'\xDA' ); break;
+ case 0xDB : Character_Fill(L'\xDB' ); break;
+ case 0xDC : Character_Fill(L'\xDC' ); break;
+ case 0xDD : Character_Fill(L'\xDD' ); break;
+ case 0xDE : Character_Fill(L'\xDE' ); break;
+ case 0xDF : Character_Fill(L'\xDF' ); break;
+ case 0xE0 : Character_Fill(L'\xE0' ); break;
+ case 0xE1 : Character_Fill(L'\xE1' ); break;
+ case 0xE2 : Character_Fill(L'\xE2' ); break;
+ case 0xE3 : Character_Fill(L'\xE3' ); break;
+ case 0xE4 : Character_Fill(L'\xE4' ); break;
+ case 0xE5 : Character_Fill(L'\xE5' ); break;
+ case 0xE6 : Character_Fill(L'\xE6' ); break;
+ case 0xE7 : Character_Fill(L'\xE7' ); break;
+ case 0xE8 : Character_Fill(L'\xE8' ); break;
+ case 0xE9 : Character_Fill(L'\xE9' ); break;
+ case 0xEA : Character_Fill(L'\xEA' ); break;
+ case 0xEB : Character_Fill(L'\xEB' ); break;
+ case 0xEC : Character_Fill(L'\xEC' ); break;
+ case 0xED : Character_Fill(L'\xED' ); break;
+ case 0xEE : Character_Fill(L'\xEE' ); break;
+ case 0xEF : Character_Fill(L'\xEF' ); break;
+ case 0xF0 : Character_Fill(L'\xF0' ); break;
+ case 0xF1 : Character_Fill(L'\xF1' ); break;
+ case 0xF2 : Character_Fill(L'\xF2' ); break;
+ case 0xF3 : Character_Fill(L'\xF3' ); break;
+ case 0xF4 : Character_Fill(L'\xF4' ); break;
+ case 0xF5 : Character_Fill(L'\xF5' ); break;
+ case 0xF6 : Character_Fill(L'\xF6' ); break;
+ case 0xF7 : Character_Fill(L'\xF7' ); break;
+ case 0xF8 : Character_Fill(L'\xF8' ); break;
+ case 0xF9 : Character_Fill(L'\xF9' ); break;
+ case 0xFA : Character_Fill(L'\xFA' ); break;
+ case 0xFB : Character_Fill(L'\xFB' ); break;
+ case 0xFC : Character_Fill(L'\xFC' ); break;
+ case 0xFD : Character_Fill(L'\xFD' ); break;
+ case 0xFE : Character_Fill(L'\xFE' ); break;
+ case 0xFF : Character_Fill(L'\xFF' ); break;
+ default : Illegal(1, cc_data_1);
+ }
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//NUL
+void File_Eia708::NUL()
+{
+}
+
+//---------------------------------------------------------------------------
+//End Of Text
+void File_Eia708::ETX()
+{
+}
+
+//---------------------------------------------------------------------------
+//Backspace
+void File_Eia708::BS()
+{
+ Param_Info1("Backspace");
+
+ int8u WindowID=Streams[service_number]->WindowID;
+ if (WindowID==(int8u)-1)
+ return; //Must wait for the corresponding CWx
+ window* Window=Streams[service_number]->Windows[WindowID];
+ if (Window==NULL)
+ return; //Must wait for the corresponding DFx
+
+ if (Window->Minimal.x)
+ {
+ //Clearing window
+ Window->Minimal.x--;
+ Window->Minimal.CC[Window->Minimal.y][Window->Minimal.x]=character();
+
+ if (Window->visible)
+ {
+ //Clearing global area
+ if (Window->Minimal.Window_y+Window->Minimal.y<(int8u)Streams[service_number]->Minimal.CC.size() && Window->Minimal.Window_x+Window->Minimal.x<(int8u)Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Window->Minimal.y].size())
+ Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Window->Minimal.y][Window->Minimal.Window_x+Window->Minimal.x]=character();
+
+ //Has changed
+ Window_HasChanged();
+ HasChanged();
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+//Form Feed
+void File_Eia708::FF()
+{
+ Param_Info1("Form Feed");
+
+ int8u WindowID=Streams[service_number]->WindowID;
+ if (WindowID==(int8u)-1)
+ return; //Must wait for the corresponding CWx
+ window* Window=Streams[service_number]->Windows[WindowID];
+ if (Window==NULL)
+ return; //Must wait for the corresponding DFx
+
+ for (size_t Pos_Y=0; Pos_Y<Window->row_count; Pos_Y++)
+ for (size_t Pos_X=0; Pos_X<Window->column_count; Pos_X++)
+ {
+ //Clearing window
+ Streams[service_number]->Windows[Streams[service_number]->WindowID]->Minimal.CC[Pos_Y][Pos_X]=character();
+
+ if (Window->visible)
+ {
+ //Clearing global area
+ if (Window->Minimal.Window_y+Pos_Y<Streams[service_number]->Minimal.CC.size() && Window->Minimal.Window_x+Pos_X<Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y].size())
+ Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y][Window->Minimal.Window_x+Pos_X]=character();
+ }
+ }
+
+ if (Window->visible)
+ {
+ //Has changed
+ Window_HasChanged();
+ HasChanged();
+ }
+
+ //SetPenLocation
+ Window->Minimal.x=0;
+ Window->Minimal.y=0;
+}
+
+//---------------------------------------------------------------------------
+//Carriage return
+void File_Eia708::CR()
+{
+ Param_Info1("Carriage return");
+
+ int8u WindowID=Streams[service_number]->WindowID;
+ if (WindowID==(int8u)-1)
+ return; //Must wait for the corresponding CWx
+ window* Window=Streams[service_number]->Windows[WindowID];
+ if (Window==NULL)
+ return; //Must wait for the corresponding DFx
+ int8u y=Window->Minimal.y;
+
+ y++;
+ if (y>=Window->row_count)
+ {
+ //Rolling up window
+ for (int8u Pos_Y=0; Pos_Y<Window->row_count-1; Pos_Y++)
+ Window->Minimal.CC[Pos_Y]=Window->Minimal.CC[Pos_Y+1];
+
+ //SetPenLocation
+ y=Window->row_count-1;
+
+ //Clearing last line of window
+ for (int8u Pos_X=0; Pos_X<Window->column_count; Pos_X++)
+ Window->Minimal.CC[y][Pos_X]=character();
+
+ if (Window->visible)
+ {
+ //Updating global area
+ for (int8u Pos_Y=0; Pos_Y<Window->row_count; Pos_Y++)
+ for (int8u Pos_X=0; Pos_X<Window->column_count; Pos_X++)
+ if (Window->Minimal.Window_y+Pos_Y<(int8u)Streams[service_number]->Minimal.CC.size() && Window->Minimal.Window_x+Pos_X<(int8u)Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y].size())
+ Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y][Window->Minimal.Window_x+Pos_X]=Window->Minimal.CC[Pos_Y][Pos_X];
+
+ //Has changed
+ Window_HasChanged();
+ HasChanged();
+ }
+ }
+
+ //SetPenLocation
+ Window->Minimal.x=0;
+ Window->Minimal.y=y;
+}
+
+//---------------------------------------------------------------------------
+//Horizontal Carriage Return
+void File_Eia708::HCR()
+{
+ Param_Info1("Horizontal Carriage Return");
+
+ int8u WindowID=Streams[service_number]->WindowID;
+ if (WindowID==(int8u)-1)
+ return; //Must wait for the corresponding CWx
+ window* Window=Streams[service_number]->Windows[WindowID];
+ if (Window==NULL)
+ return; //Must wait for the corresponding DFx
+ int8u y=Window->Minimal.y;
+
+ for (int8u Pos_X=0; Pos_X<Window->column_count; Pos_X++)
+ {
+ //Clearing window
+ Streams[service_number]->Windows[Streams[service_number]->WindowID]->Minimal.CC[y][Pos_X]=character();
+
+ if (Window->visible)
+ {
+ //Clearing global area
+ if (Window->Minimal.Window_y+y<(int8u)Streams[service_number]->Minimal.CC.size() && Window->Minimal.Window_x+y<(int8u)Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Window->Minimal.y].size())
+ Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+y][Window->Minimal.Window_x+Pos_X]=character();
+
+ //Has changed
+ Window_HasChanged();
+ HasChanged();
+ }
+ }
+
+ //SetPenLocation
+ Window->Minimal.x=0;
+}
+
+//---------------------------------------------------------------------------
+//SetCurrentWindow
+void File_Eia708::CWx(int8u WindowID)
+{
+ Param_Info1("SetCurrentWindow"); Param_Info1(WindowID);
+
+ Streams[service_number]->WindowID=WindowID;
+}
+
+//---------------------------------------------------------------------------
+//ClearWindows
+void File_Eia708::CLW()
+{
+ Param_Info1("ClearWindows");
+
+ int8u Save_WindowID=Streams[service_number]->WindowID;
+ bool Save_StandAloneCommand=StandAloneCommand;
+ StandAloneCommand=false;
+
+ Element_Begin1("ClearWindows");
+ BS_Begin();
+ int8u WindowID=8;
+ bool HasChanged_=false;
+ do
+ {
+ WindowID--;
+ bool IsSet;
+ Get_SB ( IsSet, Ztring(_T("window ")+Ztring::ToZtring(WindowID)).To_Local().c_str());
+
+ if (IsSet)
+ {
+ Streams[service_number]->WindowID=WindowID;
+ window* Window=Streams[service_number]->Windows[WindowID];
+
+ //ClearWindow is like Form Feed
+ FF();
+
+ if (Window && Window->visible)
+ {
+ //Has changed
+ HasChanged_=true;
+ Window_HasChanged();
+ }
+ }
+ }
+ while (WindowID>0);
+ BS_End();
+ Element_End0();
+
+ Streams[service_number]->WindowID=Save_WindowID;
+ StandAloneCommand=Save_StandAloneCommand;
+
+ if (HasChanged_)
+ {
+ //Has changed
+ HasChanged();
+ }
+}
+
+//---------------------------------------------------------------------------
+//DisplayWindows
+void File_Eia708::DSW()
+{
+ Param_Info1("DisplayWindows");
+
+ int8u Save_WindowID=Streams[service_number]->WindowID;
+ bool Save_StandAloneCommand=StandAloneCommand;
+ StandAloneCommand=false;
+
+ Element_Begin1("DisplayWindows");
+ BS_Begin();
+ int8u WindowID=8;
+ bool HasChanged_=false;
+ do
+ {
+ WindowID--;
+ bool IsSet;
+ Get_SB ( IsSet, Ztring(_T("window ")+Ztring::ToZtring(WindowID)).To_Local().c_str());
+
+ if (IsSet)
+ {
+ window* Window=Streams[service_number]->Windows[WindowID];
+
+ if (Window && !Window->visible)
+ {
+ Window->visible=true;
+
+ //Filling global area
+ for (size_t Pos_Y=0; Pos_Y<Window->row_count; Pos_Y++)
+ for (size_t Pos_X=0; Pos_X<Window->column_count; Pos_X++)
+ {
+ if (Window->Minimal.Window_y+Pos_Y<Streams[service_number]->Minimal.CC.size() && Window->Minimal.Window_x+Pos_X<Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y].size())
+ Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y][Window->Minimal.Window_x+Pos_X]=Window->Minimal.CC[Pos_Y][Pos_X];
+ }
+
+ //Has changed
+ HasChanged_=true;
+ Window_HasChanged();
+ }
+ }
+ }
+ while (WindowID>0);
+ BS_End();
+ Element_End0();
+
+ Streams[service_number]->WindowID=Save_WindowID;
+ StandAloneCommand=Save_StandAloneCommand;
+
+ if (HasChanged_)
+ {
+ //Has changed
+ HasChanged();
+ }
+}
+
+//---------------------------------------------------------------------------
+//HideWindows
+void File_Eia708::HDW()
+{
+ Param_Info1("HideWindows");
+
+ int8u Save_WindowID=Streams[service_number]->WindowID;
+ bool Save_StandAloneCommand=StandAloneCommand;
+ StandAloneCommand=false;
+
+ Element_Begin1("HideWindows");
+ BS_Begin();
+ int8u WindowID=8;
+ bool HasChanged_=false;
+ do
+ {
+ WindowID--;
+
+ bool IsSet;
+ Get_SB ( IsSet, Ztring(_T("window ")+Ztring::ToZtring(WindowID)).To_Local().c_str());
+
+ if (IsSet)
+ {
+ window* Window=Streams[service_number]->Windows[WindowID];
+
+ if (Window && Window->visible)
+ {
+ Window->visible=false;
+
+ for (size_t Pos_Y=0; Pos_Y<Window->row_count; Pos_Y++)
+ for (size_t Pos_X=0; Pos_X<Window->column_count; Pos_X++)
+ {
+ //Clearing window
+ Window->Minimal.CC[Pos_Y][Pos_X]=character();
+
+ //Filling global area
+ if (Window->Minimal.Window_y+Pos_Y<Streams[service_number]->Minimal.CC.size() && Window->Minimal.Window_x+Pos_X<Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y].size())
+ Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y][Window->Minimal.Window_x+Pos_X]=character();
+ }
+
+ //Has changed
+ HasChanged_=true;
+ Window_HasChanged();
+ }
+ }
+ }
+ while (WindowID>0);
+ BS_End();
+ Element_End0();
+
+ Streams[service_number]->WindowID=Save_WindowID;
+ StandAloneCommand=Save_StandAloneCommand;
+
+ if (HasChanged_)
+ {
+ //Has changed
+ HasChanged();
+ }
+}
+
+//---------------------------------------------------------------------------
+//ToggleWindows
+void File_Eia708::TGW()
+{
+ Param_Info1("ToggleWindows");
+
+ int8u Save_WindowID=Streams[service_number]->WindowID;
+ bool Save_StandAloneCommand=StandAloneCommand;
+ StandAloneCommand=false;
+
+ Element_Begin1("ToggleWindows");
+ BS_Begin();
+ int8u WindowID=8;
+ bool HasChanged_=false;
+ do
+ {
+ WindowID--;
+ bool IsSet;
+ Get_SB ( IsSet, Ztring(_T("window ")+Ztring::ToZtring(WindowID)).To_Local().c_str());
+
+ if (IsSet)
+ {
+ window* Window=Streams[service_number]->Windows[WindowID];
+
+ if (Window)
+ {
+ Window->visible=!Window->visible;
+
+ //Filling global area
+ for (size_t Pos_Y=0; Pos_Y<Window->row_count; Pos_Y++)
+ for (size_t Pos_X=0; Pos_X<Window->column_count; Pos_X++)
+ {
+ if (Window->Minimal.Window_y+Pos_Y<Streams[service_number]->Minimal.CC.size() && Window->Minimal.Window_x+Pos_X<Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y].size())
+ Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y][Window->Minimal.Window_x+Pos_X]=Window->visible?Window->Minimal.CC[Pos_Y][Pos_X]:character();
+ }
+
+ //Has changed
+ HasChanged_=true;
+ Window_HasChanged();
+ }
+ }
+ }
+ while (WindowID>0);
+ BS_End();
+ Element_End0();
+
+ Streams[service_number]->WindowID=Save_WindowID;
+ StandAloneCommand=Save_StandAloneCommand;
+
+ if (HasChanged_)
+ {
+ //Has changed
+ HasChanged();
+ }
+}
+
+//---------------------------------------------------------------------------
+//DeleteWindows
+void File_Eia708::DLW()
+{
+ Param_Info1("DeleteWindows");
+
+ int8u Save_WindowID=Streams[service_number]->WindowID;
+ bool Save_StandAloneCommand=StandAloneCommand;
+ StandAloneCommand=false;
+
+ //Bug in some files
+ bool Bug_WindowOffset=false;
+
+ Element_Begin1("DeleteWindows");
+ BS_Begin();
+ int8u WindowID=8;
+ bool HasChanged_=false;
+ do
+ {
+ WindowID--;
+ bool IsSet;
+ Get_SB ( IsSet, Ztring(_T("window ")+Ztring::ToZtring(WindowID)).To_Local().c_str());
+
+ //Bug in some files
+ if (IsSet && WindowID==1 && Streams[service_number]->Windows[0]!=NULL && Streams[service_number]->Windows[1]==NULL) //Mix between Windows 0 and 1
+ Bug_WindowOffset=true;
+ if (!IsSet && WindowID==0 && Bug_WindowOffset)
+ IsSet=true;
+
+ if (IsSet)
+ {
+ window* Window=Streams[service_number]->Windows[WindowID];
+
+ if (Window && Window->visible)
+ {
+ //Filling global area
+ for (size_t Pos_Y=0; Pos_Y<Window->row_count; Pos_Y++)
+ for (size_t Pos_X=0; Pos_X<Window->column_count; Pos_X++)
+ {
+ //Clearing window
+ Window->Minimal.CC[Pos_Y][Pos_X]=character();
+
+ //Filling global area
+ if (Window->Minimal.Window_y+Pos_Y<Streams[service_number]->Minimal.CC.size() && Window->Minimal.Window_x+Pos_X<Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y].size())
+ Streams[service_number]->Minimal.CC[Window->Minimal.Window_y+Pos_Y][Window->Minimal.Window_x+Pos_X]=character();
+ }
+
+ //Has changed
+ HasChanged_=true;
+ Window_HasChanged();
+ }
+
+ //Removing the window
+ delete Streams[service_number]->Windows[WindowID]; Streams[service_number]->Windows[WindowID]=NULL;
+ if (WindowID==Save_WindowID)
+ Save_WindowID=(int8u)-1;
+ }
+ }
+ while (WindowID>0);
+ BS_End();
+ Element_End0();
+
+ Streams[service_number]->WindowID=Save_WindowID;
+ StandAloneCommand=Save_StandAloneCommand;
+
+ if (HasChanged_)
+ {
+ //Has changed
+ HasChanged();
+ }
+}
+
+//---------------------------------------------------------------------------
+//Delay
+void File_Eia708::DLY()
+{
+ Param_Info1("Delay");
+ Element_Begin1("Delay");
+ Skip_B1( "tenths of seconds");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+//Delay Cancel
+void File_Eia708::DLC()
+{
+ Param_Info1("Delay Cancel");
+}
+
+//---------------------------------------------------------------------------
+//Reset
+void File_Eia708::RST()
+{
+ //TODO: Should clear all buffers
+ Param_Info1("Reset");
+}
+
+//---------------------------------------------------------------------------
+//Set Pen Attributes
+void File_Eia708::SPA()
+{
+ Param_Info1("Set Pen Attributes");
+ Element_Begin1("Set Pen Attributes");
+ BS_Begin();
+ Skip_S1(4, "text tag");
+ Skip_S1(2, "offset");
+ Skip_S1(2, "pen size");
+ Skip_SB( "italics");
+ Skip_SB( "underline");
+ Skip_S1(3, "edge type");
+ Skip_S1(3, "font style");
+ BS_End();
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+//Set Pen Color
+void File_Eia708::SPC()
+{
+ Param_Info1("Set Pen Color");
+ Element_Begin1("Set Pen Color");
+ BS_Begin();
+ Skip_S1(2, "foreground opacity");
+ Skip_S1(2, "foreground red");
+ Skip_S1(2, "foreground green");
+ Skip_S1(2, "foreground blue");
+ Skip_S1(2, "background opacity");
+ Skip_S1(2, "background red");
+ Skip_S1(2, "background green");
+ Skip_S1(2, "background blue");
+ Mark_0();
+ Mark_0();
+ Skip_S1(2, "edge red");
+ Skip_S1(2, "edge green");
+ Skip_S1(2, "edge blue");
+ BS_End();
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+//SetPenLocation
+void File_Eia708::SPL()
+{
+ Param_Info1("SetPenLocation");
+ Element_Begin1("SetPenLocation");
+ int8u row, column;
+ BS_Begin();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Get_S1 (4, row, "row");
+ Mark_0();
+ Mark_0();
+ Get_S1 (6, column, "column");
+ BS_End();
+ Element_End0();
+
+ int8u WindowID=Streams[service_number]->WindowID;
+ if (WindowID==(int8u)-1)
+ return; //Must wait for the corresponding CWx
+ window* Window=Streams[service_number]->Windows[WindowID];
+ if (Window==NULL)
+ return; //Must wait for the corresponding DFx
+
+ if (row<Window->Minimal.CC.size() && column<Window->Minimal.CC[Window->Minimal.y].size())
+ {
+ Window->Minimal.x=column;
+ Window->Minimal.y=row;
+ }
+ else
+ {
+ // There is a problem, resetting pen location
+ Window->Minimal.x=0;
+ Window->Minimal.y=0;
+ }
+}
+
+//---------------------------------------------------------------------------
+//SetWindowAttributes
+void File_Eia708::SWA()
+{
+ Param_Info1("SetWindowAttributes");
+ Element_Begin1("SetWindowAttributes");
+ BS_Begin();
+ Skip_S1(2, "fill opacity");
+ Skip_S1(2, "fill red");
+ Skip_S1(2, "fill green");
+ Skip_S1(2, "fill blue");
+ Skip_S1(2, "border type (low)");
+ Skip_S1(2, "border red");
+ Skip_S1(2, "border green");
+ Skip_S1(2, "border blue");
+ Skip_SB( "border type (high)");
+ Skip_SB( "wordwrap");
+ Skip_S1(2, "print direction");
+ Skip_S1(2, "scroll direction");
+ Skip_S1(2, "justify");
+ Skip_S1(4, "effect speed");
+ Skip_S1(2, "effect direction");
+ Skip_S1(2, "display effect");
+ Mark_0();
+ Mark_0();
+ Skip_S1(2, "edge red");
+ Skip_S1(2, "edge green");
+ Skip_S1(2, "edge blue");
+ BS_End();
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+//DefineWindow
+void File_Eia708::DFx(int8u WindowID)
+{
+ Param_Info1("DefineWindow"); Param_Info1(WindowID);
+ Element_Begin1("DefineWindow");
+ int8u anchor_vertical, anchor_horizontal, anchor_point, row_count, column_count;
+ bool visible, relative_positioning;
+ BS_Begin();
+ Mark_0();
+ Mark_0();
+ Get_SB ( visible, "visible");
+ Skip_SB( "row lock");
+ Skip_SB( "column lock");
+ Skip_S1(3, "priority");
+ Get_SB ( relative_positioning, "relative positioning");
+ Get_S1 (7, anchor_vertical, "anchor vertical"); //Top left
+ Get_S1 (8, anchor_horizontal, "anchor horizontal"); //Top left
+ Get_S1 (4, anchor_point, "anchor point");
+ Get_S1 (4, row_count, "row count"); //Maximum=14
+ Mark_0();
+ Mark_0();
+ Get_S1 (6, column_count, "column count"); //Maximum=31
+ Mark_0();
+ Mark_0();
+ Skip_S1(4, "window style");
+ Skip_S1(2, "pen style ID");
+ BS_End();
+ Element_End0();
+
+ Streams[service_number]->WindowID=WindowID;
+ if (Streams[service_number]->Windows[WindowID]==NULL)
+ Streams[service_number]->Windows[WindowID]=new window;
+ window* Window=Streams[service_number]->Windows[WindowID];
+ Window->visible=visible;
+ Window->relative_positioning=relative_positioning;
+ Window->anchor_vertical=anchor_vertical;
+ if (relative_positioning)
+ Window->Minimal.Window_y=(int8u)(((float)15)*anchor_vertical/100);
+ else
+ Window->Minimal.Window_y=anchor_vertical/5;
+ Window->anchor_horizontal=anchor_horizontal;
+ int8u offset_y;
+ switch (anchor_point)
+ {
+ case 0 :
+ case 1 :
+ case 2 :
+ offset_y=0;
+ break;
+ case 3 :
+ case 4 :
+ case 5 :
+ offset_y=(row_count+1)/2;
+ break;
+ case 6 :
+ case 7 :
+ case 8 :
+ offset_y=(row_count+1);
+ break;
+ default: offset_y=0; //Not valid
+ }
+ if (offset_y<Window->Minimal.Window_y)
+ Window->Minimal.Window_y-=offset_y;
+ if (relative_positioning)
+ Window->Minimal.Window_x=(int8u)(24*AspectRatio*anchor_horizontal/100);
+ else
+ Window->Minimal.Window_x=anchor_horizontal/5;
+ int8u offset_x;
+ switch (anchor_point)
+ {
+ case 0 :
+ case 3 :
+ case 6 :
+ offset_x=0;
+ break;
+ case 1 :
+ case 4 :
+ case 7 :
+ offset_x=(column_count+1)/2;
+ break;
+ case 2 :
+ case 5 :
+ case 8 :
+ offset_x=(column_count+1);
+ break;
+ default: offset_x=0; //Not valid
+ }
+ if (offset_x<Window->Minimal.Window_x)
+ Window->Minimal.Window_x-=offset_x;
+ Window->row_count=row_count+1;
+ Window->column_count=column_count+1;
+ Window->Minimal.x=0;
+ Window->Minimal.y=0;
+
+ if (Window->row_count>12)
+ {
+ Window->row_count=12; //Limitation of specifications
+ }
+ if (AspectRatio && Window->column_count>(int8u)(24*AspectRatio))
+ {
+ Window->column_count=(int8u)(24*AspectRatio); //Limitation of specifications
+ }
+ Window->Minimal.CC.resize(Window->row_count);
+ for (int8u Pos_Y=0; Pos_Y<Window->row_count; Pos_Y++)
+ Window->Minimal.CC[Pos_Y].resize(Window->column_count);
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Eia708::Character_Fill(wchar_t Character)
+{
+ Param_Info1(Ztring(1, Character));
+
+ int8u WindowID=Streams[service_number]->WindowID;
+ if (WindowID==(int8u)-1)
+ return; //Must wait for the corresponding CWx
+ window* Window=Streams[service_number]->Windows[WindowID];
+ if (Window==NULL)
+ return; //Must wait for the corresponding DFx
+
+ int8u x=Window->Minimal.x;
+ int8u y=Window->Minimal.y;
+ int8u Window_x=Window->Minimal.Window_x;
+ int8u Window_y=Window->Minimal.Window_y;
+
+ if (x<Window->column_count && y<Window->row_count)
+ {
+ //Filling window
+ Window->Minimal.CC[y][x].Value=Character;
+
+ if (Window->visible)
+ {
+ //Filling global area
+ if (Window_y+y<(int8u)Streams[service_number]->Minimal.CC.size() && Window_x+x<(int8u)Streams[service_number]->Minimal.CC[Window_y+y].size())
+ Streams[service_number]->Minimal.CC[Window_y+y][Window_x+x].Value=Character;
+
+ //Has changed
+ Window_HasChanged();
+ HasChanged();
+ }
+
+ x++;
+ Window->Minimal.x=x;
+ }
+
+ if (!HasContent)
+ HasContent=true;
+}
+
+//---------------------------------------------------------------------------
+void File_Eia708::Window_HasChanged()
+{
+}
+
+//---------------------------------------------------------------------------
+void File_Eia708::HasChanged()
+{
+}
+
+//---------------------------------------------------------------------------
+void File_Eia708::Illegal(int8u Size, int8u cc_data_1, int8u cc_data_2, int8u cc_data_3, int8u cc_data_4, int8u cc_data_5, int8u cc_data_6)
+{
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_EIA708_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia708.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia708.h
new file mode 100644
index 000000000..d225f0b30
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Eia708.h
@@ -0,0 +1,187 @@
+// File_Eia708 - Info for EIA-708 files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about PGS files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_Eia708H
+#define MediaInfo_File_Eia708H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+#include <string>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Eia708
+//***************************************************************************
+
+class File_Eia708 : public File__Analyze
+{
+public :
+ //In
+ int8u cc_type;
+ float64 AspectRatio;
+
+ //Constructor/Destructor
+ File_Eia708();
+ ~File_Eia708();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - Global
+ void Read_Buffer_Init();
+ void Read_Buffer_Continue();
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Temp
+ struct character
+ {
+ wchar_t Value;
+ int8u Attribute;
+
+ character()
+ {
+ Value=L' ';
+ }
+ };
+ struct window
+ {
+ enum scroll_direction
+ {
+ Scroll_Direction_Unknown,
+ Scroll_Direction_LeftToRight,
+ Scroll_Direction_RightToLeft,
+ Scroll_Direction_TopToBottom,
+ };
+ bool visible;
+ scroll_direction Scroll_Direction;
+ int8u row_count;
+ int8u column_count;
+ bool relative_positioning;
+ int8u anchor_vertical;
+ int8u anchor_horizontal;
+ struct data
+ {
+ vector<vector<character> > CC;
+ int8u Window_x; //x of the Windows, relative to the global area
+ int8u Window_y;
+ int8u x;
+ int8u y;
+
+ data()
+ {
+ Window_x=0;
+ Window_y=0;
+ x=0;
+ y=0;
+ }
+ };
+ data Minimal; //In characters
+ int8u PenSize;
+
+ window()
+ {
+ visible=false;
+ Scroll_Direction=Scroll_Direction_Unknown;
+ row_count=(int8u)-1;
+ column_count=(int8u)-1;
+ relative_positioning=false;
+ anchor_vertical=(int8u)-1;
+ anchor_horizontal=(int8u)-1;
+ PenSize=1; //Standard
+ }
+ };
+ struct stream
+ {
+ std::vector<window*> Windows;
+ struct data
+ {
+ vector<vector<character> > CC;
+ };
+ data Minimal;
+ int8u WindowID;
+
+ stream()
+ {
+ WindowID=(int8u)-1;
+ }
+
+ ~stream()
+ {
+ for (size_t Pos=0; Pos<Windows.size(); Pos++)
+ delete Windows[Pos]; //Windows[Pos]=NULL;
+ }
+ };
+ std::vector<stream*> Streams;
+ int8u service_number;
+ int8u block_size;
+ bool HasContent;
+
+ //Elements
+ void NUL(); //NUL
+ void ETX(); //End Of Text
+ void BS(); //Backspace
+ void FF(); //Form Feed
+ void CR(); //Carriage Return
+ void HCR(); //Horizontal Carriage Return
+ void CWx(int8u WindowID); //SetCurrentWindow
+ void CLW(); //ClearWindows
+ void DSW(); //DisplayWindows
+ void HDW(); //HideWindows
+ void TGW(); //ToggleWindows
+ void DLW(); //DeleteWindows
+ void DLY(); //Delay
+ void DLC(); //Delay Cancel
+ void RST(); //Reset
+ void SPA(); //SetPenAttributes
+ void SPC(); //SetPenColor
+ void SPL(); //SetPenLocation
+ void SWA(); //SetWindowAttributes
+ void DFx(int8u WindowID); //DefineWindow
+
+ //Temp
+ bool StandAloneCommand; //If this is a command simulated from another command
+
+ //Helpers
+ void Service();
+ void Character_Fill(wchar_t Character);
+ void HasChanged();
+ void Window_HasChanged();
+ void Illegal(int8u Size, int8u cc_data_1, int8u cc_data_2=(int8u)-1, int8u cc_data_3=(int8u)-1, int8u cc_data_4=(int8u)-1, int8u cc_data_5=(int8u)-1, int8u cc_data_6=(int8u)-1);
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Kate.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Kate.cpp
new file mode 100644
index 000000000..a805f5b1b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Kate.cpp
@@ -0,0 +1,158 @@
+// File_Kate - Info for Kate files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Note : the buffer must be given in ONE call
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_KATE_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_Kate.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Ztring Kate_Category(const Ztring &Category)
+{
+ //http://wiki.xiph.org/index.php/OggText#Categories_of_Text_Codecs
+ if (Category==_T("CC"))
+ return _T("Closed caption");
+ if (Category==_T("SUB"))
+ return _T("Subtitles");
+ if (Category==_T("TAD"))
+ return _T("Textual audio descriptions");
+ if (Category==_T("KTV"))
+ return _T("Karaoke");
+ if (Category==_T("TIK"))
+ return _T("Ticker text");
+ if (Category==_T("AR"))
+ return _T("Active regions");
+ if (Category==_T("NB"))
+ return _T("Semantic annotations");
+ if (Category==_T("META"))
+ return _T("Metadata, mostly machine-readable");
+ if (Category==_T("TRX"))
+ return _T("Transcript");
+ if (Category==_T("LRC"))
+ return _T("Lyrics");
+ if (Category==_T("LIN"))
+ return _T("Linguistic markup");
+ if (Category==_T("CUE"))
+ return _T("Cue points");
+
+ //From Kate
+ if (Category==_T("K-SLD-I"))
+ return _T("Slides, as images");
+ if (Category==_T("K-SLD-T"))
+ return _T("Slides, as text");
+ return Category;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Kate::Data_Parse()
+{
+ //Parsing
+ Identification();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Kate::Identification()
+{
+ Element_Name("Identification");
+
+ //Parsing
+ Ztring Language, Category;
+ int16u Width, Height;
+ int8u VersionMajor, VersionMinor, NumHeaders, TextEncoding;
+ Skip_B1 ( "Signature");
+ Skip_Local(7, "Signature");
+ Skip_L1( "Reserved");
+ Get_L1 (VersionMajor, "version major");
+ Get_L1 (VersionMinor, "version minor");
+ Get_L1 (NumHeaders, "num headers");
+ Get_L1 (TextEncoding, "text encoding");
+ Skip_L1( "directionality");
+ Skip_L1( "Reserved");
+ Skip_L1( "granule shift");
+ Skip_L4( "Reserved");
+ Get_L2 (Width, "cw sh + canvas width");
+ Get_L2 (Height, "ch sh + canvas height");
+ /*
+ BS_Begin();
+ Skip_BS( 4, "cw sh");
+ Get_BS (12, Width, "canvas width");
+ Skip_BS( 4, "ch sh");
+ Get_BS (12, Height, "canvas height");
+ BS_End();
+ */
+ Skip_L4( "granule rate numerator");
+ Skip_L4( "granule rate denominator");
+ Get_UTF8(16, Language, "Language");
+ Get_UTF8(16, Category, "Category");
+
+ FILLING_BEGIN();
+ Accept("Kate");
+
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Format, "Kate");
+ Fill(Stream_Text, 0, Text_Codec, "Kate");
+ Fill(Stream_Text, 0, Text_Language, Language);
+ Fill(Stream_Text, 0, Text_Language_More, Kate_Category(Category));
+
+ Finish("Kate");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_KATE_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Kate.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Kate.h
new file mode 100644
index 000000000..cab65469c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Kate.h
@@ -0,0 +1,56 @@
+// File_Kate - Info for Kate files
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Kate files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_KateH
+#define MediaInfo_File_KateH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Kate
+//***************************************************************************
+
+class File_Kate : public File__Analyze
+{
+private :
+ //Buffer - Per element
+ void Data_Parse();
+
+ //Elements
+ void Identification();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_N19.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_N19.cpp
new file mode 100644
index 000000000..d375dd24e
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_N19.cpp
@@ -0,0 +1,383 @@
+// File_N19 - Info for N19 files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_N19_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_N19.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* N19_CodePageNumber(int32u CPN)
+{
+ switch (CPN)
+ {
+ case 0x343337 : return "United States";
+ case 0x383530 : return "Multilingual";
+ case 0x383630 : return "Portugal";
+ case 0x383633 : return "Canada-French";
+ case 0x383635 : return "Nordic";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+float32 N19_DiskFormatCode_FrameRate(int64u DFC)
+{
+ switch (DFC)
+ {
+ case 0x53544C32352E3031LL : return 25.000;
+ case 0x53544C33302E3031LL : return 30.000;
+ default : return 0.000;
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* N19_DisplayStandardCode(int8u DSC)
+{
+ switch (DSC)
+ {
+ case 0x30 : return "Open subtitling";
+ case 0x31 : return "Level-1 teletext";
+ case 0x32 : return "Level-2 teletext";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* N19_LanguageCode(int16u LC)
+{
+ switch (LC)
+ {
+ case 0x3030 : return "";
+ case 0x3031 : return "sq";
+ case 0x3032 : return "br";
+ case 0x3033 : return "ca";
+ case 0x3034 : return "hr";
+ case 0x3035 : return "cy";
+ case 0x3036 : return "cs";
+ case 0x3037 : return "da";
+ case 0x3038 : return "de";
+ case 0x3039 : return "en";
+ case 0x3041 : return "es";
+ case 0x3042 : return "eo";
+ case 0x3043 : return "et";
+ case 0x3044 : return "eu";
+ case 0x3045 : return "fo";
+ case 0x3046 : return "fr";
+ case 0x3130 : return "fy";
+ case 0x3131 : return "ga";
+ case 0x3132 : return "gd";
+ case 0x3133 : return "gl";
+ case 0x3134 : return "is";
+ case 0x3135 : return "it";
+ case 0x3136 : return "Lappish";
+ case 0x3137 : return "la";
+ case 0x3138 : return "lv";
+ case 0x3139 : return "lb";
+ case 0x3141 : return "lt";
+ case 0x3142 : return "hu";
+ case 0x3143 : return "mt";
+ case 0x3144 : return "nl";
+ case 0x3145 : return "no";
+ case 0x3146 : return "oc";
+ case 0x3230 : return "pl";
+ case 0x3231 : return "pt";
+ case 0x3232 : return "ro";
+ case 0x3233 : return "Romansh";
+ case 0x3234 : return "sr";
+ case 0x3235 : return "sk";
+ case 0x3236 : return "sl";
+ case 0x3237 : return "fi";
+ case 0x3238 : return "sv";
+ case 0x3239 : return "tr";
+ case 0x3241 : return "Flemish";
+ case 0x3242 : return "wa";
+ case 0x3435 : return "zu";
+ case 0x3436 : return "vi";
+ case 0x3437 : return "uz";
+ case 0x3438 : return "ur";
+ case 0x3439 : return "uk";
+ case 0x3441 : return "th";
+ case 0x3442 : return "te";
+ case 0x3443 : return "tt";
+ case 0x3444 : return "ta";
+ case 0x3445 : return "Tadzhik";
+ case 0x3446 : return "sw";
+ case 0x3530 : return "Sranan Tongo";
+ case 0x3531 : return "so";
+ case 0x3532 : return "si";
+ case 0x3533 : return "sn";
+ case 0x3534 : return "sr";
+ case 0x3535 : return "Ruthenian";
+ case 0x3536 : return "ru";
+ case 0x3537 : return "qu";
+ case 0x3538 : return "ps";
+ case 0x3539 : return "Punjabi";
+ case 0x3541 : return "fa";
+ case 0x3542 : return "Papamiento";
+ case 0x3543 : return "or";
+ case 0x3544 : return "ne";
+ case 0x3545 : return "nr";
+ case 0x3546 : return "mr";
+ case 0x3630 : return "mo";
+ case 0x3631 : return "ms";
+ case 0x3632 : return "mg";
+ case 0x3633 : return "mk";
+ case 0x3634 : return "Laotian";
+ case 0x3635 : return "kr";
+ case 0x3636 : return "km";
+ case 0x3637 : return "kk";
+ case 0x3638 : return "kn";
+ case 0x3639 : return "jp";
+ case 0x3641 : return "id";
+ case 0x3642 : return "hi";
+ case 0x3643 : return "he";
+ case 0x3644 : return "ha";
+ case 0x3645 : return "Gurani";
+ case 0x3646 : return "Gujurati";
+ case 0x3730 : return "hr";
+ case 0x3731 : return "ka";
+ case 0x3732 : return "ff";
+ case 0x3733 : return "Dari";
+ case 0x3734 : return "Churash";
+ case 0x3735 : return "zh";
+ case 0x3736 : return "my";
+ case 0x3737 : return "bg";
+ case 0x3738 : return "bn";
+ case 0x3739 : return "be";
+ case 0x3741 : return "bm";
+ case 0x3742 : return "az";
+ case 0x3743 : return "as";
+ case 0x3744 : return "hy";
+ case 0x3745 : return "ar";
+ case 0x3746 : return "am";
+ default : return "";
+ }
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_N19::FileHeader_Begin()
+{
+ //Element_Size
+ if (Buffer_Size<11)
+ return false; //Must wait for more data
+
+ int64u DiskFormatCode=CC8(Buffer+3);
+ if (DiskFormatCode!=0x53544C32352E3031LL
+ && DiskFormatCode!=0x53544C33302E3031LL)
+ {
+ Reject("N19");
+ return false;
+ }
+
+ //Element_Size
+ if (Buffer_Size<1024)
+ return false; //Must wait for more data about GSI
+
+ //All should be OK...
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_N19::FileHeader_Parse()
+{
+ Element_Name("General Subtitle Information");
+
+ //Parsing
+ Ztring OPT, RD, TNS, MNC, MNR, CO, EN;
+ string TCP;
+ int16u LC;
+ int8u TCS;
+ Info_C3 ( CPN, "CPN - Code Page Number"); Param_Info1(N19_CodePageNumber(CPN));
+ Get_C8 ( DFC, "DFC - Disk Format Code"); Param_Info1(N19_DiskFormatCode_FrameRate(DFC));
+ Info_C1 ( DSC, "DSC - Display Standard Code"); Param_Info1(N19_DisplayStandardCode(DSC));
+ Skip_C2 ( "CCT - Character Code Table number");
+ Get_C2 ( LC, "LC - Language Code"); Param_Info1(N19_LanguageCode(LC));
+ Get_Local (32, OPT, "OPT - Original Programme Title");
+ Skip_Local(32, "OET - Original Episode Title");
+ Skip_Local(32, "TPT - Translated Programme");
+ Skip_Local(32, "TET - Translated Episode");
+ Skip_Local(32, "TN - Translator's Name");
+ Skip_Local(32, "TCD - Translator's Contact Details");
+ Skip_Local(16, "SLR - Subtitle List Reference Code");
+ Skip_Local( 6, "CD - Creation Date");
+ Get_Local ( 6, RD, "RD - Revision Date");
+ Skip_C2 ( "RN - Revision number");
+ Skip_C5 ( "TNB - Total Number of Text and Timing Information (TTI) blocks");
+ Get_Local ( 5, TNS, "TNS - Total Number of Subtitles");
+ Skip_C3 ( "TNG - Total Number of Subtitle Groups");
+ Get_Local ( 2, MNC, "MNC - Maximum Number of Displayable Characters in any text row");
+ Get_Local ( 2, MNR, "MNR - Maximum Number of Displayable Rows");
+ Get_C1 ( TCS, "TCS - Time Code: Status");
+ Get_String( 8, TCP, "TCP - Time Code: Start-of-Programme");
+ Skip_Local( 8, "TCF - Time Code: First In-Cue");
+ Skip_C1 ( "TND - Total Number of Disks");
+ Skip_C1 ( "DSN - Disk Sequence Number");
+ Get_Local ( 3, CO, "CO - Country of Origin");
+ Skip_Local(32, "PUB - Publisher");
+ Get_Local (32, EN, "EN - Editor's Name");
+ Skip_Local(32, "ECD - Editor's Contact Details");
+ Skip_XX(75, "Spare Bytes");
+ Skip_XX(576, "UDA - User-Defined Area");
+
+ FILLING_BEGIN();
+ Accept("N19");
+
+ Fill(Stream_General, 0, General_Format, "N19");
+ Fill(Stream_General, 0, General_Title, OPT);
+ RD.insert(0, _T("20"));
+ RD.insert(4, _T("-"));
+ RD.insert(7, _T("-"));
+ Fill(Stream_General, 0, General_Recorded_Date, RD);
+ Fill(Stream_General, 0, General_Country, Ztring(CO).MakeLowerCase());
+ Fill(Stream_General, 0, General_DistributedBy, EN);
+
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Format, "N19");
+ if (N19_DiskFormatCode_FrameRate(DFC))
+ {
+ Fill(Stream_Text, 0, "FrameRate", N19_DiskFormatCode_FrameRate(DFC));
+ if (TCS==0x31 && TCP.size()==8
+ && TCP[0]>='0' && TCP[0]<='9'
+ && TCP[1]>='0' && TCP[1]<='9'
+ && TCP[2]>='0' && TCP[2]<='6'
+ && TCP[3]>='0' && TCP[3]<='9'
+ && TCP[4]>='0' && TCP[4]<='6'
+ && TCP[5]>='0' && TCP[5]<='9'
+ && TCP[6]>='0' && TCP[6]<='2'
+ && TCP[7]>='0' && TCP[7]<='9')
+ {
+ int32u Delay=0;
+ Delay+=(((int32u)TCP[0])-'0')*10*60*60*1000;
+ Delay+=(((int32u)TCP[1])-'0')* 60*60*1000;
+ Delay+=(((int32u)TCP[2])-'0')* 10*60*1000;
+ Delay+=(((int32u)TCP[3])-'0')* 60*1000;
+ Delay+=(((int32u)TCP[4])-'0')* 10*1000;
+ Delay+=(((int32u)TCP[5])-'0')* 1000;
+ int8u Frames=0;
+ Frames+=(((int8u)TCP[6])-'0')*10;
+ Frames+=(((int8u)TCP[7])-'0');
+ Delay+=float32_int32s(Frames*1000/N19_DiskFormatCode_FrameRate(DFC));
+ //Fill(Stream_Text, 0, Text_Delay, Delay); //TODO is 0???
+ /*TCP.insert(':', 2);
+ TCP.insert(':', 5);
+ TCP.insert(':', 8);
+ Fill(Stream_Text, 0, "Delay/String4", TCP);*/
+ }
+ }
+ Fill(Stream_Text, 0, Text_Width, MNC.To_int32u());
+ Fill(Stream_Text, 0, Text_Width_String, Ztring::ToZtring(MNC.To_int32u())+_T(" characters"), true);
+ Fill(Stream_Text, 0, Text_Height, MNR.To_int32u());
+ Fill(Stream_Text, 0, Text_Height_String, Ztring::ToZtring(MNR.To_int32u())+_T(" characters"), true);
+ Fill(Stream_Text, 0, Text_Language, N19_LanguageCode(LC));
+
+ //Init
+ FirstFrame_TCI=(int64u)-1;
+ FILLING_END();
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_N19::Header_Parse()
+{
+ //Filling
+ Header_Fill_Size(128);
+ Header_Fill_Code(0, _T("TTI"));
+}
+
+//---------------------------------------------------------------------------
+void File_N19::Data_Parse()
+{
+ //Parsing
+ int32u TCI, TCO;
+ Skip_B1 ( "SGN - Subtitle Group Number");
+ Skip_B2 ( "SN - Subtitle Number");
+ Skip_B1 ( "EBN - Extension Block Number");
+ Skip_B1 ( "CS - Cumulative Status");
+ Get_B4 (TCI, "TCI - Time Code In");
+ TCI=((TCI>>24)&0xFF)*60*60*1000
+ + ((TCI>>16)&0xFF) *60*1000
+ + ((TCI>>8 )&0xFF) *1000
+ + float32_int32s((TCI &0xFF) *1000/N19_DiskFormatCode_FrameRate(DFC));
+ Param_Info1(Ztring().Duration_From_Milliseconds((int64u)TCI));
+ Get_B4 (TCO, "TCO - Time Code Out");
+ TCO=((TCO>>24)&0xFF)*60*60*1000
+ + ((TCO>>16)&0xFF) *60*1000
+ + ((TCO>>8 )&0xFF) *1000
+ + float32_int32s((TCO &0xFF) *1000/N19_DiskFormatCode_FrameRate(DFC));
+ Param_Info1(Ztring().Duration_From_Milliseconds((int64u)TCO));
+ Skip_B1 ( "VP - Vertical Position");
+ Skip_B1 ( "JC - Justification Code");
+ Skip_B1 ( "CF - Comment Flag");
+ Skip_Local(112, "TF - Text Field");
+
+ FILLING_BEGIN();
+ if (FirstFrame_TCI==(int64u)-1)
+ {
+ FirstFrame_TCI=TCI;
+ Fill(Stream_Text, 0, Text_Delay, TCI);
+ Fill(Stream_Text, 0, Text_Delay_Source, "Container");
+ }
+ if (File_Offset+Buffer_Offset+Element_Size+128>File_Size)
+ {
+ Fill(Stream_Text, 0, Text_Duration, TCO-FirstFrame_TCI);
+ }
+ else
+ //Jumping
+ GoToFromEnd(128, "N19");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_N19_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_N19.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_N19.h
new file mode 100644
index 000000000..d20b8520f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_N19.h
@@ -0,0 +1,59 @@
+// File_N19 - Info for N19 files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about N19 files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_N19H
+#define MediaInfo_File_N19H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_N19
+//***************************************************************************
+
+class File_N19 : public File__Analyze
+{
+private :
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Temp
+ int64u FirstFrame_TCI;
+ int64u DFC;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_OtherText.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_OtherText.cpp
new file mode 100644
index 000000000..48f28ad58
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_OtherText.cpp
@@ -0,0 +1,219 @@
+// File_OtherText - Use magic number to detect only the format (Text)
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_OTHERTEXT_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_OtherText.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Functions
+//***************************************************************************
+
+void File_OtherText::Read_Buffer_Continue()
+{
+ if (Buffer_Size<0x200)
+ return;
+
+ Ztring Format, FormatMore, Codec;
+ Ztring File;
+ ZtringList Lines;
+
+ //Feed File and Lines
+ File.From_Local((char*)Buffer, Buffer_Size); //Ansi
+ if (File.size()<0x100)
+ {
+ File.From_Unicode((wchar_t*)Buffer, 0, Buffer_Size/sizeof(wchar_t)); //Unicode with BOM
+ //TODO: Order of bytes (big or Little endian)
+ if (File.size()<0x100)
+ {
+ Reject("Other text");
+ return;
+ }
+ }
+ if (File.size()>0x1000)
+ File.resize(0x1000); //Do not work on too big
+ if (File.find(_T("\x0D\x0A"))!=Error)
+ {
+ Lines.Separator_Set(0, _T("\x0D\x0A"));
+ Lines.Write(File);
+ }
+ else if (File.find(_T("\x0D"))!=Error)
+ {
+ Lines.Separator_Set(0, _T("\x0D"));
+ Lines.Write(File);
+ }
+ else if (File.find(_T("\x0A"))!=Error)
+ {
+ Lines.Separator_Set(0, _T("\x0A"));
+ Lines.Write(File);
+ }
+ else
+ {
+ Reject("Other text");
+ return;
+ }
+ if (Lines.size()<0x10)
+ {
+ Reject("Other text");
+ return;
+ }
+ Lines.resize(0x20);
+
+ if (Lines[0].size()==1
+ && Lines[0][0]==_T('1')
+ && Lines[1].size()==29
+ && Lines[1][ 0]==_T('0') && Lines[1][ 1]==_T('0')
+ && Lines[1][ 2]==_T(':') && Lines[1][ 5]==_T(':') && Lines[1][ 8]==_T(',')
+ && Lines[1][12]==_T(' ') && Lines[1][13]==_T('-') && Lines[1][14]==_T('-') && Lines[1][15]==_T('>') && Lines[1][16]==_T(' ')
+ && Lines[1][17]==_T('0') && Lines[1][18]==_T('0')
+ && Lines[1][19]==_T(':') && Lines[1][22]==_T(':') && Lines[1][25]==_T(',')
+ && Lines.Find(_T("2"))!=Error
+ )
+ {
+ Format=_T("SubRip");
+ Codec=_T("SubRip");
+ }
+ else if (Lines[0]==_T("[Script Info]")
+ && Lines.Find(_T("ScriptType: v4.00"))!=Error
+ && Lines.Find(_T("[V4 Styles]"))!=Error
+ )
+ {
+ Format=_T("SSA");
+ FormatMore=_T("SubStation Alpha");
+ Codec=_T("SSA");
+ }
+ else if (Lines[0]==_T("[Script Info]")
+ && Lines.Find(_T("ScriptType: v4.00+"))!=Error
+ && Lines.Find(_T("[V4+ Styles]"))!=Error
+ )
+ {
+ Format=_T("ASS");
+ FormatMore=_T("Advanced SubStation Alpha");
+ Codec=_T("ASS");
+ }
+ else if (Lines[0].size()>24
+ && Lines[0][ 0]==_T('0') && Lines[0][ 1]==_T('0')
+ && Lines[0][ 2]==_T(':') && Lines[0][ 5]==_T(':') && Lines[0][ 8]==_T(':')
+ && Lines[0][11]==_T(' ')
+ && Lines[0][12]==_T('0') && Lines[0][13]==_T('0')
+ && Lines[0][14]==_T(':') && Lines[0][17]==_T(':') && Lines[0][20]==_T(':')
+ && Lines[0][23]==_T(' ')
+ )
+ {
+ Format=_T("Adobe encore DVD");
+ Codec=_T("Adobe");
+ }
+ else if (Lines[0].size()==11
+ && Lines[0][0]==_T('-') && Lines[0][1]==_T('-') && Lines[0][2]==_T('>') && Lines[0][3]==_T('>') && Lines[0][4]==_T(' ')
+ && Lines[0][5]==_T('0')
+ && Lines[1].empty()!=true
+ )
+ {
+ Format=_T("AQTitle");
+ Codec=_T("AQTitle");
+ }
+ else if (Lines[0].size()>28
+ && Lines[0][ 0]==_T('0') && Lines[0][ 1]==_T('0')
+ && Lines[0][ 2]==_T(':') && Lines[0][ 5]==_T(':') && Lines[0][ 8]==_T(':')
+ && Lines[0][11]==_T(' ') && Lines[0][12]==_T(',') && Lines[0][13]==_T(' ')
+ && Lines[0][14]==_T('0') && Lines[0][15]==_T('0')
+ && Lines[0][16]==_T(':') && Lines[0][19]==_T(':') && Lines[0][22]==_T(':')
+ && Lines[0][25]==_T(' ') && Lines[0][16]==_T(',') && Lines[0][27]==_T(' ')
+ )
+ {
+ Format=_T("Captions 32");
+ Codec=_T("Caption 32");
+ }
+ else if (Lines[0].size()==23
+ && Lines[0]==_T("*Timecode type: PAL/EBU")
+ && Lines[1].empty()
+ && Lines[2].size()==23
+ && Lines[2][ 0]==_T('0') && Lines[2][ 1]==_T('0')
+ && Lines[2][ 2]==_T(':') && Lines[2][ 5]==_T(':') && Lines[2][ 8]==_T(':')
+ && Lines[2][11]==_T(' ')
+ && Lines[2][12]==_T('0') && Lines[2][13]==_T('0')
+ && Lines[2][14]==_T(':') && Lines[2][17]==_T(':') && Lines[2][20]==_T(':')
+ && Lines[2].size()>0
+ )
+ {
+ Format=_T("Captions Inc");
+ Codec=_T("Captions inc");
+ }
+ else if (Lines[0].size()>1
+ && Lines[0][0]==_T('*')
+ && Lines.Find(_T("** Caption Number 1"))!=Error
+ )
+ {
+ Format=_T("Cheeta");
+ }
+ else if (Lines[0].size()>10
+ && Lines[0][0]==_T('~') && Lines[0][1]==_T('C') && Lines[0][2]==_T('P') && Lines[0][3]==_T('C') && Lines[0][9]==_T('~')
+ && Lines[1][ 0]==_T('0') && Lines[1][ 1]==_T('0')
+ && Lines[1][ 2]==_T(':') && Lines[1][ 5]==_T(':') && Lines[1][ 8]==_T(':')
+ )
+ {
+ Format=_T("CPC Captioning");
+ Codec=_T("CPC Captioning");
+ }
+ else
+ return;
+
+ if (Format.empty())
+ return;
+
+ Accept("Other text");
+
+ if (!IsSub)
+ {
+ Fill(Stream_General, 0, General_Format, Format);
+ Fill(Stream_General, 0, General_Format_Info, FormatMore, true);
+ }
+
+ Stream_Prepare(Stream_Text);
+ Fill(Stream_Text, 0, Text_Format, Format);
+ Fill(Stream_Text, 0, Text_Codec, Codec);
+
+ //No more need data
+ Element_Begin1(Format);
+ Element_End0();
+ Finish("Other text");
+}
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_OtherText.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_OtherText.h
new file mode 100644
index 000000000..eef020c39
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_OtherText.h
@@ -0,0 +1,48 @@
+// File_OtherText - Use magic number to detect only the format (Text)
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Use magic number to detect only the format (Text)
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_OtherTextH
+#define MediaInfo_File_OtherTextH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_OtherText
+//***************************************************************************
+
+class File_OtherText : public File__Analyze
+{
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Pgs.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Pgs.cpp
new file mode 100644
index 000000000..557115ea7
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Pgs.cpp
@@ -0,0 +1,77 @@
+// File_Pgs - Info for PGS files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_PGS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_Pgs.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Pgs::Streams_Fill()
+{
+ Stream_Prepare(Stream_Text); //TODO: This is currenlty only text
+ Fill(Stream_Text, 0, Text_Format, "PGS");
+ Fill(Stream_Text, 0, Text_Codec, "PGS");
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Pgs::Read_Buffer_Continue()
+{
+ Skip_XX(Element_Size, "PGS data");
+
+ if (!Status[IsAccepted])
+ {
+ Accept("PGS");
+ Finish("PGS");
+ }
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_PGS_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Pgs.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Pgs.h
new file mode 100644
index 000000000..ac71436e5
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Pgs.h
@@ -0,0 +1,52 @@
+// File_Pgs - Info for PGS files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about PGS files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_PgsH
+#define MediaInfo_File_PgsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Pgs
+//***************************************************************************
+
+class File_Pgs : public File__Analyze
+{
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - Global
+ void Read_Buffer_Continue();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scc.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scc.cpp
new file mode 100644
index 000000000..3dfcb93e2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scc.cpp
@@ -0,0 +1,217 @@
+// File_Scc - Info for SCC streams
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_SCC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_Scc.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "MediaInfo/Text/File_Eia608.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Scc::File_Scc()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("SCC");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Scc;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(8); //Stream
+ #endif //MEDIAINFO_TRACE
+ PTS_DTS_Needed=true;
+
+ //Temp
+ Parser=NULL;
+}
+
+//---------------------------------------------------------------------------
+File_Scc::~File_Scc()
+{
+ delete Parser; //Parser=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Scc::Streams_Finish()
+{
+ if (Parser && Parser->Status[IsAccepted])
+ {
+ Finish(Parser);
+ for (size_t Pos2=0; Pos2<Parser->Count_Get(Stream_Text); Pos2++)
+ {
+ Stream_Prepare(Stream_Text);
+ Merge(*Parser, Stream_Text, StreamPos_Last, Pos2);
+ Fill(Stream_Text, StreamPos_Last, Text_ID, Parser->Retrieve(Stream_Text, Pos2, Text_ID), true);
+ }
+ }
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Scc::FileHeader_Begin()
+{
+ //Element_Size
+ if (File_Size<22)
+ {
+ Reject("N19");
+ return false;
+ }
+ if (Buffer_Size<22)
+ return false; //Must wait for more data
+
+ if (Buffer[ 0]!=0x53
+ || Buffer[ 1]!=0x63
+ || Buffer[ 2]!=0x65
+ || Buffer[ 3]!=0x6E
+ || Buffer[ 4]!=0x61
+ || Buffer[ 5]!=0x72
+ || Buffer[ 6]!=0x69
+ || Buffer[ 7]!=0x73
+ || Buffer[ 8]!=0x74
+ || Buffer[ 9]!=0x5F
+ || Buffer[10]!=0x53
+ || Buffer[11]!=0x43
+ || Buffer[12]!=0x43
+ || Buffer[13]!=0x20
+ || Buffer[14]!=0x56
+ || Buffer[15]!=0x31
+ || Buffer[16]!=0x2E
+ || Buffer[17]!=0x30
+ )
+ {
+ Reject("N19");
+ return false;
+ }
+
+ //Element_Size
+ if (Buffer_Size<File_Size)
+ return false; //Must wait for more data
+
+ //All should be OK...
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Scc::FileHeader_Parse()
+{
+ Skip_String(18, "Magic");
+ while (Element_Offset<Buffer_Size)
+ {
+ if (Buffer[(size_t)Element_Offset]!=0x0D && Buffer[(size_t)Element_Offset]!=0x0A)
+ break;
+ Element_Offset++;
+ }
+
+ Accept();
+ Fill(Stream_General, 0, General_Format, "SCC");
+
+ //Init
+ Parser=new File_Eia608();
+ Open_Buffer_Init(Parser);
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Scc::Header_Parse()
+{
+ size_t End=Buffer_Offset;
+
+ //Content
+ while (End<Buffer_Size)
+ {
+ if (Buffer[End]==0x0D || Buffer[End]==0x0A)
+ break;
+ End++;
+ }
+
+ //EOL
+ while (End<Buffer_Size)
+ {
+ if (Buffer[End]!=0x0D && Buffer[End]!=0x0A)
+ break;
+ End++;
+ }
+
+ //Filling
+ Header_Fill_Size(End-Buffer_Offset);
+ Header_Fill_Code(0, _T("Block"));
+}
+
+//---------------------------------------------------------------------------
+void File_Scc::Data_Parse()
+{
+ while (Element_Offset<Element_Size && (Buffer[Buffer_Offset+(size_t)Element_Offset]==0x0D || Buffer[Buffer_Offset+(size_t)Element_Offset]==0x0A))
+ Element_Offset++;
+ if (Element_Offset==Element_Size)
+ return;
+
+ //Parsing
+ Skip_String(11, "TimeStamp");
+ while (Element_Offset+5<=Element_Size)
+ {
+ int8u Buffer_Temp[2];
+ Buffer_Temp[0]=(Buffer[Buffer_Offset+(size_t)Element_Offset+1]-(Buffer[Buffer_Offset+(size_t)Element_Offset+1]>='a'?('a'-10):'0'))<<4
+ | (Buffer[Buffer_Offset+(size_t)Element_Offset+2]-(Buffer[Buffer_Offset+(size_t)Element_Offset+2]>='a'?('a'-10):'0'));
+ Buffer_Temp[1]=(Buffer[Buffer_Offset+(size_t)Element_Offset+3]-(Buffer[Buffer_Offset+(size_t)Element_Offset+3]>='a'?('a'-10):'0'))<<4
+ | (Buffer[Buffer_Offset+(size_t)Element_Offset+4]-(Buffer[Buffer_Offset+(size_t)Element_Offset+4]>='a'?('a'-10):'0'));
+ Open_Buffer_Continue(Parser, Buffer_Temp, 2);
+ Element_Offset+=5;
+ }
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_SCC_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scc.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scc.h
new file mode 100644
index 000000000..40d0e8ca3
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scc.h
@@ -0,0 +1,65 @@
+// File_Scc - Info for SCC streams
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about SCC (Scenarist Closed Captioning) files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_SccH
+#define MediaInfo_File_SccH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "ZenLib/ZtringListList.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Scc
+//***************************************************************************
+
+class File_Scc : public File__Analyze
+{
+public :
+ File_Scc();
+ ~File_Scc();
+
+private :
+ //Streams management
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Temp
+ File__Analyze* Parser;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scte20.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scte20.cpp
new file mode 100644
index 000000000..44492a03a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scte20.cpp
@@ -0,0 +1,282 @@
+// File_Scte20 - Info for SCTE 20 streams
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_SCTE20_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_Scte20.h"
+#if defined(MEDIAINFO_EIA608_YES)
+ #include "MediaInfo/Text/File_Eia608.h"
+#endif
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+namespace MediaInfoLib
+{
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Scte20_field_number (int8u field_number)
+{
+ switch (field_number)
+ {
+ case 0 : return "Forbidden";
+ case 1 : return "1st display field";
+ case 2 : return "2nd display field";
+ case 3 : return "3rd display field";
+ default : return "";
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Scte20::File_Scte20()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("SCTE 20");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Scte20;
+ StreamIDs_Width[0]=1;
+ #endif //MEDIAINFO_EVENTS
+ PTS_DTS_Needed=true;
+
+ //In
+ picture_structure=(int8u)-1;
+ progressive_sequence=false;
+ progressive_frame=false;
+ top_field_first=false;
+ repeat_first_field=false;
+
+ //Temp
+ Streams.resize(2); //CEA-608 Field 1, CEA-608 Field 2
+ Streams_Count=0;
+}
+
+//---------------------------------------------------------------------------
+File_Scte20::~File_Scte20()
+{
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ delete Streams[Pos]; //Streams[Pos]=NULL
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Scte20::Streams_Update()
+{
+ Clear(Stream_Text);
+
+ //Per stream
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ if (Streams[Pos] && Streams[Pos]->Parser && Streams[Pos]->Parser->Status[IsFilled] /*&& Streams[Pos]->Parser->Status[IsUpdated]*/ && Streams[Pos]->Parser->Count_Get(Stream_Text))
+ Streams_Update_PerStream(Pos);
+}
+
+//---------------------------------------------------------------------------
+void File_Scte20::Streams_Update_PerStream(size_t Pos)
+{
+ if (Streams[Pos]==NULL)
+ return;
+
+ Update(Streams[Pos]->Parser);
+
+ if (Streams[Pos]->Parser)
+ for (size_t Pos2=0; Pos2<Streams[Pos]->Parser->Count_Get(Stream_Text); Pos2++)
+ {
+ Stream_Prepare(Stream_Text);
+ Merge(*Streams[Pos]->Parser, Stream_Text, Pos2, StreamPos_Last);
+ Fill(Stream_Text, StreamPos_Last, "MuxingMode", "SCTE 20");
+ Fill(Stream_Text, StreamPos_Last, Text_ID, Streams[Pos]->Parser->Retrieve(Stream_Text, Pos2, Text_ID), true);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Scte20::Streams_Finish()
+{
+ Clear(Stream_Text);
+
+ //Per stream
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ if (Streams[Pos] && Streams[Pos]->Parser && Streams[Pos]->Parser->Status[IsAccepted] /*&& Streams[Pos]->Parser->Status[IsUpdated]*/)
+ {
+ Finish(Streams[Pos]->Parser);
+ Streams_Update_PerStream(Pos);
+ }
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Scte20::Read_Buffer_Unsynched()
+{
+ //Parsing
+ for (size_t Pos=0; Pos<Streams.size(); Pos++)
+ if (Streams[Pos] && Streams[Pos]->Parser)
+ Streams[Pos]->Parser->Open_Buffer_Unsynch();
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+static inline int8u ReverseBits(int8u c)
+{
+ // Input: bit order is 76543210
+ //Output: bit order is 01234567
+ c = (c & 0x0F) << 4 | (c & 0xF0) >> 4;
+ c = (c & 0x33) << 2 | (c & 0xCC) >> 2;
+ c = (c & 0x55) << 1 | (c & 0xAA) >> 1;
+ return c;
+}
+
+//---------------------------------------------------------------------------
+void File_Scte20::Read_Buffer_Continue()
+{
+ //Parsing
+ Element_Begin1("SCTE 20");
+ int8u cc_count;
+ bool vbi_data_flag;
+ BS_Begin();
+ Mark_1_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Get_SB (vbi_data_flag, "vbi_data_flag");
+ if (vbi_data_flag)
+ {
+ Get_S1 (5, cc_count, "cc_count");
+ for (int8u Pos=0; Pos<cc_count; Pos++)
+ {
+ Element_Begin1("cc");
+ int8u cc_data[2];
+ int8u field_number, cc_data_1, cc_data_2;
+ Skip_S1(2, "cc_priority");
+ Get_S1 (2, field_number, "field_number"); Param_Info1(Scte20_field_number(field_number));
+ Skip_S1(5, "line_offset");
+ Get_S1 (8, cc_data_1, "cc_data_1");
+ cc_data[0]=ReverseBits(cc_data_1);
+ Param_Info1(Ztring::ToZtring(cc_data[0], 16));
+ Get_S1 (8, cc_data_2, "cc_data_2");
+ cc_data[1]=ReverseBits(cc_data_2);
+ Param_Info1(Ztring::ToZtring(cc_data[1], 16));
+ Mark_1_NoTrustError();
+ if (field_number!=0 && picture_structure!=(int8u)-1 && picture_structure!=0)
+ {
+ Element_Begin1("cc_data");
+
+ //Finding the corresponding cc_type (CEA-608 1st field or 2nd field)
+ int8u cc_type;
+ if (progressive_sequence)
+ cc_type=0;
+ else if (picture_structure!=3)
+ cc_type=picture_structure-1;
+ else if (field_number==2)
+ cc_type=top_field_first?1:0;
+ else //if (field_number==1 || field_number==3)
+ cc_type=top_field_first?0:1;
+
+ //Parsing
+ #if MEDIAINFO_DEMUX
+ Element_Code=cc_type;
+ #endif //MEDIAINFO_DEMUX
+ if (Streams[cc_type]==NULL)
+ Streams[cc_type]=new stream;
+ if (Streams[cc_type]->Parser==NULL)
+ {
+ #if defined(MEDIAINFO_EIA608_YES)
+ Streams[cc_type]->Parser=new File_Eia608();
+ ((File_Eia608*)Streams[cc_type]->Parser)->cc_type=cc_type;
+ #else //defined(MEDIAINFO_EIA608_YES)
+ Streams[cc_type]->Parser=new File__Analyze();
+ #endif //defined(MEDIAINFO_EIA608_YES)
+ Open_Buffer_Init(Streams[cc_type]->Parser);
+ }
+ Demux(cc_data, 2, ContentType_MainStream);
+ if (!Streams[cc_type]->Parser->Status[IsFinished])
+ {
+ //Parsing
+ if (Streams[cc_type]->Parser->PTS_DTS_Needed)
+ {
+ Streams[cc_type]->Parser->FrameInfo.PCR=FrameInfo.PCR;
+ Streams[cc_type]->Parser->FrameInfo.PTS=FrameInfo.PTS;
+ Streams[cc_type]->Parser->FrameInfo.DTS=FrameInfo.DTS;
+ }
+ Open_Buffer_Continue(Streams[cc_type]->Parser, cc_data, 2);
+ Element_Show();
+
+ //Filled
+ if (!Status[IsAccepted])
+ Accept("SCTE 20");
+ }
+ else
+ Skip_XX(2, "Data");
+ Element_End0();
+ }
+ Element_End0();
+ }
+ }
+ Skip_S1(4, "non_real_time_video_count");
+ BS_End();
+
+ if (Element_Size-Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "non_real_time_video + reserved");
+ Element_End0();
+ Element_Show();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_SCTE20_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scte20.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scte20.h
new file mode 100644
index 000000000..6d5867350
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Scte20.h
@@ -0,0 +1,93 @@
+// File_Scte20 - Info for SCTE 20 streams
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about SCTE 20 streams
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Scte20H
+#define MediaInfo_Scte20H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Scte20
+//***************************************************************************
+
+class File_Scte20 : public File__Analyze
+{
+public :
+ //In
+ int8u picture_structure;
+ bool progressive_sequence;
+ bool progressive_frame;
+ bool top_field_first;
+ bool repeat_first_field;
+
+ //Constructor/Destructor
+ File_Scte20();
+ ~File_Scte20();
+
+private :
+ //Streams management
+ void Streams_Update();
+ void Streams_Update_PerStream(size_t Pos);
+ void Streams_Finish();
+
+ //Synchro
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Global
+ void Read_Buffer_Continue();
+
+ //Temp
+ struct stream
+ {
+ File__Analyze* Parser;
+ size_t StreamPos;
+ bool IsFilled;
+
+ stream()
+ {
+ Parser=NULL;
+ StreamPos=(size_t)-1;
+ IsFilled=false;
+ }
+
+ ~stream()
+ {
+ delete Parser; //Parser=NULL;
+ }
+ };
+ std::vector<stream*> Streams;
+ size_t Streams_Count;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Teletext.cpp b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Teletext.cpp
new file mode 100644
index 000000000..7e2fe838f
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Teletext.cpp
@@ -0,0 +1,101 @@
+// File_Teletext - Info for Teletext streams
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DVBSUBTITLE_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Text/File_Teletext.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Teletext::File_Teletext()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("Teletext");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Teletext;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(8); //Stream
+ #endif //MEDIAINFO_TRACE
+ PTS_DTS_Needed=true;
+ IsRawStream=true;
+}
+
+//---------------------------------------------------------------------------
+File_Teletext::~File_Teletext()
+{
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Teletext::Streams_Fill()
+{
+ Stream_Prepare(Stream_Text);
+}
+
+//---------------------------------------------------------------------------
+void File_Teletext::Streams_Finish()
+{
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Teletext::Read_Buffer_Continue()
+{
+ Fill();
+ Finish();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_DVBSUBTITLE_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Text/File_Teletext.h b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Teletext.h
new file mode 100644
index 000000000..f26811036
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Text/File_Teletext.h
@@ -0,0 +1,58 @@
+// File_Teletext - Info for Teletext streams
+// Copyright (C) 2009-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Teletext streams
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_TeletextH
+#define MediaInfo_File_TeletextH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Teletext
+//***************************************************************************
+
+class File_Teletext : public File__Analyze
+{
+public :
+ File_Teletext();
+ ~File_Teletext();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - Global
+ void Read_Buffer_Continue();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/TimeCode.cpp b/src/thirdparty/MediaInfo/MediaInfo/TimeCode.cpp
new file mode 100644
index 000000000..2107c0d84
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/TimeCode.cpp
@@ -0,0 +1,152 @@
+// TimeCode - Time code operations with drop frame support
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/TimeCode.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+TimeCode::TimeCode ()
+{
+ Hours=(int8u)-1;
+ Minutes=(int8u)-1;
+ Seconds=(int8u)-1;
+ Frames=(int8u)-1;
+ FramesPerSecond=0;
+ DropFrame=false;
+ MustUseSecondField=false;
+ IsSecondField=false;
+}
+
+//---------------------------------------------------------------------------
+TimeCode::TimeCode (int8u Hours_, int8u Minutes_, int8u Seconds_, int8u Frames_, int8u FramesPerSecond_, bool DropFrame_, bool MustUseSecondField_, bool IsSecondField_)
+{
+ Hours=Hours_;
+ Minutes=Minutes_;
+ Seconds=Seconds_;
+ Frames=Frames_;
+ FramesPerSecond=FramesPerSecond_;
+ DropFrame=DropFrame_;
+ MustUseSecondField=MustUseSecondField_;
+ IsSecondField=IsSecondField_;
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void TimeCode::PlusOne()
+{
+ if (FramesPerSecond==0)
+ return;
+ if (MustUseSecondField)
+ {
+ if (IsSecondField)
+ {
+ Frames++;
+ IsSecondField=false;
+ }
+ else
+ IsSecondField=true;
+ }
+ else
+ Frames++;
+ if (Frames>=FramesPerSecond)
+ {
+ Seconds++;
+ Frames=0;
+ if (Seconds>=60)
+ {
+ Seconds=0;
+ Minutes++;
+
+ if (DropFrame && Minutes%10)
+ Frames=2; //frames 0 and 1 are dropped for every minutes except 00 10 20 30 40 50
+
+ if (Minutes>=60)
+ {
+ Minutes=0;
+ Hours++;
+ if (Hours>=24)
+ {
+ Hours=0;
+ }
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void TimeCode::MinusOne()
+{
+ if (FramesPerSecond==0)
+ return;
+ if (MustUseSecondField && IsSecondField)
+ IsSecondField=false;
+ else
+ {
+ if (Frames==0 || (DropFrame && Minutes%10 && Frames<=2))
+ {
+ Frames=FramesPerSecond;
+ if (Seconds==0)
+ {
+ Seconds=60;
+ if (Minutes==0)
+ {
+ Minutes=60;
+ if (Hours==0)
+ Hours=24;
+ Hours--;
+ }
+ Minutes--;
+ }
+ Seconds--;
+ }
+ Frames--;
+
+ if (MustUseSecondField)
+ IsSecondField=true;
+ }
+}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+} //NameSpace
diff --git a/src/thirdparty/MediaInfo/MediaInfo/TimeCode.h b/src/thirdparty/MediaInfo/MediaInfo/TimeCode.h
new file mode 100644
index 000000000..d05cf6d62
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/TimeCode.h
@@ -0,0 +1,109 @@
+// TimeCode - Time code operations with drop frame support
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_TimeCodeH
+#define MediaInfo_TimeCodeH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Unknown
+//***************************************************************************
+
+class TimeCode
+{
+public:
+ //constructor/Destructor
+ TimeCode ();
+ TimeCode (int8u Hours_, int8u Minutes_, int8u Seconds_, int8u Frames_, int8u FramesPerSecond_, bool DropFrame_, bool MustUseSecondField_=false, bool IsSecondField_=false);
+
+ //Operators
+ TimeCode &operator ++()
+ {
+ PlusOne();
+ return *this;
+ }
+ TimeCode operator ++(int)
+ {
+ PlusOne();
+ return *this;
+ }
+ TimeCode &operator --()
+ {
+ MinusOne();
+ return *this;
+ }
+ TimeCode operator --(int)
+ {
+ MinusOne();
+ return *this;
+ }
+ bool operator== (const TimeCode &tc) const
+ {
+ return Hours ==tc.Hours
+ && Minutes ==tc.Minutes
+ && Seconds ==tc.Seconds
+ && Frames ==tc.Frames
+ && FramesPerSecond ==tc.FramesPerSecond
+ && DropFrame ==tc.DropFrame
+ && MustUseSecondField ==tc.MustUseSecondField
+ && IsSecondField ==tc.IsSecondField;
+ }
+ bool operator!= (const TimeCode &tc) const
+ {
+ return Hours !=tc.Hours
+ || Minutes !=tc.Minutes
+ || Seconds !=tc.Seconds
+ || Frames !=tc.Frames
+ || FramesPerSecond !=tc.FramesPerSecond
+ || DropFrame !=tc.DropFrame
+ || MustUseSecondField !=tc.MustUseSecondField
+ || IsSecondField !=tc.IsSecondField;
+ }
+
+ //Helpers
+ bool IsValid() const
+ {
+ return FramesPerSecond?true:false;
+ }
+ void PlusOne();
+ void MinusOne();
+
+public:
+ int8u Hours;
+ int8u Minutes;
+ int8u Seconds;
+ int8u Frames;
+ int8u FramesPerSecond;
+ bool DropFrame;
+ bool MustUseSecondField;
+ bool IsSecondField;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_AfdBarData.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_AfdBarData.cpp
new file mode 100644
index 000000000..8b35d0dd8
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_AfdBarData.cpp
@@ -0,0 +1,368 @@
+// File_AfdBarData - Info for Bar Data Video files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AFDBARDATA_YES) || defined(MEDIAINFO_MXF_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+namespace MediaInfoLib
+{
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* AfdBarData_active_format[]=
+{
+ //1st value is for 4:3, 2nd is for 16:9
+ "", //Undefined
+ "Reserved",
+ "Not recommended",
+ "Not recommended",
+ "Aspect ratio greater than 16:9", //Use GA94
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "4:3 full frame image / 16:9 full frame image",
+ "4:3 full frame image / 4:3 pillarbox image",
+ "16:9 letterbox image / 16:9 full frame image",
+ "14:9 letterbox image / 14:9 pillarbox image",
+ "Reserved",
+ "4:3 full frame image, alternative 14:9 center / 4:3 pillarbox image, alternative 14:9 center",
+ "16:9 letterbox image, alternative 14:9 center / 16:9 full frame image, alternative 14:9 center",
+ "16:9 letterbox image, alternative 4:3 center / 16:9 full frame image, alternative 4:3 center",
+};
+
+//---------------------------------------------------------------------------
+const char* AfdBarData_active_format_4_3[]=
+{
+ "", //Undefined
+ "Reserved",
+ "Letterbox 16:9 image (top)",
+ "Letterbox 14:9 image (top)",
+ "Letterbox image with an aspect ratio greater than 16:9",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Full frame 4:3 image",
+ "Full frame 4:3 image",
+ "Letterbox 16:9 image",
+ "Letterbox 14:9 image",
+ "Reserved",
+ "Full frame 4:3 image, with alternative 14:9 center",
+ "Letterbox 16:9 image, with alternative 14:9 center",
+ "Letterbox 16:9 image, with alternative 4:3 center",
+};
+
+//---------------------------------------------------------------------------
+const char* AfdBarData_active_format_16_9[]=
+{
+ "", //Undefined
+ "Reserved",
+ "Letterbox 16:9 image (top)",
+ "Pillarbox 14:9 image (top)",
+ "Letterbox image with an aspect ratio greater than 16:9",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "Full frame 16:9 image",
+ "Pillarbox 4:3 image",
+ "Letterbox 16:9 image",
+ "Pillarbox 14:9 image",
+ "Reserved",
+ "Full frame 4:3 image, with alternative 14:9 center",
+ "Letterbox 16:9 image, with alternative 14:9 center",
+ "Letterbox 16:9 image, with alternative 4:3 center",
+};
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //defined(MEDIAINFO_AFDBARDATA_YES) || defined(MEDIAINFO_MXF_YES)
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AFDBARDATA_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_AfdBarData.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+namespace MediaInfoLib
+{
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* AfdBarData_aspect_ratio[]=
+{
+ "4:3",
+ "16:9",
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_AfdBarData::File_AfdBarData()
+:File__Analyze()
+{
+ //Configuration
+ PTS_DTS_Needed=true;
+
+ //In
+ Format=Format_Unknown;
+ aspect_ratio_FromContainer=(int8u)-1;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_AfdBarData::Streams_Fill()
+{
+ //Filling
+ Stream_Prepare(Stream_Video);
+ if (active_format!=(int8u)-1)
+ {
+ Fill(Stream_Video, 0, Video_ActiveFormatDescription, Stream.active_format);
+ if (aspect_ratio==(int8u)-1)
+ aspect_ratio=aspect_ratio_FromContainer;
+ if (aspect_ratio!=(int8u)-1)
+ {
+ Fill(Stream_Video, 0, Video_ActiveFormatDescription_String, Stream.aspect_ratio?AfdBarData_active_format_16_9[Stream.active_format]:AfdBarData_active_format_4_3[Stream.active_format]);
+ switch (Format)
+ {
+ case Format_A53_4_DTG1 : Fill(Stream_Video, 0, Video_ActiveFormatDescription_MuxingMode, "A/53"); break;
+ case Format_S2016_3 : Fill(Stream_Video, 0, Video_ActiveFormatDescription_MuxingMode, "SMPTE ST 2016-3"); break;
+ default :
+ Skip_XX(Element_Size, "Unknown");
+ return;
+ }
+ }
+ }
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_AfdBarData::Read_Buffer_Continue()
+{
+ //Default
+ line_number_end_of_top_bar=(int16u)-1;
+ line_number_start_of_bottom_bar=(int16u)-1;
+ pixel_number_end_of_left_bar=(int16u)-1;
+ pixel_number_start_of_right_bar=(int16u)-1;
+ active_format=(int8u)-1;
+ aspect_ratio=(int8u)-1;
+
+ //Parsing
+ switch (Format)
+ {
+ case Format_A53_4_DTG1 :
+ afd_data();
+ break;
+ case Format_A53_4_GA94_06 :
+ bar_data();
+ break;
+ case Format_S2016_3 :
+ afd_data();
+ Skip_B1( "Reserved");
+ Skip_B1( "Reserved");
+ bar_data();
+ break;
+ default :
+ Skip_XX(Element_Size, "Unknown");
+ return;
+ }
+
+ FILLING_BEGIN();
+ //Filling
+ Stream.line_number_end_of_top_bar=line_number_end_of_top_bar;
+ Stream.line_number_start_of_bottom_bar=line_number_start_of_bottom_bar;
+ Stream.pixel_number_end_of_left_bar=pixel_number_end_of_left_bar;
+ Stream.pixel_number_start_of_right_bar=pixel_number_start_of_right_bar;
+ Stream.active_format=active_format;
+ Stream.aspect_ratio=aspect_ratio;
+
+ if (!Status[IsAccepted])
+ {
+ Accept("AfdBarData");
+ Fill("AfdBarData");
+ }
+ if (MediaInfoLib::Config.ParseSpeed_Get()<1)
+ Finish("AfdBarData");
+ FILLING_END();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_AfdBarData::afd_data()
+{
+ //Parsing
+ Element_Begin1("Active Format Description");
+ BS_Begin();
+ if (Format==Format_S2016_3)
+ {
+ Mark_0_NoTrustError();
+ Get_S1 (4, active_format, "active_format"); Param_Info1(AfdBarData_active_format[active_format]);
+ Get_S1 (1, aspect_ratio, "aspect_ratio"); Param_Info1(AfdBarData_aspect_ratio[aspect_ratio]);
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ }
+ else
+ {
+ bool active_format_flag;
+ Mark_0();
+ Get_SB (active_format_flag, "active_format_flag");
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_1_NoTrustError();
+ if (active_format_flag)
+ {
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Get_S1 (4, active_format, "active_format"); Param_Info1(AfdBarData_active_format[active_format]);
+ }
+ }
+ BS_End();
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_AfdBarData::bar_data()
+{
+ //Parsing
+ Element_Begin1("bar_data");
+ bool top_bar_flag, bottom_bar_flag, left_bar_flag, right_bar_flag;
+ BS_Begin();
+ Get_SB (top_bar_flag, "top_bar_flag");
+ Get_SB (bottom_bar_flag, "bottom_bar_flag");
+ Get_SB (left_bar_flag, "left_bar_flag");
+ Get_SB (right_bar_flag, "right_bar_flag");
+ if (Format==Format_S2016_3)
+ {
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ }
+ else
+ {
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ }
+ if (top_bar_flag)
+ {
+ Mark_1();
+ Mark_1();
+ Get_S2 (14, line_number_end_of_top_bar, "line_number_end_of_top_bar");
+ }
+ if (bottom_bar_flag)
+ {
+ Mark_1();
+ Mark_1();
+ Get_S2 (14, line_number_start_of_bottom_bar, "line_number_start_of_bottom_bar");
+ }
+ if (left_bar_flag)
+ {
+ Mark_1();
+ Mark_1();
+ Get_S2 (14, pixel_number_end_of_left_bar, "pixel_number_end_of_left_bar");
+ }
+ if (right_bar_flag)
+ {
+ Mark_1();
+ Mark_1();
+ Get_S2 (14, pixel_number_start_of_right_bar, "pixel_number_start_of_right_bar");
+ }
+ if (!top_bar_flag && !bottom_bar_flag && !left_bar_flag && !right_bar_flag)
+ {
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Skip_S2(14, "reserved");
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Skip_S2(14, "reserved");
+ }
+ BS_End();
+ Element_End0();
+
+ if (Format==Format_A53_4_DTG1)
+ {
+ BS_Begin();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ BS_End();
+
+ if (Element_Size-Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "additional_bar_data");
+ }
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_AFDBARDATA_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_AfdBarData.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_AfdBarData.h
new file mode 100644
index 000000000..613d3634b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_AfdBarData.h
@@ -0,0 +1,102 @@
+// File_AfdBarData - Info for Bar Data Video files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about AFD and Bar Data files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_AfdBarDataH
+#define MediaInfo_AfdBarDataH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_AfdBarData
+//***************************************************************************
+
+class File_AfdBarData : public File__Analyze
+{
+public :
+ //In
+ enum format
+ {
+ Format_Unknown,
+ Format_A53_4_DTG1, //Active Format Description
+ Format_A53_4_GA94_06, //Bar Data
+ Format_S2016_3, //Active Format Description & Bar Data
+ };
+ format Format;
+ int8u aspect_ratio_FromContainer; //May come from the containing parser
+
+ //Constructor/Destructor
+ File_AfdBarData();
+
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - Global
+ void Read_Buffer_Continue();
+
+ //Elements
+ void afd_data();
+ void bar_data();
+
+ //Sream
+ struct stream
+ {
+ int16u line_number_end_of_top_bar;
+ int16u line_number_start_of_bottom_bar;
+ int16u pixel_number_end_of_left_bar;
+ int16u pixel_number_start_of_right_bar;
+ int8u active_format;
+ int8u aspect_ratio;
+
+ stream()
+ {
+ line_number_end_of_top_bar=(int16u)-1;
+ line_number_start_of_bottom_bar=(int16u)-1;
+ pixel_number_end_of_left_bar=(int16u)-1;
+ pixel_number_start_of_right_bar=(int16u)-1;
+ active_format=(int8u)-1;
+ aspect_ratio=(int8u)-1;
+ }
+ };
+ stream Stream;
+
+ //Temp
+ int16u line_number_end_of_top_bar;
+ int16u line_number_start_of_bottom_bar;
+ int16u pixel_number_end_of_left_bar;
+ int16u pixel_number_start_of_right_bar;
+ int8u active_format;
+ int8u aspect_ratio;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc.cpp
new file mode 100644
index 000000000..043f8d02a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc.cpp
@@ -0,0 +1,3504 @@
+// File_Avc - Info for AVC Video files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AVC_YES) || defined(MEDIAINFO_MPEGPS_YES) || defined(MEDIAINFO_MPEGTS_YES)
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+#include "ZenLib/Conf.h"
+using namespace ZenLib;
+
+//---------------------------------------------------------------------------
+const char* Avc_profile_idc(int8u profile_idc)
+{
+ switch (profile_idc)
+ {
+ case 44 : return "CAVLC 4:4:4 Intra";
+ case 66 : return "Baseline";
+ case 77 : return "Main";
+ case 83 : return "Scalable Baseline";
+ case 86 : return "Scalable High";
+ case 88 : return "Extended";
+ case 100 : return "High";
+ case 110 : return "High 10";
+ case 118 : return "Multiview High";
+ case 122 : return "High 4:2:2";
+ case 128 : return "Stereo High";
+ case 144 : return "High 4:4:4";
+ case 244 : return "High 4:4:4 Predictive";
+ default : return "Unknown";
+ }
+}
+
+//---------------------------------------------------------------------------
+} //NameSpace
+
+//---------------------------------------------------------------------------
+#endif //...
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+//
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AVC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Avc.h"
+#if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ #include "MediaInfo/Text/File_DtvccTransport.h"
+#endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+#include <cstring>
+#include <cmath>
+#include <algorithm>
+using namespace std;
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const size_t Avc_Errors_MaxCount=32;
+
+//---------------------------------------------------------------------------
+const int8u Avc_PixelAspectRatio_Size=17;
+const float32 Avc_PixelAspectRatio[]=
+{
+ (float32)1, //Reserved
+ (float32)1,
+ (float32)12/(float32)11,
+ (float32)10/(float32)11,
+ (float32)16/(float32)11,
+ (float32)40/(float32)33,
+ (float32)24/(float32)11,
+ (float32)20/(float32)11,
+ (float32)32/(float32)11,
+ (float32)80/(float32)33,
+ (float32)18/(float32)11,
+ (float32)15/(float32)11,
+ (float32)64/(float32)33,
+ (float32)160/(float32)99,
+ (float32)4/(float32)3,
+ (float32)3/(float32)2,
+ (float32)2,
+};
+
+//---------------------------------------------------------------------------
+const char* Avc_video_format[]=
+{
+ "Component",
+ "PAL",
+ "NTSC",
+ "SECAM",
+ "MAC",
+ "",
+ "Reserved",
+ "Reserved",
+};
+
+//---------------------------------------------------------------------------
+const char* Avc_primary_pic_type[]=
+{
+ "I",
+ "I, P",
+ "I, P, B",
+ "SI",
+ "SI, SP",
+ "I, SI",
+ "I, SI, P, SP",
+ "I, SI, P, SP, B",
+};
+
+//---------------------------------------------------------------------------
+const char* Avc_slice_type[]=
+{
+ "P",
+ "B",
+ "I",
+ "SP",
+ "SI",
+ "P",
+ "B",
+ "I",
+ "SP",
+ "SI",
+};
+
+//---------------------------------------------------------------------------
+const int8u Avc_pic_struct_Size=9;
+const char* Avc_pic_struct[]=
+{
+ "frame",
+ "top field",
+ "bottom field",
+ "top field, bottom field",
+ "bottom field, top field",
+ "top field, bottom field, top field repeated",
+ "bottom field, top field, bottom field repeated",
+ "frame doubling",
+ "frame tripling",
+};
+
+//---------------------------------------------------------------------------
+const int8u Avc_NumClockTS[]=
+{
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 3,
+ 3,
+ 2,
+ 3,
+};
+
+//---------------------------------------------------------------------------
+const char* Avc_ct_type[]=
+{
+ "Progressive",
+ "Interlaced",
+ "Unknown",
+ "Reserved",
+};
+
+//---------------------------------------------------------------------------
+const char* Avc_Colorimetry_format_idc[]=
+{
+ "monochrome",
+ "4:2:0",
+ "4:2:2",
+ "4:4:4",
+};
+
+//---------------------------------------------------------------------------
+const int8u Avc_SubWidthC[]=
+{
+ 1,
+ 2,
+ 2,
+ 1,
+};
+
+//---------------------------------------------------------------------------
+const int8u Avc_SubHeightC[]=
+{
+ 1,
+ 2,
+ 1,
+ 1,
+};
+
+//---------------------------------------------------------------------------
+const char* Avc_user_data_DTG1_active_format[]=
+{
+ //1st value is for 4:3, 2nd is for 16:9
+ "", //Undefined
+ "Reserved",
+ "Not recommended",
+ "Not recommended",
+ "Aspect ratio greater than 16:9", //Use GA94
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "4:3 full frame image / 16:9 full frame image",
+ "4:3 full frame image / 4:3 pillarbox image",
+ "16:9 letterbox image / 16:9 full frame image",
+ "14:9 letterbox image / 14:9 pillarbox image",
+ "Reserved",
+ "4:3 full frame image, alternative 14:9 center / 4:3 pillarbox image, alternative 14:9 center",
+ "16:9 letterbox image, alternative 14:9 center / 16:9 full frame image, alternative 14:9 center",
+ "16:9 letterbox image, alternative 4:3 center / 16:9 full frame image, alternative 4:3 center",
+};
+
+//---------------------------------------------------------------------------
+const char* Avc_colour_primaries(int8u colour_primaries)
+{
+ switch (colour_primaries)
+ {
+ case 1 : return "BT.709-5, BT.1361, IEC 61966-2-4, SMPTE RP177";
+ case 4 : return "BT.470-6 system M, NTSC, FTC 73.682";
+ case 5 : return "BT.470-6 System B, BT.470-6 System G, BT.601-6 625, BT.1358 625, BT.1700 625 PAL, BT.1700 625 SECAM";
+ case 6 : return "BT.601-6 525, BT.1358 525, BT.1700 NTSC, SMPTE 170M";
+ case 7 : return "SMPTE 240M";
+ case 8 : return "Generic film";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Avc_transfer_characteristics(int8u transfer_characteristics)
+{
+ switch (transfer_characteristics)
+ {
+ case 1 : return "BT.709-5, BT.1361";
+ case 4 : return "BT.470-6 System M, NTSC, FTC 73.682, BT.1700 625 PAL, BT.1700 625 SECAM";
+ case 5 : return "BT.470-6 System B, BT.470-6 System G";
+ case 6 : return "BT.601-6 525, BT.601-6 625, BT.1358 525, BT.1358 625, BT.1700 NTSC, SMPTE 170M";
+ case 7 : return "SMPTE 240M";
+ case 8 : return "Linear";
+ case 9 : return "Logarithmic (100:1)";
+ case 10 : return "Logarithmic (316.22777:1)";
+ case 11 : return "IEC 61966-2-4";
+ case 12 : return "BT.1361 extended colour gamut system";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Avc_matrix_coefficients(int8u matrix_coefficients)
+{
+ switch (matrix_coefficients)
+ {
+ case 0 : return "RGB";
+ case 1 : return "BT.709-5, BT.1361, IEC 61966-2-4 709, SMPTE RP177";
+ case 4 : return "FTC 73.682";
+ case 5 : return "BT.470-6 System B, BT.470-6 System G, BT.601-6 625, BT.1358 625, BT.1700 625 PAL, BT.1700 625 SECAM, IEC 61966-2-4 601";
+ case 6 : return "BT.601-6 525, BT.1358 525, BT.1700 NTSC, SMPTE 170M";
+ case 7 : return "SMPTE 240M";
+ case 8 : return "YCgCo";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Avc_user_data_GA94_cc_type(int8u cc_type)
+{
+ switch (cc_type)
+ {
+ case 0 : return "CEA-608 line 21 field 1 closed captions"; //closed caption 3 if this is second field
+ case 1 : return "CEA-608 line 21 field 2 closed captions"; //closed caption 4 if this is second field
+ case 2 : return "DTVCC Channel Packet Data";
+ case 3 : return "DTVCC Channel Packet Start";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+int32u Avc_MaxDpbMbs(int8u level)
+{
+ switch (level)
+ {
+ case 10 : return 1485;
+ case 11 : return 3000;
+ case 12 : return 6000;
+ case 13 :
+ case 20 : return 11880;
+ case 21 : return 19800;
+ case 22 : return 20250;
+ case 30 : return 40500;
+ case 31 : return 108000;
+ case 32 : return 216000;
+ case 40 :
+ case 41 : return 245760;
+ case 42 : return 522240;
+ case 50 : return 589824;
+ case 51 : return 983040;
+ default : return 0;
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Avc::File_Avc()
+#if MEDIAINFO_DUPLICATE
+:File__Duplicate()
+#endif //MEDIAINFO_DUPLICATE
+{
+ //Config
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Avc;
+ StreamIDs_Width[0]=0;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(8); //Stream
+ #endif //MEDIAINFO_TRACE
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+ PTS_DTS_Needed=true;
+ IsRawStream=true;
+ Frame_Count_NotParsedIncluded=0;
+
+ //In
+ Frame_Count_Valid=MediaInfoLib::Config.ParseSpeed_Get()>=0.3?512:2;
+ FrameIsAlwaysComplete=false;
+ MustParse_SPS_PPS=false;
+ SizedBlocks=false;
+
+ //Text
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ GA94_03_Parser=NULL;
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+}
+
+//---------------------------------------------------------------------------
+File_Avc::~File_Avc()
+{
+ for (size_t Pos=0; Pos<TemporalReferences.size(); Pos++)
+ delete TemporalReferences[Pos]; //TemporalReferences[Pos]=NULL;
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ delete GA94_03_Parser; //GA94_03_Parser=NULL;
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+
+ for (size_t Pos=0; Pos<seq_parameter_sets.size(); Pos++)
+ delete seq_parameter_sets[Pos]; //TemporalReferences[Pos]=NULL;
+
+ for (size_t Pos=0; Pos<subset_seq_parameter_sets.size(); Pos++)
+ delete subset_seq_parameter_sets[Pos]; //TemporalReferences[Pos]=NULL;
+
+ for (size_t Pos=0; Pos<pic_parameter_sets.size(); Pos++)
+ delete pic_parameter_sets[Pos]; //TemporalReferences[Pos]=NULL;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Avc::Streams_Fill()
+{
+ for (std::vector<seq_parameter_set_struct*>::iterator seq_parameter_set_Item=seq_parameter_sets.begin(); seq_parameter_set_Item!=seq_parameter_sets.end(); seq_parameter_set_Item++)
+ if ((*seq_parameter_set_Item))
+ Streams_Fill(seq_parameter_set_Item);
+ for (std::vector<seq_parameter_set_struct*>::iterator subset_seq_parameter_set_Item=subset_seq_parameter_sets.begin(); subset_seq_parameter_set_Item!=subset_seq_parameter_sets.end(); subset_seq_parameter_set_Item++)
+ if ((*subset_seq_parameter_set_Item))
+ {
+ if (seq_parameter_sets.empty())
+ Streams_Fill(subset_seq_parameter_set_Item);
+ else
+ Streams_Fill_subset(subset_seq_parameter_set_Item);
+ Fill(Stream_Video, 0, Video_MultiView_Count, (*subset_seq_parameter_set_Item)->num_views_minus1+1);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::Streams_Fill(std::vector<seq_parameter_set_struct*>::iterator seq_parameter_set_Item)
+{
+ //Calculating - Pixels
+ int32u Width =((*seq_parameter_set_Item)->pic_width_in_mbs_minus1 +1)*16;
+ int32u Height=((*seq_parameter_set_Item)->pic_height_in_map_units_minus1+1)*16*(2-(*seq_parameter_set_Item)->frame_mbs_only_flag);
+ int32u CropUnitX=Avc_SubWidthC [(*seq_parameter_set_Item)->ChromaArrayType()];
+ int32u CropUnitY=Avc_SubHeightC[(*seq_parameter_set_Item)->ChromaArrayType()]*(2-(*seq_parameter_set_Item)->frame_mbs_only_flag);
+ Width -=((*seq_parameter_set_Item)->frame_crop_left_offset+(*seq_parameter_set_Item)->frame_crop_right_offset )*CropUnitX;
+ Height-=((*seq_parameter_set_Item)->frame_crop_top_offset +(*seq_parameter_set_Item)->frame_crop_bottom_offset)*CropUnitY;
+
+ //From vui_parameters
+ float64 PixelAspectRatio=1;
+ if ((*seq_parameter_set_Item)->vui_parameters)
+ {
+ if ((*seq_parameter_set_Item)->vui_parameters->aspect_ratio_idc<Avc_PixelAspectRatio_Size)
+ PixelAspectRatio=Avc_PixelAspectRatio[(*seq_parameter_set_Item)->vui_parameters->aspect_ratio_idc];
+ else if ((*seq_parameter_set_Item)->vui_parameters->aspect_ratio_idc==0xFF && (*seq_parameter_set_Item)->vui_parameters->sar_height)
+ PixelAspectRatio=((float64)(*seq_parameter_set_Item)->vui_parameters->sar_width)/(*seq_parameter_set_Item)->vui_parameters->sar_height;
+ if ((*seq_parameter_set_Item)->vui_parameters->timing_info_present_flag)
+ {
+ if (!(*seq_parameter_set_Item)->vui_parameters->fixed_frame_rate_flag)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Mode, "VFR");
+ else if ((*seq_parameter_set_Item)->vui_parameters->time_scale && (*seq_parameter_set_Item)->vui_parameters->num_units_in_tick)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, (float64)(*seq_parameter_set_Item)->vui_parameters->time_scale/(*seq_parameter_set_Item)->vui_parameters->num_units_in_tick/((*seq_parameter_set_Item)->frame_mbs_only_flag?2:((*seq_parameter_set_Item)->pic_order_cnt_type==2?1:2))/FrameRate_Divider);
+ }
+
+ //Colour description
+ if ((*seq_parameter_set_Item)->vui_parameters->video_signal_type_present_flag)
+ {
+ Fill(Stream_Video, 0, Video_Standard, Avc_video_format[(*seq_parameter_set_Item)->vui_parameters->video_format]);
+ if ((*seq_parameter_set_Item)->vui_parameters->colour_description_present_flag)
+ {
+ Fill(Stream_Video, 0, "colour_primaries", Avc_colour_primaries((*seq_parameter_set_Item)->vui_parameters->colour_primaries));
+ Fill(Stream_Video, 0, "transfer_characteristics", Avc_transfer_characteristics((*seq_parameter_set_Item)->vui_parameters->transfer_characteristics));
+ Fill(Stream_Video, 0, "matrix_coefficients", Avc_matrix_coefficients((*seq_parameter_set_Item)->vui_parameters->matrix_coefficients));
+ }
+ }
+
+ //hrd_parameter_sets
+ int32u bit_rate_value=(int32u)-1;
+ bool bit_rate_value_IsValid=true;
+ bool cbr_flag=false;
+ bool cbr_flag_IsSet=false;
+ bool cbr_flag_IsValid=true;
+ seq_parameter_set_struct::vui_parameters_struct::xxl* NAL=(*seq_parameter_set_Item)->vui_parameters->NAL;
+ if (NAL)
+ for (size_t Pos=0; Pos<NAL->SchedSel.size(); Pos++)
+ {
+ if (NAL->SchedSel[Pos].cpb_size_value!=(int32u)-1)
+ Fill(Stream_Video, 0, Video_BufferSize, NAL->SchedSel[Pos].cpb_size_value);
+ if (bit_rate_value!=(int32u)-1 && bit_rate_value!=NAL->SchedSel[Pos].bit_rate_value)
+ bit_rate_value_IsValid=false;
+ if (bit_rate_value==(int32u)-1)
+ bit_rate_value=NAL->SchedSel[Pos].bit_rate_value;
+ if (cbr_flag_IsSet==true && cbr_flag!=NAL->SchedSel[Pos].cbr_flag)
+ cbr_flag_IsValid=false;
+ if (cbr_flag_IsSet==0)
+ {
+ cbr_flag=NAL->SchedSel[Pos].cbr_flag;
+ cbr_flag_IsSet=true;
+ }
+ }
+ seq_parameter_set_struct::vui_parameters_struct::xxl* VCL=(*seq_parameter_set_Item)->vui_parameters->VCL;
+ if (VCL)
+ for (size_t Pos=0; Pos<VCL->SchedSel.size(); Pos++)
+ {
+ Fill(Stream_Video, 0, Video_BufferSize, VCL->SchedSel[Pos].cpb_size_value);
+ if (bit_rate_value!=(int32u)-1 && bit_rate_value!=VCL->SchedSel[Pos].bit_rate_value)
+ bit_rate_value_IsValid=false;
+ if (bit_rate_value==(int32u)-1)
+ bit_rate_value=VCL->SchedSel[Pos].bit_rate_value;
+ if (cbr_flag_IsSet==true && cbr_flag!=VCL->SchedSel[Pos].cbr_flag)
+ cbr_flag_IsValid=false;
+ if (cbr_flag_IsSet==0)
+ {
+ cbr_flag=VCL->SchedSel[Pos].cbr_flag;
+ cbr_flag_IsSet=true;
+ }
+ }
+ if (cbr_flag_IsSet && cbr_flag_IsValid)
+ {
+ Fill(Stream_Video, 0, Video_BitRate_Mode, cbr_flag?"CBR":"VBR");
+ if (bit_rate_value!=(int32u)-1 && bit_rate_value_IsValid)
+ Fill(Stream_Video, 0, cbr_flag?Video_BitRate_Nominal:Video_BitRate_Maximum, bit_rate_value);
+ }
+ }
+
+ if (Count_Get(Stream_Video)==0)
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "AVC");
+ Fill(Stream_Video, 0, Video_Codec, "AVC");
+
+ Ztring Profile=Ztring().From_Local(Avc_profile_idc((*seq_parameter_set_Item)->profile_idc))+_T("@L")+Ztring().From_Number(((float)(*seq_parameter_set_Item)->level_idc)/10, 1);
+ Fill(Stream_Video, 0, Video_Format_Profile, Profile);
+ Fill(Stream_Video, 0, Video_Codec_Profile, Profile);
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Width);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Height);
+ Fill(Stream_Video, 0, Video_PixelAspectRatio, PixelAspectRatio, 3, true);
+ Fill(Stream_Video, 0, Video_DisplayAspectRatio, Width*PixelAspectRatio/Height, 3, true); //More precise
+ if (FrameRate_Divider==2)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Format_Settings_FrameMode, "Frame doubling");
+ Fill(Stream_Video, StreamPos_Last, Video_Format_Settings, "Frame doubling");
+ }
+ if (FrameRate_Divider==3)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Format_Settings_FrameMode, "Frame tripling");
+ Fill(Stream_Video, StreamPos_Last, Video_Format_Settings, "Frame tripling");
+ }
+
+ //Interlacement
+ if ((*seq_parameter_set_Item)->mb_adaptive_frame_field_flag && Structure_Frame>0) //Interlaced macro-block
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "MBAFF");
+ Fill(Stream_Video, 0, Video_Interlacement, "MBAFF");
+ }
+ else if ((*seq_parameter_set_Item)->frame_mbs_only_flag || Structure_Field==0) //No interlaced frame
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Progressive");
+ Fill(Stream_Video, 0, Video_Interlacement, "PPF");
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Interlaced");
+ Fill(Stream_Video, 0, Video_Interlacement, "Interlaced");
+ }
+ std::string ScanOrders, PictureTypes(PictureTypes_PreviousFrames);
+ ScanOrders.reserve(TemporalReferences.size());
+ for (size_t Pos=0; Pos<TemporalReferences.size(); Pos++)
+ if (TemporalReferences[Pos])
+ {
+ ScanOrders+=TemporalReferences[Pos]->IsTop?'T':'B';
+ if ((Pos%2)==0)
+ PictureTypes+=Avc_slice_type[TemporalReferences[Pos]->slice_type];
+ }
+ else if (!PictureTypes.empty()) //Only if stream already started
+ {
+ ScanOrders+=' ';
+ if ((Pos%2)==0)
+ PictureTypes+=' ';
+ }
+ Fill(Stream_Video, 0, Video_ScanOrder, ScanOrder_Detect(ScanOrders));
+ { //Legacy
+ string Result=ScanOrder_Detect(ScanOrders);
+ if (!Result.empty())
+ Fill(Stream_Video, 0, Video_Interlacement, Result, true, true);
+ }
+ Fill(Stream_Video, 0, Video_Format_Settings_GOP, GOP_Detect(PictureTypes));
+
+ Fill(Stream_Video, 0, Video_Encoded_Library, Encoded_Library);
+ Fill(Stream_Video, 0, Video_Encoded_Library_Name, Encoded_Library_Name);
+ Fill(Stream_Video, 0, Video_Encoded_Library_Version, Encoded_Library_Version);
+ Fill(Stream_Video, 0, Video_Encoded_Library_Settings, Encoded_Library_Settings);
+ Fill(Stream_Video, 0, Video_BitRate_Nominal, BitRate_Nominal);
+ Fill(Stream_Video, 0, Video_MuxingMode, MuxingMode);
+ for (std::vector<pic_parameter_set_struct*>::iterator pic_parameter_set_Item=pic_parameter_sets.begin(); pic_parameter_set_Item!=pic_parameter_sets.end(); pic_parameter_set_Item++)
+ if (*pic_parameter_set_Item && (*pic_parameter_set_Item)->seq_parameter_set_id==seq_parameter_set_Item-(seq_parameter_sets.empty()?subset_seq_parameter_sets.begin():seq_parameter_sets.begin()))
+ {
+ if ((*pic_parameter_set_Item)->entropy_coding_mode_flag)
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings, "CABAC");
+ Fill(Stream_Video, 0, Video_Format_Settings_CABAC, "Yes");
+ Fill(Stream_Video, 0, Video_Codec_Settings, "CABAC");
+ Fill(Stream_Video, 0, Video_Codec_Settings_CABAC, "Yes");
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings_CABAC, "No");
+ Fill(Stream_Video, 0, Video_Codec_Settings_CABAC, "No");
+ }
+ break; //TODO: currently, testing only the first pic_parameter_set
+ }
+ if ((*seq_parameter_set_Item)->max_num_ref_frames>0)
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings, Ztring::ToZtring((*seq_parameter_set_Item)->max_num_ref_frames)+_T(" Ref Frames"));
+ Fill(Stream_Video, 0, Video_Codec_Settings, Ztring::ToZtring((*seq_parameter_set_Item)->max_num_ref_frames)+_T(" Ref Frames"));
+ Fill(Stream_Video, 0, Video_Format_Settings_RefFrames, (*seq_parameter_set_Item)->max_num_ref_frames);
+ Fill(Stream_Video, 0, Video_Codec_Settings_RefFrames, (*seq_parameter_set_Item)->max_num_ref_frames);
+ }
+ Fill(Stream_Video, 0, Video_ColorSpace, "YUV");
+ Fill(Stream_Video, 0, Video_Colorimetry, Avc_Colorimetry_format_idc[(*seq_parameter_set_Item)->chroma_format_idc]);
+ if ((*seq_parameter_set_Item)->bit_depth_luma_minus8==(*seq_parameter_set_Item)->bit_depth_chroma_minus8)
+ Fill(Stream_Video, 0, Video_BitDepth, (*seq_parameter_set_Item)->bit_depth_luma_minus8+8);
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::Streams_Fill_subset(std::vector<seq_parameter_set_struct*>::iterator seq_parameter_set_Item)
+{
+ Ztring Profile=Ztring().From_Local(Avc_profile_idc((*seq_parameter_set_Item)->profile_idc))+_T("@L")+Ztring().From_Number(((float)(*seq_parameter_set_Item)->level_idc)/10, 1);
+ Ztring Profile_Base=Retrieve(Stream_Video, 0, Video_Format_Profile);
+ Fill(Stream_Video, 0, Video_Format_Profile, Profile, true);
+ if (!Profile_Base.empty())
+ Fill(Stream_Video, 0, Video_Format_Profile, Profile_Base);
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::Streams_Finish()
+{
+ if (PTS_End!=(int64u)-1 && (IsSub || File_Offset+Buffer_Offset+Element_Size==File_Size))
+ {
+ if (PTS_End>PTS_Begin)
+ Fill(Stream_Video, 0, Video_Duration, float64_int64s(((float64)(PTS_End-PTS_Begin))/1000000));
+ }
+
+ //GA94 captions
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ if (GA94_03_Parser && GA94_03_Parser->Status[IsAccepted])
+ {
+ Finish(GA94_03_Parser);
+ Merge(*GA94_03_Parser);
+
+ for (size_t Pos=0; Pos<Count_Get(Stream_Text); Pos++)
+ {
+ Ztring MuxingMode=Retrieve(Stream_Text, Pos, "MuxingMode");
+ Fill(Stream_Text, Pos, "MuxingMode", _T("SCTE 128 / ")+MuxingMode, true);
+ }
+ }
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+
+ #if MEDIAINFO_IBI
+ if (seq_parameter_sets.size()==1 && (*seq_parameter_sets.begin())->vui_parameters && (*seq_parameter_sets.begin())->vui_parameters->timing_info_present_flag && (*seq_parameter_sets.begin())->vui_parameters->fixed_frame_rate_flag)
+ Ibi_Stream_Finish((*seq_parameter_sets.begin())->vui_parameters->time_scale, (*seq_parameter_sets.begin())->vui_parameters->num_units_in_tick);
+ #endif //MEDIAINFO_IBI
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Avc::FileHeader_Begin()
+{
+ if (!File__Analyze::FileHeader_Begin_0x000001())
+ return false;
+
+ if (!MustSynchronize)
+ {
+ Synched_Init();
+ Buffer_TotalBytes_FirstSynched=0;
+ File_Offset_FirstSynched=File_Offset;
+ }
+
+ //All should be OK
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Avc::Synchronize()
+{
+ //Synchronizing
+ while(Buffer_Offset+4<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x01))
+ {
+ Buffer_Offset+=2;
+ while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Buffer_Offset+=2;
+ if (Buffer_Offset>=Buffer_Size || Buffer[Buffer_Offset-1]==0x00)
+ Buffer_Offset--;
+ }
+ if (Buffer_Offset && Buffer[Buffer_Offset-1]==0x00)
+ Buffer_Offset--;
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+4==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x00
+ || Buffer[Buffer_Offset+3]!=0x01))
+ Buffer_Offset++;
+ if (Buffer_Offset+3==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x01))
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00))
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && Buffer[Buffer_Offset ]!=0x00)
+ Buffer_Offset++;
+
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+
+ //Synched is OK
+ Synched=true;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Avc::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+6>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (CC3(Buffer+Buffer_Offset)!=0x000001 && CC4(Buffer+Buffer_Offset)!=0x00000001)
+ {
+ Synched=false;
+ return true;
+ }
+
+ //Quick search
+ if (Synched && !Header_Parser_QuickSearch())
+ return false;
+
+ #if MEDIAINFO_IBI
+ bool zero_byte=Buffer[Buffer_Offset+2]==0x00;
+ bool RandomAccess=(Buffer[Buffer_Offset+(zero_byte?4:3)]&0x1F)==0x07 || ((Buffer[Buffer_Offset+(zero_byte?4:3)]&0x1F)==0x09 && ((Buffer[Buffer_Offset+(zero_byte?5:4)]&0xE0)==0x00 || (Buffer[Buffer_Offset+(zero_byte?5:4)]&0xE0)==0xA0)); //seq_parameter_set or access_unit_delimiter with value=0 or 5 (3 bits)
+ if (RandomAccess)
+ Ibi_Add();
+ #endif //MEDIAINFO_IBI
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Demux
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+bool File_Avc::Demux_UnpacketizeContainer_Test()
+{
+ bool zero_byte=Buffer[Buffer_Offset+2]==0x00;
+ if (!(((Buffer[Buffer_Offset+(zero_byte?4:3)]&0x1B)==0x01 && (Buffer[Buffer_Offset+(zero_byte?5:4)]&0x80)!=0x80)
+ || (Buffer[Buffer_Offset+(zero_byte?4:3)]&0x1F)==0x0C))
+ {
+ if (Demux_Offset==0)
+ {
+ Demux_Offset=Buffer_Offset;
+ Demux_IntermediateItemFound=false;
+ }
+ while (Demux_Offset+6<=Buffer_Size)
+ {
+ //Synchronizing
+ while(Demux_Offset+6<=Buffer_Size && (Buffer[Demux_Offset ]!=0x00
+ || Buffer[Demux_Offset+1]!=0x00
+ || Buffer[Demux_Offset+2]!=0x01))
+ {
+ Demux_Offset+=2;
+ while(Demux_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Demux_Offset+=2;
+ if (Demux_Offset>=Buffer_Size || Buffer[Demux_Offset-1]==0x00)
+ Demux_Offset--;
+ }
+
+ if (Demux_Offset+6<=Buffer_Size)
+ {
+ zero_byte=Buffer[Demux_Offset+2]==0x00;
+ if (Demux_IntermediateItemFound)
+ {
+ if (!(((Buffer[Demux_Offset+(zero_byte?4:3)]&0x1B)==0x01 && (Buffer[Demux_Offset+(zero_byte?5:4)]&0x80)!=0x80)
+ || (Buffer[Demux_Offset+(zero_byte?4:3)]&0x1F)==0x0C))
+ break;
+ }
+ else
+ {
+ if ((Buffer[Demux_Offset+(zero_byte?4:3)]&0x1B)==0x01 && (Buffer[Demux_Offset+(zero_byte?5:4)]&0x80)==0x80)
+ Demux_IntermediateItemFound=true;
+ }
+ }
+ Demux_Offset++;
+ }
+
+ if (Demux_Offset+6>Buffer_Size && !FrameIsAlwaysComplete && File_Offset+Buffer_Size<File_Size)
+ return false; //No complete frame
+
+ if (Demux_Offset && Buffer[Demux_Offset-1]==0x00)
+ Demux_Offset--;
+
+ zero_byte=Buffer[Buffer_Offset+2]==0x00;
+ bool RandomAccess=(Buffer[Buffer_Offset+(zero_byte?4:3)]&0x1F)==0x07 || ((Buffer[Buffer_Offset+(zero_byte?4:3)]&0x1F)==0x09 && ((Buffer[Buffer_Offset+(zero_byte?5:4)]&0xE0)==0x00 || (Buffer[Buffer_Offset+(zero_byte?5:4)]&0xE0)==0xA0)); //seq_parameter_set or access_unit_delimiter with value=0 or 5 (3 bits)
+ if (!Status[IsAccepted])
+ {
+ Accept("AVC");
+ if (Config->Demux_EventWasSent)
+ return false;
+ }
+
+ if (IFrame_Count || RandomAccess)
+ {
+ bool Frame_Count_NotParsedIncluded_PlusOne=false;
+ int64u PTS_Temp=FrameInfo.PTS;
+ if (!IsSub)
+ FrameInfo.PTS=(int64u)-1;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1 && Interlaced_Top!=Interlaced_Bottom)
+ {
+ Frame_Count_NotParsedIncluded--;
+ Frame_Count_NotParsedIncluded_PlusOne=true;
+ }
+ Demux_UnpacketizeContainer_Demux(RandomAccess);
+ if (!IsSub)
+ FrameInfo.PTS=PTS_Temp;
+ if (Frame_Count_NotParsedIncluded_PlusOne)
+ Frame_Count_NotParsedIncluded++;
+ }
+ else
+ Demux_UnpacketizeContainer_Demux_Clear();
+ }
+
+ return true;
+}
+#endif //MEDIAINFO_DEMUX
+
+//---------------------------------------------------------------------------
+void File_Avc::Synched_Init()
+{
+ //FrameInfo
+ PTS_End=0;
+ if (FrameInfo.DTS==(int64u)-1)
+ FrameInfo.DTS=0; //No DTS in container
+ DTS_Begin=FrameInfo.DTS;
+ DTS_End=FrameInfo.DTS;
+
+ //Temporal references
+ TemporalReferences_DelayedElement=NULL;
+ TemporalReferences_Min=0;
+ TemporalReferences_Max=0;
+ TemporalReferences_Reserved=0;
+ TemporalReferences_Offset=0;
+ TemporalReferences_Offset_pic_order_cnt_lsb_Last=0;
+ TemporalReferences_pic_order_cnt_Min=0;
+
+ //Text
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ GA94_03_IsPresent=false;
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+
+ //File specific
+ SizeOfNALU_Minus1=(int8u)-1;
+
+ //Status
+ IFrame_Count=0;
+ prevPicOrderCntMsb=0;
+ prevPicOrderCntLsb=(int32u)-1;
+ prevTopFieldOrderCnt=(int32u)-1;
+ prevFrameNum=(int32u)-1;
+ prevFrameNumOffset=(int32u)-1;
+
+ //Count of a Packets
+ Block_Count=0;
+ Interlaced_Top=0;
+ Interlaced_Bottom=0;
+ Structure_Field=0;
+ Structure_Frame=0;
+
+ //Temp
+ FrameRate_Divider=1;
+ FirstPFrameInGop_IsParsed=false;
+ tc=0;
+
+ //Default values
+ Streams.resize(0x100);
+ Streams[0x06].Searching_Payload=true; //sei
+ Streams[0x07].Searching_Payload=true; //seq_parameter_set
+ Streams[0x09].Searching_Payload=true; //access_unit_delimiter
+ Streams[0x0F].Searching_Payload=true; //subset_seq_parameter_set
+ for (int8u Pos=0xFF; Pos>=0xB9; Pos--)
+ Streams[Pos].Searching_Payload=true; //Testing MPEG-PS
+
+ //Options
+ Option_Manage();
+
+ //Specific cases
+ #if MEDIAINFO_EVENTS
+ if (Config->ParseUndecodableFrames_Get())
+ {
+ Accept(); //In some case, we must accept the stream very quickly and before the sequence header is detected
+ Streams[0x01].Searching_Payload=true; //slice_header
+ Streams[0x05].Searching_Payload=true; //slice_header
+ }
+ #endif //MEDIAINFO_EVENTS
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Avc::Read_Buffer_Unsynched()
+{
+ //Temporal references
+ for (size_t Pos=0; Pos<TemporalReferences.size(); Pos++)
+ delete TemporalReferences[Pos]; //TemporalReferences[Pos]=NULL;
+ TemporalReferences.clear();
+ delete TemporalReferences_DelayedElement; TemporalReferences_DelayedElement=NULL;
+ TemporalReferences_Min=0;
+ TemporalReferences_Max=0;
+ TemporalReferences_Reserved=0;
+ TemporalReferences_Offset=0;
+ TemporalReferences_Offset_pic_order_cnt_lsb_Last=0;
+ TemporalReferences_pic_order_cnt_Min=0;
+
+ //Text
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ if (GA94_03_Parser)
+ GA94_03_Parser->Open_Buffer_Unsynch();
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+
+ //parameter_sets
+ for (std::vector<seq_parameter_set_struct*>::iterator seq_parameter_set_Item=seq_parameter_sets.begin(); seq_parameter_set_Item!=seq_parameter_sets.end(); seq_parameter_set_Item++)
+ if ((*seq_parameter_set_Item))
+ (*seq_parameter_set_Item)->IsSynched=false;
+ for (std::vector<seq_parameter_set_struct*>::iterator subset_seq_parameter_set_Item=subset_seq_parameter_sets.begin(); subset_seq_parameter_set_Item!=subset_seq_parameter_sets.end(); subset_seq_parameter_set_Item++)
+ if ((*subset_seq_parameter_set_Item))
+ (*subset_seq_parameter_set_Item)->IsSynched=false;
+ for (std::vector<pic_parameter_set_struct*>::iterator pic_parameter_set_Item=pic_parameter_sets.begin(); pic_parameter_set_Item!=pic_parameter_sets.end(); pic_parameter_set_Item++)
+ if ((*pic_parameter_set_Item))
+ (*pic_parameter_set_Item)->IsSynched=false;
+
+ //Status
+ IFrame_Count=0;
+ Interlaced_Top=0;
+ Interlaced_Bottom=0;
+ prevPicOrderCntMsb=0;
+ prevPicOrderCntLsb=(int32u)-1;
+ prevTopFieldOrderCnt=(int32u)-1;
+ prevFrameNum=(int32u)-1;
+ prevFrameNumOffset=(int32u)-1;
+
+ //Temp
+ FrameRate_Divider=1;
+ FirstPFrameInGop_IsParsed=false;
+ tc=0;
+
+ //Impossible to know TimeStamps now
+ PTS_End=0;
+ DTS_End=0;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Avc::Header_Parse()
+{
+ //Specific case
+ if (MustParse_SPS_PPS)
+ {
+ Header_Fill_Size(Element_Size);
+ Header_Fill_Code((int64u)-1, "Specific");
+ return;
+ }
+
+ //Parsing
+ int8u nal_unit_type;
+ if (!SizedBlocks)
+ {
+ if (Buffer[Buffer_Offset+2]==0x00)
+ Skip_B1( "zero_byte");
+ Skip_B3( "start_code_prefix_one_3bytes");
+ BS_Begin();
+ Mark_0 ();
+ Get_S1 ( 2, nal_ref_idc, "nal_ref_idc");
+ Get_S1 ( 5, nal_unit_type, "nal_unit_type");
+ BS_End();
+ if (!Header_Parser_Fill_Size())
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+ }
+ else
+ {
+ int32u Size;
+ switch (SizeOfNALU_Minus1)
+ {
+ case 0: {
+ int8u Size_;
+ Get_B1 (Size_, "size");
+ Size=Size_;
+ }
+ break;
+ case 1: {
+ int16u Size_;
+ Get_B2 (Size_, "size");
+ Size=Size_;
+ }
+ break;
+ case 2: {
+ int32u Size_;
+ Get_B3 (Size_, "size");
+ Size=Size_;
+ }
+ break;
+ case 3: Get_B4 (Size, "size");
+ break;
+ default: Trusted_IsNot("No size of NALU defined");
+ Size=(int32u)(Buffer_Size-Buffer_Offset);
+ }
+ BS_Begin();
+ Mark_0 ();
+ Get_S1 ( 2, nal_ref_idc, "nal_ref_idc");
+ Get_S1 ( 5, nal_unit_type, "nal_unit_type");
+ BS_End();
+
+ //Filling
+ Header_Fill_Size(Element_Offset+Size-1);
+ }
+
+ //Filling
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ Header_Fill_Code(nal_unit_type, Ztring().From_CC1(nal_unit_type));
+ else
+ #endif //MEDIAINFO_TRACE
+ Header_Fill_Code(nal_unit_type);
+}
+
+//---------------------------------------------------------------------------
+bool File_Avc::Header_Parser_Fill_Size()
+{
+ //Look for next Sync word
+ if (Buffer_Offset_Temp==0) //Buffer_Offset_Temp is not 0 if Header_Parse_Fill_Size() has already parsed first frames
+ Buffer_Offset_Temp=Buffer_Offset+4;
+ while (Buffer_Offset_Temp+5<=Buffer_Size
+ && CC3(Buffer+Buffer_Offset_Temp)!=0x000001)
+ {
+ Buffer_Offset_Temp+=2;
+ while(Buffer_Offset_Temp<Buffer_Size && Buffer[Buffer_Offset_Temp]!=0x00)
+ Buffer_Offset_Temp+=2;
+ if (Buffer_Offset_Temp>=Buffer_Size || Buffer[Buffer_Offset_Temp-1]==0x00)
+ Buffer_Offset_Temp--;
+ }
+
+ //Must wait more data?
+ if (Buffer_Offset_Temp+5>Buffer_Size)
+ {
+ if (FrameIsAlwaysComplete || File_Offset+Buffer_Size>=File_Size)
+ Buffer_Offset_Temp=Buffer_Size; //We are sure that the next bytes are a start
+ else
+ return false;
+ }
+
+ if (Buffer[Buffer_Offset_Temp-1]==0x00)
+ Buffer_Offset_Temp--;
+
+ //OK, we continue
+ Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset);
+ Buffer_Offset_Temp=0;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Avc::Header_Parser_QuickSearch()
+{
+ while ( Buffer_Offset+6<=Buffer_Size
+ && Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && (Buffer[Buffer_Offset+2]==0x01
+ || (Buffer[Buffer_Offset+2]==0x00 && Buffer[Buffer_Offset+3]==0x01)))
+ {
+ //Getting start_code
+ int8u start_code;
+ if (Buffer[Buffer_Offset+2]==0x00)
+ start_code=CC1(Buffer+Buffer_Offset+4)&0x1F;
+ else
+ start_code=CC1(Buffer+Buffer_Offset+3)&0x1F;
+
+ //Searching start33
+ if (Streams[start_code].Searching_Payload
+ || Streams[start_code].ShouldDuplicate)
+ return true;
+
+ //Synchronizing
+ Buffer_Offset+=4;
+ Synched=false;
+ if (!Synchronize())
+ return false;
+
+ if (Buffer_Offset+6>Buffer_Size)
+ return false;
+ }
+
+ Trusted_IsNot("AVC, Synchronisation lost");
+ return Synchronize();
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::Data_Parse()
+{
+ //Specific case
+ if (Element_Code==(int64u)-1)
+ {
+ SPS_PPS();
+ return;
+ }
+
+ //Trailing zeroes
+ int64u Element_Size_SaveBeforeZeroes=Element_Size;
+ if (Element_Size)
+ {
+ while (Element_Size && Buffer[Buffer_Offset+(size_t)Element_Size-1]==0)
+ Element_Size--;
+ }
+
+ //svc_extension
+ bool svc_extension_flag=false;
+ if (Element_Code==0x0E || Element_Code==0x14)
+ {
+ BS_Begin();
+ Get_SB (svc_extension_flag, "svc_extension_flag");
+ if (svc_extension_flag)
+ nal_unit_header_svc_extension();
+ else
+ nal_unit_header_mvc_extension();
+ BS_End();
+ }
+
+ //Searching emulation_prevention_three_byte
+ int8u* Buffer_3Bytes=NULL;
+ const int8u* Save_Buffer=Buffer;
+ int64u Save_File_Offset=File_Offset;
+ size_t Save_Buffer_Offset=Buffer_Offset;
+ int64u Save_Element_Size=Element_Size;
+ size_t Element_Offset_3Bytes=(size_t)Element_Offset;
+ std::vector<size_t> ThreeByte_List;
+ while (Element_Offset_3Bytes+3<=Element_Size)
+ {
+ if (CC3(Buffer+Buffer_Offset+(size_t)Element_Offset_3Bytes)==0x000003)
+ ThreeByte_List.push_back(Element_Offset_3Bytes+2);
+ Element_Offset_3Bytes+=2;
+ while(Element_Offset_3Bytes<Element_Size && Buffer[Buffer_Offset+(size_t)Element_Offset_3Bytes]!=0x00)
+ Element_Offset_3Bytes+=2;
+ if (Element_Offset_3Bytes>=Element_Size || Buffer[Buffer_Offset+(size_t)Element_Offset_3Bytes-1]==0x00)
+ Element_Offset_3Bytes--;
+ }
+
+ if (!ThreeByte_List.empty())
+ {
+ //We must change the buffer for keeping out
+ Element_Size=Save_Element_Size-ThreeByte_List.size();
+ File_Offset+=Buffer_Offset;
+ Buffer_Offset=0;
+ Buffer_3Bytes=new int8u[(size_t)Element_Size];
+ for (size_t Pos=0; Pos<=ThreeByte_List.size(); Pos++)
+ {
+ size_t Pos0=(Pos==ThreeByte_List.size())?(size_t)Save_Element_Size:(ThreeByte_List[Pos]);
+ size_t Pos1=(Pos==0)?0:(ThreeByte_List[Pos-1]+1);
+ size_t Buffer_3bytes_Begin=Pos1-Pos;
+ size_t Save_Buffer_Begin =Pos1;
+ size_t Size= Pos0-Pos1;
+ std::memcpy(Buffer_3Bytes+Buffer_3bytes_Begin, Save_Buffer+Save_Buffer_Offset+Save_Buffer_Begin, Size);
+ }
+ Buffer=Buffer_3Bytes;
+ }
+
+ //Parsing
+ switch (Element_Code)
+ {
+ case 0x00 : Element_Name("unspecified"); Skip_XX(Element_Size-Element_Offset, "Data"); break;
+ case 0x01 : slice_layer_without_partitioning_non_IDR(); break;
+ case 0x02 : Element_Name("slice_data_partition_a_layer"); Skip_XX(Element_Size-Element_Offset, "Data"); break;
+ case 0x03 : Element_Name("slice_data_partition_b_layer"); Skip_XX(Element_Size-Element_Offset, "Data"); break;
+ case 0x04 : Element_Name("slice_data_partition_c_layer"); Skip_XX(Element_Size-Element_Offset, "Data"); break;
+ case 0x05 : slice_layer_without_partitioning_IDR(); break;
+ case 0x06 : sei(); break;
+ case 0x07 : seq_parameter_set(); break;
+ case 0x08 : pic_parameter_set(); break;
+ case 0x09 : access_unit_delimiter(); break;
+ case 0x0A : Element_Name("end_of_seq"); Skip_XX(Element_Size-Element_Offset, "Data"); break;
+ case 0x0B : Element_Name("end_of_stream"); Skip_XX(Element_Size-Element_Offset, "Data"); break;
+ case 0x0C : filler_data(); break;
+ case 0x0D : Element_Name("seq_parameter_set_extension"); Skip_XX(Element_Size-Element_Offset, "Data"); break;
+ case 0x0E : prefix_nal_unit(svc_extension_flag); break;
+ case 0x0F : subset_seq_parameter_set(); break;
+ case 0x13 : Element_Name("slice_layer_without_partitioning"); Skip_XX(Element_Size-Element_Offset, "Data"); break;
+ case 0x14 : slice_layer_extension(svc_extension_flag); break;
+ default :
+ if (Element_Code<0x18)
+ Element_Name("reserved");
+ else
+ Element_Name("unspecified");
+ Skip_XX(Element_Size-Element_Offset, "Data");
+ }
+
+ if (!ThreeByte_List.empty())
+ {
+ //We must change the buffer for keeping out
+ Element_Size=Save_Element_Size;
+ File_Offset=Save_File_Offset;
+ Buffer_Offset=Save_Buffer_Offset;
+ delete[] Buffer; Buffer=Save_Buffer;
+ Buffer_3Bytes=NULL; //Same as Buffer...
+ Element_Offset+=ThreeByte_List.size();
+ }
+
+ //Duplicate
+ #if MEDIAINFO_DUPLICATE
+ if (!Streams.empty() && Streams[(size_t)Element_Code].ShouldDuplicate)
+ File__Duplicate_Write(Element_Code);
+ #endif //MEDIAINFO_DUPLICATE
+
+ //Trailing zeroes
+ Element_Size=Element_Size_SaveBeforeZeroes;
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Packet "01"
+void File_Avc::slice_layer_without_partitioning_non_IDR()
+{
+ Element_Name("slice_layer_without_partitioning (non-IDR)");
+
+ //Parsing
+ slice_header();
+}
+
+//---------------------------------------------------------------------------
+// Packet "05"
+void File_Avc::slice_layer_without_partitioning_IDR()
+{
+ Element_Name("slice_layer_without_partitioning (IDR)");
+
+ //Parsing
+ slice_header();
+
+ FILLING_BEGIN_PRECISE();
+ //NextCode
+ for (int8u Pos=0x01; Pos<=0x05; Pos++)
+ NextCode_Add(Pos);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+//
+void File_Avc::slice_header()
+{
+ //Parsing
+ int32u slice_type, pic_order_cnt_lsb=(int32u)-1;
+ int32u first_mb_in_slice, pic_parameter_set_id, frame_num, num_ref_idx_l0_active_minus1, num_ref_idx_l1_active_minus1;
+ int32s delta_pic_order_cnt_bottom=0;
+ bool field_pic_flag=false, bottom_field_flag=false;
+ BS_Begin();
+ Get_UE (first_mb_in_slice, "first_mb_in_slice");
+ Get_UE (slice_type, "slice_type"); Param_Info1C((slice_type<10), Avc_slice_type[slice_type]);
+ #if MEDIAINFO_EVENTS
+ {
+ struct MediaInfo_Event_Video_SliceInfo_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_Video_SliceInfo, 0);
+ Event.Stream_Offset=File_Offset+Buffer_Offset;
+ Event.PCR=FrameInfo.PCR;
+ Event.PTS=FrameInfo.PTS;
+ Event.DTS=FrameInfo.DTS;
+ Event.DUR=FrameInfo.DUR;
+ Event.StreamIDs_Size=StreamIDs_Size;
+ Event.StreamIDs=(MediaInfo_int64u*)StreamIDs;
+ Event.StreamIDs_Width=(MediaInfo_int8u*)StreamIDs_Width;
+ Event.ParserIDs=(MediaInfo_int8u* )ParserIDs;
+ Event.FramePosition=Frame_Count;
+ Event.FieldPosition=Field_Count;
+ Event.SlicePosition=Element_IsOK()?first_mb_in_slice:(int64u)-1;
+ switch (slice_type)
+ {
+ case 0 :
+ case 3 :
+ case 5 :
+ case 8 :
+ Event.SliceType=1; break;
+ case 1 :
+ case 6 :
+ Event.SliceType=2; break;
+ case 2 :
+ case 4 :
+ case 7 :
+ case 9 :
+ Event.SliceType=0; break;
+ default:
+ Event.SliceType=(int8u)-1;
+ }
+ Event.Flags=0;
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_Video_SliceInfo_0));
+ }
+ #endif //MEDIAINFO_EVENTS
+ if (slice_type>=10)
+ {
+ BS_End();
+ Skip_XX(Element_Size-Element_Offset, "Data");
+ return;
+ }
+ Get_UE (pic_parameter_set_id, "pic_parameter_set_id");
+ std::vector<pic_parameter_set_struct*>::iterator pic_parameter_set_Item;
+ if (pic_parameter_set_id>=pic_parameter_sets.size() || (*(pic_parameter_set_Item=pic_parameter_sets.begin()+pic_parameter_set_id))==NULL || !(*pic_parameter_set_Item)->IsSynched)
+ {
+ //Not yet present
+ Skip_BS(Data_BS_Remain(), "Data (pic_parameter_set is missing)");
+ return;
+ }
+ std::vector<seq_parameter_set_struct*>::iterator seq_parameter_set_Item;
+ if ((*pic_parameter_set_Item)->seq_parameter_set_id>=seq_parameter_sets.size() || (*(seq_parameter_set_Item=seq_parameter_sets.begin()+(*pic_parameter_set_Item)->seq_parameter_set_id))==NULL || !(*seq_parameter_set_Item)->IsSynched)
+ {
+ if ((*pic_parameter_set_Item)->seq_parameter_set_id>=subset_seq_parameter_sets.size() || (*(seq_parameter_set_Item=subset_seq_parameter_sets.begin()+(*pic_parameter_set_Item)->seq_parameter_set_id))==NULL || !(*seq_parameter_set_Item)->IsSynched)
+ {
+ //Not yet present
+ Skip_BS(Data_BS_Remain(), "Data (seq_parameter_set is missing)");
+ return;
+ }
+ }
+ num_ref_idx_l0_active_minus1=(*pic_parameter_set_Item)->num_ref_idx_l0_default_active_minus1; //Default
+ num_ref_idx_l1_active_minus1=(*pic_parameter_set_Item)->num_ref_idx_l1_default_active_minus1; //Default
+ Get_BS ((*seq_parameter_set_Item)->log2_max_frame_num_minus4+4, frame_num, "frame_num");
+ if (!(*seq_parameter_set_Item)->frame_mbs_only_flag)
+ {
+ TEST_SB_GET(field_pic_flag, "field_pic_flag");
+ Get_SB (bottom_field_flag, "bottom_field_flag");
+ TEST_SB_END();
+ }
+ if (Element_Code==5)
+ Skip_UE( "idr_pic_id");
+ if ((*seq_parameter_set_Item)->pic_order_cnt_type==0)
+ {
+ Get_BS ((*seq_parameter_set_Item)->log2_max_pic_order_cnt_lsb_minus4+4, pic_order_cnt_lsb, "pic_order_cnt_lsb");
+ if ((*pic_parameter_set_Item)->bottom_field_pic_order_in_frame_present_flag && !field_pic_flag)
+ Get_SE (delta_pic_order_cnt_bottom, "delta_pic_order_cnt_bottom");
+ }
+ if ((*seq_parameter_set_Item)->pic_order_cnt_type==1 && !(*seq_parameter_set_Item)->delta_pic_order_always_zero_flag )
+ {
+ Skip_SE( "delta_pic_order_cnt[0]");
+ if((*pic_parameter_set_Item)->bottom_field_pic_order_in_frame_present_flag && !field_pic_flag)
+ Skip_SE( "delta_pic_order_cnt[1]");
+ }
+ if((*pic_parameter_set_Item)->redundant_pic_cnt_present_flag)
+ Skip_UE( "redundant_pic_cnt");
+ if (slice_type==1 || slice_type==6) //B-Frame
+ Skip_SB( "direct_spatial_mv_pred_flag");
+ switch (slice_type)
+ {
+ case 0 : //P-Frame
+ case 1 : //B-Frame
+ case 3 : //SP-Frame
+ case 5 : //P-Frame
+ case 6 : //B-Frame
+ case 8 : //SP-Frame
+ TEST_SB_SKIP( "num_ref_idx_active_override_flag");
+ Get_UE (num_ref_idx_l0_active_minus1, "num_ref_idx_l0_active_minus1");
+ switch (slice_type)
+ {
+ case 1 : //B-Frame
+ case 6 : //B-Frame
+ Get_UE (num_ref_idx_l1_active_minus1, "num_ref_idx_l1_active_minus1");
+ break;
+ default: ;
+ }
+ TEST_SB_END();
+ break;
+ default: ;
+ }
+ ref_pic_list_modification(slice_type, Element_Code==20); //nal_unit_type==20 --> ref_pic_list_mvc_modification()
+ if (((*pic_parameter_set_Item)->weighted_pred_flag && (slice_type==0 || slice_type==3 || slice_type==5 || slice_type==8))
+ || ((*pic_parameter_set_Item)->weighted_bipred_idc==1 && (slice_type==1 || slice_type==6)))
+ pred_weight_table(num_ref_idx_l0_active_minus1, num_ref_idx_l1_active_minus1, (*seq_parameter_set_Item)->ChromaArrayType());
+ std::vector<int8u> memory_management_control_operations;
+ if (nal_ref_idc)
+ dec_ref_pic_marking(memory_management_control_operations);
+
+ //TODO...
+ BS_End();
+ Skip_XX(Element_Size-Element_Offset, "ToDo...");
+
+ FILLING_BEGIN_PRECISE();
+ //Count of I-Frames
+ if (first_mb_in_slice==0 && Element_Code!=20 && (slice_type==2 || slice_type==7)) //Not slice_layer_extension, I-Frame
+ IFrame_Count++;
+
+ //pic_struct
+ if (field_pic_flag && (*seq_parameter_set_Item)->pic_struct_FirstDetected==(int8u)-1)
+ (*seq_parameter_set_Item)->pic_struct_FirstDetected=bottom_field_flag?2:1; //2=BFF, 1=TFF
+
+ //Saving some info
+ int32s TemporalReferences_Offset_pic_order_cnt_lsb_Diff=0;
+ if ((*seq_parameter_set_Item)->pic_order_cnt_type!=1 && first_mb_in_slice==0 && Element_Code!=0x14) //Not slice_layer_extension
+ {
+ if (field_pic_flag)
+ {
+ Structure_Field++;
+ if (bottom_field_flag)
+ Interlaced_Bottom++;
+ else
+ Interlaced_Top++;
+ }
+ else
+ Structure_Frame++;
+
+ //Frame order detection
+ int64s pic_order_cnt=0;
+ switch ((*seq_parameter_set_Item)->pic_order_cnt_type)
+ {
+ case 0 :
+ {
+ if (Element_Code==5) //IDR
+ {
+ prevPicOrderCntMsb=0;
+ prevPicOrderCntLsb=0;
+ TemporalReferences_Offset=TemporalReferences_Max;
+ if (TemporalReferences_Offset%2)
+ TemporalReferences_Offset++;
+ TemporalReferences_pic_order_cnt_Min=0;
+ }
+ else
+ {
+ bool Has5=false;
+ for (std::vector<int8u>::iterator Temp=memory_management_control_operations.begin(); Temp!=memory_management_control_operations.end(); Temp++)
+ if ((*Temp)==5)
+ {
+ Has5=true;
+ break;
+ }
+ if (Has5)
+ {
+ prevPicOrderCntMsb=0;
+ if (bottom_field_flag)
+ prevPicOrderCntLsb=0;
+ else
+ prevPicOrderCntLsb=prevTopFieldOrderCnt;
+ }
+ }
+ int32s PicOrderCntMsb;
+ if (prevPicOrderCntLsb==(int32u)-1)
+ {
+ PicOrderCntMsb=0;
+ if ((int32u)(2*((*seq_parameter_set_Item)->max_num_ref_frames+3))<pic_order_cnt_lsb)
+ TemporalReferences_Min=pic_order_cnt_lsb-2*((*seq_parameter_set_Item)->max_num_ref_frames+3);
+ }
+ else if (pic_order_cnt_lsb<prevPicOrderCntLsb && prevPicOrderCntLsb-pic_order_cnt_lsb>=(*seq_parameter_set_Item)->MaxPicOrderCntLsb/2)
+ PicOrderCntMsb=prevPicOrderCntMsb+(*seq_parameter_set_Item)->MaxPicOrderCntLsb;
+ else if (pic_order_cnt_lsb>prevPicOrderCntLsb && pic_order_cnt_lsb-prevPicOrderCntLsb>(*seq_parameter_set_Item)->MaxPicOrderCntLsb/2)
+ PicOrderCntMsb=prevPicOrderCntMsb-(*seq_parameter_set_Item)->MaxPicOrderCntLsb;
+ else
+ PicOrderCntMsb=prevPicOrderCntMsb;
+
+ int32s TopFieldOrderCnt=PicOrderCntMsb+pic_order_cnt_lsb;
+ int32s BottomFieldOrderCnt;
+ if (field_pic_flag)
+ BottomFieldOrderCnt=TopFieldOrderCnt+delta_pic_order_cnt_bottom;
+ else
+ BottomFieldOrderCnt=PicOrderCntMsb+pic_order_cnt_lsb;
+
+ prevPicOrderCntMsb=PicOrderCntMsb;
+ prevPicOrderCntLsb=pic_order_cnt_lsb;
+ prevTopFieldOrderCnt=TopFieldOrderCnt;
+
+ pic_order_cnt=bottom_field_flag?BottomFieldOrderCnt:TopFieldOrderCnt;
+ }
+ break;
+ case 2 :
+ {
+ bool Has5=false;
+ for (std::vector<int8u>::iterator Temp=memory_management_control_operations.begin(); Temp!=memory_management_control_operations.end(); Temp++)
+ if ((*Temp)==5)
+ {
+ Has5=true;
+ break;
+ }
+ if (Has5)
+ prevFrameNumOffset=0;
+ int32u FrameNumOffset;
+
+ if (Element_Code==5) //IdrPicFlag
+ {
+ TemporalReferences_Offset=TemporalReferences_Max;
+ if (TemporalReferences_Offset%2)
+ TemporalReferences_Offset++;
+ FrameNumOffset=0;
+ }
+ else if (prevFrameNumOffset==(int32u)-1)
+ FrameNumOffset=0;
+ else if (prevFrameNum>frame_num)
+ FrameNumOffset=prevFrameNumOffset+(*seq_parameter_set_Item)->MaxFrameNum;
+ else
+ FrameNumOffset=prevFrameNumOffset;
+
+ int32u tempPicOrderCnt;
+ if (Element_Code==5) //IdrPicFlag
+ tempPicOrderCnt=0;
+ else if (nal_ref_idc)
+ tempPicOrderCnt=2*(FrameNumOffset+frame_num);
+ else
+ tempPicOrderCnt=2*(FrameNumOffset+frame_num)-1;
+
+ pic_order_cnt=tempPicOrderCnt;
+
+ prevFrameNum=frame_num;
+ prevFrameNumOffset=FrameNumOffset;
+
+ pic_order_cnt_lsb=frame_num;
+ }
+ break;
+ default: ;
+ }
+
+ if (pic_order_cnt<TemporalReferences_pic_order_cnt_Min)
+ {
+ if (pic_order_cnt<0)
+ {
+ size_t Base=(size_t)(TemporalReferences_Offset+TemporalReferences_pic_order_cnt_Min);
+ size_t ToInsert=(size_t)(TemporalReferences_pic_order_cnt_Min-pic_order_cnt);
+ if (Base+ToInsert>=4*TemporalReferences_Reserved || Base>=4*TemporalReferences_Reserved || ToInsert+TemporalReferences_Max>=4*TemporalReferences_Reserved || TemporalReferences_Max>=4*TemporalReferences_Reserved || TemporalReferences_Max-Base>=4*TemporalReferences_Reserved)
+ {
+ Trusted_IsNot("Problem in temporal references");
+ return;
+ }
+ Element_Info1(_T("Offset of ")+Ztring::ToZtring(ToInsert));
+ TemporalReferences.insert(TemporalReferences.begin()+Base, ToInsert, NULL);
+ TemporalReferences_Offset+=ToInsert;
+ TemporalReferences_Max+=ToInsert;
+ TemporalReferences_pic_order_cnt_Min=pic_order_cnt;
+ }
+ else if (TemporalReferences_Min>(size_t)(TemporalReferences_Offset+pic_order_cnt))
+ TemporalReferences_Min=(size_t)(TemporalReferences_Offset+pic_order_cnt);
+ }
+
+ if (TemporalReferences_Offset+pic_order_cnt>=3*TemporalReferences_Reserved)
+ {
+ size_t Offset=TemporalReferences_Max-TemporalReferences_Offset;
+ if (Offset%2)
+ Offset++;
+ if (Offset>=TemporalReferences_Reserved && pic_order_cnt>=(int64s)TemporalReferences_Reserved)
+ {
+ TemporalReferences_Offset+=TemporalReferences_Reserved;
+ pic_order_cnt-=TemporalReferences_Reserved;
+ switch ((*seq_parameter_set_Item)->pic_order_cnt_type)
+ {
+ case 0 :
+ prevPicOrderCntMsb-=(int32u)TemporalReferences_Reserved;
+ break;
+ case 2 :
+ prevFrameNumOffset-=(int32u)TemporalReferences_Reserved/2;
+ break;
+ default:;
+ }
+ }
+ else if (Offset && Offset<=2) //Only I-frames
+ TemporalReferences_Offset+=2;
+ while (TemporalReferences_Offset+pic_order_cnt>=3*TemporalReferences_Reserved)
+ {
+ for (size_t Pos=0; Pos<TemporalReferences_Reserved; Pos++)
+ {
+ if (TemporalReferences[Pos])
+ {
+ if ((Pos%2)==0)
+ PictureTypes_PreviousFrames+=Avc_slice_type[TemporalReferences[Pos]->slice_type];
+ }
+ else if (!PictureTypes_PreviousFrames.empty()) //Only if stream already started
+ {
+ if ((Pos%2)==0)
+ PictureTypes_PreviousFrames+=' ';
+ }
+ delete TemporalReferences[Pos];
+ }
+ if (PictureTypes_PreviousFrames.size()>=8*TemporalReferences.size())
+ PictureTypes_PreviousFrames.erase(PictureTypes_PreviousFrames.begin(), PictureTypes_PreviousFrames.begin()+PictureTypes_PreviousFrames.size()-TemporalReferences.size());
+ TemporalReferences.erase(TemporalReferences.begin(), TemporalReferences.begin()+TemporalReferences_Reserved);
+ TemporalReferences.resize(4*TemporalReferences_Reserved);
+ if (TemporalReferences_Reserved<TemporalReferences_Offset)
+ TemporalReferences_Offset-=TemporalReferences_Reserved;
+ else
+ TemporalReferences_Offset=0;
+ if (TemporalReferences_Reserved<TemporalReferences_Min)
+ TemporalReferences_Min-=TemporalReferences_Reserved;
+ else
+ TemporalReferences_Min=0;
+ if (TemporalReferences_Reserved<TemporalReferences_Max)
+ TemporalReferences_Max-=TemporalReferences_Reserved;
+ else
+ TemporalReferences_Max=0;
+ }
+ }
+
+ TemporalReferences_Offset_pic_order_cnt_lsb_Diff=(int32s)((int32s)(TemporalReferences_Offset+pic_order_cnt)-TemporalReferences_Offset_pic_order_cnt_lsb_Last);
+ TemporalReferences_Offset_pic_order_cnt_lsb_Last=(size_t)(TemporalReferences_Offset+pic_order_cnt);
+ if (TemporalReferences_Max<=TemporalReferences_Offset_pic_order_cnt_lsb_Last)
+ TemporalReferences_Max=TemporalReferences_Offset_pic_order_cnt_lsb_Last+((*seq_parameter_set_Item)->frame_mbs_only_flag?2:1);
+ if (TemporalReferences_Min>TemporalReferences_Offset_pic_order_cnt_lsb_Last)
+ TemporalReferences_Min=TemporalReferences_Offset_pic_order_cnt_lsb_Last;
+ if (TemporalReferences_DelayedElement)
+ {
+ delete TemporalReferences[TemporalReferences_Offset_pic_order_cnt_lsb_Last]; TemporalReferences[TemporalReferences_Offset_pic_order_cnt_lsb_Last]=TemporalReferences_DelayedElement;
+ }
+ if (TemporalReferences[TemporalReferences_Offset_pic_order_cnt_lsb_Last]==NULL)
+ TemporalReferences[TemporalReferences_Offset_pic_order_cnt_lsb_Last]=new temporal_reference();
+ TemporalReferences[TemporalReferences_Offset_pic_order_cnt_lsb_Last]->frame_num=frame_num;
+ TemporalReferences[TemporalReferences_Offset_pic_order_cnt_lsb_Last]->slice_type=(int8u)slice_type;
+ TemporalReferences[TemporalReferences_Offset_pic_order_cnt_lsb_Last]->IsTop=!bottom_field_flag;
+ TemporalReferences[TemporalReferences_Offset_pic_order_cnt_lsb_Last]->IsField=field_pic_flag;
+ if (TemporalReferences_DelayedElement)
+ {
+ TemporalReferences_DelayedElement=NULL;
+ sei_message_user_data_registered_itu_t_t35_GA94_03_Delayed((*pic_parameter_set_Item)->seq_parameter_set_id);
+ }
+ }
+
+ if ((*seq_parameter_set_Item)->vui_parameters && (*seq_parameter_set_Item)->vui_parameters->num_units_in_tick)
+ tc=float64_int64s(((float64)1000000000)/((float64)(*seq_parameter_set_Item)->vui_parameters->time_scale/(*seq_parameter_set_Item)->vui_parameters->num_units_in_tick/((*seq_parameter_set_Item)->pic_order_cnt_type==2?1:2)/FrameRate_Divider)/((!(*seq_parameter_set_Item)->frame_mbs_only_flag && field_pic_flag)?2:1));
+ if (first_mb_in_slice==0)
+ {
+ if (Frame_Count==0)
+ {
+ if (FrameInfo.PTS==(int64u)-1)
+ FrameInfo.PTS=FrameInfo.DTS+tc*(TemporalReferences_Offset_pic_order_cnt_lsb_Diff?2:1)*((!(*seq_parameter_set_Item)->frame_mbs_only_flag && field_pic_flag)?2:1); //No PTS in container
+ PTS_Begin=FrameInfo.PTS;
+ }
+ if (slice_type==2 || slice_type==7) //IFrame
+ FirstPFrameInGop_IsParsed=false;
+ }
+ else
+ {
+ if (FrameInfo.PTS!=(int64u)-1)
+ FrameInfo.PTS-=tc;
+ if (FrameInfo.DTS!=(int64u)-1)
+ FrameInfo.DTS-=tc;
+ }
+
+ //Frame pos
+ if (Frame_Count!=(int64u)-1 && Frame_Count && ((!(*seq_parameter_set_Item)->frame_mbs_only_flag && Interlaced_Top==Interlaced_Bottom && field_pic_flag) || first_mb_in_slice!=0 || (Element_Code==0x14 && !seq_parameter_sets.empty())))
+ {
+ Frame_Count--;
+ if (IFrame_Count && Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded--;
+ Frame_Count_InThisBlock--;
+ }
+ else if (first_mb_in_slice==0)
+ {
+ if ((*seq_parameter_set_Item)->pic_order_cnt_type!=1 && first_mb_in_slice==0 && Element_Code!=0x14) //Not slice_layer_extension
+ {
+ if ((!IsSub || Frame_Count_InThisBlock) && TemporalReferences_Offset_pic_order_cnt_lsb_Diff && TemporalReferences_Offset_pic_order_cnt_lsb_Diff!=2)
+ FrameInfo.PTS+=(TemporalReferences_Offset_pic_order_cnt_lsb_Diff-(field_pic_flag?1:2))/((!(*seq_parameter_set_Item)->frame_mbs_only_flag && field_pic_flag)?1:2)*(int64s)tc;
+ }
+
+ if (!FirstPFrameInGop_IsParsed && (slice_type==0 || slice_type==5)) //P-Frame
+ {
+ FirstPFrameInGop_IsParsed=true;
+
+ //Testing if we have enough to test GOP
+ if (Frame_Count<=Frame_Count_Valid)
+ {
+ std::string PictureTypes(PictureTypes_PreviousFrames);
+ PictureTypes.reserve(TemporalReferences.size());
+ for (size_t Pos=0; Pos<TemporalReferences.size(); Pos++)
+ if (TemporalReferences[Pos])
+ {
+ if ((Pos%2)==0)
+ PictureTypes+=Avc_slice_type[TemporalReferences[Pos]->slice_type];
+ }
+ else if (!PictureTypes.empty()) //Only if stream already started
+ {
+ if ((Pos%2)==0)
+ PictureTypes+=' ';
+ }
+ if (!GOP_Detect(PictureTypes).empty())
+ Frame_Count_Valid=Frame_Count; //We have enough frames
+ }
+ }
+ }
+
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ Element_Info1(TemporalReferences_Offset_pic_order_cnt_lsb_Last);
+ Element_Info1((((*seq_parameter_set_Item)->frame_mbs_only_flag || !field_pic_flag)?_T("Frame "):(bottom_field_flag?_T("Field (Bottom) "):_T("Field (Top) ")))+Ztring::ToZtring(Frame_Count));
+ if (slice_type<9)
+ Element_Info1(_T("slice_type ")+Ztring().From_Local(Avc_slice_type[slice_type]));
+ Element_Info1(_T("frame_num ")+Ztring::ToZtring(frame_num));
+ if ((*seq_parameter_set_Item)->vui_parameters && (*seq_parameter_set_Item)->vui_parameters->fixed_frame_rate_flag)
+ {
+ if (FrameInfo.PCR!=(int64u)-1)
+ Element_Info1(_T("PCR ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.PCR)/1000000)));
+ if (FrameInfo.DTS!=(int64u)-1)
+ Element_Info1(_T("DTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.DTS)/1000000)));
+ if (FrameInfo.PTS!=(int64u)-1)
+ Element_Info1(_T("PTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/1000000)));
+ }
+ if ((*seq_parameter_set_Item)->pic_order_cnt_type==0)
+ Element_Info1(_T("pic_order_cnt_lsb ")+Ztring::ToZtring(pic_order_cnt_lsb));
+ if (first_mb_in_slice)
+ Element_Info1(_T("first_mb_in_slice ")+Ztring::ToZtring(first_mb_in_slice));
+ }
+ #endif //MEDIAINFO_TRACE
+
+ //Counting
+ if (Frame_Count!=(int64u)-1)
+ {
+ if (File_Offset+Buffer_Offset+Element_Size==File_Size)
+ Frame_Count_Valid=Frame_Count; //Finish frames in case of there are less than Frame_Count_Valid frames
+ Frame_Count++;
+ if (IFrame_Count && Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ Frame_Count_InThisBlock++;
+ }
+ if ((*seq_parameter_set_Item)->pic_order_cnt_type==0 && field_pic_flag)
+ {
+ Field_Count++;
+ Field_Count_InThisBlock++;
+ }
+ if (FrameInfo.PTS!=(int64u)-1)
+ FrameInfo.PTS+=tc;
+ if (FrameInfo.DTS!=(int64u)-1)
+ FrameInfo.DTS+=tc;
+ if (FrameInfo.PTS!=(int64u)-1 && PTS_End<FrameInfo.PTS)
+ PTS_End=FrameInfo.PTS;
+
+ #if MEDIAINFO_DUPLICATE
+ if (Streams[(size_t)Element_Code].ShouldDuplicate)
+ File__Duplicate_Write(Element_Code, (*seq_parameter_set_Item)->pic_order_cnt_type==0?pic_order_cnt_lsb:frame_num);
+ #endif //MEDIAINFO_DUPLICATE
+
+ //Filling only if not already done
+ if (Frame_Count==1 && !Status[IsAccepted])
+ Accept("AVC");
+ if (!Status[IsFilled])
+ {
+ if (IFrame_Count>=8)
+ Frame_Count_Valid=Frame_Count; //We have enough frames
+ #ifdef MEDIAINFO_DTVCCTRANSPORT_YES
+ if (((!GA94_03_IsPresent && Frame_Count>=Frame_Count_Valid) || Frame_Count>=512)) //Going more far if captions are detected
+ #else //MEDIAINFO_DTVCCTRANSPORT_YES
+ if (Frame_Count>=Frame_Count_Valid)
+ #endif //MEDIAINFO_DTVCCTRANSPORT_YES
+ {
+ Fill("AVC");
+ if (!IsSub && !Streams[(size_t)Element_Code].ShouldDuplicate && MediaInfoLib::Config.ParseSpeed_Get()<1.0)
+ Finish("AVC");
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+//
+void File_Avc::ref_pic_list_modification(int32u slice_type, bool mvc)
+{
+ if ((slice_type%5)!=2 && (slice_type%5)!=4)
+ {
+ TEST_SB_SKIP( "ref_pic_list_modification_flag_l0");
+ int32u modification_of_pic_nums_idc;
+ do
+ {
+ Get_UE (modification_of_pic_nums_idc, "modification_of_pic_nums_idc");
+ if (modification_of_pic_nums_idc<2)
+ Skip_UE( "abs_diff_pic_num_minus1");
+ else if (modification_of_pic_nums_idc==2)
+ Skip_UE( "long_term_pic_num");
+ else if (mvc && (modification_of_pic_nums_idc==4 || modification_of_pic_nums_idc==5)) //ref_pic_list_mvc_modification only
+ Skip_UE( "abs_diff_view_idx_minus1");
+ else if (modification_of_pic_nums_idc!=3)
+ {
+ Trusted_IsNot("ref_pic_list_modification_flag_l0");
+ Skip_BS(Data_BS_Remain(), "(Remaining bits)");
+ }
+ }
+ while (modification_of_pic_nums_idc!=3 && Data_BS_Remain());
+ TEST_SB_END();
+ }
+ if ((slice_type%5)==1)
+ {
+ TEST_SB_SKIP( "ref_pic_list_modification_flag_l1");
+ int32u modification_of_pic_nums_idc;
+ do
+ {
+ Get_UE (modification_of_pic_nums_idc, "modification_of_pic_nums_idc");
+ if (modification_of_pic_nums_idc<2)
+ Skip_UE( "abs_diff_pic_num_minus1");
+ else if (modification_of_pic_nums_idc==2)
+ Skip_UE( "long_term_pic_num");
+ else if (mvc && (modification_of_pic_nums_idc==4 || modification_of_pic_nums_idc==5)) //ref_pic_list_mvc_modification only
+ Skip_UE( "abs_diff_view_idx_minus1");
+ else if (modification_of_pic_nums_idc!=3)
+ {
+ Trusted_IsNot("ref_pic_list_modification_flag_l1");
+ Skip_BS(Data_BS_Remain(), "(Remaining bits)");
+ }
+ }
+ while (modification_of_pic_nums_idc!=3 && Data_BS_Remain());
+ TEST_SB_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+//
+void File_Avc::pred_weight_table(int32u num_ref_idx_l0_active_minus1, int32u num_ref_idx_l1_active_minus1, int8u ChromaArrayType)
+{
+ Skip_UE( "luma_log2_weight_denom");
+ if (ChromaArrayType)
+ Skip_UE( "chroma_log2_weight_denom");
+ for(int32u i=0; i<=num_ref_idx_l0_active_minus1; i++)
+ {
+ TEST_SB_SKIP( "luma_weight_l0_flag");
+ Skip_SE( "luma_weight_l0");
+ Skip_SE( "luma_offset_l0");
+ TEST_SB_END();
+ }
+ if (ChromaArrayType)
+ {
+ TEST_SB_SKIP( "chroma_weight_l0_flag");
+ Skip_SE( "chroma_weight_l0");
+ Skip_SE( "chroma_offset_l0");
+ TEST_SB_END();
+ }
+}
+
+//---------------------------------------------------------------------------
+//
+void File_Avc::dec_ref_pic_marking(std::vector<int8u> &memory_management_control_operations)
+{
+ if (Element_Code==5) //IdrPicFlag
+ {
+ Skip_SB( "no_output_of_prior_pics_flag");
+ Skip_SB( "long_term_reference_flag");
+ }
+ else
+ {
+ TEST_SB_SKIP( "adaptive_ref_pic_marking_mode_flag");
+ int32u memory_management_control_operation;
+ do
+ {
+ Get_UE (memory_management_control_operation, "memory_management_control_operation");
+ switch (memory_management_control_operation)
+ {
+ case 1 :
+ Skip_UE( "difference_of_pic_nums_minus1");
+ break;
+ case 2 :
+ Skip_UE( "long_term_pic_num");
+ break;
+ case 3 :
+ Skip_UE( "difference_of_pic_nums_minus1");
+ //break; 3 --> difference_of_pic_nums_minus1 then long_term_frame_idx
+ case 6 :
+ Skip_UE( "long_term_frame_idx");
+ break;
+ case 4 :
+ Skip_UE( "max_long_term_frame_idx_plus1");
+ break;
+ }
+ memory_management_control_operations.push_back((int8u)memory_management_control_operation);
+ }
+ while (Data_BS_Remain() && memory_management_control_operation);
+ TEST_SB_END()
+ }
+}
+
+//---------------------------------------------------------------------------
+// Packet "06"
+void File_Avc::sei()
+{
+ Element_Name("sei");
+
+ //Parsing
+ int32u seq_parameter_set_id=(int32u)-1;
+ while(Element_Offset+1<Element_Size)
+ {
+ Element_Begin1("sei message");
+ sei_message(seq_parameter_set_id);
+ Element_End0();
+ }
+ BS_Begin();
+ Mark_1( );
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::sei_message(int32u &seq_parameter_set_id)
+{
+ //Parsing
+ int32u payloadType=0, payloadSize=0;
+ int8u payload_type_byte, payload_size_byte;
+ Element_Begin1("sei message header");
+ do
+ {
+ Get_B1 (payload_type_byte, "payload_type_byte");
+ payloadType+=payload_type_byte;
+ }
+ while(payload_type_byte==0xFF);
+ do
+ {
+ Get_B1 (payload_size_byte, "payload_size_byte");
+ payloadSize+=payload_size_byte;
+ }
+ while(payload_size_byte==0xFF);
+ Element_End0();
+
+ int64u Element_Offset_Save=Element_Offset+payloadSize;
+ int64u Element_Size_Save=Element_Size;
+ Element_Size=Element_Offset_Save;
+ switch (payloadType)
+ {
+ case 0 : sei_message_buffering_period(seq_parameter_set_id); break;
+ case 1 : sei_message_pic_timing(payloadSize, seq_parameter_set_id); break;
+ case 4 : sei_message_user_data_registered_itu_t_t35(); break;
+ case 5 : sei_message_user_data_unregistered(payloadSize); break;
+ case 6 : sei_message_recovery_point(); break;
+ case 32 : sei_message_mainconcept(payloadSize); break;
+ default :
+ Element_Info1("unknown");
+ Skip_XX(payloadSize, "data");
+ }
+ Element_Offset=Element_Offset_Save; //Positionning in the right place.
+ Element_Size=Element_Size_Save; //Positionning in the right place.
+}
+
+//---------------------------------------------------------------------------
+// SEI - 0
+void File_Avc::sei_message_buffering_period(int32u &seq_parameter_set_id)
+{
+ Element_Info1("buffering_period");
+
+ //Parsing
+ BS_Begin();
+ Get_UE (seq_parameter_set_id, "seq_parameter_set_id");
+ std::vector<seq_parameter_set_struct*>::iterator seq_parameter_set_Item;
+ if (seq_parameter_set_id>=seq_parameter_sets.size() || (*(seq_parameter_set_Item=seq_parameter_sets.begin()+seq_parameter_set_id))==NULL || !(*seq_parameter_set_Item)->IsSynched)
+ {
+ //Not yet present
+ Skip_BS(Data_BS_Remain(), "Data (seq_parameter_set is missing)");
+ return;
+ }
+ if ((*seq_parameter_set_Item)->NalHrdBpPresentFlag())
+ sei_message_buffering_period_xxl((*seq_parameter_set_Item)->vui_parameters->NAL);
+ if ((*seq_parameter_set_Item)->VclHrdBpPresentFlag())
+ sei_message_buffering_period_xxl((*seq_parameter_set_Item)->vui_parameters->VCL);
+ BS_End();
+}
+
+void File_Avc::sei_message_buffering_period_xxl(void* xxl_)
+{
+ if (xxl_==NULL)
+ return;
+ seq_parameter_set_struct::vui_parameters_struct::xxl* xxl=(seq_parameter_set_struct::vui_parameters_struct::xxl*)xxl_;
+ for (int32u SchedSelIdx=0; SchedSelIdx<xxl->SchedSel.size(); SchedSelIdx++)
+ {
+ Get_S4 (xxl->initial_cpb_removal_delay_length_minus1+1, xxl->SchedSel[SchedSelIdx].initial_cpb_removal_delay, "initial_cpb_removal_delay"); Param_Info2(xxl->SchedSel[SchedSelIdx].initial_cpb_removal_delay/90, " ms");
+ Get_S4 (xxl->initial_cpb_removal_delay_length_minus1+1, xxl->SchedSel[SchedSelIdx].initial_cpb_removal_delay_offset, "initial_cpb_removal_delay_offset"); Param_Info2(xxl->SchedSel[SchedSelIdx].initial_cpb_removal_delay_offset/90, " ms");
+ }
+}
+
+//---------------------------------------------------------------------------
+// SEI - 1
+void File_Avc::sei_message_pic_timing(int32u /*payloadSize*/, int32u seq_parameter_set_id)
+{
+ Element_Info1("pic_timing");
+
+ //Testing if we can parsing it now. TODO: handle case seq_parameter_set_id is unknown (buffering of message, decoding in slice parsing)
+ if (seq_parameter_set_id==(int32u)-1 && seq_parameter_sets.size()==1)
+ seq_parameter_set_id=0;
+ std::vector<seq_parameter_set_struct*>::iterator seq_parameter_set_Item;
+ if (seq_parameter_set_id>=seq_parameter_sets.size() || (*(seq_parameter_set_Item=seq_parameter_sets.begin()+seq_parameter_set_id))==NULL || !(*seq_parameter_set_Item)->IsSynched)
+ {
+ //Not yet present
+ Skip_BS(Data_BS_Remain(), "Data (seq_parameter_set is missing)");
+ return;
+ }
+
+ //Parsing
+ int8u pic_struct=(int8u)-1;
+ BS_Begin();
+ if ((*seq_parameter_set_Item)->CpbDpbDelaysPresentFlag())
+ {
+ int8u cpb_removal_delay_length_minus1=(*seq_parameter_set_Item)->vui_parameters->NAL?(*seq_parameter_set_Item)->vui_parameters->NAL->cpb_removal_delay_length_minus1:(*seq_parameter_set_Item)->vui_parameters->VCL->cpb_removal_delay_length_minus1; //Spec is not precise, I am not sure
+ int8u dpb_output_delay_length_minus1=(*seq_parameter_set_Item)->vui_parameters->NAL?(*seq_parameter_set_Item)->vui_parameters->NAL->dpb_output_delay_length_minus1:(*seq_parameter_set_Item)->vui_parameters->VCL->dpb_output_delay_length_minus1; //Spec is not precise, I am not sure
+ Skip_S4(cpb_removal_delay_length_minus1+1, "cpb_removal_delay");
+ Skip_S4(dpb_output_delay_length_minus1+1, "dpb_output_delay");
+ }
+ if ((*seq_parameter_set_Item)->vui_parameters && (*seq_parameter_set_Item)->vui_parameters->pic_struct_present_flag)
+ {
+ Get_S1 (4, pic_struct, "pic_struct");
+ switch (pic_struct)
+ {
+ case 0 :
+ case 1 :
+ case 2 :
+ case 3 :
+ case 4 :
+ case 5 :
+ case 6 : break;
+ case 7 : FrameRate_Divider=2; break;
+ case 8 : FrameRate_Divider=3; break;
+ default : Param_Info1("Reserved"); return; //NumClockTS is unknown
+ }
+ Param_Info1(Avc_pic_struct[pic_struct]);
+ int8u NumClockTS=Avc_NumClockTS[pic_struct];
+ int8u seconds_value=0, minutes_value=0, hours_value=0; //Here because theses values can be reused in later ClockTSs.
+ for (int8u i=0; i<NumClockTS; i++)
+ {
+ Element_Begin1("ClockTS");
+ TEST_SB_SKIP( "clock_timestamp_flag");
+ Ztring TimeStamp;
+ int32u time_offset=0;
+ int8u n_frames;
+ bool full_timestamp_flag, nuit_field_based_flag;
+ Info_S1(2, ct_type, "ct_type"); Param_Info1(Avc_ct_type[ct_type]);
+ Get_SB ( nuit_field_based_flag, "nuit_field_based_flag");
+ Skip_S1(5, "counting_type");
+ Get_SB ( full_timestamp_flag, "full_timestamp_flag");
+ Skip_SB( "discontinuity_flag");
+ Skip_SB( "cnt_dropped_flag");
+ Get_S1 (8, n_frames, "n_frames");
+ if (full_timestamp_flag)
+ {
+ Get_S1 (6, seconds_value, "seconds_value");
+ Get_S1 (6, minutes_value, "minutes_value");
+ Get_S1 (5, hours_value, "hours_value");
+ }
+ else
+ {
+ TEST_SB_SKIP( "seconds_flag");
+ Get_S1 (6, seconds_value, "seconds_value");
+ TEST_SB_SKIP( "minutes_flag");
+ Get_S1 (6, minutes_value, "minutes_value");
+ TEST_SB_SKIP( "hours_flag");
+ Get_S1 (5, hours_value, "hours_value");
+ TEST_SB_END();
+ TEST_SB_END();
+ TEST_SB_END();
+ }
+ TimeStamp=Ztring::ToZtring(hours_value)+_T(':')+Ztring::ToZtring(minutes_value)+_T(':')+Ztring::ToZtring(seconds_value);
+ if ((*seq_parameter_set_Item)->CpbDpbDelaysPresentFlag())
+ {
+ int8u time_offset_length=(*seq_parameter_set_Item)->vui_parameters->NAL?(*seq_parameter_set_Item)->vui_parameters->NAL->time_offset_length:(*seq_parameter_set_Item)->vui_parameters->VCL->time_offset_length; //Spec is not precise, I am not sure
+ if (time_offset_length)
+ Get_S4 (time_offset_length, time_offset, "time_offset");
+ }
+ if ((*seq_parameter_set_Item)->vui_parameters && (*seq_parameter_set_Item)->vui_parameters->time_scale)
+ {
+ float32 Milliseconds=((float32)(n_frames*((*seq_parameter_set_Item)->vui_parameters->num_units_in_tick*(1+(nuit_field_based_flag?1:0)))+time_offset))/(*seq_parameter_set_Item)->vui_parameters->time_scale;
+ TimeStamp+=_T('.');
+ TimeStamp+=Ztring::ToZtring(Milliseconds);
+ }
+ Param_Info1(TimeStamp);
+ TEST_SB_END();
+ Element_End0();
+ }
+ }
+ BS_End();
+
+ FILLING_BEGIN();
+ if ((*seq_parameter_set_Item)->pic_struct_FirstDetected==(int8u)-1 && (*seq_parameter_set_Item)->vui_parameters && (*seq_parameter_set_Item)->vui_parameters->pic_struct_present_flag)
+ (*seq_parameter_set_Item)->pic_struct_FirstDetected=pic_struct;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// SEI - 5
+void File_Avc::sei_message_user_data_registered_itu_t_t35()
+{
+ Element_Info1("user_data_registered_itu_t_t35");
+
+ //Parsing
+ int8u itu_t_t35_country_code;
+ Get_B1 (itu_t_t35_country_code, "itu_t_t35_country_code");
+ if (itu_t_t35_country_code==0xFF)
+ Skip_B1( "itu_t_t35_country_code_extension_byte");
+ if (itu_t_t35_country_code!=0xB5 || Element_Offset+2>=Element_Size)
+ {
+ if (Element_Size-Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ return;
+ }
+
+ //United-States
+ int16u id;
+ Get_B2 (id, "id?");
+ if (id!=0x0031 || Element_Offset+4>=Element_Size)
+ {
+ if (Element_Size-Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ return;
+ }
+
+ int32u Identifier;
+ Peek_B4(Identifier);
+ switch (Identifier)
+ {
+ case 0x44544731 : sei_message_user_data_registered_itu_t_t35_DTG1(); return;
+ case 0x47413934 : sei_message_user_data_registered_itu_t_t35_GA94(); return;
+ default : if (Element_Size-Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ }
+}
+
+//---------------------------------------------------------------------------
+// SEI - 5 - DTG1
+void File_Avc::sei_message_user_data_registered_itu_t_t35_DTG1()
+{
+ Element_Info1("Active Format Description");
+
+ //Parsing
+ bool active_format_flag;
+ Skip_C4( "afd_identifier");
+ BS_Begin();
+ Mark_0();
+ Get_SB (active_format_flag, "active_format_flag");
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_0_NoTrustError();
+ Mark_1_NoTrustError();
+ if (active_format_flag)
+ {
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Info_S1(4, active_format, "active_format"); Param_Info1(Avc_user_data_DTG1_active_format[active_format]);
+ }
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+// SEI - 5 - GA94
+void File_Avc::sei_message_user_data_registered_itu_t_t35_GA94()
+{
+ //Parsing
+ int8u user_data_type_code;
+ Skip_B4( "GA94_identifier");
+ Get_B1 (user_data_type_code, "user_data_type_code");
+ switch (user_data_type_code)
+ {
+ case 0x03 : sei_message_user_data_registered_itu_t_t35_GA94_03(); break;
+ case 0x06 : sei_message_user_data_registered_itu_t_t35_GA94_06(); break;
+ default : Skip_XX(Element_Size-Element_Offset, "GA94_reserved_user_data");
+ }
+}
+
+//---------------------------------------------------------------------------
+// SEI - 5 - GA94 - 0x03
+void File_Avc::sei_message_user_data_registered_itu_t_t35_GA94_03()
+{
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ GA94_03_IsPresent=true;
+ MustExtendParsingDuration=true;
+ Buffer_TotalBytes_Fill_Max=(int64u)-1; //Disabling this feature for this format, this is done in the parser
+
+ Element_Info1("DTVCC Transport");
+
+ //Coherency
+ delete TemporalReferences_DelayedElement; TemporalReferences_DelayedElement=new temporal_reference();
+
+ TemporalReferences_DelayedElement->GA94_03=new temporal_reference::buffer_data;
+ TemporalReferences_DelayedElement->GA94_03->Size=(size_t)(Element_Size-Element_Offset);
+ delete[] TemporalReferences_DelayedElement->GA94_03->Data;
+ TemporalReferences_DelayedElement->GA94_03->Data=new int8u[(size_t)(Element_Size-Element_Offset)];
+ std::memcpy(TemporalReferences_DelayedElement->GA94_03->Data, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+
+ //Parsing
+ Skip_XX(Element_Size-Element_Offset, "CC data");
+ #else //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ Skip_XX(Element_Size-Element_Offset, "DTVCC Transport data");
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+}
+
+void File_Avc::sei_message_user_data_registered_itu_t_t35_GA94_03_Delayed(int32u seq_parameter_set_id)
+{
+ // Skipping missing frames
+ if (TemporalReferences_Max-TemporalReferences_Min>(size_t)(4*(seq_parameter_sets[seq_parameter_set_id]->max_num_ref_frames+3))) // max_num_ref_frames ref frame maximum
+ {
+ TemporalReferences_Min=TemporalReferences_Max-4*(seq_parameter_sets[seq_parameter_set_id]->max_num_ref_frames+3);
+ while (TemporalReferences[TemporalReferences_Min]==NULL)
+ TemporalReferences_Min++;
+ }
+
+ // Parsing captions
+ while (TemporalReferences[TemporalReferences_Min] && TemporalReferences_Min+2*seq_parameter_sets[seq_parameter_set_id]->max_num_ref_frames<TemporalReferences_Max)
+ {
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ Element_Begin1("Reordered DTVCC Transport");
+
+ //Parsing
+ #if MEDIAINFO_DEMUX
+ int64u Element_Code_Old=Element_Code;
+ Element_Code=0x4741393400000003LL;
+ #endif //MEDIAINFO_DEMUX
+ if (GA94_03_Parser==NULL)
+ {
+ GA94_03_Parser=new File_DtvccTransport;
+ Open_Buffer_Init(GA94_03_Parser);
+ ((File_DtvccTransport*)GA94_03_Parser)->Format=File_DtvccTransport::Format_A53_4_GA94_03;
+ }
+ if (((File_DtvccTransport*)GA94_03_Parser)->AspectRatio==0)
+ {
+ float64 PixelAspectRatio=1;
+ std::vector<seq_parameter_set_struct*>::iterator seq_parameter_set_Item=seq_parameter_sets.begin();
+ for (; seq_parameter_set_Item!=seq_parameter_sets.end(); seq_parameter_set_Item++)
+ if ((*seq_parameter_set_Item))
+ break;
+ if (seq_parameter_set_Item!=seq_parameter_sets.end())
+ {
+ if ((*seq_parameter_set_Item)->vui_parameters->aspect_ratio_idc<Avc_PixelAspectRatio_Size)
+ PixelAspectRatio=Avc_PixelAspectRatio[(*seq_parameter_set_Item)->vui_parameters->aspect_ratio_idc];
+ else if ((*seq_parameter_set_Item)->vui_parameters->aspect_ratio_idc==0xFF && (*seq_parameter_set_Item)->vui_parameters->sar_height)
+ PixelAspectRatio=((float64)(*seq_parameter_set_Item)->vui_parameters->sar_width)/(*seq_parameter_set_Item)->vui_parameters->sar_height;
+ }
+ int32u Width =((*seq_parameter_set_Item)->pic_width_in_mbs_minus1 +1)*16;
+ int32u Height=((*seq_parameter_set_Item)->pic_height_in_map_units_minus1+1)*16*(2-(*seq_parameter_set_Item)->frame_mbs_only_flag);
+ ((File_DtvccTransport*)GA94_03_Parser)->AspectRatio=Width*PixelAspectRatio/Height;
+ }
+ if (GA94_03_Parser->PTS_DTS_Needed)
+ {
+ GA94_03_Parser->FrameInfo.PCR=FrameInfo.PCR;
+ GA94_03_Parser->FrameInfo.PTS=FrameInfo.PTS;
+ GA94_03_Parser->FrameInfo.DTS=FrameInfo.DTS;
+ }
+ #if MEDIAINFO_DEMUX
+ if (TemporalReferences[TemporalReferences_Min]->GA94_03)
+ Demux(TemporalReferences[TemporalReferences_Min]->GA94_03->Data, TemporalReferences[TemporalReferences_Min]->GA94_03->Size, ContentType_MainStream);
+ Element_Code=Element_Code_Old;
+ #endif //MEDIAINFO_DEMUX
+ if (TemporalReferences[TemporalReferences_Min]->GA94_03)
+ Open_Buffer_Continue(GA94_03_Parser, TemporalReferences[TemporalReferences_Min]->GA94_03->Data, TemporalReferences[TemporalReferences_Min]->GA94_03->Size);
+
+ Element_End0();
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+
+ TemporalReferences_Min+=(seq_parameter_sets[seq_parameter_set_id]->frame_mbs_only_flag?2:1);
+ }
+}
+
+//---------------------------------------------------------------------------
+// SEI - 5 - GA94 - 0x03
+void File_Avc::sei_message_user_data_registered_itu_t_t35_GA94_06()
+{
+ Element_Info1("Bar data");
+
+ //Parsing
+ bool top_bar_flag, bottom_bar_flag, left_bar_flag, right_bar_flag;
+ BS_Begin();
+ Get_SB (top_bar_flag, "top_bar_flag");
+ Get_SB (bottom_bar_flag, "bottom_bar_flag");
+ Get_SB (left_bar_flag, "left_bar_flag");
+ Get_SB (right_bar_flag, "right_bar_flag");
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ Mark_1_NoTrustError();
+ BS_End();
+ if (top_bar_flag)
+ {
+ Mark_1();
+ Mark_1();
+ Skip_S2(14, "line_number_end_of_top_bar");
+ }
+ if (bottom_bar_flag)
+ {
+ Mark_1();
+ Mark_1();
+ Skip_S2(14, "line_number_start_of_bottom_bar");
+ }
+ if (left_bar_flag)
+ {
+ Mark_1();
+ Mark_1();
+ Skip_S2(14, "pixel_number_end_of_left_bar");
+ }
+ if (right_bar_flag)
+ {
+ Mark_1();
+ Mark_1();
+ Skip_S2(14, "pixel_number_start_of_right_bar");
+ }
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ Mark_1();
+ BS_End();
+
+ if (Element_Size-Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "additional_bar_data");
+}
+
+//---------------------------------------------------------------------------
+// SEI - 5
+void File_Avc::sei_message_user_data_unregistered(int32u payloadSize)
+{
+ Element_Info1("user_data_unregistered");
+
+ //Parsing
+ int128u uuid_iso_iec_11578;
+ Get_GUID(uuid_iso_iec_11578, "uuid_iso_iec_11578");
+
+ switch (uuid_iso_iec_11578.hi)
+ {
+ case 0xB748D9E6BDE945DCLL : Element_Info1("x264");
+ sei_message_user_data_unregistered_x264(payloadSize-16); break;
+ case 0x684E92AC604A57FBLL : Element_Info1("eavc");
+ sei_message_user_data_unregistered_x264(payloadSize-16); break;
+ default :
+ Element_Info1("unknown");
+ Skip_XX(payloadSize-16, "data");
+ }
+}
+
+//---------------------------------------------------------------------------
+// SEI - 5 - x264
+void File_Avc::sei_message_user_data_unregistered_x264(int32u payloadSize)
+{
+ //Parsing
+ Ztring Data;
+ Peek_Local(payloadSize, Data);
+ if (Data.size()!=payloadSize && Data.size()+1!=payloadSize)
+ {
+ Skip_XX(payloadSize, "Unknown");
+ return; //This is not a text string
+ }
+ size_t Data_Pos;
+ size_t Data_Pos_Before=0;
+ size_t Loop=0;
+ do
+ {
+ Data_Pos=Data.find(_T(" - "), Data_Pos_Before);
+ if (Data_Pos==std::string::npos)
+ Data_Pos=Data.size();
+ if (Data.find(_T("options: "), Data_Pos_Before)==Data_Pos_Before)
+ {
+ Element_Begin1("options");
+ size_t Options_Pos;
+ size_t Options_Pos_Before=Data_Pos_Before;
+ Encoded_Library_Settings.clear();
+ do
+ {
+ Options_Pos=Data.find(_T(" "), Options_Pos_Before);
+ if (Options_Pos==std::string::npos)
+ Options_Pos=Data.size();
+ Ztring option;
+ Get_Local (Options_Pos-Options_Pos_Before, option, "option");
+ Options_Pos_Before=Options_Pos;
+ do
+ {
+ Ztring Separator;
+ Peek_Local(1, Separator);
+ if (Separator==_T(" "))
+ {
+ Skip_Local(1, "separator");
+ Options_Pos_Before+=1;
+ }
+ else
+ break;
+ }
+ while (Options_Pos_Before!=Data.size());
+
+ //Filling
+ if (option!=_T("options:"))
+ {
+ if (!Encoded_Library_Settings.empty())
+ Encoded_Library_Settings+=_T(" / ");
+ Encoded_Library_Settings+=option;
+ if (option.find(_T("bitrate="))==0)
+ BitRate_Nominal=option.substr(8)+_T("000"); //After "bitrate="
+ }
+ }
+ while (Options_Pos_Before!=Data.size());
+ Element_End0();
+ }
+ else
+ {
+ Ztring Value;
+ Get_Local(Data_Pos-Data_Pos_Before, Value, "data");
+
+ //Saving
+ if (Loop==0)
+ {
+ //Cleaning a little the value
+ while (!Value.empty() && Value[0]<0x30)
+ Value.erase(Value.begin());
+ while (!Value.empty() && Value[Value.size()-1]<0x30)
+ Value.erase(Value.end()-1);
+ Encoded_Library=Value;
+ }
+ if (Loop==1 && Encoded_Library.find(_T("x264"))==0)
+ {
+ Encoded_Library+=_T(" - ");
+ Encoded_Library+=Value;
+ }
+ }
+ Data_Pos_Before=Data_Pos;
+ if (Data_Pos_Before+3<=Data.size())
+ {
+ Skip_Local(3, "separator");
+ Data_Pos_Before+=3;
+ }
+
+ Loop++;
+ }
+ while (Data_Pos_Before!=Data.size());
+
+ //Encoded_Library
+ if (Encoded_Library.find(_T("eavc "))==0)
+ {
+ Encoded_Library_Name=_T("eavc");
+ Encoded_Library_Version=Encoded_Library.SubString(_T("eavc "), _T(""));
+ }
+ else if (Encoded_Library.find(_T("x264 - "))==0)
+ {
+ Encoded_Library_Name=_T("x264");
+ Encoded_Library_Version=Encoded_Library.SubString(_T("x264 - "), _T(""));
+ }
+ else if (Encoded_Library.find(_T("SUPER(C) by eRightSoft "))==0)
+ {
+ Encoded_Library_Name=_T("SUPER(C) by eRightSoft");
+ Encoded_Library_Date=Ztring(_T("UTC "))+Encoded_Library.SubString(_T("2000-"), _T(" "));
+ }
+ else
+ Encoded_Library_Name=Encoded_Library;
+}
+
+//---------------------------------------------------------------------------
+// SEI - 6
+void File_Avc::sei_message_recovery_point()
+{
+ Element_Info1("recovery_point");
+
+ //Parsing
+ BS_Begin();
+ Skip_UE( "recovery_frame_cnt");
+ Skip_SB( "exact_match_flag");
+ Skip_SB( "broken_link_flag");
+ Skip_S1(2, "changing_slice_group_idc");
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+// SEI - 32
+void File_Avc::sei_message_mainconcept(int32u payloadSize)
+{
+ Element_Info1("MainConcept text");
+
+ //Parsing
+ Ztring Text;
+ Get_Local(payloadSize, Text, "text");
+
+ if (Text.find(_T("produced by MainConcept H.264/AVC Codec v"))!=std::string::npos)
+ {
+ Encoded_Library=Text.SubString(_T("produced by "), _T(" MainConcept AG"));
+ Encoded_Library_Name=_T("MainConcept H.264/AVC Codec");
+ Encoded_Library_Version=Text.SubString(_T("produced by MainConcept H.264/AVC Codec v"), _T(" (c) "));
+ Encoded_Library_Date=MediaInfoLib::Config.Library_Get(InfoLibrary_Format_MainConcept_Avc, Encoded_Library_Version, InfoLibrary_Date);
+ }
+}
+
+//---------------------------------------------------------------------------
+// Packet "07"
+void File_Avc::seq_parameter_set()
+{
+ Element_Name("seq_parameter_set");
+
+ //parsing
+ int32u seq_parameter_set_id;
+ if (!seq_parameter_set_data(seq_parameter_sets, seq_parameter_set_id))
+ return;
+ Mark_1( );
+ size_t BS_bits=Data_BS_Remain()%8;
+ while (BS_bits)
+ {
+ Mark_0( );
+ BS_bits--;
+ }
+ BS_End();
+
+ //Hack for 00003.m2ts: There is a trailing 0x89, why?
+ if (Element_Offset+1==Element_Size)
+ {
+ int8u ToTest;
+ Peek_B1(ToTest);
+ if (ToTest==0x98)
+ Skip_B1( "Unknown");
+
+ }
+
+ //Hack for : There is a trailing data, why?
+ if (Element_Offset+4==Element_Size)
+ {
+ int32u ToTest;
+ Peek_B4(ToTest);
+ if (ToTest==0xE30633C0)
+ Skip_B4( "Unknown");
+ }
+
+ //NULL bytes
+ while (Element_Offset<Element_Size)
+ {
+ int8u Null;
+ Get_B1 (Null, "NULL byte");
+ if (Null)
+ Trusted_IsNot("Should be NULL byte");
+ }
+
+ FILLING_BEGIN_PRECISE();
+ //NextCode
+ NextCode_Clear();
+ NextCode_Add(0x08);
+
+ //Autorisation of other streams
+ Streams[0x08].Searching_Payload=true; //pic_parameter_set
+ if (Streams[0x07].ShouldDuplicate)
+ Streams[0x08].ShouldDuplicate=true; //pic_parameter_set
+ Streams[0x0A].Searching_Payload=true; //end_of_seq
+ if (Streams[0x07].ShouldDuplicate)
+ Streams[0x0A].ShouldDuplicate=true; //end_of_seq
+ Streams[0x0B].Searching_Payload=true; //end_of_stream
+ if (Streams[0x07].ShouldDuplicate)
+ Streams[0x0B].ShouldDuplicate=true; //end_of_stream
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "08"
+void File_Avc::pic_parameter_set()
+{
+ Element_Name("pic_parameter_set");
+
+ //Parsing
+ int32u pic_parameter_set_id, seq_parameter_set_id, num_slice_groups_minus1, num_ref_idx_l0_default_active_minus1, num_ref_idx_l1_default_active_minus1;
+ int8u weighted_bipred_idc;
+ bool entropy_coding_mode_flag,bottom_field_pic_order_in_frame_present_flag, redundant_pic_cnt_present_flag, weighted_pred_flag;
+ BS_Begin();
+ Get_UE (pic_parameter_set_id, "pic_parameter_set_id");
+ Get_UE (seq_parameter_set_id, "seq_parameter_set_id");
+ std::vector<seq_parameter_set_struct*>::iterator seq_parameter_set_Item;
+ if (seq_parameter_set_id>=seq_parameter_sets.size() || (*(seq_parameter_set_Item=seq_parameter_sets.begin()+seq_parameter_set_id))==NULL || !(*seq_parameter_set_Item)->IsSynched)
+ {
+ if (seq_parameter_set_id>=subset_seq_parameter_sets.size() || (*(seq_parameter_set_Item=subset_seq_parameter_sets.begin()+seq_parameter_set_id))==NULL || !(*seq_parameter_set_Item)->IsSynched)
+ {
+ //Not yet present
+ Skip_BS(Data_BS_Remain(), "Data (seq_parameter_set is missing)");
+ return;
+ }
+ }
+ Get_SB (entropy_coding_mode_flag, "entropy_coding_mode_flag");
+ Get_SB (bottom_field_pic_order_in_frame_present_flag, "bottom_field_pic_order_in_frame_present_flag");
+ Get_UE (num_slice_groups_minus1, "num_slice_groups_minus1");
+ if (num_slice_groups_minus1>7)
+ {
+ Trusted_IsNot("num_slice_groups_minus1 too high");
+ num_slice_groups_minus1=0;
+ }
+ if (num_slice_groups_minus1>0)
+ {
+ int32u slice_group_map_type;
+ Get_UE (slice_group_map_type, "slice_group_map_type");
+ if (slice_group_map_type==0)
+ {
+ for (int32u Pos=0; Pos<=num_slice_groups_minus1; Pos++)
+ Skip_UE( "run_length_minus1");
+ }
+ else if (slice_group_map_type==2)
+ {
+ for (int32u Pos=0; Pos<num_slice_groups_minus1; Pos++)
+ {
+ Skip_UE( "top_left");
+ Skip_UE( "bottom_right");
+ }
+ }
+ else if (slice_group_map_type==3
+ || slice_group_map_type==4
+ || slice_group_map_type==5)
+ {
+ Skip_SB( "slice_group_change_direction_flag");
+ Skip_UE( "slice_group_change_rate_minus1");
+ }
+ else if (slice_group_map_type==6)
+ {
+ int32u pic_size_in_map_units_minus1;
+ Get_UE (pic_size_in_map_units_minus1, "pic_size_in_map_units_minus1");
+ if(pic_size_in_map_units_minus1>((*seq_parameter_set_Item)->pic_width_in_mbs_minus1+1)*((*seq_parameter_set_Item)->pic_height_in_map_units_minus1+1))
+ {
+ Trusted_IsNot("pic_size_in_map_units_minus1 too high");
+ return;
+ }
+ #if defined (__mips__) || defined (__mipsel__)
+ int32u slice_group_id_Size=(int32u)(std::ceil(std::log((double)(num_slice_groups_minus1+1))/std::log((double)10))); //std::log is natural logarithm
+ #else
+ int32u slice_group_id_Size=(int32u)(std::ceil(std::log((float32)(num_slice_groups_minus1+1))/std::log((float32)10))); //std::log is natural logarithm
+ #endif
+ for (int32u Pos=0; Pos<=pic_size_in_map_units_minus1; Pos++)
+ Skip_BS(slice_group_id_Size, "slice_group_id");
+ }
+ }
+ Get_UE (num_ref_idx_l0_default_active_minus1, "num_ref_idx_l0_default_active_minus1");
+ Get_UE (num_ref_idx_l1_default_active_minus1, "num_ref_idx_l1_default_active_minus1");
+ Get_SB (weighted_pred_flag, "weighted_pred_flag");
+ Get_S1 (2, weighted_bipred_idc, "weighted_bipred_idc");
+ Skip_SE( "pic_init_qp_minus26");
+ Skip_SE( "pic_init_qs_minus26");
+ Skip_SE( "chroma_qp_index_offset");
+ Skip_SB( "deblocking_filter_control_present_flag");
+ Skip_SB( "constrained_intra_pred_flag");
+ Get_SB (redundant_pic_cnt_present_flag, "redundant_pic_cnt_present_flag");
+ bool more_rbsp_data=false;
+ if (Element_Size)
+ {
+ int64u Offset=Element_Size-1;
+ while (Offset && Buffer[Buffer_Offset+(size_t)Offset]==0x00) //Searching if there are NULL bytes at the end of the data
+ Offset--;
+ size_t Bit_Pos=7;
+ while (!(Buffer[Buffer_Offset+(size_t)Offset]&(1<<(7-Bit_Pos))))
+ Bit_Pos--;
+ if (Data_BS_Remain()>1+(7-Bit_Pos)+(Element_Size-Offset-1)*8)
+ more_rbsp_data=true;
+ }
+ if (more_rbsp_data)
+ {
+ bool transform_8x8_mode_flag;
+ Get_SB (transform_8x8_mode_flag, "transform_8x8_mode_flag");
+ TEST_SB_SKIP( "pic_scaling_matrix_present_flag");
+ for (int8u Pos=0; Pos<6+(transform_8x8_mode_flag?2:0); Pos++ )
+ {
+ TEST_SB_SKIP( "pic_scaling_list_present_flag");
+ scaling_list(Pos<6?16:64);
+ TEST_SB_END();
+ }
+ TEST_SB_END();
+ Skip_SE( "second_chroma_qp_index_offset");
+ }
+ Mark_1( );
+ BS_End();
+
+ while (Element_Offset<Element_Size) //Not always removed from the stream, ie in MPEG-4
+ {
+ int8u Padding;
+ Peek_B1(Padding);
+ if (!Padding)
+ Skip_B1( "Padding");
+ else
+ break;
+ }
+
+ FILLING_BEGIN_PRECISE();
+ //Integrity
+ if (pic_parameter_set_id>=256)
+ {
+ Trusted_IsNot("pic_parameter_set_id not valid");
+ return; //Problem, not valid
+ }
+ if (seq_parameter_set_id>=31)
+ {
+ Trusted_IsNot("seq_parameter_set_id not valid");
+ return; //Problem, not valid
+ }
+
+ //NextCode
+ NextCode_Clear();
+ NextCode_Add(0x05);
+ NextCode_Add(0x06);
+ if (!subset_seq_parameter_sets.empty())
+ NextCode_Add(0x14); //slice_layer_extension
+
+ //Filling
+ if (pic_parameter_set_id>=pic_parameter_sets.size())
+ pic_parameter_sets.resize(pic_parameter_set_id+1);
+ std::vector<pic_parameter_set_struct*>::iterator pic_parameter_sets_Item=pic_parameter_sets.begin()+pic_parameter_set_id;
+ delete *pic_parameter_sets_Item; *pic_parameter_sets_Item=new pic_parameter_set_struct();
+ (*pic_parameter_sets_Item)->IsSynched =true;
+ (*pic_parameter_sets_Item)->seq_parameter_set_id =(int8u)seq_parameter_set_id;
+ (*pic_parameter_sets_Item)->entropy_coding_mode_flag =entropy_coding_mode_flag;
+ (*pic_parameter_sets_Item)->bottom_field_pic_order_in_frame_present_flag =bottom_field_pic_order_in_frame_present_flag;
+ (*pic_parameter_sets_Item)->num_ref_idx_l0_default_active_minus1 =(int8u)num_ref_idx_l0_default_active_minus1;
+ (*pic_parameter_sets_Item)->num_ref_idx_l1_default_active_minus1 =(int8u)num_ref_idx_l1_default_active_minus1;
+ (*pic_parameter_sets_Item)->weighted_pred_flag =weighted_pred_flag;
+ (*pic_parameter_sets_Item)->weighted_bipred_idc =weighted_bipred_idc;
+ (*pic_parameter_sets_Item)->redundant_pic_cnt_present_flag =redundant_pic_cnt_present_flag;
+
+ //Autorisation of other streams
+ if (!seq_parameter_sets.empty())
+ {
+ for (int8u Pos=0x01; Pos<=0x06; Pos++)
+ {
+ Streams[Pos].Searching_Payload=true; //Coded slice...
+ if (Streams[0x08].ShouldDuplicate)
+ Streams[Pos].ShouldDuplicate=true;
+ }
+ }
+ if (!subset_seq_parameter_sets.empty())
+ {
+ Streams[0x14].Searching_Payload=true; //slice_layer_extension
+ if (Streams[0x08].ShouldDuplicate)
+ Streams[0x14].ShouldDuplicate=true; //slice_layer_extension
+ }
+
+ //Setting as OK
+ if (!Status[IsAccepted])
+ Accept("AVC");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "09"
+void File_Avc::access_unit_delimiter()
+{
+ Element_Name("access_unit_delimiter");
+
+ int8u primary_pic_type;
+ BS_Begin();
+ Get_S1 ( 3, primary_pic_type, "primary_pic_type"); Param_Info1(Avc_primary_pic_type[primary_pic_type]);
+ Mark_1_NoTrustError( ); //Found 1 file without this bit
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+// Packet "09"
+void File_Avc::filler_data()
+{
+ Element_Name("filler_data");
+
+ while (Element_Offset<Element_Size)
+ {
+ int8u FF;
+ Peek_B1(FF);
+ if (FF!=0xFF)
+ break;
+ Element_Offset++;
+ }
+ BS_Begin();
+ Mark_1( );
+ BS_End();
+}
+
+//---------------------------------------------------------------------------
+// Packet "0E"
+void File_Avc::prefix_nal_unit(bool svc_extension_flag)
+{
+ Element_Name("prefix_nal_unit");
+
+ //Parsing
+ if (svc_extension_flag)
+ {
+ Skip_XX(Element_Size-Element_Offset, "prefix_nal_unit_svc");
+ }
+}
+
+//---------------------------------------------------------------------------
+// Packet "0F"
+void File_Avc::subset_seq_parameter_set()
+{
+ Element_Name("subset_seq_parameter_set");
+
+ //Parsing
+ int32u subset_seq_parameter_set_id;
+ if (!seq_parameter_set_data(subset_seq_parameter_sets, subset_seq_parameter_set_id))
+ return;
+ std::vector<seq_parameter_set_struct*>::iterator subset_seq_parameter_sets_Item=subset_seq_parameter_sets.begin()+subset_seq_parameter_set_id;
+ if ((*subset_seq_parameter_sets_Item)->profile_idc==83 || (*subset_seq_parameter_sets_Item)->profile_idc==86)
+ {
+ //bool svc_vui_parameters_present_flag;
+ seq_parameter_set_svc_extension();
+ /* The rest is not yet implemented
+ Get_SB (svc_vui_parameters_present_flag, "svc_vui_parameters_present_flag");
+ if (svc_vui_parameters_present_flag)
+ svc_vui_parameters_extension();
+ */
+ }
+ else if ((*subset_seq_parameter_sets_Item)->profile_idc==118 || (*subset_seq_parameter_sets_Item)->profile_idc==128)
+ {
+ //bool mvc_vui_parameters_present_flag, additional_extension2_flag;
+ Mark_1();
+ seq_parameter_set_mvc_extension(subset_seq_parameter_set_id);
+ /* The rest is not yet implemented
+ Get_SB (mvc_vui_parameters_present_flag, "mvc_vui_parameters_present_flag");
+ if (mvc_vui_parameters_present_flag)
+ mvc_vui_parameters_extension();
+ Get_SB (additional_extension2_flag, "additional_extension2_flag");
+ if (additional_extension2_flag)
+ {
+ //Not handled, should skip all bits except 1
+ BS_End();
+ return;
+ }
+ */
+ }
+ /* The rest is not yet implemented
+ Mark_1( );
+ */
+ BS_End();
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Clear();
+ NextCode_Add(0x08);
+
+ //Autorisation of other streams
+ Streams[0x08].Searching_Payload=true; //pic_parameter_set
+ if (Streams[0x0F].ShouldDuplicate)
+ Streams[0x08].ShouldDuplicate=true; //pic_parameter_set
+ Streams[0x0A].Searching_Payload=true; //end_of_seq
+ if (Streams[0x0F].ShouldDuplicate)
+ Streams[0x0A].ShouldDuplicate=true; //end_of_seq
+ Streams[0x0B].Searching_Payload=true; //end_of_stream
+ if (Streams[0x0F].ShouldDuplicate)
+ Streams[0x0B].ShouldDuplicate=true; //end_of_stream
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "14"
+void File_Avc::slice_layer_extension(bool svc_extension_flag)
+{
+ Element_Name("slice_layer_extension");
+
+ //Parsing
+ if (svc_extension_flag)
+ {
+ Skip_XX(Element_Size-Element_Offset, "slice_header_in_scalable_extension + slice_data_in_scalable_extension");
+ }
+ else
+ {
+ slice_header();
+ //slice_data();
+ }
+}
+
+//***************************************************************************
+// SubElements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Avc::seq_parameter_set_data(std::vector<seq_parameter_set_struct*> &Data, int32u &Data_id)
+{
+ //Parsing
+ void* vui_parameters_Item=NULL;
+ int32u chroma_format_idc=1, bit_depth_luma_minus8=0, bit_depth_chroma_minus8=0, log2_max_frame_num_minus4, pic_order_cnt_type, log2_max_pic_order_cnt_lsb_minus4=(int32u)-1, max_num_ref_frames, pic_width_in_mbs_minus1, pic_height_in_map_units_minus1, frame_crop_left_offset=0, frame_crop_right_offset=0, frame_crop_top_offset=0, frame_crop_bottom_offset=0;
+ int8u profile_idc, level_idc;
+ bool constraint_set3_flag, separate_colour_plane_flag=false, delta_pic_order_always_zero_flag=false, frame_mbs_only_flag, mb_adaptive_frame_field_flag=false;
+ Get_B1 (profile_idc, "profile_idc");
+ BS_Begin();
+ Element_Begin1("constraints");
+ Skip_SB( "constraint_set0_flag");
+ Skip_SB( "constraint_set1_flag");
+ Skip_SB( "constraint_set2_flag");
+ Get_SB (constraint_set3_flag, "constraint_set3_flag");
+ Skip_SB( "reserved_zero_4bits");
+ Skip_SB( "reserved_zero_4bits");
+ Skip_SB( "reserved_zero_4bits");
+ Skip_SB( "reserved_zero_4bits");
+ Element_End0();
+ Get_S1 ( 8, level_idc, "level_idc");
+ Get_UE ( Data_id, "seq_parameter_set_id");
+ switch (profile_idc)
+ {
+ case 100 :
+ case 110 :
+ case 122 :
+ case 244 :
+ case 44 :
+ case 83 :
+ case 86 :
+ case 118 :
+ case 128 : //High profiles
+ Element_Begin1("high profile specific");
+ Get_UE (chroma_format_idc, "chroma_format_idc"); Param_Info1C((chroma_format_idc<3), Avc_Colorimetry_format_idc[chroma_format_idc]);
+ if (chroma_format_idc==3)
+ Get_SB (separate_colour_plane_flag, "separate_colour_plane_flag");
+ Get_UE (bit_depth_luma_minus8, "bit_depth_luma_minus8");
+ Get_UE (bit_depth_chroma_minus8, "bit_depth_chroma_minus8");
+ Skip_SB( "qpprime_y_zero_transform_bypass_flag");
+ TEST_SB_SKIP( "seq_scaling_matrix_present_flag");
+ for (int32u Pos=0; Pos<8; Pos++)
+ {
+ TEST_SB_SKIP( "seq_scaling_list_present_flag");
+ scaling_list(Pos<6?16:64);
+ TEST_SB_END();
+ }
+ TEST_SB_END();
+ Element_End0();
+ break;
+ default : ;
+ }
+ Get_UE (log2_max_frame_num_minus4, "log2_max_frame_num_minus4");
+ Get_UE (pic_order_cnt_type, "pic_order_cnt_type");
+ if (pic_order_cnt_type==0)
+ Get_UE (log2_max_pic_order_cnt_lsb_minus4, "log2_max_pic_order_cnt_lsb_minus4");
+ else if (pic_order_cnt_type==1)
+ {
+ int32u num_ref_frames_in_pic_order_cnt_cycle;
+ Get_SB (delta_pic_order_always_zero_flag, "delta_pic_order_always_zero_flag");
+ Skip_SE( "offset_for_non_ref_pic");
+ Skip_SE( "offset_for_top_to_bottom_field");
+ Get_UE (num_ref_frames_in_pic_order_cnt_cycle, "num_ref_frames_in_pic_order_cnt_cycle");
+ if (num_ref_frames_in_pic_order_cnt_cycle>=256)
+ {
+ Trusted_IsNot("num_ref_frames_in_pic_order_cnt_cycle too high");
+ return false;
+ }
+ for(int32u Pos=0; Pos<num_ref_frames_in_pic_order_cnt_cycle; Pos++)
+ Skip_SE( "offset_for_ref_frame");
+ }
+ Get_UE (max_num_ref_frames, "max_num_ref_frames");
+ Skip_SB( "gaps_in_frame_num_value_allowed_flag");
+ Get_UE (pic_width_in_mbs_minus1, "pic_width_in_mbs_minus1");
+ Get_UE (pic_height_in_map_units_minus1, "pic_height_in_map_units_minus1");
+ Get_SB (frame_mbs_only_flag, "frame_mbs_only_flag");
+ if (!frame_mbs_only_flag)
+ Get_SB (mb_adaptive_frame_field_flag, "mb_adaptive_frame_field_flag");
+ Skip_SB( "direct_8x8_inference_flag");
+ TEST_SB_SKIP( "frame_cropping_flag");
+ Get_UE (frame_crop_left_offset, "frame_crop_left_offset");
+ Get_UE (frame_crop_right_offset, "frame_crop_right_offset");
+ Get_UE (frame_crop_top_offset, "frame_crop_top_offset");
+ Get_UE (frame_crop_bottom_offset, "frame_crop_bottom_offset");
+ TEST_SB_END();
+ TEST_SB_SKIP( "vui_parameters_present_flag");
+ vui_parameters(vui_parameters_Item);
+ TEST_SB_END();
+
+ FILLING_BEGIN()
+ //Integrity
+ if (Data_id>=32)
+ {
+ Trusted_IsNot("seq_parameter_set_id not valid");
+ delete (seq_parameter_set_struct::vui_parameters_struct*)vui_parameters_Item;
+ return false; //Problem, not valid
+ }
+ if (pic_order_cnt_type==0 && log2_max_pic_order_cnt_lsb_minus4>12)
+ {
+ Trusted_IsNot("log2_max_pic_order_cnt_lsb_minus4 not valid");
+ delete (seq_parameter_set_struct::vui_parameters_struct*)vui_parameters_Item;
+ return false; //Problem, not valid
+ }
+ if (log2_max_frame_num_minus4>12)
+ {
+ Trusted_IsNot("log2_max_frame_num_minus4 not valid");
+ delete (seq_parameter_set_struct::vui_parameters_struct*)vui_parameters_Item;
+ return false; //Problem, not valid
+ }
+
+ //Creating Data
+ if (Data_id>=Data.size())
+ Data.resize(Data_id+1);
+ std::vector<seq_parameter_set_struct*>::iterator Data_Item=Data.begin()+Data_id;
+ delete *Data_Item; *Data_Item=new seq_parameter_set_struct();
+
+ //Filling from stream
+ (*Data_Item)->IsSynched =true;
+ (*Data_Item)->constraint_set3_flag =constraint_set3_flag;
+ (*Data_Item)->profile_idc =profile_idc;
+ (*Data_Item)->level_idc =level_idc;
+ (*Data_Item)->chroma_format_idc =(int8u)chroma_format_idc;
+ (*Data_Item)->separate_colour_plane_flag =separate_colour_plane_flag;
+ (*Data_Item)->bit_depth_luma_minus8 =(int8u)bit_depth_luma_minus8;
+ (*Data_Item)->bit_depth_chroma_minus8 =(int8u)bit_depth_chroma_minus8;
+ (*Data_Item)->log2_max_frame_num_minus4 =(int8u)log2_max_frame_num_minus4;
+ (*Data_Item)->pic_order_cnt_type =(int8u)pic_order_cnt_type;
+ (*Data_Item)->log2_max_pic_order_cnt_lsb_minus4 =(int8u)log2_max_pic_order_cnt_lsb_minus4;
+ (*Data_Item)->delta_pic_order_always_zero_flag =delta_pic_order_always_zero_flag;
+ (*Data_Item)->max_num_ref_frames =(int8u)max_num_ref_frames;
+ (*Data_Item)->pic_width_in_mbs_minus1 =pic_width_in_mbs_minus1;
+ (*Data_Item)->pic_height_in_map_units_minus1 =pic_height_in_map_units_minus1;
+ (*Data_Item)->frame_mbs_only_flag =frame_mbs_only_flag;
+ (*Data_Item)->mb_adaptive_frame_field_flag =mb_adaptive_frame_field_flag;
+ (*Data_Item)->frame_crop_left_offset =frame_crop_left_offset;
+ (*Data_Item)->frame_crop_right_offset =frame_crop_right_offset;
+ (*Data_Item)->frame_crop_top_offset =frame_crop_top_offset;
+ (*Data_Item)->frame_crop_bottom_offset =frame_crop_bottom_offset;
+ (*Data_Item)->vui_parameters =(seq_parameter_set_struct::vui_parameters_struct*)vui_parameters_Item;
+
+ //Computing values (for speed)
+ (*Data_Item)->pic_struct_FirstDetected =(int8u)-1; //For stats only, init
+ size_t MaxNumber;
+ switch (pic_order_cnt_type)
+ {
+ case 0 : MaxNumber=(*Data_Item)->MaxPicOrderCntLsb =(int32u)pow(2.0, (int)(log2_max_pic_order_cnt_lsb_minus4+4)); break;
+ case 2 : MaxNumber=(*Data_Item)->MaxFrameNum =(int32u)pow(2.0, (int)(log2_max_frame_num_minus4+4)); MaxNumber*=2; break;
+ default: Trusted_IsNot("Not supported"); return false;
+ }
+
+ if (MaxNumber>TemporalReferences_Reserved)
+ {
+ TemporalReferences.resize(4*MaxNumber);
+ TemporalReferences_Reserved=MaxNumber;
+ }
+ FILLING_ELSE()
+ return false;
+ FILLING_END()
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::scaling_list(int32u ScalingList_Size)
+{
+ //From http://mpeg4ip.cvs.sourceforge.net/mpeg4ip/mpeg4ip/util/h264/main.cpp?revision=1.17&view=markup
+ int32u lastScale=8, nextScale=8;
+ for (int32u Pos=0; Pos<ScalingList_Size; Pos++)
+ {
+ if (nextScale!=0)
+ {
+ int32s delta_scale;
+ Get_SE (delta_scale, "scale_delta");
+ nextScale=(lastScale+delta_scale+256)%256;
+ }
+ if (nextScale)
+ lastScale=nextScale;
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::vui_parameters(void* &vui_parameters_Item_)
+{
+ //Parsing
+ void *NAL=NULL, *VCL=NULL;
+ int32u num_units_in_tick=(int32u)-1, time_scale=(int32u)-1;
+ int16u sar_width=(int16u)-1, sar_height=(int16u)-1;
+ int8u aspect_ratio_idc=0, video_format=5, colour_primaries=2, transfer_characteristics=2, matrix_coefficients=2;
+ bool aspect_ratio_info_present_flag, video_signal_type_present_flag, colour_description_present_flag=false, timing_info_present_flag, fixed_frame_rate_flag=false, nal_hrd_parameters_present_flag, vcl_hrd_parameters_present_flag, pic_struct_present_flag;
+ TEST_SB_GET (aspect_ratio_info_present_flag, "aspect_ratio_info_present_flag");
+ Get_S1 (8, aspect_ratio_idc, "aspect_ratio_idc"); Param_Info1C((aspect_ratio_idc<Avc_PixelAspectRatio_Size), Avc_PixelAspectRatio[aspect_ratio_idc]);
+ if (aspect_ratio_idc==0xFF)
+ {
+ Get_S2 (16, sar_width, "sar_width");
+ Get_S2 (16, sar_height, "sar_height");
+ }
+ TEST_SB_END();
+ TEST_SB_SKIP( "overscan_info_present_flag");
+ Skip_SB( "overscan_appropriate_flag");
+ TEST_SB_END();
+ TEST_SB_GET (video_signal_type_present_flag, "video_signal_type_present_flag");
+ Get_S1 (3, video_format, "video_format"); Param_Info1(Avc_video_format[video_format]);
+ Skip_SB( "video_full_range_flag");
+ TEST_SB_GET (colour_description_present_flag, "colour_description_present_flag");
+ Get_S1 (8, colour_primaries, "colour_primaries"); Param_Info1(Avc_colour_primaries(colour_primaries));
+ Get_S1 (8, transfer_characteristics, "transfer_characteristics"); Param_Info1(Avc_transfer_characteristics(transfer_characteristics));
+ Get_S1 (8, matrix_coefficients, "matrix_coefficients"); Param_Info1(Avc_matrix_coefficients(matrix_coefficients));
+ TEST_SB_END();
+ TEST_SB_END();
+ TEST_SB_SKIP( "chroma_loc_info_present_flag");
+ Skip_UE( "chroma_sample_loc_type_top_field");
+ Skip_UE( "chroma_sample_loc_type_bottom_field");
+ TEST_SB_END();
+ TEST_SB_GET (timing_info_present_flag, "timing_info_present_flag");
+ Get_S4 (32, num_units_in_tick, "num_units_in_tick");
+ Get_S4 (32, time_scale, "time_scale");
+ Get_SB ( fixed_frame_rate_flag, "fixed_frame_rate_flag");
+ TEST_SB_END();
+ TEST_SB_GET (nal_hrd_parameters_present_flag, "nal_hrd_parameters_present_flag");
+ hrd_parameters(NAL);
+ TEST_SB_END();
+ TEST_SB_GET (vcl_hrd_parameters_present_flag, "vcl_hrd_parameters_present_flag");
+ hrd_parameters(VCL);
+ TEST_SB_END();
+ if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag)
+ Skip_SB( "low_delay_hrd_flag");
+ Get_SB ( pic_struct_present_flag, "pic_struct_present_flag");
+ seq_parameter_set_struct::vui_parameters_struct::bitstream_restriction_struct* bitstream_restriction=NULL;
+ TEST_SB_SKIP( "bitstream_restriction_flag");
+ bitstream_restriction=new seq_parameter_set_struct::vui_parameters_struct::bitstream_restriction_struct();
+ int32u num_reorder_frames;
+ Skip_SB( "motion_vectors_over_pic_boundaries_flag");
+ Skip_UE( "max_bytes_per_pic_denom");
+ Skip_UE( "max_bits_per_mb_denom");
+ Skip_UE( "log2_max_mv_length_horizontal");
+ Skip_UE( "log2_max_mv_length_vertical");
+ Get_UE (num_reorder_frames, "num_reorder_frames");
+ Skip_UE( "max_dec_frame_buffering");
+ bitstream_restriction->num_reorder_frames=(int8u)num_reorder_frames;
+ TEST_SB_END();
+
+ FILLING_BEGIN();
+ seq_parameter_set_struct::vui_parameters_struct* vui_parameters_Item=new seq_parameter_set_struct::vui_parameters_struct();
+ vui_parameters_Item_=vui_parameters_Item;
+ vui_parameters_Item->aspect_ratio_info_present_flag=aspect_ratio_info_present_flag;
+ if (aspect_ratio_info_present_flag)
+ {
+ vui_parameters_Item->aspect_ratio_idc=aspect_ratio_idc;
+ if (aspect_ratio_idc==0xFF)
+ {
+ vui_parameters_Item->sar_width=sar_width;
+ vui_parameters_Item->sar_height=sar_height;
+ }
+ }
+ vui_parameters_Item->video_signal_type_present_flag=video_signal_type_present_flag;
+ if (video_signal_type_present_flag)
+ {
+ vui_parameters_Item->video_format=video_format;
+ vui_parameters_Item->colour_description_present_flag=colour_description_present_flag;
+ if (colour_description_present_flag)
+ {
+ vui_parameters_Item->colour_primaries=colour_primaries;
+ vui_parameters_Item->transfer_characteristics=transfer_characteristics;
+ vui_parameters_Item->matrix_coefficients=matrix_coefficients;
+ }
+ }
+ vui_parameters_Item->timing_info_present_flag=timing_info_present_flag;
+ if (timing_info_present_flag)
+ {
+ vui_parameters_Item->num_units_in_tick=num_units_in_tick;
+ vui_parameters_Item->time_scale=time_scale;
+ vui_parameters_Item->fixed_frame_rate_flag=fixed_frame_rate_flag;
+ }
+ vui_parameters_Item->NAL=(seq_parameter_set_struct::vui_parameters_struct::xxl*)NAL;
+ vui_parameters_Item->VCL=(seq_parameter_set_struct::vui_parameters_struct::xxl*)VCL;
+ vui_parameters_Item->pic_struct_present_flag=pic_struct_present_flag;
+ vui_parameters_Item->bitstream_restriction=bitstream_restriction;
+ FILLING_ELSE();
+ delete (seq_parameter_set_struct::vui_parameters_struct::xxl*)NAL;
+ delete (seq_parameter_set_struct::vui_parameters_struct::xxl*)VCL;
+ delete bitstream_restriction;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::hrd_parameters(void* &hrd_parameters_Item_)
+{
+ //Parsing
+ int32u cpb_cnt_minus1;
+ int8u bit_rate_scale, cpb_size_scale, initial_cpb_removal_delay_length_minus1, cpb_removal_delay_length_minus1, dpb_output_delay_length_minus1, time_offset_length;
+ Get_UE ( cpb_cnt_minus1, "cpb_cnt_minus1");
+ Get_S1 (4, bit_rate_scale, "bit_rate_scale");
+ Get_S1 (4, cpb_size_scale, "cpb_size_scale");
+ if (cpb_cnt_minus1>31)
+ {
+ Trusted_IsNot("cpb_cnt_minus1 too high");
+ cpb_cnt_minus1=0;
+ }
+ seq_parameter_set_struct::vui_parameters_struct::xxl* ToTest=new seq_parameter_set_struct::vui_parameters_struct::xxl();
+ hrd_parameters_Item_=ToTest;
+ ToTest->SchedSel.resize(cpb_cnt_minus1+1);
+ for (int32u SchedSelIdx=0; SchedSelIdx<=cpb_cnt_minus1; SchedSelIdx++)
+ {
+ Element_Begin1("ShedSel");
+ int32u bit_rate_value_minus1, cpb_size_value_minus1;
+ Get_UE (bit_rate_value_minus1, "bit_rate_value_minus1");
+ ToTest->SchedSel[SchedSelIdx].bit_rate_value=(int32u)((bit_rate_value_minus1+1)*pow(2.0, 6+bit_rate_scale)); Param_Info2(ToTest->SchedSel[SchedSelIdx].bit_rate_value, " bps");
+ Get_UE (cpb_size_value_minus1, "cpb_size_value_minus1");
+ ToTest->SchedSel[SchedSelIdx].cpb_size_value=(int32u)((cpb_size_value_minus1+1)*pow(2.0, 4+cpb_size_scale)); Param_Info2(ToTest->SchedSel[SchedSelIdx].cpb_size_value, " bits");
+ Get_SB (ToTest->SchedSel[SchedSelIdx].cbr_flag, "cbr_flag");
+ Element_End0();
+ }
+ Get_S1 (5, initial_cpb_removal_delay_length_minus1, "initial_cpb_removal_delay_length_minus1");
+ Get_S1 (5, cpb_removal_delay_length_minus1, "cpb_removal_delay_length_minus1");
+ Get_S1 (5, dpb_output_delay_length_minus1, "dpb_output_delay_length_minus1");
+ Get_S1 (5, time_offset_length, "time_offset_length");
+
+ //Validity test
+ if (!Element_IsOK() || (ToTest->SchedSel.size()==1 && ToTest->SchedSel[0].bit_rate_value==64))
+ {
+ delete ToTest; ToTest=NULL; hrd_parameters_Item_=NULL; //We do not trust this kind of data
+ return;
+ }
+
+ //Filling
+ ToTest->initial_cpb_removal_delay_length_minus1 =initial_cpb_removal_delay_length_minus1;
+ ToTest->cpb_removal_delay_length_minus1 =cpb_removal_delay_length_minus1;
+ ToTest->dpb_output_delay_length_minus1 =dpb_output_delay_length_minus1;
+ ToTest->time_offset_length =time_offset_length;
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::nal_unit_header_svc_extension()
+{
+ //Parsing
+ Element_Begin1("nal_unit_header_svc_extension");
+ Skip_SB( "idr_flag");
+ Skip_S1( 6, "priority_id");
+ Skip_SB( "no_inter_layer_pred_flag");
+ Skip_S1( 3, "dependency_id");
+ Skip_S1( 4, "quality_id");
+ Skip_S1( 3, "temporal_id");
+ Skip_SB( "use_ref_base_pic_flag");
+ Skip_SB( "discardable_flag");
+ Skip_SB( "output_flag");
+ Skip_S1( 2, "reserved_three_2bits");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::nal_unit_header_mvc_extension()
+{
+ //Parsing
+ Element_Begin1("nal_unit_header_mvc_extension");
+ Skip_SB( "non_idr_flag");
+ Skip_S1( 6, "priority_id");
+ Skip_S1(10, "view_id");
+ Skip_S1( 3, "temporal_id");
+ Skip_SB( "anchor_pic_flag");
+ Skip_SB( "inter_view_flag");
+ Skip_SB( "reserved_one_bit");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::seq_parameter_set_svc_extension()
+{
+ //Parsing
+ Element_Begin1("seq_parameter_set_svc_extension");
+ //Skip_SB( "");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::svc_vui_parameters_extension()
+{
+ //Parsing
+ Element_Begin1("svc_vui_parameters_extension");
+ //Skip_SB( "");
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::seq_parameter_set_mvc_extension(int32u subset_seq_parameter_sets_id)
+{
+ //Parsing
+ Element_Begin1("seq_parameter_set_mvc_extension");
+ int32u num_views_minus1;
+ Get_UE (num_views_minus1, "num_views_minus1");
+ //Skip_SB( "");
+ Element_End0();
+
+ std::vector<seq_parameter_set_struct*>::iterator subset_seq_parameter_sets_Item=subset_seq_parameter_sets.begin()+subset_seq_parameter_sets_id;
+ FILLING_BEGIN()
+ (*subset_seq_parameter_sets_Item)->num_views_minus1 =(int16u)num_views_minus1;
+ FILLING_ELSE()
+ delete (*subset_seq_parameter_sets_Item); (*subset_seq_parameter_sets_Item)=NULL;
+ FILLING_END()
+}
+
+//---------------------------------------------------------------------------
+void File_Avc::mvc_vui_parameters_extension()
+{
+ //Parsing
+ Element_Begin1("mvc_vui_parameters_extension");
+ Skip_SB( "");
+ Element_End0();
+}
+
+//***************************************************************************
+// Specific
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Avc::SPS_PPS()
+{
+ //Parsing
+ int8u Profile, Level, seq_parameter_set_count, pic_parameter_set_count;
+ if (SizedBlocks)
+ Skip_B1( "Version");
+ Get_B1 (Profile, "Profile");
+ Skip_B1( "Compatible profile");
+ Get_B1 (Level, "Level");
+ BS_Begin();
+ Skip_S1(6, "Reserved");
+ Get_S1 (2, SizeOfNALU_Minus1, "Size of NALU length minus 1");
+ Skip_S1(3, "Reserved");
+ Get_S1 (5, seq_parameter_set_count, "seq_parameter_set count");
+ BS_End();
+ for (int8u Pos=0; Pos<seq_parameter_set_count; Pos++)
+ {
+ Element_Begin1("seq_parameter_set");
+ int16u Size;
+ Get_B2 (Size, "Size");
+ BS_Begin();
+ Mark_0 ();
+ Skip_S1( 2, "nal_ref_idc");
+ Skip_S1( 5, "nal_unit_type");
+ BS_End();
+ if (Element_Offset+Size-1>Element_Size)
+ {
+ Trusted_IsNot("Size is wrong");
+ break; //There is an error
+ }
+ int64u Element_Offset_Save=Element_Offset;
+ int64u Element_Size_Save=Element_Size;
+ Buffer_Offset+=(size_t)Element_Offset_Save;
+ Element_Offset=0;
+ Element_Size=Size-(Size?1:0);
+ Element_Code=0x07; //seq_parameter_set
+ Data_Parse();
+ Buffer_Offset-=(size_t)Element_Offset_Save;
+ Element_Offset=Element_Offset_Save+Size-1;
+ Element_Size=Element_Size_Save;
+ Element_End0();
+ }
+ Get_B1 (pic_parameter_set_count, "pic_parameter_set count");
+ for (int8u Pos=0; Pos<pic_parameter_set_count; Pos++)
+ {
+ Element_Begin1("pic_parameter_set");
+ int16u Size;
+ Get_B2 (Size, "Size");
+ BS_Begin();
+ Mark_0 ();
+ Skip_S1( 2, "nal_ref_idc");
+ Skip_S1( 5, "nal_unit_type");
+ BS_End();
+ int64u Element_Offset_Save=Element_Offset;
+ int64u Element_Size_Save=Element_Size;
+ Buffer_Offset+=(size_t)Element_Offset_Save;
+ Element_Offset=0;
+ Element_Size=Size-1;
+ if (Element_Size>Element_Size_Save-Element_Offset_Save)
+ break; //There is an error
+ Element_Code=0x08; //pic_parameter_set
+ Data_Parse();
+ Buffer_Offset-=(size_t)Element_Offset_Save;
+ Element_Offset=Element_Offset_Save+Size-1;
+ Element_Size=Element_Size_Save;
+ Element_End0();
+ }
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "Padding?");
+
+ //Filling
+ FILLING_BEGIN_PRECISE();
+ //Detection of some bugs in the file
+ if (!seq_parameter_sets.empty() && seq_parameter_sets[0] && (Profile!=seq_parameter_sets[0]->profile_idc || Level!=seq_parameter_sets[0]->level_idc))
+ MuxingMode=Ztring("Container profile=")+Ztring().From_Local(Avc_profile_idc(Profile))+_T("@")+Ztring().From_Number(((float)Level)/10, 1);
+
+ MustParse_SPS_PPS=false;
+ if (!Status[IsAccepted])
+ Accept("AVC");
+ FILLING_END();
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+std::string File_Avc::GOP_Detect (std::string PictureTypes)
+{
+ //Finding a string without blanks
+ size_t PictureTypes_Limit=PictureTypes.find(' ');
+ if (PictureTypes_Limit!=string::npos)
+ {
+ if (PictureTypes_Limit>PictureTypes.size()/2)
+ PictureTypes.resize(PictureTypes_Limit);
+ else
+ {
+ //Trim
+ size_t TrimPos;
+ TrimPos=PictureTypes.find_first_not_of(' ');
+ if (TrimPos!=string::npos)
+ PictureTypes.erase(0, TrimPos);
+ TrimPos=PictureTypes.find_last_not_of(' ');
+ if (TrimPos!=string::npos)
+ PictureTypes.erase(TrimPos+1);
+
+ //Finding the longest string
+ ZtringList List; List.Separator_Set(0, _T(" "));
+ List.Write(Ztring().From_Local(PictureTypes));
+ size_t MaxLength=0;
+ size_t MaxLength_Pos=0;
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ if (List[Pos].size()>MaxLength)
+ {
+ MaxLength=List[Pos].size();
+ MaxLength_Pos=Pos;
+ }
+ PictureTypes=List[MaxLength_Pos].To_Local();
+
+ }
+ }
+
+ //Creating all GOP values
+ std::vector<Ztring> GOPs;
+ size_t GOP_Frame_Count=0;
+ size_t GOP_BFrames_Max=0;
+ size_t I_Pos1=PictureTypes.find('I');
+ while (I_Pos1!=std::string::npos)
+ {
+ size_t I_Pos2=PictureTypes.find('I', I_Pos1+1);
+ if (I_Pos2!=std::string::npos)
+ {
+ std::vector<size_t> P_Positions;
+ size_t P_Position=I_Pos1;
+ do
+ {
+ P_Position=PictureTypes.find('P', P_Position+1);
+ if (P_Position<I_Pos2)
+ P_Positions.push_back(P_Position);
+ }
+ while (P_Position<I_Pos2);
+ if (P_Positions.size()>1 && P_Positions[0]>I_Pos1+1 && P_Positions[P_Positions.size()-1]==I_Pos2-1)
+ P_Positions.resize(P_Positions.size()-1); //Removing last P-Frame for next test, this is often a terminating P-Frame replacing a B-Frame
+ Ztring GOP;
+ bool IsOK=true;
+ if (!P_Positions.empty())
+ {
+ size_t Delta=P_Positions[0]-I_Pos1;
+ for (size_t Pos=1; Pos<P_Positions.size(); Pos++)
+ if (P_Positions[Pos]-P_Positions[Pos-1]!=Delta)
+ {
+ IsOK=false;
+ break;
+ }
+ if (IsOK)
+ {
+ GOP+=_T("M=")+Ztring::ToZtring(P_Positions[0]-I_Pos1)+_T(", ");
+ if (P_Positions[0]-I_Pos1>GOP_BFrames_Max)
+ GOP_BFrames_Max=P_Positions[0]-I_Pos1;
+ }
+ }
+ if (IsOK)
+ {
+ GOP+=_T("N=")+Ztring::ToZtring(I_Pos2-I_Pos1);
+ GOPs.push_back(GOP);
+ }
+ else
+ GOPs.push_back(Ztring()); //There is a problem, blank
+ GOP_Frame_Count+=I_Pos2-I_Pos1;
+ }
+ I_Pos1=I_Pos2;
+ }
+
+ //Some clean up
+ if (GOP_Frame_Count+GOP_BFrames_Max>Frame_Count && !GOPs.empty())
+ GOPs.resize(GOPs.size()-1); //Removing the last one, there may have uncomplete B-frame filling
+ if (GOPs.size()>4)
+ GOPs.erase(GOPs.begin()); //Removing the first one, it is sometime different and we have enough to deal with
+
+ //Filling
+ if (GOPs.size()>=4)
+ {
+ bool IsOK=true;
+ for (size_t Pos=1; Pos<GOPs.size(); Pos++)
+ if (GOPs[Pos]!=GOPs[0])
+ {
+ IsOK=false;
+ break;
+ }
+ if (IsOK)
+ return GOPs[0].To_Local();
+ }
+
+ return string();
+}
+
+//---------------------------------------------------------------------------
+std::string File_Avc::ScanOrder_Detect (std::string ScanOrders)
+{
+ //Finding a string without blanks
+ size_t ScanOrders_Limit=ScanOrders.find(' ');
+ if (ScanOrders_Limit!=string::npos)
+ {
+ if (ScanOrders_Limit>ScanOrders.size()/2)
+ ScanOrders.resize(ScanOrders_Limit);
+ else
+ {
+ //Trim
+ size_t TrimPos;
+ TrimPos=ScanOrders.find_first_not_of(' ');
+ if (TrimPos!=string::npos)
+ ScanOrders.erase(0, TrimPos);
+ TrimPos=ScanOrders.find_last_not_of(' ');
+ if (TrimPos!=string::npos)
+ ScanOrders.erase(TrimPos+1);
+
+ //Finding the longest string
+ ZtringList List; List.Separator_Set(0, _T(" "));
+ List.Write(Ztring().From_Local(ScanOrders));
+ size_t MaxLength=0;
+ size_t MaxLength_Pos=0;
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ if (List[Pos].size()>MaxLength)
+ {
+ MaxLength=List[Pos].size();
+ MaxLength_Pos=Pos;
+ }
+ ScanOrders=List[MaxLength_Pos].To_Local();
+
+ }
+ }
+
+ //Filling
+ if (ScanOrders.find("TBTBTBTB")==0)
+ return ("TFF");
+ if (ScanOrders.find("BTBTBTBT")==0)
+ return ("BFF");
+ return string();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_AVC_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc.h
new file mode 100644
index 000000000..8cb2a8abe
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc.h
@@ -0,0 +1,394 @@
+// File_Avc - Info for AVC Video files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_AvcH
+#define MediaInfo_AvcH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/File__Duplicate.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Avc
+//***************************************************************************
+
+class File_Avc :
+#if MEDIAINFO_DUPLICATE
+ public File__Duplicate
+#else //MEDIAINFO_DUPLICATE
+ public File__Analyze
+#endif //MEDIAINFO_DUPLICATE
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ bool FrameIsAlwaysComplete;
+ bool MustParse_SPS_PPS;
+ bool SizedBlocks;
+
+ //Constructor/Destructor
+ File_Avc();
+ ~File_Avc();
+
+private :
+ //Structures - seq_parameter_set
+ struct seq_parameter_set_struct
+ {
+ struct vui_parameters_struct
+ {
+ struct xxl
+ {
+ struct xxl_data
+ {
+ //HRD configuration
+ int32u bit_rate_value;
+ int32u cpb_size_value;
+ bool cbr_flag;
+
+ //sei_message_buffering_period
+ int32u initial_cpb_removal_delay;
+ int32u initial_cpb_removal_delay_offset;
+
+ xxl_data()
+ {
+ //HRD configuration
+ bit_rate_value=(int32u)-1;
+ cpb_size_value=(int32u)-1;
+ cbr_flag=true;
+
+ //sei_message_buffering_period
+ initial_cpb_removal_delay=(int32u)-1;
+ initial_cpb_removal_delay_offset=(int32u)-1;
+ }
+ };
+ vector<xxl_data> SchedSel;
+ int8u initial_cpb_removal_delay_length_minus1;
+ int8u cpb_removal_delay_length_minus1;
+ int8u dpb_output_delay_length_minus1;
+ int8u time_offset_length;
+ };
+ struct bitstream_restriction_struct
+ {
+ int8u num_reorder_frames;
+ };
+ xxl* NAL;
+ xxl* VCL;
+ bitstream_restriction_struct* bitstream_restriction;
+ int32u num_units_in_tick;
+ int32u time_scale;
+ int16u sar_width;
+ int16u sar_height;
+ int8u aspect_ratio_idc;
+ int8u video_format;
+ int8u colour_primaries;
+ int8u transfer_characteristics;
+ int8u matrix_coefficients;
+ bool aspect_ratio_info_present_flag;
+ bool video_signal_type_present_flag;
+ bool colour_description_present_flag;
+ bool timing_info_present_flag;
+ bool fixed_frame_rate_flag;
+ bool pic_struct_present_flag;
+ };
+ vui_parameters_struct* vui_parameters;
+ int32u pic_width_in_mbs_minus1;
+ int32u pic_height_in_map_units_minus1;
+ int32u frame_crop_left_offset;
+ int32u frame_crop_right_offset;
+ int32u frame_crop_top_offset;
+ int32u frame_crop_bottom_offset;
+ int32u MaxPicOrderCntLsb; //Computed value (for speed)
+ int32u MaxFrameNum; //Computed value (for speed)
+ int16u num_views_minus1; //MultiView specific field
+ int8u chroma_format_idc;
+ int8u profile_idc;
+ int8u level_idc;
+ int8u bit_depth_luma_minus8;
+ int8u bit_depth_chroma_minus8;
+ int8u log2_max_frame_num_minus4;
+ int8u pic_order_cnt_type;
+ int8u log2_max_pic_order_cnt_lsb_minus4;
+ int8u max_num_ref_frames;
+ int8u pic_struct_FirstDetected; //For stats only
+ bool constraint_set3_flag;
+ bool separate_colour_plane_flag;
+ bool delta_pic_order_always_zero_flag;
+ bool frame_mbs_only_flag;
+ bool mb_adaptive_frame_field_flag;
+ bool IsSynched; //Computed value
+
+ //Computed values
+ bool NalHrdBpPresentFlag() {return vui_parameters && vui_parameters->NAL;}
+ bool VclHrdBpPresentFlag() {return vui_parameters && vui_parameters->VCL;}
+ bool CpbDpbDelaysPresentFlag() {return vui_parameters && (vui_parameters->NAL || vui_parameters->VCL);}
+ int8u ChromaArrayType() {return separate_colour_plane_flag?0:chroma_format_idc;}
+
+ //Constructor/Destructor
+ ~seq_parameter_set_struct()
+ {
+ if (vui_parameters)
+ {
+ delete vui_parameters->NAL; //vui_parameters->NAL=NULL;
+ delete vui_parameters->VCL; //vui_parameters->VCL=NULL;
+ delete vui_parameters->bitstream_restriction; //vui_parameters->bitstream_restriction=NULL;
+ delete vui_parameters; //vui_parameters=NULL;
+ }
+ }
+ };
+ typedef vector<seq_parameter_set_struct*> seq_parameter_set_structs;
+
+ //Structures - pic_parameter_set
+ struct pic_parameter_set_struct
+ {
+ int8u seq_parameter_set_id;
+ int8u num_ref_idx_l0_default_active_minus1;
+ int8u num_ref_idx_l1_default_active_minus1;
+ int8u weighted_bipred_idc;
+ bool entropy_coding_mode_flag;
+ bool bottom_field_pic_order_in_frame_present_flag;
+ bool weighted_pred_flag;
+ bool redundant_pic_cnt_present_flag;
+ bool IsSynched; //Computed value
+ };
+ typedef vector<pic_parameter_set_struct*> pic_parameter_set_structs;
+
+ //Streams management
+ void Streams_Fill();
+ void Streams_Fill(vector<seq_parameter_set_struct*>::iterator seq_parameter_set_Item);
+ void Streams_Fill_subset(vector<seq_parameter_set_struct*>::iterator seq_parameter_set_Item);
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+ void Synched_Init();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test();
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Per element
+ void Header_Parse();
+ bool Header_Parser_QuickSearch();
+ bool Header_Parser_Fill_Size();
+ void Data_Parse();
+
+ #if MEDIAINFO_DUPLICATE
+ //Output buffer
+ size_t Output_Buffer_Get (const String &Value);
+ size_t Output_Buffer_Get (size_t Pos);
+ #endif //MEDIAINFO_DUPLICATE
+
+ //Options
+ void Option_Manage ();
+
+ //Elements
+ void slice_layer_without_partitioning_IDR();
+ void slice_layer_without_partitioning_non_IDR();
+ void slice_header();
+ void seq_parameter_set();
+ void pic_parameter_set();
+ void sei();
+ void sei_message(int32u &seq_parameter_set_id);
+ void sei_message_buffering_period(int32u &seq_parameter_set_id);
+ void sei_message_buffering_period_xxl(void* xxl);
+ void sei_message_pic_timing(int32u payloadSize, int32u seq_parameter_set_id);
+ void sei_message_user_data_registered_itu_t_t35();
+ void sei_message_user_data_registered_itu_t_t35_DTG1();
+ void sei_message_user_data_registered_itu_t_t35_GA94();
+ void sei_message_user_data_registered_itu_t_t35_GA94_03();
+ void sei_message_user_data_registered_itu_t_t35_GA94_03_Delayed(int32u seq_parameter_set_id);
+ void sei_message_user_data_registered_itu_t_t35_GA94_06();
+ void sei_message_user_data_unregistered(int32u payloadSize);
+ void sei_message_user_data_unregistered_x264(int32u payloadSize);
+ void sei_message_recovery_point();
+ void sei_message_mainconcept(int32u payloadSize);
+ void access_unit_delimiter();
+ void filler_data();
+ void prefix_nal_unit(bool svc_extension_flag);
+ void subset_seq_parameter_set();
+ void slice_layer_extension(bool svc_extension_flag);
+
+ //Packets - SubElements
+ bool seq_parameter_set_data(vector<seq_parameter_set_struct*> &Data, int32u &Data_id);
+ void seq_parameter_set_svc_extension();
+ void seq_parameter_set_mvc_extension(int32u subset_seq_parameter_sets_id);
+ void scaling_list(int32u ScalingList_Size);
+ void vui_parameters(void* &vui_parameters_Item);
+ void svc_vui_parameters_extension();
+ void mvc_vui_parameters_extension();
+ void hrd_parameters(void* &hrd_parameters_Item);
+ void nal_unit_header_svc_extension();
+ void nal_unit_header_mvc_extension();
+ void ref_pic_list_modification(int32u slice_type, bool mvc);
+ void pred_weight_table(int32u num_ref_idx_l0_active_minus1, int32u num_ref_idx_l1_active_minus1, int8u ChromaArrayType);
+ void dec_ref_pic_marking(vector<int8u> &memory_management_control_operations);
+
+ //Packets - Specific
+ void SPS_PPS();
+
+ //Streams
+ struct stream
+ {
+ bool Searching_Payload;
+ bool ShouldDuplicate;
+
+ stream()
+ {
+ Searching_Payload=false;
+ ShouldDuplicate=false;
+ }
+ };
+ vector<stream> Streams;
+
+ //Temporal references
+ struct temporal_reference
+ {
+ struct buffer_data
+ {
+ size_t Size;
+ int8u* Data;
+
+ buffer_data()
+ {
+ Size=0;
+ Data=NULL;
+ }
+
+ ~buffer_data()
+ {
+ delete[] Data; //Data=NULL;
+ }
+ };
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ buffer_data* GA94_03;
+ #endif //MEDIAINFO_DTVCCTRANSPORT_YES
+
+ int32u frame_num;
+ int8u slice_type;
+ bool IsTop;
+ bool IsField;
+
+ temporal_reference()
+ {
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ GA94_03=NULL;
+ #endif //MEDIAINFO_DTVCCTRANSPORT_YES
+ slice_type=(int8u)-1;
+ }
+
+ ~temporal_reference()
+ {
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ delete GA94_03; //GA94_03=NULL;
+ #endif //MEDIAINFO_DTVCCTRANSPORT_YES
+ }
+ };
+ typedef vector<temporal_reference*> temporal_references;
+ temporal_references TemporalReferences; //per pic_order_cnt_lsb
+ temporal_reference* TemporalReferences_DelayedElement;
+ size_t TemporalReferences_Min;
+ size_t TemporalReferences_Max;
+ size_t TemporalReferences_Reserved;
+ size_t TemporalReferences_Offset;
+ size_t TemporalReferences_Offset_pic_order_cnt_lsb_Last;
+ int64s TemporalReferences_pic_order_cnt_Min;
+
+ //Text
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ File__Analyze* GA94_03_Parser;
+ bool GA94_03_IsPresent;
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+
+ //Replacement of File__Analyze buffer
+ const int8u* Buffer_ToSave;
+ size_t Buffer_Size_ToSave;
+
+ //parameter_sets
+ seq_parameter_set_structs seq_parameter_sets;
+ seq_parameter_set_structs subset_seq_parameter_sets;
+ pic_parameter_set_structs pic_parameter_sets;
+
+ //File specific
+ int8u SizeOfNALU_Minus1;
+
+ //Status
+ size_t IFrame_Count;
+ int32s prevPicOrderCntMsb;
+ int32u prevPicOrderCntLsb;
+ int32u prevTopFieldOrderCnt;
+ int32u prevFrameNum;
+ int32u prevFrameNumOffset;
+ vector<int8u> prevMemoryManagementControlOperations;
+
+ //Count of a Packets
+ size_t Block_Count;
+ size_t Interlaced_Top;
+ size_t Interlaced_Bottom;
+ size_t Structure_Field;
+ size_t Structure_Frame;
+
+ //Temp
+ Ztring Encoded_Library;
+ Ztring Encoded_Library_Name;
+ Ztring Encoded_Library_Version;
+ Ztring Encoded_Library_Date;
+ Ztring Encoded_Library_Settings;
+ Ztring BitRate_Nominal;
+ Ztring MuxingMode;
+ string PictureTypes_PreviousFrames;
+ int64u tc;
+ int32u Firstpic_order_cnt_lsbInBlock;
+ int8u nal_ref_idc;
+ int8u FrameRate_Divider;
+ bool FirstPFrameInGop_IsParsed;
+
+ //Helpers
+ string GOP_Detect (string PictureTypes);
+ string ScanOrder_Detect (string ScanOrders);
+
+ #if MEDIAINFO_DUPLICATE
+ bool File__Duplicate_Set (const Ztring &Value); //Fill a new File__Duplicate value
+ void File__Duplicate_Write (int64u Element_Code, int32u frame_num=(int32u)-1);
+ File__Duplicate__Writer Writer;
+ int8u Duplicate_Buffer[1024*1024];
+ size_t Duplicate_Buffer_Size;
+ size_t frame_num_Old;
+ bool SPS_PPS_AlreadyDone;
+ bool FLV;
+ #endif //MEDIAINFO_DUPLICATE
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc_Duplicate.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc_Duplicate.cpp
new file mode 100644
index 000000000..43864395b
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Avc_Duplicate.cpp
@@ -0,0 +1,274 @@
+// File__Duplicate - Duplication of some formats
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Duplication helper for some specific formats
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AVC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Avc.h"
+#include "MediaInfo/MediaInfo_Config.h"
+#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#include "ZenLib/ZtringList.h"
+#include "ZenLib/File.h"
+#include <cstring>
+using namespace ZenLib;
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Options
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Avc::Option_Manage()
+{
+ #if MEDIAINFO_DUPLICATE
+ //File__Duplicate configuration
+ if (File__Duplicate_HasChanged())
+ {
+ //Autorisation of other streams
+ Streams[0x07].ShouldDuplicate=true;
+ }
+ #endif //MEDIAINFO_DUPLICATE
+}
+
+//***************************************************************************
+// Set
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DUPLICATE
+bool File_Avc::File__Duplicate_Set (const Ztring &Value)
+{
+ ZtringList List(Value);
+
+ //Searching Target
+ bool IsForUs=false;
+ std::vector<ZtringList::iterator> Targets_ToAdd;
+ std::vector<ZtringList::iterator> Targets_ToRemove;
+ std::vector<ZtringList::iterator> Orders_ToAdd;
+ std::vector<ZtringList::iterator> Orders_ToRemove;
+ for (ZtringList::iterator Current=List.begin(); Current<List.end(); Current++)
+ {
+ //Detecting if we want to remove
+ bool ToRemove=false;
+ if (Current->find(_T('-'))==0)
+ {
+ ToRemove=true;
+ Current->erase(Current->begin());
+ }
+
+ //Managing targets
+ if (Current->find(_T("file:"))==0
+ || Current->find(_T("memory:"))==0)
+ (ToRemove?Targets_ToRemove:Targets_ToAdd).push_back(Current);
+ //Parser name
+ else if (Current->find(_T("parser=Avc"))==0)
+ IsForUs=true;
+ //Managing orders
+ else
+ (ToRemove?Orders_ToRemove:Orders_ToAdd).push_back(Current);
+ }
+
+ //For us?
+ if (!IsForUs)
+ return false;
+
+ //Configuration of initial values
+ frame_num_Old=(int32u)-1;
+ Duplicate_Buffer_Size=0;
+ SPS_PPS_AlreadyDone=false;
+ FLV=false;
+
+ //For each target to add
+ for (std::vector<ZtringList::iterator>::iterator Target=Targets_ToAdd.begin(); Target<Targets_ToAdd.end(); Target++)
+ Writer.Configure(**Target);
+
+ //For each order to add
+ for (std::vector<ZtringList::iterator>::iterator Order=Orders_ToAdd.begin(); Order<Orders_ToAdd.end(); Order++)
+ if ((**Order)==_T("format=Flv"))
+ FLV=true;
+
+ return true;
+}
+#endif //MEDIAINFO_DUPLICATE
+
+//***************************************************************************
+// Write
+//***************************************************************************
+
+#if MEDIAINFO_DUPLICATE
+void File_Avc::File__Duplicate_Write (int64u Element_Code, int32u frame_num)
+{
+ const int8u* ToAdd=Buffer+Buffer_Offset-(size_t)Header_Size+3;
+ size_t ToAdd_Size=(size_t)(Element_Size+Header_Size-3);
+
+ if (!SPS_PPS_AlreadyDone)
+ {
+ if (Element_Code==7)
+ {
+ std::memcpy(Duplicate_Buffer, ToAdd, ToAdd_Size);
+ Duplicate_Buffer_Size=ToAdd_Size;
+
+ }
+ else if (Element_Code==8)
+ {
+
+ // Form:
+ // 8 bytes : PTS
+ // 8 bytes : DTS
+ // 8 bytes : Size (without header)
+ // 1 byte : Type (0=Frame, 1=Header);
+ // 7 bytes : Reserved
+ size_t Extra;
+ if (FLV)
+ Extra=1; //FLV
+ else
+ Extra=0; //MPEG-4
+ int8u Header[32];
+ int64u2BigEndian(Header+ 0, FrameInfo.PTS);
+ int64u2BigEndian(Header+ 8, FrameInfo.DTS);
+ int64u2BigEndian(Header+16, 5+Extra+2+Duplicate_Buffer_Size+1+2+ToAdd_Size); //5+Extra for SPS_SQS header, 2 for SPS size, 1 for PPS count, 2 for PPS size
+ Header[24]=1;
+ int56u2BigEndian(Header+25, 0);
+ Writer.Write(Header, 32);
+
+ //SPS_PPS
+ int8u* SPS_SQS=new int8u[5+Extra];
+ if (Extra==1)
+ {
+ SPS_SQS[0]=0x01; //Profile FLV
+ SPS_SQS[1]=(!seq_parameter_sets.empty() && seq_parameter_sets[0])?seq_parameter_sets[0]->profile_idc:0x00; //Compatible Profile. TODO: Handling more than 1 seq_parameter_set
+ SPS_SQS[2]=0x00; //Reserved
+ }
+ else
+ {
+ SPS_SQS[0]=(!seq_parameter_sets.empty() && seq_parameter_sets[0])?seq_parameter_sets[0]->profile_idc:0x00; //Profile MPEG-4. TODO: Handling more than 1 seq_parameter_set
+ SPS_SQS[1]=0x00; //Compatible Profile
+ }
+ SPS_SQS[2+Extra]=(!seq_parameter_sets.empty() && seq_parameter_sets[0])?seq_parameter_sets[0]->level_idc:0x00; //Level. TODO: Handling more than 1 seq_parameter_set
+ SPS_SQS[3+Extra]=0xFF; //Reserved + Size of NALU length minus 1
+ SPS_SQS[4+Extra]=0xE1; //Reserved + seq_parameter_set count
+ Writer.Write(SPS_SQS, 5+Extra);
+
+ //NALU
+ int8u NALU[2];
+ NALU[0]=((Duplicate_Buffer_Size)>> 8)&0xFF;
+ NALU[1]=((Duplicate_Buffer_Size)>> 0)&0xFF;
+ Writer.Write(NALU, 2);
+
+ //SPS
+ Writer.Write(Duplicate_Buffer, Duplicate_Buffer_Size);
+ Duplicate_Buffer_Size=0;
+
+ //PPS count
+ SPS_SQS[0]=0x01; //pic_parameter_set count
+ Writer.Write(SPS_SQS, 1);
+ delete[] SPS_SQS;
+
+ //NALU
+ NALU[0]=((ToAdd_Size)>> 8)&0xFF;
+ NALU[1]=((ToAdd_Size)>> 0)&0xFF;
+ Writer.Write(NALU, 2);
+
+ //PPS
+ Writer.Write(ToAdd, ToAdd_Size);
+
+ SPS_PPS_AlreadyDone=true;
+ }
+ }
+ else if (frame_num!=(int32u)-1)
+ {
+ if (frame_num!=frame_num_Old && frame_num_Old!=(int32u)-1 && frame_num!=(int32u)-1)
+ {
+ // Form:
+ // 8 bytes : PTS
+ // 8 bytes : DTS
+ // 8 bytes : Size (without header)
+ // 1 byte : Type (0=Frame, 1=Header);
+ // 7 bytes : Reserved
+ int8u Header[32];
+ int64u2BigEndian(Header+ 0, FrameInfo.PTS);
+ int64u2BigEndian(Header+ 8, FrameInfo.DTS);
+ int64u2BigEndian(Header+16, Duplicate_Buffer_Size);
+ Header[24]=0;
+ int56u2BigEndian(Header+25, 0);
+ Writer.Write(Header, 32);
+
+ Writer.Write(Duplicate_Buffer, Duplicate_Buffer_Size);
+ Duplicate_Buffer_Size=0;
+ }
+
+
+ //NALU
+ int32u2BigEndian(Duplicate_Buffer+Duplicate_Buffer_Size, (int32u)ToAdd_Size); //4 bytes for NALU header
+ Duplicate_Buffer_Size+=4;
+
+ //Frame (partial)
+ std::memcpy(Duplicate_Buffer+Duplicate_Buffer_Size, ToAdd, ToAdd_Size);
+ Duplicate_Buffer_Size+=ToAdd_Size;
+ frame_num_Old=frame_num;
+ }
+}
+#endif //MEDIAINFO_DUPLICATE
+
+//***************************************************************************
+// Output_Buffer
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DUPLICATE
+size_t File_Avc::Output_Buffer_Get (const String &)
+{
+ return Writer.Output_Buffer_Get();
+}
+#endif //MEDIAINFO_DUPLICATE
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DUPLICATE
+size_t File_Avc::Output_Buffer_Get (size_t)
+{
+ return Writer.Output_Buffer_Get();
+}
+#endif //MEDIAINFO_DUPLICATE
+
+} //NameSpace
+
+#endif //MEDIAINFO_AVC_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_AvsV.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_AvsV.cpp
new file mode 100644
index 000000000..fd5733716
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_AvsV.cpp
@@ -0,0 +1,834 @@
+// File_AvsV - Info for AVS Video files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_AVSV_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_AvsV.h"
+#undef FILLING_BEGIN
+#define FILLING_BEGIN() \
+ while (Element_Offset<Element_Size && Buffer[Buffer_Offset+(size_t)Element_Offset]==0x00) \
+ Element_Offset++; \
+ if (Element_Offset!=Element_Size) \
+ Trusted_IsNot("Size error"); \
+ else if (Element_IsOK()) \
+ {
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Ztring AvsV_profile(int8u profile_id)
+{
+ switch (profile_id)
+ {
+ case 0x20 : return "Base";
+ default :
+ return Ztring::ToZtring(profile_id);
+ }
+}
+
+//---------------------------------------------------------------------------
+Ztring AvsV_level(int8u level_id)
+{
+ switch (level_id)
+ {
+ case 0x00 : return Ztring();
+ case 0x10 : return "@2.0";
+ case 0x20 : return "@4.0";
+ case 0x22 : return "@4.2";
+ case 0x40 : return "@6.0";
+ case 0x42 : return "@6.2";
+ default :
+ return _T('@')+Ztring::ToZtring(level_id);
+ }
+}
+
+//---------------------------------------------------------------------------
+const float32 AvsV_frame_rate[]=
+{
+ (float32)0,
+ ((float32)24000)/1001,
+ (float32)24,
+ (float32)25,
+ ((float32)30000)/1001,
+ (float32)30,
+ (float32)50,
+ ((float32)60000)/1001,
+ (float32)60,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+};
+
+//---------------------------------------------------------------------------
+const char* AvsV_chroma_format[]=
+{
+ "",
+ "4:2:0",
+ "4:2:2",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* AvsV_extension_start_code_identifier[]=
+{
+ "",
+ "",
+ "sequence_display",
+ "",
+ "copyright",
+ "",
+ "",
+ "picture_display",
+ "",
+ "",
+ "",
+ "camera_parameters",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* AvsV_video_format[]=
+{
+ "Component",
+ "PAL",
+ "NTSC",
+ "SECAM",
+ "MAC",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const float32 AvsV_aspect_ratio[]=
+{
+ (float32)0,
+ (float32)1,
+ (float32)4/(float32)3,
+ (float32)16/(float32)9,
+ (float32)2.21,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+};
+
+//---------------------------------------------------------------------------
+const char* AvsV_picture_coding_type[]=
+{
+ "",
+ "P",
+ "B",
+ "",
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_AvsV::File_AvsV()
+:File__Analyze()
+{
+ //Config
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+
+ //In
+ Frame_Count_Valid=30;
+ FrameIsAlwaysComplete=false;
+
+ //Temp
+ video_sequence_start_IsParsed=false;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_AvsV::Streams_Fill()
+{
+ //Filling
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "AVS Video");
+ Fill(Stream_Video, 0, Video_Codec, "AVS Video");
+
+ //From sequence header
+ Fill(Stream_Video, 0, Video_Format_Profile, AvsV_profile(profile_id)+AvsV_level(level_id));
+ Fill(Stream_Video, 0, Video_Codec_Profile, AvsV_profile(profile_id)+AvsV_level(level_id));
+ Fill(Stream_Video, StreamPos_Last, Video_Width, horizontal_size);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, vertical_size);
+ Fill(Stream_Video, 0, Video_FrameRate, AvsV_frame_rate[frame_rate_code]/(progressive_sequence?1:2));
+ if (aspect_ratio==0)
+ ;//Forbidden
+ else if (aspect_ratio==1)
+ Fill(Stream_Video, 0, Video_PixelAspectRatio, 1.000, 3, true);
+ else if (display_horizontal_size && display_vertical_size)
+ {
+ if (vertical_size && AvsV_aspect_ratio[aspect_ratio])
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, (float)horizontal_size/vertical_size
+ *AvsV_aspect_ratio[aspect_ratio]/((float)display_horizontal_size/display_vertical_size), 3, true);
+ }
+ else if (AvsV_aspect_ratio[aspect_ratio])
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, AvsV_aspect_ratio[aspect_ratio], 3, true);
+ Fill(Stream_Video, 0, Video_Colorimetry, AvsV_chroma_format[chroma_format]);
+ if (progressive_frame_Count && progressive_frame_Count!=Frame_Count)
+ {
+ //This is mixed
+ }
+ else if (Frame_Count>0) //Only if we have at least one progressive_frame definition
+ {
+ if (progressive_sequence || progressive_frame_Count==Frame_Count)
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Progressive");
+ Fill(Stream_Video, 0, Video_Interlacement, "PPF");
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Interlaced");
+ if ((Interlaced_Top && Interlaced_Bottom) || (!Interlaced_Top && !Interlaced_Bottom))
+ Fill(Stream_Video, 0, Video_Interlacement, "Interlaced");
+ else
+ {
+ Fill(Stream_Video, 0, Video_ScanOrder, Interlaced_Top?"TFF":"BFF");
+ Fill(Stream_Video, 0, Video_Interlacement, Interlaced_Top?"TFF":"BFF");
+ }
+ }
+ }
+ Fill(Stream_Video, 0, Video_BitRate_Nominal, bit_rate*8);
+
+ //From extensions
+ Fill(Stream_Video, 0, Video_Standard, AvsV_video_format[video_format]);
+
+ //Library name
+ if (!Library.empty())
+ {
+ Fill(Stream_Video, 0, Video_Encoded_Library, Library);
+ Fill(Stream_Video, 0, Video_Encoded_Library_Name, Library_Name);
+ Fill(Stream_Video, 0, Video_Encoded_Library_Version, Library_Version);
+ Fill(Stream_Video, 0, Video_Encoded_Library_Date, Library_Date);
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_AvsV::Streams_Finish()
+{
+ //Purge what is not needed anymore
+ if (!File_Name.empty()) //Only if this is not a buffer, with buffer we can have more data
+ Streams.clear();
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_AvsV::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (CC3(Buffer+Buffer_Offset)!=0x000001)
+ Synched=false;
+
+ //Quick search
+ if (Synched && !Header_Parser_QuickSearch())
+ return false;
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_AvsV::Synched_Init()
+{
+ //Count of a Packets
+ progressive_frame_Count=0;
+ Interlaced_Top=0;
+ Interlaced_Bottom=0;
+
+ //Temp
+ bit_rate=0;
+ horizontal_size=0;
+ vertical_size=0;
+ display_horizontal_size=0;
+ display_vertical_size=0;
+ profile_id=0;
+ level_id=0;
+ chroma_format=0;
+ aspect_ratio=0;
+ frame_rate_code=0;
+ video_format=5; //Unspecified video format
+ progressive_sequence=false;
+ low_delay=false;
+
+ //Default stream values
+ Streams.resize(0x100);
+ Streams[0xB0].Searching_Payload=true; //video_sequence_start
+ for (int8u Pos=0xFF; Pos>=0xB9; Pos--)
+ Streams[Pos].Searching_Payload=true; //Testing MPEG-PS
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_AvsV::Header_Parse()
+{
+ //Parsing
+ int8u start_code;
+ Skip_B3( "synchro");
+ Get_B1 (start_code, "start_code");
+ if (!Header_Parser_Fill_Size())
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ //Filling
+ Header_Fill_Code(start_code, Ztring().From_CC1(start_code));
+}
+
+//---------------------------------------------------------------------------
+bool File_AvsV::Header_Parser_QuickSearch()
+{
+ while ( Buffer_Offset+4<=Buffer_Size
+ && Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x01)
+ {
+ //Getting start_code
+ int8u start_code=Buffer[Buffer_Offset+3];
+
+ //Searching start or timestamp
+ if (Streams[start_code].Searching_Payload)
+ return true;
+
+ //Synchronizing
+ Buffer_Offset+=4;
+ Synched=false;
+ if (!Synchronize_0x000001())
+ return false;
+ }
+
+ if (Buffer_Offset+3==Buffer_Size)
+ return false; //Sync is OK, but start_code is not available
+ Trusted_IsNot("AVS Video, Synchronisation lost");
+ return Synchronize();
+}
+
+//---------------------------------------------------------------------------
+bool File_AvsV::Header_Parser_Fill_Size()
+{
+ //Look for next Sync word
+ if (Buffer_Offset_Temp==0) //Buffer_Offset_Temp is not 0 if Header_Parse_Fill_Size() has already parsed first frames
+ Buffer_Offset_Temp=Buffer_Offset+4;
+ while (Buffer_Offset_Temp+4<=Buffer_Size
+ && CC3(Buffer+Buffer_Offset_Temp)!=0x000001)
+ {
+ Buffer_Offset_Temp+=2;
+ while(Buffer_Offset_Temp<Buffer_Size && Buffer[Buffer_Offset_Temp]!=0x00)
+ Buffer_Offset_Temp+=2;
+ if (Buffer_Offset_Temp>=Buffer_Size || Buffer[Buffer_Offset_Temp-1]==0x00)
+ Buffer_Offset_Temp--;
+ }
+
+ //Must wait more data?
+ if (Buffer_Offset_Temp+4>Buffer_Size)
+ {
+ if (FrameIsAlwaysComplete || File_Offset+Buffer_Size==File_Size)
+ Buffer_Offset_Temp=Buffer_Size; //We are sure that the next bytes are a start
+ else
+ return false;
+ }
+
+ //OK, we continue
+ Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset);
+ Buffer_Offset_Temp=0;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_AvsV::Data_Parse()
+{
+ //Parsing
+ switch (Element_Code)
+ {
+ case 0xB0: video_sequence_start(); break;
+ case 0xB1: video_sequence_end(); break;
+ case 0xB2: user_data_start(); break;
+ case 0xB5: extension_start(); break;
+ case 0xB3:
+ case 0xB6: picture_start(); break;
+ case 0xB7: video_edit(); break;
+ case 0xB4:
+ case 0xB8: reserved(); break;
+ default:
+ if (Element_Code>=0x00
+ && Element_Code<=0xAF) slice();
+ else
+ {
+ if (Frame_Count==0 && Buffer_TotalBytes>Buffer_TotalBytes_FirstSynched_Max)
+ Trusted=0;
+ Trusted_IsNot("Unattended element");
+
+ }
+ }
+
+ if (File_Offset+Buffer_Offset+Element_Size==File_Size && Frame_Count>0 && Count_Get(Stream_Video)==0) //Finalize frames in case of there are less than Frame_Count_Valid frames
+ {
+ //No need of more
+ Accept("AVS Video");
+ Finish("AVS Video");
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Packet "00" to "AF"
+void File_AvsV::slice()
+{
+ Element_Name("Slice");
+
+ //Parsing
+ Skip_XX(Element_Size, "Unknown");
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Test();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B0"
+void File_AvsV::video_sequence_start()
+{
+ Element_Name("video_sequence_start");
+
+ //Parsing
+ int32u bit_rate_upper, bit_rate_lower;
+ Get_B1 ( profile_id, "profile_id");
+ Get_B1 ( level_id, "level_id");
+ BS_Begin();
+ Get_SB ( progressive_sequence, "progressive_sequence");
+ Get_S2 (14, horizontal_size, "horizontal_size");
+ Get_S2 (14, vertical_size, "vertical_size");
+ Get_S1 ( 2, chroma_format, "chroma_format");
+ Skip_S1( 3, "sample_precision");
+ Get_S1 ( 4, aspect_ratio, "aspect_ratio"); Param_Info1(AvsV_aspect_ratio[aspect_ratio]);
+ Get_S1 ( 4, frame_rate_code, "frame_rate_code"); Param_Info1(AvsV_frame_rate[frame_rate_code]);
+ Get_S3 (18, bit_rate_lower, "bit_rate_lower");
+ Mark_1 ();
+ Get_S3 (12, bit_rate_upper, "bit_rate_upper");
+ bit_rate=(bit_rate_upper<<18)+bit_rate_lower; Param_Info2(bit_rate*8, " bps");
+ Get_SB ( low_delay, "low_delay");
+ Mark_1 ();
+ Skip_S3(18, "bbv_buffer_size");
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ BS_End();
+
+ //Not sure, but the 3 first official files have this
+ if (Element_Size-Element_Offset)
+ {
+ BS_Begin();
+ Mark_1();
+ BS_End();
+ }
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Clear();
+ NextCode_Add(0xB2); //user_data_start
+ NextCode_Add(0xB3); //picture_start (I)
+ NextCode_Add(0xB5); //extension_start
+
+ //Autorisation of other streams
+ Streams[0xB1].Searching_Payload=true, //video_sequence_end
+ Streams[0xB2].Searching_Payload=true; //user_data_start
+ Streams[0xB3].Searching_Payload=true, //picture_start (I)
+ Streams[0xB4].Searching_Payload=true, //reserved
+ Streams[0xB5].Searching_Payload=true; //extension_start
+ Streams[0xB6].Searching_Payload=true, //picture_start (P or B)
+ Streams[0xB7].Searching_Payload=true; //video_edit
+ Streams[0xB8].Searching_Payload=true, //reserved
+
+ video_sequence_start_IsParsed=true;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B1"
+void File_AvsV::video_sequence_end()
+{
+ Element_Name("video_sequence_start");
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Clear();
+ NextCode_Add(0xB0); //SeqenceHeader
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B2", User defined size, this is often used of library name
+void File_AvsV::user_data_start()
+{
+ Element_Name("user_data_start");
+
+ //Rejecting junk from the end
+ size_t Library_End_Offset=(size_t)Element_Size;
+ while (Library_End_Offset>0
+ && (Buffer[Buffer_Offset+Library_End_Offset-1]<0x20
+ || Buffer[Buffer_Offset+Library_End_Offset-1]>0x7D
+ || (Buffer[Buffer_Offset+Library_End_Offset-1]>=0x3A
+ && Buffer[Buffer_Offset+Library_End_Offset-1]<=0x40)))
+ Library_End_Offset--;
+ if (Library_End_Offset==0)
+ return; //No good info
+
+ //Accepting good data after junk
+ size_t Library_Start_Offset=Library_End_Offset-1;
+ while (Library_Start_Offset>0 && (Buffer[Buffer_Offset+Library_Start_Offset-1]>=0x20 && Buffer[Buffer_Offset+Library_Start_Offset-1]<=0x7D))
+ Library_Start_Offset--;
+
+ //But don't accept non-alpha caracters at the beginning (except for "3ivx")
+ if (Library_End_Offset-Library_Start_Offset!=4 || CC4(Buffer+Buffer_Offset+Library_Start_Offset)!=0x33697678) //3ivx
+ while (Library_Start_Offset<Element_Size && Buffer[Buffer_Offset+Library_Start_Offset]<=0x40)
+ Library_Start_Offset++;
+
+ //Parsing
+ Ztring Temp;
+ if (Library_Start_Offset>0)
+ Skip_XX(Library_Start_Offset, "junk");
+ if (Library_End_Offset-Library_Start_Offset)
+ Get_Local(Library_End_Offset-Library_Start_Offset, Temp,"data");
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "junk");
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Test();
+
+ if (Temp.size()>=4)
+ Library=Temp;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B5"
+void File_AvsV::extension_start()
+{
+ Element_Name("Extension");
+
+ //Parsing
+ int8u extension_start_code_identifier;
+ BS_Begin();
+ Get_S1 ( 4, extension_start_code_identifier, "extension_start_code_identifier"); Param_Info1(AvsV_extension_start_code_identifier[extension_start_code_identifier]);
+ Element_Info1(AvsV_extension_start_code_identifier[extension_start_code_identifier]);
+
+ switch (extension_start_code_identifier)
+ {
+ case 2 :{ //sequence_display
+ //Parsing
+ Get_S1 ( 3, video_format, "video_format"); Param_Info1(AvsV_video_format[video_format]);
+ Skip_SB( "sample_range");
+ TEST_SB_SKIP( "colour_description");
+ Skip_S1( 8, "colour_primaries");
+ Skip_S1( 8, "transfer_characteristics");
+ Skip_S1( 8, "matrix_coefficients");
+ TEST_SB_END();
+ Get_S2 (14, display_horizontal_size, "display_horizontal_size");
+ Mark_1 ();
+ Get_S2 (14, display_vertical_size, "display_vertical_size");
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ BS_End();
+ }
+ break;
+ case 4 :{ //copyright
+ //Parsing
+ Skip_SB( "copyright_flag");
+ Skip_S1( 8, "copyright_id");
+ Skip_SB( "original_or_copy");
+ Skip_S1( 7, "reserved");
+ Mark_1 ();
+ Info_S3(20, copyright_number_1, "copyright_number_1");
+ Mark_1 ();
+ Info_S3(22, copyright_number_2, "copyright_number_2");
+ Mark_1 ();
+ Info_S3(22, copyright_number_3, "copyright_number_3"); Param_Info1(Ztring::ToZtring(((int64u)copyright_number_1<<44)+((int64u)copyright_number_2<<22)+(int64u)copyright_number_3, 16));
+ BS_End();
+ }
+ break;
+ case 11 :{ //camera_parameters
+ //Parsing
+ Skip_SB( "reserved");
+ Skip_S1( 7, "camera_id");
+ Mark_1 ();
+ Skip_S3(22, "height_of_image_device");
+ Mark_1 ();
+ Skip_S3(22, "focal_length");
+ Mark_1 ();
+ Skip_S3(22, "f_number");
+ Mark_1 ();
+ Skip_S3(22, "vertical_angle_of_view");
+ Mark_1 ();
+ Skip_S3(16, "camera_position_x_upper");
+ Mark_1 ();
+ Skip_S3(16, "camera_position_x_lower");
+ Mark_1 ();
+ Skip_S3(16, "camera_position_y_upper");
+ Mark_1 ();
+ Skip_S3(16, "camera_position_y_lower");
+ Mark_1 ();
+ Skip_S3(16, "camera_position_z_upper");
+ Mark_1 ();
+ Skip_S3(16, "camera_position_z_lower");
+ Mark_1 ();
+ Skip_S3(22, "camera_direction_x");
+ Mark_1 ();
+ Skip_S3(22, "camera_direction_y");
+ Mark_1 ();
+ Skip_S3(22, "camera_direction_z");
+ Mark_1 ();
+ Skip_S3(22, "camera_plane_vertical_x");
+ Mark_1 ();
+ Skip_S3(22, "camera_plane_vertical_y");
+ Mark_1 ();
+ Skip_S3(22, "camera_plane_vertical_z");
+ Mark_1 ();
+ Skip_S4(32, "reserved");
+ BS_End();
+ }
+ break;
+ default:{
+ //Parsing
+ Skip_S1(4, "data");
+ BS_End();
+ Skip_XX(Element_Size-Element_Offset, "data");
+ }
+
+ }
+
+ //Not sure, but the 3 first official files have this
+ if (Element_Size-Element_Offset)
+ {
+ BS_Begin();
+ Mark_1();
+ BS_End();
+ }
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Test();
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B3" or "B6"
+void File_AvsV::picture_start()
+{
+ //Counting
+ if (File_Offset+Buffer_Offset+Element_Size==File_Size)
+ Frame_Count_Valid=Frame_Count; //Finalize frames in case of there are less than Frame_Count_Valid frames
+ Frame_Count++;
+
+ //Name
+ Element_Name("picture_start");
+ Element_Info1(Ztring::ToZtring(Frame_Count));
+ Element_Info1C((Element_Code==0xB3), _T("I"));
+
+ //Parsing
+ int8u picture_coding_type=(int8u)-1;
+ bool time_code_flag, progressive_frame, picture_structure=true, top_field_first, repeat_first_field, skip_mode_flag=false, loop_filter_disable;
+ Skip_B2( "bbv_delay");
+ BS_Begin();
+ if (Element_Code==0xB3) //Only I
+ {
+ Get_SB ( time_code_flag, "time_code_flag");
+ if (time_code_flag)
+ {
+ Skip_SB( "time_code_dropframe");
+ Skip_S1(5, "time_code_hours");
+ Skip_S1(6, "time_code_minutes");
+ Skip_S1(6, "time_code_seconds");
+ Skip_S1(6, "time_code_pictures");
+ }
+ }
+ if (Element_Code==0xB6) //Only P or B
+ {
+ Get_S1 ( 2, picture_coding_type, "picture_coding_type"); Element_Info1(AvsV_picture_coding_type[picture_coding_type]);
+ }
+ Skip_S1( 8, "picture_distance");
+ if (low_delay)
+ Skip_UE( "bbv_check_times");
+ Get_SB ( progressive_frame, "progressive_frame");
+ if (!progressive_frame)
+ {
+ Get_SB( picture_structure, "picture_structure");
+ if (Element_Code==0xB6) //Only P or B
+ {
+ if (picture_structure)
+ Skip_SB( "advanced_pred_mode_disable");
+ }
+ }
+ Get_SB ( top_field_first, "top_field_first");
+ Get_SB ( repeat_first_field, "repeat_first_field");
+ Skip_SB( "fixed_picture_qp");
+ Skip_S1( 6, "picture_qp");
+ if (Element_Code==0xB3) //Only I
+ {
+ if (!progressive_frame && !picture_structure)
+ Get_SB( skip_mode_flag, "skip_mode_flag");
+ }
+ if (Element_Code==0xB6) //Only P or B
+ {
+ if (picture_coding_type!=2 || !picture_structure)
+ Skip_SB( "picture_reference_flag");
+ }
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ Skip_SB( "reserved");
+ if (Element_Code==0xB6) //Only P or B
+ {
+ Get_SB( skip_mode_flag, "skip_mode_flag");
+ }
+ Get_SB ( loop_filter_disable, "loop_filter_disable");
+ if (!loop_filter_disable)
+ {
+ bool loop_filter_parameter_flag;
+ Get_SB ( loop_filter_parameter_flag, "loop_filter_parameter_flag");
+ if (loop_filter_parameter_flag)
+ {
+ Skip_SE( "alpha_c_offset");
+ Skip_SE( "beta_offset");
+ }
+ }
+ BS_End();
+
+ if (Element_Size-Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+
+ FILLING_BEGIN();
+ if (progressive_frame==false)
+ {
+ if (picture_structure==true) //Frame
+ {
+ if (top_field_first)
+ Interlaced_Top++;
+ else
+ Interlaced_Bottom++;
+ }
+ }
+ else
+ progressive_frame_Count++;
+
+ //NextCode
+ NextCode_Test();
+ NextCode_Clear();
+ for (int8u Pos=0x00; Pos<=0xAF; Pos++)
+ NextCode_Add(Pos); //slice
+ NextCode_Add(0xB0); //video_sequence_start
+ NextCode_Add(0xB3); //picture_start
+ NextCode_Add(0xB6); //picture_start
+
+ //Autorisation of other streams
+ for (int8u Pos=0x00; Pos<=0xAF; Pos++)
+ Streams[Pos].Searching_Payload=true; //slice
+
+ //Filling only if not already done
+ if (Frame_Count>=Frame_Count_Valid && Count_Get(Stream_Video)==0)
+ {
+ //No need of more
+ Accept("AVS Video");
+ Finish("AVS Video");
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B7"
+void File_AvsV::video_edit()
+{
+ Element_Name("video_edit");
+}
+
+//---------------------------------------------------------------------------
+// Packet "B4" and "B8"
+void File_AvsV::reserved()
+{
+ Element_Name("reserved");
+
+ //Parsing
+ if (Element_Size)
+ Skip_XX(Element_Size, "reserved");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_AVSV_*
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_AvsV.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_AvsV.h
new file mode 100644
index 000000000..7274d743c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_AvsV.h
@@ -0,0 +1,122 @@
+// File_AvsV - Info for AVS Video files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about AVS Video files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_AvsVH
+#define MediaInfo_AvsVH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Multiple/File_Mpeg4.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Avs
+//***************************************************************************
+
+class File_AvsV : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ bool FrameIsAlwaysComplete;
+
+ //constructor/Destructor
+ File_AvsV();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin() {return FileHeader_Begin_0x000001();}
+
+ //Buffer - Synchro
+ bool Synchronize() {return Synchronize_0x000001();}
+ bool Synched_Test();
+ void Synched_Init();
+
+ //Buffer - Per element
+ void Header_Parse();
+ bool Header_Parser_QuickSearch();
+ bool Header_Parser_Fill_Size();
+ void Data_Parse();
+
+ //Elements
+ void slice();
+ void video_sequence_start();
+ void video_sequence_end();
+ void user_data_start();
+ void extension_start();
+ void picture_start();
+ void video_edit();
+ void reserved();
+
+ //Count of a Packets
+ size_t progressive_frame_Count;
+ size_t Interlaced_Top;
+ size_t Interlaced_Bottom;
+
+ //From user_data
+ Ztring Library;
+ Ztring Library_Name;
+ Ztring Library_Version;
+ Ztring Library_Date;
+
+ //Temp
+ int32u bit_rate; //From video_sequence_start
+ int16u horizontal_size; //From video_sequence_start
+ int16u vertical_size; //From video_sequence_start
+ int16u display_horizontal_size; //From sequence_display
+ int16u display_vertical_size; //From sequence_display
+ int8u profile_id; //From video_sequence_start
+ int8u level_id; //From video_sequence_start
+ int8u chroma_format; //From video_sequence_start
+ int8u aspect_ratio; //From video_sequence_start
+ int8u frame_rate_code; //From video_sequence_start
+ int8u video_format; //From sequence_display
+ bool progressive_sequence; //From video_sequence_start
+ bool low_delay; //From video_sequence_start
+ bool video_sequence_start_IsParsed; //From video_sequence_start
+
+ //Streams
+ struct stream
+ {
+ bool Searching_Payload;
+
+ stream()
+ {
+ Searching_Payload=false;
+ }
+ };
+ std::vector<stream> Streams;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Dirac.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Dirac.cpp
new file mode 100644
index 000000000..e719cac39
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Dirac.cpp
@@ -0,0 +1,902 @@
+// File_Dirac - Info for DIRAC files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_DIRAC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Dirac.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+const char* Dirac_base_video_format(intu base_video_format)
+{
+ switch (base_video_format)
+ {
+ case 1 : return "QSIF525";
+ case 2 : return "QCIF";
+ case 3 : return "SIF525";
+ case 4 : return "CIF";
+ case 5 : return "4SIF525";
+ case 6 : return "4CIF";
+ case 7 : return "480i60";
+ case 8 : return "576i50";
+ case 9 : return "720p50";
+ case 10 : return "720p60";
+ case 11 : return "1080i60";
+ case 12 : return "1080i50";
+ case 13 : return "1080p60";
+ case 14 : return "1080p60";
+ case 15 : return "2K-24";
+ case 16 : return "4K-24";
+ case 17 : return "4K-60";
+ case 18 : return "4K-50";
+ case 19 : return "8K-60";
+ case 20 : return "8K-50";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+float32 Dirac_frame_rate(int32u frame_rate_index)
+{
+ switch (frame_rate_index)
+ {
+ case 0 : return (float32)0; //Reserved
+ case 1 : return (float32)24000/(float32)1001;
+ case 2 : return (float32)24;
+ case 3 : return (float32)25;
+ case 4 : return (float32)30000/(float32)1001;
+ case 5 : return (float32)30;
+ case 6 : return (float32)50;
+ case 7 : return (float32)60000/(float32)1001;
+ case 8 : return (float32)60;
+ case 9 : return (float32)15000/(float32)1001;
+ case 10 : return (float32)12.5;
+ default : return (float32)0; //Unknown
+ }
+}
+
+//---------------------------------------------------------------------------
+float32 Dirac_pixel_aspect_ratio(int32u pixel_aspect_ratio_index)
+{
+ switch (pixel_aspect_ratio_index)
+ {
+ case 0 : return (float32)0; //Reserved
+ case 1 : return (float32)1; //Reserved
+ case 2 : return (float32)10/(float32)11;
+ case 3 : return (float32)12/(float32)11;
+ case 4 : return (float32)40/(float32)33;
+ case 5 : return (float32)16/(float32)11;
+ case 6 : return (float32) 4/(float32) 3;
+ default : return (float32)0; //Unknown
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Dirac_picture_coding_mode(int32u picture_coding_mode)
+{
+ switch (picture_coding_mode)
+ {
+ case 0 : return "PPF";
+ case 1 : return "Interlaced";
+ default: return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Dirac_source_sampling(int32u source_sampling)
+{
+ switch (source_sampling)
+ {
+ case 0 : return "Progressive";
+ case 1 : return "Interlaced";
+ default: return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Dirac_source_sampling_Codec(int32u source_sampling)
+{
+ switch (source_sampling)
+ {
+ case 0 : return "PPF";
+ case 1 : return "Interlaced";
+ default: return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Dirac_chroma_format(int32u chroma_format)
+{
+ switch (chroma_format)
+ {
+ case 0 : return "4:4:4";
+ case 1 : return "4:2:2";
+ case 2 : return "4:2:0";
+ default: return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+void Dirac_base_video_format(int32u base_video_format,
+ int32u &frame_width,
+ int32u &frame_height,
+ int32u &chroma_format,
+ int32u &source_sampling,
+ int32u &clean_width,
+ int32u &clean_height,
+ int32u &clean_left_offset,
+ int32u &clean_top_offset,
+ float32 &frame_rate,
+ float32 &pixel_aspect_ratio)
+{
+ switch (base_video_format)
+ {
+ case 0 : frame_width=640;
+ frame_height=480;
+ chroma_format=2;
+ source_sampling=0;
+ clean_width=640;
+ clean_height=480;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(1);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 1 : frame_width=176;
+ frame_height=120;
+ chroma_format=2;
+ source_sampling=0;
+ clean_width=176;
+ clean_height=144;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(9);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(2);
+ return;
+ case 2 : frame_width=176;
+ frame_height=144;
+ chroma_format=2;
+ source_sampling=0;
+ clean_width=176;
+ clean_height=144;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(10);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(3);
+ return;
+ case 3 : frame_width=352;
+ frame_height=240;
+ chroma_format=2;
+ source_sampling=0;
+ clean_width=352;
+ clean_height=240;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(9);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(2);
+ return;
+ case 4 : frame_width=352;
+ frame_height=288;
+ chroma_format=2;
+ source_sampling=0;
+ clean_width=352;
+ clean_height=288;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(10);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(3);
+ return;
+ case 5 : frame_width=704;
+ frame_height=480;
+ chroma_format=2;
+ source_sampling=0;
+ clean_width=704;
+ clean_height=480;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(9);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(2);
+ return;
+ case 6 : frame_width=704;
+ frame_height=576;
+ chroma_format=2;
+ source_sampling=0;
+ clean_width=704;
+ clean_height=576;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(10);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(3);
+ return;
+ case 7 : frame_width=720;
+ frame_height=480;
+ chroma_format=1;
+ source_sampling=1;
+ clean_width=704;
+ clean_height=480;
+ clean_left_offset=8;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(4);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(2);
+ return;
+ case 8 : frame_width=720;
+ frame_height=576;
+ chroma_format=1;
+ source_sampling=1;
+ clean_width=704;
+ clean_height=576;
+ clean_left_offset=8;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(3);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(3);
+ return;
+ case 9 : frame_width=1280;
+ frame_height=720;
+ chroma_format=1;
+ source_sampling=0;
+ clean_width=1280;
+ clean_height=720;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(7);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 10 : frame_width=1280;
+ frame_height=720;
+ chroma_format=1;
+ source_sampling=0;
+ clean_width=1280;
+ clean_height=720;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(6);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 11 : frame_width=1920;
+ frame_height=1080;
+ chroma_format=1;
+ source_sampling=1;
+ clean_width=1920;
+ clean_height=1080;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(4);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 12 : frame_width=1920;
+ frame_height=1080;
+ chroma_format=1;
+ source_sampling=1;
+ clean_width=1920;
+ clean_height=1080;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(3);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 13 : frame_width=1920;
+ frame_height=1080;
+ chroma_format=1;
+ source_sampling=0;
+ clean_width=1920;
+ clean_height=1080;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(7);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 14 : frame_width=1920;
+ frame_height=1080;
+ chroma_format=1;
+ source_sampling=0;
+ clean_width=1920;
+ clean_height=1080;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(6);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 15 : frame_width=2048;
+ frame_height=1080;
+ chroma_format=0;
+ source_sampling=0;
+ clean_width=2048;
+ clean_height=1080;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(2);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 16 : frame_width=4096;
+ frame_height=2160;
+ chroma_format=0;
+ source_sampling=0;
+ clean_width=4096;
+ clean_height=2160;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(2);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 17 : frame_width=3840;
+ frame_height=2160;
+ chroma_format=0;
+ source_sampling=0;
+ clean_width=3840;
+ clean_height=2160;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(7);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 18 : frame_width=3840;
+ frame_height=2160;
+ chroma_format=0;
+ source_sampling=0;
+ clean_width=3840;
+ clean_height=2160;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(6);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 19 : frame_width=7680;
+ frame_height=4320;
+ chroma_format=0;
+ source_sampling=0;
+ clean_width=7680;
+ clean_height=4320;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(7);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ case 20 : frame_width=7680;
+ frame_height=4320;
+ chroma_format=0;
+ source_sampling=0;
+ clean_width=7680;
+ clean_height=4320;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate(6);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(1);
+ return;
+ default : frame_width=0;
+ frame_height=0;
+ chroma_format=(int32u)-1;
+ source_sampling=(int32u)-1;
+ clean_width=0;
+ clean_height=0;
+ clean_left_offset=0;
+ clean_top_offset=0;
+ frame_rate=Dirac_frame_rate((int32u)-1);
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio((int32u)-1);
+ return;
+ }
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Dirac::File_Dirac()
+:File__Analyze()
+{
+ //Configuration
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+
+ //In
+ Frame_Count_Valid=1;
+ Ignore_End_of_Sequence=false;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dirac::Streams_Fill()
+{
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "Dirac");
+ Fill(Stream_Video, 0, Video_Codec, "Dirac");
+
+ if (clean_width)
+ Fill(Stream_Video, StreamPos_Last, Video_Width, clean_width);
+ if (clean_height)
+ Fill(Stream_Video, StreamPos_Last, Video_Height, clean_height);
+ if (pixel_aspect_ratio)
+ {
+ Fill(Stream_Video, 0, Video_PixelAspectRatio, pixel_aspect_ratio, 3, true);
+ if (clean_height!=0)
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, ((float)clean_width)/clean_height*pixel_aspect_ratio, 3, true);
+ }
+ if (frame_rate)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, frame_rate);
+ Fill(Stream_Video, 0, Video_Colorimetry, Dirac_chroma_format(chroma_format));
+ Fill(Stream_Video, 0, Video_ScanType, Dirac_source_sampling(source_sampling));
+ Fill(Stream_Video, 0, Video_Interlacement, Dirac_source_sampling_Codec(source_sampling));
+}
+
+//---------------------------------------------------------------------------
+void File_Dirac::Streams_Finish()
+{
+ //Purge what is not needed anymore
+ if (!File_Name.empty()) //Only if this is not a buffer, with buffer we can have more data
+ Streams.clear();
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Dirac::Synchronize()
+{
+ //Synchronizing
+ while(Buffer_Offset+4<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x42
+ || Buffer[Buffer_Offset+1]!=0x42
+ || Buffer[Buffer_Offset+2]!=0x43
+ || Buffer[Buffer_Offset+3]!=0x44)) //"BBCD"
+ {
+ Buffer_Offset+=2;
+ while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x42)
+ Buffer_Offset+=2;
+ if (Buffer_Offset>=Buffer_Size || Buffer[Buffer_Offset-1]==0x42)
+ Buffer_Offset--;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+4>Buffer_Size)
+ {
+ if (Buffer_Offset+3==Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x424243) //"BBC"
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && CC2(Buffer+Buffer_Offset)!=0x4242) //"BB"
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && CC1(Buffer+Buffer_Offset)!=0x42) //"B"
+ Buffer_Offset++;
+ return false;
+ }
+
+ //Synched is OK
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Dirac::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (CC4(Buffer+Buffer_Offset)!=0x42424344) //"BBCD"
+ Synched=false;
+
+ //Quick search
+ if (Synched && !Header_Parser_QuickSearch())
+ return false;
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Dirac::Synched_Init()
+{
+ //Temp
+ Dirac_base_video_format((int32u)-1, frame_width, frame_height, chroma_format, source_sampling,
+ clean_width, clean_height, clean_left_offset, clean_top_offset,
+ frame_rate, pixel_aspect_ratio);
+
+ //Default stream values
+ Streams.resize(0x100);
+ Streams[0x00].Searching_Payload=true; //Sequence header
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Dirac::Header_Parse()
+{
+ //Parsing
+ int32u Next_Parse_Offset, Previous_Parse_Offset;
+ int8u Parse_Code;
+ Skip_C4( "Parse Info Prefix");
+ Get_B1 (Parse_Code, "Parse Code");
+ Get_B4 (Next_Parse_Offset, "Next Parse Offset");
+ Get_B4 (Previous_Parse_Offset, "Previous Parse Offset");
+
+ //Filling
+ Header_Fill_Code(Parse_Code, Ztring().From_CC1(Parse_Code));
+ Header_Fill_Size((Parse_Code==0x10 && Next_Parse_Offset==0)?13:Next_Parse_Offset); //Speacial case if this is the End Of Sequence
+}
+
+//---------------------------------------------------------------------------
+bool File_Dirac::Header_Parser_QuickSearch()
+{
+ while ( Buffer_Offset+5<=Buffer_Size
+ && Buffer[Buffer_Offset ]==0x42
+ && Buffer[Buffer_Offset+1]==0x42
+ && Buffer[Buffer_Offset+2]==0x43
+ && Buffer[Buffer_Offset+3]==0x44) //"BBCD"
+ {
+ //Getting start_code
+ int8u start_code=CC1(Buffer+Buffer_Offset+4);
+
+ //Searching start
+ if (Streams[start_code].Searching_Payload)
+ return true;
+
+ //Getting size
+ Buffer_Offset+=BigEndian2int32u(Buffer+Buffer_Offset+5);
+ }
+
+ if (Buffer_Offset+4==Buffer_Size)
+ return false; //Sync is OK, but start_code is not available
+ if (Buffer_Offset+5<=Buffer_Size)
+ Trusted_IsNot("Dirac, Synchronisation lost");
+ Synched=false;
+ return Synchronize();
+}
+
+//---------------------------------------------------------------------------
+void File_Dirac::Data_Parse()
+{
+ //Parsing
+ switch (Element_Code)
+ {
+ case 0x00 : Sequence_header(); break;
+ case 0x10 : End_of_Sequence(); break;
+ case 0x20 : Auxiliary_data(); break;
+ case 0x30 : Padding_data(); break;
+ case 0x0C : Intra_Reference_Picture(); break;
+ case 0x08 : Intra_Non_Reference_Picture(); break;
+ case 0x4C : Intra_Reference_Picture_No(); break;
+ case 0x48 : Intra_Non_Reference_Picture_No(); break;
+ case 0x0D : Inter_Reference_Picture_1(); break;
+ case 0x0E : Inter_Reference_Picture_2(); break;
+ case 0x09 : Inter_Non_Reference_Picture_1(); break;
+ case 0x0A : Inter_Non_Reference_Picture_2(); break;
+ case 0xCC : Reference_Picture_Low(); break;
+ case 0xC8 : Intra_Non_Reference_Picture_Low(); break;
+ default : Reserved();
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Packet "00"
+void File_Dirac::Sequence_header()
+{
+ Element_Name("Sequence header");
+
+ //Parsing
+ int32u version_major, version_minor, profile, level, base_video_format;
+ BS_Begin();
+ Get_UI(version_major, "version major");
+ Get_UI(version_minor, "version minor");
+ Get_UI(profile, "profile");
+ Get_UI(level, "level");
+
+ if (version_major<=2)
+ {
+ Get_UI(base_video_format, "base video format"); //Param_Info1(Dirac_base_video_format(base_video_format));
+ Dirac_base_video_format(base_video_format, frame_width, frame_height, chroma_format, source_sampling,
+ clean_width, clean_height, clean_left_offset, clean_top_offset,
+ frame_rate, pixel_aspect_ratio);
+ TEST_SB_SKIP( "custom dimensions flag");
+ Get_UI (frame_width, "frame width");
+ Get_UI (frame_height, "frame height");
+ TEST_SB_END();
+ TEST_SB_SKIP( "custom chroma format flag");
+ Get_UI (chroma_format, "chroma format"); Param_Info1(Dirac_chroma_format(chroma_format));
+ TEST_SB_END();
+ TEST_SB_SKIP( "custom scan format flag");
+ Get_UI (source_sampling, "source sampling"); Param_Info1(Dirac_source_sampling(source_sampling));
+ TEST_SB_END();
+ TEST_SB_SKIP( "frame rate flag");
+ int32u frame_rate_index;
+ Get_UI (frame_rate_index, "index"); Param_Info1(Dirac_frame_rate(frame_rate_index));
+ if (frame_rate_index==0)
+ {
+ int32u frame_rate_numer, frame_rate_denom;
+ Get_UI (frame_rate_numer, "frame rate numer");
+ Get_UI (frame_rate_denom, "frame rate denom");
+ frame_rate=((float32)frame_rate_numer)/((float32)frame_rate_denom);
+ }
+ else
+ frame_rate=Dirac_frame_rate(frame_rate_index);
+ TEST_SB_END();
+ TEST_SB_SKIP( "pixel aspect ratio flag");
+ int32u pixel_aspect_ratio_index;
+ Get_UI (pixel_aspect_ratio_index, "index"); Param_Info1(Dirac_pixel_aspect_ratio(pixel_aspect_ratio_index));
+ if (pixel_aspect_ratio_index==0)
+ {
+ int32u pixel_aspect_ratio_numer, pixel_aspect_ratio_denom;
+ Get_UI (pixel_aspect_ratio_numer, "pixel aspect ratio numer");
+ Get_UI (pixel_aspect_ratio_denom, "pixel aspect ratio denom");
+ pixel_aspect_ratio=((float32)pixel_aspect_ratio_numer)/((float32)pixel_aspect_ratio_denom);
+ }
+ else
+ pixel_aspect_ratio=Dirac_pixel_aspect_ratio(pixel_aspect_ratio_index);
+ TEST_SB_END();
+ TESTELSE_SB_SKIP( "custom clean area flag");
+ Get_UI (clean_width, "clean width");
+ Get_UI (clean_height, "clean height");
+ Get_UI (clean_left_offset, "clean left offset");
+ Get_UI (clean_top_offset, "clean top offset");
+ TESTELSE_SB_ELSE( "custom clean area flag");
+ clean_width=frame_width;
+ clean_height=frame_height;
+ TESTELSE_SB_END();
+ TEST_SB_SKIP( "custom signal range flag");
+ int32u custom_signal_range_index;
+ Get_UI(custom_signal_range_index, "index");
+ if (custom_signal_range_index==0)
+ {
+ Skip_UI( "luma offset");
+ Skip_UI( "luma excursion");
+ Skip_UI( "chroma offset");
+ Skip_UI( "chroma excursion");
+ }
+ TEST_SB_END();
+ TEST_SB_SKIP( "custom colour spec flag");
+ int32u custom_colour_spec_index;
+ Get_UI(custom_colour_spec_index, "index");
+ if (custom_colour_spec_index==0)
+ {
+ TEST_SB_SKIP( "custom colour primaries flag");
+ Skip_UI( "custom colour primaries index");
+ TEST_SB_END();
+ TEST_SB_SKIP( "colour matrix flag");
+ Skip_UI( "colour matrix index");
+ TEST_SB_END();
+ TEST_SB_SKIP( "custom transfer function flag");
+ Skip_UI( "custom transfer function index");
+ TEST_SB_END();
+ }
+ TEST_SB_END();
+ Info_UI(picture_coding_mode, "picture coding mode"); Param_Info1(Dirac_picture_coding_mode(picture_coding_mode));
+ }
+ else
+ {
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ }
+
+ FILLING_BEGIN();
+ //Autorisation of other streams
+ Streams[0x10].Searching_Payload=true; //End_of_Sequence
+ Streams[0x20].Searching_Payload=true; //Auxiliary_data
+ Streams[0x30].Searching_Payload=true; //Padding_data
+ Streams[0x0C].Searching_Payload=true; //Intra_Reference_Picture
+ Streams[0x08].Searching_Payload=true; //Intra_Non_Reference_Picture
+ Streams[0x4C].Searching_Payload=true; //Intra_Reference_Picture_No
+ Streams[0x48].Searching_Payload=true; //Intra_Non_Reference_Picture_No
+ Streams[0x0D].Searching_Payload=true; //Inter_Reference_Picture_1
+ Streams[0x0E].Searching_Payload=true; //Inter_Reference_Picture_2
+ Streams[0x09].Searching_Payload=true; //Inter_Non_Reference_Picture_1
+ Streams[0x0A].Searching_Payload=true; //Inter_Non_Reference_Picture_2
+ Streams[0xCC].Searching_Payload=true; //Reference_Picture_Low
+ Streams[0xC8].Searching_Payload=true; //Intra_Non_Reference_Picture_Low
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "10"
+void File_Dirac::End_of_Sequence()
+{
+ Element_Name("End of Sequence");
+
+ //Parsing
+ if (!Ignore_End_of_Sequence)
+ {
+ NextCode_Clear();
+ Accept("Dirac");
+ Finish("Dirac");
+ }
+}
+
+//---------------------------------------------------------------------------
+// Packet "20"
+void File_Dirac::Auxiliary_data()
+{
+ Element_Name("Auxiliary data");
+
+ //Parsing
+ Skip_XX(Element_Size, "Auxiliary data");
+}
+
+//---------------------------------------------------------------------------
+// Packet "30"
+void File_Dirac::Padding_data()
+{
+ Element_Name("Padding data");
+
+ //Parsing
+ Skip_XX(Element_Size, "Padding data");
+}
+
+//---------------------------------------------------------------------------
+// Packet "0C"
+void File_Dirac::Intra_Reference_Picture()
+{
+ Element_Name("Intra Reference Picture");
+
+ //Parsing
+ picture();
+}
+
+//---------------------------------------------------------------------------
+// Packet "08"
+void File_Dirac::Intra_Non_Reference_Picture()
+{
+ Element_Name("Intra Non Reference Picture");
+
+ //Parsing
+ picture();
+}
+
+//---------------------------------------------------------------------------
+// Packet "4C"
+void File_Dirac::Intra_Reference_Picture_No()
+{
+ Element_Name("Intra Reference Picture (no arithmetic coding)");
+
+ //Parsing
+ picture();
+}
+
+//---------------------------------------------------------------------------
+// Packet "48"
+void File_Dirac::Intra_Non_Reference_Picture_No()
+{
+ Element_Name("Intra Non Reference Picture (no arithmetic coding)");
+
+ //Parsing
+ picture();
+}
+
+//---------------------------------------------------------------------------
+// Packet "0D"
+void File_Dirac::Inter_Reference_Picture_1()
+{
+ Element_Name("Inter Reference Picture (1 picture)");
+
+ //Parsing
+ picture();
+}
+
+//---------------------------------------------------------------------------
+// Packet "0E"
+void File_Dirac::Inter_Reference_Picture_2()
+{
+ Element_Name("Inter Reference Picture (2 pictures)");
+
+ //Parsing
+ picture();
+}
+
+//---------------------------------------------------------------------------
+// Packet "09"
+void File_Dirac::Inter_Non_Reference_Picture_1()
+{
+ Element_Name("Inter Non Reference Picture (1 picture)");
+
+ //Parsing
+ picture();
+}
+
+//---------------------------------------------------------------------------
+// Packet "0A"
+void File_Dirac::Inter_Non_Reference_Picture_2()
+{
+ Element_Name("Inter Non Reference Picture (2 pictures)");
+
+ //Parsing
+ picture();
+}
+
+//---------------------------------------------------------------------------
+// Packet "CC"
+void File_Dirac::Reference_Picture_Low()
+{
+ Element_Name("Reference Picture (low-delay)");
+
+ //Parsing
+ picture();
+}
+
+//---------------------------------------------------------------------------
+// Packet "C8"
+void File_Dirac::Intra_Non_Reference_Picture_Low()
+{
+ Element_Name("Intra Non Reference Picture (low-delay)");
+
+ //Parsing
+ picture();
+}
+
+//---------------------------------------------------------------------------
+void File_Dirac::Reserved()
+{
+ Element_Name("Reserved");
+
+ Skip_XX(Element_Size, "Unknown");
+}
+
+//---------------------------------------------------------------------------
+void File_Dirac::picture()
+{
+ //Parsing
+ Skip_XX(Element_Size, "Data");
+
+ FILLING_BEGIN();
+ //Counting
+ if (File_Offset+Buffer_Offset+Element_Size==File_Size)
+ Frame_Count_Valid=Frame_Count; //Finalize frames in case of there are less than Frame_Count_Valid frames
+
+ //Name
+ Element_Info1(Ztring::ToZtring(Frame_Count));
+
+ //Filling only if not already done
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ if (Frame_Count>=Frame_Count_Valid && Count_Get(Stream_Video)==0)
+ {
+ NextCode_Clear();
+ Accept("Dirac");
+ Finish("Dirac");
+ }
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_DIRAC_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Dirac.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Dirac.h
new file mode 100644
index 000000000..d95fd6260
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Dirac.h
@@ -0,0 +1,114 @@
+// File_Dirac - Info for Dirac files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Dirac files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_DiracH
+#define MediaInfo_File_DiracH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Dirac
+//***************************************************************************
+
+class File_Dirac : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ bool Ignore_End_of_Sequence;
+
+ //Constructor/Destructor
+ File_Dirac();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin() {return FileHeader_Begin_0x000001();}
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+ void Synched_Init();
+
+ //Buffer - Per element
+ void Header_Parse();
+ bool Header_Parser_QuickSearch();
+ bool Header_Parser_Fill_Size();
+ void Data_Parse();
+
+ //Elements
+ void Sequence_header();
+ void End_of_Sequence();
+ void Auxiliary_data();
+ void Padding_data();
+ void Intra_Reference_Picture();
+ void Intra_Non_Reference_Picture();
+ void Intra_Reference_Picture_No();
+ void Intra_Non_Reference_Picture_No();
+ void Inter_Reference_Picture_1();
+ void Inter_Reference_Picture_2();
+ void Inter_Non_Reference_Picture_1();
+ void Inter_Non_Reference_Picture_2();
+ void Reference_Picture_Low();
+ void Intra_Non_Reference_Picture_Low();
+ void Reserved();
+ void picture();
+
+ //Streams
+ struct stream
+ {
+ bool Searching_Payload;
+
+ stream()
+ {
+ Searching_Payload=false;
+ }
+ };
+ std::vector<stream> Streams;
+
+ //Temp
+ int32u frame_width;
+ int32u frame_height;
+ int32u chroma_format;
+ int32u source_sampling;
+ int32u clean_width;
+ int32u clean_height;
+ int32u clean_left_offset;
+ int32u clean_top_offset;
+ float32 frame_rate;
+ float32 pixel_aspect_ratio;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Flic.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Flic.cpp
new file mode 100644
index 000000000..d0466b935
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Flic.cpp
@@ -0,0 +1,148 @@
+// File_Flic - Info for Flic files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// From : http://www.compuphase.com/flic.htm
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_FLIC_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Flic.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Flic::FileHeader_Parse()
+{
+ //Parsing
+ int32u DelayBetweenFrames;
+ int16u Type, Frames, Width, Height, BitsPerPixel, AspectX=0, AspectY=0;
+ Skip_L4( "Size of FLIC including this header");
+ Get_L2 (Type, "File type");
+ Get_L2 (Frames, "Number of frames in first segment");
+ Get_L2 (Width, "Width");
+ Get_L2 (Height, "Height");
+ Get_L2 (BitsPerPixel, "Bits per pixel");
+ Skip_L2( "Flags");
+ Get_L4 (DelayBetweenFrames, "Delay between frames");
+ if (Type!=0xAF11)
+ {
+ Skip_L2( "Reserved");
+ Skip_L4( "Date of Creation)");
+ Skip_L4( "Serial number or compiler id");
+ Skip_L4( "Date of FLIC update");
+ Skip_L4( "Serial number");
+ Get_L2 (AspectX, "Width of square rectangle");
+ Get_L2 (AspectY, "Height of square rectangle");
+ }
+ else
+ Skip_XX(22, "Reserved");
+ Skip_L2( "EGI: flags for specific EGI extensions");
+ Skip_L2( "EGI: key-image frequency");
+ Skip_L2( "EGI: total number of frames (segments)");
+ Skip_L4( "EGI: maximum chunk size (uncompressed)");
+ Skip_L2( "EGI: max. number of regions in a CHK_REGION chunk");
+ Skip_L2( "EGI: number of transparent levels");
+ if (Type!=0xAF11)
+ {
+ Skip_XX(24, "Reserved");
+ Skip_L4( "Offset to frame 1");
+ Skip_L4( "Offset to frame 2");
+ Skip_XX(40, "Reserved");
+ }
+ else
+ Skip_XX(72, "Reserved");
+
+ //Filling
+ FILLING_BEGIN();
+ switch (Type)
+ {
+ case 0xAF11 :
+ case 0xAF12 :
+ case 0xAF30 :
+ case 0xAF31 :
+ case 0xAF44 :
+ break;
+ default :
+ Reject("FLIC");
+ return;
+ }
+
+ //Filling
+ Accept("FLIC");
+
+ Fill(Stream_General, 0, General_Format, "FLIC");
+
+ Stream_Prepare(Stream_Video);
+ if (Type==0xAF11)
+ {
+ Fill(Stream_Video, 0, Video_Format, "FLI");
+ Fill(Stream_Video, 0, Video_Codec, "FLI");
+ if (DelayBetweenFrames)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, 1000.0/(DelayBetweenFrames*70)); //multiple of 1/70 per frame
+ Fill(Stream_Video, 0, Video_Duration, Frames*DelayBetweenFrames*70);
+ }
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_Format, "FLC");
+ Fill(Stream_Video, 0, Video_Codec, "FLC");
+ if (DelayBetweenFrames)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, 1000.0/DelayBetweenFrames); //ms per frame
+ Fill(Stream_Video, 0, Video_Duration, Frames*DelayBetweenFrames);
+ }
+ if (AspectY>0)
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, AspectX/AspectY, 3, true);
+ }
+ Fill(Stream_Video, 0, Video_FrameCount, Frames);
+ Fill(Stream_Video, StreamPos_Last, Video_Width, Width);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, Height);
+ Fill(Stream_Video, 0, Video_BitDepth, (BitsPerPixel%3)?BitsPerPixel:(BitsPerPixel/3), 10, true); //If not a multiple of 3, the total resolution is filled
+ //No more need data
+ Finish("FLIC");
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_FLIC_*
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Flic.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Flic.h
new file mode 100644
index 000000000..fb3e32693
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Flic.h
@@ -0,0 +1,49 @@
+// File_Flic - Info for Flic files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Flic files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_FlicH
+#define MediaInfo_FlicH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Flic
+//***************************************************************************
+
+class File_Flic : public File__Analyze
+{
+private :
+ //Buffer
+ void FileHeader_Parse();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Fraps.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Fraps.cpp
new file mode 100644
index 000000000..5269522c7
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Fraps.cpp
@@ -0,0 +1,151 @@
+// File_Fraps - Info for Fraps files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_FRAPS_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Fraps.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Fraps::File_Fraps()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("Fraps");
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Fraps::Streams_Fill()
+{
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "Fraps");
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Fraps::Read_Buffer_Continue()
+{
+ //Parsing
+ int8u version, flags;
+ Get_L1 (version, "version");
+ Skip_L2( "unknown");
+ Get_L1 (flags, "flags");
+ if (flags&0x40)
+ Skip_L4( "unknown");
+ switch (version)
+ {
+ case 0x00 :
+ Version0(); break;
+ case 0x01 :
+ Version1(); break;
+ case 0x02 :
+ case 0x04 :
+ Version2(); break;
+ default : Skip_XX(Element_Size-Element_Offset, "data");
+ }
+
+ Finish();
+}
+
+//---------------------------------------------------------------------------
+void File_Fraps::Version0()
+{
+ //Parsing
+ Skip_XX(Element_Size-Element_Offset, "data");
+
+ FILLING_BEGIN();
+ Accept();
+ Fill();
+ Fill(Stream_Video, 0, Video_ColorSpace, "YUV");
+ Fill(Stream_Video, 0, Video_ChromaSubsampling, "4:2:0");
+ Fill(Stream_Video, 0, Video_BitDepth, 8);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Fraps::Version1()
+{
+ //Parsing
+ Skip_XX(Element_Size-Element_Offset, "data");
+
+ FILLING_BEGIN();
+ Accept();
+ Fill();
+ Fill(Stream_Video, 0, Video_ColorSpace, "RGB");
+ Fill(Stream_Video, 0, Video_BitDepth, 8);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Fraps::Version2()
+{
+ //Parsing
+ if (Element_Size>8) //Else this is a repeat frame
+ {
+ Skip_C4( "FPSx");
+ Skip_L4( "offset to the Y plane (minus 8)");
+ Skip_L4( "offset to the U plane (minus 8)");
+ Skip_L4( "offset to the V plane (minus 8)");
+ Skip_XX(Element_Size-Element_Offset, "data");
+ }
+
+ FILLING_BEGIN();
+ Accept();
+ Fill();
+ Fill(Stream_Video, 0, Video_ColorSpace, "YUV");
+ Fill(Stream_Video, 0, Video_BitDepth, 8);
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_FRAPS_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Fraps.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Fraps.h
new file mode 100644
index 000000000..9e6528f82
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Fraps.h
@@ -0,0 +1,61 @@
+// File_Fraps - Info for Fraps files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Fraps files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_FrapsH
+#define MediaInfo_File_FrapsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Fraps
+//***************************************************************************
+
+class File_Fraps : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Fraps();
+
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+
+ //Elements
+ void Version0();
+ void Version1();
+ void Version2();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_H263.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_H263.cpp
new file mode 100644
index 000000000..7d27f849a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_H263.cpp
@@ -0,0 +1,433 @@
+// File_H263 - Info for MPEG Video files
+// Copyright (C) 2012-2012 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_H263_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_H263.h"
+#include "ZenLib/BitStream.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+namespace MediaInfoLib
+{
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* H263_Source_Format[]=
+{
+ "",
+ "sub-QCIF",
+ "QCIF",
+ "CIF",
+ "4CIF",
+ "16CIF",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const int16u H263_Source_Format_Width[]=
+{
+ 0,
+ 128,
+ 176,
+ 352,
+ 704,
+ 1408,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+const int16u H263_Source_Format_Height[]=
+{
+ 0,
+ 96,
+ 144,
+ 288,
+ 576,
+ 1152,
+ 0,
+ 0,
+};
+
+//---------------------------------------------------------------------------
+const int8u H263_PAR_W[]=
+{
+ 0,
+ 12,
+ 10,
+ 16,
+ 40,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+const int8u H263_PAR_H[]=
+{
+ 0,
+ 11,
+ 11,
+ 11,
+ 33,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_H263::File_H263()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("H.263");
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+ IsRawStream=true;
+
+ //In
+ Frame_Count_Valid=Config_ParseSpeed>=0.3?8:2;
+ FrameIsAlwaysComplete=false;
+}
+
+//---------------------------------------------------------------------------
+File_H263::~File_H263()
+{
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_H263::Streams_Accept()
+{
+ Stream_Prepare(Stream_Video);
+}
+
+//---------------------------------------------------------------------------
+void File_H263::Streams_Update()
+{
+}
+
+//---------------------------------------------------------------------------
+void File_H263::Streams_Fill()
+{
+ Fill(Stream_General, 0, General_Format_Version, "H.263");
+ Fill(Stream_Video, 0, Video_Format, "H.263");
+ Fill(Stream_Video, 0, Video_Codec, "H.263");
+
+ Fill(Stream_Video, 0, Video_Width, H263_Source_Format_Width[Source_Format]);
+ Fill(Stream_Video, 0, Video_Height, H263_Source_Format_Height[Source_Format]);
+ Fill(Stream_Video, 0, Video_ColorSpace, "YUV");
+ Fill(Stream_Video, 0, Video_Colorimetry, "4:2:0");
+ Fill(Stream_Video, 0, Video_BitDepth, 8);
+ Fill(Stream_Video, 0, Video_PixelAspectRatio, ((float32)PAR_W)/PAR_H, 3);
+}
+
+//---------------------------------------------------------------------------
+void File_H263::Streams_Finish()
+{
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_H263::Synchronize()
+{
+ //Synchronizing
+ while(Buffer_Offset+3<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || (Buffer[Buffer_Offset+2]&0xFC)!=0x80))
+ {
+ Buffer_Offset+=2;
+ while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Buffer_Offset+=2;
+ if ((Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset-1]==0x00) || Buffer_Offset>=Buffer_Size)
+ Buffer_Offset--;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+3==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || (Buffer[Buffer_Offset+2]&0xFC)!=0x80))
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00))
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && Buffer[Buffer_Offset ]!=0x00)
+ Buffer_Offset++;
+
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ //Synched is OK
+ Synched=true;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_H263::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || (Buffer[Buffer_Offset+2]&0xFC)!=0x80)
+ {
+ Synched=false;
+ return true;
+ }
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_H263::Synched_Init()
+{
+ //Temp
+ PAR_W=12;
+ PAR_H=11;
+ Temporal_Reference_IsValid=false;
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_H263::Read_Buffer_Unsynched()
+{
+ Temporal_Reference_IsValid=false;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_H263::Header_Parse()
+{
+ Header_Fill_Code(0x00, "Frame");
+ Header_Parser_Fill_Size();
+}
+
+//---------------------------------------------------------------------------
+bool File_H263::Header_Parser_Fill_Size()
+{
+ //Look for next Sync word
+ if (Buffer_Offset_Temp==0) //Buffer_Offset_Temp is not 0 if Header_Parse_Fill_Size() has already parsed first frames
+ Buffer_Offset_Temp=Buffer_Offset+3;
+ while (Buffer_Offset_Temp+3<=Buffer_Size
+ && (Buffer[Buffer_Offset_Temp ]!=0x00
+ || Buffer[Buffer_Offset_Temp+1]!=0x00
+ || (Buffer[Buffer_Offset_Temp+2]&0xFC)!=0x80))
+ {
+ Buffer_Offset_Temp+=2;
+ while(Buffer_Offset_Temp<Buffer_Size && Buffer[Buffer_Offset_Temp]!=0x00)
+ Buffer_Offset_Temp+=2;
+ if (Buffer_Offset_Temp>=Buffer_Size || Buffer[Buffer_Offset_Temp-1]==0x00)
+ Buffer_Offset_Temp--;
+ }
+
+ //Must wait more data?
+ if (Buffer_Offset_Temp+3>Buffer_Size)
+ {
+ if (FrameIsAlwaysComplete || File_Offset+Buffer_Size==File_Size)
+ Buffer_Offset_Temp=Buffer_Size; //We are sure that the next bytes are a start
+ else
+ return false;
+ }
+
+ //OK, we continue
+ Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset);
+ Buffer_Offset_Temp=0;
+ return true;
+
+}
+
+//---------------------------------------------------------------------------
+void File_H263::Data_Parse()
+{
+ //Parsing
+ int8u Temporal_Reference_Temp;
+ BS_Begin();
+ Skip_S3(22, "Picture Start Code (PSC)");
+ Get_S1 ( 8, Temporal_Reference_Temp, "Temporal Reference (TR)");
+ if (!Temporal_Reference_IsValid)
+ {
+ Temporal_Reference=Temporal_Reference_Temp;
+ Temporal_Reference_IsValid=true;
+ }
+ else
+ Temporal_Reference++;
+ if (Temporal_Reference_Temp!=Temporal_Reference)
+ {
+ Trusted_IsNot("Out of Order");
+ Open_Buffer_Unsynch();
+ return;
+ }
+ Element_Begin1("Type Information (PTYPE)");
+ Mark_1();
+ Mark_0();
+ Skip_SB( "Split screen indicator");
+ Skip_SB( "Document camera indicator");
+ Skip_SB( "Full Picture Freeze Release");
+ Get_S1 (3, Source_Format, "Source Format"); Param_Info1(H263_Source_Format[Source_Format]);
+ if (Source_Format!=7)
+ {
+ Skip_SB( "Picture Coding Type");
+ Skip_SB( "Unrestricted Motion Vector mode");
+ Skip_SB( "Syntax-based Arithmetic Coding mode");
+ Skip_SB( "Advanced Prediction mode");
+ Skip_SB( "PB-frames mode");
+ }
+ Element_End0();
+ if (Source_Format==7) // Extended PTYPE
+ {
+ Element_Begin1("Plus PTYPE (PLUSPTYPE)");
+ int8u Ufep, PixelAspectRatioCode=0, Width=0, Height=0;
+ Get_S1 ( 3, Ufep, "Update Full Extended PTYPE (UFEP)");
+ switch (Ufep)
+ {
+ case 0 :
+ break;
+ case 1 :
+ Element_Begin1("Optional Part of PLUSPTYPE (OPPTYPE)");
+ Get_S1 (3, Source_Format, "Source Format"); Param_Info1(H263_Source_Format[Source_Format]);
+ Skip_SB( "Custom PCF");
+ Skip_SB( "Unrestricted Motion Vector (UMV) mode");
+ Skip_SB( "Syntax-based Arithmetic Coding (SAC) mode");
+ Skip_SB( "Advanced Prediction (AP) mode");
+ Skip_SB( "Advanced INTRA Coding (AIC) mode");
+ Skip_SB( "Deblocking Filter (DF) mode");
+ Skip_SB( "Slice Structured (SS) mode");
+ Skip_SB( "Reference Picture Selection (RPS) mode");
+ Skip_SB( "Independent Segment Decoding (ISD) mode");
+ Skip_SB( "Alternative INTER VLC (AIV) mode");
+ Skip_SB( "Modified Quantization (MQ) mode");
+ Mark_1();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Element_End0();
+ break;
+ default :
+ BS_End();
+ Skip_XX(Element_Size-Element_Offset, "Unknown");
+ return; //TODO: frame count...
+ }
+ Element_Begin1("mandatory part of PLUSPTYPE when PLUSPTYPE present (MPPTYPE)");
+ Skip_S1(3, "Picture Type Code");
+ Skip_SB( "Reference Picture Resampling (RPR) mode");
+ Skip_SB( "Reduced-Resolution Update (RRU) mode");
+ Skip_SB( "Rounding Type (RTYPE)");
+ Mark_0();
+ Mark_0();
+ Mark_1();
+ Element_End0();
+ Element_End0();
+ Skip_SB( "CPM");
+ Skip_S1(2, "PSBI");
+ Element_Begin1("Custom Picture Format (CPFMT)");
+ Get_S1 (4, PixelAspectRatioCode, "Pixel Aspect Ratio Code");
+ Get_S1 (4, Width, "Picture Width Indication");
+ Width++; Width<<=2; Param_Info2(Width, " pixels");
+ Mark_1();
+ Get_S1 (4, Height, "Picture Height Indication");
+ Height<<=2; Param_Info2(Height, " pixels");
+ Element_End0();
+ if (PixelAspectRatioCode==0xF)
+ {
+ Element_Begin1("Extended Pixel Aspect Ratio (EPAR)");
+ Get_S1 (8, PAR_W, "PAR Width");
+ Get_S1 (8, PAR_H, "PAR Height");
+ Element_End0();
+ }
+ else
+ {
+ PAR_W=H263_PAR_W[PixelAspectRatioCode];
+ PAR_H=H263_PAR_H[PixelAspectRatioCode];
+ }
+ }
+ BS_End();
+ Skip_XX(Element_Size-Element_Offset, "Other data");
+
+ FILLING_BEGIN();
+ Element_Info1(Frame_Count);
+ Frame_Count++;
+
+ //Filling
+ if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid)
+ {
+ Accept("H.263");
+ Finish("H.263");
+ }
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_H263_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_H263.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_H263.h
new file mode 100644
index 000000000..7436e17ec
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_H263.h
@@ -0,0 +1,83 @@
+// File_H263 - Info for MPEG Video files
+// Copyright (C) 2012-2012 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about h.263 files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_H263H
+#define MediaInfo_H263H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_H263
+//***************************************************************************
+
+class File_H263 : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ bool FrameIsAlwaysComplete;
+
+ //Constructor/Destructor
+ File_H263();
+ ~File_H263();
+
+private :
+ //Streams management
+ void Streams_Accept();
+ void Streams_Update();
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+ void Synched_Init();
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Per element
+ void Header_Parse();
+ bool Header_Parser_Fill_Size();
+ void Data_Parse();
+
+ //Elements
+
+ //Temp
+ int8u Temporal_Reference;
+ int8u Source_Format;
+ int8u PAR_W;
+ int8u PAR_H;
+ bool Temporal_Reference_IsValid;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Lagarith.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Lagarith.cpp
new file mode 100644
index 000000000..d5d3510cd
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Lagarith.cpp
@@ -0,0 +1,106 @@
+// File_Lagarith - Info for Lagarith files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_LAGARITH_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Lagarith.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Lagarith::File_Lagarith()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("Lagarith");
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Lagarith::Streams_Fill()
+{
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "Lagarith");
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Lagarith::Read_Buffer_Continue()
+{
+ //Parsing
+ int8u version;
+ Get_L1 (version, "version");
+ Skip_XX(Element_Size-Element_Offset, "data");
+
+ FILLING_BEGIN();
+ Accept();
+ Fill();
+ switch (version)
+ {
+ case 0x02 : Fill(Stream_Video, 0, Video_ColorSpace, "RGB"); Fill(Stream_Video, 0, Video_BitDepth, 8); break;
+ case 0x03 : Fill(Stream_Video, 0, Video_ColorSpace, "YUV"); Fill(Stream_Video, 0, Video_ChromaSubsampling, "4:2:2"); Fill(Stream_Video, 0, Video_BitDepth, 8); break;
+ case 0x04 : Fill(Stream_Video, 0, Video_ColorSpace, "RGB"); Fill(Stream_Video, 0, Video_BitDepth, 8); break;
+ case 0x05 : Fill(Stream_Video, 0, Video_ColorSpace, "Grey"); break;
+ case 0x06 : Fill(Stream_Video, 0, Video_ColorSpace, "RGB"); break;
+ case 0x07 : Fill(Stream_Video, 0, Video_ColorSpace, "RGB"); break;
+ case 0x08 : Fill(Stream_Video, 0, Video_ColorSpace, "RGBA"); break;
+ case 0x09 : Fill(Stream_Video, 0, Video_ColorSpace, "RGBA"); break;
+ case 0x0A : Fill(Stream_Video, 0, Video_ColorSpace, "YUV"); Fill(Stream_Video, 0, Video_ChromaSubsampling, "4:2:0"); Fill(Stream_Video, 0, Video_BitDepth, 8); break;
+ case 0x0B : Fill(Stream_Video, 0, Video_ColorSpace, "YUV"); Fill(Stream_Video, 0, Video_ChromaSubsampling, "4:2:0"); Fill(Stream_Video, 0, Video_BitDepth, 8); break;
+ default : ;
+ }
+
+ FILLING_END();
+ Finish();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_LAGARITH_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Lagarith.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Lagarith.h
new file mode 100644
index 000000000..149c81ced
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Lagarith.h
@@ -0,0 +1,56 @@
+// File_Lagarith - Info for Lagarith files
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Lagarith files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_LagarithH
+#define MediaInfo_File_LagarithH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Lagarith
+//***************************************************************************
+
+class File_Lagarith : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Lagarith();
+
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - Global
+ void Read_Buffer_Continue ();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpeg4v.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpeg4v.cpp
new file mode 100644
index 000000000..b1b116b20
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpeg4v.cpp
@@ -0,0 +1,1857 @@
+// File_Mpeg4v - Info for MPEG-4 Visual files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Constants (Common)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEG4V_YES) || defined(MEDIAINFO_MPEG4_YES)
+//---------------------------------------------------------------------------
+
+#include "ZenLib/Conf.h"
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+
+namespace MediaInfoLib
+{
+
+//---------------------------------------------------------------------------
+const char* Mpeg4v_Profile_Level(int32u Profile_Level)
+{
+ switch (Profile_Level)
+ {
+ case B8(00000001) : return "Simple@L1";
+ case B8(00000010) : return "Simple@L2";
+ case B8(00000011) : return "Simple@L3";
+ case B8(00000100) : return "Simple@L4a";
+ case B8(00000101) : return "Simple@L5";
+ case B8(00000110) : return "Simple@L6";
+ case B8(00001000) : return "Simple@L0";
+ case B8(00001001) : return "Simple@L0b";
+ case B8(00010000) : return "Simple Scalable@L0";
+ case B8(00010001) : return "Simple Scalable@L1";
+ case B8(00010010) : return "Simple Scalable@L2";
+ case B8(00010101) : return "AVC"; //For descriptors
+ case B8(00100001) : return "Core@L1";
+ case B8(00100010) : return "Core@L2";
+ case B8(00110010) : return "Main@L2";
+ case B8(00110011) : return "Main@L3";
+ case B8(00110100) : return "Main@L4";
+ case B8(01000010) : return "N-bit@L2";
+ case B8(01010001) : return "Scalable Texture@L1";
+ case B8(01100001) : return "Simple Face Animation@L1";
+ case B8(01100010) : return "Simple Face Animation@L2";
+ case B8(01100011) : return "Simple FBA@L1";
+ case B8(01100100) : return "Simple FBA@L2";
+ case B8(01110001) : return "Basic Animated Texture@L1";
+ case B8(01110010) : return "Basic Animated Texture@L2";
+ case B8(01111111) : return "AVC"; //For descriptors
+ case B8(10000001) : return "Hybrid@L1";
+ case B8(10000010) : return "Hybrid@L2";
+ case B8(10010001) : return "Advanced Real Time Simple@L1";
+ case B8(10010010) : return "Advanced Real Time Simple@L2";
+ case B8(10010011) : return "Advanced Real Time Simple@L3";
+ case B8(10010100) : return "Advanced Real Time Simple@L4";
+ case B8(10100001) : return "Core Scalable@L1";
+ case B8(10100010) : return "Core Scalable@L2";
+ case B8(10100011) : return "Core Scalable@L3";
+ case B8(10110001) : return "Advanced Coding Efficiency@L1";
+ case B8(10110010) : return "Advanced Coding Efficiency@L2";
+ case B8(10110011) : return "Advanced Coding Efficiency@L3";
+ case B8(10110100) : return "Advanced Coding Efficiency@L4";
+ case B8(11000001) : return "Advanced Core@L1";
+ case B8(11000010) : return "Advanced Core@L2";
+ case B8(11010001) : return "Advanced Scalable Texture@L1";
+ case B8(11010010) : return "Advanced Scalable Texture@L2";
+ case B8(11010011) : return "Advanced Scalable Texture@L3";
+ case B8(11100001) : return "Simple Studio@L1";
+ case B8(11100010) : return "Simple Studio@L2";
+ case B8(11100011) : return "Simple Studio@L3";
+ case B8(11100100) : return "Simple Studio@L4";
+ case B8(11100101) : return "Core Studio@L1";
+ case B8(11100110) : return "Core Studio@L2";
+ case B8(11100111) : return "Core Studio@L3";
+ case B8(11101000) : return "Core Studio@L4";
+ case B8(11110000) : return "Advanced Simple@L0";
+ case B8(11110001) : return "Advanced Simple@L1";
+ case B8(11110010) : return "Advanced Simple@L2";
+ case B8(11110011) : return "Advanced Simple@L3";
+ case B8(11110100) : return "Advanced Simple@L4";
+ case B8(11110101) : return "Advanced Simple@L5";
+ case B8(11110111) : return "Advanced Simple@L3b";
+ case B8(11111000) : return "Fine Granularity Scalable@L0";
+ case B8(11111001) : return "Fine Granularity Scalable@L1";
+ case B8(11111010) : return "Fine Granularity Scalable@L2";
+ case B8(11111011) : return "Fine Granularity Scalable@L3";
+ case B8(11111100) : return "Fine Granularity Scalable@L4";
+ case B8(11111101) : return "Fine Granularity Scalable@L5";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+} //NameSpace
+
+//---------------------------------------------------------------------------
+#endif //...
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+//
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEG4V_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Mpeg4v.h"
+#include "ZenLib/BitStream.h"
+#include "ZenLib/Utils.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Constants
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Mpeg4v_Colorimetry[]=
+{
+ "",
+ "4:2:0",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg4v_visual_object_type[]=
+{
+ "",
+ "video",
+ "still texture",
+ "mesh",
+ "FBA",
+ "3D mesh",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg4v_visual_object_verid[]=
+{
+ "",
+ "ISO/IEC 14496-2",
+ "ISO/IEC 14496-2 AMD 1",
+ "ISO/IEC 14496-2 AMD 2",
+ "ISO/IEC 14496-2 AMD 3 (Studio)",
+ "ISO/IEC 14496-2 AMD 4 (SVP)",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg4v_video_object_layer_verid[]=
+{
+ "",
+ "ISO/IEC 14496-2",
+ "ISO/IEC 14496-2 AMD 1",
+ "ISO/IEC 14496-2 AMD 2",
+ "ISO/IEC 14496-2 AMD 3 (Studio)",
+ "ISO/IEC 14496-2 AMD 4 (SVP)",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpeg4v_vop_coding_type[]=
+{
+ "I",
+ "P",
+ "B",
+ "S",
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Mpeg4v::File_Mpeg4v()
+:File__Analyze()
+{
+ //Config
+ Trusted_Multiplier=2;
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+ PTS_DTS_Needed=true;
+ IsRawStream=true;
+
+ //In
+ Frame_Count_Valid=MediaInfoLib::Config.ParseSpeed_Get()>=0.3?30:2;
+ FrameIsAlwaysComplete=false;
+
+ //Temp
+ video_object_layer_start_IsParsed=false;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4v::OnlyVOP()
+{
+ //Default stream values
+ Synched_Init();
+ Streams[0xB3].Searching_Payload=true; //group_of_vop_start
+ Streams[0xB6].Searching_Payload=true; //vop_start
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Mpeg4v::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (CC3(Buffer+Buffer_Offset)!=0x000001)
+ Synched=false;
+
+ //Quick search
+ if (Synched && !Header_Parser_QuickSearch())
+ return false;
+
+ #if MEDIAINFO_IBI
+ bool RandomAccess=Buffer[Buffer_Offset+3]==0xB0; //SequenceHeader
+ if (RandomAccess)
+ Ibi_Add();
+ #endif //MEDIAINFO_IBI
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4v::Synched_Init()
+{
+ //Count of a Packets
+ IVOP_Count=0;
+ PVOP_Count=0;
+ BVOP_Count=0;
+ BVOP_Count_Max=0;
+ SVOP_Count=0;
+ NVOP_Count=0;
+ Interlaced_Top=0;
+ Interlaced_Bottom=0;
+ Frame_Count_InThisBlock_Max=0;
+ if (Frame_Count_NotParsedIncluded==(int64u)-1)
+ Frame_Count_NotParsedIncluded=0; //No Frame_Count_NotParsedIncluded in the container
+
+ //From VOL, needed in VOP
+ fixed_vop_time_increment=0;
+ Time_Begin_Seconds=(int32u)-1;
+ Time_End_Seconds=(int32u)-1;
+ Time_Begin_MilliSeconds=(int16u)-1;
+ Time_End_MilliSeconds=(int16u)-1;
+ object_layer_width=0;
+ object_layer_height=0;
+ vop_time_increment_resolution=0;
+ visual_object_verid=1;
+ profile_and_level_indication=0;
+ no_of_sprite_warping_points=0;
+ aspect_ratio_info=0;
+ par_width=0;
+ par_height=0;
+ bits_per_pixel=8;
+ shape=0;
+ sprite_enable=0;
+ estimation_method=0;
+ chroma_format=(int8u)-1;
+ quarter_sample=false;
+ low_delay=false;
+ load_intra_quant_mat=false;
+ load_nonintra_quant_mat=false;
+ load_intra_quant_mat_grayscale=false;
+ load_nonintra_quant_mat_grayscale=false;
+ interlaced=false;
+ newpred_enable=0;
+ time_size=0;
+ reduced_resolution_vop_enable=0;
+ scalability=0;
+ enhancement_type=0;
+ complexity_estimation_disable=false;
+ opaque=false;
+ transparent=false;
+ intra_cae=false;
+ inter_cae=false;
+ no_update=false;
+ upsampling=false;
+ intra_blocks=false;
+ inter_blocks=false;
+ inter4v_blocks=false;
+ not_coded_blocks=false;
+ dct_coefs=false;
+ dct_lines=false;
+ vlc_symbols=false;
+ vlc_bits=false;
+ apm=false;
+ npm=false;
+ interpolate_mc_q=false;
+ forw_back_mc_q=false;
+ halfpel2=false;
+ halfpel4=false;
+ sadct=false;
+ quarterpel=false;
+ quant_type=false;
+
+ if (!IsSub)
+ FrameInfo.DTS=0;
+
+ //Default stream values
+ Streams.resize(0x100);
+ Streams[0x00].Searching_Payload=true; //video_object_start
+ Streams[0x20].Searching_Payload=true; //video_object_layer_start
+ Streams[0xB0].Searching_Payload=true; //visual_object_sequence_start
+ Streams[0xB5].Searching_Payload=true; //visual_object_start
+ NextCode_Add(0x20); //video_object_layer_start
+ for (int8u Pos=0xFF; Pos>=0xB9; Pos--)
+ Streams[Pos].Searching_Payload=true; //Testing MPEG-PS
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg4v::Streams_Fill()
+{
+ //Filling
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "MPEG-4 Visual");
+ Fill(Stream_Video, 0, Video_Codec, "MPEG-4V");
+
+ if (profile_and_level_indication>0)
+ {
+ Fill(Stream_Video, 0, Video_Format_Profile, Mpeg4v_Profile_Level(profile_and_level_indication));
+ Fill(Stream_Video, 0, Video_Codec_Profile, Mpeg4v_Profile_Level(profile_and_level_indication));
+ }
+
+ if (fixed_vop_time_increment && vop_time_increment_resolution)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, ((float)vop_time_increment_resolution)/fixed_vop_time_increment);
+ if (object_layer_height)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Width, object_layer_width);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, object_layer_height);
+ float32 PixelAspectRatio_Value=1.0;
+ if (aspect_ratio_info==0x01) PixelAspectRatio_Value=(float32)1;
+ if (aspect_ratio_info==0x02) PixelAspectRatio_Value=(float32)12/(float32)11;
+ else if (aspect_ratio_info==0x03) PixelAspectRatio_Value=(float32)10/(float32)11;
+ else if (aspect_ratio_info==0x04) PixelAspectRatio_Value=(float32)16/(float32)11;
+ else if (aspect_ratio_info==0x05) PixelAspectRatio_Value=(float32)40/(float32)13;
+ else if (aspect_ratio_info==0x0F && par_height) PixelAspectRatio_Value=((float32)par_width)/par_height;
+ Fill(Stream_Video, 0, Video_PixelAspectRatio, PixelAspectRatio_Value, 3, true);
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, ((float)object_layer_width)/object_layer_height*PixelAspectRatio_Value, 3, true);
+ }
+ Fill(Stream_Video, 0, Video_ColorSpace, "YUV");
+ Fill(Stream_Video, 0, Video_BitDepth, bits_per_pixel);
+ if (chroma_format<4)
+ Fill(Stream_Video, 0, Video_Colorimetry, Mpeg4v_Colorimetry[chroma_format]);
+ if (low_delay)
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings_BVOP, "No");
+ Fill(Stream_Video, 0, Video_Codec_Settings_BVOP, "No");
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings, "BVOP");
+ Fill(Stream_Video, 0, Video_Format_Settings_BVOP, "Yes");
+ Fill(Stream_Video, 0, Video_Codec_Settings, "BVOP");
+ Fill(Stream_Video, 0, Video_Codec_Settings_BVOP, "Yes");
+ }
+ if (no_of_sprite_warping_points)
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings, Ztring(_T("GMC"))+Ztring::ToZtring(no_of_sprite_warping_points));
+ Fill(Stream_Video, 0, Video_Format_Settings_GMC, no_of_sprite_warping_points);
+ Fill(Stream_Video, 0, Video_Codec_Settings, Ztring(_T("GMC"))+Ztring::ToZtring(no_of_sprite_warping_points));
+ Fill(Stream_Video, 0, Video_Codec_Settings_GMC, no_of_sprite_warping_points);
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings_GMC, 0);
+ Fill(Stream_Video, 0, Video_Codec_Settings_GMC, 0);
+ }
+ if (quarter_sample)
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings, "QPel");
+ Fill(Stream_Video, 0, Video_Format_Settings_QPel, "Yes");
+ Fill(Stream_Video, 0, Video_Codec_Settings, "QPel");
+ Fill(Stream_Video, 0, Video_Codec_Settings_QPel, "Yes");
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings_QPel, "No");
+ Fill(Stream_Video, 0, Video_Codec_Settings_QPel, "No");
+ }
+ if (!quant_type)
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings_Matrix, "Default (H.263)");
+ Fill(Stream_Video, 0, Video_Codec_Settings_Matrix, "Default (H.263)");
+ }
+ else if (load_intra_quant_mat_grayscale || load_nonintra_quant_mat_grayscale)
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings, "Custom Matrix (Gray)");
+ Fill(Stream_Video, 0, Video_Format_Settings_Matrix, "Custom (Gray)");
+ Fill(Stream_Video, 0, Video_Codec_Settings, "Custom Matrix (Gray)");
+ Fill(Stream_Video, 0, Video_Codec_Settings_Matrix, "Custom (Gray)");
+ }
+ else if (load_intra_quant_mat || load_nonintra_quant_mat)
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings, "Custom Matrix");
+ Fill(Stream_Video, 0, Video_Format_Settings_Matrix, "Custom");
+ Fill(Stream_Video, 0, Video_Format_Settings_Matrix_Data, Matrix_intra);
+ Fill(Stream_Video, 0, Video_Format_Settings_Matrix_Data, Matrix_nonintra);
+ Fill(Stream_Video, 0, Video_Codec_Settings, "Custom Matrix");
+ Fill(Stream_Video, 0, Video_Codec_Settings_Matrix, "Custom");
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings_Matrix, "Default (MPEG)");
+ Fill(Stream_Video, 0, Video_Codec_Settings_Matrix, "Default (MPEG)");
+ }
+ if (interlaced)
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Interlaced");
+ if ((Interlaced_Top && Interlaced_Bottom) || (!Interlaced_Top && !Interlaced_Bottom))
+ Fill(Stream_Video, 0, Video_Interlacement, "Interlaced");
+ else
+ {
+ Fill(Stream_Video, 0, Video_ScanOrder, Interlaced_Top?"TFF":"BFF");
+ Fill(Stream_Video, 0, Video_Interlacement, Interlaced_Top?"TFF":"BFF");
+ }
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Progressive");
+ Fill(Stream_Video, 0, Video_Interlacement, "PPF");
+ }
+ if (!Library.empty())
+ {
+ Fill(Stream_Video, 0, Video_Encoded_Library, Library);
+ Fill(Stream_Video, 0, Video_Encoded_Library_Name, Library_Name);
+ Fill(Stream_Video, 0, Video_Encoded_Library_Version, Library_Version);
+ Fill(Stream_Video, 0, Video_Encoded_Library_Date, Library_Date);
+ }
+ for (size_t Pos=0; Pos<user_data_start_SNC_Data.size(); Pos++)
+ {
+ if (user_data_start_SNC_Data[Pos][0]==_T("CamTim"))
+ Fill(Stream_General, 0, General_Recorded_Date, Ztring().Date_From_String(user_data_start_SNC_Data[Pos][1].To_UTF8().c_str()));
+ if (user_data_start_SNC_Data[Pos][0]==_T("FrmRate"))
+ Fill(Stream_Video, 0, Video_FrameRate, user_data_start_SNC_Data[Pos][1].To_float32(), 3);
+ if (user_data_start_SNC_Data[Pos][0]==_T("TimStamp"))
+ {
+ Fill(Stream_Video, 0, Video_Delay, user_data_start_SNC_Data[Pos][1].To_int64u());
+ Fill(Stream_Video, 0, Video_Delay_Source, "Stream");
+ }
+ if (user_data_start_SNC_Data[Pos][0]==_T("CamPos") && user_data_start_SNC_Data[Pos][1].size()==16)
+ {
+ Fill(Stream_Video, 0, "Pan / Tilt / Zoom / Status", Ztring(user_data_start_SNC_Data[Pos][1].substr( 3, 4)).To_int8u(16));
+ Fill(Stream_Video, 0, "Pan / Tilt / Zoom / Status", Ztring(user_data_start_SNC_Data[Pos][1].substr( 7, 4)).To_int8u(16));
+ Fill(Stream_Video, 0, "Pan / Tilt / Zoom / Status", Ztring(user_data_start_SNC_Data[Pos][1].substr(11, 4)).To_int8u(16));
+ if (user_data_start_SNC_Data[Pos][1][15]==_T('M'))
+ Fill(Stream_Video, 0, "Pan / Tilt / Zoom / Status", _T("Move"));
+ else if (user_data_start_SNC_Data[Pos][1][15]==_T('S'))
+ Fill(Stream_Video, 0, "Pan / Tilt / Zoom / Status", _T("Stop"));
+ else
+ Fill(Stream_Video, 0, "Pan / Tilt / Zoom / Status", user_data_start_SNC_Data[Pos][1][15]);
+ }
+ if (user_data_start_SNC_Data[Pos][0]==_T("AlmEvent") && user_data_start_SNC_Data[Pos][1].size()==16)
+ Fill(Stream_Video, 0, "Alarm event", user_data_start_SNC_Data[Pos][1]);
+ }
+ if (video_object_layer_start_IsParsed && shape!=2 && !complexity_estimation_disable)
+ {
+ Fill(Stream_Video, 0, "data_partitioned", data_partitioned?"Yes":"No");
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("data_partitioned"), Info_Options)=_T("N NT");
+ if (data_partitioned)
+ {
+ Fill(Stream_Video, 0, "reversible_vlc", reversible_vlc?"Yes":"No");
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("reversible_vlc"), Info_Options)=_T("N NT");
+ }
+ }
+
+ //BVOPs
+ if (BVOP_Count_Max)
+ {
+ Ztring Format_Settings=Retrieve(Stream_Video, 0, Video_Format_Settings);
+ Format_Settings.FindAndReplace(_T("BVOP"), _T("BVOP")+Ztring::ToZtring(BVOP_Count_Max));
+ Fill(Stream_Video, 0, Video_Format_Settings, Format_Settings, true);
+ Fill(Stream_Video, 0, Video_Format_Settings_BVOP, BVOP_Count_Max, 10, true);
+ }
+
+ //Packed Bitstream
+ if (Frame_Count_InThisBlock_Max==2)
+ {
+ Fill(Stream_Video, 0, Video_MuxingMode, MediaInfoLib::Config.Language_Get("MuxingMode_PackedBitstream"));
+ Fill(Stream_Video, 0, Video_Codec_Settings, "Packed Bitstream");
+ Fill(Stream_Video, 0, Video_Codec_Settings_PacketBitStream, "Yes");
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_Codec_Settings_PacketBitStream, "No");
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4v::Streams_Finish()
+{
+ //Duration
+ if (!IsSub && Time_End_Seconds!=(int32u)-1 && Time_Begin_Seconds!=(int32u)-1)
+ {
+ int32u Duration=(Time_End_Seconds-Time_Begin_Seconds)*1000+Time_End_MilliSeconds-Time_Begin_MilliSeconds;
+ if (fixed_vop_time_increment && vop_time_increment_resolution)
+ Duration+=(float32_int32s)(((float)1000)/(((float)vop_time_increment_resolution)/fixed_vop_time_increment));
+ Fill(Stream_Video, 0, Video_Duration, Duration);
+ }
+
+ #if MEDIAINFO_IBI
+ if (fixed_vop_time_increment)
+ Ibi_Stream_Finish(vop_time_increment_resolution, fixed_vop_time_increment);
+ #endif //MEDIAINFO_IBI
+}
+//***************************************************************************
+// Buffer - Demux
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+bool File_Mpeg4v::Demux_UnpacketizeContainer_Test()
+{
+ if ((Demux_IntermediateItemFound && Buffer[Buffer_Offset+3]==0xB0) || Buffer[Buffer_Offset+3]==0xB3 || Buffer[Buffer_Offset+3]==0xB6)
+ {
+ if (Demux_Offset==0)
+ {
+ Demux_Offset=Buffer_Offset;
+ Demux_IntermediateItemFound=false;
+ }
+ while (Demux_Offset+4<=Buffer_Size)
+ {
+ //Synchronizing
+ while(Demux_Offset+3<=Buffer_Size && (Buffer[Demux_Offset ]!=0x00
+ || Buffer[Demux_Offset+1]!=0x00
+ || Buffer[Demux_Offset+2]!=0x01))
+ {
+ Demux_Offset+=2;
+ while(Demux_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Demux_Offset+=2;
+ if (Demux_Offset>=Buffer_Size || Buffer[Demux_Offset-1]==0x00)
+ Demux_Offset--;
+ }
+
+ if (Demux_Offset+4<=Buffer_Size)
+ {
+ if (Demux_IntermediateItemFound)
+ {
+ bool MustBreak;
+ switch (Buffer[Demux_Offset+3])
+ {
+ case 0xB0 :
+ case 0xB3 :
+ case 0xB6 :
+ MustBreak=true; break;
+ default : MustBreak=false;
+ }
+ if (MustBreak)
+ break; //while() loop
+ }
+ else
+ {
+ if (Buffer[Demux_Offset+3]==0xB6)
+ Demux_IntermediateItemFound=true;
+ }
+ }
+ Demux_Offset++;
+ }
+
+ if (Demux_Offset+4>Buffer_Size && File_Offset+Buffer_Size!=File_Size)
+ return false; //No complete frame
+
+ if (!Status[IsAccepted])
+ {
+ Accept("MPEG-4 Visual");
+ if (Config->Demux_EventWasSent)
+ return false;
+ }
+
+ Demux_UnpacketizeContainer_Demux(Buffer[Buffer_Offset+3]==0xB0);
+ }
+
+ return true;
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg4v::Read_Buffer_Unsynched()
+{
+ Time_End_Seconds=(int32u)-1;
+ Time_End_MilliSeconds=(int16u)-1;
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpeg4v::Header_Parse()
+{
+ //Parsing
+ int8u start_code;
+ Skip_B3( "synchro");
+ Get_B1 (start_code, "start_code");
+ if (!Header_Parser_Fill_Size())
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ //Filling
+ Header_Fill_Code(start_code, Ztring().From_CC1(start_code));
+}
+
+//---------------------------------------------------------------------------
+bool File_Mpeg4v::Header_Parser_Fill_Size()
+{
+ //Look for next Sync word
+ if (Buffer_Offset_Temp==0) //Buffer_Offset_Temp is not 0 if Header_Parse_Fill_Size() has already parsed first frames
+ Buffer_Offset_Temp=Buffer_Offset+4;
+ while (Buffer_Offset_Temp+4<=Buffer_Size
+ && CC3(Buffer+Buffer_Offset_Temp)!=0x000001)
+ {
+ Buffer_Offset_Temp+=2;
+ while(Buffer_Offset_Temp<Buffer_Size && Buffer[Buffer_Offset_Temp]!=0x00)
+ Buffer_Offset_Temp+=2;
+ if (Buffer_Offset_Temp>=Buffer_Size || Buffer[Buffer_Offset_Temp-1]==0x00)
+ Buffer_Offset_Temp--;
+ }
+
+ //Must wait more data?
+ if (Buffer_Offset_Temp+4>Buffer_Size)
+ {
+ if (FrameIsAlwaysComplete || File_Offset+Buffer_Size==File_Size)
+ Buffer_Offset_Temp=Buffer_Size; //We are sure that the next bytes are a start
+ else
+ return false;
+ }
+
+ //OK, we continue
+ Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset);
+ Buffer_Offset_Temp=0;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Mpeg4v::Header_Parser_QuickSearch()
+{
+ while ( Buffer_Offset+4<=Buffer_Size
+ && Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x01)
+ {
+ //Getting start_code
+ int8u start_code=CC1(Buffer+Buffer_Offset+3);
+
+ //Searching start
+ if (Streams[start_code].Searching_Payload)
+ return true;
+
+ //Synchronizing
+ Buffer_Offset+=4;
+ Synched=false;
+ if (!Synchronize())
+ {
+ if (File_Offset+Buffer_Size==File_Size)
+ {
+ Synched=true;
+ return true;
+ }
+ return false;
+ }
+
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ }
+
+ if (Buffer_Offset+3==Buffer_Size)
+ return false; //Sync is OK, but start_code is not available
+ Trusted_IsNot("MPEG-4 Visual, Synchronisation lost");
+ return Synchronize();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpeg4v::Data_Parse()
+{
+ //Parsing
+ switch (Element_Code)
+ {
+ case 0xB0: visual_object_sequence_start(); break;
+ case 0xB1: visual_object_sequence_end(); break;
+ case 0xB2: user_data_start(); break;
+ case 0xB3: group_of_vop_start(); break;
+ case 0xB4: video_session_error(); break;
+ case 0xB5: visual_object_start(); break;
+ case 0xB6: vop_start(); break;
+ case 0xB7: slice_start(); break;
+ case 0xB8: extension_start(); break;
+ case 0xB9: fgs_vop_start(); break;
+ case 0xBA: fba_object_start(); break;
+ case 0xBB: fba_object_plane_start(); break;
+ case 0xBC: mesh_object_start(); break;
+ case 0xBD: mesh_object_plane_start(); break;
+ case 0xBE: still_texture_object_start(); break;
+ case 0xBF: texture_spatial_layer_start(); break;
+ case 0xC0: texture_snr_layer_start(); break;
+ case 0xC1: texture_tile_start(); break;
+ case 0xC2: texture_shape_layer_start(); break;
+ case 0xC3: stuffing_start(); break;
+ default:
+ if (Element_Code<=0x1F) video_object_start();
+ else if (Element_Code>=0x20
+ && Element_Code<=0x2F) video_object_layer_start();
+ else if (Element_Code>=0x40
+ && Element_Code<=0x4F) fgs_bp_start();
+ else if (Element_Code<=0xC5) reserved();
+ else
+ {
+ if (Frame_Count==0 && Buffer_TotalBytes>Buffer_TotalBytes_FirstSynched_Max)
+ Trusted=0;
+ Trusted_IsNot("Unattended element!");
+ }
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Packet "00"
+void File_Mpeg4v::video_object_start()
+{
+ Element_Name("video_object_start");
+
+ //Integrity
+ if (Element_Size>0)
+ {
+ Trusted_IsNot("size is wrong");
+ return;
+ }
+}
+
+//---------------------------------------------------------------------------
+// Packet "20"
+void File_Mpeg4v::video_object_layer_start()
+{
+ Element_Name("video_object_layer_start");
+
+ //Default
+ Matrix_intra.clear();
+ Matrix_nonintra.clear();
+
+ //Parsing
+ int8u video_object_layer_verid=visual_object_verid;
+ int8u shape_extension=0;
+ int32u aux_comp_count=0;
+ BS_Begin();
+ Skip_SB( "random_accessible_vol");
+ Skip_S1(8, "video_object_type_indication");
+ TEST_SB_SKIP( "is_object_layer_identifier");
+ Get_S1 (4, video_object_layer_verid, "video_object_layer_verid"); Param_Info1(Mpeg4v_video_object_layer_verid[video_object_layer_verid]);
+ Skip_S1(3, "video_object_layer_priority");
+ TEST_SB_END();
+ Get_S1 (4, aspect_ratio_info, "aspect_ratio_info");
+ if (aspect_ratio_info==0x0F)
+ {
+ Get_S1 (8, par_width, "par_width");
+ Get_S1 (8, par_height, "par_height");
+ }
+ TEST_SB_SKIP( "vol_control_parameters");
+ Get_S1 (2, chroma_format, "chroma_format");
+ Get_SB ( low_delay, "low_delay");
+ TEST_SB_SKIP( "vbv_parameters");
+ Skip_S2(15, "first_half_bit_rate");
+ Mark_1 ();
+ Skip_S2(15, "latter_half_bit_rate");
+ Mark_1 ();
+ Skip_S2(15, "first_half_vbv_Element_Size");
+ Mark_1 ();
+ Skip_S1( 3, "latter_half_vbv_Element_Size");
+ Skip_S2(11, "first_half_vbv_occupancy");
+ Mark_1 ();
+ Skip_S2(15, "latter_half_vbv_occupancy");
+ Mark_1 ();
+ TEST_SB_END();
+ TEST_SB_END();
+ Get_S1 (2, shape, "video_object_layer_shape");
+ if (shape==3 && video_object_layer_verid!=1) //Shape=GrayScale
+ Get_S1 (4, shape_extension, "video_object_layer_shape_extension");
+ switch (shape_extension)
+ {
+ case 0 :
+ case 1 :
+ case 5 :
+ case 7 :
+ case 8 :
+ aux_comp_count=1; break;
+ case 2 :
+ case 3 :
+ case 6 :
+ case 9 :
+ case 11 :
+ aux_comp_count=2; break;
+ case 4 :
+ case 10 :
+ case 12 :
+ aux_comp_count=3; break;
+ default : ;
+ }
+ Mark_1 ();
+ Get_S2 (16, vop_time_increment_resolution, "vop_time_increment_resolution");
+ int32u PowerOf2=1;
+ for (time_size=0; time_size<=16; time_size++)
+ {
+ if ((int32u)vop_time_increment_resolution<PowerOf2)
+ break;
+ PowerOf2<<=1;
+ }
+ Mark_1 ();
+ TEST_SB_SKIP( "fixed_vop_rate");
+ Get_BS (time_size, fixed_vop_time_increment, "fixed_vop_time_increment"); Param_Info2C((vop_time_increment_resolution), fixed_vop_time_increment*1000/vop_time_increment_resolution, " ms");
+ TEST_SB_END();
+ if (shape!=2) //Shape!=BinaryOnly
+ {
+ if (shape==0) //Shape=Rectangular
+ {
+ Mark_1 ();
+ Get_S2 (13, object_layer_width, "object_layer_width");
+ Mark_1 ();
+ Get_S2 (13, object_layer_height, "object_layer_height");
+ Mark_1 ();
+ }
+ Get_SB (interlaced, "interlaced");
+ Skip_SB( "obmc_disable");
+ if (video_object_layer_verid==1)
+ Get_S1 (1, sprite_enable, "sprite_enable");
+ else
+ Get_S1 (2, sprite_enable, "sprite_enable");
+ if (sprite_enable==1 || sprite_enable==2 ) //static or GMC
+ {
+ if (sprite_enable!=2) //No GMC
+ {
+ Skip_S2(13, "sprite_width");
+ Mark_1 ();
+ Skip_S2(13, "sprite_height");
+ Mark_1 ();
+ Skip_S2(13, "sprite_top_coordinate");
+ Mark_1 ();
+ Skip_S2(13, "sprite_left_coordinate");
+ Mark_1 ();
+ }
+ Get_S1 (6, no_of_sprite_warping_points, "no_of_sprite_warping_points");
+ Skip_S1(2, "sprite_warping_accuracy");
+ Skip_SB( "sprite_brightness_change");
+ if (sprite_enable!=2) //No GMC
+ Skip_SB( "low_latency_sprite_enable");
+ }
+ if (video_object_layer_verid==1 && shape!=0) //Shape!=Rectangular
+ Skip_SB( "sadct_disable");
+ TEST_SB_SKIP( "bits_per_pixel_not_8_bit");
+ Skip_S1(4, "quant_precision");
+ Get_S1 (4, bits_per_pixel, "bits_per_pixel");
+ TEST_SB_END();
+ if (shape==3) //Shape=GrayScale
+ {
+ Skip_SB( "no_gray_quant_update");
+ Skip_SB( "composition_method");
+ Skip_SB( "linear_composition");
+ }
+ TEST_SB_GET (quant_type, "quant_type");
+ Get_SB (load_intra_quant_mat, "load_intra_quant_mat");
+ if(load_intra_quant_mat)
+ for (int16u Pos=0; Pos<64; Pos++)
+ {
+ int8u intra_quant_mat;
+ Get_S1 (8, intra_quant_mat, "intra_quant_mat");
+ if (!intra_quant_mat)
+ {
+ if (Matrix_intra.size()<2)
+ break; //There is a problem
+ Ztring Value=Matrix_intra.substr(Matrix_intra.size()-2, 2);
+ for (;Pos<64; Pos++)
+ Matrix_intra+=Value;
+ }
+ else
+ {
+ Ztring Value=Ztring::ToZtring(intra_quant_mat, 16);
+ if (Value.size()==1)
+ Value.insert(0, _T("0"));
+ Matrix_intra+=Value;
+ }
+ }
+ else
+ Matrix_intra="Default";
+ Get_SB (load_nonintra_quant_mat, "load_nonintra_quant_mat");
+ if(load_nonintra_quant_mat)
+ for (int16u Pos=0; Pos<64; Pos++)
+ {
+ int8u nonintra_quant_mat;
+ Get_S1 (8, nonintra_quant_mat, "nonintra_quant_mat");
+ if (!nonintra_quant_mat)
+ {
+ if (Matrix_nonintra.size()<2)
+ break; //There is a problem
+ Ztring Value=Matrix_nonintra.substr(Matrix_nonintra.size()-2, 2);
+ for (;Pos<64; Pos++)
+ Matrix_nonintra+=Value;
+ }
+ else
+ {
+ Ztring Value=Ztring::ToZtring(nonintra_quant_mat, 16);
+ if (Value.size()==1)
+ Value.insert(0, _T("0"));
+ Matrix_nonintra+=Value;
+ }
+ }
+ else
+ Matrix_nonintra="Default";
+ if(shape==3) //Shape=GrayScale
+ {
+ for(size_t aux_comp_Pos=0; aux_comp_Pos<aux_comp_count; aux_comp_Pos++)
+ {
+ Get_SB (load_intra_quant_mat_grayscale, "load_intra_quant_mat_grayscale");
+ if(load_intra_quant_mat_grayscale)
+ for (int16u Pos=0; Pos<64; Pos++)
+ {
+ int8u intra_quant_mat_grayscale;
+ Get_S1 (8, intra_quant_mat_grayscale, "intra_quant_mat_grayscale");
+ if (!intra_quant_mat_grayscale)
+ break;
+ }
+ Get_SB (load_nonintra_quant_mat_grayscale, "load_nonintra_quant_mat_grayscale");
+ if(load_nonintra_quant_mat_grayscale)
+ for (int16u Pos=0; Pos<64; Pos++)
+ {
+ int8u nonintra_quant_mat_grayscale;
+ Get_S1 (8, nonintra_quant_mat_grayscale, "nonintra_quant_mat_grayscale");
+ if (!nonintra_quant_mat_grayscale)
+ break;
+ }
+ }
+ }
+ TEST_SB_END();
+ if (video_object_layer_verid!=1)
+ {
+ Get_SB (quarter_sample, "quarter_sample");
+ }
+ Get_SB (complexity_estimation_disable, "complexity_estimation_disable");
+ if (!complexity_estimation_disable)
+ {
+ Get_S1 (2, estimation_method, "estimation_method");
+ if (estimation_method==0 || estimation_method==1)
+ {
+ TEST_SB_SKIP( "shape_complexity_estimation_disable");
+ Get_SB (opaque, "opaque");
+ Get_SB (transparent, "transparent");
+ Get_SB (intra_cae, "intra_cae");
+ Get_SB (inter_cae, "inter_cae");
+ Get_SB (no_update, "no_update");
+ Get_SB (upsampling, "upsampling");
+ TEST_SB_END();
+ TEST_SB_SKIP( "texture_complexity_estimation_set_1_disable");
+ Get_SB (intra_blocks, "intra_blocks");
+ Get_SB (inter_blocks, "inter_blocks");
+ Get_SB (inter4v_blocks, "inter4v_blocks");
+ Get_SB (not_coded_blocks, "not_coded_blocks");
+ TEST_SB_END();
+ Mark_1 ();
+ TEST_SB_SKIP( "texture_complexity_estimation_set_2_disable");
+ Get_SB (dct_coefs, "dct_coefs");
+ Get_SB (dct_lines, "dct_lines");
+ Get_SB (vlc_symbols, "vlc_symbols");
+ Get_SB (vlc_bits, "vlc_bits");
+ TEST_SB_END();
+ TEST_SB_SKIP( "motion_compensation_complexity_disable");
+ Get_SB (apm, "apm");
+ Get_SB (npm, "npm");
+ Get_SB (interpolate_mc_q, "interpolate_mc_q");
+ Get_SB (forw_back_mc_q, "forw_back_mc_q");
+ Get_SB (halfpel2, "halfpel2");
+ Get_SB (halfpel4, "halfpel4");
+ TEST_SB_END();
+ Mark_1 ();
+ if (estimation_method==1)
+ {
+ TEST_SB_SKIP( "version2_complexity_estimation_disable");
+ Get_SB (sadct, "sadct");
+ Get_SB (quarterpel, "quarterpel");
+ TEST_SB_END();
+ }
+ }
+ }
+ Skip_SB( "resync_marker_disable");
+ TEST_SB_GET( data_partitioned, "data_partitioned");
+ Get_SB ( reversible_vlc, "reversible_vlc");
+ TEST_SB_END();
+ if (video_object_layer_verid!=1)
+ {
+ Get_SB (newpred_enable, "newpred_enable");
+ if (newpred_enable)
+ {
+ Skip_S1(2, "requested_upstream_message_type");
+ Skip_SB( "newpred_segment_type");
+ }
+ Get_SB (reduced_resolution_vop_enable, "reduced_resolution_vop_enable");
+ }
+ Get_SB (scalability, "scalability");
+ if (scalability==1)
+ {
+ bool Hierarchy;
+ Get_SB ( Hierarchy, "hierarchy_type");
+ Skip_S1(4, "ref_layer_id");
+ Skip_SB( "ref_layer_sampling_direc");
+ Skip_S1(5, "hor_sampling_factor_n");
+ Skip_S1(5, "hor_sampling_factor_m");
+ Skip_S1(5, "vert_sampling_factor_n");
+ Skip_S1(5, "vert_sampling_factor_m");
+ Get_SB ( enhancement_type, "enhancement_type");
+ if (shape==1 && Hierarchy==0) //Shape=Binary
+ {
+ Skip_SB( "use_ref_shape");
+ Skip_SB( "use_ref_texture");
+ Skip_S1(5, "shape_hor_sampling_factor_n");
+ Skip_S1(5, "shape_hor_sampling_factor_m");
+ Skip_S1(5, "shape_vert_sampling_factor_n");
+ Skip_S1(5, "shape_vert_sampling_factor_m");
+ }
+ }
+ }
+ else
+ {
+ if (video_object_layer_verid!=1)
+ {
+ TEST_SB_SKIP( "scalability");
+ Skip_S1(4, "ref_layer_id");
+ Skip_S1(5, "shape_hor_sampling_factor_n");
+ Skip_S1(5, "shape_hor_sampling_factor_m");
+ Skip_S1(5, "shape_vert_sampling_factor_n");
+ Skip_S1(5, "shape_vert_sampling_factor_m");
+ TEST_SB_END();
+ }
+ Skip_SB( "resync_marker_disable");
+ }
+ BS_End();
+
+ //Coherancy
+ if (object_layer_width==0 || object_layer_height==0 || object_layer_width/object_layer_height<0.1 || object_layer_width/object_layer_height>10)
+ Trusted_IsNot("Problem with width and height!");
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Test();
+ NextCode_Clear();
+ NextCode_Add(0xB2); //user_data
+ NextCode_Add(0xB3); //group_of_vop_start
+ NextCode_Add(0xB6); //vop_start
+ for (int8u Pos=0x00; Pos<0x1F; Pos++)
+ NextCode_Add(Pos); //video_object_start
+
+ //Autorisation of other streams
+ Streams[0xB2].Searching_Payload=true; //user_data
+ Streams[0xB3].Searching_Payload=true; //group_of_vop_start
+ Streams[0xB6].Searching_Payload=true; //vop_start
+
+ //Setting as OK
+ video_object_layer_start_IsParsed=true;
+ if (!Status[IsAccepted])
+ Accept("MPEG-4 Visual");
+ FILLING_END()
+}
+
+//---------------------------------------------------------------------------
+// Packet "40"
+//
+void File_Mpeg4v::fgs_bp_start()
+{
+ Element_Name("fgs_bp_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "B0"
+void File_Mpeg4v::visual_object_sequence_start()
+{
+ Element_Name("visual_object_sequence_start");
+
+ //Parsing
+ Get_B1 (profile_and_level_indication, "profile_and_level_indication"); Param_Info1(Mpeg4v_Profile_Level(profile_and_level_indication));
+
+ //Integrity
+ if (Element_Size>1)
+ {
+ Trusted_IsNot("Size is wrong");
+ return;
+ }
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Clear();
+ NextCode_Add(0xB1); //visual_object_sequence_end
+ NextCode_Add(0xB2); //user_data
+ NextCode_Add(0xB5); //visual_object_start
+
+ //Autorisation of other streams
+ Streams[0xB1].Searching_Payload=true, //visual_object_sequence_end
+ Streams[0xB2].Searching_Payload=true; //user_data
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B1"
+void File_Mpeg4v::visual_object_sequence_end()
+{
+ Element_Name("visual_object_sequence_end");
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Clear();
+ NextCode_Add(0xB0); //visual_object_sequence_start
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B2", User defined size, this is often used of library name
+void File_Mpeg4v::user_data_start()
+{
+ Element_Name("user_data_start");
+
+ //Sony SNC files (security video)
+ if (Element_Size>=120 && Element_Size<=140)
+ {
+ int64u SNC_Identifier;
+ Peek_B8(SNC_Identifier);
+ if (SNC_Identifier==0x43616D54696D3A20ULL)
+ {
+ user_data_start_SNC();
+ return;
+ }
+ }
+
+ //Rejecting junk at the begin
+ size_t Library_Start_Offset=0;
+ while (Library_Start_Offset+4<=Element_Size)
+ {
+ bool OK=true;
+ for (size_t Pos=0; Pos<4; Pos++)
+ {
+ if (!((Buffer[Buffer_Offset+Library_Start_Offset+Pos]==0x20 && Pos)
+ || Buffer[Buffer_Offset+Library_Start_Offset+Pos]==0x22
+ || Buffer[Buffer_Offset+Library_Start_Offset+Pos]==0x27
+ || Buffer[Buffer_Offset+Library_Start_Offset+Pos]==0x28
+ || (Buffer[Buffer_Offset+Library_Start_Offset+Pos]==0x29 && Pos)
+ || (Buffer[Buffer_Offset+Library_Start_Offset+Pos]>=0x30 && Buffer[Buffer_Offset+Library_Start_Offset+Pos]<=0x3F)
+ || (Buffer[Buffer_Offset+Library_Start_Offset+Pos]>=0x41 && Buffer[Buffer_Offset+Library_Start_Offset+Pos]<=0x7D)))
+ {
+ OK=false;
+ break;
+ }
+ }
+ if (OK)
+ break;
+ Library_Start_Offset++;
+ }
+ if (Library_Start_Offset+4>Element_Size)
+ {
+ Skip_XX(Element_Size, "junk");
+ return; //No good info
+ }
+
+ //Accepting good data after junk
+ size_t Library_End_Offset=Library_Start_Offset+4;
+ while (Library_End_Offset<Element_Size
+ && (Buffer[Buffer_Offset+Library_End_Offset]==0x0D
+ || Buffer[Buffer_Offset+Library_End_Offset]==0x0A
+ || (Buffer[Buffer_Offset+Library_End_Offset]>=0x20 && Buffer[Buffer_Offset+Library_End_Offset]<=0x3F)
+ || (Buffer[Buffer_Offset+Library_End_Offset]>=0x41 && Buffer[Buffer_Offset+Library_End_Offset]<=0x7D)))
+ Library_End_Offset++;
+
+ //Parsing
+ Ztring Temp;
+ if (Library_Start_Offset>0)
+ Skip_XX(Library_Start_Offset, "junk");
+ if (Library_End_Offset-Library_Start_Offset)
+ Get_Local(Library_End_Offset-Library_Start_Offset, Temp,"data");
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "junk");
+
+ //Cleanup
+ while(Temp.size()>3 && Temp[1]==_T('e') && Temp[2]==_T('n') && Temp[3]==_T('c'))
+ Temp.erase(0, 1);
+ while(Temp.size()>5 && Temp[3]==_T('M') && Temp[4]==_T('P') && Temp[5]==_T('E'))
+ Temp.erase(0, 1);
+
+ FILLING_BEGIN();
+ if (Temp.size()>=4)
+ {
+ if (Temp.find(_T("build"))==0)
+ Library+=Ztring(_T(" "))+Temp;
+ else
+ Library=Temp;
+
+ //Library
+ if (Library.find(_T("DivX50"))==0)
+ {
+ Library_Name=_T("DivX");
+ Ztring Version=Library.SubString(_T("Build"), _T(""));
+ if (Version.empty())
+ Version=Library.SubString(_T("b"), _T("p"));
+ if (Version.empty())
+ Version=Library.SubString(_T("b"), _T(""));
+ Library_Version=MediaInfoLib::Config.Library_Get(InfoLibrary_Format_DivX, Version, InfoLibrary_Version);
+ if (Library_Version.empty())
+ Library_Version=Version;
+ Library_Date=MediaInfoLib::Config.Library_Get(InfoLibrary_Format_DivX, Version, InfoLibrary_Date);
+ }
+ if (Library.find(_T("XviD"))==0)
+ {
+ Library_Name=_T("XviD");
+ if (Library.find(_T("build="))==std::string::npos)
+ {
+ Ztring Version=Library.SubString(_T("XviD"), _T(""));
+ Version.FindAndReplace(_T("C"), _T(""));
+ Version.TrimLeft(_T('0'));
+ Library_Version=MediaInfoLib::Config.Library_Get(InfoLibrary_Format_XviD, Version, InfoLibrary_Version);
+ if (Library_Version.empty())
+ Library_Version=Version;
+ Library_Date=MediaInfoLib::Config.Library_Get(InfoLibrary_Format_XviD, Version, InfoLibrary_Date);
+ }
+ else
+ {
+ Library_Version=Library.SubString(_T("XviD"), _T(""));
+ Ztring Date=Library.SubString(_T(" build="), _T(""));
+ if (Date.size()==10)
+ {
+ Date[4]=_T('-');
+ Date[7]=_T('-');
+ Library_Date=_T("UTC ")+Date;
+ }
+ }
+ }
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B2", SNC (From Sony SNC surveillance video)
+void File_Mpeg4v::user_data_start_SNC()
+{
+ Element_Info1("Sony SNC");
+
+ if (!user_data_start_SNC_Data.empty())
+ {
+ Skip_XX(Element_Size, "Value");
+ return;
+ }
+
+ //Parsing
+ Ztring Value;
+ Get_Local(Element_Size, Value, "Value");
+ ZtringListList List;
+ List.Separator_Set(0, _T("\r\n"));
+ List.Separator_Set(1, _T(": "));
+ List.Write(Value);
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ if (List[Pos].size()==2)
+ user_data_start_SNC_Data(List[Pos][0])=List[Pos][1];
+ }
+}
+
+//---------------------------------------------------------------------------
+// Packet "B3"
+void File_Mpeg4v::group_of_vop_start()
+{
+ Element_Name("group_of_vop_start");
+
+ //Parsing
+ int8u Hours, Minutes, Seconds;
+ bool closed_gop, broken_link;
+ BS_Begin();
+ Get_S1 ( 5, Hours, "time_code_hours");
+ Get_S1 ( 6, Minutes, "time_code_minutes");
+ Mark_1();
+ Get_S1 ( 6, Seconds, "time_code_seconds");
+ Get_SB ( closed_gop, "closed_gop");
+ Get_SB ( broken_link, "broken_link");
+ BS_End();
+ Ztring Time;
+ Time+=Ztring::ToZtring(Hours);
+ Time+=_T(':');
+ Time+=Ztring::ToZtring(Minutes);
+ Time+=_T(':');
+ Time+=Ztring::ToZtring(Seconds);
+ Time+=_T(".000");
+ Element_Info1(Time);
+
+ FILLING_BEGIN();
+ //Calculating
+ if (Time_Begin_Seconds==(int32u)-1)
+ Time_Begin_Seconds=60*60*Hours+60*Minutes+Seconds;
+ Time_End_Seconds=60*60*Hours+60*Minutes+Seconds;
+ Time_End_MilliSeconds=(int16u)-1;
+
+ //NextCode
+ NextCode_Test();
+ NextCode_Clear();
+ for (int8u Pos=0x00; Pos<0x1F; Pos++)
+ NextCode_Add(Pos); //video_object_start
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B4"
+void File_Mpeg4v::video_session_error()
+{
+ Element_Name("video_session_error");
+}
+
+//---------------------------------------------------------------------------
+// Packet "B5"
+void File_Mpeg4v::visual_object_start()
+{
+ Element_Name("visual_object_start");
+
+ //Parsing
+ int8u visual_object_type;
+ BS_Begin();
+ TEST_SB_SKIP( "is_visual_object_identifier");
+ Get_S1 ( 4, visual_object_verid, "visual_object_verid"); Param_Info1(Mpeg4v_visual_object_verid[visual_object_verid]);
+ Skip_BS( 3, "visual_object_priority");
+ TEST_SB_END();
+ Get_S1 ( 4, visual_object_type, "visual_object_type"); Param_Info1(Mpeg4v_visual_object_type[visual_object_type]);
+ if (visual_object_type==1 || visual_object_type==2)
+ {
+ TEST_SB_SKIP( "video_signal_type");
+ Skip_S1(3, "video_format");
+ Skip_SB( "video_range");
+ TEST_SB_SKIP( "colour_description");
+ Skip_S1(8, "colour_primaries");
+ Skip_S1(8, "transfer_characteristics");
+ Skip_S1(8, "matrix_coefficients");
+ TEST_SB_END();
+ TEST_SB_END();
+ BS_End();
+
+ //Integrity
+ if (Element_Offset<Element_Size)
+ Trusted_IsNot("Size is wrong");
+ }
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Clear();
+ NextCode_Add(0xB2); //user_data
+ for (int8u Pos=0x00; Pos<0x2F; Pos++)
+ NextCode_Add(Pos); //video_object_start and video_object_layer_start
+
+ //Autorisation of other streams
+ Streams[0xB2].Searching_Payload=true;
+ for (int8u Pos=0x00; Pos<0x25; Pos++)
+ Streams[Pos].Searching_Payload=true; //video_object_start and video_object_layer_start
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B6"
+void File_Mpeg4v::vop_start()
+{
+ Element_Info1C( (FrameInfo.DTS!=(int64u)-1), _T("DTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.DTS)/1000000)));
+
+ //Counting
+ if (File_Offset+Buffer_Offset+Element_Size==File_Size)
+ Frame_Count_Valid=Frame_Count; //Finish frames in case of there are less than Frame_Count_Valid frames
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ if (Frame_Count_InThisBlock>Frame_Count_InThisBlock_Max)
+ Frame_Count_InThisBlock_Max=Frame_Count_InThisBlock;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+
+ //Name
+ Element_Name("vop_start");
+ Element_Info1(Ztring(_T("Frame ")+Ztring::ToZtring(Frame_Count)));
+
+ //Parsing
+ int32u vop_time_increment;
+ int8u vop_coding_type;
+ bool vop_coded;
+ BS_Begin();
+ Get_S1 (2, vop_coding_type, "vop_coding_type"); Param_Info1(Mpeg4v_vop_coding_type[vop_coding_type]);
+ Element_Info1(Mpeg4v_vop_coding_type[vop_coding_type]);
+ bool modulo_time_base_Continue;
+ int8u modulo_time_base=0;
+ do
+ {
+ Get_SB (modulo_time_base_Continue, "modulo_time_base");
+ if (modulo_time_base_Continue)
+ modulo_time_base++;
+ }
+ while (modulo_time_base_Continue);
+ Mark_1 ();
+
+ FILLING_BEGIN();
+ if (time_size==0)
+ {
+ //Filling only if not already done
+ if (Frame_Count>=Frame_Count_Valid && Count_Get(Stream_Video)==0)
+ {
+ Accept("MPEG-4 Visual");
+ Finish("MPEG-4 Visual");
+ }
+ return;
+ }
+ FILLING_END();
+
+ Get_S4 (time_size, vop_time_increment, "vop_time_increment"); Param_Info2C((vop_time_increment_resolution), vop_time_increment*1000/vop_time_increment_resolution, " ms");
+ Mark_1 ();
+ Get_SB (vop_coded, "vop_coded");
+ if (vop_coded)
+ {
+ if (newpred_enable)
+ {
+ Skip_S3(time_size+3<15?time_size+3:15, "vop_id");
+ TEST_SB_SKIP( "vop_id_for_prediction_indication");
+ Skip_BS(time_size+3<15?time_size+3:15, "vop_id_for_prediction");
+ TEST_SB_END();
+ Mark_1 ();
+ }
+
+ if (shape!=2 //Shape!=BinaryOnly
+ && (vop_coding_type==1 //Type=P
+ || (vop_coding_type==3 //Type=S
+ && sprite_enable==2))) //Sprite_Enable=GMC
+ Skip_SB( "vop_rounding_type");
+ if (reduced_resolution_vop_enable==1
+ && shape==0 //Shape=Rectangular
+ && (vop_coding_type==1 //Type=P
+ || vop_coding_type==0)) //Type=I
+ Skip_SB( "vop_reduced_resolution");
+ if (shape!=0) //Shape!=Rectangular
+ {
+ if (sprite_enable==1 //Sprite_Enable=Static
+ && vop_coding_type==0) //Type=I
+ {
+ Skip_S2(13, "vop_width");
+ Mark_1 ();
+ Skip_S2(13, "vop_height");
+ Mark_1 ();
+ Skip_S2(13, "vop_horizontal_mc_spatial_ref");
+ Mark_1 ();
+ Skip_S2(13, "vop_vertical_mc_spatial_ref");
+ Mark_1 ();
+ }
+ if (shape!=2 //Shape=BinaryOnly
+ && scalability==1
+ && enhancement_type==1)
+ Skip_SB( "background_composition");
+ Skip_SB( "change_conv_ratio_disable");
+ TEST_SB_SKIP( "vop_constant_alpha");
+ Skip_S1(8, "vop_constant_alpha_value");
+ TEST_SB_END();
+ }
+
+ if (shape!=2) //Shape=BinaryOnly
+ if (complexity_estimation_disable==0)
+ {
+ if (estimation_method==0)
+ {
+ if (vop_coding_type==0) //I
+ {
+ if (opaque) Skip_S1(8, "dcecs_opaque");
+ if (transparent) Skip_S1(8, "dcecs_transparent");
+ if (intra_cae) Skip_S1(8, "dcecs_intra_cae");
+ if (inter_cae) Skip_S1(8, "dcecs_inter_cae");
+ if (no_update) Skip_S1(8, "dcecs_no_update");
+ if (upsampling) Skip_S1(8, "dcecs_upsampling");
+ if (intra_blocks) Skip_S1(8, "dcecs_intra_blocks");
+ if (not_coded_blocks) Skip_S1(8, "dcecs_not_coded_blocks");
+ if (dct_coefs) Skip_S1(8, "dcecs_dct_coefs");
+ if (dct_lines) Skip_S1(8, "dcecs_dct_lines");
+ if (vlc_symbols) Skip_S1(8, "dcecs_vlc_symbols");
+ if (vlc_bits) Skip_S1(4, "dcecs_vlc_bits");
+ if (sadct) Skip_S1(8, "dcecs_sadct");
+ }
+ if (vop_coding_type==1) //P
+ {
+ if (opaque) Skip_S1(8, "dcecs_opaque");
+ if (transparent) Skip_S1(8, "dcecs_transparent");
+ if (intra_cae) Skip_S1(8, "dcecs_intra_cae");
+ if (inter_cae) Skip_S1(8, "dcecs_inter_cae");
+ if (no_update) Skip_S1(8, "dcecs_no_update");
+ if (upsampling) Skip_S1(8, "dcecs_upsampling");
+ if (intra_blocks) Skip_S1(8, "dcecs_intra_blocks");
+ if (not_coded_blocks) Skip_S1(8, "dcecs_not_coded_blocks");
+ if (dct_coefs) Skip_S1(8, "dcecs_dct_coefs");
+ if (dct_lines) Skip_S1(8, "dcecs_dct_lines");
+ if (vlc_symbols) Skip_S1(8, "dcecs_vlc_symbols");
+ if (vlc_bits) Skip_S1(4, "dcecs_vlc_bits");
+ if (inter_blocks) Skip_S1(8, "dcecs_inter_blocks");
+ if (inter4v_blocks) Skip_S1(8, "dcecs_inter4v_blocks");
+ if (apm) Skip_S1(8, "dcecs_apm");
+ if (npm) Skip_S1(8, "dcecs_npm");
+ if (forw_back_mc_q) Skip_S1(8, "dcecs_forw_back_mc_q");
+ if (halfpel2) Skip_S1(8, "dcecs_halfpel2");
+ if (halfpel4) Skip_S1(8, "dcecs_halfpel4");
+ if (sadct) Skip_S1(8, "dcecs_sadct");
+ if (quarterpel) Skip_S1(8, "dcecs_quarterpel");
+ }
+ if (vop_coding_type==2) //B
+ {
+ if (opaque) Skip_S1(8, "dcecs_opaque");
+ if (transparent) Skip_S1(8, "dcecs_transparent");
+ if (intra_cae) Skip_S1(8, "dcecs_intra_cae");
+ if (inter_cae) Skip_S1(8, "dcecs_inter_cae");
+ if (no_update) Skip_S1(8, "dcecs_no_update");
+ if (upsampling) Skip_S1(8, "dcecs_upsampling");
+ if (intra_blocks) Skip_S1(8, "dcecs_intra_blocks");
+ if (not_coded_blocks) Skip_S1(8, "dcecs_not_coded_blocks");
+ if (dct_coefs) Skip_S1(8, "dcecs_dct_coefs");
+ if (dct_lines) Skip_S1(8, "dcecs_dct_lines");
+ if (vlc_symbols) Skip_S1(8, "dcecs_vlc_symbols");
+ if (vlc_bits) Skip_S1(4, "dcecs_vlc_bits");
+ if (inter_blocks) Skip_S1(8, "dcecs_inter_blocks");
+ if (inter4v_blocks) Skip_S1(8, "dcecs_inter4v_blocks");
+ if (apm) Skip_S1(8, "dcecs_apm");
+ if (npm) Skip_S1(8, "dcecs_npm");
+ if (forw_back_mc_q) Skip_S1(8, "dcecs_forw_back_mc_q");
+ if (halfpel2) Skip_S1(8, "dcecs_halfpel2");
+ if (halfpel4) Skip_S1(8, "dcecs_halfpel4");
+ if (interpolate_mc_q) Skip_S1(8, "dcecs_interpolate_mc_q");
+ if (sadct) Skip_S1(8, "dcecs_sadct");
+ if (quarterpel) Skip_S1(8, "dcecs_sadct");
+ }
+ if (vop_coding_type==3 && sprite_enable==1) //B and static
+ {
+ if (intra_blocks) Skip_S1(8, "dcecs_intra_blocks");
+ if (not_coded_blocks) Skip_S1(8, "dcecs_not_coded_blocks");
+ if (dct_coefs) Skip_S1(8, "dcecs_dct_coefs");
+ if (dct_lines) Skip_S1(8, "dcecs_dct_lines");
+ if (vlc_symbols) Skip_S1(8, "dcecs_vlc_symbols");
+ if (vlc_bits) Skip_S1(4, "dcecs_vlc_bits");
+ if (inter_blocks) Skip_S1(8, "dcecs_inter_blocks");
+ if (inter4v_blocks) Skip_S1(8, "dcecs_inter4v_blocks");
+ if (apm) Skip_S1(8, "dcecs_apm");
+ if (npm) Skip_S1(8, "dcecs_npm");
+ if (forw_back_mc_q) Skip_S1(8, "dcecs_forw_back_mc_q");
+ if (halfpel2) Skip_S1(8, "dcecs_halfpel2");
+ if (halfpel4) Skip_S1(8, "dcecs_halfpel4");
+ if (interpolate_mc_q) Skip_S1(8, "dcecs_interpolate_mc_q");
+ }
+ }
+ }
+ if (shape!=2) //Shape!=BinaryOnly
+ {
+ Skip_S1(3, "intra_dc_vlc_thr");
+ if (interlaced)
+ {
+ bool top_field_first;
+ Get_SB (top_field_first, "top_field_first");
+ Skip_SB( "alternate_vertical_scan_flag");
+
+ //Filling
+ if (top_field_first)
+ Interlaced_Top++;
+ else
+ Interlaced_Bottom++;
+ }
+ }
+ //...
+ }
+
+ if (!vop_coded) //VOP with no data
+ NVOP_Count++;
+ else if (vop_coding_type==0) //Type I
+ {
+ IVOP_Count++;
+ PVOP_Count=0;
+ BVOP_Count=0;
+ }
+ else if (vop_coding_type==1) //Type P
+ {
+ PVOP_Count++;
+ BVOP_Count=0;
+ }
+ else if (vop_coding_type==2) //Type B
+ {
+ BVOP_Count++;
+ if (BVOP_Count>BVOP_Count_Max)
+ BVOP_Count_Max=BVOP_Count;
+ }
+ else if (vop_coding_type==3)
+ {
+ SVOP_Count++; //Type S
+ BVOP_Count=0;
+ }
+
+ FILLING_BEGIN();
+ //Duration
+ if (vop_time_increment_resolution)
+ {
+ int16u Time=modulo_time_base*1000+(int16u)vop_time_increment*1000/vop_time_increment_resolution;
+ while (Time_End_MilliSeconds!=(int16u)-1 && Time+500<Time_End_MilliSeconds)
+ Time+=1000;
+ Time_End_MilliSeconds=Time;
+ if (Time_Begin_MilliSeconds==(int16u)-1)
+ Time_Begin_MilliSeconds=Time_End_MilliSeconds;
+
+ Element_Info1C((Time_End_Seconds!=(int32u)-1), Ztring().Duration_From_Milliseconds((int64u)(Time_End_Seconds*1000+Time_End_MilliSeconds)));
+
+ if (FrameInfo.DTS!=(int64u)-1)
+ {
+ if (fixed_vop_time_increment && vop_time_increment_resolution)
+ FrameInfo.DTS+=((int64u)fixed_vop_time_increment)*1000000000/vop_time_increment_resolution;
+ else
+ FrameInfo.DTS=(int64u)-1;
+ }
+ }
+
+ //NextCode
+ NextCode_Test();
+ NextCode_Clear();
+ for (int8u Pos=0x00; Pos<0x2F; Pos++)
+ NextCode_Add(Pos); //video_object_start and video_object_layer_start
+ NextCode_Add(0xB1); //visual_object_sequence_end
+ NextCode_Add(0xB3); //group_of_vop_start_code
+ NextCode_Add(0xB5); //visual_object_start
+ NextCode_Add(0xB6); //vop_start
+
+ //Filling only if not already done
+ if (Frame_Count==2 && !Status[IsAccepted])
+ Accept("MPEG-4 Visual");
+ if (Frame_Count>=Frame_Count_Valid && Count_Get(Stream_Video)==0)
+ {
+ //TODO: better handling of the difference
+ if (IsSub)
+ Finish("MPEG-4 Visual");
+ else
+ {
+ Fill("MPEG-4 Visual");
+ if (Config_ParseSpeed<1.0)
+ {
+ if (!IsSub)
+ Open_Buffer_Unsynch();
+ GoToFromEnd(1024*1024, "MPEG-4 Visual");
+ }
+ }
+ }
+
+ #if MEDIAINFO_EVENTS
+ {
+ struct MediaInfo_Event_Video_SliceInfo_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_Video_SliceInfo, 0);
+ Event.Stream_Offset=File_Offset+Buffer_Offset;
+ Event.PCR=FrameInfo.PCR;
+ Event.PTS=FrameInfo.PTS;
+ Event.DTS=FrameInfo.DTS;
+ Event.DUR=FrameInfo.DUR;
+ Event.StreamIDs_Size=StreamIDs_Size;
+ Event.StreamIDs=(MediaInfo_int64u*)StreamIDs;
+ Event.StreamIDs_Width=(MediaInfo_int8u*)StreamIDs_Width;
+ Event.ParserIDs=(MediaInfo_int8u* )ParserIDs;
+ Event.FramePosition=Frame_Count;
+ Event.FieldPosition=Field_Count;
+ Event.SlicePosition=0;
+ switch (vop_coding_type)
+ {
+ case 0 :
+ Event.SliceType=0; break;
+ case 1 :
+ Event.SliceType=1; break;
+ case 2 :
+ Event.SliceType=2; break;
+ case 3 :
+ Event.SliceType=3; break;
+ default:
+ Event.SliceType=(int8u)-1;
+ }
+ Event.Flags=0;
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_Video_SliceInfo_0));
+ }
+ #endif //MEDIAINFO_EVENTS
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B7"
+void File_Mpeg4v::slice_start()
+{
+ Element_Name("slice_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "B8"
+void File_Mpeg4v::extension_start()
+{
+ Element_Name("extension_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "B9"
+void File_Mpeg4v::fgs_vop_start()
+{
+ Element_Name("fgs_vop_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "BA"
+void File_Mpeg4v::fba_object_start()
+{
+ Element_Name("fba_object_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "BB"
+void File_Mpeg4v::fba_object_plane_start()
+{
+ Element_Name("fba_object_plane_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "BC"
+void File_Mpeg4v::mesh_object_start()
+{
+ Element_Name("mesh_object_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "BD"
+void File_Mpeg4v::mesh_object_plane_start()
+{
+ Element_Name("mesh_object_plane_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "BE"
+void File_Mpeg4v::still_texture_object_start()
+{
+ Element_Name("still_texture_object_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "BF"
+void File_Mpeg4v::texture_spatial_layer_start()
+{
+ Element_Name("texture_spatial_layer_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "C0"
+void File_Mpeg4v::texture_snr_layer_start()
+{
+ Element_Name("texture_snr_layer_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "C1"
+void File_Mpeg4v::texture_tile_start()
+{
+ Element_Name("texture_tile_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "C2"
+void File_Mpeg4v::texture_shape_layer_start()
+{
+ Element_Name("texture_shape_layer_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "C3"
+void File_Mpeg4v::stuffing_start()
+{
+ Element_Name("stuffing_start");
+}
+
+//---------------------------------------------------------------------------
+// Packet "C4" and C5"
+void File_Mpeg4v::reserved()
+{
+ Element_Name("reserved");
+}
+
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPEG4V_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpeg4v.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpeg4v.h
new file mode 100644
index 000000000..7a0286137
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpeg4v.h
@@ -0,0 +1,201 @@
+// File_Avc - Info for MPEG-4 Visual Visual files
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MPEG-4 Visual files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Mpeg4vH
+#define MediaInfo_Mpeg4vH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Multiple/File_Mpeg4.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Mpeg4v
+//***************************************************************************
+
+class File_Mpeg4v : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ bool FrameIsAlwaysComplete;
+ void OnlyVOP(); //Data has only VOPs in it (configuration is elsewhere)
+
+ //Constructor/Destructor
+ File_Mpeg4v();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin() {return FileHeader_Begin_0x000001();}
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Synchro
+ bool Synchronize() {return Synchronize_0x000001();}
+ bool Synched_Test();
+ void Synched_Init();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test();
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Per element
+ void Header_Parse();
+ bool Header_Parser_QuickSearch();
+ bool Header_Parser_Fill_Size();
+ void Data_Parse();
+
+ //Elements
+ void video_object_start();
+ void video_object_layer_start();
+ void fgs_bp_start();
+ void visual_object_sequence_start();
+ void visual_object_sequence_end();
+ void user_data_start();
+ void user_data_start_SNC();
+ void group_of_vop_start();
+ void video_session_error();
+ void visual_object_start();
+ void vop_start();
+ void slice_start();
+ void extension_start();
+ void fgs_vop_start();
+ void fba_object_start();
+ void fba_object_plane_start();
+ void mesh_object_start();
+ void mesh_object_plane_start();
+ void still_texture_object_start();
+ void texture_spatial_layer_start();
+ void texture_snr_layer_start();
+ void texture_tile_start();
+ void texture_shape_layer_start();
+ void stuffing_start();
+ void reserved();
+
+ //Streams
+ struct stream
+ {
+ bool Searching_Payload;
+
+ stream()
+ {
+ Searching_Payload=false;
+ }
+ };
+ std::vector<stream> Streams;
+
+ //Count of a Packets
+ size_t IVOP_Count;
+ size_t PVOP_Count;
+ size_t BVOP_Count;
+ size_t BVOP_Count_Max;
+ size_t SVOP_Count;
+ size_t NVOP_Count;
+ size_t Interlaced_Top;
+ size_t Interlaced_Bottom;
+ int64u Frame_Count_InThisBlock_Max;
+
+ //From video_object_layer
+ int32u fixed_vop_time_increment;
+ int32u Time_Begin_Seconds;
+ int32u Time_End_Seconds;
+ int16u Time_Begin_MilliSeconds;
+ int16u Time_End_MilliSeconds;
+ int16u object_layer_width;
+ int16u object_layer_height;
+ int16u vop_time_increment_resolution;
+ int8u time_size;
+ int8u visual_object_verid;
+ int8u profile_and_level_indication;
+ int8u no_of_sprite_warping_points;
+ int8u aspect_ratio_info;
+ int8u par_width;
+ int8u par_height;
+ int8u bits_per_pixel;
+ int8u shape;
+ int8u sprite_enable;
+ int8u estimation_method;
+ int8u chroma_format;
+ bool quarter_sample;
+ bool low_delay;
+ bool load_intra_quant_mat;
+ bool load_nonintra_quant_mat;
+ bool load_intra_quant_mat_grayscale;
+ bool load_nonintra_quant_mat_grayscale;
+ bool interlaced;
+ bool newpred_enable;
+ bool reduced_resolution_vop_enable;
+ bool scalability;
+ bool enhancement_type;
+ bool complexity_estimation_disable;
+ bool opaque;
+ bool transparent;
+ bool intra_cae;
+ bool inter_cae;
+ bool no_update;
+ bool upsampling;
+ bool intra_blocks;
+ bool inter_blocks;
+ bool inter4v_blocks;
+ bool not_coded_blocks;
+ bool dct_coefs;
+ bool dct_lines;
+ bool vlc_symbols;
+ bool vlc_bits;
+ bool apm;
+ bool npm;
+ bool interpolate_mc_q;
+ bool forw_back_mc_q;
+ bool halfpel2;
+ bool halfpel4;
+ bool sadct;
+ bool quarterpel;
+ bool video_object_layer_start_IsParsed;
+ bool quant_type;
+ bool data_partitioned;
+ bool reversible_vlc;
+
+ //From user_data
+ Ztring Library;
+ Ztring Library_Name;
+ Ztring Library_Version;
+ Ztring Library_Date;
+ Ztring Matrix_intra;
+ Ztring Matrix_nonintra;
+ ZtringListList user_data_start_SNC_Data;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpegv.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpegv.cpp
new file mode 100644
index 000000000..ab7c48c18
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpegv.cpp
@@ -0,0 +1,3775 @@
+// File_Mpegv - Info for MPEG Video files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos (Global)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEGV_YES) || defined(MEDIAINFO_MPEGTS_YES) || defined(MEDIAINFO_MPEGPS_YES) || defined(MEDIAINFO_MXF_YES)
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+#include "ZenLib/Conf.h"
+using namespace ZenLib;
+
+//---------------------------------------------------------------------------
+extern const float32 Mpegv_frame_rate[16]=
+{
+ (float32) 0,
+ (float32)24000/(float32)1001,
+ (float32)24,
+ (float32)25,
+ (float32)30000/(float32)1001,
+ (float32)30,
+ (float32)50,
+ (float32)60000/(float32)1001,
+ (float32)60,
+ (float32) 0,
+ (float32) 0,
+ (float32) 0,
+ (float32) 0,
+ (float32) 0,
+ (float32) 0,
+ (float32) 0,
+};
+
+//---------------------------------------------------------------------------
+const char* Mpegv_Colorimetry_format[4]=
+{
+ "",
+ "4:2:0",
+ "4:2:2",
+ "4:4:4",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpegv_profile_and_level_indication (int8u profile_and_level_indication)
+{
+ switch (profile_and_level_indication)
+ {
+ case 0x82 : return "4:2:2@High";
+ case 0x85 : return "4:2:2@Main";
+ case 0x8A : return "Multi-view@High";
+ case 0x8B : return "Multi-view@High-1440";
+ case 0x8D : return "Multi-view@Main";
+ case 0x8E : return "Multi-view@Low";
+ default : return "";
+ }
+};
+
+//---------------------------------------------------------------------------
+const char* Mpegv_profile_and_level_indication_profile[]=
+{
+ "0",
+ "High",
+ "Spatially Scalable",
+ "SNR Scalable",
+ "Main",
+ "Simple",
+ "6",
+ "7",
+}; //4:2:2 Profile?
+
+//---------------------------------------------------------------------------
+const char* Mpegv_profile_and_level_indication_level[]=
+{
+ "0",
+ "1",
+ "2",
+ "3",
+ "High",
+ "4",
+ "High 1440",
+ "5",
+ "Main",
+ "6",
+ "Low",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+};
+
+} //NameSpace
+
+//---------------------------------------------------------------------------
+#endif //...
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_MPEGV_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Mpegv.h"
+#include "ZenLib/BitStream.h"
+#include "ZenLib/Utils.h"
+#if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ #include "MediaInfo/Text/File_DtvccTransport.h"
+#endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+#if defined(MEDIAINFO_SCTE20_YES)
+ #include "MediaInfo/Text/File_Scte20.h"
+#endif //defined(MEDIAINFO_SCTE20_YES)
+#if defined(MEDIAINFO_CDP_YES)
+ #include "MediaInfo/Text/File_Cdp.h"
+ #include <cstring>
+#endif //defined(MEDIAINFO_CDP_YES)
+#if defined(MEDIAINFO_AFDBARDATA_YES)
+ #include "MediaInfo/Video/File_AfdBarData.h"
+ #include <cstring>
+#endif //defined(MEDIAINFO_AFDBARDATA_YES)
+#if MEDIAINFO_MACROBLOCKS || MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+#endif //MEDIAINFO_MACROBLOCKS || MEDIAINFO_EVENTS
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+using namespace ZenLib;
+
+#undef FILLING_BEGIN
+#define FILLING_BEGIN() \
+ while (Element_Offset<Element_Size && Buffer[Buffer_Offset+(size_t)Element_Offset]==0x00) \
+ Element_Offset++; \
+ if (Element_Offset!=Element_Size) \
+ Trusted_IsNot("Size error"); \
+ else if (Element_IsOK()) \
+ { \
+
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+namespace MediaInfoLib
+{
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const float32 Mpegv_aspect_ratio1[]=
+{
+ (float32)0,
+ (float32)1,
+ (float32)0.6735,
+ (float32)0.7031, //16/9 PAL
+ (float32)0.7615,
+ (float32)0.8055,
+ (float32)0.8437, //16/9 NTSC
+ (float32)0.8935,
+ (float32)0.9375, //4/3 PAL
+ (float32)0.9815,
+ (float32)1.0255,
+ (float32)1.0695,
+ (float32)1.1250, //4/3 NTSC
+ (float32)1.1575,
+ (float32)1.2015,
+ (float32)0,
+};
+
+//---------------------------------------------------------------------------
+const float32 Mpegv_aspect_ratio2[]=
+{
+ (float32)0,
+ (float32)1,
+ (float32)4/(float32)3,
+ (float32)16/(float32)9,
+ (float32)2.21,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+ (float32)0,
+};
+
+//---------------------------------------------------------------------------
+const char* Mpegv_video_format[]=
+{
+ "Component",
+ "PAL",
+ "NTSC",
+ "SECAM",
+ "MAC",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpegv_picture_structure[]=
+{
+ "",
+ "T", //Top Field
+ "B", //Bottom Field
+ "F", //Frame
+};
+
+const char* Mpegv_picture_coding_type[]=
+{
+ "",
+ "I",
+ "P",
+ "B",
+ "D",
+ "",
+ "",
+ "",
+};
+
+const char* Mpegv_extension_start_code_identifier[]=
+{
+ "",
+ "Sequence",
+ "Sequence Display",
+ "Quant Matrix",
+ "Copyright",
+ "Sequence Scalable",
+ "",
+ "Picture Display",
+ "Picture Coding",
+ "Picture Spatial Scalable",
+ "Picture Temporal Scalable",
+ "Camera Parameters",
+ "ITU-T",
+ "",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const char* Mpegv_colour_primaries(int8u colour_primaries)
+{
+ switch (colour_primaries)
+ {
+ case 1 : return "BT.709";
+ case 4 : return "BT.470-2 system M";
+ case 5 : return "BT.470-2 System B, BT.470-2 System G";
+ case 6 : return "SMPTE 170M";
+ case 7 : return "SMPTE 240M";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpegv_transfer_characteristics(int8u transfer_characteristics)
+{
+ switch (transfer_characteristics)
+ {
+ case 1 : return "BT.709";
+ case 4 : return "BT.470-2 System M";
+ case 5 : return "BT.470-2 System B, BT.470-2 System G";
+ case 6 : return "SMPTE 170M";
+ case 7 : return "SMPTE 240M";
+ case 8 : return "Linear";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Mpegv_matrix_coefficients(int8u matrix_coefficients)
+{
+ switch (matrix_coefficients)
+ {
+ case 1 : return "BT.709";
+ case 4 : return "FCC";
+ case 5 : return "BT.470-2 System B, BT.470-2 System G";
+ case 6 : return "SMPTE 170M";
+ case 7 : return "SMPTE 240M";
+ default : return "";
+ }
+}
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_MACROBLOCKS
+const int8u Mpegv_block_count[4]=
+{
+ 0,
+ 6,
+ 8,
+ 12,
+};
+
+const File__Analyze::vlc Mpegv_macroblock_address_increment[]=
+{
+ // macroblock_address_increment
+ { 1 , 1 , 0 , 0 , 1 },
+ { 2 , 2 , 0 , 0 , 3 },
+ { 3 , 0 , 0 , 0 , 2 },
+ { 2 , 1 , 0 , 0 , 5 },
+ { 3 , 0 , 0 , 0 , 4 },
+ { 2 , 1 , 0 , 0 , 7 },
+ { 3 , 0 , 0 , 0 , 6 },
+ { 6 , 2 , 0 , 0 , 9 },
+ { 7 , 0 , 0 , 0 , 8 },
+ { 6 , 1 , 0 , 0 , 15 },
+ { 7 , 0 , 0 , 0 , 14 },
+ { 8 , 0 , 0 , 0 , 13 },
+ { 9 , 0 , 0 , 0 , 12 },
+ { 10 , 0 , 0 , 0 , 11 },
+ { 11 , 0 , 0 , 0 , 10 },
+ { 18 , 2 , 0 , 0 , 21 },
+ { 19 , 0 , 0 , 0 , 20 },
+ { 20 , 0 , 0 , 0 , 19 },
+ { 21 , 0 , 0 , 0 , 18 },
+ { 22 , 0 , 0 , 0 , 17 },
+ { 23 , 0 , 0 , 0 , 16 },
+ { 8 , 1 , 2 , 0 , 33 }, //Escape
+ { 24 , 0 , 0 , 0 , 33 },
+ { 25 , 0 , 0 , 0 , 32 },
+ { 26 , 0 , 0 , 0 , 31 },
+ { 27 , 0 , 0 , 0 , 30 },
+ { 28 , 0 , 0 , 0 , 29 },
+ { 29 , 0 , 0 , 0 , 28 },
+ { 30 , 0 , 0 , 0 , 27 },
+ { 31 , 0 , 0 , 0 , 26 },
+ { 32 , 0 , 0 , 0 , 25 },
+ { 33 , 0 , 0 , 0 , 24 },
+ { 34 , 0 , 0 , 0 , 23 },
+ { 35 , 0 , 0 , 0 , 22 },
+ VLC_END
+};
+const File__Analyze::vlc Mpegv_dct_dc_size_luminance[]=
+{
+ { 0, 2, 0, 0, 1},
+ { 1, 0, 0, 0, 2},
+ { 4, 1, 0, 0, 0},
+ { 5, 0, 0, 0, 3},
+ { 6, 0, 0, 0, 4},
+ { 14, 1, 0, 0, 5},
+ { 30, 1, 0, 0, 6},
+ { 62, 1, 0, 0, 7},
+ { 126, 1, 0, 0, 8},
+ { 254, 1, 0, 0, 9},
+ { 510, 1, 0, 0, 10},
+ { 511, 0, 0, 0, 11},
+ VLC_END
+};
+
+const File__Analyze::vlc Mpegv_dct_dc_size_chrominance[]=
+{
+ { 0, 2, 0, 0, 0},
+ { 1, 0, 0, 0, 1},
+ { 2, 0, 0, 0, 2},
+ { 6, 1, 0, 0, 3},
+ { 14, 1, 0, 0, 4},
+ { 30, 1, 0, 0, 5},
+ { 62, 1, 0, 0, 6},
+ { 126, 1, 0, 0, 7},
+ { 254, 1, 0, 0, 8},
+ { 510, 1, 0, 0, 9},
+ { 1022, 1, 0, 0, 10},
+ { 1023, 0, 0, 0, 11},
+ VLC_END
+};
+
+const File__Analyze::vlc Mpegv_dct_coefficients_0[]=
+{
+ // Run Level
+ { 2 , 2 , 3 , 0 , 1 }, // End of Block (others) or Run=0/Level=1 (first DCT)
+ { 3 , 0 , 3 , 0 , -1 }, // End of Block (others) or Run=0/Level=1 (first DCT)
+ { 6 , 2 , 0 , 1 , 1 },
+ { 7 , 0 , 0 , 1 , -1 },
+ { 8 , 1 , 0 , 0 , 2 },
+ { 9 , 0 , 0 , 0 , -2 },
+ { 10 , 0 , 0 , 2 , 1 },
+ { 11 , 0 , 0 , 2 , -1 },
+ { 1 , 1 , 2 , 0 , 0 }, // Escape
+ { 10 , 0 , 0 , 0 , 3 },
+ { 11 , 0 , 0 , 0 , -3 },
+ { 12 , 0 , 0 , 4 , 1 },
+ { 13 , 0 , 0 , 4 , -1 },
+ { 14 , 0 , 0 , 3 , 1 },
+ { 15 , 0 , 0 , 3 , -1 },
+ { 8 , 1 , 0 , 7 , 1 },
+ { 9 , 0 , 0 , 7 , -1 },
+ { 10 , 0 , 0 , 6 , 1 },
+ { 11 , 0 , 0 , 6 , -1 },
+ { 12 , 0 , 0 , 1 , 2 },
+ { 13 , 0 , 0 , 1 , -2 },
+ { 14 , 0 , 0 , 5 , 1 },
+ { 15 , 0 , 0 , 5 , -1 },
+ { 8 , 1 , 0 , 2 , 2 },
+ { 9 , 0 , 0 , 2 , -2 },
+ { 10 , 0 , 0 , 9 , 1 },
+ { 11 , 0 , 0 , 9 , -1 },
+ { 12 , 0 , 0 , 0 , 4 },
+ { 13 , 0 , 0 , 0 , -4 },
+ { 14 , 0 , 0 , 8 , 1 },
+ { 15 , 0 , 0 , 8 , -1 },
+ { 64 , 1 , 0 , 13 , 1 },
+ { 65 , 0 , 0 , 13 , -1 },
+ { 66 , 0 , 0 , 0 , 6 },
+ { 67 , 0 , 0 , 0 , -6 },
+ { 68 , 0 , 0 , 12 , 1 },
+ { 69 , 0 , 0 , 12 , -1 },
+ { 70 , 0 , 0 , 11 , 1 },
+ { 71 , 0 , 0 , 11 , -1 },
+ { 72 , 0 , 0 , 3 , 2 },
+ { 73 , 0 , 0 , 3 , -2 },
+ { 74 , 0 , 0 , 1 , 3 },
+ { 75 , 0 , 0 , 1 , -3 },
+ { 76 , 0 , 0 , 0 , 5 },
+ { 77 , 0 , 0 , 0 , -5 },
+ { 78 , 0 , 0 , 10 , 1 },
+ { 79 , 0 , 0 , 10 , -1 },
+ { 16 , 2 , 0 , 16 , 1 },
+ { 17 , 0 , 0 , 16 , -1 },
+ { 18 , 0 , 0 , 5 , 2 },
+ { 19 , 0 , 0 , 5 , -2 },
+ { 20 , 0 , 0 , 0 , 7 },
+ { 21 , 0 , 0 , 0 , -7 },
+ { 22 , 0 , 0 , 2 , 3 },
+ { 23 , 0 , 0 , 2 , -3 },
+ { 24 , 0 , 0 , 1 , 4 },
+ { 25 , 0 , 0 , 1 , -4 },
+ { 26 , 0 , 0 , 15 , 1 },
+ { 27 , 0 , 0 , 15 , -1 },
+ { 28 , 0 , 0 , 14 , 1 },
+ { 29 , 0 , 0 , 14 , -1 },
+ { 30 , 0 , 0 , 4 , 2 },
+ { 31 , 0 , 0 , 4 , -2 },
+ { 32 , 2 , 0 , 0 , 11 },
+ { 33 , 0 , 0 , 0 , -11 },
+ { 34 , 0 , 0 , 8 , 2 },
+ { 35 , 0 , 0 , 8 , -2 },
+ { 36 , 0 , 0 , 4 , 3 },
+ { 37 , 0 , 0 , 4 , -3 },
+ { 38 , 0 , 0 , 0 , 10 },
+ { 39 , 0 , 0 , 0 , -10 },
+ { 40 , 0 , 0 , 2 , 4 },
+ { 41 , 0 , 0 , 2 , -4 },
+ { 42 , 0 , 0 , 7 , 2 },
+ { 43 , 0 , 0 , 7 , -2 },
+ { 44 , 0 , 0 , 21 , 1 },
+ { 45 , 0 , 0 , 21 , -1 },
+ { 46 , 0 , 0 , 20 , 1 },
+ { 47 , 0 , 0 , 20 , -1 },
+ { 48 , 0 , 0 , 0 , 9 },
+ { 49 , 0 , 0 , 0 , -9 },
+ { 50 , 0 , 0 , 19 , 1 },
+ { 51 , 0 , 0 , 19 , -1 },
+ { 52 , 0 , 0 , 18 , 1 },
+ { 53 , 0 , 0 , 18 , -1 },
+ { 54 , 0 , 0 , 1 , 5 },
+ { 55 , 0 , 0 , 1 , -5 },
+ { 56 , 0 , 0 , 3 , 3 },
+ { 57 , 0 , 0 , 3 , -3 },
+ { 58 , 0 , 0 , 0 , 8 },
+ { 59 , 0 , 0 , 0 , -8 },
+ { 60 , 0 , 0 , 6 , 2 },
+ { 61 , 0 , 0 , 6 , -2 },
+ { 62 , 0 , 0 , 17 , 1 },
+ { 63 , 0 , 0 , 17 , -1 },
+ { 32 , 1 , 0 , 10 , 2 },
+ { 33 , 0 , 0 , 10 , -2 },
+ { 34 , 0 , 0 , 9 , 2 },
+ { 35 , 0 , 0 , 9 , -2 },
+ { 36 , 0 , 0 , 5 , 3 },
+ { 37 , 0 , 0 , 5 , -3 },
+ { 38 , 0 , 0 , 3 , 4 },
+ { 39 , 0 , 0 , 3 , -4 },
+ { 40 , 0 , 0 , 2 , 5 },
+ { 41 , 0 , 0 , 2 , -5 },
+ { 42 , 0 , 0 , 1 , 7 },
+ { 43 , 0 , 0 , 1 , -7 },
+ { 44 , 0 , 0 , 1 , 6 },
+ { 45 , 0 , 0 , 1 , -6 },
+ { 46 , 0 , 0 , 0 , 15 },
+ { 47 , 0 , 0 , 0 , -15 },
+ { 48 , 0 , 0 , 0 , 14 },
+ { 49 , 0 , 0 , 0 , -14 },
+ { 50 , 0 , 0 , 0 , 13 },
+ { 51 , 0 , 0 , 0 , -13 },
+ { 52 , 0 , 0 , 0 , 12 },
+ { 53 , 0 , 0 , 0 , -12 },
+ { 54 , 0 , 0 , 26 , 1 },
+ { 55 , 0 , 0 , 26 , -1 },
+ { 56 , 0 , 0 , 25 , 1 },
+ { 57 , 0 , 0 , 25 , -1 },
+ { 58 , 0 , 0 , 24 , 1 },
+ { 59 , 0 , 0 , 24 , -1 },
+ { 60 , 0 , 0 , 23 , 1 },
+ { 61 , 0 , 0 , 23 , -1 },
+ { 62 , 0 , 0 , 22 , 1 },
+ { 63 , 0 , 0 , 22 , -1 },
+ { 32 , 1 , 0 , 0 , 31 },
+ { 33 , 0 , 0 , 0 , -31 },
+ { 34 , 0 , 0 , 0 , 30 },
+ { 35 , 0 , 0 , 0 , -30 },
+ { 36 , 0 , 0 , 0 , 29 },
+ { 37 , 0 , 0 , 0 , -29 },
+ { 38 , 0 , 0 , 0 , 28 },
+ { 39 , 0 , 0 , 0 , -28 },
+ { 40 , 0 , 0 , 0 , 27 },
+ { 41 , 0 , 0 , 0 , -27 },
+ { 42 , 0 , 0 , 0 , 26 },
+ { 43 , 0 , 0 , 0 , -26 },
+ { 44 , 0 , 0 , 0 , 25 },
+ { 45 , 0 , 0 , 0 , -25 },
+ { 46 , 0 , 0 , 0 , 24 },
+ { 47 , 0 , 0 , 0 , -24 },
+ { 48 , 0 , 0 , 0 , 23 },
+ { 49 , 0 , 0 , 0 , -23 },
+ { 50 , 0 , 0 , 0 , 22 },
+ { 51 , 0 , 0 , 0 , -22 },
+ { 52 , 0 , 0 , 0 , 21 },
+ { 53 , 0 , 0 , 0 , -21 },
+ { 54 , 0 , 0 , 0 , 20 },
+ { 55 , 0 , 0 , 0 , -20 },
+ { 56 , 0 , 0 , 0 , 19 },
+ { 57 , 0 , 0 , 0 , -19 },
+ { 58 , 0 , 0 , 0 , 18 },
+ { 59 , 0 , 0 , 0 , -18 },
+ { 60 , 0 , 0 , 0 , 17 },
+ { 61 , 0 , 0 , 0 , -17 },
+ { 62 , 0 , 0 , 0 , 16 },
+ { 63 , 0 , 0 , 0 , -16 },
+ { 32 , 1 , 0 , 0 , 40 },
+ { 33 , 0 , 0 , 0 , -40 },
+ { 34 , 0 , 0 , 0 , 39 },
+ { 35 , 0 , 0 , 0 , -39 },
+ { 36 , 0 , 0 , 0 , 38 },
+ { 37 , 0 , 0 , 0 , -38 },
+ { 38 , 0 , 0 , 0 , 37 },
+ { 39 , 0 , 0 , 0 , -37 },
+ { 40 , 0 , 0 , 0 , 36 },
+ { 41 , 0 , 0 , 0 , -36 },
+ { 42 , 0 , 0 , 0 , 35 },
+ { 43 , 0 , 0 , 0 , -35 },
+ { 44 , 0 , 0 , 0 , 34 },
+ { 45 , 0 , 0 , 0 , -34 },
+ { 46 , 0 , 0 , 0 , 33 },
+ { 47 , 0 , 0 , 0 , -33 },
+ { 48 , 0 , 0 , 0 , 32 },
+ { 49 , 0 , 0 , 0 , -32 },
+ { 50 , 0 , 0 , 1 , 14 },
+ { 51 , 0 , 0 , 1 , -14 },
+ { 52 , 0 , 0 , 1 , 13 },
+ { 53 , 0 , 0 , 1 , -13 },
+ { 54 , 0 , 0 , 1 , 12 },
+ { 55 , 0 , 0 , 1 , -12 },
+ { 56 , 0 , 0 , 1 , 11 },
+ { 57 , 0 , 0 , 1 , -11 },
+ { 58 , 0 , 0 , 1 , 10 },
+ { 59 , 0 , 0 , 1 , -10 },
+ { 60 , 0 , 0 , 1 , 9 },
+ { 61 , 0 , 0 , 1 , -9 },
+ { 62 , 0 , 0 , 1 , 8 },
+ { 63 , 0 , 0 , 1 , -8 },
+ { 32 , 1 , 0 , 1 , 18 },
+ { 33 , 0 , 0 , 1 , -18 },
+ { 34 , 0 , 0 , 1 , 17 },
+ { 35 , 0 , 0 , 1 , -17 },
+ { 36 , 0 , 0 , 1 , 16 },
+ { 37 , 0 , 0 , 1 , -16 },
+ { 38 , 0 , 0 , 1 , 15 },
+ { 39 , 0 , 0 , 1 , -15 },
+ { 40 , 0 , 0 , 6 , 3 },
+ { 41 , 0 , 0 , 6 , -3 },
+ { 42 , 0 , 0 , 16 , 2 },
+ { 43 , 0 , 0 , 16 , -2 },
+ { 44 , 0 , 0 , 15 , 2 },
+ { 45 , 0 , 0 , 15 , -2 },
+ { 46 , 0 , 0 , 14 , 2 },
+ { 47 , 0 , 0 , 14 , -2 },
+ { 48 , 0 , 0 , 13 , 2 },
+ { 49 , 0 , 0 , 13 , -2 },
+ { 50 , 0 , 0 , 12 , 2 },
+ { 51 , 0 , 0 , 12 , -2 },
+ { 52 , 0 , 0 , 11 , 2 },
+ { 53 , 0 , 0 , 11 , -2 },
+ { 54 , 0 , 0 , 31 , 1 },
+ { 55 , 0 , 0 , 31 , -1 },
+ { 56 , 0 , 0 , 30 , 1 },
+ { 57 , 0 , 0 , 30 , -1 },
+ { 58 , 0 , 0 , 29 , 1 },
+ { 59 , 0 , 0 , 29 , -1 },
+ { 60 , 0 , 0 , 28 , 1 },
+ { 61 , 0 , 0 , 28 , -1 },
+ { 62 , 0 , 0 , 27 , 1 },
+ { 63 , 0 , 0 , 27 , -1 },
+ {(int32u)-1, (int8u)-1, 1, -1, -1} //
+};
+
+const File__Analyze::vlc Mpegv_dct_coefficients_1[]=
+{
+ // Run Level
+ { 4 , 3 , 0 , 0 , 1 },
+ { 5 , 0 , 0 , 0 , -1 },
+ { 4 , 1 , 0 , 1 , 1 },
+ { 5 , 0 , 0 , 1 , -1 },
+ { 6 , 0 , 1 , 0 , 0 },
+ { 12 , 0 , 0 , 0 , 2 },
+ { 13 , 0 , 0 , 0 , -2 },
+ { 14 , 1 , 0 , 0 , 3 },
+ { 15 , 0 , 0 , 0 , -3 },
+ { 1 , 1 , 2 , 0 , 0 },
+ { 10 , 0 , 0 , 2 , 1 },
+ { 11 , 0 , 0 , 2 , -1 },
+ { 12 , 0 , 0 , 1 , 2 },
+ { 13 , 0 , 0 , 1 , -2 },
+ { 14 , 0 , 0 , 3 , 1 },
+ { 15 , 0 , 0 , 3 , -1 },
+ { 56 , 0 , 0 , 0 , 4 },
+ { 57 , 0 , 0 , 0 , -4 },
+ { 58 , 0 , 0 , 0 , 5 },
+ { 59 , 0 , 0 , 0 , -5 },
+ { 8 , 1 , 0 , 0 , 7 },
+ { 9 , 0 , 0 , 0 , -7 },
+ { 10 , 0 , 0 , 0 , 6 },
+ { 11 , 0 , 0 , 0 , -6 },
+ { 12 , 0 , 0 , 4 , 1 },
+ { 13 , 0 , 0 , 4 , -1 },
+ { 14 , 0 , 0 , 5 , 1 },
+ { 15 , 0 , 0 , 5 , -1 },
+ { 8 , 1 , 0 , 7 , 1 },
+ { 9 , 0 , 0 , 7 , -1 },
+ { 10 , 0 , 0 , 8 , 1 },
+ { 11 , 0 , 0 , 8 , -1 },
+ { 12 , 0 , 0 , 6 , 1 },
+ { 13 , 0 , 0 , 6 , -1 },
+ { 14 , 0 , 0 , 2 , 2 },
+ { 15 , 0 , 0 , 2 , -2 },
+ { 240 , 0 , 0 , 9 , 1 },
+ { 241 , 0 , 0 , 9 , -1 },
+ { 242 , 0 , 0 , 1 , 3 },
+ { 243 , 0 , 0 , 1 , -3 },
+ { 244 , 0 , 0 , 10 , 1 },
+ { 245 , 0 , 0 , 10 , -1 },
+ { 246 , 0 , 0 , 0 , 8 },
+ { 247 , 0 , 0 , 0 , -8 },
+ { 248 , 0 , 0 , 0 , 9 },
+ { 249 , 0 , 0 , 0 , -9 },
+ { 64 , 1 , 0 , 1 , 5 },
+ { 65 , 0 , 0 , 1 , -5 },
+ { 66 , 0 , 0 , 11 , 1 },
+ { 67 , 0 , 0 , 11 , -1 },
+ { 68 , 0 , 0 , 0 , 11 },
+ { 69 , 0 , 0 , 0 , -11 },
+ { 70 , 0 , 0 , 0 , 10 },
+ { 71 , 0 , 0 , 0 , -10 },
+ { 72 , 0 , 0 , 13 , 1 },
+ { 73 , 0 , 0 , 13 , -1 },
+ { 74 , 0 , 0 , 12 , 1 },
+ { 75 , 0 , 0 , 12 , -1 },
+ { 76 , 0 , 0 , 3 , 2 },
+ { 77 , 0 , 0 , 3 , -2 },
+ { 78 , 0 , 0 , 1 , 4 },
+ { 79 , 0 , 0 , 1 , -4 },
+ { 500 , 0 , 0 , 0 , 12 },
+ { 501 , 0 , 0 , 0 , -12 },
+ { 502 , 0 , 0 , 0 , 13 },
+ { 503 , 0 , 0 , 0 , -13 },
+ { 504 , 0 , 0 , 2 , 3 },
+ { 505 , 0 , 0 , 2 , -3 },
+ { 506 , 0 , 0 , 4 , 2 },
+ { 507 , 0 , 0 , 4 , -2 },
+ { 508 , 0 , 0 , 0 , 14 },
+ { 509 , 0 , 0 , 0 , -14 },
+ { 510 , 0 , 0 , 0 , 15 },
+ { 511 , 0 , 0 , 0 , -15 },
+ { 8 , 1 , 0 , 5 , 2 },
+ { 9 , 0 , 0 , 5 , -2 },
+ { 10 , 0 , 0 , 14 , 1 },
+ { 11 , 0 , 0 , 14 , -1 },
+ { 14 , 0 , 0 , 15 , 1 },
+ { 15 , 0 , 0 , 15 , -1 },
+ { 24 , 1 , 0 , 2 , 4 },
+ { 25 , 0 , 0 , 2 , -4 },
+ { 26 , 0 , 0 , 16 , 1 },
+ { 27 , 0 , 0 , 16 , -1 },
+ { 34 , 2 , 0 , 8 , 2 },
+ { 35 , 0 , 0 , 8 , -2 },
+ { 36 , 0 , 0 , 4 , 3 },
+ { 37 , 0 , 0 , 4 , -3 },
+ { 42 , 0 , 0 , 7 , 2 },
+ { 43 , 0 , 0 , 7 , -2 },
+ { 44 , 0 , 0 , 21 , 1 },
+ { 45 , 0 , 0 , 21 , -1 },
+ { 46 , 0 , 0 , 20 , 1 },
+ { 47 , 0 , 0 , 20 , -1 },
+ { 50 , 0 , 0 , 19 , 1 },
+ { 51 , 0 , 0 , 19 , -1 },
+ { 52 , 0 , 0 , 18 , 1 },
+ { 53 , 0 , 0 , 18 , -1 },
+ { 56 , 0 , 0 , 3 , 3 },
+ { 57 , 0 , 0 , 3 , -3 },
+ { 60 , 0 , 0 , 6 , 2 },
+ { 61 , 0 , 0 , 6 , -2 },
+ { 62 , 0 , 0 , 17 , 1 },
+ { 63 , 0 , 0 , 17 , -1 },
+ { 32 , 1 , 0 , 10 , 2 },
+ { 33 , 0 , 0 , 10 , -2 },
+ { 34 , 0 , 0 , 9 , 2 },
+ { 35 , 0 , 0 , 9 , -2 },
+ { 36 , 0 , 0 , 5 , 3 },
+ { 37 , 0 , 0 , 5 , -3 },
+ { 38 , 0 , 0 , 3 , 4 },
+ { 39 , 0 , 0 , 3 , -4 },
+ { 40 , 0 , 0 , 2 , 5 },
+ { 41 , 0 , 0 , 2 , -5 },
+ { 42 , 0 , 0 , 1 , 7 },
+ { 43 , 0 , 0 , 1 , -7 },
+ { 44 , 0 , 0 , 1 , 6 },
+ { 45 , 0 , 0 , 1 , -6 },
+ { 54 , 0 , 0 , 26 , 1 },
+ { 55 , 0 , 0 , 26 , -1 },
+ { 56 , 0 , 0 , 25 , 1 },
+ { 57 , 0 , 0 , 25 , -1 },
+ { 58 , 0 , 0 , 24 , 1 },
+ { 59 , 0 , 0 , 24 , -1 },
+ { 60 , 0 , 0 , 23 , 1 },
+ { 61 , 0 , 0 , 23 , -1 },
+ { 62 , 0 , 0 , 22 , 1 },
+ { 63 , 0 , 0 , 22 , -1 },
+ { 32 , 1 , 0 , 0 , 31 },
+ { 33 , 0 , 0 , 0 , -31 },
+ { 34 , 0 , 0 , 0 , 30 },
+ { 35 , 0 , 0 , 0 , -30 },
+ { 36 , 0 , 0 , 0 , 29 },
+ { 37 , 0 , 0 , 0 , -29 },
+ { 38 , 0 , 0 , 0 , 28 },
+ { 39 , 0 , 0 , 0 , -28 },
+ { 40 , 0 , 0 , 0 , 27 },
+ { 41 , 0 , 0 , 0 , -27 },
+ { 42 , 0 , 0 , 0 , 26 },
+ { 43 , 0 , 0 , 0 , -26 },
+ { 44 , 0 , 0 , 0 , 25 },
+ { 45 , 0 , 0 , 0 , -25 },
+ { 46 , 0 , 0 , 0 , 24 },
+ { 47 , 0 , 0 , 0 , -24 },
+ { 48 , 0 , 0 , 0 , 23 },
+ { 49 , 0 , 0 , 0 , -23 },
+ { 50 , 0 , 0 , 0 , 22 },
+ { 51 , 0 , 0 , 0 , -22 },
+ { 52 , 0 , 0 , 0 , 21 },
+ { 53 , 0 , 0 , 0 , -21 },
+ { 54 , 0 , 0 , 0 , 20 },
+ { 55 , 0 , 0 , 0 , -20 },
+ { 56 , 0 , 0 , 0 , 19 },
+ { 57 , 0 , 0 , 0 , -19 },
+ { 58 , 0 , 0 , 0 , 18 },
+ { 59 , 0 , 0 , 0 , -18 },
+ { 60 , 0 , 0 , 0 , 17 },
+ { 61 , 0 , 0 , 0 , -17 },
+ { 62 , 0 , 0 , 0 , 16 },
+ { 63 , 0 , 0 , 0 , -16 },
+ { 32 , 1 , 0 , 0 , 40 },
+ { 33 , 0 , 0 , 0 , -40 },
+ { 34 , 0 , 0 , 0 , 39 },
+ { 35 , 0 , 0 , 0 , -39 },
+ { 36 , 0 , 0 , 0 , 38 },
+ { 37 , 0 , 0 , 0 , -38 },
+ { 38 , 0 , 0 , 0 , 37 },
+ { 39 , 0 , 0 , 0 , -37 },
+ { 40 , 0 , 0 , 0 , 36 },
+ { 41 , 0 , 0 , 0 , -36 },
+ { 42 , 0 , 0 , 0 , 35 },
+ { 43 , 0 , 0 , 0 , -35 },
+ { 44 , 0 , 0 , 0 , 34 },
+ { 45 , 0 , 0 , 0 , -34 },
+ { 46 , 0 , 0 , 0 , 33 },
+ { 47 , 0 , 0 , 0 , -33 },
+ { 48 , 0 , 0 , 0 , 32 },
+ { 49 , 0 , 0 , 0 , -32 },
+ { 50 , 0 , 0 , 1 , 14 },
+ { 51 , 0 , 0 , 1 , -14 },
+ { 52 , 0 , 0 , 1 , 13 },
+ { 53 , 0 , 0 , 1 , -13 },
+ { 54 , 0 , 0 , 1 , 12 },
+ { 55 , 0 , 0 , 1 , -12 },
+ { 56 , 0 , 0 , 1 , 11 },
+ { 57 , 0 , 0 , 1 , -11 },
+ { 58 , 0 , 0 , 1 , 10 },
+ { 59 , 0 , 0 , 1 , -10 },
+ { 60 , 0 , 0 , 1 , 9 },
+ { 61 , 0 , 0 , 1 , -9 },
+ { 62 , 0 , 0 , 1 , 8 },
+ { 63 , 0 , 0 , 1 , -8 },
+ { 32 , 1 , 0 , 1 , 18 },
+ { 33 , 0 , 0 , 1 , -18 },
+ { 34 , 0 , 0 , 1 , 17 },
+ { 35 , 0 , 0 , 1 , -17 },
+ { 36 , 0 , 0 , 1 , 16 },
+ { 37 , 0 , 0 , 1 , -16 },
+ { 38 , 0 , 0 , 1 , 15 },
+ { 39 , 0 , 0 , 1 , -15 },
+ { 40 , 0 , 0 , 6 , 3 },
+ { 41 , 0 , 0 , 6 , -3 },
+ { 42 , 0 , 0 , 16 , 2 },
+ { 43 , 0 , 0 , 16 , -2 },
+ { 44 , 0 , 0 , 15 , 2 },
+ { 45 , 0 , 0 , 15 , -2 },
+ { 46 , 0 , 0 , 14 , 2 },
+ { 47 , 0 , 0 , 14 , -2 },
+ { 48 , 0 , 0 , 13 , 2 },
+ { 49 , 0 , 0 , 13 , -2 },
+ { 50 , 0 , 0 , 12 , 2 },
+ { 51 , 0 , 0 , 12 , -2 },
+ { 52 , 0 , 0 , 11 , 2 },
+ { 53 , 0 , 0 , 11 , -2 },
+ { 54 , 0 , 0 , 31 , 1 },
+ { 55 , 0 , 0 , 31 , -1 },
+ { 56 , 0 , 0 , 30 , 1 },
+ { 57 , 0 , 0 , 30 , -1 },
+ { 58 , 0 , 0 , 29 , 1 },
+ { 59 , 0 , 0 , 29 , -1 },
+ { 60 , 0 , 0 , 28 , 1 },
+ { 61 , 0 , 0 , 28 , -1 },
+ { 62 , 0 , 0 , 27 , 1 },
+ { 63 , 0 , 0 , 27 , -1 },
+ {(int32u)-1, (int8u)-1, 1, -1, -1} //
+};
+
+const File__Analyze::vlc Mpegv_macroblock_type_I[]=
+{
+ { 1, 1, 0, 0, 0x02},
+ { 1, 1, 0, 0, 0x22},
+ VLC_END
+};
+
+const File__Analyze::vlc Mpegv_macroblock_type_P[]=
+{
+ { 1, 1, 0, 0, 0x14},
+ { 1, 1, 0, 0, 0x04},
+ { 1, 1, 0, 0, 0x10},
+ { 3, 2, 0, 0, 0x02},
+ { 2, 0, 0, 0, 0x34},
+ { 1, 0, 0, 0, 0x24},
+ { 1, 1, 0, 0, 0x22},
+ {(int32u)-1,(int8u)-1, 0, 0, 0}
+};
+
+const File__Analyze::vlc Mpegv_macroblock_type_B[]=
+{
+ { 2 , 2 , 0 , 0 , 0x18 },
+ { 3 , 0 , 0 , 0 , 0x1C },
+ { 2 , 1 , 0 , 0 , 0x08 },
+ { 3 , 0 , 0 , 0 , 0x0C },
+ { 2 , 1 , 0 , 0 , 0x10 },
+ { 3 , 0 , 0 , 0 , 0x14 },
+ { 3 , 1 , 0 , 0 , 0x02 },
+ { 2 , 0 , 0 , 0 , 0x3C },
+ { 3 , 1 , 0 , 0 , 0x34 },
+ { 2 , 0 , 0 , 0 , 0x2C },
+ { 1 , 0 , 0 , 0 , 0x22 },
+ VLC_END
+};
+
+const File__Analyze::vlc Mpegv_motion_code[]=
+{
+ { 1 , 1 , 0 , 0 , 0 },
+ { 1 , 1 , 0 , 0 , 1 },
+ { 1 , 1 , 0 , 0 , 2 },
+ { 1 , 1 , 0 , 0 , 3 },
+ { 3 , 2 , 0 , 0 , 4 },
+ { 5 , 1 , 0 , 0 , 5 },
+ { 4 , 0 , 0 , 0 , 6 },
+ { 3 , 0 , 0 , 0 , 7 },
+ { 11 , 2 , 0 , 0 , 8 },
+ { 10 , 0 , 0 , 0 , 9 },
+ { 9 , 0 , 0 , 0 , 10 },
+ { 17 , 1 , 0 , 0 , 11 },
+ { 16 , 0 , 0 , 0 , 12 },
+ { 15 , 0 , 0 , 0 , 13 },
+ { 14 , 0 , 0 , 0 , 14 },
+ { 13 , 0 , 0 , 0 , 15 },
+ { 12 , 0 , 0 , 0 , 16 },
+
+ VLC_END
+};
+
+const File__Analyze::vlc Mpegv_dmvector[]=
+{
+ { 0 , 1 , 0 , 0 , 0 },
+ { 2 , 1 , 0 , 0 , 1 },
+ { 3 , 0 , 0 , 0 , -1 },
+ VLC_END
+};
+
+const File__Analyze::vlc Mpegv_coded_block_pattern[]=
+{
+ // cbp
+ { 7 , 3 , 0 , 0 , 60 },
+ { 13 , 1 , 0 , 0 , 4 },
+ { 12 , 0 , 0 , 0 , 8 },
+ { 11 , 0 , 0 , 0 , 16 },
+ { 10 , 0 , 0 , 0 , 32 },
+ { 19 , 1 , 0 , 0 , 12 },
+ { 18 , 0 , 0 , 0 , 48 },
+ { 17 , 0 , 0 , 0 , 20 },
+ { 16 , 0 , 0 , 0 , 40 },
+ { 15 , 0 , 0 , 0 , 28 },
+ { 14 , 0 , 0 , 0 , 44 },
+ { 13 , 0 , 0 , 0 , 52 },
+ { 12 , 0 , 0 , 0 , 56 },
+ { 11 , 0 , 0 , 0 , 1 },
+ { 10 , 0 , 0 , 0 , 61 },
+ { 9 , 0 , 0 , 0 , 2 },
+ { 8 , 0 , 0 , 0 , 62 },
+ { 15 , 1 , 0 , 0 , 24 },
+ { 14 , 0 , 0 , 0 , 36 },
+ { 13 , 0 , 0 , 0 , 3 },
+ { 12 , 0 , 0 , 0 , 63 },
+ { 23 , 1 , 0 , 0 , 5 },
+ { 22 , 0 , 0 , 0 , 9 },
+ { 21 , 0 , 0 , 0 , 17 },
+ { 20 , 0 , 0 , 0 , 33 },
+ { 19 , 0 , 0 , 0 , 6 },
+ { 18 , 0 , 0 , 0 , 10 },
+ { 17 , 0 , 0 , 0 , 18 },
+ { 16 , 0 , 0 , 0 , 34 },
+ { 31 , 1 , 0 , 0 , 7 },
+ { 30 , 0 , 0 , 0 , 11 },
+ { 29 , 0 , 0 , 0 , 19 },
+ { 28 , 0 , 0 , 0 , 35 },
+ { 27 , 0 , 0 , 0 , 13 },
+ { 26 , 0 , 0 , 0 , 49 },
+ { 25 , 0 , 0 , 0 , 21 },
+ { 24 , 0 , 0 , 0 , 41 },
+ { 23 , 0 , 0 , 0 , 14 },
+ { 22 , 0 , 0 , 0 , 50 },
+ { 21 , 0 , 0 , 0 , 22 },
+ { 20 , 0 , 0 , 0 , 42 },
+ { 19 , 0 , 0 , 0 , 15 },
+ { 18 , 0 , 0 , 0 , 51 },
+ { 17 , 0 , 0 , 0 , 23 },
+ { 16 , 0 , 0 , 0 , 43 },
+ { 15 , 0 , 0 , 0 , 25 },
+ { 14 , 0 , 0 , 0 , 37 },
+ { 13 , 0 , 0 , 0 , 26 },
+ { 12 , 0 , 0 , 0 , 38 },
+ { 11 , 0 , 0 , 0 , 29 },
+ { 10 , 0 , 0 , 0 , 45 },
+ { 9 , 0 , 0 , 0 , 53 },
+ { 8 , 0 , 0 , 0 , 57 },
+ { 7 , 0 , 0 , 0 , 30 },
+ { 6 , 0 , 0 , 0 , 46 },
+ { 5 , 0 , 0 , 0 , 54 },
+ { 4 , 0 , 0 , 0 , 58 },
+ { 7 , 1 , 0 , 0 , 31 },
+ { 6 , 0 , 0 , 0 , 47 },
+ { 5 , 0 , 0 , 0 , 55 },
+ { 4 , 0 , 0 , 0 , 59 },
+ { 3 , 0 , 0 , 0 , 27 },
+ { 2 , 0 , 0 , 0 , 39 },
+ { 1 , 0 , 0 , 0 , 0 },
+ VLC_END
+};
+
+#endif //MEDIAINFO_MACROBLOCKS
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Mpegv::File_Mpegv()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("MPEG Video");
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Mpegv;
+ StreamIDs_Width[0]=16;
+ #endif //MEDIAINFO_EVENTS
+ #if MEDIAINFO_TRACE
+ Trace_Layers_Update(8); //Stream
+ #endif //MEDIAINFO_TRACE
+ Trusted_Multiplier=2;
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+ PTS_DTS_Needed=true;
+ IsRawStream=true;
+ Frame_Count_NotParsedIncluded=0;
+
+ //In
+ MPEG_Version=1;
+ Frame_Count_Valid=Config_ParseSpeed>=0.3?40:2;
+ FrameIsAlwaysComplete=false;
+ TimeCodeIsNotTrustable=false;
+ #if defined(MEDIAINFO_ANCILLARY_YES)
+ Ancillary=NULL;
+ #endif //defined(MEDIAINFO_ANCILLARY_YES)
+
+ //temporal_reference
+ TemporalReference_Offset=0;
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ GA94_03_Parser=NULL;
+ GA94_03_TemporalReference_Offset=0;
+ GA94_03_IsPresent=false;
+ Text_Positions.push_back(text_position(GA94_03_Parser));
+ CC___Parser=NULL;
+ CC___IsPresent=false;
+ Text_Positions.push_back(text_position(CC___Parser));
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ #if defined(MEDIAINFO_SCTE20_YES)
+ Scte_Parser=NULL;
+ Scte_TemporalReference_Offset=0;
+ Scte_IsPresent=false;
+ Text_Positions.push_back(text_position(Scte_Parser));
+ #endif //defined(MEDIAINFO_SCTE20_YES)
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ DTG1_Parser=NULL;
+ GA94_06_Parser=NULL;
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+ #if defined(MEDIAINFO_CDP_YES)
+ Cdp_Parser=NULL;
+ Cdp_IsPresent=false;
+ Text_Positions.push_back(text_position(Cdp_Parser));
+ #endif //defined(MEDIAINFO_CDP_YES)
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ AfdBarData_Parser=NULL;
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+
+ //Temp
+ SizeToAnalyse_Begin=1*1024*1024;
+ SizeToAnalyse_End=1*1024*1024;
+ Searching_TimeStamp_Start_DoneOneTime=false;
+ sequence_header_IsParsed=false;
+ FrameInfo.DTS=0;
+ Parsing_End_ForDTS=false;
+
+ //Macroblocks
+ #if MEDIAINFO_MACROBLOCKS
+ Macroblocks_Parse=false;
+ #endif //MEDIAINFO_MACROBLOCKS
+}
+
+//---------------------------------------------------------------------------
+File_Mpegv::~File_Mpegv()
+{
+ for (size_t Pos=0; Pos<TemporalReference.size(); Pos++)
+ delete TemporalReference[Pos]; //TemporalReference[Pos]=NULL;
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ delete GA94_03_Parser; //GA94_03_Parser=NULL;
+ delete CC___Parser; //CC___Parser=NULL;
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ #if defined(MEDIAINFO_SCTE20_YES)
+ delete Scte_Parser; //Scte_Parser=NULL;
+ #endif //defined(MEDIAINFO_SCTE20_YES)
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ delete DTG1_Parser; //DTG1_Parser=NULL;
+ delete GA94_06_Parser; //GA94_06_Parser=NULL;
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+
+ //Macroblocks
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse)
+ {
+ delete[] macroblock_address_increment_Vlc.Array; //macroblock_address_increment_Vlc.Array=NULL;
+ delete[] macroblock_address_increment_Vlc.BitsToSkip; //macroblock_address_increment_Vlc.Size=NULL;
+ delete[] dct_dc_size_luminance.Array; //dct_dc_size_luminance.Array=NULL;
+ delete[] dct_dc_size_luminance.BitsToSkip; //dct_dc_size_luminance.Size=NULL;
+ delete[] dct_dc_size_chrominance.Array; //dct_dc_size_chrominance.Array=NULL;
+ delete[] dct_dc_size_chrominance.BitsToSkip; //dct_dc_size_chrominance.Size=NULL;
+ delete[] dct_coefficients_0.Array; //dct_coefficients_0.Array=NULL;
+ delete[] dct_coefficients_0.BitsToSkip; //dct_coefficients_0.Size=NULL;
+ delete[] dct_coefficients_1.Array; //dct_coefficients_1.Array=NULL;
+ delete[] dct_coefficients_1.BitsToSkip; //dct_coefficients_1.Size=NULL;
+ }
+ #endif //MEDIAINFO_MACROBLOCKS
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpegv::Streams_Accept()
+{
+ Stream_Prepare(Stream_Video);
+}
+
+//---------------------------------------------------------------------------
+void File_Mpegv::Streams_Update()
+{
+ for (size_t Text_Positions_Pos=0; Text_Positions_Pos<Text_Positions.size(); Text_Positions_Pos++)
+ {
+ if (*Text_Positions[Text_Positions_Pos].Parser && (*Text_Positions[Text_Positions_Pos].Parser)->Status[IsUpdated])
+ {
+ Update(*Text_Positions[Text_Positions_Pos].Parser);
+ for (size_t Pos=0; Pos<(*Text_Positions[Text_Positions_Pos].Parser)->Count_Get(Stream_Text); Pos++)
+ {
+ bool IsNewStream=false;
+ if (Retrieve(Stream_Text, Text_Positions[Text_Positions_Pos].StreamPos+Pos, Text_ID)!=(*Text_Positions[Text_Positions_Pos].Parser)->Get(Stream_Text, Pos, Text_ID))
+ {
+ Stream_Prepare(Stream_Text, Text_Positions[Text_Positions_Pos].StreamPos+Pos);
+ for (size_t Text_Positions_Pos2=Text_Positions_Pos+1; Text_Positions_Pos2<Text_Positions.size(); Text_Positions_Pos2++)
+ Text_Positions[Text_Positions_Pos2].StreamPos++;
+ IsNewStream=true;
+ }
+ Merge(*(*Text_Positions[Text_Positions_Pos].Parser), Stream_Text, Pos, Text_Positions[Text_Positions_Pos].StreamPos+Pos);
+
+ if (IsNewStream)
+ {
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ if ((*Text_Positions[Text_Positions_Pos].Parser)==GA94_03_Parser)
+ {
+ Ztring MuxingMode=Retrieve(Stream_Text, Text_Positions[Text_Positions_Pos].StreamPos+Pos, "MuxingMode");
+ Fill(Stream_Text, Text_Positions[Text_Positions_Pos].StreamPos+Pos, "MuxingMode", _T("A/53 / ")+MuxingMode, true);
+ }
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ #if defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_CDP_YES)
+ if ((*Text_Positions[Text_Positions_Pos].Parser)==Cdp_Parser)
+ {
+ Ztring MuxingMode=Retrieve(Stream_Text, Text_Positions[Text_Positions_Pos].StreamPos+Pos, "MuxingMode");
+ Fill(Stream_Text, Text_Positions[Text_Positions_Pos].StreamPos+Pos, "MuxingMode", _T("Ancillary data / ")+MuxingMode, true);
+ }
+ #endif //defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_CDP_YES)
+ }
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpegv::Streams_Fill()
+{
+ //Version
+ if (MPEG_Version==2)
+ {
+ Fill(Stream_General, 0, General_Format_Version, "Version 2");
+ Fill(Stream_Video, 0, Video_Format, "MPEG Video");
+ Fill(Stream_Video, 0, Video_Format_Version, "Version 2");
+ Fill(Stream_Video, 0, Video_Format_Commercial, "MPEG-2 Video");
+ Fill(Stream_Video, 0, Video_Codec, "MPEG-2V");
+ Fill(Stream_Video, 0, Video_Codec_String, "MPEG-2 Video", Unlimited, true, true);
+ }
+ else
+ {
+ Fill(Stream_General, 0, General_Format_Version, "Version 1");
+ Fill(Stream_Video, 0, Video_Format, "MPEG Video");
+ Fill(Stream_Video, 0, Video_Format_Version, "Version 1");
+ Fill(Stream_Video, 0, Video_Format_Commercial, "MPEG-1 Video");
+ Fill(Stream_Video, 0, Video_Codec, "MPEG-1V");
+ Fill(Stream_Video, 0, Video_Codec_String, "MPEG-1 Video", Unlimited, true, true);
+ }
+
+ Fill(Stream_Video, 0, Video_Width, 0x1000*horizontal_size_extension+horizontal_size_value);
+ Fill(Stream_Video, 0, Video_Height, 0x1000*vertical_size_extension+vertical_size_value);
+ Fill(Stream_Video, 0, Video_Colorimetry, Mpegv_Colorimetry_format[chroma_format]);
+ Fill(Stream_Video, 0, Video_ColorSpace, "YUV");
+ Fill(Stream_Video, 0, Video_BitDepth, 8);
+
+ //AspectRatio
+ if (MPEG_Version==2)
+ {
+ if (aspect_ratio_information==0)
+ ;//Forbidden
+ else if (aspect_ratio_information==1)
+ Fill(Stream_Video, 0, Video_PixelAspectRatio, 1.000, 3, true);
+ else if (display_horizontal_size && display_vertical_size)
+ {
+ if (vertical_size_value && Mpegv_aspect_ratio2[aspect_ratio_information])
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, (float)(0x1000*horizontal_size_extension+horizontal_size_value)/(0x1000*vertical_size_extension+vertical_size_value)
+ *Mpegv_aspect_ratio2[aspect_ratio_information]/((float)display_horizontal_size/display_vertical_size), 3, true);
+ }
+ else if (Mpegv_aspect_ratio2[aspect_ratio_information])
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, Mpegv_aspect_ratio2[aspect_ratio_information], 3, true);
+ }
+ else //Version 1
+ {
+ if (vertical_size_value && Mpegv_aspect_ratio1[aspect_ratio_information])
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, (float)(0x1000*horizontal_size_extension+horizontal_size_value)/(0x1000*vertical_size_extension+vertical_size_value)/Mpegv_aspect_ratio1[aspect_ratio_information], 3, true);
+ }
+
+ //FrameRate
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, (float)(Mpegv_frame_rate[frame_rate_code] * (frame_rate_extension_n + 1)) / (float)(frame_rate_extension_d + 1));
+
+ //BitRate
+ if (vbv_delay==0xFFFF || (MPEG_Version==1 && bit_rate_value==0x3FFFF))
+ Fill(Stream_Video, 0, Video_BitRate_Mode, "VBR");
+ if (bit_rate_value_IsValid && (bit_rate_extension>0 || bit_rate_value!=0x3FFFF))
+ Fill(Stream_Video, 0, Video_BitRate_Maximum, ((((int32u)bit_rate_extension<<12))+bit_rate_value)*400);
+
+ //Interlacement
+ if (MPEG_Version==1)
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Progressive");
+ Fill(Stream_Video, 0, Video_Interlacement, "PPF");
+ }
+ else if (progressive_frame_Count && progressive_frame_Count!=Frame_Count)
+ {
+ //This is mixed
+ }
+ else if (Frame_Count>0) //Only if we have at least one progressive_frame definition
+ {
+ if (progressive_sequence || progressive_frame_Count==Frame_Count)
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Progressive");
+ Fill(Stream_Video, 0, Video_Interlacement, "PPF");
+ if (!progressive_sequence && !(Interlaced_Top && Interlaced_Bottom) && !(!Interlaced_Top && !Interlaced_Bottom))
+ Fill(Stream_Video, 0, Video_ScanOrder, Interlaced_Top?"TFF":"BFF");
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Interlaced");
+ if ((Interlaced_Top && Interlaced_Bottom) || (!Interlaced_Top && !Interlaced_Bottom))
+ Fill(Stream_Video, 0, Video_Interlacement, "Interlaced");
+ else
+ {
+ Fill(Stream_Video, 0, Video_ScanOrder, Interlaced_Top?"TFF":"BFF");
+ Fill(Stream_Video, 0, Video_Interlacement, Interlaced_Top?"TFF":"BFF");
+ }
+ }
+ std::string TempRef, CodingType;
+ for (size_t Pos=0; Pos<TemporalReference.size(); Pos++)
+ if (TemporalReference[Pos] && TemporalReference[Pos]->HasPictureCoding)
+ {
+ TempRef+=TemporalReference[Pos]->top_field_first?"T":"B";
+ TempRef+=TemporalReference[Pos]->repeat_first_field?"3":"2";
+ CodingType+=Mpegv_picture_coding_type[TemporalReference[Pos]->picture_coding_type];
+ }
+ if (TempRef.find('3')!=std::string::npos)
+ {
+ if (TempRef.find("T2T3B2B3T2T3B2B3")!=std::string::npos
+ || TempRef.find("B2B3T2T3B2B3T2T3")!=std::string::npos)
+ {
+ Fill(Stream_Video, 0, Video_ScanOrder, "2:3 Pulldown", Unlimited, true, true);
+ Fill(Stream_Video, 0, Video_FrameRate, FrameRate*24/30, 3, true); //Real framerate
+ Fill(Stream_Video, 0, Video_ScanType, "Progressive", Unlimited, true, true);
+ Fill(Stream_Video, 0, Video_Interlacement, "PPF", Unlimited, true, true);
+ }
+ if (TempRef.find("T2T2T2T2T2T2T2T2T2T2T2T3B2B2B2B2B2B2B2B2B2B2B2B3")!=std::string::npos
+ || TempRef.find("B2B2B2B2B2B2B2B2B2B2B2B3T2T2T2T2T2T2T2T2T2T2T2T3")!=std::string::npos)
+ {
+ Fill(Stream_Video, 0, Video_ScanOrder, "2:2:2:2:2:2:2:2:2:2:2:3 Pulldown", Unlimited, true, true);
+ Fill(Stream_Video, 0, Video_FrameRate, FrameRate*24/25, 3, true); //Real framerate
+ Fill(Stream_Video, 0, Video_ScanType, "Progressive", Unlimited, true, true);
+ Fill(Stream_Video, 0, Video_Interlacement, "PPF", Unlimited, true, true);
+ }
+ }
+
+ //GOP
+ std::vector<Ztring> GOPs;
+ size_t GOP_Frame_Count=0;
+ size_t GOP_BFrames_Max=0;
+ size_t I_Pos1=CodingType.find(_T('I'));
+ while (I_Pos1!=std::string::npos)
+ {
+ size_t I_Pos2=CodingType.find(_T('I'), I_Pos1+1);
+ if (I_Pos2!=std::string::npos)
+ {
+ std::vector<size_t> P_Positions;
+ size_t P_Position=I_Pos1;
+ do
+ {
+ P_Position=CodingType.find(_T('P'), P_Position+1);
+ if (P_Position<I_Pos2)
+ P_Positions.push_back(P_Position);
+ }
+ while (P_Position<I_Pos2);
+ Ztring GOP;
+ if (!P_Positions.empty())
+ {
+ GOP+=_T("M=")+Ztring::ToZtring(P_Positions[0]-I_Pos1)+_T(", ");
+ if (P_Positions[0]-I_Pos1>GOP_BFrames_Max)
+ GOP_BFrames_Max=P_Positions[0]-I_Pos1;
+ }
+ GOP+=_T("N=")+Ztring::ToZtring(I_Pos2-I_Pos1);
+ GOPs.push_back(GOP);
+ GOP_Frame_Count+=I_Pos2-I_Pos1;
+ }
+ I_Pos1=I_Pos2;
+ }
+
+ if (GOP_Frame_Count+GOP_BFrames_Max>=Frame_Count && !GOPs.empty())
+ GOPs.resize(GOPs.size()-1); //Removing the last one, there may have uncomplete B-frame filling
+
+ if (!GOPs.empty())
+ {
+ size_t Unique=0;
+ for (size_t Pos=1; Pos<GOPs.size(); Pos++)
+ if (GOPs[Pos]!=GOPs[0])
+ Unique++;
+ if ((Frame_Count<Frame_Count_Valid*10 && Unique) || Unique>2) //In order to accept some unsynch //TODO: change the method, synching with next I-Frame
+ GOPs.clear(); //Not a fixed GOP
+ }
+ else if (TemporalReference.size()==1 && CodingType=="I" && Frame_Count>1)
+ GOPs.push_back(_T("N=1"));
+ if (!GOPs.empty())
+ Fill(Stream_Video, 0, Video_Format_Settings_GOP, GOPs[0]);
+ }
+
+ //Profile
+ if (!profile_and_level_indication_escape && profile_and_level_indication_profile!=(int8u)-1 && profile_and_level_indication_level!=(int8u)-1)
+ {
+ Fill(Stream_Video, 0, Video_Format_Profile, Ztring().From_Local(Mpegv_profile_and_level_indication_profile[profile_and_level_indication_profile])+_T("@")+Ztring().From_Local(Mpegv_profile_and_level_indication_level[profile_and_level_indication_level]));
+ Fill(Stream_Video, 0, Video_Codec_Profile, Ztring().From_Local(Mpegv_profile_and_level_indication_profile[profile_and_level_indication_profile])+_T("@")+Ztring().From_Local(Mpegv_profile_and_level_indication_level[profile_and_level_indication_level]));
+ }
+ else if (profile_and_level_indication_escape)
+ {
+ Fill(Stream_Video, 0, Video_Format_Profile, Ztring().From_Local(Mpegv_profile_and_level_indication(profile_and_level_indication)));
+ Fill(Stream_Video, 0, Video_Codec_Profile, Ztring().From_Local(Mpegv_profile_and_level_indication(profile_and_level_indication)));
+ }
+
+ //Standard
+ Fill(Stream_Video, 0, Video_Standard, Mpegv_video_format[video_format]);
+ Fill(Stream_Video, 0, "colour_primaries", Mpegv_colour_primaries(colour_primaries));
+ Fill(Stream_Video, 0, "transfer_characteristics", Mpegv_transfer_characteristics(transfer_characteristics));
+ Fill(Stream_Video, 0, "matrix_coefficients", Mpegv_matrix_coefficients(matrix_coefficients));
+
+ //Matrix
+ if (load_intra_quantiser_matrix || load_non_intra_quantiser_matrix)
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings, "CustomMatrix");
+ Fill(Stream_Video, 0, Video_Format_Settings_Matrix, "Custom");
+ Fill(Stream_Video, 0, Video_Format_Settings_Matrix_Data, Matrix_intra);
+ Fill(Stream_Video, 0, Video_Format_Settings_Matrix_Data, Matrix_nonintra);
+ Fill(Stream_Video, 0, Video_Codec_Settings, "CustomMatrix");
+ Fill(Stream_Video, 0, Video_Codec_Settings_Matrix, "Custom");
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings_Matrix, "Default");
+ Fill(Stream_Video, 0, Video_Codec_Settings_Matrix, "Default");
+ }
+
+ //library
+ if (Library.size()>=8)
+ {
+ Fill(Stream_Video, 0, Video_Encoded_Library, Library);
+ Fill(Stream_Video, 0, Video_Encoded_Library_Name, Library_Name);
+ Fill(Stream_Video, 0, Video_Encoded_Library_Version, Library_Version);
+ Fill(Stream_Video, 0, General_Encoded_Library, Library);
+ Fill(Stream_Video, 0, General_Encoded_Library_Name, Library_Name);
+ Fill(Stream_Video, 0, General_Encoded_Library_Version, Library_Version);
+ }
+
+ //Delay
+ if (group_start_FirstPass)
+ {
+ float64 Time_Begin=((float64)Time_Begin_Seconds)*1000;
+ if (FrameRate)
+ Time_Begin+=((float64)Time_Begin_Frames)*1000/FrameRate;
+ Fill(Stream_Video, 0, Video_Delay, Time_Begin, 0);
+ Fill(Stream_Video, 0, Video_Delay_Settings, Ztring(_T("drop_frame_flag="))+(group_start_drop_frame_flag?_T("1"):_T("0")));
+ Fill(Stream_Video, 0, Video_Delay_Settings, Ztring(_T("closed_gop="))+(group_start_closed_gop?_T("1"):_T("0")));
+ Fill(Stream_Video, 0, Video_Delay_Settings, Ztring(_T("broken_link="))+(group_start_broken_link?_T("1"):_T("0")));
+ Fill(Stream_Video, 0, Video_Delay_Source, "Stream");
+ }
+
+ //BVOP
+ if (BVOP_Count>0)
+ {
+ Fill(Stream_Video, 0, Video_Format_Settings, "BVOP");
+ Fill(Stream_Video, 0, Video_Format_Settings_BVOP, "Yes");
+ }
+ else
+ Fill(Stream_Video, 0, Video_Format_Settings_BVOP, "No");
+
+ //Buffer
+ Fill(Stream_Video, 0, Video_BufferSize, 2*1024*((((int32u)vbv_buffer_size_extension)<<10)+vbv_buffer_size_value));
+
+ //Autorisation of other streams
+ if (!Status[IsAccepted])
+ {
+ NextCode_Clear();
+ NextCode_Add(0x00);
+ NextCode_Add(0xB8);
+ }
+ #if MEDIAINFO_MACROBLOCKS
+ if (!Macroblocks_Parse)
+ #endif //MEDIAINFO_MACROBLOCKS
+ for (int8u Pos=0x01; Pos<=0xAF; Pos++)
+ Streams[Pos].Searching_Payload=false;
+ Streams[0xB8].Searching_TimeStamp_End=true;
+ if (IsSub)
+ Streams[0x00].Searching_TimeStamp_End=true;
+
+ //Caption may be in user_data, must be activated if full parsing is requested
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES) || defined(MEDIAINFO_SCTE20_YES) || (defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_CDP_YES))
+ Streams[0x00].Searching_Payload=GA94_03_IsPresent || Cdp_IsPresent;
+ Streams[0xB2].Searching_Payload=GA94_03_IsPresent || CC___IsPresent || Scte_IsPresent;
+ Streams[0xB3].Searching_Payload=GA94_03_IsPresent || Cdp_IsPresent;
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES) || defined(MEDIAINFO_SCTE20_YES) || (defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_CDP_YES))
+ if (Config_ParseSpeed>=1)
+ {
+ Streams[0x00].Searching_Payload=true;
+ Streams[0xB2].Searching_Payload=true;
+ Streams[0xB3].Searching_Payload=true;
+ Streams[0xB5].Searching_Payload=true;
+ }
+
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ if (DTG1_Parser)
+ Merge(*DTG1_Parser, Stream_Video, 0, 0);
+ if (GA94_06_Parser)
+ Merge(*GA94_06_Parser, Stream_Video, 0, 0);
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ if (AfdBarData_Parser)
+ Merge(*AfdBarData_Parser, Stream_Video, 0, 0);
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+
+ //extra
+ if (intra_dc_precision!=(int8u)-1)
+ {
+ Fill(Stream_Video, 0, "intra_dc_precision", 8+intra_dc_precision);
+ (*Stream_More)[Stream_Video][0](Ztring().From_Local("intra_dc_precision"), Info_Options)=_T("N NT");
+ }
+
+ //Commercial name
+ if (Retrieve(Stream_Video, 0, Video_Format_Version)==_T("Version 2")
+ && Retrieve(Stream_Video, 0, Video_DisplayAspectRatio)==_T("1.778")
+ && Retrieve(Stream_Video, 0, Video_BitDepth)==_T("8")
+ && Retrieve(Stream_Video, 0, Video_ChromaSubsampling)==_T("4:2:0"))
+ {
+ //HDV1
+ if (Retrieve(Stream_Video, 0, Video_Width)==_T("1280")
+ && Retrieve(Stream_Video, 0, Video_Height)==_T("720")
+ && Retrieve(Stream_Video, 0, Video_ScanType)==_T("Progressive")
+ && (Retrieve(Stream_Video, 0, Video_FrameRate)==_T("60.000") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("59.940") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("30.000") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("29.970") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("24.000") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("23.976") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("50.000") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("25.000"))
+ && (Retrieve(Stream_Video, 0, Video_Format_Profile)==_T("Main@High") || Retrieve(Stream_Video, 0, Video_Format_Profile)==_T("Main@High 1440"))
+ && Retrieve(Stream_Video, 0, Video_BitRate).To_int64u()<20000000 && Retrieve(Stream_Video, 0, Video_BitRate_Maximum).To_int64u()<20000000)
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "HDV 720p");
+
+ //HDV2
+ if (Retrieve(Stream_Video, 0, Video_Width)==_T("1440")
+ && Retrieve(Stream_Video, 0, Video_Height)==_T("1080")
+ && Retrieve(Stream_Video, 0, Video_Format_Profile)==_T("Main@High 1440")
+ && Retrieve(Stream_Video, 0, Video_BitRate).To_int64u()<27000000 && Retrieve(Stream_Video, 0, Video_BitRate_Maximum).To_int64u()<27000000)
+ {
+ //Interlaced
+ if (Retrieve(Stream_Video, 0, Video_ScanType)==_T("Interlaced")
+ && (Retrieve(Stream_Video, 0, Video_FrameRate)==_T("30.000") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("29.970") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("50.000") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("25.000")))
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "HDV 1080i");
+
+ //Progressive
+ if (Retrieve(Stream_Video, 0, Video_ScanType)==_T("Progressive")
+ && (Retrieve(Stream_Video, 0, Video_FrameRate)==_T("30.000") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("29.970") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("24.000") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("23.976") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("50.000") || Retrieve(Stream_Video, 0, Video_FrameRate)==_T("25.000")))
+ Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "HDV 1080p");
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+void File_Mpegv::Streams_Finish()
+{
+ //Duration
+ if (PTS_End>PTS_Begin)
+ Fill(Stream_Video, 0, Video_Duration, float64_int64s(((float64)(PTS_End-PTS_Begin))/1000000));
+ else if (Time_End_Seconds!=Error)
+ {
+ float32 Time_Begin=((float32)Time_Begin_Seconds)*1000;
+ float32 Time_End =((float32)Time_End_Seconds)*1000;
+ if (FrameRate)
+ {
+ float32 FrameRate_Corrected=FrameRate;
+ if (FrameRate>=29.970 && FrameRate<=29.971 && !group_start_drop_frame_flag)
+ FrameRate_Corrected=30;
+ Time_Begin+=Time_Begin_Frames*1000/FrameRate_Corrected;
+ Time_End +=Time_End_Frames *1000/FrameRate_Corrected;
+ }
+ float32 Duration=Time_End-Time_Begin;
+ if (FrameRate>=29.970 && FrameRate<=29.971 && !group_start_drop_frame_flag)
+ {
+ Duration*=1001;
+ Duration/=1000;
+ }
+ Fill(Stream_Video, 0, Video_Duration, Duration, 0);
+ }
+ else if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ {
+ Fill(Stream_Video, 0, Video_FrameCount, Frame_Count_NotParsedIncluded);
+ }
+
+ //Other parsers
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ if (GA94_03_Parser && !GA94_03_Parser->Status[IsFinished] && GA94_03_Parser->Status[IsAccepted])
+ Finish(GA94_03_Parser);
+ if (CC___Parser && !CC___Parser->Status[IsFinished] && CC___Parser->Status[IsAccepted])
+ Finish(CC___Parser);
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ #if defined(MEDIAINFO_SCTE20_YES)
+ if (Scte_Parser && !Scte_Parser->Status[IsFinished] && Scte_Parser->Status[IsAccepted])
+ Finish(Scte_Parser);
+ #endif //defined(MEDIAINFO_SCTE20_YES)
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ if (DTG1_Parser && !DTG1_Parser->Status[IsFinished] && DTG1_Parser->Status[IsAccepted])
+ {
+ Finish(DTG1_Parser);
+ Merge(*DTG1_Parser, Stream_Video, 0, 0);
+ }
+ if (GA94_06_Parser && !GA94_06_Parser->Status[IsFinished] && GA94_06_Parser->Status[IsAccepted])
+ {
+ Finish(GA94_06_Parser);
+ Merge(*GA94_06_Parser, Stream_Video, 0, 0);
+ }
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+ #if defined(MEDIAINFO_CDP_YES)
+ if (Cdp_Parser && !Cdp_Parser->Status[IsFinished] && Cdp_Parser->Status[IsAccepted])
+ Finish(Cdp_Parser);
+ #endif //defined(MEDIAINFO_CDP_YES)
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ if (AfdBarData_Parser && !AfdBarData_Parser->Status[IsFinished] && AfdBarData_Parser->Status[IsAccepted])
+ {
+ Finish(AfdBarData_Parser);
+ Merge(*AfdBarData_Parser, Stream_Video, 0, 0);
+ }
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+
+ #if MEDIAINFO_IBI
+ int64u Numerator=0, Denominator=0;
+ switch (frame_rate_code)
+ {
+ case 1 : Numerator=24000; Denominator=1001; break;
+ case 2 : Numerator=24; Denominator=1; break;
+ case 3 : Numerator=25; Denominator=1; break;
+ case 4 : Numerator=30000; Denominator=1001; break;
+ case 5 : Numerator=30; Denominator=1; break;
+ case 6 : Numerator=50; Denominator=1; break;
+ case 7 : Numerator=60000; Denominator=1001; break;
+ case 8 : Numerator=60; Denominator=1; break;
+ default: ;
+ }
+ if (Numerator)
+ {
+ Numerator*=frame_rate_extension_n+1;
+ Denominator*=frame_rate_extension_d+1;
+ Ibi_Stream_Finish(Numerator, Denominator);
+ }
+ #endif //MEDIAINFO_IBI
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Mpegv::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x01)
+ {
+ Synched=false;
+ return true;
+ }
+
+ //Quick search
+ if (Synched && !Header_Parser_QuickSearch())
+ return false;
+
+ #if MEDIAINFO_IBI
+ if (Ibi_SliceParsed)
+ {
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ if (Buffer[Buffer_Offset+3]==0x00 && Buffer_Offset+5>Buffer_Size)
+ return false;
+ bool RandomAccess=(Buffer[Buffer_Offset+3]==0x00 && (Buffer[Buffer_Offset+5]&0x38)==0x08) || Buffer[Buffer_Offset+3]==0xB3; //picture_start with I-Frame || sequence_header
+ if (RandomAccess)
+ Ibi_Add();
+ Ibi_SliceParsed=false;
+ }
+ #endif //MEDIAINFO_IBI
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Mpegv::Synched_Init()
+{
+ //Temp
+ BVOP_Count=0;
+ progressive_frame_Count=0;
+ Interlaced_Top=0;
+ Interlaced_Bottom=0;
+ display_horizontal_size=0;
+ display_vertical_size=0;
+ vbv_delay=0;
+ vbv_buffer_size_value=0;
+ Time_Current_Seconds=Error;
+ Time_Current_Frames=(int8u)-1;
+ Time_Begin_Seconds=Error;
+ Time_Begin_Frames=(int8u)-1;
+ Time_End_Seconds=Error;
+ Time_End_Frames=(int8u)-1;
+ picture_coding_type=(int8u)-1;
+ bit_rate_value=0;
+ FrameRate=0;
+ horizontal_size_value=0;
+ vertical_size_value=0;
+ bit_rate_extension=0;
+ temporal_reference_Old=(int16u)-1;
+ aspect_ratio_information=0;
+ frame_rate_code=0;
+ profile_and_level_indication_profile=(int8u)-1;
+ profile_and_level_indication_level=(int8u)-1;
+ chroma_format=0;
+ horizontal_size_extension=0;
+ vertical_size_extension=0;
+ frame_rate_extension_n=0;
+ frame_rate_extension_d=0;
+ video_format=5; //Unspecified video format
+ colour_primaries=(int8u)-1;
+ transfer_characteristics=(int8u)-1;
+ matrix_coefficients=(int8u)-1;
+ vbv_buffer_size_extension=0;
+ intra_dc_precision=(int8u)-1;
+ load_intra_quantiser_matrix=false;
+ load_non_intra_quantiser_matrix=false;
+ progressive_sequence=true; //progressive by default
+ top_field_first=false;
+ repeat_first_field=false;
+ FirstFieldFound=false;
+ group_start_IsParsed=false;
+ group_start_FirstPass=false;
+ PTS_LastIFrame=(int64u)-1;
+ bit_rate_value_IsValid=false;
+ profile_and_level_indication_escape=false;
+ RefFramesCount=0;
+ BVOPsSinceLastRefFrames=0;
+ temporal_reference_LastIFrame=0;
+ tc=0;
+ IFrame_IsParsed=false;
+ #if MEDIAINFO_IBI
+ Ibi_SliceParsed=true;
+ #endif //MEDIAINFO_IBI
+
+ //Default stream values
+ Streams.resize(0x100);
+ Streams[0xB3].Searching_Payload=true;
+ for (int8u Pos=0xFF; Pos>=0xB9; Pos--)
+ Streams[Pos].Searching_Payload=true; //Testing MPEG-PS
+
+ //Macroblocks
+ #if MEDIAINFO_MACROBLOCKS
+ Macroblocks_Parse=Config->File_Macroblocks_Parse_Get();
+ if (Macroblocks_Parse)
+ {
+ macroblock_address_increment_Vlc.Array=NULL;
+ macroblock_address_increment_Vlc.Vlc=Mpegv_macroblock_address_increment;
+ macroblock_address_increment_Vlc.Size=11;
+ Get_VL_Prepare(macroblock_address_increment_Vlc);
+ dct_dc_size_luminance.Array=NULL;
+ dct_dc_size_luminance.Vlc=Mpegv_dct_dc_size_luminance;
+ dct_dc_size_luminance.Size=9;
+ Get_VL_Prepare(dct_dc_size_luminance);
+ dct_dc_size_chrominance.Array=NULL;
+ dct_dc_size_chrominance.Vlc=Mpegv_dct_dc_size_chrominance;
+ dct_dc_size_chrominance.Size=10;
+ Get_VL_Prepare(dct_dc_size_chrominance);
+ dct_coefficients_0.Array=NULL;
+ dct_coefficients_0.Vlc=Mpegv_dct_coefficients_0;
+ dct_coefficients_0.Size=17;
+ Get_VL_Prepare(dct_coefficients_0);
+ dct_coefficients_1.Array=NULL;
+ dct_coefficients_1.Vlc=Mpegv_dct_coefficients_1;
+ dct_coefficients_1.Size=17;
+ Get_VL_Prepare(dct_coefficients_1);
+ macroblock_type_I.Array=NULL;
+ macroblock_type_I.Vlc=Mpegv_macroblock_type_I;
+ macroblock_type_I.Size=2;
+ Get_VL_Prepare(macroblock_type_I);
+ macroblock_type_P.Array=NULL;
+ macroblock_type_P.Vlc=Mpegv_macroblock_type_P;
+ macroblock_type_P.Size=6;
+ Get_VL_Prepare(macroblock_type_P);
+ macroblock_type_B.Array=NULL;
+ macroblock_type_B.Vlc=Mpegv_macroblock_type_B;
+ macroblock_type_B.Size=6;
+ Get_VL_Prepare(macroblock_type_B);
+ motion_code.Array=NULL;
+ motion_code.Vlc=Mpegv_motion_code;
+ motion_code.Size=11;
+ Get_VL_Prepare(motion_code);
+ dmvector.Array=NULL;
+ dmvector.Vlc=Mpegv_dmvector;
+ dmvector.Size=2;
+ Get_VL_Prepare(dmvector);
+ coded_block_pattern.Array=NULL;
+ coded_block_pattern.Vlc=Mpegv_coded_block_pattern;
+ coded_block_pattern.Size=9;
+ Get_VL_Prepare(coded_block_pattern);
+ }
+ #endif //MEDIAINFO_MACROBLOCKS
+}
+
+//***************************************************************************
+// Buffer - Demux
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+bool File_Mpegv::Demux_UnpacketizeContainer_Test()
+{
+ if ((Demux_IntermediateItemFound && Buffer[Buffer_Offset+3]==0x00) || Buffer[Buffer_Offset+3]==0xB3)
+ {
+ if (Demux_Offset==0)
+ {
+ Demux_Offset=Buffer_Offset;
+ Demux_IntermediateItemFound=false;
+ }
+ while (Demux_Offset+4<=Buffer_Size)
+ {
+ //Synchronizing
+ while(Demux_Offset+3<=Buffer_Size && (Buffer[Demux_Offset ]!=0x00
+ || Buffer[Demux_Offset+1]!=0x00
+ || Buffer[Demux_Offset+2]!=0x01))
+ {
+ Demux_Offset+=2;
+ while(Demux_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Demux_Offset+=2;
+ if (Demux_Offset>=Buffer_Size || Buffer[Demux_Offset-1]==0x00)
+ Demux_Offset--;
+ }
+
+ if (Demux_Offset+4<=Buffer_Size)
+ {
+ if (Demux_IntermediateItemFound)
+ {
+ bool MustBreak;
+ switch (Buffer[Demux_Offset+3])
+ {
+ case 0x00 :
+ case 0xB3 :
+ MustBreak=true; break;
+ default : MustBreak=false;
+ }
+ if (MustBreak)
+ break; //while() loop
+ }
+ else
+ {
+ if (!Buffer[Demux_Offset+3])
+ Demux_IntermediateItemFound=true;
+ }
+ }
+ Demux_Offset++;
+ }
+
+ if (Demux_Offset+4>Buffer_Size && File_Offset+Buffer_Size!=File_Size)
+ return false; //No complete frame
+
+ bool RandomAccess=Buffer[Buffer_Offset+3]==0xB3;
+ if (!Status[IsAccepted])
+ {
+ Accept("AVC");
+ if (Config->Demux_EventWasSent)
+ return false;
+ }
+ if (IFrame_IsParsed || RandomAccess)
+ Demux_UnpacketizeContainer_Demux(RandomAccess);
+ else
+ Demux_UnpacketizeContainer_Demux_Clear();
+ }
+
+ return true;
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpegv::Read_Buffer_Unsynched()
+{
+ for (int8u Pos=0x00; Pos<0xB9; Pos++)
+ {
+ Streams[Pos].Searching_Payload=false;
+ Streams[Pos].Searching_TimeStamp_Start=false;
+ Streams[Pos].Searching_TimeStamp_End=false;
+ }
+ Streams[0xB3].Searching_TimeStamp_End=true; //sequence_header
+ Streams[0xB8].Searching_TimeStamp_End=true; //group_start
+ Time_End_Seconds=Error;
+ Time_End_Frames=(int8u)-1;
+ RefFramesCount=0;
+ sequence_header_IsParsed=false;
+ group_start_IsParsed=false;
+ PTS_LastIFrame=(int64u)-1;
+ IFrame_IsParsed=false;
+ #if MEDIAINFO_IBI
+ Ibi_SliceParsed=true;
+ #endif //MEDIAINFO_IBI
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse)
+ {
+ macroblock_x_PerFrame=0;
+ macroblock_y_PerFrame=0;
+ }
+ #endif //MEDIAINFO_MACROBLOCKS
+
+ temporal_reference_Old=(int16u)-1;
+ for (size_t Pos=0; Pos<TemporalReference.size(); Pos++)
+ delete TemporalReference[Pos]; //TemporalReference[Pos]=NULL;
+ TemporalReference.clear();
+ TemporalReference_Offset=0;
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ GA94_03_TemporalReference_Offset=0;
+ if (GA94_03_Parser)
+ GA94_03_Parser->Open_Buffer_Unsynch();
+ if (CC___Parser)
+ CC___Parser->Open_Buffer_Unsynch();
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ #if defined(MEDIAINFO_SCTE20_YES)
+ Scte_TemporalReference_Offset=0;
+ if (Scte_Parser)
+ Scte_Parser->Open_Buffer_Unsynch();
+ #endif //defined(MEDIAINFO_SCTE20_YES)
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ if (DTG1_Parser)
+ DTG1_Parser->Open_Buffer_Unsynch();
+ if (GA94_06_Parser)
+ GA94_06_Parser->Open_Buffer_Unsynch();
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+ #if defined(MEDIAINFO_CDP_YES)
+ if (Cdp_Parser)
+ Cdp_Parser->Open_Buffer_Unsynch();
+ #endif //defined(MEDIAINFO_CDP_YES)
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ if (AfdBarData_Parser)
+ AfdBarData_Parser->Open_Buffer_Unsynch();
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+
+ #if defined(MEDIAINFO_ANCILLARY_YES)
+ if (Ancillary && *Ancillary && (*Ancillary)->Cdp_Data.empty())
+ (*Ancillary)->AspectRatio=0;
+ #endif //defined(MEDIAINFO_ANCILLARY_YES)
+
+ //NextCode
+ if (!Status[IsAccepted])
+ {
+ NextCode_Clear();
+ NextCode_Add(0xB3);
+ NextCode_Add(0xB8);
+ }
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpegv::Header_Parse()
+{
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ //Parsing
+ int8u start_code;
+ Skip_B3( "synchro");
+ Get_B1 (start_code, "start_code");
+ if (!Header_Parser_Fill_Size())
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ //Filling
+ Header_Fill_Code(start_code, Ztring().From_CC1(start_code));
+ }
+ else
+ {
+ #endif //MEDIAINFO_TRACE
+ //Parsing
+ int8u start_code=Buffer[Buffer_Offset+3];
+ Element_Offset+=4;
+ if (!Header_Parser_Fill_Size())
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ //Filling
+ Header_Fill_Code(start_code, Ztring().From_CC1(start_code));
+ #if MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_TRACE
+}
+
+//---------------------------------------------------------------------------
+bool File_Mpegv::Header_Parser_Fill_Size()
+{
+ //Look for next Sync word
+ if (Buffer_Offset_Temp==0) //Buffer_Offset_Temp is not 0 if Header_Parse_Fill_Size() has already parsed first frames
+ Buffer_Offset_Temp=Buffer_Offset+4;
+ while (Buffer_Offset_Temp+4<=Buffer_Size
+ && CC3(Buffer+Buffer_Offset_Temp)!=0x000001)
+ {
+ Buffer_Offset_Temp+=2;
+ while(Buffer_Offset_Temp<Buffer_Size && Buffer[Buffer_Offset_Temp]!=0x00)
+ Buffer_Offset_Temp+=2;
+ if (Buffer_Offset_Temp>=Buffer_Size || Buffer[Buffer_Offset_Temp-1]==0x00)
+ Buffer_Offset_Temp--;
+ }
+
+ //Must wait more data?
+ if (Buffer_Offset_Temp+4>Buffer_Size)
+ {
+ if (FrameIsAlwaysComplete || File_Offset+Buffer_Size==File_Size)
+ Buffer_Offset_Temp=Buffer_Size; //We are sure that the next bytes are a start
+ else
+ return false;
+ }
+
+ //OK, we continue
+ Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset);
+ Buffer_Offset_Temp=0;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Mpegv::Header_Parser_QuickSearch()
+{
+ while ( Buffer_Offset+4<=Buffer_Size
+ && Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x01)
+ {
+ //Getting start_code
+ int8u start_code=Buffer[Buffer_Offset+3];
+
+ //Searching start or timestamp
+ if (Streams[start_code].Searching_Payload
+ || Streams[start_code].Searching_TimeStamp_Start
+ || Streams[start_code].Searching_TimeStamp_End)
+ return true;
+
+ //Synchronizing
+ Buffer_Offset+=4;
+ Synched=false;
+ if (!Synchronize())
+ {
+ if (File_Offset+Buffer_Size==File_Size)
+ {
+ Synched=true;
+ return true;
+ }
+ return false;
+ }
+
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ }
+
+ Trusted_IsNot("MPEG Video, Synchronisation lost");
+ return Synchronize();
+}
+
+//---------------------------------------------------------------------------
+void File_Mpegv::Data_Parse()
+{
+ //Parsing
+ switch (Element_Code)
+ {
+ case 0x00: picture_start(); break;
+ case 0xB0: Skip_XX(Element_Size, "Unknown"); break;
+ case 0xB1: Skip_XX(Element_Size, "Unknown"); break;
+ case 0xB2: user_data_start(); break;
+ case 0xB3: sequence_header(); break;
+ case 0xB4: sequence_error(); break;
+ case 0xB5: extension_start(); break;
+ case 0xB6: Skip_XX(Element_Size, "Unknown"); break;
+ case 0xB7: sequence_end(); break;
+ case 0xB8: group_start(); break;
+ default:
+ if (Element_Code>=0x01
+ && Element_Code<=0xAF) slice_start();
+ else
+ Trusted_IsNot("Unattended element");
+ }
+}
+
+//***************************************************************************
+// EOF
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Mpegv::Detect_EOF()
+{
+ if ((IsSub && Status[IsFilled])
+ || (!IsSub && File_Size>SizeToAnalyse_Begin+SizeToAnalyse_End && File_Offset+Buffer_Offset+Element_Offset>SizeToAnalyse_Begin && File_Offset+Buffer_Offset+Element_Offset<File_Size-SizeToAnalyse_End && Config_ParseSpeed<=0.5))
+ {
+ if (MustExtendParsingDuration && Frame_Count<Frame_Count_Valid*10 //10 times the normal test
+ && !(!IsSub && File_Size>SizeToAnalyse_Begin*10+SizeToAnalyse_End*10 && File_Offset+Buffer_Offset+Element_Offset>SizeToAnalyse_Begin*10 && File_Offset+Buffer_Offset+Element_Offset<File_Size-SizeToAnalyse_End*10))
+ {
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES) || defined(MEDIAINFO_SCTE20_YES) || (defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_CDP_YES))
+ Streams[0x00].Searching_Payload=GA94_03_IsPresent || Cdp_IsPresent;
+ Streams[0xB2].Searching_Payload=GA94_03_IsPresent || CC___IsPresent || Scte_IsPresent;
+ Streams[0xB3].Searching_Payload=GA94_03_IsPresent || Cdp_IsPresent;
+ #endif defined(MEDIAINFO_DTVCCTRANSPORT_YES) || defined(MEDIAINFO_SCTE20_YES) || (defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_CDP_YES))
+ return;
+ }
+
+ //
+ Time_End_Seconds=Error;
+ Time_End_Frames=(int8u)-1;
+
+ //Autorisation of other streams
+ if (!IsSub)
+ Streams[0x00].Searching_TimeStamp_End=false;
+
+ //Jumping
+ if (!Status[IsFilled])
+ Fill("MPEG Video");
+
+ if (!IsSub)
+ Open_Buffer_Unsynch();
+ GoToFromEnd(SizeToAnalyse_End, "MPEG Video");
+ EOF_AlreadyDetected=true; //Sometimes called from Filling
+ }
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Packet "00"
+void File_Mpegv::picture_start()
+{
+ Element_Name("picture_start");
+
+ //Coherency
+ if (!Status[IsAccepted])
+ {
+ if (!NextCode_Test())
+ return;
+ }
+
+ //Parsing
+ int8u picture_coding_type_Old=picture_coding_type;
+ BS_Begin();
+ Get_S2 (10, temporal_reference, "temporal_reference");
+ Get_S1 ( 3, picture_coding_type, "picture_coding_type"); Param_Info1(Mpegv_picture_coding_type[picture_coding_type]);
+ Get_S2 (16, vbv_delay, "vbv_delay");
+ if (picture_coding_type==2 || picture_coding_type==3) //P or B
+ {
+ Skip_S1(1, "full_pel_forward_vector");
+ Skip_S1(3, "forward_f_code");
+ }
+ if (picture_coding_type==3) //B
+ {
+ Skip_S1(1, "full_pel_backward_vector");
+ Skip_S1(3, "backward_f_code");
+ }
+ bool extra_bit_picture;
+ do
+ {
+ Peek_SB(extra_bit_picture);
+ if (extra_bit_picture)
+ {
+ Skip_S1(1, "extra_bit_picture");
+ Skip_S1(8, "extra_information_picture");
+ }
+ }
+ while (extra_bit_picture);
+ BS_End();
+
+ FILLING_BEGIN();
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse)
+ {
+ macroblock_x_PerFrame=0;
+ macroblock_y_PerFrame=0;
+ }
+ #endif //MEDIAINFO_MACROBLOCKS
+
+ #if MEDIAINFO_EVENTS
+ {
+ struct MediaInfo_Event_Video_SliceInfo_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_Video_SliceInfo, 0);
+ Event.Stream_Offset=File_Offset+Buffer_Offset;
+ Event.PCR=FrameInfo.PCR;
+ Event.PTS=FrameInfo.PTS;
+ Event.DTS=FrameInfo.DTS;
+ Event.DUR=FrameInfo.DUR;
+ Event.StreamIDs_Size=StreamIDs_Size;
+ Event.StreamIDs=(MediaInfo_int64u*)StreamIDs;
+ Event.StreamIDs_Width=(MediaInfo_int8u*)StreamIDs_Width;
+ Event.ParserIDs=(MediaInfo_int8u* )ParserIDs;
+ Event.FramePosition=Frame_Count;
+ Event.FieldPosition=Field_Count;
+ Event.SlicePosition=0;
+ switch (picture_coding_type)
+ {
+ case 1 :
+ Event.SliceType=0; break;
+ case 2 :
+ Event.SliceType=1; break;
+ case 3 :
+ Event.SliceType=2; break;
+ default:
+ Event.SliceType=(int8u)-1;
+ }
+ Event.Flags=0;
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_Video_SliceInfo_0));
+ }
+ #endif //MEDIAINFO_EVENTS
+
+ //Detection of first I-Frame
+ if (!IFrame_IsParsed)
+ {
+ if (picture_coding_type==1 || picture_coding_type==4) //I-Frame or D-Frame
+ IFrame_IsParsed=true;
+ }
+
+ //Config
+ progressive_frame=true;
+ picture_structure=3; //Frame is default
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse)
+ {
+ spatial_temporal_weight_code_table_index=0;
+ f_code[0][0]=0;
+ f_code[0][1]=0;
+ f_code[1][0]=0;
+ f_code[1][1]=0;
+ sequence_scalable_extension_Present=false;
+ frame_pred_frame_dct=false;
+ concealment_motion_vectors=false;
+ intra_vlc_format=false;
+ }
+ #endif //MEDIAINFO_MACROBLOCKS
+
+ //Temporal reference
+ if (TemporalReference_Offset+temporal_reference>=TemporalReference.size())
+ TemporalReference.resize(TemporalReference_Offset+temporal_reference+1);
+ if (TemporalReference[TemporalReference_Offset+temporal_reference]==NULL)
+ TemporalReference[TemporalReference_Offset+temporal_reference]=new temporalreference;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->IsValid=true;
+
+ //Detecting streams with only I-Frames
+ if (picture_coding_type==1 && picture_coding_type_Old==1)
+ temporal_reference_Old=(int16u)-1; //Resetting temporal_reference_Old
+
+ //NextCode
+ if (!Status[IsAccepted])
+ {
+ NextCode_Clear();
+ for (int64u Element_Name_Next=0x01; Element_Name_Next<=0xAF; Element_Name_Next++)
+ NextCode_Add(Element_Name_Next);
+ NextCode_Add(0xB2);
+ NextCode_Add(0xB5);
+ NextCode_Add(0xB8);
+ }
+
+ //Autorisation of other streams
+ for (int8u Pos=0x01; Pos<=0xAF; Pos++)
+ Streams[Pos].Searching_Payload=true;
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "01" --> "AF"
+void File_Mpegv::slice_start()
+{
+ if (!Status[IsAccepted])
+ {
+ if (!NextCode_Test())
+ return;
+ }
+ Element_Name("slice_start");
+
+ //Parsing
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse && MPEG_Version==2)
+ {
+ BS_Begin();
+
+ bool intra_slice_flag;
+ if (0x1000*vertical_size_extension+vertical_size_value>2800) //vertical_size
+ Skip_S1(3, "slice_vertical_position_extension");
+ if (sequence_scalable_extension_Present)
+ Skip_S1(7, "priority_breakpoint");
+ Skip_S1(5, "quantiser_scale_code");
+ Peek_SB(intra_slice_flag);
+ if (intra_slice_flag)
+ {
+ Skip_SB( "intra_slice_flag");
+ Skip_SB( "intra_slice");
+ Skip_S1(7, "reserved_bits");
+ for (;;)
+ {
+ bool extra_bit_slice;
+ Peek_SB(extra_bit_slice);
+ if (extra_bit_slice)
+ {
+ Skip_S1(8, "extra_information_slice");
+ }
+ else
+ break;
+ if (!Data_BS_Remain())
+ {
+ Trusted_IsNot("extra_bit_slice is missing");
+ return;
+ }
+ }
+ }
+ Skip_SB( "extra_bit_slice (must be 0)");
+
+ macroblock_x=(int64u)-1;
+ while (Synched) //Synched: testing if this is still valid
+ {
+ int8u Remain;
+ if (Data_BS_Remain()%8)
+ Peek_S1(Data_BS_Remain()%8, Remain);
+ else if (Data_Remain())
+ Remain=Buffer[Buffer_Offset+(size_t)(Element_Size-Data_Remain())];
+ else
+ Remain=0;
+ if (Remain==0)
+ {
+ int32u Remain3;
+ size_t Bits=Data_BS_Remain();
+ if (Bits>23)
+ Bits=23;
+ Peek_S3((int8u)Bits, Remain3);
+ if (Remain3==0)
+ break;
+ }
+ slice_start_macroblock();
+ }
+
+ if (Data_BS_Remain())
+ Skip_BS(Data_BS_Remain(), "padding");
+ BS_End();
+ }
+ else
+ #endif //MEDIAINFO_MACROBLOCK
+ Skip_XX(Element_Size, "data");
+
+ FILLING_BEGIN();
+ //Timestamp
+ if (group_start_FirstPass && (Time_Begin_Seconds==Error || Time_Current_Seconds*FrameRate+Time_Current_Frames+temporal_reference<Time_Begin_Seconds*FrameRate+Time_Begin_Frames))
+ {
+ Time_Begin_Seconds=Time_Current_Seconds;
+ Time_Begin_Frames =Time_Current_Frames+(int8u)temporal_reference;
+ }
+ if (!TimeCodeIsNotTrustable && (picture_coding_type==1 || picture_coding_type==2)) //IFrame or PFrame
+ {
+ Time_End_Seconds=Time_Current_Seconds;
+ Time_End_Frames =Time_Current_Frames+(int8u)temporal_reference;
+ }
+
+ if (temporal_reference==temporal_reference_Old)
+ {
+ Frame_Count--;
+ if (IFrame_IsParsed && Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded--;
+ Frame_Count_InThisBlock--;
+ }
+ else
+ {
+ temporal_reference_Old=temporal_reference;
+ }
+
+ if (picture_coding_type==1) //IFrame
+ {
+ temporal_reference_LastIFrame=temporal_reference;
+ PTS_LastIFrame=FrameInfo.PTS;
+ }
+ if (PTS_LastIFrame!=(int64u)-1)
+ {
+ FrameInfo.PTS=PTS_LastIFrame+(temporal_reference-temporal_reference_LastIFrame)*tc;
+ if (PTS_Begin==(int64u)-1 && picture_coding_type==1) //IFrame
+ PTS_Begin=FrameInfo.PTS;
+ }
+
+ //Info
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ Element_Info1(_T("Frame ")+Ztring::ToZtring(Frame_Count));
+ Element_Info1(_T("picture_coding_type ")+Ztring().From_Local(Mpegv_picture_coding_type[picture_coding_type]));
+ Element_Info1(_T("temporal_reference ")+Ztring::ToZtring(temporal_reference));
+ if (FrameInfo.PTS!=(int64u)-1)
+ Element_Info1(_T("PTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/1000000)));
+ if (FrameInfo.DTS!=(int64u)-1)
+ Element_Info1(_T("DTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.DTS)/1000000)));
+ if (Time_End_Seconds!=Error)
+ {
+ int32u Time_End =Time_End_Seconds *1000;
+ if (FrameRate)
+ Time_End +=(int32u)float32_int32s((Time_Current_Frames+temporal_reference)*1000/FrameRate);
+ size_t Hours = Time_End/60/60/1000;
+ size_t Minutes=(Time_End-(Hours*60*60*1000))/60/1000;
+ size_t Seconds=(Time_End-(Hours*60*60*1000)-(Minutes*60*1000))/1000;
+ size_t Milli =(Time_End-(Hours*60*60*1000)-(Minutes*60*1000)-(Seconds*1000));
+
+ Ztring Time;
+ Time+=Ztring::ToZtring(Hours);
+ Time+=_T(':');
+ Time+=Ztring::ToZtring(Minutes);
+ Time+=_T(':');
+ Time+=Ztring::ToZtring(Seconds);
+ if (FrameRate!=0)
+ {
+ Time+=_T('.');
+ Time+=Ztring::ToZtring(Milli);
+ }
+ Element_Info1(_T("time_code ")+Time);
+ }
+ }
+ #endif //MEDIAINFO_TRACE
+
+ //CDP
+ #if defined(MEDIAINFO_CDP_YES)
+ if (Ancillary)
+ {
+ Cdp_IsPresent=true;
+ MustExtendParsingDuration=true;
+ Buffer_TotalBytes_Fill_Max=(int64u)-1; //Disabling this feature for this format, this is done in the parser
+
+ Element_Trace_Begin1("CDP");
+ if ((*Ancillary)==NULL)
+ (*Ancillary)=new File_Ancillary();
+ (*Ancillary)->AspectRatio=MPEG_Version==1?Mpegv_aspect_ratio1[aspect_ratio_information]:Mpegv_aspect_ratio2[aspect_ratio_information];
+ (*Ancillary)->FrameRate=((float)(Mpegv_frame_rate[frame_rate_code] * (frame_rate_extension_n + 1)) / (float)(frame_rate_extension_d + 1));
+ if ((*Ancillary)->Status[IsAccepted]) //In order to test if there is a parser using ancillary data
+ Open_Buffer_Continue((*Ancillary), Buffer+Buffer_Offset, 0);
+ Element_Trace_End0();
+ }
+ #endif //defined(MEDIAINFO_CDP_YES)
+
+ //Active Format Description & Bar Data
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ if (Ancillary && *Ancillary && !(*Ancillary)->AfdBarData_Data.empty())
+ {
+ Element_Trace_Begin1("Active Format Description & Bar Data");
+
+ //Parsing
+ if (AfdBarData_Parser==NULL)
+ {
+ AfdBarData_Parser=new File_AfdBarData;
+ Open_Buffer_Init(AfdBarData_Parser);
+ ((File_AfdBarData*)AfdBarData_Parser)->Format=File_AfdBarData::Format_S2016_3;
+ }
+ if (AfdBarData_Parser->PTS_DTS_Needed)
+ AfdBarData_Parser->FrameInfo.DTS=FrameInfo.DTS;
+ if (!AfdBarData_Parser->Status[IsFinished])
+ Open_Buffer_Continue(AfdBarData_Parser, (*Ancillary)->AfdBarData_Data[0]->Data, (*Ancillary)->AfdBarData_Data[0]->Size);
+
+ //Removing data from stack
+ delete (*Ancillary)->AfdBarData_Data[0]; //(*Ancillary)->AfdBarData_Data[0]=NULL;
+ (*Ancillary)->AfdBarData_Data.erase((*Ancillary)->AfdBarData_Data.begin());
+
+ Element_Trace_End0();
+ }
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+
+ //Counting
+ if (File_Offset+Buffer_Offset+Element_Size==File_Size)
+ Frame_Count_Valid=Frame_Count; //Finish frames in case of there are less than Frame_Count_Valid frames
+ if (!TimeCodeIsNotTrustable && (picture_coding_type==1 || picture_coding_type==2)) //IFrame or PFrame
+ {
+ Time_End_Frames++; //One frame
+ if (progressive_sequence && repeat_first_field)
+ {
+ Time_End_Frames++; //Frame repeated a second time
+ if (top_field_first)
+ Time_End_Frames++; //Frame repeated a third time
+ }
+ }
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ if (IFrame_IsParsed && Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+ if (!(progressive_sequence || picture_structure==3))
+ {
+ Field_Count++;
+ Field_Count_InThisBlock++;
+ }
+ if (picture_coding_type==3)
+ BVOP_Count++;
+ else
+ BVOPsSinceLastRefFrames=0;
+ if (RefFramesCount<2 && (picture_coding_type==1 || picture_coding_type==2))
+ RefFramesCount++;
+ int64u tc_ToAdd=tc/((progressive_sequence || picture_structure==3)?1:2); //Progressive of Frame
+ if (repeat_first_field)
+ {
+ if (progressive_sequence)
+ {
+ tc_ToAdd+=tc;
+ if (top_field_first)
+ tc_ToAdd+=tc;
+ }
+ else
+ tc_ToAdd+=tc/2;
+ }
+ if (FrameInfo.DTS!=(int64u)-1)
+ {
+ FrameInfo.DTS+=tc_ToAdd;
+ if (DTS_End<FrameInfo.DTS)
+ DTS_End=FrameInfo.DTS;
+ }
+ if (FrameInfo.PTS!=(int64u)-1)
+ {
+ FrameInfo.PTS+=tc_ToAdd;
+ if (PTS_End<FrameInfo.PTS)
+ PTS_End=FrameInfo.PTS;
+ }
+
+ //NextCode
+ if (!Status[IsAccepted])
+ {
+ NextCode_Clear();
+ NextCode_Add(0x00);
+ NextCode_Add(0xB3);
+ NextCode_Add(0xB8);
+ }
+
+ //Autorisation of other streams
+ #if MEDIAINFO_MACROBLOCKS
+ if (!Macroblocks_Parse)
+ #endif //MEDIAINFO_MACROBLOCKS
+ for (int8u Pos=0x01; Pos<=0xAF; Pos++)
+ Streams[Pos].Searching_Payload=false;
+
+ //Filling only if not already done
+ if (!Status[IsAccepted])
+ Accept("MPEG Video");
+ if ((!Status[IsFilled] && (!MustExtendParsingDuration && Frame_Count>=Frame_Count_Valid)) || Frame_Count>=Frame_Count_Valid*10)
+ {
+ Fill("MPEG Video");
+ if (File_Size==(int64u)-1)
+ Finish("MPEG Video");
+ else if (!IsSub && 2*(File_Offset+Buffer_Size+SizeToAnalyse_End)<File_Size && Config_ParseSpeed<1.0)
+ {
+ Open_Buffer_Unsynch();
+ GoToFromEnd(SizeToAnalyse_End);
+ }
+ }
+
+ //Skipping slices (if already unpacketized)
+ #if MEDIAINFO_DEMUX
+ if (Demux_UnpacketizeContainer && Buffer_TotalBytes+Buffer_Offset<Demux_TotalBytes
+ #if MEDIAINFO_MACROBLOCKS
+ && !Macroblocks_Parse
+ #endif //MEDIAINFO_MACROBLOCKS
+ )
+ {
+ Element_Offset=Demux_TotalBytes-(Buffer_TotalBytes+Buffer_Offset);
+ }
+ #endif //MEDIAINFO_DEMUX
+
+ #if MEDIAINFO_IBI
+ Ibi_SliceParsed=true;
+ #endif //MEDIAINFO_IBI
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse)
+ {
+ macroblock_x++;
+ Element_Info1(Ztring::ToZtring(macroblock_x)+_T(" macroblocks"));
+ macroblock_x_PerFrame+=macroblock_x;
+ macroblock_y_PerFrame++;
+ }
+ #endif //MEDIAINFO_MACROBLOCKS
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet Packet "01" --> "AF", slice_start, macroblock
+#if MEDIAINFO_MACROBLOCKS
+enum Mpegv_macroblock_type_config //bitwise
+{
+ spatial_temporal_weight_code_flag =0x01,
+ macroblock_intra =0x02,
+ macroblock_pattern =0x04,
+ macroblock_motion_backward =0x08,
+ macroblock_motion_forward =0x10,
+ macroblock_quant =0x20,
+};
+void File_Mpegv::slice_start_macroblock()
+{
+ frame_motion_type=(int8u)-1;
+ spatial_temporal_weight_code=0;
+
+ Element_Trace_Begin1("macroblock");
+
+ size_t macroblock_address_increment;
+ do
+ {
+ Get_VL(macroblock_address_increment_Vlc, macroblock_address_increment, "macroblock_address_increment");
+ Element_Info1(_T("macroblock_address_increment=")+Ztring::ToZtring(Mpegv_macroblock_address_increment[macroblock_address_increment].mapped_to3));
+ if (macroblock_x!=(int64u)-1)
+ macroblock_x+=Mpegv_macroblock_address_increment[macroblock_address_increment].mapped_to3;
+ }
+ while (Mpegv_macroblock_address_increment[macroblock_address_increment].mapped_to1==2); //Escape code
+ if (macroblock_x==(int64u)-1)
+ macroblock_x=0;
+ Element_Info1(_T("macroblock_x=")+Ztring::ToZtring(macroblock_x));
+ Element_Trace_Begin1("macroblock_modes");
+ vlc_fast* macroblock_type_X;
+ switch(picture_coding_type)
+ {
+ case 1: macroblock_type_X=&macroblock_type_I; break;
+ case 2: macroblock_type_X=&macroblock_type_P; break;
+ case 3: macroblock_type_X=&macroblock_type_B; break;
+ default : Element_DoNotTrust("Wrong picture_coding_type");
+ Element_Trace_End0();
+ Element_Trace_End0();
+ return;
+ }
+ size_t macroblock_type_offset;
+ Get_VL(*macroblock_type_X, macroblock_type_offset, "macroblock_type");
+ macroblock_type=macroblock_type_X->Vlc[macroblock_type_offset].mapped_to3;
+ if (!Synched)
+ {
+ BS_End();
+ Element_Offset=Element_Size;
+ return;
+ }
+ Element_Info1(_T("macroblock_quant=")+Ztring::ToZtring(macroblock_type&macroblock_quant));
+ Element_Info1(_T("macroblock_motion_forward=")+Ztring::ToZtring(macroblock_type&macroblock_motion_forward));
+ Element_Info1(_T("macroblock_motion_backward=")+Ztring::ToZtring(macroblock_type&macroblock_motion_backward));
+ Element_Info1(_T("macroblock_pattern=")+Ztring::ToZtring(macroblock_type&macroblock_pattern));
+ Element_Info1(_T("macroblock_intra=")+Ztring::ToZtring(macroblock_type&macroblock_intra));
+ Element_Info1(_T("spatial_temporal_weight_code_flag=")+Ztring::ToZtring(macroblock_type&spatial_temporal_weight_code_flag));
+ if (macroblock_type&spatial_temporal_weight_code_flag
+ && spatial_temporal_weight_code_table_index)
+ Get_S1 (2, spatial_temporal_weight_code, "spatial_temporal_weight_code");
+ if (macroblock_type&macroblock_intra
+ && concealment_motion_vectors)
+ frame_motion_type=2;
+ if (macroblock_type&macroblock_motion_forward
+ || macroblock_type&macroblock_motion_backward)
+ {
+ if (picture_structure==3) //Frame
+ {
+ if (!frame_pred_frame_dct)
+ Get_S1(2, frame_motion_type, "frame_motion_type");
+ else
+ frame_motion_type=2;
+ }
+ else
+ Get_S1 (2, field_motion_type, "field_motion_type");
+ }
+ if (picture_structure==3 //Frame
+ && !frame_pred_frame_dct
+ && (macroblock_type&macroblock_intra
+ || macroblock_type&macroblock_pattern))
+ Skip_SB( "dct_type");
+ Element_Trace_End0();
+ if (macroblock_type&macroblock_quant)
+ Skip_S1(5, "quantiser_scale_code");
+ if (macroblock_type&macroblock_motion_forward
+ || (macroblock_type&macroblock_intra
+ && concealment_motion_vectors))
+ slice_start_macroblock_motion_vectors(false);
+ if (macroblock_type&macroblock_motion_backward)
+ slice_start_macroblock_motion_vectors(true);
+ if (macroblock_type&macroblock_intra
+ && concealment_motion_vectors)
+ Mark_1();
+ if (macroblock_type&macroblock_pattern)
+ slice_start_macroblock_coded_block_pattern();
+ for (int8u i=0; i<block_count; i++)
+ slice_start_macroblock_block(i);
+ Element_Trace_End0();
+}
+#endif //MEDIAINFO_MACROBLOCKS
+
+//---------------------------------------------------------------------------
+// Packet Packet "01" --> "AF", slice_start, macroblock, motion_vectors
+#if MEDIAINFO_MACROBLOCKS
+void File_Mpegv::slice_start_macroblock_motion_vectors(bool s)
+{
+ Element_Trace_Begin1("motion_vectors");
+ int8u motion_vector_count;
+ switch (frame_motion_type)
+ {
+ case 1 :
+ switch (spatial_temporal_weight_code)
+ {
+ case 0 :
+ case 1 :
+ motion_vector_count=2;
+ break;
+ case 2 :
+ case 3 :
+ motion_vector_count=1;
+ break;
+ default: Trusted_IsNot("spatial_temporal_weight_code problem");
+ Element_Trace_End0();
+ return;
+ }
+ break;
+ case 2 :
+ motion_vector_count=1;
+ break;
+ case 3 :
+ switch (spatial_temporal_weight_code)
+ {
+ case 1 :
+ Trusted_IsNot("spatial_temporal_weight_code problem");
+ Element_Trace_End0();
+ return;
+ default:
+ motion_vector_count=1;
+ break;
+ }
+ default : Trusted_IsNot("frame_motion_type problem");
+ Element_Trace_End0();
+ return;
+ }
+ if (motion_vector_count==1)
+ {
+ if (!(picture_structure==3 //Frame
+ && frame_motion_type==2) //mv_format==Frame
+ && frame_motion_type!=3) //dmv!=1
+ Skip_SB( "motion_vertical_field_select[0][s]");
+ slice_start_macroblock_motion_vectors_motion_vector(false, s);
+ }
+ else
+ {
+ Skip_SB( "motion_vertical_field_select[0][s]");
+ slice_start_macroblock_motion_vectors_motion_vector(false, s);
+ Skip_SB( "motion_vertical_field_select[1][s]");
+ slice_start_macroblock_motion_vectors_motion_vector(true, s);
+ }
+ Element_Trace_End0();
+}
+#endif //MEDIAINFO_MACROBLOCKS
+
+//---------------------------------------------------------------------------
+// Packet Packet "01" --> "AF", slice_start, macroblock, motion_vectors, motion_vector
+#if MEDIAINFO_MACROBLOCKS
+void File_Mpegv::slice_start_macroblock_motion_vectors_motion_vector(bool r, bool s)
+{
+ Element_Trace_Begin1("motion_vector");
+ size_t motion_code_;
+
+ Get_VL(motion_code, motion_code_, "motion_code[r][s][0]"); Param_Info1(Mpegv_motion_code[motion_code_].mapped_to3);
+ if (Mpegv_motion_code[motion_code_].mapped_to3)
+ Skip_SB( "motion_code[r][s][0] sign");
+ if (f_code[s][0]>1 && Mpegv_motion_code[motion_code_].mapped_to3)
+ Skip_S1(f_code[s][0]-1, "motion_residual[r][s][0]");
+ if (frame_motion_type==3) //dmv==1
+ {
+ Info_VL(dmvector, dmvector_, "dmvector[0]"); Param_Info1(Mpegv_dmvector[dmvector_].mapped_to3);
+ }
+
+ Get_VL(motion_code, motion_code_, "motion_code[r][s][1]"); Param_Info1(Mpegv_motion_code[motion_code_].mapped_to3);
+ if (Mpegv_motion_code[motion_code_].mapped_to3)
+ Skip_SB( "motion_code[r][s][1] sign");
+ if (f_code[s][1]>1 && Mpegv_motion_code[motion_code_].mapped_to3)
+ Skip_S1(f_code[s][1]-1, "motion_residual[r][s][1]");
+ if (frame_motion_type==3) //dmv==1
+ {
+ Info_VL(dmvector, dmvector_, "dmvector[1]"); Param_Info1(Mpegv_dmvector[dmvector_].mapped_to3);
+ }
+
+ Element_Trace_End0();
+}
+#endif //MEDIAINFO_MACROBLOCKS
+
+//---------------------------------------------------------------------------
+// Packet Packet "01" --> "AF", slice_start, macroblock, coded_block_pattern
+#if MEDIAINFO_MACROBLOCKS
+void File_Mpegv::slice_start_macroblock_coded_block_pattern()
+{
+ Element_Trace_Begin1("coded_block_pattern");
+ size_t coded_block_pattern_;
+ Get_VL(coded_block_pattern, coded_block_pattern_, "coded_block_pattern_420");
+ cbp=Mpegv_coded_block_pattern[coded_block_pattern_].mapped_to3;
+ switch (chroma_format)
+ {
+ case 2 : //4:2:2
+ {
+ int8u coded_block_pattern_1;
+ Get_S1 (2, coded_block_pattern_1, "coded_block_pattern_1");
+ cbp<<=2;
+ cbp|=coded_block_pattern_1;
+ }
+ break;
+ case 3 : //4:4:4
+ {
+ int8u coded_block_pattern;
+ Get_S1 (8, coded_block_pattern, "coded_block_pattern_1/2");
+ cbp<<=8;
+ cbp|=coded_block_pattern;
+ }
+ break;
+ default : ;
+ }
+ Element_Info1(Ztring::ToZtring((int16u)cbp, 2));
+ Element_Trace_End0();
+}
+#endif //MEDIAINFO_MACROBLOCKS
+
+//---------------------------------------------------------------------------
+// Packet Packet "01" --> "AF", slice_start, macroblock, block
+#if MEDIAINFO_MACROBLOCKS
+void File_Mpegv::slice_start_macroblock_block(int8u i)
+{
+ //pattern_code
+ if (!(macroblock_type&macroblock_intra) && !((macroblock_type&macroblock_pattern) && (cbp&(1<<(block_count-1-i)))))
+ return;
+
+ Element_Trace_Begin1("block"); Element_Info1(i);
+ bool IsFirst;
+ const vlc* Mpegv_dct_coefficients;
+ vlc_fast* Mpegv_dct_coefficients2;
+ if (macroblock_type&macroblock_intra)
+ {
+ IsFirst=false;
+ Mpegv_dct_coefficients=intra_vlc_format?Mpegv_dct_coefficients_1:Mpegv_dct_coefficients_0;
+ Mpegv_dct_coefficients2=&(intra_vlc_format?dct_coefficients_1:dct_coefficients_0);
+ if (i<4)
+ {
+ size_t dct_dc_size_luminance_;
+ Get_VL(dct_dc_size_luminance, dct_dc_size_luminance_, "dct_dc_size_luminance"); Param_Info1(Mpegv_dct_dc_size_luminance[dct_dc_size_luminance_].mapped_to3);
+ if (Mpegv_dct_dc_size_luminance[dct_dc_size_luminance_].mapped_to3)
+ Skip_S2(Mpegv_dct_dc_size_luminance[dct_dc_size_luminance_].mapped_to3, "dct_dc_differential");
+ }
+ else
+ {
+ size_t dct_dc_size_chrominance_;
+ Get_VL(dct_dc_size_chrominance, dct_dc_size_chrominance_, "dct_dc_size_chrominance"); Param_Info1(Mpegv_dct_dc_size_chrominance[dct_dc_size_chrominance_].mapped_to3);
+ if (Mpegv_dct_dc_size_chrominance[dct_dc_size_chrominance_].mapped_to3)
+ Skip_S2((int8u)dct_dc_size_chrominance_, "dct_dc_differential");
+ }
+ }
+ else
+ {
+ IsFirst=true;
+ Mpegv_dct_coefficients=Mpegv_dct_coefficients_0;
+ Mpegv_dct_coefficients2=&dct_coefficients_0;
+ }
+
+ for (;;)
+ {
+ Element_Trace_Begin1("dct_coefficient");
+ size_t dct_coefficient;
+ Get_VL(*Mpegv_dct_coefficients2, dct_coefficient, "dct_coefficient");
+ switch (Mpegv_dct_coefficients[dct_coefficient].mapped_to1)
+ {
+ case 1 :
+ Element_Trace_End1("End of block");
+ Element_Trace_End0();
+ return;
+ case 2 :
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ Info_S1( 6, Run, "Run"); Element_Info1(Run);
+ Info_S2(12, Level, "Level"); Element_Info1(Level-(Level>0x800?4096:0));
+ }
+ else
+ #endif //MEDIAINFO_MACROBLOCKS
+ Skip_S3(18, "Run + Level");
+ break;
+ case 3 :
+ if (!IsFirst)
+ {
+ if (Mpegv_dct_coefficients[dct_coefficient].bit_increment)
+ {
+ Element_Trace_End1("End of block");
+ Element_Trace_End0();
+ return;
+ }
+ Skip_SB( "dct_coefficient sign");
+ }
+ default:
+ Element_Info1(Mpegv_dct_coefficients[dct_coefficient].mapped_to2);
+ Element_Info1(Mpegv_dct_coefficients[dct_coefficient].mapped_to3);
+ }
+ if (IsFirst)
+ IsFirst=false;
+ Element_Trace_End0();
+ }
+}
+#endif //MEDIAINFO_MACROBLOCKS
+
+//---------------------------------------------------------------------------
+// Packet "B2"
+void File_Mpegv::user_data_start()
+{
+ Element_Name("user_data_start");
+
+ //GA94 stuff
+ if (Element_Size>=4)
+ {
+ int32u GA94_Identifier;
+ Peek_B4(GA94_Identifier);
+ switch (GA94_Identifier)
+ {
+ case 0x434301F8 : user_data_start_CC(); return;
+ case 0x44544731 : user_data_start_DTG1(); return;
+ case 0x47413934 : user_data_start_GA94(); return;
+ default : {
+ int8u SCTE20_Identifier;
+ Peek_B1(SCTE20_Identifier);
+ if (SCTE20_Identifier==0x03)
+ {
+ user_data_start_3();
+ return;
+ }
+ }
+ }
+ }
+
+ //Rejecting junk at the begin
+ size_t Library_Start_Offset=0;
+ while (Library_Start_Offset+4<=Element_Size)
+ {
+ bool OK=true;
+ for (size_t Pos=0; Pos<4; Pos++)
+ {
+ if (!((Buffer[Buffer_Offset+Library_Start_Offset+Pos]==0x20 && Pos)
+ || Buffer[Buffer_Offset+Library_Start_Offset+Pos]==0x22
+ || Buffer[Buffer_Offset+Library_Start_Offset+Pos]==0x27
+ || Buffer[Buffer_Offset+Library_Start_Offset+Pos]==0x28
+ || (Buffer[Buffer_Offset+Library_Start_Offset+Pos]==0x29 && Pos)
+ || (Buffer[Buffer_Offset+Library_Start_Offset+Pos]>=0x30
+ && Buffer[Buffer_Offset+Library_Start_Offset+Pos]<=0x3F)
+ || (Buffer[Buffer_Offset+Library_Start_Offset+Pos]>=0x41
+ && Buffer[Buffer_Offset+Library_Start_Offset+Pos]<=0x7D)))
+ {
+ OK=false;
+ break;
+ }
+ }
+ if (OK)
+ break;
+ Library_Start_Offset++;
+ }
+ if (Library_Start_Offset+4>Element_Size)
+ {
+ Skip_XX(Element_Size, "junk");
+ return; //No good info
+ }
+
+ //Accepting good data after junk
+ size_t Library_End_Offset=Library_Start_Offset+4;
+ while (Library_End_Offset<Element_Size
+ && (Buffer[Buffer_Offset+Library_End_Offset]==0x0D
+ || Buffer[Buffer_Offset+Library_End_Offset]==0x0A
+ || (Buffer[Buffer_Offset+Library_End_Offset]>=0x20 && Buffer[Buffer_Offset+Library_End_Offset]<=0x3F)
+ || (Buffer[Buffer_Offset+Library_End_Offset]>=0x41 && Buffer[Buffer_Offset+Library_End_Offset]<=0x7D)))
+ Library_End_Offset++;
+
+ //Parsing
+ Ztring Temp;
+ if (Library_Start_Offset>0)
+ Skip_XX(Library_Start_Offset, "junk");
+ if (Library_End_Offset-Library_Start_Offset)
+ Get_Local(Library_End_Offset-Library_Start_Offset, Temp,"data");
+ if (Element_Offset<Element_Size)
+ Skip_XX(Element_Size-Element_Offset, "junk");
+
+ //Cleanup
+ while(Temp.size()>3 && Temp[1]==_T('e') && Temp[2]==_T('n') && Temp[3]==_T('c'))
+ Temp.erase(0, 1);
+ while(Temp.size()>5 && Temp[3]==_T('M') && Temp[4]==_T('P') && Temp[5]==_T('E'))
+ Temp.erase(0, 1);
+
+ //Cleanup
+ while(!Temp.empty() && Temp[0]==_T('0'))
+ Temp.erase(0, 1);
+
+ FILLING_BEGIN();
+ if (!Temp.empty())
+ {
+ if (Temp.find(_T("build"))==0)
+ Library+=Ztring(_T(" "))+Temp;
+ else
+ Library=Temp;
+
+ //Library
+ if (Temp.find(_T("Created with Nero"))==0)
+ {
+ Library_Name=_T("Ahead Nero");
+ }
+ else if (Library.find(_T("encoded by avi2mpg1 ver "))==0)
+ {
+ Library_Name=_T("avi2mpg1");
+ Library_Version=Library.SubString(_T("encoded by avi2mpg1 ver "), _T(""));
+ }
+ else if (Library.find(_T("encoded by TMPGEnc (ver. "))==0)
+ {
+ Library_Name=_T("TMPGEnc");
+ Library_Version=Library.SubString(_T("encoded by TMPGEnc (ver. "), _T(")"));
+ }
+ else if (Library.find(_T("encoded by TMPGEnc 4.0 XPress Version. "))==0)
+ {
+ Library_Name=_T("TMPGEnc XPress");
+ Library_Version=Library.SubString(_T("encoded by TMPGEnc 4.0 XPress Version. "), _T(""));
+ }
+ else if (Library.find(_T("encoded by TMPGEnc MPEG Editor "))==0)
+ {
+ Library_Name=_T("TMPGEnc MPEG Editor");
+ Library_Version=Library.SubString(_T("Version. "), _T(""));
+ }
+ else if (Library.find(_T("encoded by TMPGEnc "))==0)
+ {
+ Library_Name=_T("TMPGEnc");
+ Library_Version=Library.SubString(_T("encoded by TMPGEnc "), _T(""));
+ }
+ else if (Library.find(_T("MPEG Encoder v"))==0)
+ {
+ Library_Name=_T("MPEG Encoder by Tristan Savatier");
+ Library_Version=Library.SubString(_T("MPEG Encoder v"), _T(" by"));
+ }
+ else
+ Library_Name=Library;
+
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B2", CC (From DVD)
+void File_Mpegv::user_data_start_CC()
+{
+ Skip_B4( "identifier");
+
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ Element_Info1("DVD Captions");
+
+ //Parsing
+ #if MEDIAINFO_DEMUX
+ Element_Code=0x434301F800000000LL;
+ #endif //MEDIAINFO_DEMUX
+ if (CC___Parser==NULL)
+ {
+ CC___IsPresent=true;
+ MustExtendParsingDuration=true;
+ Buffer_TotalBytes_Fill_Max=(int64u)-1; //Disabling this feature for this format, this is done in the parser
+ CC___Parser=new File_DtvccTransport;
+ Open_Buffer_Init(CC___Parser);
+ ((File_DtvccTransport*)CC___Parser)->Format=File_DtvccTransport::Format_DVD;
+ }
+ if (CC___Parser->PTS_DTS_Needed)
+ {
+ CC___Parser->FrameInfo.PCR=FrameInfo.PCR;
+ CC___Parser->FrameInfo.PTS=FrameInfo.PTS;
+ CC___Parser->FrameInfo.DTS=FrameInfo.DTS;
+ }
+ Demux(Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset), ContentType_MainStream);
+ Open_Buffer_Continue(CC___Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+ Element_Offset=Element_Size;
+ #else //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ Skip_XX(Element_Size-Element_Offset, "DVD Captions");
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+}
+
+//---------------------------------------------------------------------------
+// Packet "B2", 0x03 (SCTE20)
+void File_Mpegv::user_data_start_3()
+{
+ Skip_B1( "identifier");
+
+ #if defined(MEDIAINFO_SCTE20_YES)
+ Scte_IsPresent=true;
+ MustExtendParsingDuration=true;
+ Buffer_TotalBytes_Fill_Max=(int64u)-1; //Disabling this feature for this format, this is done in the parser
+
+ Element_Info1("SCTE 20");
+
+ //Coherency
+ if (TemporalReference_Offset+temporal_reference>=TemporalReference.size())
+ return;
+
+ //Purging too old orphelins
+ if (Scte_TemporalReference_Offset+8<TemporalReference_Offset+temporal_reference)
+ {
+ size_t Pos=TemporalReference_Offset+temporal_reference;
+ do
+ {
+ if (TemporalReference[Pos]==NULL || !TemporalReference[Pos]->IsValid || TemporalReference[Pos]->Scte.empty())
+ break;
+ Pos--;
+ }
+ while (Pos>0);
+ Scte_TemporalReference_Offset=Pos+1;
+ }
+
+ if (TemporalReference_Offset+temporal_reference>=TemporalReference.size())
+ TemporalReference.resize(TemporalReference_Offset+temporal_reference+1);
+ if (TemporalReference[TemporalReference_Offset+temporal_reference]==NULL)
+ TemporalReference[TemporalReference_Offset+temporal_reference]=new temporalreference;
+ temporalreference::buffer_data* BufferData=new temporalreference::buffer_data;
+ BufferData->Size=(size_t)(Element_Size-Element_Offset);
+ BufferData->Data=new int8u[(size_t)(Element_Size-Element_Offset)];
+ std::memcpy(BufferData->Data, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+ TemporalReference[TemporalReference_Offset+temporal_reference]->Scte.push_back(BufferData);
+ TemporalReference[TemporalReference_Offset+temporal_reference]->Scte_Parsed.push_back(false);
+ if (TemporalReference[TemporalReference_Offset+temporal_reference]->Scte_Parsed.size()>=2 && TemporalReference[TemporalReference_Offset+temporal_reference]->Scte_Parsed[TemporalReference[TemporalReference_Offset+temporal_reference]->Scte_Parsed.size()-2] && Scte_TemporalReference_Offset==TemporalReference_Offset+temporal_reference+1)
+ Scte_TemporalReference_Offset--;
+
+ //Parsing
+ Skip_XX(Element_Size-Element_Offset, "SCTE 20 data");
+
+ //Parsing Captions after reordering
+ bool CanBeParsed=true;
+ size_t FirstSize=(size_t)-1;
+ for (size_t Scte20_Pos=Scte_TemporalReference_Offset; Scte20_Pos<TemporalReference.size(); Scte20_Pos++)
+ {
+ if (TemporalReference[Scte20_Pos]==NULL || !TemporalReference[Scte20_Pos]->IsValid || TemporalReference[Scte20_Pos]->Scte.empty())
+ CanBeParsed=false; //There is a missing field/frame
+ if (CanBeParsed)
+ {
+ if (FirstSize==(size_t)-1)
+ FirstSize=TemporalReference[Scte20_Pos]->Scte.size();
+ else if (!progressive_sequence && !TemporalReference[Scte20_Pos]->progressive_frame && TemporalReference[Scte20_Pos]->picture_structure==3 && TemporalReference[Scte20_Pos]->Scte.size()!=FirstSize)
+ CanBeParsed=false; //There is a missing field in a frame duo
+ }
+ }
+ if (CanBeParsed)
+ {
+ for (size_t Scte20_Pos=Scte_TemporalReference_Offset; Scte20_Pos<TemporalReference.size(); Scte20_Pos++)
+ {
+ Element_Begin1("Reordered SCTE 20");
+
+ //Parsing
+ #if MEDIAINFO_DEMUX
+ Element_Code=0x0000000300000000LL;
+ #endif //MEDIAINFO_DEMUX
+ if (Scte_Parser==NULL)
+ {
+ Scte_Parser=new File_Scte20;
+ Open_Buffer_Init(Scte_Parser);
+ }
+ //((File_Scte20*)Scte_Parser)->AspectRatio=MPEG_Version==1?Mpegv_aspect_ratio1[aspect_ratio_information]:Mpegv_aspect_ratio2[aspect_ratio_information];
+ ((File_Scte20*)Scte_Parser)->picture_structure=TemporalReference[Scte20_Pos]->picture_structure;
+ ((File_Scte20*)Scte_Parser)->progressive_sequence=progressive_sequence;
+ ((File_Scte20*)Scte_Parser)->progressive_frame=TemporalReference[Scte20_Pos]->progressive_frame;
+ ((File_Scte20*)Scte_Parser)->top_field_first=TemporalReference[Scte20_Pos]->top_field_first;
+ ((File_Scte20*)Scte_Parser)->repeat_first_field=TemporalReference[Scte20_Pos]->repeat_first_field;
+ for (size_t Pos=0; Pos<TemporalReference[Scte20_Pos]->Scte.size(); Pos++)
+ if (!TemporalReference[Scte20_Pos]->Scte_Parsed[Pos])
+ {
+ if (Scte_Parser->PTS_DTS_Needed)
+ {
+ Scte_Parser->FrameInfo.PCR=FrameInfo.PCR;
+ Scte_Parser->FrameInfo.PTS=FrameInfo.PTS-(TemporalReference.size()-1-Scte20_Pos)*tc;
+ Scte_Parser->FrameInfo.DTS=FrameInfo.DTS-(TemporalReference.size()-1-Scte20_Pos)*tc;
+ }
+ Demux(TemporalReference[Scte20_Pos]->Scte[Pos]->Data, TemporalReference[Scte20_Pos]->Scte[Pos]->Size, ContentType_MainStream);
+ Open_Buffer_Continue(Scte_Parser, TemporalReference[Scte20_Pos]->Scte[Pos]->Data, TemporalReference[Scte20_Pos]->Scte[Pos]->Size);
+ TemporalReference[Scte20_Pos]->Scte_Parsed[Pos]=true;
+ }
+
+ Element_End0();
+ }
+ Scte_TemporalReference_Offset=TemporalReference.size();
+ }
+ #else //defined(MEDIAINFO_SCTE20_YES)
+ Skip_XX(Element_Size-Element_Offset, "SCTE 20 data");
+ #endif //defined(MEDIAINFO_SCTE20_YES)
+}
+
+//---------------------------------------------------------------------------
+// Packet "B2", DTG1
+void File_Mpegv::user_data_start_DTG1()
+{
+ Skip_B4( "identifier");
+
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ Element_Info1("Active Format Description");
+
+ //Parsing
+ if (DTG1_Parser==NULL)
+ {
+ DTG1_Parser=new File_AfdBarData;
+ Open_Buffer_Init(DTG1_Parser);
+ ((File_AfdBarData*)DTG1_Parser)->Format=File_AfdBarData::Format_A53_4_DTG1;
+
+ //Aspect ratio for AFD
+ float32 DAR=0;
+ if (MPEG_Version==2)
+ {
+ if (aspect_ratio_information==0)
+ ; //Forbidden
+ else if (aspect_ratio_information==1)
+ DAR=((float32)(0x1000*horizontal_size_extension+horizontal_size_value))/(0x1000*vertical_size_extension+vertical_size_value);
+ else if (display_horizontal_size && display_vertical_size)
+ {
+ if (vertical_size_value && Mpegv_aspect_ratio2[aspect_ratio_information])
+ DAR=((float32)(0x1000*horizontal_size_extension+horizontal_size_value))/(0x1000*vertical_size_extension+vertical_size_value)
+ *Mpegv_aspect_ratio2[aspect_ratio_information]/((float32)display_horizontal_size/display_vertical_size);
+ }
+ else if (Mpegv_aspect_ratio2[aspect_ratio_information])
+ DAR=Mpegv_aspect_ratio2[aspect_ratio_information];
+ }
+ else //Version 1
+ {
+ if (vertical_size_value && Mpegv_aspect_ratio1[aspect_ratio_information])
+ DAR=((float32)(0x1000*horizontal_size_extension+horizontal_size_value))/(0x1000*vertical_size_extension+vertical_size_value)/Mpegv_aspect_ratio1[aspect_ratio_information];
+ }
+ if (DAR>=1.330 && DAR<1.336) ((File_AfdBarData*)DTG1_Parser)->aspect_ratio_FromContainer=0; //4/3
+ if (DAR>=1.774 && DAR<1.780) ((File_AfdBarData*)DTG1_Parser)->aspect_ratio_FromContainer=1; //16/9
+ }
+ if (DTG1_Parser->PTS_DTS_Needed)
+ {
+ DTG1_Parser->FrameInfo.PCR=FrameInfo.PCR;
+ DTG1_Parser->FrameInfo.PTS=FrameInfo.PTS;
+ DTG1_Parser->FrameInfo.DTS=FrameInfo.DTS;
+ }
+ Open_Buffer_Continue(DTG1_Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+ Element_Offset=Element_Size;
+ #else //defined(MEDIAINFO_AFDBARDATA_YES)
+ Skip_XX(Element_Size-Element_Offset, "Active Format Description");
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+}
+
+//---------------------------------------------------------------------------
+// Packet "B2", GA94
+void File_Mpegv::user_data_start_GA94()
+{
+ //Parsing
+ int8u user_data_type_code;
+ Skip_B4( "GA94_identifier");
+ Get_B1 (user_data_type_code, "user_data_type_code");
+ switch (user_data_type_code)
+ {
+ case 0x03 : user_data_start_GA94_03(); break;
+ case 0x06 : user_data_start_GA94_06(); break;
+ default : Skip_XX(Element_Size-Element_Offset, "GA94_reserved_user_data");
+ }
+}
+
+//---------------------------------------------------------------------------
+// Packet "B2", GA94 0x03 (styled captioning)
+void File_Mpegv::user_data_start_GA94_03()
+{
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ GA94_03_IsPresent=true;
+ MustExtendParsingDuration=true;
+ Buffer_TotalBytes_Fill_Max=(int64u)-1; //Disabling this feature for this format, this is done in the parser
+
+ Element_Info1("DTVCC Transport");
+
+ //Coherency
+ if (TemporalReference_Offset+temporal_reference>=TemporalReference.size())
+ return;
+
+ //Purging too old orphelins
+ if (GA94_03_TemporalReference_Offset+8<TemporalReference_Offset+temporal_reference)
+ {
+ size_t Pos=TemporalReference_Offset+temporal_reference;
+ do
+ {
+ if (TemporalReference[Pos]==NULL || !TemporalReference[Pos]->IsValid || TemporalReference[Pos]->GA94_03==NULL)
+ break;
+ Pos--;
+ }
+ while (Pos>0);
+ GA94_03_TemporalReference_Offset=Pos+1;
+ }
+
+ if (TemporalReference_Offset+temporal_reference>=TemporalReference.size())
+ TemporalReference.resize(TemporalReference_Offset+temporal_reference+1);
+ if (TemporalReference[TemporalReference_Offset+temporal_reference]==NULL)
+ TemporalReference[TemporalReference_Offset+temporal_reference]=new temporalreference;
+ if (TemporalReference[TemporalReference_Offset+temporal_reference]->GA94_03==NULL)
+ TemporalReference[TemporalReference_Offset+temporal_reference]->GA94_03=new temporalreference::buffer_data;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->GA94_03->Size=(size_t)(Element_Size-Element_Offset);
+ delete[] TemporalReference[TemporalReference_Offset+temporal_reference]->GA94_03->Data;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->GA94_03->Data=new int8u[(size_t)(Element_Size-Element_Offset)];
+ std::memcpy(TemporalReference[TemporalReference_Offset+temporal_reference]->GA94_03->Data, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+
+ //Parsing
+ Skip_XX(Element_Size-Element_Offset, "CC data");
+
+ //Parsing Captions after reordering
+ bool CanBeParsed=true;
+ for (size_t GA94_03_Pos=GA94_03_TemporalReference_Offset; GA94_03_Pos<TemporalReference.size(); GA94_03_Pos++)
+ if (TemporalReference[GA94_03_Pos]==NULL || !TemporalReference[GA94_03_Pos]->IsValid || TemporalReference[GA94_03_Pos]->GA94_03==NULL)
+ CanBeParsed=false; //There is a missing field/frame
+ if (CanBeParsed)
+ {
+ for (size_t GA94_03_Pos=GA94_03_TemporalReference_Offset; GA94_03_Pos<TemporalReference.size(); GA94_03_Pos++)
+ {
+ Element_Begin1("Reordered DTVCC Transport");
+
+ //Parsing
+ #if MEDIAINFO_DEMUX
+ Element_Code=0x4741393400000003LL;
+ #endif //MEDIAINFO_DEMUX
+ if (GA94_03_Parser==NULL)
+ {
+ GA94_03_Parser=new File_DtvccTransport;
+ Open_Buffer_Init(GA94_03_Parser);
+ ((File_DtvccTransport*)GA94_03_Parser)->Format=File_DtvccTransport::Format_A53_4_GA94_03;
+ }
+ if (GA94_03_Parser->PTS_DTS_Needed)
+ {
+ GA94_03_Parser->FrameInfo.PCR=FrameInfo.PCR;
+ GA94_03_Parser->FrameInfo.PTS=FrameInfo.PTS-(FrameInfo.PTS!=(int64u)-1?((TemporalReference.size()-1-GA94_03_Pos)*tc):0);
+ GA94_03_Parser->FrameInfo.DTS=FrameInfo.DTS-(FrameInfo.DTS!=(int64u)-1?((TemporalReference.size()-1-GA94_03_Pos)*tc):0);
+ }
+ Demux(TemporalReference[GA94_03_Pos]->GA94_03->Data, TemporalReference[GA94_03_Pos]->GA94_03->Size, ContentType_MainStream);
+ ((File_DtvccTransport*)GA94_03_Parser)->AspectRatio=MPEG_Version==1?Mpegv_aspect_ratio1[aspect_ratio_information]:Mpegv_aspect_ratio2[aspect_ratio_information];
+ Open_Buffer_Continue(GA94_03_Parser, TemporalReference[GA94_03_Pos]->GA94_03->Data, TemporalReference[GA94_03_Pos]->GA94_03->Size);
+
+ Element_End0();
+ }
+ GA94_03_TemporalReference_Offset=TemporalReference.size();
+ }
+ #else //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ Skip_XX(Element_Size-Element_Offset, "DTVCC Transport data");
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+}
+
+//---------------------------------------------------------------------------
+// Packet "B2", GA94 0x06 (bar data)
+void File_Mpegv::user_data_start_GA94_06()
+{
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ Element_Info1("Bar Data");
+
+ //Parsing
+ if (GA94_06_Parser==NULL)
+ {
+ GA94_06_Parser=new File_AfdBarData;
+ Open_Buffer_Init(GA94_06_Parser);
+ ((File_AfdBarData*)GA94_06_Parser)->Format=File_AfdBarData::Format_A53_4_GA94_06;
+ }
+ if (GA94_06_Parser->PTS_DTS_Needed)
+ {
+ GA94_06_Parser->FrameInfo.PCR=FrameInfo.PCR;
+ GA94_06_Parser->FrameInfo.PTS=FrameInfo.PTS;
+ GA94_06_Parser->FrameInfo.DTS=FrameInfo.DTS;
+ }
+ Open_Buffer_Init(GA94_06_Parser);
+ Open_Buffer_Continue(GA94_06_Parser, Buffer+Buffer_Offset+(size_t)Element_Offset, (size_t)(Element_Size-Element_Offset));
+ Element_Offset=Element_Size;
+ #else //defined(MEDIAINFO_AFDBARDATA_YES)
+ Skip_XX(Element_Size-Element_Offset, "Bar Data");
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+}
+
+//---------------------------------------------------------------------------
+// Packet "B3"
+void File_Mpegv::sequence_header()
+{
+ Element_Name("sequence_header");
+
+ //Reading
+ int32u bit_rate_value_temp;
+ BS_Begin();
+ Get_S2 (12, horizontal_size_value, "horizontal_size_value");
+ Get_S2 (12, vertical_size_value, "vertical_size_value");
+ Get_S1 ( 4, aspect_ratio_information, "aspect_ratio_information"); Param_Info1C((vertical_size_value && Mpegv_aspect_ratio1[aspect_ratio_information]), (float)horizontal_size_value/vertical_size_value/Mpegv_aspect_ratio1[aspect_ratio_information]); Param_Info1(Mpegv_aspect_ratio2[aspect_ratio_information]);
+ Get_S1 ( 4, frame_rate_code, "frame_rate_code"); Param_Info1(Mpegv_frame_rate[frame_rate_code]);
+ Get_S3 (18, bit_rate_value_temp, "bit_rate_value"); Param_Info1(bit_rate_value_temp*400);
+ Mark_1 ();
+ Get_S2 (10, vbv_buffer_size_value, "vbv_buffer_size_value"); Param_Info2(2*1024*((int32u)vbv_buffer_size_value), " bytes");
+ Skip_SB( "constrained_parameters_flag");
+ TEST_SB_GET(load_intra_quantiser_matrix, "load_intra_quantiser_matrix");
+ bool FillMatrix=Matrix_intra.empty();
+ for (size_t Pos=0; Pos<64; Pos++)
+ {
+ int8u intra_quantiser;
+ Get_S1 (8, intra_quantiser, "intra_quantiser");
+ if (FillMatrix)
+ {
+ Ztring Value=Ztring::ToZtring(intra_quantiser, 16);
+ if (Value.size()==1)
+ Value.insert(0, _T("0"));
+ Matrix_intra+=Value;
+ }
+ }
+ TEST_SB_END();
+ TEST_SB_GET(load_non_intra_quantiser_matrix, "load_non_intra_quantiser_matrix");
+ bool FillMatrix=Matrix_nonintra.empty();
+ for (size_t Pos=0; Pos<64; Pos++)
+ {
+ int8u non_intra_quantiser;
+ Get_S1 (8, non_intra_quantiser, "non_intra_quantiser");
+ if (FillMatrix)
+ {
+ Ztring Value=Ztring::ToZtring(non_intra_quantiser, 16);
+ if (Value.size()==1)
+ Value.insert(0, _T("0"));
+ Matrix_nonintra+=Value;
+ }
+ }
+ TEST_SB_END();
+ BS_End();
+
+ //0x00 at the end
+ if (Element_Offset<Element_Size)
+ {
+ int64u NullBytes_Begin=Element_Size-1;
+ while (NullBytes_Begin>Element_Offset && Buffer[Buffer_Offset+(size_t)NullBytes_Begin]==0x00)
+ NullBytes_Begin--;
+
+ if (NullBytes_Begin==Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "Padding");
+ }
+
+ FILLING_BEGIN_PRECISE();
+ //Temporal reference
+ temporal_reference_Old=(int16u)-1;
+ TemporalReference_Offset=TemporalReference.size();
+ if (TemporalReference_Offset>=0x800)
+ {
+ for (size_t Pos=0; Pos<0x400; Pos++)
+ delete TemporalReference[Pos]; //TemporalReference[Pos]=NULL;
+ TemporalReference.erase(TemporalReference.begin(), TemporalReference.begin()+0x400);
+ if (0x400<TemporalReference_Offset)
+ TemporalReference_Offset-=0x400;
+ else
+ TemporalReference_Offset=0;
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ if (0x400<GA94_03_TemporalReference_Offset)
+ GA94_03_TemporalReference_Offset-=0x400;
+ else
+ GA94_03_TemporalReference_Offset=0;
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ #if defined(MEDIAINFO_SCTE20_YES)
+ if (0x400<Scte_TemporalReference_Offset)
+ Scte_TemporalReference_Offset-=0x400;
+ else
+ Scte_TemporalReference_Offset=0;
+ #endif //defined(MEDIAINFO_SCTE20_YES)
+ }
+
+ //Bit_rate
+ if (bit_rate_value_IsValid && bit_rate_value_temp!=bit_rate_value)
+ bit_rate_value_IsValid=false; //two bit_rate_values, not handled.
+ else if (bit_rate_value==0)
+ {
+ bit_rate_value=bit_rate_value_temp;
+ bit_rate_value_IsValid=true;
+ }
+
+ //NextCode
+ if (!Status[IsAccepted])
+ {
+ NextCode_Clear();
+ NextCode_Add(0x00);
+ NextCode_Add(0xB2);
+ NextCode_Add(0xB5);
+ NextCode_Add(0xB8);
+ }
+
+ //Autorisation of other streams
+ Streams[0x00].Searching_Payload=true;
+ Streams[0xB2].Searching_Payload=true;
+ Streams[0xB5].Searching_Payload=true;
+ if (Frame_Count==0)
+ Streams[0xB8].Searching_TimeStamp_Start=true;
+ Streams[0xB8].Searching_TimeStamp_End=true;
+
+ //Temp
+ if (Mpegv_frame_rate[frame_rate_code])
+ tc=float64_int64s(((float64)1000000000)/Mpegv_frame_rate[frame_rate_code]);
+ if (Frame_Count<Frame_Count_Valid)
+ {
+ FrameRate=Mpegv_frame_rate[frame_rate_code];
+ SizeToAnalyse_Begin=bit_rate_value*50*2; //standard delay between TimeStamps is 0.7s, we try 2s to be sure to have at least 2 timestamps (for integrity checking)
+ SizeToAnalyse_End=bit_rate_value*50*2; //standard delay between TimeStamps is 0.7s, we try 2s to be sure
+ }
+
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse)
+ block_count=6; //chroma_format default to 4:2:0
+ #endif //MEDIAINFO_MACROBLOCKS
+
+ //Setting as OK
+ sequence_header_IsParsed=true;
+ if (Frame_Count==0 && FrameInfo.DTS==(int64u)-1)
+ FrameInfo.DTS=0; //No DTS in container
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "B4"
+void File_Mpegv::sequence_error()
+{
+ Element_Name("sequence_error");
+}
+
+//---------------------------------------------------------------------------
+// Packet "B5"
+void File_Mpegv::extension_start()
+{
+ Element_Name("extension_start");
+ MPEG_Version=2; //extension_start only exists in MPEG-2 specs
+
+ //Parsing
+ int8u extension_start_code_identifier;
+ BS_Begin();
+ Get_S1 ( 4, extension_start_code_identifier, "extension_start_code_identifier"); Param_Info1(Mpegv_extension_start_code_identifier[extension_start_code_identifier]);
+ Element_Info1(Mpegv_extension_start_code_identifier[extension_start_code_identifier]);
+
+ switch (extension_start_code_identifier)
+ {
+ case 1 :{ //Sequence
+ //Parsing
+ Peek_SB(profile_and_level_indication_escape);
+ if (profile_and_level_indication_escape)
+ {
+ Get_S1 ( 8, profile_and_level_indication, "profile_and_level_indication"); Param_Info1(Mpegv_profile_and_level_indication(profile_and_level_indication));
+ }
+ else
+ {
+ Skip_SB( "profile_and_level_indication_escape");
+ Get_S1 ( 3, profile_and_level_indication_profile, "profile_and_level_indication_profile"); Param_Info1(Mpegv_profile_and_level_indication_profile[profile_and_level_indication_profile]);
+ Get_S1 ( 4, profile_and_level_indication_level, "profile_and_level_indication_level"); Param_Info1(Mpegv_profile_and_level_indication_level[profile_and_level_indication_level]);
+ }
+ Get_SB ( progressive_sequence, "progressive_sequence");
+ Get_S1 ( 2, chroma_format, "chroma_format"); Param_Info1(Mpegv_Colorimetry_format[chroma_format]);
+ Get_S1 ( 2, horizontal_size_extension, "horizontal_size_extension");
+ Get_S1 ( 2, vertical_size_extension, "vertical_size_extension");
+ Get_S2 (12, bit_rate_extension, "bit_rate_extension");
+ Mark_1 ();
+ Get_S1 ( 8, vbv_buffer_size_extension, "vbv_buffer_size_extension"); Param_Info2(2*1024*((((int32u)vbv_buffer_size_extension)<<10)+vbv_buffer_size_value), " bytes");
+ Skip_SB( "low_delay");
+ Get_S1 ( 2, frame_rate_extension_n, "frame_rate_extension_n");
+ Get_S1 ( 5, frame_rate_extension_d, "frame_rate_extension_d");
+ BS_End();
+
+ FILLING_BEGIN();
+ if (frame_rate_extension_d)
+ FrameRate=(float)frame_rate_extension_n/frame_rate_extension_d;
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse)
+ block_count=Mpegv_block_count[chroma_format];
+ #endif //MEDIAINFO_MACROBLOCKS
+ FILLING_END();
+ }
+ break;
+ case 2 :{ //Sequence Display
+ //Parsing
+ Get_S1 ( 3, video_format, "video_format"); Param_Info1(Mpegv_video_format[video_format]);
+ TEST_SB_SKIP( "colour_description");
+ Get_S1 (8, colour_primaries, "colour_primaries"); Param_Info1(Mpegv_colour_primaries(colour_primaries));
+ Get_S1 (8, transfer_characteristics, "transfer_characteristics"); Param_Info1(Mpegv_transfer_characteristics(transfer_characteristics));
+ Get_S1 (8, matrix_coefficients, "matrix_coefficients"); Param_Info1(Mpegv_matrix_coefficients(matrix_coefficients));
+ TEST_SB_END();
+ Get_S2 (14, display_horizontal_size, "display_horizontal_size");
+ Mark_1 ();
+ Get_S2 (14, display_vertical_size, "display_vertical_size");
+ BS_End();
+ }
+ break;
+ case 5 :{ //Sequence Scalable Extension
+ //Parsing
+ Skip_S2(10, "lower_layer_temporal_reference");
+ Mark_1();
+ Skip_S2(15, "lower_layer_horizontal_offset");
+ Mark_1();
+ Skip_S2(15, "lower_layer_vertical_offset");
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse)
+ {
+ sequence_scalable_extension_Present=true;
+ Get_S1 ( 2, spatial_temporal_weight_code_table_index, "spatial_temporal_weight_code_table_index");
+ }
+ else
+ #endif //MEDIAINFO_MACROBLOCKS
+ Skip_S1( 2, "spatial_temporal_weight_code_table_index");
+ Skip_SB( "lower_layer_progressive_frame");
+ Skip_SB( "lower_layer_deinterlaced_field_select");
+ BS_End();
+ }
+ break;
+ case 8 :{ //Picture Coding
+ //Parsing
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse)
+ {
+ Get_S1 ( 4, f_code[0][0], "f_code_forward_horizontal");
+ Get_S1 ( 4, f_code[0][1], "f_code_forward_vertical");
+ Get_S1 ( 4, f_code[1][0], "f_code_backward_horizontal");
+ Get_S1 ( 4, f_code[1][1], "f_code_backward_vertical");
+ }
+ else
+ #endif //MEDIAINFO_MACROBLOCKS
+ {
+ Skip_S1( 4, "f_code_forward_horizontal");
+ Skip_S1( 4, "f_code_forward_vertical");
+ Skip_S1( 4, "f_code_backward_horizontal");
+ Skip_S1( 4, "f_code_backward_vertical");
+ }
+ Get_S1 ( 2, intra_dc_precision, "intra_dc_precision");
+ Get_S1 ( 2, picture_structure, "picture_structure"); Param_Info1(Mpegv_picture_structure[picture_structure]);
+ Get_SB ( top_field_first, "top_field_first");
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse)
+ {
+ Get_SB ( frame_pred_frame_dct, "frame_pred_frame_dct");
+ Get_SB ( concealment_motion_vectors, "concealment_motion_vectors");
+ }
+ else
+ #endif //MEDIAINFO_MACROBLOCKS
+ {
+ Skip_SB( "frame_pred_frame_dct");
+ Skip_SB( "concealment_motion_vectors");
+ }
+ Skip_SB( "q_scale_type");
+ #if MEDIAINFO_MACROBLOCKS
+ if (Macroblocks_Parse)
+ {
+ Get_SB ( intra_vlc_format, "intra_vlc_format");
+ }
+ else
+ #endif //MEDIAINFO_MACROBLOCKS
+ {
+ Skip_SB( "intra_vlc_format");
+ }
+ Skip_SB( "alternate_scan");
+ Get_SB ( repeat_first_field, "repeat_first_field");
+ Skip_SB( "chroma_420_type");
+ Get_SB ( progressive_frame, "progressive_frame");
+ TEST_SB_SKIP( "composite_display_flag");
+ Skip_SB( "v_axis");
+ Skip_S1( 3, "field_sequence");
+ Skip_SB( "sub_carrier");
+ Skip_S1( 7, "burst_amplitude");
+ Skip_S1( 8, "sub_carrier_phase");
+ TEST_SB_END();
+ BS_End();
+ }
+
+ FILLING_BEGIN();
+ if (progressive_frame==false)
+ {
+ if (picture_structure==3) //Frame
+ {
+ if (top_field_first)
+ Interlaced_Top++;
+ else
+ Interlaced_Bottom++;
+ FirstFieldFound=false;
+ if (TemporalReference_Offset+temporal_reference>=TemporalReference.size())
+ TemporalReference.resize(TemporalReference_Offset+temporal_reference+1);
+ if (TemporalReference[TemporalReference_Offset+temporal_reference]==NULL)
+ TemporalReference[TemporalReference_Offset+temporal_reference]=new temporalreference;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->picture_coding_type=picture_coding_type;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->progressive_frame=progressive_frame;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->picture_structure=picture_structure;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->top_field_first=top_field_first;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->repeat_first_field=repeat_first_field;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->HasPictureCoding=true;
+ }
+ else //Field
+ {
+ if (!FirstFieldFound)
+ {
+ if (picture_structure==1) //-Top
+ Interlaced_Top++;
+ else //-Bottom
+ Interlaced_Bottom++;
+ }
+ FirstFieldFound=!FirstFieldFound;
+ }
+ }
+ else
+ {
+ progressive_frame_Count++;
+ if (top_field_first)
+ Interlaced_Top++;
+ else
+ Interlaced_Bottom++;
+ if (picture_structure==3) //Frame
+ {
+ if (TemporalReference_Offset+temporal_reference>=TemporalReference.size())
+ TemporalReference.resize(TemporalReference_Offset+temporal_reference+1);
+ if (TemporalReference[TemporalReference_Offset+temporal_reference]==NULL)
+ TemporalReference[TemporalReference_Offset+temporal_reference]=new temporalreference;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->picture_coding_type=picture_coding_type;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->progressive_frame=progressive_frame;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->picture_structure=picture_structure;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->top_field_first=top_field_first;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->repeat_first_field=repeat_first_field;
+ TemporalReference[TemporalReference_Offset+temporal_reference]->HasPictureCoding=true;
+ }
+ FILLING_END();
+ }
+ break;
+ case 9 :{ //Picture Spatial Scalable Extension
+ //Parsing
+ Skip_S1(4, "data");
+ BS_End();
+ Skip_XX(Element_Size-Element_Offset, "data");
+ }
+ break;
+ case 10 :{ //Picture Temporal Scalable Extension
+ //Parsing
+ Skip_S1(4, "data");
+ BS_End();
+ Skip_XX(Element_Size-Element_Offset, "data");
+ }
+ break;
+ default:{
+ //Parsing
+ Skip_S1(4, "data");
+ BS_End();
+ Skip_XX(Element_Size-Element_Offset, "data");
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+// Packet "B7"
+void File_Mpegv::sequence_end()
+{
+ Element_Name("sequence_end");
+
+ if (!Status[IsFilled] && sequence_header_IsParsed)
+ {
+ //End of file, and we have some frames
+ Accept("MPEG Video");
+ Finish("MPEG Video");
+ }
+}
+
+//---------------------------------------------------------------------------
+// Packet "B8"
+void File_Mpegv::group_start()
+{
+ if (!Status[IsAccepted])
+ {
+ if (!NextCode_Test())
+ return;
+ }
+ Element_Name("group_start");
+
+ //Reading
+ int8u Hours, Minutes, Seconds, Frames;
+ bool drop_frame_flag, closed_gop, broken_link;
+ #if MEDIAINFO_TRACE
+ if (Trace_Activated)
+ {
+ //Parsing
+ BS_Begin();
+ Get_SB ( drop_frame_flag, "time_code_drop_frame_flag");
+ Get_S1 ( 5, Hours, "time_code_time_code_hours");
+ Get_S1 ( 6, Minutes, "time_code_time_code_minutes");
+ Mark_1();
+ Get_S1 ( 6, Seconds, "time_code_time_code_seconds");
+ Get_S1 ( 6, Frames, "time_code_time_code_pictures");
+ Get_SB ( closed_gop, "closed_gop");
+ Get_SB ( broken_link, "broken_link");
+ BS_End();
+ Ztring Time;
+ Time+=Ztring::ToZtring(Hours);
+ Time+=_T(':');
+ Time+=Ztring::ToZtring(Minutes);
+ Time+=_T(':');
+ Time+=Ztring::ToZtring(Seconds);
+ if (FrameRate!=0)
+ {
+ Time+=_T('.');
+ Time+=Ztring::ToZtring(Frames*1000/FrameRate, 0);
+ }
+ Element_Info1(Time);
+ }
+ else
+ {
+ #endif //MEDIAINFO_TRACE
+ //Parsing
+ size_t Buffer_Pos=Buffer_Offset+(size_t)Element_Offset;
+ drop_frame_flag = (Buffer[Buffer_Pos ]&0x80)?true:false;
+ Hours =((Buffer[Buffer_Pos ]&0x7C)>> 2);
+ Minutes =((Buffer[Buffer_Pos ]&0x03)<< 4)
+ | ((Buffer[Buffer_Pos+1] )>> 4);
+ Seconds =((Buffer[Buffer_Pos+1]&0x07)<< 3)
+ | ((Buffer[Buffer_Pos+2] )>> 5);
+ Frames =((Buffer[Buffer_Pos+2]&0x1F)<< 1)
+ | ((Buffer[Buffer_Pos+3] )>> 7);
+ closed_gop = (Buffer[Buffer_Pos+3]&0x40)?true:false;
+ broken_link = (Buffer[Buffer_Pos+3]&0x20)?true:false;
+ Element_Offset+=4;
+ #if MEDIAINFO_TRACE
+ }
+ #endif //MEDIAINFO_TRACE
+
+ FILLING_BEGIN();
+ //NextCode
+ if (!Status[IsAccepted])
+ {
+ NextCode_Clear();
+ NextCode_Add(0x00);
+ NextCode_Add(0xB2);
+ NextCode_Add(0xB5);
+ NextCode_Add(0xB8);
+ }
+
+ if (TimeCodeIsNotTrustable)
+ return;
+
+ if (Time_Current_Seconds==0 && Time_Current_Frames==0 && Hours==0 && Minutes==0 && Seconds==0 && Frames==0)
+ {
+ //Time code is always 0
+ TimeCodeIsNotTrustable=true;
+ Time_Begin_Seconds=(size_t)-1;
+ Time_End_Seconds=(size_t)-1;
+ return;
+ }
+
+ //Calculating
+ Time_Current_Seconds=60*60*Hours+60*Minutes+Seconds;
+ Time_Current_Frames =Frames;
+
+ if (!group_start_IsParsed)
+ group_start_IsParsed=true;
+ if (!group_start_FirstPass)
+ {
+ group_start_FirstPass=true;
+ group_start_drop_frame_flag=drop_frame_flag;
+ group_start_closed_gop=closed_gop;
+ group_start_broken_link=broken_link;
+ }
+
+ RefFramesCount=0;
+
+ //Autorisation of other streams
+ if (Searching_TimeStamp_Start_DoneOneTime)
+ Streams[0xB8].Searching_TimeStamp_Start=false; //group_start
+ else
+ Searching_TimeStamp_Start_DoneOneTime=true;
+ Streams[0x00].Searching_TimeStamp_End=true; //picture_start
+ FILLING_END();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_MPEGV_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpegv.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpegv.h
new file mode 100644
index 000000000..3f0486b5c
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Mpegv.h
@@ -0,0 +1,341 @@
+// File_Mpegv - Info for MPEG Video files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MPEG Video files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_MpegvH
+#define MediaInfo_MpegvH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#if defined(MEDIAINFO_ANCILLARY_YES)
+ #include <MediaInfo/Multiple/File_Ancillary.h>
+#endif //defined(MEDIAINFO_ANCILLARY_YES)
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Mpegv
+//***************************************************************************
+
+class File_Mpegv : public File__Analyze
+{
+public :
+ //In
+ int8u MPEG_Version;
+ int64u Frame_Count_Valid;
+ bool FrameIsAlwaysComplete;
+ bool TimeCodeIsNotTrustable;
+ #if defined(MEDIAINFO_ANCILLARY_YES)
+ File_Ancillary** Ancillary;
+ #endif //defined(MEDIAINFO_ANCILLARY_YES)
+
+ //Constructor/Destructor
+ File_Mpegv();
+ ~File_Mpegv();
+
+private :
+ //Streams management
+ void Streams_Accept();
+ void Streams_Update();
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin() {return FileHeader_Begin_0x000001();}
+
+ //Buffer - Synchro
+ bool Synchronize() {return Synchronize_0x000001();}
+ bool Synched_Test();
+ void Synched_Init();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test();
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Per element
+ void Header_Parse();
+ bool Header_Parser_QuickSearch();
+ bool Header_Parser_Fill_Size();
+ void Data_Parse();
+
+ //EOF
+ void Detect_EOF();
+
+ //Elements
+ void picture_start();
+ void slice_start();
+ #if MEDIAINFO_MACROBLOCKS
+ void slice_start_macroblock();
+ void slice_start_macroblock_motion_vectors(bool s);
+ void slice_start_macroblock_motion_vectors_motion_vector(bool r, bool s);
+ void slice_start_macroblock_coded_block_pattern();
+ void slice_start_macroblock_block(int8u i);
+ #endif //MEDIAINFO_MACROBLOCKS
+ void user_data_start();
+ void user_data_start_3();
+ void user_data_start_CC();
+ void user_data_start_DTG1();
+ void user_data_start_GA94();
+ void user_data_start_GA94_03();
+ void user_data_start_GA94_06();
+ void sequence_header();
+ void sequence_error();
+ void extension_start();
+ void sequence_end();
+ void group_start();
+
+ //Streams
+ struct stream
+ {
+ bool Searching_Payload;
+ bool Searching_TimeStamp_Start;
+ bool Searching_TimeStamp_End;
+
+ stream()
+ {
+ Searching_Payload=false;
+ Searching_TimeStamp_Start=false;
+ Searching_TimeStamp_End=false;
+ }
+ };
+ std::vector<stream> Streams;
+
+ //Temporal reference
+ struct temporalreference
+ {
+ struct buffer_data
+ {
+ size_t Size;
+ int8u* Data;
+
+ buffer_data()
+ {
+ Size=0;
+ Data=NULL;
+ }
+
+ ~buffer_data()
+ {
+ delete[] Data; //Data=NULL;
+ }
+ };
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ buffer_data* GA94_03;
+ #endif //MEDIAINFO_DTVCCTRANSPORT_YES
+ #if defined(MEDIAINFO_SCTE20_YES)
+ std::vector<buffer_data*> Scte;
+ std::vector<bool> Scte_Parsed;
+ #endif //MEDIAINFO_SCTE20_YES
+
+ int8u picture_coding_type;
+ int8u picture_structure;
+
+ bool IsValid;
+ bool HasPictureCoding;
+
+ bool progressive_frame;
+ bool top_field_first;
+ bool repeat_first_field;
+
+ temporalreference()
+ {
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ GA94_03=NULL;
+ #endif //MEDIAINFO_DTVCCTRANSPORT_YES
+ picture_coding_type=(int8u)-1;
+ picture_structure=(int8u)-1;
+ IsValid=false;
+ HasPictureCoding=false;
+ }
+
+ ~temporalreference()
+ {
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ delete GA94_03; //GA94_03=NULL;
+ #endif //MEDIAINFO_DTVCCTRANSPORT_YES
+ #if defined(MEDIAINFO_SCTE20_YES)
+ for (size_t Pos=0; Pos<Scte.size(); Pos++)
+ delete Scte[Pos]; //Scte[Pos]=NULL;
+ #endif //MEDIAINFO_SCTE20_YES
+ }
+ };
+ std::vector<temporalreference*> TemporalReference; //per temporal_reference
+ size_t TemporalReference_Offset;
+ struct text_position
+ {
+ File__Analyze** Parser;
+ size_t StreamPos;
+
+ text_position()
+ {
+ Parser=NULL;
+ StreamPos=(size_t)-1;
+ }
+
+ text_position(File__Analyze* &Parser_)
+ {
+ Parser=&Parser_;
+ StreamPos=0;
+ }
+ };
+ std::vector<text_position> Text_Positions;
+ #if defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ File__Analyze* GA94_03_Parser;
+ size_t GA94_03_TemporalReference_Offset;
+ bool GA94_03_IsPresent;
+ File__Analyze* CC___Parser;
+ bool CC___IsPresent;
+ #endif //defined(MEDIAINFO_DTVCCTRANSPORT_YES)
+ #if defined(MEDIAINFO_SCTE20_YES)
+ File__Analyze* Scte_Parser;
+ size_t Scte_TemporalReference_Offset;
+ bool Scte_IsPresent;
+ #endif //defined(MEDIAINFO_SCTE20_YES)
+ #if defined(MEDIAINFO_AFDBARDATA_YES)
+ File__Analyze* DTG1_Parser;
+ File__Analyze* GA94_06_Parser;
+ #endif //defined(MEDIAINFO_AFDBARDATA_YES)
+ #if defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_CDP_YES)
+ File__Analyze* Cdp_Parser;
+ bool Cdp_IsPresent;
+ #endif //defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_CDP_YES)
+ #if defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_AFDBARDATA_YES)
+ File__Analyze* AfdBarData_Parser;
+ #endif //defined(MEDIAINFO_GXF_YES) && defined(MEDIAINFO_AFDBARDATA_YES)
+
+ //Temp
+ Ztring Library;
+ Ztring Library_Name;
+ Ztring Library_Version;
+ Ztring Matrix_intra;
+ Ztring Matrix_nonintra;
+ size_t BVOP_Count;
+ size_t progressive_frame_Count;
+ size_t Interlaced_Top;
+ size_t Interlaced_Bottom;
+ size_t Time_Current_Seconds;
+ size_t Time_Begin_Seconds;
+ size_t Time_End_Seconds;
+ int64u SizeToAnalyse_Begin; //Total size of a chunk to analyse, it may be changed by the parser
+ int64u SizeToAnalyse_End; //Total size of a chunk to analyse, it may be changed by the parser
+ int32u bit_rate_value;
+ float32 FrameRate;
+ int16u horizontal_size_value;
+ int16u vertical_size_value;
+ int16u bit_rate_extension;
+ int16u temporal_reference;
+ int16u temporal_reference_Old;
+ int16u display_horizontal_size;
+ int16u display_vertical_size;
+ int16u vbv_delay;
+ int16u vbv_buffer_size_value;
+ int8u Time_Current_Frames;
+ int8u Time_Begin_Frames;
+ int8u Time_End_Frames;
+ int8u picture_coding_type;
+ int8u aspect_ratio_information;
+ int8u frame_rate_code;
+ int8u profile_and_level_indication;
+ int8u profile_and_level_indication_profile;
+ int8u profile_and_level_indication_level;
+ int8u chroma_format;
+ int8u horizontal_size_extension;
+ int8u vertical_size_extension;
+ int8u frame_rate_extension_n;
+ int8u frame_rate_extension_d;
+ int8u video_format;
+ int8u colour_primaries;
+ int8u transfer_characteristics;
+ int8u matrix_coefficients;
+ int8u picture_structure;
+ int8u vbv_buffer_size_extension;
+ int8u intra_dc_precision;
+ bool load_intra_quantiser_matrix;
+ bool load_non_intra_quantiser_matrix;
+ bool progressive_sequence;
+ bool progressive_frame;
+ bool top_field_first;
+ bool repeat_first_field;
+ bool FirstFieldFound;
+ bool sequence_header_IsParsed;
+ bool group_start_IsParsed;
+ bool group_start_FirstPass;
+ bool group_start_drop_frame_flag;
+ bool group_start_closed_gop;
+ bool group_start_broken_link;
+ bool Searching_TimeStamp_Start_DoneOneTime;
+ bool Parsing_End_ForDTS;
+ bool bit_rate_value_IsValid;
+ bool profile_and_level_indication_escape;
+ int8u RefFramesCount;
+ int8u BVOPsSinceLastRefFrames;
+ int16u temporal_reference_LastIFrame;
+ int64u PTS_LastIFrame;
+ int64u tc;
+ bool IFrame_IsParsed;
+
+ #if MEDIAINFO_MACROBLOCKS
+ int64u macroblock_x;
+ int64u macroblock_x_PerFrame;
+ int64u macroblock_y_PerFrame;
+ int16u cbp;
+ int8u frame_motion_type;
+ int8u field_motion_type;
+ int8u spatial_temporal_weight_code;
+ int8u block_count; //Computed from chroma_format
+ int8u macroblock_type; //Temp
+ int8u spatial_temporal_weight_code_table_index;
+ int8u f_code[2][2];
+ bool Macroblocks_Parse;
+ bool sequence_scalable_extension_Present;
+ bool frame_pred_frame_dct;
+ bool concealment_motion_vectors;
+ bool intra_vlc_format;
+ vlc_fast macroblock_address_increment_Vlc;
+ vlc_fast dct_dc_size_luminance;
+ vlc_fast dct_dc_size_chrominance;
+ vlc_fast dct_coefficients_0;
+ vlc_fast dct_coefficients_1;
+ vlc_fast macroblock_type_I;
+ vlc_fast macroblock_type_P;
+ vlc_fast macroblock_type_B;
+ vlc_fast motion_code;
+ vlc_fast dmvector;
+ vlc_fast coded_block_pattern;
+ #endif //MEDIAINFO_MACROBLOCKS
+
+ #if MEDIAINFO_IBI
+ bool Ibi_SliceParsed;
+ #endif //MEDIAINFO_IBI
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Theora.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Theora.cpp
new file mode 100644
index 000000000..5f7c89453
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Theora.cpp
@@ -0,0 +1,145 @@
+// File_Theora - Info for Theora files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Note : the buffer must be given in ONE call
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_THEORA_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Theora.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Format
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Theora::Header_Parse()
+{
+ //Filling
+ Header_Fill_Code(0, "Theora");
+ Header_Fill_Size(Element_Size);
+}
+
+//---------------------------------------------------------------------------
+void File_Theora::Data_Parse()
+{
+ //Parsing
+ if (Status[IsAccepted])
+ Setup();
+ else
+ Identification();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Theora::Identification()
+{
+ Element_Name("Identification");
+
+ //Parsing
+ int32u Version, PICW=0, PICH=0, FRN=0, FRD=0, PARN=0, PARD=0, NOMBR=0;
+ Skip_B1 ( "Signature");
+ Skip_Local(6, "Signature");
+ Get_B3 (Version, "Version");
+ if ((Version&0x030200)==0x030200) //Version 3.2.x
+ {
+ Skip_B2( "FMBW");
+ Skip_B2( "FMBH");
+ Get_B3 (PICW, "PICW");
+ Get_B3 (PICH, "PICH");
+ Skip_B1( "PICX");
+ Skip_B1( "PICY");
+ Get_B4 (FRN, "FRN");
+ Get_B4 (FRD, "FRD");
+ Get_B3 (PARN, "PARN");
+ Get_B3 (PARD, "PARD");
+ Skip_B1( "CS"); // //0=4:2:0, 2=4:2:2, 3=4:4:4
+ Get_B3 (NOMBR, "NOMBR"); //The nominal bitrate of the stream
+ BS_Begin();
+ Skip_BS( 6, "QUAL"); //The quality hint.
+ Skip_BS( 5, "KFGSHIFT");
+ Skip_BS( 2, "PF"); //The Pixel Format
+ Skip_BS( 3, "Reserved");
+ BS_End();
+ }
+
+ //Filling
+ FILLING_BEGIN()
+ Accept("Theora");
+
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, StreamPos_Last, Video_Format, "Theora");
+ Fill(Stream_Video, StreamPos_Last, Video_Codec, "Theora");
+ if ((Version&0x030200)!=0x030200) //Version 3.2.x
+ return;
+ if (FRN && FRD)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, ((float)FRN)/FRD, 3);
+ float PixelRatio=1;
+ if (PARN && PARD)
+ PixelRatio=((float)PARN)/(float)PARD;
+ Fill(Stream_Video, StreamPos_Last, Video_Width, PICW);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, PICH);
+ Fill(Stream_Video, StreamPos_Last, Video_DisplayAspectRatio, ((float)PICW)/((float)PICH)*PixelRatio, 3, true);
+ if (NOMBR)
+ Fill(Stream_Video, StreamPos_Last, Video_BitRate_Nominal, NOMBR);
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Theora::Setup()
+{
+ Element_Name("Setup");
+
+ //Parsing
+ Skip_XX(Element_Size, "Unknown");
+
+ Finish("Theora");
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_THEORA_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Theora.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Theora.h
new file mode 100644
index 000000000..1f8cec44a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Theora.h
@@ -0,0 +1,58 @@
+// File_Theora - Info for Theora files
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about Theora files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_File_TheoraH
+#define MediaInfo_File_TheoraH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Theora
+//***************************************************************************
+
+class File_Theora : public File__Analyze
+{
+private :
+ //Buffer - Per element
+ void Header_Parse();
+ void Data_Parse();
+
+ //Elements
+ void Identification();
+ void Setup();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc1.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc1.cpp
new file mode 100644
index 000000000..a0200bed2
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc1.cpp
@@ -0,0 +1,1143 @@
+// File_Vc1 - Info for VC-1 files
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_VC1_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Vc1.h"
+#include "ZenLib/BitStream.h"
+#undef FILLING_BEGIN
+#define FILLING_BEGIN() \
+ while (Element_Offset<Element_Size && Buffer[Buffer_Offset+(size_t)Element_Offset]==0x00) \
+ Element_Offset++; \
+ if (Element_Offset!=Element_Size) \
+ Trusted_IsNot("Size error"); \
+ else if (Element_IsOK()) \
+ {
+#include <cmath>
+#if MEDIAINFO_EVENTS
+ #include "MediaInfo/MediaInfo_Config_MediaInfo.h"
+ #include "MediaInfo/MediaInfo_Events.h"
+#endif //MEDIAINFO_EVENTS
+using namespace std;
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const char* Vc1_Profile[]=
+{
+ "Simple",
+ "Main",
+ "Complex",
+ "Advanced",
+};
+
+//---------------------------------------------------------------------------
+const char* Vc1_ColorimetryFormat[]=
+{
+ "",
+ "4:2:0",
+ "",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const float32 Vc1_PixelAspectRatio[]=
+{
+ (float32)1, //Reserved
+ (float32)1,
+ (float32)12/(float32)11,
+ (float32)10/(float32)11,
+ (float32)16/(float32)11,
+ (float32)40/(float32)33,
+ (float32)24/(float32)11,
+ (float32)20/(float32)11,
+ (float32)32/(float32)11,
+ (float32)80/(float32)33,
+ (float32)18/(float32)11,
+ (float32)15/(float32)11,
+ (float32)64/(float32)33,
+ (float32)160/(float32)99,
+ (float32)1, //Reserved
+ (float32)1, //Custom
+};
+
+//---------------------------------------------------------------------------
+float32 Vc1_FrameRate_enr(int8u Code)
+{
+ switch (Code)
+ {
+ case 0x01 : return (float32)24000;
+ case 0x02 : return (float32)25000;
+ case 0x03 : return (float32)30000;
+ case 0x04 : return (float32)50000;
+ case 0x05 : return (float32)60000;
+ case 0x06 : return (float32)48000;
+ case 0x07 : return (float32)72000;
+ default : return (float32)0;
+ }
+}
+
+//---------------------------------------------------------------------------
+float32 Vc1_FrameRate_dr(int8u Code)
+{
+ switch (Code)
+ {
+ case 0x01 : return (float32)1000;
+ case 0x02 : return (float32)1001;
+ default : return (float32)0;
+ }
+}
+
+//---------------------------------------------------------------------------
+const char* Vc1_Type[]=
+{
+ "I",
+ "P",
+ "B",
+ "BI",
+ "Skipped",
+};
+
+//---------------------------------------------------------------------------
+const char* Vc1_PictureFormat[]=
+{
+ "Progressive frame",
+ "Interlaced frame",
+ "Two interlaced fields",
+ "",
+};
+
+//---------------------------------------------------------------------------
+const int8u Vc1_FieldTypeTable[][2]=
+{
+ {0, 0},
+ {0, 1},
+ {1, 0},
+ {1, 1},
+ {2, 2},
+ {2, 3},
+ {3, 2},
+ {3, 3},
+};
+
+//---------------------------------------------------------------------------
+const File__Analyze::vlc Vc1_ptype[]=
+{
+ // macroblock_address_increment
+ { 0 , 1 , 0 , 0 , 1 },
+ { 2 , 1 , 0 , 0 , 2 },
+ { 6 , 1 , 0 , 0 , 0 },
+ { 14 , 1 , 0 , 0 , 3 },
+ { 15 , 0 , 0 , 0 , 4 },
+ VLC_END
+};
+
+//---------------------------------------------------------------------------
+int32u Vc1_bfraction(int8u Size, int32u Value)
+{
+ switch (Size)
+ {
+ case 3 :
+ switch (Value)
+ {
+ case 0x00 : return 0x00;
+ case 0x01 : return 0x01;
+ case 0x02 : return 0x02;
+ case 0x03 : return 0x03;
+ case 0x04 : return 0x04;
+ case 0x05 : return 0x05;
+ case 0x06 : return 0x06;
+ default : return (int32u)-1;
+ }
+ case 7 :
+ switch (Value)
+ {
+ case 0x70 : return 0x70;
+ case 0x71 : return 0x71;
+ case 0x72 : return 0x72;
+ case 0x73 : return 0x73;
+ case 0x74 : return 0x74;
+ case 0x75 : return 0x75;
+ case 0x76 : return 0x76;
+ case 0x77 : return 0x77;
+ case 0x78 : return 0x78;
+ case 0x79 : return 0x79;
+ case 0x7A : return 0x7A;
+ case 0x7B : return 0x7B;
+ case 0x7C : return 0x7C;
+ case 0x7D : return 0x7D;
+ case 0x7E : return 0x7E;
+ case 0x7F : return 0x7F;
+ default : return (int32u)-1;
+ }
+ default: return (int32u)-1;
+ }
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Vc1::File_Vc1()
+:File__Analyze()
+{
+ //Config
+ #if MEDIAINFO_EVENTS
+ ParserIDs[0]=MediaInfo_Parser_Vc1;
+ StreamIDs_Width[0]=0;
+ #endif //MEDIAINFO_EVENTS
+ MustSynchronize=true;
+ Buffer_TotalBytes_FirstSynched_Max=64*1024;
+ PTS_DTS_Needed=true;
+ IsRawStream=true;
+ Frame_Count_NotParsedIncluded=0;
+
+ //In
+ Frame_Count_Valid=30;
+ FrameIsAlwaysComplete=false;
+ From_WMV3=false;
+ Only_0D=false;
+
+ //Temp
+ EntryPoint_Parsed=false;
+ FrameRate=0;
+ RefFramesCount=0;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Vc1::Streams_Fill()
+{
+ //Calculating - PixelAspectRatio
+ float32 PixelAspectRatio;
+ if (AspectRatio!=0x0F)
+ PixelAspectRatio=Vc1_PixelAspectRatio[AspectRatio];
+ else if (AspectRatioY)
+ PixelAspectRatio=((float)AspectRatioX)/((float)AspectRatioY);
+ else
+ PixelAspectRatio=1; //Unknown
+
+ //Filling
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "VC-1");
+ Fill(Stream_Video, 0, Video_Codec, From_WMV3?"WMV3":"VC-1"); //For compatibility with the old reaction
+ Fill(Stream_Video, 0, Video_BitDepth, 8);
+
+ Ztring Profile=Vc1_Profile[profile];
+ if (profile==3)
+ Profile+=_T("@L")+Ztring::ToZtring(level);
+ Fill(Stream_Video, 0, Video_Format_Profile, Profile);
+ Fill(Stream_Video, 0, Video_Codec_Profile, Profile);
+ Fill(Stream_Video, 0, Video_Colorimetry, Vc1_ColorimetryFormat[colordiff_format]);
+ if (coded_width && coded_height)
+ {
+ Fill(Stream_Video, StreamPos_Last, Video_Width, (coded_width+1)*2);
+ Fill(Stream_Video, StreamPos_Last, Video_Height, (coded_height+1)*2);
+ }
+ if (PixelAspectRatio!=0)
+ Fill(Stream_Video, 0, Video_PixelAspectRatio, PixelAspectRatio, 3, true);
+ if (FrameRate!=0)
+ Fill(Stream_Video, StreamPos_Last, Video_FrameRate, FrameRate);
+
+ //Interlacement
+ if (!interlace || (PictureFormat_Count[1]==0 && PictureFormat_Count[2]==0)) //No interlaced frame/field
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Progressive");
+ Fill(Stream_Video, 0, Video_Interlacement, "PPF");
+ }
+ else if (PictureFormat_Count[0]>0) //Interlaced and non interlaced frames/fields
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Mixed");
+ Fill(Stream_Video, 0, Video_Interlacement, "Mixed");
+ }
+ else
+ {
+ Fill(Stream_Video, 0, Video_ScanType, "Interlaced");
+ Fill(Stream_Video, 0, Video_Interlacement, "Interlaced");
+ }
+ if (Frame_Count>0 && interlace)
+ Fill(Stream_Video, 0, Video_ScanOrder, Interlaced_Bottom?"BFF":"TFF");
+ std::string TempRef;
+ for (std::map<int16u, temporalreference>::iterator Temp=TemporalReference.begin(); Temp!=TemporalReference.end(); Temp++)
+ {
+ TempRef+=Temp->second.top_field_first?"T":"B";
+ TempRef+=Temp->second.repeat_first_field?"3":"2";
+ }
+ if (TempRef.find('3')!=std::string::npos) //A pulldown maybe is detected
+ {
+ if (TempRef.find("T2T3B2B3T2T3B2B3")!=std::string::npos
+ || TempRef.find("B2B3T2T3B2B3T2T3")!=std::string::npos)
+ {
+ Fill(Stream_Video, 0, Video_ScanOrder, "2:3 Pulldown", Unlimited, true, true);
+ Fill(Stream_Video, 0, Video_FrameRate, FrameRate*24/30, 3, true); //Real framerate
+ Fill(Stream_Video, 0, Video_ScanType, "Progressive", Unlimited, true, true);
+ Fill(Stream_Video, 0, Video_Interlacement, "PPF", Unlimited, true, true);
+ }
+ if (TempRef.find("T2T2T2T2T2T2T2T2T2T2T2T3B2B2B2B2B2B2B2B2B2B2B2B3")!=std::string::npos
+ || TempRef.find("B2B2B2B2B2B2B2B2B2B2B2B3T2T2T2T2T2T2T2T2T2T2T2T3")!=std::string::npos)
+ {
+ Fill(Stream_Video, 0, Video_ScanOrder, "2:2:2:2:2:2:2:2:2:2:2:3 Pulldown", Unlimited, true, true);
+ Fill(Stream_Video, 0, Video_FrameRate, FrameRate*24/25, 3, true); //Real framerate
+ Fill(Stream_Video, 0, Video_ScanType, "Progressive", Unlimited, true, true);
+ Fill(Stream_Video, 0, Video_Interlacement, "PPF", Unlimited, true, true);
+ }
+ }
+
+ //Buffer
+ for (size_t Pos=0; Pos<hrd_buffers.size(); Pos++)
+ Fill(Stream_Video, 0, Video_BufferSize, hrd_buffers[Pos]);
+}
+
+//---------------------------------------------------------------------------
+void File_Vc1::Streams_Finish()
+{
+ if (PTS_End>PTS_Begin)
+ Fill(Stream_Video, 0, Video_Duration, float64_int64s(((float64)(PTS_End-PTS_Begin))/1000000));
+
+ #if MEDIAINFO_IBI
+ int64u Numerator=0, Denominator=0;
+ if (framerate_present)
+ {
+ if (framerate_form)
+ {
+ Numerator=framerateexp+1;
+ Denominator=32;
+ }
+ else if (Vc1_FrameRate_dr(frameratecode_dr))
+ {
+ Numerator=(int64u)Vc1_FrameRate_enr(frameratecode_enr);
+ Denominator=(int64u)Vc1_FrameRate_dr(frameratecode_dr);
+ }
+ }
+ if (Numerator)
+ Ibi_Stream_Finish(Numerator, Denominator);
+ #endif //MEDIAINFO_IBI
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Vc1::FileHeader_Begin()
+{
+ if (!File__Analyze::FileHeader_Begin_0x000001())
+ return false;
+
+ if (!MustSynchronize)
+ {
+ Synched_Init();
+ Buffer_TotalBytes_FirstSynched+=0;
+ File_Offset_FirstSynched=File_Offset;
+ }
+
+ //All should be OK
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Synchro
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Vc1::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+3>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (CC3(Buffer+Buffer_Offset)!=0x000001)
+ Synched=false;
+
+ //Quick search
+ if (Synched && !Header_Parser_QuickSearch())
+ return false;
+
+ #if MEDIAINFO_IBI
+ bool RandomAccess=Buffer[Buffer_Offset+3]==0x0F; //SequenceHeader
+ if (RandomAccess)
+ Ibi_Add();
+ #endif //MEDIAINFO_IBI
+
+ //We continue
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Vc1::Synched_Init()
+{
+ //Count
+ Interlaced_Top=0;
+ Interlaced_Bottom=0;
+ PictureFormat_Count.resize(4);
+ if (Frame_Count_NotParsedIncluded==(int64u)-1)
+ Frame_Count_NotParsedIncluded=0; //No Frame_Count_NotParsedIncluded in the container
+
+ //Temp
+ coded_width=0;
+ coded_height=0;
+ framerateexp=0;
+ frameratecode_enr=0;
+ frameratecode_dr=0;
+ profile=0;
+ level=0;
+ colordiff_format=0;
+ AspectRatio=0;
+ AspectRatioX=0;
+ AspectRatioY=0;
+ hrd_num_leaky_buckets=0;
+ max_b_frames=7; //Default for advanced profile
+ interlace=false;
+ tfcntrflag=false;
+ framerate_present=false;
+ framerate_form=false;
+ hrd_param_flag=false;
+ finterpflag=false;
+ rangered=false;
+ psf=false;
+ pulldown=false;
+ panscan_flag=false;
+ #if MEDIAINFO_DEMUX
+ Demux_IntermediateItemFound=true;
+ #endif //MEDIAINFO_DEMUX
+
+ TemporalReference_Offset=0;
+
+ if (!IsSub)
+ FrameInfo.DTS=0;
+
+ //Default stream values
+ Streams.resize(0x100);
+ Streams[0x0F].Searching_Payload=true;
+}
+
+//***************************************************************************
+// Buffer - Demux
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+bool File_Vc1::Demux_UnpacketizeContainer_Test()
+{
+ if ((Demux_IntermediateItemFound && Buffer[Buffer_Offset+3]==0x0D) || Buffer[Buffer_Offset+3]==0x0F)
+ {
+ if (Demux_Offset==0)
+ {
+ Demux_Offset=Buffer_Offset;
+ Demux_IntermediateItemFound=false;
+ }
+ while (Demux_Offset+4<=Buffer_Size)
+ {
+ //Synchronizing
+ while(Demux_Offset+3<=Buffer_Size && (Buffer[Demux_Offset ]!=0x00
+ || Buffer[Demux_Offset+1]!=0x00
+ || Buffer[Demux_Offset+2]!=0x01))
+ {
+ Demux_Offset+=2;
+ while(Demux_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Demux_Offset+=2;
+ if (Demux_Offset>=Buffer_Size || Buffer[Demux_Offset-1]==0x00)
+ Demux_Offset--;
+ }
+
+ if (Demux_Offset+4<=Buffer_Size)
+ {
+ if (Demux_IntermediateItemFound)
+ {
+ bool MustBreak;
+ switch (Buffer[Demux_Offset+3])
+ {
+ case 0x0D :
+ case 0x0F :
+ MustBreak=true; break;
+ default : MustBreak=false;
+ }
+ if (MustBreak)
+ break; //while() loop
+ }
+ else
+ {
+ if (Buffer[Demux_Offset+3]==0x0D)
+ Demux_IntermediateItemFound=true;
+ }
+ }
+ Demux_Offset++;
+ }
+
+ if (Demux_Offset+4>Buffer_Size && File_Offset+Buffer_Size!=File_Size)
+ return false; //No complete frame
+
+ if (!Status[IsAccepted])
+ {
+ Accept("VC-1");
+ if (Config->Demux_EventWasSent)
+ return false;
+ }
+ Demux_UnpacketizeContainer_Demux(Buffer[Buffer_Offset+3]==0x0F);
+ }
+
+ return true;
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Vc1::Read_Buffer_Unsynched()
+{
+ RefFramesCount=0;
+ #if MEDIAINFO_DEMUX
+ Demux_IntermediateItemFound=true;
+ #endif //MEDIAINFO_DEMUX
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Vc1::Header_Parse()
+{
+ //Specific
+ if (From_WMV3 || Only_0D)
+ {
+ Header_Fill_Size(Buffer_Size);
+ Header_Fill_Code(From_WMV3?0x0F:0x0D, Ztring().From_CC1(From_WMV3?0x0F:0x0D));
+ return;
+ }
+
+ //Parsing
+ Skip_B3( "synchro");
+ Get_B1 (start_code, "start_code");
+ if (!Header_Parser_Fill_Size())
+ {
+ Element_WaitForMoreData();
+ return;
+ }
+
+ //Filling
+ Header_Fill_Code(start_code, Ztring().From_CC1(start_code));
+}
+
+//---------------------------------------------------------------------------
+void File_Vc1::Data_Parse()
+{
+ //Parse
+ switch (Element_Code)
+ {
+ case 0x0A: EndOfSequence(); break;
+ case 0x0B: Slice(); break;
+ case 0x0C: Field(); break;
+ case 0x0D: FrameHeader(); break;
+ case 0x0E: EntryPointHeader(); break;
+ case 0x0F: SequenceHeader(); break;
+ case 0x1B: UserDefinedSlice(); break;
+ case 0x1C: UserDefinedField(); break;
+ case 0x1D: UserDefinedFrameHeader(); break;
+ case 0x1E: UserDefinedEntryPointHeader(); break;
+ case 0x1F: UserDefinedSequenceHeader(); break;
+ default:
+ Trusted_IsNot("Unattended element!");
+ }
+}
+
+//---------------------------------------------------------------------------
+bool File_Vc1::Header_Parser_Fill_Size()
+{
+ //Look for next Sync word
+ if (Buffer_Offset_Temp==0) //Buffer_Offset_Temp is not 0 if Header_Parse_Fill_Size() has already parsed first frames
+ Buffer_Offset_Temp=Buffer_Offset+4;
+ while (Buffer_Offset_Temp+4<=Buffer_Size
+ && CC3(Buffer+Buffer_Offset_Temp)!=0x000001)
+ {
+ Buffer_Offset_Temp+=2;
+ while(Buffer_Offset_Temp<Buffer_Size && Buffer[Buffer_Offset_Temp]!=0x00)
+ Buffer_Offset_Temp+=2;
+ if (Buffer_Offset_Temp>=Buffer_Size || Buffer[Buffer_Offset_Temp-1]==0x00)
+ Buffer_Offset_Temp--;
+
+ if (start_code==0x0D) //FrameHeader, we need only few bytes
+ {
+ if (Buffer_Offset_Temp-Buffer_Offset>20)
+ {
+ //OK, we continue, we have enough for a slice
+ Header_Fill_Size(16);
+ Buffer_Offset_Temp=0;
+ return true;
+ }
+ }
+ }
+
+ //Must wait more data?
+ if (Buffer_Offset_Temp+4>Buffer_Size)
+ {
+ if (FrameIsAlwaysComplete || File_Offset+Buffer_Size==File_Size)
+ Buffer_Offset_Temp=Buffer_Size; //We are sure that the next bytes are a start
+ else
+ return false;
+ }
+
+ //OK, we continue
+ Header_Fill_Size(Buffer_Offset_Temp-Buffer_Offset);
+ Buffer_Offset_Temp=0;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Vc1::Header_Parser_QuickSearch()
+{
+ while ( Buffer_Offset+4<=Buffer_Size
+ && Buffer[Buffer_Offset ]==0x00
+ && Buffer[Buffer_Offset+1]==0x00
+ && Buffer[Buffer_Offset+2]==0x01)
+ {
+ //Getting start_code
+ int8u start_code=CC1(Buffer+Buffer_Offset+3);
+
+ //Searching start
+ if (Streams[start_code].Searching_Payload)
+ return true;
+
+ //Synchronizing
+ Buffer_Offset+=4;
+ Synched=false;
+ if (!Synchronize())
+ {
+ if (File_Offset+Buffer_Size==File_Size)
+ {
+ Synched=true;
+ return true;
+ }
+ return false;
+ }
+
+ if (Buffer_Offset+4>Buffer_Size)
+ return false;
+ }
+
+ if (Buffer_Offset+3==Buffer_Size)
+ return false; //Sync is OK, but start_code is not available
+ Trusted_IsNot("VC-1, Synchronisation lost");
+ return Synchronize();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Packet "0A"
+void File_Vc1::EndOfSequence()
+{
+ Element_Name("EndOfSequence");
+}
+
+//---------------------------------------------------------------------------
+// Packet "0B"
+void File_Vc1::Slice()
+{
+ Element_Name("Slice");
+}
+
+//---------------------------------------------------------------------------
+// Packet "0C"
+void File_Vc1::Field()
+{
+ Element_Name("Field");
+}
+
+//---------------------------------------------------------------------------
+// Packet "0D"
+void File_Vc1::FrameHeader()
+{
+ //Name
+ Element_Name("FrameHeader");
+ Element_Info1(Ztring(_T("Frame ")+Ztring::ToZtring(Frame_Count)));
+ if (FrameRate)
+ {
+ Element_Info1C((FrameInfo.PTS!=(int64u)-1), _T("PTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.PTS)/1000000+Frame_Count_InThisBlock*1000/FrameRate)));
+ Element_Info1C((FrameInfo.DTS!=(int64u)-1), _T("DTS ")+Ztring().Duration_From_Milliseconds(float64_int64s(((float64)FrameInfo.DTS)/1000000)));
+ }
+
+ //Counting
+ if (File_Offset+Buffer_Offset+Element_Size==File_Size)
+ Frame_Count_Valid=Frame_Count; //Finish frames in case of there are less than Frame_Count_Valid frames
+ Frame_Count++;
+ Frame_Count_InThisBlock++;
+ if (Frame_Count_NotParsedIncluded!=(int64u)-1)
+ Frame_Count_NotParsedIncluded++;
+
+ //Parsing
+ BS_Begin();
+ int8u ptype=(int8u)-1;
+ if (profile==3) //Advanced
+ {
+ int8u PictureFormat=0; //Default=Progressive frame
+ if (interlace)
+ {
+ bool fcm_1;
+ Get_SB ( fcm_1, "fcm_1");
+ if (fcm_1)
+ {
+ bool fcm_2;
+ Get_SB ( fcm_2, "fcm_2");
+ PictureFormat=fcm_2?2:1; //Interlaced Field : Interlaced Frame
+ }
+ }
+ Param_Info1(Vc1_PictureFormat[PictureFormat]);
+ PictureFormat_Count[PictureFormat]++;
+
+ if (PictureFormat==2) //Interlaced Field
+ {
+ int8u ptype_;
+ Get_S1 ( 3, ptype_, "ptype");
+ if (ptype_<5)
+ {
+ Param_Info1(Vc1_Type[Vc1_FieldTypeTable[ptype_][0]]); Element_Info1(Vc1_Type[Vc1_FieldTypeTable[ptype_][0]]); //First field
+ Param_Info1(Vc1_Type[Vc1_FieldTypeTable[ptype_][1]]); Element_Info1(Vc1_Type[Vc1_FieldTypeTable[ptype_][1]]); //Second field
+ ptype=Vc1_FieldTypeTable[ptype_][0]; //Saving the ptype from the first field
+ }
+ else
+ {
+ Trusted_IsNot("ptype is out of range");
+ ptype=0; //Error
+ }
+ }
+ else
+ {
+ size_t ptype_;
+ Get_VL (Vc1_ptype, ptype_, "ptype"); if (ptype_<5) {Param_Info1(Vc1_Type[Vc1_ptype[ptype_].mapped_to3]); Element_Info1(Vc1_Type[Vc1_ptype[ptype_].mapped_to3]);}
+ ptype=(int8u)Vc1_ptype[ptype_].mapped_to3;
+ }
+ if (RefFramesCount<2 && (ptype==0 || ptype==1))
+ RefFramesCount++;
+ if (FrameInfo.DTS!=(int64u)-1)
+ {
+ if (framerate_present)
+ FrameInfo.DTS+=float64_int64s(((float64)1000000000)/FrameRate);
+ }
+ if (FrameInfo.PTS!=(int64u)-1)
+ {
+ if (PTS_Begin==(int64u)-1 && ptype==0) //IFrame
+ PTS_Begin=FrameInfo.PTS;
+ if ((ptype==0 || ptype==1) && Frame_Count_InThisBlock<=1) //IFrame or PFrame
+ PTS_End=FrameInfo.PTS;
+ if ((ptype==0 || ptype==1) || (Frame_Count_InThisBlock>=2 && RefFramesCount>=2)) //IFrame or PFrame or more than 2 RefFrame for BFrames
+ {
+ if (framerate_present)
+ PTS_End+=float64_int64s(((float64)1000000000)/FrameRate);
+ }
+ }
+
+ if (ptype!=4) //!=Skipping
+ {
+ if (tfcntrflag)
+ {
+ Skip_S1( 8, "tfcntr - frame counter");
+ }
+ }
+
+ if (interlace && !psf)
+ {
+ bool tff=true, rff=false;
+ if (pulldown)
+ {
+ Get_SB (tff, "tff - top field first");
+ Get_SB (rff, "rff - repeat first field");
+ if (tff)
+ Interlaced_Top++;
+ else
+ Interlaced_Bottom++;
+
+ if (TemporalReference.size()<30)
+ {
+ if (ptype!=2 && ptype!=3 //if not B and BI-frame
+ && !TemporalReference_Waiting.empty()) //We must have 2 I or P pictures to be sure not having B picture later
+ {
+ //We have 2 I or P pictures
+ for (size_t Pos=1; Pos<TemporalReference_Waiting.size(); Pos++) //All B frames (not the first frame, which is I or P)
+ {
+ TemporalReference_Offset++;
+ TemporalReference[TemporalReference_Offset]=TemporalReference_Waiting[Pos];
+ }
+ TemporalReference_Offset++;
+ TemporalReference[TemporalReference_Offset]=TemporalReference_Waiting[0];
+ TemporalReference_Waiting.clear();
+ }
+
+ //We must wait for having another I or P picture
+ temporalreference Temp;
+ Temp.top_field_first=tff;
+ Temp.repeat_first_field=rff;
+ TemporalReference_Waiting.push_back(Temp);
+ }
+ }
+ }
+ else
+ {
+ int8u rptfrm=0;
+ if (pulldown)
+ {
+ Get_S1 ( 2, rptfrm, "rptfrm - repeate frame");
+ }
+ }
+
+ /*
+ if (panscan_flag)
+ {
+ //TODO
+ }
+
+ if (ptype!=4) //!=Skipping
+ {
+ bool rndctrl;
+ Get_SB( rndctrl, "rndctrl - rounding control");
+ if (rndctrl && (ptype==0 || ptype==3)) //I or BI type
+ Trusted_IsNot("Should not be true!");
+
+ if (interlace)
+ Skip_SB( "uvsamp - uv sampling mode");
+
+ if (finterpflag && PictureFormat==0) //Progressive frame
+ Skip_SB( "interrpfrm");
+
+ if (PictureFormat!=1) //!=Interlaced frame
+ {
+ if (ptype==2 //Type B
+ || (ptype==3 && PictureFormat==2)) //Type BI and Interlaced field
+ Skip_VL(Vc1_bfraction, "bfraction");
+ }
+ }
+ */
+ }
+ BS_End();
+ if (Element_Size-Element_Offset)
+ Skip_XX(Element_Size-Element_Offset, "Data");
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Test();
+ NextCode_Clear();
+ NextCode_Add(0x0D);
+ NextCode_Add(0x0F);
+
+ //Autorisation of other streams
+ Streams[0x0D].Searching_Payload=true;
+ Streams[0x0F].Searching_Payload=true;
+
+ //Filling only if not already done
+ if (!Status[IsFilled] && Frame_Count>=Frame_Count_Valid)
+ {
+ Fill("VC-1");
+
+ if (!IsSub && MediaInfoLib::Config.ParseSpeed_Get()<1)
+ Finish("VC-1");
+ }
+
+ #if MEDIAINFO_EVENTS
+ {
+ struct MediaInfo_Event_Video_SliceInfo_0 Event;
+ Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_Video_SliceInfo, 0);
+ Event.Stream_Offset=File_Offset+Buffer_Offset;
+ Event.PCR=FrameInfo.PCR;
+ Event.PTS=FrameInfo.PTS;
+ Event.DTS=FrameInfo.DTS;
+ Event.DUR=FrameInfo.DUR;
+ Event.StreamIDs_Size=StreamIDs_Size;
+ Event.StreamIDs=(MediaInfo_int64u*)StreamIDs;
+ Event.StreamIDs_Width=(MediaInfo_int8u*)StreamIDs_Width;
+ Event.ParserIDs=(MediaInfo_int8u* )ParserIDs;
+ Event.FramePosition=Frame_Count;
+ Event.FieldPosition=Field_Count;
+ Event.SlicePosition=0;
+ switch (ptype)
+ {
+ case 0 :
+ Event.SliceType=0; break;
+ case 1 :
+ Event.SliceType=1; break;
+ case 2 :
+ case 3 :
+ Event.SliceType=2; break;
+ case 4 :
+ Event.SliceType=3; break;
+ default:
+ Event.SliceType=(int8u)-1;
+ }
+ Event.Flags=0;
+ Config->Event_Send((const int8u*)&Event, sizeof(MediaInfo_Event_Video_SliceInfo_0));
+ }
+ #endif //MEDIAINFO_EVENTS
+ FILLING_END();
+
+ Synched=false; //We do not have the complete FrameHeader
+}
+
+//---------------------------------------------------------------------------
+// Packet "0E"
+void File_Vc1::EntryPointHeader()
+{
+ Element_Name("EntryPointHeader");
+
+ //Parsing
+ bool extended_mv;
+ BS_Begin();
+ Skip_SB( "broken_link");
+ Skip_SB( "closed_entry");
+ Get_SB ( panscan_flag, "panscan_flag");
+ Skip_SB( "refdist_flag");
+ Skip_SB( "loopfilter");
+ Skip_SB( "fastuvmc");
+ Get_SB ( extended_mv, "extended_mv");
+ Skip_S1( 2, "dquant");
+ Skip_SB( "vstransform");
+ Skip_SB( "overlap");
+ Skip_S1( 2, "quantizer");
+ if (hrd_param_flag)
+ for (int8u Pos=0; Pos<hrd_num_leaky_buckets; Pos++)
+ {
+ Element_Begin1("leaky_bucket");
+ Skip_S1( 8, "hrd_full");
+ Element_End0();
+ }
+ TEST_SB_SKIP( "coded_size_flag");
+ Info_S2(12, coded_width, "coded_width"); Param_Info2((coded_width+1)*2, " pixels");
+ Info_S2(12, coded_height, "coded_height"); Param_Info2((coded_height+1)*2, " pixels");
+ TEST_SB_END();
+ if (extended_mv)
+ Skip_SB( "extended_dmv");
+ TEST_SB_SKIP( "range_mapy_flag");
+ Skip_S1( 3, "range_mapy");
+ TEST_SB_END();
+ TEST_SB_SKIP( "range_mapuv_flag");
+ Skip_S1( 3, "range_mapuv");
+ TEST_SB_END();
+ Mark_1();
+ BS_End();
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Test();
+ NextCode_Clear();
+ NextCode_Add(0x0D);
+
+ //Autorisation of other streams
+ Streams[0x0D].Searching_Payload=true;
+
+ EntryPoint_Parsed=true;
+ if (!Status[IsAccepted])
+ Accept("VC-1");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "0F"
+void File_Vc1::SequenceHeader()
+{
+ Element_Name("SequenceHeader");
+
+ //Parsing
+ BS_Begin();
+ Get_S1 ( 2, profile, "profile"); Param_Info1(Vc1_Profile[profile]);
+ if (profile==0 || profile==1) //Simple or Main
+ {
+ Skip_S1( 2, "res_sm");
+ Skip_S1( 3, "frmrtq_postproc");
+ Skip_S1( 5, "bitrtq_postproc");
+ Skip_SB( "loopfilter");
+ Skip_SB( "res_x8");
+ Skip_SB( "multires");
+ Skip_SB( "res_fasttx");
+ Skip_SB( "fastuvmc");
+ Skip_SB( "extended_mv");
+ Skip_S1( 2, "dquant");
+ Skip_SB( "vtransform");
+ Skip_SB( "res_transtab");
+ Skip_SB( "overlap");
+ Skip_SB( "syncmarker");
+ Skip_SB( "rangered");
+ Skip_S1( 2, "maxbframes");
+ Skip_S1( 2, "quantizer");
+ Skip_SB( "finterpflag");
+ Skip_SB( "res_rtm_flag");
+ }
+ else if (profile==3) //Advanced
+ {
+ Get_S1 ( 3, level, "level");
+ Get_S1 ( 2, colordiff_format, "colordiff_format"); Param_Info1(Vc1_ColorimetryFormat[colordiff_format]);
+ Skip_S1( 3, "frmrtq_postproc");
+ Skip_S1( 5, "bitrtq_postproc");
+ Skip_SB( "postprocflag");
+ Get_S2 (12, coded_width, "max_coded_width"); Param_Info2((coded_width+1)*2, " pixels");
+ Get_S2 (12, coded_height, "max_coded_height"); Param_Info2((coded_height+1)*2, " pixels");
+ Get_SB ( pulldown, "pulldown");
+ Get_SB ( interlace, "interlace");
+ Get_SB ( tfcntrflag, "tfcntrflag - frame counter");
+ Get_SB ( finterpflag, "finterpflag");
+ Skip_SB( "reserved");
+ Get_SB ( psf, "psf - progressive segmented frame");
+ TEST_SB_SKIP( "display_ext");
+ Info_S2(14, display_x, "display_horiz_size"); Param_Info2(display_x+1, " pixels");
+ Info_S2(14, display_y, "display_vert_size"); Param_Info2(display_y+1, " pixels");
+ TEST_SB_SKIP( "aspectratio_flag");
+ Get_S1 ( 4, AspectRatio, "aspect_ratio"); Param_Info1(Vc1_PixelAspectRatio[AspectRatio]);
+ if (AspectRatio==0x0F)
+ {
+ Get_S1 ( 8, AspectRatioX, "aspect_horiz_size");
+ Get_S1 ( 8, AspectRatioY, "aspect_vert_size");
+ }
+ TEST_SB_END();
+ TEST_SB_GET(framerate_present, "framerate_flag");
+ TESTELSE_SB_GET(framerate_form, "framerateind");
+ Get_S2 (16, framerateexp, "framerateexp"); Param_Info3((float32)((framerateexp+1)/32.0), 3, " fps");
+ TESTELSE_SB_ELSE( "framerateind");
+ Get_S1 ( 8, frameratecode_enr, "frameratenr"); Param_Info1(Vc1_FrameRate_enr(frameratecode_enr));
+ Get_S1 ( 4, frameratecode_dr, "frameratedr"); Param_Info1(Vc1_FrameRate_dr(frameratecode_dr));
+ TESTELSE_SB_END();
+ TEST_SB_END();
+ TEST_SB_SKIP( "color_format_flag");
+ Skip_S1( 8, "color_prim");
+ Skip_S1( 8, "transfer_char");
+ Skip_S1( 8, "matrix_coef");
+ TEST_SB_END();
+ TEST_SB_END();
+ TEST_SB_GET (hrd_param_flag, "hrd_param_flag");
+ int8u buffer_size_exponent;
+ Get_S1 ( 5, hrd_num_leaky_buckets, "hrd_num_leaky_buckets");
+ Skip_S1( 4, "bitrate_exponent");
+ Get_S1 ( 4, buffer_size_exponent, "buffer_size_exponent");
+ hrd_buffers.clear();
+ for (int8u Pos=0; Pos<hrd_num_leaky_buckets; Pos++)
+ {
+ Element_Begin1("leaky_bucket");
+ int16u hrd_buffer;
+ Skip_S2(16, "hrd_rate");
+ Get_S2(16, hrd_buffer, "hrd_buffer");
+ int32u hrd_buffer_value=(int32u)((hrd_buffer+1)*pow(2.0, 1+buffer_size_exponent)); Param_Info2(hrd_buffer_value, " bytes");
+ Element_End0();
+
+ //Filling
+ hrd_buffers.push_back(hrd_buffer_value);
+ }
+ TEST_SB_END();
+ }
+ else //forbidden
+ {
+ Element_DoNotTrust("Forbidden value");
+ }
+ Mark_1();
+ BS_End();
+
+ FILLING_BEGIN();
+ //NextCode
+ NextCode_Clear();
+ NextCode_Add(0x0D);
+ NextCode_Add(0x0E);
+
+ //Autorisation of other streams
+ Streams[0x0D].Searching_Payload=true;
+ Streams[0x0E].Searching_Payload=true;
+
+ //Frame rate
+ if (framerate_present)
+ {
+ if (framerate_form)
+ FrameRate=((float32)(framerateexp+1))/(float32)32;
+ else if (Vc1_FrameRate_dr(frameratecode_dr))
+ FrameRate=Vc1_FrameRate_enr(frameratecode_enr)/Vc1_FrameRate_dr(frameratecode_dr);
+ }
+
+ if (From_WMV3)
+ {
+ if (!Status[IsAccepted])
+ Accept("VC-1");
+ Finish("VC-1");
+ }
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+// Packet "1B"
+void File_Vc1::UserDefinedSlice()
+{
+ Element_Name("UserDefinedSlice");
+}
+
+//---------------------------------------------------------------------------
+// Packet "1C"
+void File_Vc1::UserDefinedField()
+{
+ Element_Name("UserDefinedField");
+}
+
+//---------------------------------------------------------------------------
+// Packet "1D"
+void File_Vc1::UserDefinedFrameHeader()
+{
+ Element_Name("UserDefinedFrameHeader");
+}
+
+//---------------------------------------------------------------------------
+// Packet "1E"
+void File_Vc1::UserDefinedEntryPointHeader()
+{
+ Element_Name("UserDefinedEntryPointHeader");
+}
+
+//---------------------------------------------------------------------------
+// Packet "1F"
+void File_Vc1::UserDefinedSequenceHeader()
+{
+ Element_Name("UserDefinedSequenceHeader");
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_VC1_YES
+
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc1.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc1.h
new file mode 100644
index 000000000..fa4252799
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc1.h
@@ -0,0 +1,165 @@
+// File_Vc1 - Info for MPEG Video files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about MPEG Video files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Vc1H
+#define MediaInfo_Vc1H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Vc1
+//***************************************************************************
+
+class File_Vc1 : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ bool FrameIsAlwaysComplete;
+ bool From_WMV3;
+ bool Only_0D;
+
+ //Constructor/Destructor
+ File_Vc1();
+
+private :
+ //Streams management
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+
+ //Buffer - Synchro
+ bool Synchronize() {return Synchronize_0x000001();}
+ bool Synched_Test();
+ void Synched_Init();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test();
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Global
+ void Read_Buffer_Unsynched();
+
+ //Buffer - Per element
+ void Header_Parse();
+ bool Header_Parser_QuickSearch();
+ bool Header_Parser_Fill_Size();
+ void Data_Parse();
+
+ //Elements
+ void EndOfSequence();
+ void Slice();
+ void Field();
+ void FrameHeader();
+ void EntryPointHeader();
+ void SequenceHeader();
+ void UserDefinedSlice();
+ void UserDefinedField();
+ void UserDefinedFrameHeader();
+ void UserDefinedEntryPointHeader();
+ void UserDefinedSequenceHeader();
+
+ //Count
+ size_t Interlaced_Top;
+ size_t Interlaced_Bottom;
+ std::vector<size_t> PictureFormat_Count;
+
+ //From SequenceHeader
+ std::vector<int32u> hrd_buffers;
+ int16u coded_width;
+ int16u coded_height;
+ int16u framerateexp;
+ int8u frameratecode_enr;
+ int8u frameratecode_dr;
+ int8u profile;
+ int8u level;
+ int8u colordiff_format;
+ int8u AspectRatio;
+ int8u AspectRatioX;
+ int8u AspectRatioY;
+ int8u hrd_num_leaky_buckets;
+ int8u max_b_frames;
+ bool interlace;
+ bool tfcntrflag;
+ bool framerate_present;
+ bool framerate_form;
+ bool hrd_param_flag;
+ bool finterpflag;
+ bool rangered;
+ bool psf;
+ bool pulldown;
+ bool panscan_flag;
+
+ //Stream
+ struct stream
+ {
+ bool Searching_Payload;
+ bool Searching_TimeStamp_Start;
+ bool Searching_TimeStamp_End;
+
+ stream()
+ {
+ Searching_Payload=false;
+ Searching_TimeStamp_Start=false;
+ Searching_TimeStamp_End=false;
+ }
+ };
+ std::vector<stream> Streams;
+
+ //Temporal reference
+ struct temporalreference
+ {
+ bool top_field_first;
+ bool repeat_first_field;
+ };
+ std::map<int16u, temporalreference> TemporalReference; //int32u is the reference
+ std::vector<temporalreference> TemporalReference_Waiting; //First must be I and P-frames, other B-frames
+ int16u TemporalReference_Offset;
+
+ //Temp
+ size_t Width;
+ size_t Height;
+ size_t RatioValue;
+ size_t BitRate;
+ int8u start_code;
+ bool EntryPoint_Parsed;
+ float32 FrameRate;
+ size_t RefFramesCount;
+
+ //Error controls
+ std::vector<int8u> Frame_ShouldBe;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc3.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc3.cpp
new file mode 100644
index 000000000..6fc17413a
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc3.cpp
@@ -0,0 +1,383 @@
+// File_Vc3 - Info for VC-3 streams
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_VC3_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Vc3.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const int32u Vc3_CompressedFrameSize(int32u CompressionID)
+{
+ switch (CompressionID)
+ {
+ case 1235 : return 917504;
+ case 1237 : return 606208;
+ case 1238 : return 917504;
+ case 1241 : return 917504;
+ case 1242 : return 606208;
+ case 1243 : return 917504;
+ case 1250 : return 458752;
+ case 1251 : return 458752;
+ case 1252 : return 303104;
+ case 1253 : return 188416;
+ default : return 0;
+ }
+};
+
+//---------------------------------------------------------------------------
+const int8u Vc3_SBD(int32u SBD) //Sample Bit Depth
+{
+ switch (SBD)
+ {
+ case 1 : return 8;
+ case 2 : return 10;
+ default: return 0;
+ }
+};
+
+//---------------------------------------------------------------------------
+const char* Vc3_FFC[4]=
+{
+ "",
+ "Progressive",
+ "Interlaced",
+ "Interlaced",
+};
+
+//---------------------------------------------------------------------------
+const char* Vc3_SST[2]=
+{
+ "Progressive",
+ "Interlaced",
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Vc3::File_Vc3()
+:File__Analyze()
+{
+ //Configuration
+ MustSynchronize=true;
+
+ //In
+ Frame_Count_Valid=2;
+ FrameRate=0;
+
+ //Temp
+ Data_ToParse=0;
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Vc3::Streams_Fill()
+{
+ //Filling
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "VC-3");
+ Fill(Stream_Video, 0, Video_BitRate_Mode, "CBR");
+ if (FrameRate)
+ Fill(Stream_Video, 0, Video_BitRate, Vc3_CompressedFrameSize(CID)*8*FrameRate, 0);
+ Fill(Stream_Video, 0, Video_Width, SPL);
+ Fill(Stream_Video, 0, Video_Height, ALPF);
+ Fill(Stream_Video, 0, Video_BitDepth, Vc3_SBD(SBD));
+ Fill(Stream_Video, 0, Video_ColorSpace, "YUV");
+ Fill(Stream_Video, 0, Video_ChromaSubsampling, "4:2:2");
+ Fill(Stream_Video, 0, Video_ScanType, Vc3_SST[SST]);
+}
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Vc3::Synchronize()
+{
+ //Synchronizing
+ while (Buffer_Offset+5<=Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x02
+ || Buffer[Buffer_Offset+3]!=0x80
+ || Buffer[Buffer_Offset+4]!=0x01))
+ {
+ Buffer_Offset+=2;
+ while (Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
+ Buffer_Offset+=2;
+ if (Buffer_Offset>=Buffer_Size || Buffer[Buffer_Offset-1]==0x00)
+ Buffer_Offset--;
+ }
+
+ //Parsing last bytes if needed
+ if (Buffer_Offset+4==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x02
+ || Buffer[Buffer_Offset+3]!=0x80))
+ Buffer_Offset++;
+ if (Buffer_Offset+3==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x02))
+ Buffer_Offset++;
+ if (Buffer_Offset+2==Buffer_Size && (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00))
+ Buffer_Offset++;
+ if (Buffer_Offset+1==Buffer_Size && Buffer[Buffer_Offset ]!=0x00)
+ Buffer_Offset++;
+
+ if (Buffer_Offset+5>Buffer_Size)
+ return false;
+
+ //Synched is OK
+ Synched=true;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+bool File_Vc3::Synched_Test()
+{
+ //Must have enough buffer for having header
+ if (Buffer_Offset+5>Buffer_Size)
+ return false;
+
+ //Quick test of synchro
+ if (Buffer[Buffer_Offset ]!=0x00
+ || Buffer[Buffer_Offset+1]!=0x00
+ || Buffer[Buffer_Offset+2]!=0x02
+ || Buffer[Buffer_Offset+3]!=0x80
+ || Buffer[Buffer_Offset+4]!=0x01)
+ {
+ Synched=false;
+ return true;
+ }
+
+ //We continue
+ return true;
+}
+
+//***************************************************************************
+// Buffer - Demux
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#if MEDIAINFO_DEMUX
+bool File_Vc3::Demux_UnpacketizeContainer_Test()
+{
+ if (Buffer_Offset+0x2C>Buffer_Size)
+ return false;
+
+ int32u CompressionID=BigEndian2int32u(Buffer+Buffer_Offset+0x28);
+ int32u Size=Vc3_CompressedFrameSize(CompressionID);
+ Demux_Offset=Buffer_Offset+Size;
+
+ if (Demux_Offset>Buffer_Size && File_Offset+Buffer_Size!=File_Size)
+ return false; //No complete frame
+
+ Demux_UnpacketizeContainer_Demux();
+
+ return true;
+}
+#endif //MEDIAINFO_DEMUX
+
+//***************************************************************************
+// Buffer - Per element
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Vc3::Header_Begin()
+{
+ if (Buffer_Offset+0x2C>Buffer_Size)
+ return false;
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+void File_Vc3::Header_Parse()
+{
+ int32u CompressionID=BigEndian2int32u(Buffer+Buffer_Offset+0x28);
+
+ Header_Fill_Code(0, "Frame");
+ Header_Fill_Size(Vc3_CompressedFrameSize(CompressionID));
+}
+
+//---------------------------------------------------------------------------
+void File_Vc3::Data_Parse()
+{
+ //Parsing
+ Element_Info1(Frame_Count+1);
+ HeaderPrefix();
+ CodingControlA();
+ Skip_XX(16, "Reserved");
+ ImageGeometry();
+ Skip_XX( 5, "Reserved");
+ CompressionID();
+
+ Skip_XX(640-Element_Offset, "ToDo");
+ Skip_XX(Element_Size-Element_Offset, "Data");
+
+ FILLING_BEGIN();
+ Data_ToParse-=Buffer_Size-(size_t)Buffer_Offset;
+ Frame_Count++;
+ if (!Status[IsFinished] && Frame_Count>=Frame_Count_Valid)
+ Finish("VC-3");
+ FILLING_END();
+}
+
+//***************************************************************************
+// Elements
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Vc3::HeaderPrefix()
+{
+ //Parsing
+ Element_Begin1("Header Prefix");
+ int64u Data;
+ Get_B5 (Data, "Contents");
+ Element_End0();
+
+ FILLING_BEGIN();
+ if (Data==0x0000028001LL)
+ Accept("VC-3");
+ else
+ Reject("VC-3");
+ FILLING_END();
+}
+
+//---------------------------------------------------------------------------
+void File_Vc3::CodingControlA()
+{
+ //Parsing
+ Element_Begin1("Coding Control A");
+ BS_Begin();
+
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Info_S1(2, FFC, "Field/Frame Count"); Param_Info1(Vc3_FFC[FFC]);
+
+ Mark_1();
+ Mark_0();
+ Mark_0();
+ Get_SB ( CRCF, "CRC flag");
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+
+ Mark_1();
+ Mark_0();
+ Mark_1();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+
+ BS_End();
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Vc3::ImageGeometry()
+{
+ //Parsing
+ Element_Begin1("Image Geometry");
+ Get_B2 (ALPF, "Active lines-per-frame");
+ Get_B2 (SPL, "Samples-per-line");
+ Skip_B1( "Zero");
+ Skip_B2( "Number of active lines");
+ Skip_B2( "Zero");
+
+ BS_Begin();
+
+ Get_S1 (3, SBD, "Sample bit depth");
+ Mark_1();
+ Mark_1();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+
+ Mark_1();
+ Mark_0();
+ Mark_0();
+ Mark_0();
+ Mark_1();
+ Get_SB ( SST, "Source scan type");
+ Mark_0();
+ Mark_0();
+
+ BS_End();
+ Element_End0();
+}
+
+//---------------------------------------------------------------------------
+void File_Vc3::CompressionID()
+{
+ //Parsing
+ Element_Begin1("Compression ID");
+ int32u Data;
+ Get_B4 (Data, "Compression ID");
+ Element_End0();
+
+ FILLING_BEGIN();
+ CID=Data;
+ Data_ToParse=Vc3_CompressedFrameSize(Data);
+ if (Data_ToParse==0)
+ Reject("VC-3");
+ FILLING_END();
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //NameSpace
+
+#endif //MEDIAINFO_VC3_*
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc3.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc3.h
new file mode 100644
index 000000000..540056514
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vc3.h
@@ -0,0 +1,91 @@
+// File_Vc3 - Info for VC-3 streams
+// Copyright (C) 2010-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about VC-3 video streams
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Vc3H
+#define MediaInfo_Vc3H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+#include "MediaInfo/Multiple/File_Mpeg4.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Avs
+//***************************************************************************
+
+class File_Vc3 : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+ float FrameRate;
+
+ //constructor/Destructor
+ File_Vc3();
+
+private :
+ //Streams management
+ void Streams_Fill();
+
+ //Buffer - Synchro
+ bool Synchronize();
+ bool Synched_Test();
+
+ //Buffer - Demux
+ #if MEDIAINFO_DEMUX
+ bool Demux_UnpacketizeContainer_Test();
+ #endif //MEDIAINFO_DEMUX
+
+ //Buffer - Per element
+ bool Header_Begin ();
+ void Header_Parse ();
+ void Data_Parse ();
+
+ //Elements
+ void HeaderPrefix();
+ void CodingControlA();
+ void ImageGeometry();
+ void CompressionID();
+ void CodingControlB();
+ void TimeCode();
+ void UserData();
+ void MacroblockScanIndices();
+
+ //Temp
+ int64u Data_ToParse;
+ int32u CID;
+ bool CRCF;
+ int16u ALPF;
+ int16u SPL;
+ int8u SBD;
+ bool SST;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vp8.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vp8.cpp
new file mode 100644
index 000000000..ad78aa7b6
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vp8.cpp
@@ -0,0 +1,126 @@
+// File_Vp8 - Info for MPEG Video files
+// Copyright (C) 2004-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_VP8_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Vp8.h"
+#include "ZenLib/BitStream.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+namespace MediaInfoLib
+{
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Vp8::File_Vp8()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("VP8");
+ IsRawStream=true;
+
+ //In
+ Frame_Count_Valid=Config_ParseSpeed>=0.3?32:4;
+}
+
+//---------------------------------------------------------------------------
+File_Vp8::~File_Vp8()
+{
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Vp8::Streams_Accept()
+{
+ Stream_Prepare(Stream_Video);
+}
+
+//---------------------------------------------------------------------------
+void File_Vp8::Streams_Update()
+{
+}
+
+//---------------------------------------------------------------------------
+void File_Vp8::Streams_Fill()
+{
+ Fill(Stream_Video, 0, Video_Format, "VP8");
+ Fill(Stream_Video, 0, Video_Codec, "VP8");
+}
+
+//---------------------------------------------------------------------------
+void File_Vp8::Streams_Finish()
+{
+}
+
+//***************************************************************************
+// Buffer - Global
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Vp8::Read_Buffer_Continue()
+{
+ Accept();
+
+ BS_Begin_LE(); //VP8 bitstream is Little Endian
+ bool frame_type;
+ Get_TB ( frame_type, "frame type");
+ Skip_T1( 3, "version number");
+ Skip_TB( "show_frame flag");
+ Skip_T3(19, "size of the first data partition");
+ BS_End();
+
+ if (!frame_type) //I-Frame
+ {
+ Skip_B3( "0x9D012A");
+ Skip_L2( "Width");
+ Skip_L2( "Height");
+ }
+ Skip_XX(Element_Size-Element_Offset, "Other data");
+
+ Frame_Count++;
+ if (Frame_Count>=Frame_Count_Valid)
+ Finish();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_VP8_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vp8.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vp8.h
new file mode 100644
index 000000000..2da74a386
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Vp8.h
@@ -0,0 +1,64 @@
+// File_Vp8 - Info for VP8 streams
+// Copyright (C) 2012-2012 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about VP8 files
+// http://datatracker.ietf.org/doc/rfc6386/?include_text=1
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Vp8H
+#define MediaInfo_Vp8H
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Vp8
+//***************************************************************************
+
+class File_Vp8 : public File__Analyze
+{
+public :
+ //In
+ int64u Frame_Count_Valid;
+
+ //Constructor/Destructor
+ File_Vp8();
+ ~File_Vp8();
+
+private :
+ //Streams management
+ void Streams_Accept();
+ void Streams_Update();
+ void Streams_Fill();
+ void Streams_Finish();
+
+ //Buffer - Global
+ void Read_Buffer_Continue();
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Y4m.cpp b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Y4m.cpp
new file mode 100644
index 000000000..e645a19f7
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Y4m.cpp
@@ -0,0 +1,242 @@
+// File_Y4m - Info for YUV4MPEG2 files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+//
+// Source:
+// http://wiki.multimedia.cx/index.php?title=YUV4MPEG2
+//
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+// Pre-compilation
+#include "MediaInfo/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Setup.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(MEDIAINFO_Y4M_YES)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/Video/File_Y4m.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+namespace MediaInfoLib
+{
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Infos
+//***************************************************************************
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File_Y4m::File_Y4m()
+:File__Analyze()
+{
+ //Configuration
+ ParserName=_T("YUV4MPEG2");
+ IsRawStream=true;
+ Frame_Count_NotParsedIncluded=0;
+
+ //Temp
+ HeaderEnd=0;
+}
+
+//---------------------------------------------------------------------------
+File_Y4m::~File_Y4m()
+{
+}
+
+//***************************************************************************
+// Streams management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void File_Y4m::Streams_Accept()
+{
+ Fill(Stream_General, 0, General_Format, "YUV4MPEG2");
+
+ Stream_Prepare(Stream_Video);
+ Fill(Stream_Video, 0, Video_Format, "YUV");
+ Fill(Stream_Video, 0, Video_ColorSpace, "YUV");
+}
+
+//---------------------------------------------------------------------------
+void File_Y4m::Streams_Fill()
+{
+}
+
+//***************************************************************************
+// Buffer - File header
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File_Y4m::FileHeader_Begin()
+{
+ if (Buffer_Size<10)
+ return false;
+
+ if (!(Buffer[0]==0x59
+ && Buffer[1]==0x55
+ && Buffer[2]==0x56
+ && Buffer[3]==0x34
+ && Buffer[4]==0x4D
+ && Buffer[5]==0x50
+ && Buffer[6]==0x45
+ && Buffer[7]==0x47
+ && Buffer[8]==0x32
+ && Buffer[9]==0x20))
+ {
+ Reject();
+ return false;
+ }
+
+ for (; HeaderEnd<Buffer_Size; HeaderEnd++)
+ {
+ if (Buffer[HeaderEnd]==0x0A)
+ {
+ Accept();
+ return true;
+ }
+ }
+
+ return false;
+}
+
+//---------------------------------------------------------------------------
+void File_Y4m::FileHeader_Parse()
+{
+ //Parsing
+ Ztring Header;
+ Get_Local(HeaderEnd, Header, "Data");
+
+ ZtringList List; List.Separator_Set(0, " ");
+ List.Write(Header);
+ int64u Width=0, Height=0, Multiplier=0, Divisor=1;
+ float64 FrameRate=0;
+ for (size_t Pos=1; Pos<List.size(); Pos++)
+ {
+ if (!List[Pos].empty())
+ {
+ switch (List[Pos][0])
+ {
+ case 'A' : //Pixel aspect ratio
+ {
+ ZtringList Value; Value.Separator_Set(0, ":");
+ Value.Write(List[Pos].substr(1));
+ if (Value.size()==2)
+ {
+ float64 x=Value[0].To_float64();
+ float64 y=Value[1].To_float64();
+ if (x && y)
+ Fill(Stream_Video, 0, Video_PixelAspectRatio, x/y, 3);
+ }
+ }
+ break;
+ case 'C' : //Color space
+ if (List[Pos]==_T("C420jpeg") || List[Pos]==_T("C420paldv") || List[Pos]==_T("C420"))
+ {
+ Fill(Stream_Video, 0, Video_ChromaSubsampling, "4:2:0");
+ Multiplier=3;
+ Divisor=2;
+ }
+ if (List[Pos]==_T("C422"))
+ {
+ Fill(Stream_Video, 0, Video_ChromaSubsampling, "4:2:2");
+ Multiplier=2;
+ }
+ if (List[Pos]==_T("C444"))
+ {
+ Fill(Stream_Video, 0, Video_ChromaSubsampling, "4:4:4");
+ Multiplier=3;
+ }
+ break;
+ case 'F' : //Frame rate
+ {
+ ZtringList Value; Value.Separator_Set(0, ":");
+ Value.Write(List[Pos].substr(1));
+ if (Value.size()==2)
+ {
+ float64 N=Value[0].To_float64();
+ float64 D=Value[1].To_float64();
+ if (N && D)
+ {
+ FrameRate=N/D;
+ Fill(Stream_Video, 0, Video_FrameRate, FrameRate, 3);
+ }
+ }
+ }
+ break;
+ case 'H' : //Height
+ {
+ Ztring Value=List[Pos].substr(1);
+ Height=Value.To_int64u();
+ Fill(Stream_Video, 0, Video_Height, Height); break;
+ }
+ break;
+ case 'I' : //Interlacing
+ if (List[Pos].size()==2)
+ switch (List[Pos][1])
+ {
+ case 'p' : Fill(Stream_Video, 0, Video_ScanType, "Progressive"); break;
+ case 't' : Fill(Stream_Video, 0, Video_ScanType, "Progressive"); Fill(Stream_Video, 0, Video_ScanOrder, "TFF"); break;
+ case 'b' : Fill(Stream_Video, 0, Video_ScanType, "Progressive"); Fill(Stream_Video, 0, Video_ScanOrder, "BFF"); break;
+ case 'm' : Fill(Stream_Video, 0, Video_ScanType, "Mixed"); break;
+ default : ;
+ }
+ break;
+ case 'W' : //Width
+ {
+ Ztring Value=List[Pos].substr(1);
+ Width=Value.To_int64u();
+ Fill(Stream_Video, 0, Video_Width, Width); break;
+ }
+ break;
+ default : ;
+ }
+ }
+ }
+
+ //Duration (we expect no meta per frame)
+ if (Width && Height && Multiplier)
+ {
+ int64u Frame_ByteSize=6+Width*Height*Multiplier/Divisor; //5 for "FRAME\0"
+ Fill(Stream_Video, 0, Video_FrameCount, File_Size/Frame_ByteSize);
+ if (FrameRate)
+ Fill(Stream_Video, 0, Video_BitRate, Width*Height*Multiplier/Divisor*8*FrameRate);
+ }
+
+ Finish();
+}
+
+} //NameSpace
+
+#endif //MEDIAINFO_Y4M_YES
diff --git a/src/thirdparty/MediaInfo/MediaInfo/Video/File_Y4m.h b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Y4m.h
new file mode 100644
index 000000000..a77d292ef
--- /dev/null
+++ b/src/thirdparty/MediaInfo/MediaInfo/Video/File_Y4m.h
@@ -0,0 +1,62 @@
+// File_Y4m - Info for YUV4MPEG2 files
+// Copyright (C) 2011-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This library is free software: you can redistribute it and/or modify it
+// under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library. If not, see <http://www.gnu.org/licenses/>.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Information about YUV4MPEG2 files
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef MediaInfo_Y4mH
+#define MediaInfo_Y4mH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "MediaInfo/File__Analyze.h"
+//---------------------------------------------------------------------------
+
+namespace MediaInfoLib
+{
+
+//***************************************************************************
+// Class File_Y4m
+//***************************************************************************
+
+class File_Y4m : public File__Analyze
+{
+public :
+ //Constructor/Destructor
+ File_Y4m();
+ ~File_Y4m();
+
+private :
+ //Streams management
+ void Streams_Accept();
+ void Streams_Fill();
+
+ //Buffer - File header
+ bool FileHeader_Begin();
+ void FileHeader_Parse();
+
+ //Temp
+ size_t HeaderEnd;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/MediaInfo/ThirdParty/base64/base64.h b/src/thirdparty/MediaInfo/ThirdParty/base64/base64.h
new file mode 100644
index 000000000..40a340c61
--- /dev/null
+++ b/src/thirdparty/MediaInfo/ThirdParty/base64/base64.h
@@ -0,0 +1,158 @@
+//  //
+// #### ### ## -= Base64 library =-  //
+// # # # # # Base64.h - Base64 encoder/decoder  //
+// #### #### # #  //
+// # # # # ##### Encodes and decodes base64 strings  //
+// # # # # # Ideas taken from work done by Bob Withers  //
+// #### ### # R1 2002-05-07 by Markus Ewald  //
+//  //
+#ifndef B64_BASE64_H
+#define B64_BASE64_H
+
+#include <string>
+
+namespace Base64 {
+
+ /// Encode string to base64
+ inline std::string encode(const std::string &sString);
+ /// Encode base64 into string
+ inline std::string decode(const std::string &sString);
+
+}; // namespace Base64
+
+// ####################################################################### //
+// # Base64::encode() # //
+// ####################################################################### //
+/** Encodes the specified string to base64
+
+ @param sString String to encode
+ @return Base64 encoded string
+*/
+inline std::string Base64::encode(const std::string &sString) {
+ static const std::string sBase64Table(
+ // 0000000000111111111122222222223333333333444444444455555555556666
+ // 0123456789012345678901234567890123456789012345678901234567890123
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
+ );
+ static const char cFillChar = '=';
+ std::string::size_type nLength = sString.length();
+ std::string sResult;
+
+ // Allocate memory for the converted string
+ sResult.reserve(nLength * 8 / 6 + 1);
+
+ for(std::string::size_type nPos = 0; nPos < nLength; nPos++) {
+ char cCode;
+
+ // Encode the first 6 bits
+ cCode = (sString[nPos] >> 2) & 0x3f;
+ sResult.append(1, sBase64Table[cCode]);
+
+ // Encode the remaining 2 bits with the next 4 bits (if present)
+ cCode = (sString[nPos] << 4) & 0x3f;
+ if(++nPos < nLength)
+ cCode |= (sString[nPos] >> 4) & 0x0f;
+ sResult.append(1, sBase64Table[cCode]);
+
+ if(nPos < nLength) {
+ cCode = (sString[nPos] << 2) & 0x3f;
+ if(++nPos < nLength)
+ cCode |= (sString[nPos] >> 6) & 0x03;
+
+ sResult.append(1, sBase64Table[cCode]);
+ } else {
+ ++nPos;
+ sResult.append(1, cFillChar);
+ }
+
+ if(nPos < nLength) {
+ cCode = sString[nPos] & 0x3f;
+ sResult.append(1, sBase64Table[cCode]);
+ } else {
+ sResult.append(1, cFillChar);
+ }
+ }
+
+ return sResult;
+}
+
+// ####################################################################### //
+// # Base64::decode() # //
+// ####################################################################### //
+/** Decodes the specified base64 string
+
+ @param sString Base64 string to decode
+ @return Decoded string
+*/
+inline std::string Base64::decode(const std::string &sString) {
+ static const std::string::size_type np = std::string::npos;
+ static const std::string::size_type DecodeTable[] = {
+ // 0 1 2 3 4 5 6 7 8 9
+ np, np, np, np, np, np, np, np, np, np, // 0 - 9
+ np, np, np, np, np, np, np, np, np, np, // 10 - 19
+ np, np, np, np, np, np, np, np, np, np, // 20 - 29
+ np, np, np, np, np, np, np, np, np, np, // 30 - 39
+ np, np, np, 62, np, np, np, 63, 52, 53, // 40 - 49
+ 54, 55, 56, 57, 58, 59, 60, 61, np, np, // 50 - 59
+ np, np, np, np, np, 0, 1, 2, 3, 4, // 60 - 69
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 70 - 79
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, // 80 - 89
+ 25, np, np, np, np, np, np, 26, 27, 28, // 90 - 99
+ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // 100 - 109
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, // 110 - 119
+ 49, 50, 51, np, np, np, np, np, np, np, // 120 - 129
+ np, np, np, np, np, np, np, np, np, np, // 130 - 139
+ np, np, np, np, np, np, np, np, np, np, // 140 - 149
+ np, np, np, np, np, np, np, np, np, np, // 150 - 159
+ np, np, np, np, np, np, np, np, np, np, // 160 - 169
+ np, np, np, np, np, np, np, np, np, np, // 170 - 179
+ np, np, np, np, np, np, np, np, np, np, // 180 - 189
+ np, np, np, np, np, np, np, np, np, np, // 190 - 199
+ np, np, np, np, np, np, np, np, np, np, // 200 - 209
+ np, np, np, np, np, np, np, np, np, np, // 210 - 219
+ np, np, np, np, np, np, np, np, np, np, // 220 - 229
+ np, np, np, np, np, np, np, np, np, np, // 230 - 239
+ np, np, np, np, np, np, np, np, np, np, // 240 - 249
+ np, np, np, np, np, np // 250 - 256
+ };
+ static const char cFillChar = '=';
+
+ std::string::size_type nLength = sString.length();
+ std::string sResult;
+
+ sResult.reserve(nLength);
+
+ for(std::string::size_type nPos = 0; nPos < nLength; nPos++) {
+ unsigned char c, c1;
+
+ c = (char) DecodeTable[(unsigned char)sString[nPos]];
+ nPos++;
+ c1 = (char) DecodeTable[(unsigned char)sString[nPos]];
+ c = (c << 2) | ((c1 >> 4) & 0x3);
+ sResult.append(1, c);
+
+ if(++nPos < nLength) {
+ c = sString[nPos];
+ if(cFillChar == c)
+ break;
+
+ c = (char) DecodeTable[(unsigned char)sString[nPos]];
+ c1 = ((c1 << 4) & 0xf0) | ((c >> 2) & 0xf);
+ sResult.append(1, c1);
+ }
+
+ if(++nPos < nLength) {
+ c1 = sString[nPos];
+ if(cFillChar == c1)
+ break;
+
+ c1 = (char) DecodeTable[(unsigned char)sString[nPos]];
+ c = ((c << 6) & 0xc0) | c1;
+ sResult.append(1, c);
+ }
+ }
+
+ return sResult;
+}
+
+#endif // B64_BASE64_H
diff --git a/src/thirdparty/MediaInfo/ThirdParty/tinyxml2/tinyxml2.cpp b/src/thirdparty/MediaInfo/ThirdParty/tinyxml2/tinyxml2.cpp
new file mode 100644
index 000000000..76d6636ad
--- /dev/null
+++ b/src/thirdparty/MediaInfo/ThirdParty/tinyxml2/tinyxml2.cpp
@@ -0,0 +1,1824 @@
+/*
+Original code by Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+#include "tinyxml2.h"
+
+#if 1
+ #include <cstdio>
+ #include <cstdlib>
+ #include <new>
+ using namespace std;
+#else
+ #include <string.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <ctype.h>
+ #include <new>
+ #include <stdarg.h>
+#endif
+
+using namespace tinyxml2;
+
+static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF
+static const char LF = LINE_FEED;
+static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out
+static const char CR = CARRIAGE_RETURN;
+static const char SINGLE_QUOTE = '\'';
+static const char DOUBLE_QUOTE = '\"';
+
+// Bunch of unicode info at:
+// http://www.unicode.org/faq/utf_bom.html
+// ef bb bf (Microsoft "lead bytes") - designates UTF-8
+
+static const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
+static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
+static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
+
+
+#define DELETE_NODE( node ) { \
+ if ( node ) { \
+ MemPool* pool = node->memPool; \
+ node->~XMLNode(); \
+ pool->Free( node ); \
+ } \
+}
+#define DELETE_ATTRIBUTE( attrib ) { \
+ if ( attrib ) { \
+ MemPool* pool = attrib->memPool; \
+ attrib->~XMLAttribute(); \
+ pool->Free( attrib ); \
+ } \
+}
+
+struct Entity {
+ const char* pattern;
+ int length;
+ char value;
+};
+
+static const int NUM_ENTITIES = 5;
+static const Entity entities[NUM_ENTITIES] =
+{
+ { "quot", 4, DOUBLE_QUOTE },
+ { "amp", 3, '&' },
+ { "apos", 4, SINGLE_QUOTE },
+ { "lt", 2, '<' },
+ { "gt", 2, '>' }
+};
+
+
+StrPair::~StrPair()
+{
+ Reset();
+}
+
+
+void StrPair::Reset()
+{
+ if ( flags & NEEDS_DELETE ) {
+ delete [] start;
+ }
+ flags = 0;
+ start = 0;
+ end = 0;
+}
+
+
+void StrPair::SetStr( const char* str, int flags )
+{
+ Reset();
+ size_t len = strlen( str );
+ start = new char[ len+1 ];
+ memcpy( start, str, len+1 );
+ end = start + len;
+ this->flags = flags | NEEDS_DELETE;
+}
+
+
+char* StrPair::ParseText( char* p, const char* endTag, int strFlags )
+{
+ TIXMLASSERT( endTag && *endTag );
+
+ char* start = p; // fixme: hides a member
+ char endChar = *endTag;
+ int length = strlen( endTag );
+
+ // Inner loop of text parsing.
+ while ( *p ) {
+ if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) {
+ Set( start, p, strFlags );
+ return p + length;
+ }
+ ++p;
+ }
+ return 0;
+}
+
+
+char* StrPair::ParseName( char* p )
+{
+ char* start = p;
+
+ if ( !start || !(*start) ) {
+ return 0;
+ }
+
+ if ( !XMLUtil::IsAlpha( *p ) ) {
+ return 0;
+ }
+
+ while( *p && (
+ XMLUtil::IsAlphaNum( (unsigned char) *p )
+ || *p == '_'
+ || *p == '-'
+ || *p == '.'
+ || *p == ':' ))
+ {
+ ++p;
+ }
+
+ if ( p > start ) {
+ Set( start, p, 0 );
+ return p;
+ }
+ return 0;
+}
+
+
+
+const char* StrPair::GetStr()
+{
+ if ( flags & NEEDS_FLUSH ) {
+ *end = 0;
+ flags ^= NEEDS_FLUSH;
+
+ if ( flags ) {
+ char* p = start; // the read pointer
+ char* q = start; // the write pointer
+
+ while( p < end ) {
+ if ( (flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) {
+ // CR-LF pair becomes LF
+ // CR alone becomes LF
+ // LF-CR becomes LF
+ if ( *(p+1) == LF ) {
+ p += 2;
+ }
+ else {
+ ++p;
+ }
+ *q++ = LF;
+ }
+ else if ( (flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) {
+ if ( *(p+1) == CR ) {
+ p += 2;
+ }
+ else {
+ ++p;
+ }
+ *q++ = LF;
+ }
+ else if ( (flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) {
+ int i=0;
+
+ // Entities handled by tinyXML2:
+ // - special entities in the entity table [in/out]
+ // - numeric character reference [in]
+ // &#20013; or &#x4e2d;
+
+ if ( *(p+1) == '#' ) {
+ char buf[10] = { 0 };
+ int len;
+ p = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );
+ for( int i=0; i<len; ++i ) {
+ *q++ = buf[i];
+ }
+ TIXMLASSERT( q <= p );
+ }
+ else {
+ for( i=0; i<NUM_ENTITIES; ++i ) {
+ if ( strncmp( p+1, entities[i].pattern, entities[i].length ) == 0
+ && *(p+entities[i].length+1) == ';' )
+ {
+ // Found an entity convert;
+ *q = entities[i].value;
+ ++q;
+ p += entities[i].length + 2;
+ break;
+ }
+ }
+ if ( i == NUM_ENTITIES ) {
+ // fixme: treat as error?
+ ++p;
+ ++q;
+ }
+ }
+ }
+ else {
+ *q = *p;
+ ++p;
+ ++q;
+ }
+ }
+ *q = 0;
+ }
+ flags = (flags & NEEDS_DELETE);
+ }
+ return start;
+}
+
+
+
+
+// --------- XMLUtil ----------- //
+
+const char* XMLUtil::ReadBOM( const char* p, bool* bom )
+{
+ *bom = false;
+ const unsigned char* pu = reinterpret_cast<const unsigned char*>(p);
+ // Check for BOM:
+ if ( *(pu+0) == TIXML_UTF_LEAD_0
+ && *(pu+1) == TIXML_UTF_LEAD_1
+ && *(pu+2) == TIXML_UTF_LEAD_2 )
+ {
+ *bom = true;
+ p += 3;
+ }
+ return p;
+}
+
+
+void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length )
+{
+ const unsigned long BYTE_MASK = 0xBF;
+ const unsigned long BYTE_MARK = 0x80;
+ const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
+
+ if (input < 0x80)
+ *length = 1;
+ else if ( input < 0x800 )
+ *length = 2;
+ else if ( input < 0x10000 )
+ *length = 3;
+ else if ( input < 0x200000 )
+ *length = 4;
+ else
+ { *length = 0; return; } // This code won't covert this correctly anyway.
+
+ output += *length;
+
+ // Scary scary fall throughs.
+ switch (*length)
+ {
+ case 4:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 3:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 2:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 1:
+ --output;
+ *output = (char)(input | FIRST_BYTE_MARK[*length]);
+ }
+}
+
+
+const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
+{
+ // Presume an entity, and pull it out.
+ *length = 0;
+
+ if ( *(p+1) == '#' && *(p+2) )
+ {
+ unsigned long ucs = 0;
+ int delta = 0;
+ unsigned mult = 1;
+
+ if ( *(p+2) == 'x' )
+ {
+ // Hexadecimal.
+ if ( !*(p+3) ) return 0;
+
+ const char* q = p+3;
+ q = strchr( q, ';' );
+
+ if ( !q || !*q ) return 0;
+
+ delta = (q-p);
+ --q;
+
+ while ( *q != 'x' )
+ {
+ if ( *q >= '0' && *q <= '9' )
+ ucs += mult * (*q - '0');
+ else if ( *q >= 'a' && *q <= 'f' )
+ ucs += mult * (*q - 'a' + 10);
+ else if ( *q >= 'A' && *q <= 'F' )
+ ucs += mult * (*q - 'A' + 10 );
+ else
+ return 0;
+ mult *= 16;
+ --q;
+ }
+ }
+ else
+ {
+ // Decimal.
+ if ( !*(p+2) ) return 0;
+
+ const char* q = p+2;
+ q = strchr( q, ';' );
+
+ if ( !q || !*q ) return 0;
+
+ delta = q-p;
+ --q;
+
+ while ( *q != '#' )
+ {
+ if ( *q >= '0' && *q <= '9' )
+ ucs += mult * (*q - '0');
+ else
+ return 0;
+ mult *= 10;
+ --q;
+ }
+ }
+ // convert the UCS to UTF-8
+ ConvertUTF32ToUTF8( ucs, value, length );
+ return p + delta + 1;
+ }
+ return p+1;
+}
+
+
+char* XMLDocument::Identify( char* p, XMLNode** node )
+{
+ XMLNode* returnNode = 0;
+ char* start = p;
+ p = XMLUtil::SkipWhiteSpace( p );
+ if( !p || !*p )
+ {
+ return p;
+ }
+
+ // What is this thing?
+ // - Elements start with a letter or underscore, but xml is reserved.
+ // - Comments: <!--
+ // - Decleration: <?
+ // - Everthing else is unknown to tinyxml.
+ //
+
+ static const char* xmlHeader = { "<?" };
+ static const char* commentHeader = { "<!--" };
+ static const char* dtdHeader = { "<!" };
+ static const char* cdataHeader = { "<![CDATA[" };
+ static const char* elementHeader = { "<" }; // and a header for everything else; check last.
+
+ static const int xmlHeaderLen = 2;
+ static const int commentHeaderLen = 4;
+ static const int dtdHeaderLen = 2;
+ static const int cdataHeaderLen = 9;
+ static const int elementHeaderLen = 1;
+
+#if defined(_MSC_VER)
+#pragma warning ( push )
+#pragma warning ( disable : 4127 )
+#endif
+ TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLUnknown ) ); // use same memory pool
+ TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLDeclaration ) ); // use same memory pool
+#if defined(_MSC_VER)
+#pragma warning (pop)
+#endif
+ if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) {
+ returnNode = new (commentPool.Alloc()) XMLDeclaration( this );
+ returnNode->memPool = &commentPool;
+ p += xmlHeaderLen;
+ }
+ else if ( XMLUtil::StringEqual( p, commentHeader, commentHeaderLen ) ) {
+ returnNode = new (commentPool.Alloc()) XMLComment( this );
+ returnNode->memPool = &commentPool;
+ p += commentHeaderLen;
+ }
+ else if ( XMLUtil::StringEqual( p, cdataHeader, cdataHeaderLen ) ) {
+ XMLText* text = new (textPool.Alloc()) XMLText( this );
+ returnNode = text;
+ returnNode->memPool = &textPool;
+ p += cdataHeaderLen;
+ text->SetCData( true );
+ }
+ else if ( XMLUtil::StringEqual( p, dtdHeader, dtdHeaderLen ) ) {
+ returnNode = new (commentPool.Alloc()) XMLUnknown( this );
+ returnNode->memPool = &commentPool;
+ p += dtdHeaderLen;
+ }
+ else if ( XMLUtil::StringEqual( p, elementHeader, elementHeaderLen ) ) {
+ returnNode = new (elementPool.Alloc()) XMLElement( this );
+ returnNode->memPool = &elementPool;
+ p += elementHeaderLen;
+ }
+ else {
+ returnNode = new (textPool.Alloc()) XMLText( this );
+ returnNode->memPool = &textPool;
+ p = start; // Back it up, all the text counts.
+ }
+
+ *node = returnNode;
+ return p;
+}
+
+
+bool XMLDocument::Accept( XMLVisitor* visitor ) const
+{
+ if ( visitor->VisitEnter( *this ) )
+ {
+ for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() )
+ {
+ if ( !node->Accept( visitor ) )
+ break;
+ }
+ }
+ return visitor->VisitExit( *this );
+}
+
+
+// --------- XMLNode ----------- //
+
+XMLNode::XMLNode( XMLDocument* doc ) :
+ document( doc ),
+ parent( 0 ),
+ firstChild( 0 ), lastChild( 0 ),
+ prev( 0 ), next( 0 )
+{
+}
+
+
+XMLNode::~XMLNode()
+{
+ DeleteChildren();
+ if ( parent ) {
+ parent->Unlink( this );
+ }
+}
+
+
+void XMLNode::SetValue( const char* str, bool staticMem )
+{
+ if ( staticMem )
+ value.SetInternedStr( str );
+ else
+ value.SetStr( str );
+}
+
+
+void XMLNode::DeleteChildren()
+{
+ while( firstChild ) {
+ XMLNode* node = firstChild;
+ Unlink( node );
+
+ DELETE_NODE( node );
+ }
+ firstChild = lastChild = 0;
+}
+
+
+void XMLNode::Unlink( XMLNode* child )
+{
+ TIXMLASSERT( child->parent == this );
+ if ( child == firstChild )
+ firstChild = firstChild->next;
+ if ( child == lastChild )
+ lastChild = lastChild->prev;
+
+ if ( child->prev ) {
+ child->prev->next = child->next;
+ }
+ if ( child->next ) {
+ child->next->prev = child->prev;
+ }
+ child->parent = 0;
+}
+
+
+void XMLNode::DeleteChild( XMLNode* node )
+{
+ TIXMLASSERT( node->parent == this );
+ DELETE_NODE( node );
+}
+
+
+XMLNode* XMLNode::InsertEndChild( XMLNode* addThis )
+{
+ if ( lastChild ) {
+ TIXMLASSERT( firstChild );
+ TIXMLASSERT( lastChild->next == 0 );
+ lastChild->next = addThis;
+ addThis->prev = lastChild;
+ lastChild = addThis;
+
+ addThis->next = 0;
+ }
+ else {
+ TIXMLASSERT( firstChild == 0 );
+ firstChild = lastChild = addThis;
+
+ addThis->prev = 0;
+ addThis->next = 0;
+ }
+ addThis->parent = this;
+ return addThis;
+}
+
+
+XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis )
+{
+ if ( firstChild ) {
+ TIXMLASSERT( lastChild );
+ TIXMLASSERT( firstChild->prev == 0 );
+
+ firstChild->prev = addThis;
+ addThis->next = firstChild;
+ firstChild = addThis;
+
+ addThis->prev = 0;
+ }
+ else {
+ TIXMLASSERT( lastChild == 0 );
+ firstChild = lastChild = addThis;
+
+ addThis->prev = 0;
+ addThis->next = 0;
+ }
+ addThis->parent = this;
+ return addThis;
+}
+
+
+XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis )
+{
+ TIXMLASSERT( afterThis->parent == this );
+ if ( afterThis->parent != this )
+ return 0;
+
+ if ( afterThis->next == 0 ) {
+ // The last node or the only node.
+ return InsertEndChild( addThis );
+ }
+ addThis->prev = afterThis;
+ addThis->next = afterThis->next;
+ afterThis->next->prev = addThis;
+ afterThis->next = addThis;
+ addThis->parent = this;
+ return addThis;
+}
+
+
+
+
+const XMLElement* XMLNode::FirstChildElement( const char* value ) const
+{
+ for( XMLNode* node=firstChild; node; node=node->next ) {
+ XMLElement* element = node->ToElement();
+ if ( element ) {
+ if ( !value || XMLUtil::StringEqual( element->Name(), value ) ) {
+ return element;
+ }
+ }
+ }
+ return 0;
+}
+
+
+const XMLElement* XMLNode::LastChildElement( const char* value ) const
+{
+ for( XMLNode* node=lastChild; node; node=node->prev ) {
+ XMLElement* element = node->ToElement();
+ if ( element ) {
+ if ( !value || XMLUtil::StringEqual( element->Name(), value ) ) {
+ return element;
+ }
+ }
+ }
+ return 0;
+}
+
+
+const XMLElement* XMLNode::NextSiblingElement( const char* value ) const
+{
+ for( XMLNode* element=this->next; element; element = element->next ) {
+ if ( element->ToElement()
+ && (!value || XMLUtil::StringEqual( value, element->Value() )))
+ {
+ return element->ToElement();
+ }
+ }
+ return 0;
+}
+
+
+const XMLElement* XMLNode::PreviousSiblingElement( const char* value ) const
+{
+ for( XMLNode* element=this->prev; element; element = element->prev ) {
+ if ( element->ToElement()
+ && (!value || XMLUtil::StringEqual( value, element->Value() )))
+ {
+ return element->ToElement();
+ }
+ }
+ return 0;
+}
+
+
+char* XMLNode::ParseDeep( char* p, StrPair* parentEnd )
+{
+ // This is a recursive method, but thinking about it "at the current level"
+ // it is a pretty simple flat list:
+ // <foo/>
+ // <!-- comment -->
+ //
+ // With a special case:
+ // <foo>
+ // </foo>
+ // <!-- comment -->
+ //
+ // Where the closing element (/foo) *must* be the next thing after the opening
+ // element, and the names must match. BUT the tricky bit is that the closing
+ // element will be read by the child.
+ //
+ // 'endTag' is the end tag for this node, it is returned by a call to a child.
+ // 'parentEnd' is the end tag for the parent, which is filled in and returned.
+
+ while( p && *p ) {
+ XMLNode* node = 0;
+
+ p = document->Identify( p, &node );
+ if ( p == 0 || node == 0 ) {
+ break;
+ }
+
+ StrPair endTag;
+ p = node->ParseDeep( p, &endTag );
+ if ( !p ) {
+ DELETE_NODE( node );
+ node = 0;
+ if ( !document->Error() ) {
+ document->SetError( XML_ERROR_PARSING, 0, 0 );
+ }
+ break;
+ }
+
+ // We read the end tag. Return it to the parent.
+ if ( node->ToElement() && node->ToElement()->ClosingType() == XMLElement::CLOSING ) {
+ if ( parentEnd ) {
+ *parentEnd = ((XMLElement*)node)->value;
+ }
+ DELETE_NODE( node );
+ return p;
+ }
+
+ // Handle an end tag returned to this level.
+ // And handle a bunch of annoying errors.
+ XMLElement* ele = node->ToElement();
+ if ( ele ) {
+ if ( endTag.Empty() && ele->ClosingType() == XMLElement::OPEN ) {
+ document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
+ p = 0;
+ }
+ else if ( !endTag.Empty() && ele->ClosingType() != XMLElement::OPEN ) {
+ document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
+ p = 0;
+ }
+ else if ( !endTag.Empty() ) {
+ if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) {
+ document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
+ p = 0;
+ }
+ }
+ }
+ if ( p == 0 ) {
+ DELETE_NODE( node );
+ node = 0;
+ }
+ if ( node ) {
+ this->InsertEndChild( node );
+ }
+ }
+ return 0;
+}
+
+// --------- XMLText ---------- //
+char* XMLText::ParseDeep( char* p, StrPair* )
+{
+ const char* start = p;
+ if ( this->CData() ) {
+ p = value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION );
+ if ( !p ) {
+ document->SetError( XML_ERROR_PARSING_CDATA, start, 0 );
+ }
+ return p;
+ }
+ else {
+ p = value.ParseText( p, "<", document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES );
+ if ( !p ) {
+ document->SetError( XML_ERROR_PARSING_TEXT, start, 0 );
+ }
+ if ( p && *p ) {
+ return p-1;
+ }
+ }
+ return 0;
+}
+
+
+XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const
+{
+ if ( !doc ) {
+ doc = document;
+ }
+ XMLText* text = doc->NewText( Value() ); // fixme: this will always allocate memory. Intern?
+ text->SetCData( this->CData() );
+ return text;
+}
+
+
+bool XMLText::ShallowEqual( const XMLNode* compare ) const
+{
+ return ( compare->ToText() && XMLUtil::StringEqual( compare->ToText()->Value(), Value() ));
+}
+
+
+bool XMLText::Accept( XMLVisitor* visitor ) const
+{
+ return visitor->Visit( *this );
+}
+
+
+// --------- XMLComment ---------- //
+
+XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc )
+{
+}
+
+
+XMLComment::~XMLComment()
+{
+ //printf( "~XMLComment\n" );
+}
+
+
+char* XMLComment::ParseDeep( char* p, StrPair* )
+{
+ // Comment parses as text.
+ const char* start = p;
+ p = value.ParseText( p, "-->", StrPair::COMMENT );
+ if ( p == 0 ) {
+ document->SetError( XML_ERROR_PARSING_COMMENT, start, 0 );
+ }
+ return p;
+}
+
+
+XMLNode* XMLComment::ShallowClone( XMLDocument* doc ) const
+{
+ if ( !doc ) {
+ doc = document;
+ }
+ XMLComment* comment = doc->NewComment( Value() ); // fixme: this will always allocate memory. Intern?
+ return comment;
+}
+
+
+bool XMLComment::ShallowEqual( const XMLNode* compare ) const
+{
+ return ( compare->ToComment() && XMLUtil::StringEqual( compare->ToComment()->Value(), Value() ));
+}
+
+
+bool XMLComment::Accept( XMLVisitor* visitor ) const
+{
+ return visitor->Visit( *this );
+}
+
+
+// --------- XMLDeclaration ---------- //
+
+XMLDeclaration::XMLDeclaration( XMLDocument* doc ) : XMLNode( doc )
+{
+}
+
+
+XMLDeclaration::~XMLDeclaration()
+{
+ //printf( "~XMLDeclaration\n" );
+}
+
+
+char* XMLDeclaration::ParseDeep( char* p, StrPair* )
+{
+ // Declaration parses as text.
+ const char* start = p;
+ p = value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION );
+ if ( p == 0 ) {
+ document->SetError( XML_ERROR_PARSING_DECLARATION, start, 0 );
+ }
+ return p;
+}
+
+
+XMLNode* XMLDeclaration::ShallowClone( XMLDocument* doc ) const
+{
+ if ( !doc ) {
+ doc = document;
+ }
+ XMLDeclaration* dec = doc->NewDeclaration( Value() ); // fixme: this will always allocate memory. Intern?
+ return dec;
+}
+
+
+bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const
+{
+ return ( compare->ToDeclaration() && XMLUtil::StringEqual( compare->ToDeclaration()->Value(), Value() ));
+}
+
+
+
+bool XMLDeclaration::Accept( XMLVisitor* visitor ) const
+{
+ return visitor->Visit( *this );
+}
+
+// --------- XMLUnknown ---------- //
+
+XMLUnknown::XMLUnknown( XMLDocument* doc ) : XMLNode( doc )
+{
+}
+
+
+XMLUnknown::~XMLUnknown()
+{
+}
+
+
+char* XMLUnknown::ParseDeep( char* p, StrPair* )
+{
+ // Unknown parses as text.
+ const char* start = p;
+
+ p = value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION );
+ if ( !p ) {
+ document->SetError( XML_ERROR_PARSING_UNKNOWN, start, 0 );
+ }
+ return p;
+}
+
+
+XMLNode* XMLUnknown::ShallowClone( XMLDocument* doc ) const
+{
+ if ( !doc ) {
+ doc = document;
+ }
+ XMLUnknown* text = doc->NewUnknown( Value() ); // fixme: this will always allocate memory. Intern?
+ return text;
+}
+
+
+bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const
+{
+ return ( compare->ToUnknown() && XMLUtil::StringEqual( compare->ToUnknown()->Value(), Value() ));
+}
+
+
+bool XMLUnknown::Accept( XMLVisitor* visitor ) const
+{
+ return visitor->Visit( *this );
+}
+
+// --------- XMLAttribute ---------- //
+char* XMLAttribute::ParseDeep( char* p, bool processEntities )
+{
+ p = name.ParseText( p, "=", StrPair::ATTRIBUTE_NAME );
+ if ( !p || !*p ) return 0;
+
+ char endTag[2] = { *p, 0 };
+ ++p;
+ p = value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES );
+ //if ( value.Empty() ) return 0;
+ return p;
+}
+
+
+void XMLAttribute::SetName( const char* n )
+{
+ name.SetStr( n );
+}
+
+
+int XMLAttribute::QueryIntValue( int* value ) const
+{
+ if ( TIXML_SSCANF( Value(), "%d", value ) == 1 )
+ return XML_NO_ERROR;
+ return XML_WRONG_ATTRIBUTE_TYPE;
+}
+
+
+int XMLAttribute::QueryUnsignedValue( unsigned int* value ) const
+{
+ if ( TIXML_SSCANF( Value(), "%u", value ) == 1 )
+ return XML_NO_ERROR;
+ return XML_WRONG_ATTRIBUTE_TYPE;
+}
+
+
+int XMLAttribute::QueryBoolValue( bool* value ) const
+{
+ int ival = -1;
+ QueryIntValue( &ival );
+
+ if ( ival > 0 || XMLUtil::StringEqual( Value(), "true" ) ) {
+ *value = true;
+ return XML_NO_ERROR;
+ }
+ else if ( ival == 0 || XMLUtil::StringEqual( Value(), "false" ) ) {
+ *value = false;
+ return XML_NO_ERROR;
+ }
+ return XML_WRONG_ATTRIBUTE_TYPE;
+}
+
+
+int XMLAttribute::QueryDoubleValue( double* value ) const
+{
+ if ( TIXML_SSCANF( Value(), "%lf", value ) == 1 )
+ return XML_NO_ERROR;
+ return XML_WRONG_ATTRIBUTE_TYPE;
+}
+
+
+int XMLAttribute::QueryFloatValue( float* value ) const
+{
+ if ( TIXML_SSCANF( Value(), "%f", value ) == 1 )
+ return XML_NO_ERROR;
+ return XML_WRONG_ATTRIBUTE_TYPE;
+}
+
+
+void XMLAttribute::SetAttribute( const char* v )
+{
+ value.SetStr( v );
+}
+
+
+void XMLAttribute::SetAttribute( int v )
+{
+ char buf[BUF_SIZE];
+ TIXML_SNPRINTF( buf, BUF_SIZE, "%d", v );
+ value.SetStr( buf );
+}
+
+
+void XMLAttribute::SetAttribute( unsigned v )
+{
+ char buf[BUF_SIZE];
+ TIXML_SNPRINTF( buf, BUF_SIZE, "%u", v );
+ value.SetStr( buf );
+}
+
+
+void XMLAttribute::SetAttribute( bool v )
+{
+ char buf[BUF_SIZE];
+ TIXML_SNPRINTF( buf, BUF_SIZE, "%d", v ? 1 : 0 );
+ value.SetStr( buf );
+}
+
+void XMLAttribute::SetAttribute( double v )
+{
+ char buf[BUF_SIZE];
+ TIXML_SNPRINTF( buf, BUF_SIZE, "%f", v );
+ value.SetStr( buf );
+}
+
+void XMLAttribute::SetAttribute( float v )
+{
+ char buf[BUF_SIZE];
+ TIXML_SNPRINTF( buf, BUF_SIZE, "%f", v );
+ value.SetStr( buf );
+}
+
+
+// --------- XMLElement ---------- //
+XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ),
+ closingType( 0 ),
+ rootAttribute( 0 )
+{
+}
+
+
+XMLElement::~XMLElement()
+{
+ while( rootAttribute ) {
+ XMLAttribute* next = rootAttribute->next;
+ DELETE_ATTRIBUTE( rootAttribute );
+ rootAttribute = next;
+ }
+}
+
+
+XMLAttribute* XMLElement::FindAttribute( const char* name )
+{
+ XMLAttribute* a = 0;
+ for( a=rootAttribute; a; a = a->next ) {
+ if ( XMLUtil::StringEqual( a->Name(), name ) )
+ return a;
+ }
+ return 0;
+}
+
+
+const XMLAttribute* XMLElement::FindAttribute( const char* name ) const
+{
+ XMLAttribute* a = 0;
+ for( a=rootAttribute; a; a = a->next ) {
+ if ( XMLUtil::StringEqual( a->Name(), name ) )
+ return a;
+ }
+ return 0;
+}
+
+
+const char* XMLElement::Attribute( const char* name, const char* value ) const
+{
+ const XMLAttribute* a = FindAttribute( name );
+ if ( !a )
+ return 0;
+ if ( !value || XMLUtil::StringEqual( a->Value(), value ))
+ return a->Value();
+ return 0;
+}
+
+
+const char* XMLElement::GetText() const
+{
+ if ( FirstChild() && FirstChild()->ToText() ) {
+ return FirstChild()->ToText()->Value();
+ }
+ return 0;
+}
+
+
+
+XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
+{
+ XMLAttribute* attrib = FindAttribute( name );
+ if ( !attrib ) {
+ attrib = new (document->attributePool.Alloc() ) XMLAttribute();
+ attrib->memPool = &document->attributePool;
+ LinkAttribute( attrib );
+ attrib->SetName( name );
+ }
+ return attrib;
+}
+
+
+void XMLElement::LinkAttribute( XMLAttribute* attrib )
+{
+ if ( rootAttribute ) {
+ XMLAttribute* end = rootAttribute;
+ while ( end->next )
+ end = end->next;
+ end->next = attrib;
+ }
+ else {
+ rootAttribute = attrib;
+ }
+}
+
+
+void XMLElement::DeleteAttribute( const char* name )
+{
+ XMLAttribute* prev = 0;
+ for( XMLAttribute* a=rootAttribute; a; a=a->next ) {
+ if ( XMLUtil::StringEqual( name, a->Name() ) ) {
+ if ( prev ) {
+ prev->next = a->next;
+ }
+ else {
+ rootAttribute = a->next;
+ }
+ DELETE_ATTRIBUTE( a );
+ break;
+ }
+ prev = a;
+ }
+}
+
+
+char* XMLElement::ParseAttributes( char* p )
+{
+ const char* start = p;
+
+ // Read the attributes.
+ while( p ) {
+ p = XMLUtil::SkipWhiteSpace( p );
+ if ( !p || !(*p) ) {
+ document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() );
+ return 0;
+ }
+
+ // attribute.
+ if ( XMLUtil::IsAlpha( *p ) ) {
+ XMLAttribute* attrib = new (document->attributePool.Alloc() ) XMLAttribute();
+ attrib->memPool = &document->attributePool;
+
+ p = attrib->ParseDeep( p, document->ProcessEntities() );
+ if ( !p || Attribute( attrib->Name() ) ) {
+ DELETE_ATTRIBUTE( attrib );
+ document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p );
+ return 0;
+ }
+ LinkAttribute( attrib );
+ }
+ // end of the tag
+ else if ( *p == '/' && *(p+1) == '>' ) {
+ closingType = CLOSED;
+ return p+2; // done; sealed element.
+ }
+ // end of the tag
+ else if ( *p == '>' ) {
+ ++p;
+ break;
+ }
+ else {
+ document->SetError( XML_ERROR_PARSING_ELEMENT, start, p );
+ return 0;
+ }
+ }
+ return p;
+}
+
+
+//
+// <ele></ele>
+// <ele>foo<b>bar</b></ele>
+//
+char* XMLElement::ParseDeep( char* p, StrPair* strPair )
+{
+ // Read the element name.
+ p = XMLUtil::SkipWhiteSpace( p );
+ if ( !p ) return 0;
+
+ // The closing element is the </element> form. It is
+ // parsed just like a regular element then deleted from
+ // the DOM.
+ if ( *p == '/' ) {
+ closingType = CLOSING;
+ ++p;
+ }
+
+ p = value.ParseName( p );
+ if ( value.Empty() ) return 0;
+
+ p = ParseAttributes( p );
+ if ( !p || !*p || closingType )
+ return p;
+
+ p = XMLNode::ParseDeep( p, strPair );
+ return p;
+}
+
+
+
+XMLNode* XMLElement::ShallowClone( XMLDocument* doc ) const
+{
+ if ( !doc ) {
+ doc = document;
+ }
+ XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern?
+ for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) {
+ element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern?
+ }
+ return element;
+}
+
+
+bool XMLElement::ShallowEqual( const XMLNode* compare ) const
+{
+ const XMLElement* other = compare->ToElement();
+ if ( other && XMLUtil::StringEqual( other->Value(), Value() )) {
+
+ const XMLAttribute* a=FirstAttribute();
+ const XMLAttribute* b=other->FirstAttribute();
+
+ while ( a && b ) {
+ if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) {
+ return false;
+ }
+ }
+ if ( a || b ) {
+ // different count
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+
+bool XMLElement::Accept( XMLVisitor* visitor ) const
+{
+ if ( visitor->VisitEnter( *this, rootAttribute ) )
+ {
+ for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() )
+ {
+ if ( !node->Accept( visitor ) )
+ break;
+ }
+ }
+ return visitor->VisitExit( *this );
+}
+
+
+// --------- XMLDocument ----------- //
+XMLDocument::XMLDocument( bool _processEntities ) :
+ XMLNode( 0 ),
+ writeBOM( false ),
+ processEntities( _processEntities ),
+ errorID( 0 ),
+ errorStr1( 0 ),
+ errorStr2( 0 ),
+ charBuffer( 0 )
+{
+ document = this; // avoid warning about 'this' in initializer list
+}
+
+
+XMLDocument::~XMLDocument()
+{
+ DeleteChildren();
+ delete [] charBuffer;
+
+#if 0
+ textPool.Trace( "text" );
+ elementPool.Trace( "element" );
+ commentPool.Trace( "comment" );
+ attributePool.Trace( "attribute" );
+#endif
+
+ TIXMLASSERT( textPool.CurrentAllocs() == 0 );
+ TIXMLASSERT( elementPool.CurrentAllocs() == 0 );
+ TIXMLASSERT( commentPool.CurrentAllocs() == 0 );
+ TIXMLASSERT( attributePool.CurrentAllocs() == 0 );
+}
+
+
+void XMLDocument::InitDocument()
+{
+ errorID = XML_NO_ERROR;
+ errorStr1 = 0;
+ errorStr2 = 0;
+
+ delete [] charBuffer;
+ charBuffer = 0;
+
+}
+
+
+XMLElement* XMLDocument::NewElement( const char* name )
+{
+ XMLElement* ele = new (elementPool.Alloc()) XMLElement( this );
+ ele->memPool = &elementPool;
+ ele->SetName( name );
+ return ele;
+}
+
+
+XMLComment* XMLDocument::NewComment( const char* str )
+{
+ XMLComment* comment = new (commentPool.Alloc()) XMLComment( this );
+ comment->memPool = &commentPool;
+ comment->SetValue( str );
+ return comment;
+}
+
+
+XMLText* XMLDocument::NewText( const char* str )
+{
+ XMLText* text = new (textPool.Alloc()) XMLText( this );
+ text->memPool = &textPool;
+ text->SetValue( str );
+ return text;
+}
+
+
+XMLDeclaration* XMLDocument::NewDeclaration( const char* str )
+{
+ XMLDeclaration* dec = new (commentPool.Alloc()) XMLDeclaration( this );
+ dec->memPool = &commentPool;
+ dec->SetValue( str );
+ return dec;
+}
+
+
+XMLUnknown* XMLDocument::NewUnknown( const char* str )
+{
+ XMLUnknown* unk = new (commentPool.Alloc()) XMLUnknown( this );
+ unk->memPool = &commentPool;
+ unk->SetValue( str );
+ return unk;
+}
+
+
+int XMLDocument::LoadFile( const char* filename )
+{
+ DeleteChildren();
+ InitDocument();
+
+#if defined(_MSC_VER)
+#pragma warning ( push )
+#pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
+#endif
+ FILE* fp = fopen( filename, "rb" );
+#if defined(_MSC_VER)
+#pragma warning ( pop )
+#endif
+ if ( !fp ) {
+ SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 );
+ return errorID;
+ }
+ LoadFile( fp );
+ fclose( fp );
+ return errorID;
+}
+
+
+int XMLDocument::LoadFile( FILE* fp )
+{
+ DeleteChildren();
+ InitDocument();
+
+ fseek( fp, 0, SEEK_END );
+ unsigned size = ftell( fp );
+ fseek( fp, 0, SEEK_SET );
+
+ if ( size == 0 ) {
+ return errorID;
+ }
+
+ charBuffer = new char[size+1];
+ fread( charBuffer, size, 1, fp );
+ charBuffer[size] = 0;
+
+ const char* p = charBuffer;
+ p = XMLUtil::SkipWhiteSpace( p );
+ p = XMLUtil::ReadBOM( p, &writeBOM );
+ if ( !p || !*p ) {
+ SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
+ return errorID;
+ }
+
+ ParseDeep( charBuffer + (p-charBuffer), 0 );
+ return errorID;
+}
+
+
+int XMLDocument::SaveFile( const char* filename )
+{
+#if defined(_MSC_VER)
+#pragma warning ( push )
+#pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
+#endif
+ FILE* fp = fopen( filename, "w" );
+#if defined(_MSC_VER)
+#pragma warning ( pop )
+#endif
+ if ( !fp ) {
+ SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 );
+ return errorID;
+ }
+ SaveFile(fp);
+ fclose( fp );
+ return errorID;
+}
+
+
+int XMLDocument::SaveFile( FILE* fp )
+{
+ XMLPrinter stream( fp );
+ Print( &stream );
+ return errorID;
+}
+
+
+int XMLDocument::Parse( const char* p )
+{
+ DeleteChildren();
+ InitDocument();
+
+ if ( !p || !*p ) {
+ SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
+ return errorID;
+ }
+ p = XMLUtil::SkipWhiteSpace( p );
+ p = XMLUtil::ReadBOM( p, &writeBOM );
+ if ( !p || !*p ) {
+ SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
+ return errorID;
+ }
+
+ size_t len = strlen( p );
+ charBuffer = new char[ len+1 ];
+ memcpy( charBuffer, p, len+1 );
+
+
+ ParseDeep( charBuffer, 0 );
+ return errorID;
+}
+
+
+void XMLDocument::Print( XMLPrinter* streamer )
+{
+ XMLPrinter stdStreamer( stdout );
+ if ( !streamer )
+ streamer = &stdStreamer;
+ Accept( streamer );
+}
+
+
+void XMLDocument::SetError( int error, const char* str1, const char* str2 )
+{
+ errorID = error;
+ errorStr1 = str1;
+ errorStr2 = str2;
+}
+
+
+void XMLDocument::PrintError() const
+{
+ if ( errorID ) {
+ static const int LEN = 20;
+ char buf1[LEN] = { 0 };
+ char buf2[LEN] = { 0 };
+
+ if ( errorStr1 ) {
+ TIXML_SNPRINTF( buf1, LEN, "%s", errorStr1 );
+ }
+ if ( errorStr2 ) {
+ TIXML_SNPRINTF( buf2, LEN, "%s", errorStr2 );
+ }
+
+ printf( "XMLDocument error id=%d str1=%s str2=%s\n",
+ errorID, buf1, buf2 );
+ }
+}
+
+
+XMLPrinter::XMLPrinter( FILE* file ) :
+ elementJustOpened( false ),
+ firstElement( true ),
+ fp( file ),
+ depth( 0 ),
+ textDepth( -1 ),
+ processEntities( true )
+{
+ for( int i=0; i<ENTITY_RANGE; ++i ) {
+ entityFlag[i] = false;
+ restrictedEntityFlag[i] = false;
+ }
+ for( int i=0; i<NUM_ENTITIES; ++i ) {
+ TIXMLASSERT( entities[i].value < ENTITY_RANGE );
+ if ( entities[i].value < ENTITY_RANGE ) {
+ entityFlag[ (int)entities[i].value ] = true;
+ }
+ }
+ restrictedEntityFlag[(int)'&'] = true;
+ restrictedEntityFlag[(int)'<'] = true;
+ restrictedEntityFlag[(int)'>'] = true; // not required, but consistency is nice
+ buffer.Push( 0 );
+}
+
+
+void XMLPrinter::Print( const char* format, ... )
+{
+ va_list va;
+ va_start( va, format );
+
+ if ( fp ) {
+ vfprintf( fp, format, va );
+ }
+ else {
+ // This seems brutally complex. Haven't figured out a better
+ // way on windows.
+ #ifdef _MSC_VER
+ int len = -1;
+ int expand = 1000;
+ while ( len < 0 ) {
+ len = vsnprintf_s( accumulator.Mem(), accumulator.Capacity(), _TRUNCATE, format, va );
+ if ( len < 0 ) {
+ expand *= 3/2;
+ accumulator.PushArr( expand );
+ }
+ }
+ char* p = buffer.PushArr( len ) - 1;
+ memcpy( p, accumulator.Mem(), len+1 );
+ #else
+ int len = vsnprintf( 0, 0, format, va );
+ // Close out and re-start the va-args
+ va_end( va );
+ va_start( va, format );
+ char* p = buffer.PushArr( len ) - 1;
+ vsnprintf( p, len+1, format, va );
+ #endif
+ }
+ va_end( va );
+}
+
+
+void XMLPrinter::PrintSpace( int depth )
+{
+ for( int i=0; i<depth; ++i ) {
+ Print( " " );
+ }
+}
+
+
+void XMLPrinter::PrintString( const char* p, bool restricted )
+{
+ // Look for runs of bytes between entities to print.
+ const char* q = p;
+ const bool* flag = restricted ? restrictedEntityFlag : entityFlag;
+
+ if ( processEntities ) {
+ while ( *q ) {
+ // Remember, char is sometimes signed. (How many times has that bitten me?)
+ if ( *q > 0 && *q < ENTITY_RANGE ) {
+ // Check for entities. If one is found, flush
+ // the stream up until the entity, write the
+ // entity, and keep looking.
+ if ( flag[(unsigned)(*q)] ) {
+ while ( p < q ) {
+ Print( "%c", *p );
+ ++p;
+ }
+ for( int i=0; i<NUM_ENTITIES; ++i ) {
+ if ( entities[i].value == *q ) {
+ Print( "&%s;", entities[i].pattern );
+ break;
+ }
+ }
+ ++p;
+ }
+ }
+ ++q;
+ }
+ }
+ // Flush the remaining string. This will be the entire
+ // string if an entity wasn't found.
+ if ( !processEntities || (q-p > 0) ) {
+ Print( "%s", p );
+ }
+}
+
+
+void XMLPrinter::PushHeader( bool writeBOM, bool writeDec )
+{
+ static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 };
+ if ( writeBOM ) {
+ Print( "%s", bom );
+ }
+ if ( writeDec ) {
+ PushDeclaration( "xml version=\"1.0\"" );
+ }
+}
+
+
+void XMLPrinter::OpenElement( const char* name )
+{
+ if ( elementJustOpened ) {
+ SealElement();
+ }
+ stack.Push( name );
+
+ if ( textDepth < 0 && !firstElement ) {
+ Print( "\n" );
+ PrintSpace( depth );
+ }
+
+ Print( "<%s", name );
+ elementJustOpened = true;
+ firstElement = false;
+ ++depth;
+}
+
+
+void XMLPrinter::PushAttribute( const char* name, const char* value )
+{
+ TIXMLASSERT( elementJustOpened );
+ Print( " %s=\"", name );
+ PrintString( value, false );
+ Print( "\"" );
+}
+
+
+void XMLPrinter::PushAttribute( const char* name, int v )
+{
+ char buf[BUF_SIZE];
+ TIXML_SNPRINTF( buf, BUF_SIZE, "%d", v );
+ PushAttribute( name, buf );
+}
+
+
+void XMLPrinter::PushAttribute( const char* name, unsigned v )
+{
+ char buf[BUF_SIZE];
+ TIXML_SNPRINTF( buf, BUF_SIZE, "%u", v );
+ PushAttribute( name, buf );
+}
+
+
+void XMLPrinter::PushAttribute( const char* name, bool v )
+{
+ char buf[BUF_SIZE];
+ TIXML_SNPRINTF( buf, BUF_SIZE, "%d", v ? 1 : 0 );
+ PushAttribute( name, buf );
+}
+
+
+void XMLPrinter::PushAttribute( const char* name, double v )
+{
+ char buf[BUF_SIZE];
+ TIXML_SNPRINTF( buf, BUF_SIZE, "%f", v );
+ PushAttribute( name, buf );
+}
+
+
+void XMLPrinter::CloseElement()
+{
+ --depth;
+ const char* name = stack.Pop();
+
+ if ( elementJustOpened ) {
+ Print( "/>" );
+ }
+ else {
+ if ( textDepth < 0 ) {
+ Print( "\n" );
+ PrintSpace( depth );
+ }
+ Print( "</%s>", name );
+ }
+
+ if ( textDepth == depth )
+ textDepth = -1;
+ if ( depth == 0 )
+ Print( "\n" );
+ elementJustOpened = false;
+}
+
+
+void XMLPrinter::SealElement()
+{
+ elementJustOpened = false;
+ Print( ">" );
+}
+
+
+void XMLPrinter::PushText( const char* text, bool cdata )
+{
+ textDepth = depth-1;
+
+ if ( elementJustOpened ) {
+ SealElement();
+ }
+ if ( cdata ) {
+ Print( "<![CDATA[" );
+ Print( "%s", text );
+ Print( "]]>" );
+ }
+ else {
+ PrintString( text, true );
+ }
+}
+
+
+void XMLPrinter::PushComment( const char* comment )
+{
+ if ( elementJustOpened ) {
+ SealElement();
+ }
+ if ( textDepth < 0 && !firstElement ) {
+ Print( "\n" );
+ PrintSpace( depth );
+ }
+ firstElement = false;
+ Print( "<!--%s-->", comment );
+}
+
+
+void XMLPrinter::PushDeclaration( const char* value )
+{
+ if ( elementJustOpened ) {
+ SealElement();
+ }
+ if ( textDepth < 0 && !firstElement) {
+ Print( "\n" );
+ PrintSpace( depth );
+ }
+ firstElement = false;
+ Print( "<?%s?>", value );
+}
+
+
+void XMLPrinter::PushUnknown( const char* value )
+{
+ if ( elementJustOpened ) {
+ SealElement();
+ }
+ if ( textDepth < 0 && !firstElement ) {
+ Print( "\n" );
+ PrintSpace( depth );
+ }
+ firstElement = false;
+ Print( "<!%s>", value );
+}
+
+
+bool XMLPrinter::VisitEnter( const XMLDocument& doc )
+{
+ processEntities = doc.ProcessEntities();
+ if ( doc.HasBOM() ) {
+ PushHeader( true, false );
+ }
+ return true;
+}
+
+
+bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute )
+{
+ OpenElement( element.Name() );
+ while ( attribute ) {
+ PushAttribute( attribute->Name(), attribute->Value() );
+ attribute = attribute->Next();
+ }
+ return true;
+}
+
+
+bool XMLPrinter::VisitExit( const XMLElement& )
+{
+ CloseElement();
+ return true;
+}
+
+
+bool XMLPrinter::Visit( const XMLText& text )
+{
+ PushText( text.Value(), text.CData() );
+ return true;
+}
+
+
+bool XMLPrinter::Visit( const XMLComment& comment )
+{
+ PushComment( comment.Value() );
+ return true;
+}
+
+bool XMLPrinter::Visit( const XMLDeclaration& declaration )
+{
+ PushDeclaration( declaration.Value() );
+ return true;
+}
+
+
+bool XMLPrinter::Visit( const XMLUnknown& unknown )
+{
+ PushUnknown( unknown.Value() );
+ return true;
+}
diff --git a/src/thirdparty/MediaInfo/ThirdParty/tinyxml2/tinyxml2.h b/src/thirdparty/MediaInfo/ThirdParty/tinyxml2/tinyxml2.h
new file mode 100644
index 000000000..659cef95e
--- /dev/null
+++ b/src/thirdparty/MediaInfo/ThirdParty/tinyxml2/tinyxml2.h
@@ -0,0 +1,1407 @@
+/*
+Original code by Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+#ifndef TINYXML2_INCLUDED
+#define TINYXML2_INCLUDED
+
+#if 1
+ #include <cctype>
+ #include <climits>
+ #include <cstdio>
+ #include <cstring>
+ #include <cstdarg>
+ #define TINYXML2_STD using namespace std;
+ #define TINYXML2_FILE std::FILE
+#else
+ // Not completely sure all the interesting systems
+ // can handle the new headers; can switch this if
+ // there is an include problem.
+ #include <limits.h>
+ #include <ctype.h>
+ #include <stdio.h>
+ #include <memory.h> // Needed by mac.
+ #define TINYXML2_STD
+ #define TINYXML2_FILE FILE
+#endif
+
+
+/*
+ TODO: add 'lastAttribute' for faster parsing.
+ TODO: intern strings instead of allocation.
+*/
+/*
+ gcc: g++ -Wall tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
+*/
+
+#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
+ #ifndef DEBUG
+ #define DEBUG
+ #endif
+#endif
+
+
+#if defined(DEBUG)
+ #if defined(_MSC_VER)
+ #define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
+ #elif defined (ANDROID_NDK)
+ #include <android/log.h>
+ #define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
+ #else
+ #include <assert.h>
+ #define TIXMLASSERT assert
+ #endif
+#else
+ #define TIXMLASSERT( x ) {}
+#endif
+
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
+ // Microsoft visual studio, version 2005 and higher.
+ /*int _snprintf_s(
+ char *buffer,
+ size_t sizeOfBuffer,
+ size_t count,
+ const char *format [,
+ argument] ...
+ );*/
+ inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) {
+ va_list va;
+ va_start( va, format );
+ int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
+ va_end( va );
+ return result;
+ }
+ #define TIXML_SSCANF sscanf_s
+#else
+ // GCC version 3 and higher
+ //#warning( "Using sn* functions." )
+ #define TIXML_SNPRINTF snprintf
+ #define TIXML_SSCANF sscanf
+#endif
+
+static const int TIXML2_MAJOR_VERSION = 0;
+static const int TIXML2_MINOR_VERSION = 9;
+static const int TIXML2_PATCH_VERSION = 4;
+
+namespace tinyxml2
+{
+class XMLDocument;
+class XMLElement;
+class XMLAttribute;
+class XMLComment;
+class XMLNode;
+class XMLText;
+class XMLDeclaration;
+class XMLUnknown;
+
+class XMLPrinter;
+
+/*
+ A class that wraps strings. Normally stores the start and end
+ pointers into the XML file itself, and will apply normalization
+ and entity translation if actually read. Can also store (and memory
+ manage) a traditional char[]
+*/
+class StrPair
+{
+public:
+ enum {
+ NEEDS_ENTITY_PROCESSING = 0x01,
+ NEEDS_NEWLINE_NORMALIZATION = 0x02,
+
+ TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
+ TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
+ ATTRIBUTE_NAME = 0,
+ ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
+ ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
+ COMMENT = NEEDS_NEWLINE_NORMALIZATION
+ };
+
+ StrPair() : flags( 0 ), start( 0 ), end( 0 ) {}
+ ~StrPair();
+
+ void Set( char* _start, char* _end, int _flags ) {
+ Reset();
+ this->start = _start; this->end = _end; this->flags = _flags | NEEDS_FLUSH;
+ }
+ const char* GetStr();
+ bool Empty() const { return start == end; }
+
+ void SetInternedStr( const char* str ) { Reset(); this->start = const_cast<char*>(str); }
+ void SetStr( const char* str, int flags=0 );
+
+ char* ParseText( char* in, const char* endTag, int strFlags );
+ char* ParseName( char* in );
+
+
+private:
+ void Reset();
+
+ enum {
+ NEEDS_FLUSH = 0x100,
+ NEEDS_DELETE = 0x200
+ };
+
+ // After parsing, if *end != 0, it can be set to zero.
+ int flags;
+ char* start;
+ char* end;
+};
+
+
+/*
+ A dynamic array of Plain Old Data. Doesn't support constructors, etc.
+ Has a small initial memory pool, so that low or no usage will not
+ cause a call to new/delete
+*/
+template <class T, int INIT>
+class DynArray
+{
+public:
+ DynArray< T, INIT >()
+ {
+ mem = pool;
+ allocated = INIT;
+ size = 0;
+ }
+ ~DynArray()
+ {
+ if ( mem != pool ) {
+ delete mem;
+ }
+ }
+ void Push( T t )
+ {
+ EnsureCapacity( size+1 );
+ mem[size++] = t;
+ }
+
+ T* PushArr( int count )
+ {
+ EnsureCapacity( size+count );
+ T* ret = &mem[size];
+ size += count;
+ return ret;
+ }
+ T Pop() {
+ return mem[--size];
+ }
+ void PopArr( int count )
+ {
+ TIXMLASSERT( size >= count );
+ size -= count;
+ }
+
+ bool Empty() const { return size == 0; }
+ T& operator[](int i) { TIXMLASSERT( i>= 0 && i < size ); return mem[i]; }
+ const T& operator[](int i) const { TIXMLASSERT( i>= 0 && i < size ); return mem[i]; }
+ int Size() const { return size; }
+ int Capacity() const { return allocated; }
+ const T* Mem() const { return mem; }
+ T* Mem() { return mem; }
+
+
+private:
+ void EnsureCapacity( int cap ) {
+ if ( cap > allocated ) {
+ int newAllocated = cap * 2;
+ T* newMem = new T[newAllocated];
+ memcpy( newMem, mem, sizeof(T)*size ); // warning: not using constructors, only works for PODs
+ if ( mem != pool ) delete [] mem;
+ mem = newMem;
+ allocated = newAllocated;
+ }
+ }
+
+ T* mem;
+ T pool[INIT];
+ int allocated; // objects allocated
+ int size; // number objects in use
+};
+
+
+/*
+ Parent virtual class a a pool for fast allocation
+ and deallocation of objects.
+*/
+class MemPool
+{
+public:
+ MemPool() {}
+ virtual ~MemPool() {}
+
+ virtual int ItemSize() const = 0;
+ virtual void* Alloc() = 0;
+ virtual void Free( void* ) = 0;
+};
+
+
+/*
+ Template child class to create pools of the correct type.
+*/
+template< int SIZE >
+class MemPoolT : public MemPool
+{
+public:
+ MemPoolT() : root(0), currentAllocs(0), nAllocs(0), maxAllocs(0) {}
+ ~MemPoolT() {
+ // Delete the blocks.
+ for( int i=0; i<blockPtrs.Size(); ++i ) {
+ delete blockPtrs[i];
+ }
+ }
+
+ virtual int ItemSize() const { return SIZE; }
+ int CurrentAllocs() const { return currentAllocs; }
+
+ virtual void* Alloc() {
+ if ( !root ) {
+ // Need a new block.
+ Block* block = new Block();
+ blockPtrs.Push( block );
+
+ for( int i=0; i<COUNT-1; ++i ) {
+ block->chunk[i].next = &block->chunk[i+1];
+ }
+ block->chunk[COUNT-1].next = 0;
+ root = block->chunk;
+ }
+ void* result = root;
+ root = root->next;
+
+ ++currentAllocs;
+ if ( currentAllocs > maxAllocs ) maxAllocs = currentAllocs;
+ nAllocs++;
+ return result;
+ }
+ virtual void Free( void* mem ) {
+ if ( !mem ) return;
+ --currentAllocs;
+ Chunk* chunk = (Chunk*)mem;
+ memset( chunk, 0xfe, sizeof(Chunk) );
+ chunk->next = root;
+ root = chunk;
+ }
+ void Trace( const char* name ) {
+ printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
+ name, maxAllocs, maxAllocs*SIZE/1024, currentAllocs, SIZE, nAllocs, blockPtrs.Size() );
+ }
+
+private:
+ enum { COUNT = 1024/SIZE };
+ union Chunk {
+ Chunk* next;
+ char mem[SIZE];
+ };
+ struct Block {
+ Chunk chunk[1024/SIZE];
+ };
+ DynArray< Block*, 10 > blockPtrs;
+ Chunk* root;
+
+ int currentAllocs;
+ int nAllocs;
+ int maxAllocs;
+};
+
+
+
+/**
+ Implements the interface to the "Visitor pattern" (see the Accept() method.)
+ If you call the Accept() method, it requires being passed a XMLVisitor
+ class to handle callbacks. For nodes that contain other nodes (Document, Element)
+ you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves
+ are simply called with Visit().
+
+ If you return 'true' from a Visit method, recursive parsing will continue. If you return
+ false, <b>no children of this node or its sibilings</b> will be Visited.
+
+ All flavors of Visit methods have a default implementation that returns 'true' (continue
+ visiting). You need to only override methods that are interesting to you.
+
+ Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting.
+
+ You should never change the document from a callback.
+
+ @sa XMLNode::Accept()
+*/
+class XMLVisitor
+{
+public:
+ virtual ~XMLVisitor() {}
+
+ /// Visit a document.
+ virtual bool VisitEnter( const XMLDocument& /*doc*/ ) { return true; }
+ /// Visit a document.
+ virtual bool VisitExit( const XMLDocument& /*doc*/ ) { return true; }
+
+ /// Visit an element.
+ virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) { return true; }
+ /// Visit an element.
+ virtual bool VisitExit( const XMLElement& /*element*/ ) { return true; }
+
+ /// Visit a declaration
+ virtual bool Visit( const XMLDeclaration& /*declaration*/ ) { return true; }
+ /// Visit a text node
+ virtual bool Visit( const XMLText& /*text*/ ) { return true; }
+ /// Visit a comment node
+ virtual bool Visit( const XMLComment& /*comment*/ ) { return true; }
+ /// Visit an unknown node
+ virtual bool Visit( const XMLUnknown& /*unknown*/ ) { return true; }
+};
+
+
+/*
+ Utility functionality.
+*/
+class XMLUtil
+{
+public:
+ // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
+ // correct, but simple, and usually works.
+ static const char* SkipWhiteSpace( const char* p ) { TINYXML2_STD while( !IsUTF8Continuation(*p) && isspace( *p ) ) { ++p; } return p; }
+ static char* SkipWhiteSpace( char* p ) { TINYXML2_STD while( !IsUTF8Continuation(*p) && isspace( *p ) ) { ++p; } return p; }
+
+ inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
+ int n = 0;
+ if ( p == q ) {
+ return true;
+ }
+ while( *p && *q && *p == *q && n<nChar ) {
+ ++p; ++q; ++n;
+ }
+ if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
+ return true;
+ }
+ return false;
+ }
+ inline static int IsUTF8Continuation( const char p ) { return p & 0x80; }
+ inline static int IsAlphaNum( unsigned char anyByte ) { TINYXML2_STD return ( anyByte < 128 ) ? isalnum( anyByte ) : 1; }
+ inline static int IsAlpha( unsigned char anyByte ) { TINYXML2_STD return ( anyByte < 128 ) ? isalpha( anyByte ) : 1; }
+
+ static const char* ReadBOM( const char* p, bool* hasBOM );
+ // p is the starting location,
+ // the UTF-8 value of the entity will be placed in value, and length filled in.
+ static const char* GetCharacterRef( const char* p, char* value, int* length );
+ static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
+};
+
+
+/** XMLNode is a base class for every object that is in the
+ XML Document Object Model (DOM), except XMLAttributes.
+ Nodes have siblings, a parent, and children which can
+ be navigated. A node is always in a XMLDocument.
+ The type of a XMLNode can be queried, and it can
+ be cast to its more defined type.
+
+ An XMLDocument allocates memory for all its Nodes.
+ When the XMLDocument gets deleted, all its Nodes
+ will also be deleted.
+
+ @verbatim
+ A Document can contain: Element (container or leaf)
+ Comment (leaf)
+ Unknown (leaf)
+ Declaration( leaf )
+
+ An Element can contain: Element (container or leaf)
+ Text (leaf)
+ Attributes (not on tree)
+ Comment (leaf)
+ Unknown (leaf)
+
+ @endverbatim
+*/
+class XMLNode
+{
+ friend class XMLDocument;
+ friend class XMLElement;
+public:
+
+ /// Get the XMLDocument that owns this XMLNode.
+ const XMLDocument* GetDocument() const { return document; }
+ /// Get the XMLDocument that owns this XMLNode.
+ XMLDocument* GetDocument() { return document; }
+
+ virtual XMLElement* ToElement() { return 0; } ///< Safely cast to an Element, or null.
+ virtual XMLText* ToText() { return 0; } ///< Safely cast to Text, or null.
+ virtual XMLComment* ToComment() { return 0; } ///< Safely cast to a Comment, or null.
+ virtual XMLDocument* ToDocument() { return 0; } ///< Safely cast to a Document, or null.
+ virtual XMLDeclaration* ToDeclaration() { return 0; } ///< Safely cast to a Declaration, or null.
+ virtual XMLUnknown* ToUnknown() { return 0; } ///< Safely cast to an Unknown, or null.
+
+ virtual const XMLElement* ToElement() const { return 0; }
+ virtual const XMLText* ToText() const { return 0; }
+ virtual const XMLComment* ToComment() const { return 0; }
+ virtual const XMLDocument* ToDocument() const { return 0; }
+ virtual const XMLDeclaration* ToDeclaration() const { return 0; }
+ virtual const XMLUnknown* ToUnknown() const { return 0; }
+
+ /** The meaning of 'value' changes for the specific type.
+ @verbatim
+ Document: empy
+ Element: name of the element
+ Comment: the comment text
+ Unknown: the tag contents
+ Text: the text string
+ @endverbatim
+ */
+ const char* Value() const { return value.GetStr(); }
+ /** Set the Value of an XML node.
+ @sa Value()
+ */
+ void SetValue( const char* val, bool staticMem=false );
+
+ /// Get the parent of this node on the DOM.
+ const XMLNode* Parent() const { return parent; }
+ XMLNode* Parent() { return parent; }
+
+ /// Returns true if this node has no children.
+ bool NoChildren() const { return !firstChild; }
+
+ /// Get the first child node, or null if none exists.
+ const XMLNode* FirstChild() const { return firstChild; }
+ XMLNode* FirstChild() { return firstChild; }
+ /** Get the first child element, or optionally the first child
+ element with the specified name.
+ */
+ const XMLElement* FirstChildElement( const char* value=0 ) const;
+ XMLElement* FirstChildElement( const char* _value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( _value )); }
+
+ /// Get the last child node, or null if none exists.
+ const XMLNode* LastChild() const { return lastChild; }
+ XMLNode* LastChild() { return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() ); }
+
+ /** Get the last child element or optionally the last child
+ element with the specified name.
+ */
+ const XMLElement* LastChildElement( const char* value=0 ) const;
+ XMLElement* LastChildElement( const char* _value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(_value) ); }
+
+ /// Get the previous (left) sibling node of this node.
+ const XMLNode* PreviousSibling() const { return prev; }
+ XMLNode* PreviousSibling() { return prev; }
+
+ /// Get the previous (left) sibling element of this node, with an opitionally supplied name.
+ const XMLElement* PreviousSiblingElement( const char* value=0 ) const ;
+ XMLElement* PreviousSiblingElement( const char* _value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( _value ) ); }
+
+ /// Get the next (right) sibling node of this node.
+ const XMLNode* NextSibling() const { return next; }
+ XMLNode* NextSibling() { return next; }
+
+ /// Get the next (right) sibling element of this node, with an opitionally supplied name.
+ const XMLElement* NextSiblingElement( const char* value=0 ) const;
+ XMLElement* NextSiblingElement( const char* _value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( _value ) ); }
+
+ /**
+ Add a child node as the last (right) child.
+ */
+ XMLNode* InsertEndChild( XMLNode* addThis );
+
+ XMLNode* LinkEndChild( XMLNode* addThis ) { return InsertEndChild( addThis ); }
+ /**
+ Add a child node as the first (left) child.
+ */
+ XMLNode* InsertFirstChild( XMLNode* addThis );
+ /**
+ Add a node after the specified child node.
+ */
+ XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
+
+ /**
+ Delete all the children of this node.
+ */
+ void DeleteChildren();
+
+ /**
+ Delete a child of this node.
+ */
+ void DeleteChild( XMLNode* node );
+
+ /**
+ Make a copy of this node, but not its children.
+ You may pass in a Document pointer that will be
+ the owner of the new Node. If the 'document' is
+ null, then the node returned will be allocated
+ from the current Document. (this->GetDocument())
+
+ Note: if called on a XMLDocument, this will return null.
+ */
+ virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
+
+ /**
+ Test if 2 nodes are the same, but don't test children.
+ The 2 nodes do not need to be in the same Document.
+
+ Note: if called on a XMLDocument, this will return false.
+ */
+ virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
+
+ /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the
+ XML tree will be conditionally visited and the host will be called back
+ via the TiXmlVisitor interface.
+
+ This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse
+ the XML for the callbacks, so the performance of TinyXML is unchanged by using this
+ interface versus any other.)
+
+ The interface has been based on ideas from:
+
+ - http://www.saxproject.org/
+ - http://c2.com/cgi/wiki?HierarchicalVisitorPattern
+
+ Which are both good references for "visiting".
+
+ An example of using Accept():
+ @verbatim
+ TiXmlPrinter printer;
+ tinyxmlDoc.Accept( &printer );
+ const char* xmlcstr = printer.CStr();
+ @endverbatim
+ */
+ virtual bool Accept( XMLVisitor* visitor ) const = 0;
+
+ // internal
+ virtual char* ParseDeep( char*, StrPair* );
+
+protected:
+ XMLNode( XMLDocument* );
+ virtual ~XMLNode();
+ XMLNode( const XMLNode& ); // not supported
+ void operator=( const XMLNode& ); // not supported
+
+ XMLDocument* document;
+ XMLNode* parent;
+ mutable StrPair value;
+
+ XMLNode* firstChild;
+ XMLNode* lastChild;
+
+ XMLNode* prev;
+ XMLNode* next;
+
+private:
+ MemPool* memPool;
+ void Unlink( XMLNode* child );
+};
+
+
+/** XML text.
+
+ Note that a text node can have child element nodes, for example:
+ @verbatim
+ <root>This is <b>bold</b></root>
+ @endverbatim
+
+ A text node can have 2 ways to output the next. "normal" output
+ and CDATA. It will default to the mode it was parsed from the XML file and
+ you generally want to leave it alone, but you can change the output mode with
+ SetCDATA() and query it with CDATA().
+*/
+class XMLText : public XMLNode
+{
+ friend class XMLBase;
+ friend class XMLDocument;
+public:
+ virtual bool Accept( XMLVisitor* visitor ) const;
+
+ virtual XMLText* ToText() { return this; }
+ virtual const XMLText* ToText() const { return this; }
+
+ /// Declare whether this should be CDATA or standard text.
+ void SetCData( bool _isCData ) { this->isCData = _isCData; }
+ /// Returns true if this is a CDATA text element.
+ bool CData() const { return isCData; }
+
+ char* ParseDeep( char*, StrPair* endTag );
+ virtual XMLNode* ShallowClone( XMLDocument* document ) const;
+ virtual bool ShallowEqual( const XMLNode* compare ) const;
+
+
+protected:
+ XMLText( XMLDocument* doc ) : XMLNode( doc ), isCData( false ) {}
+ virtual ~XMLText() {}
+ XMLText( const XMLText& ); // not supported
+ void operator=( const XMLText& ); // not supported
+
+private:
+ bool isCData;
+};
+
+
+/** An XML Comment. */
+class XMLComment : public XMLNode
+{
+ friend class XMLDocument;
+public:
+ virtual XMLComment* ToComment() { return this; }
+ virtual const XMLComment* ToComment() const { return this; }
+
+ virtual bool Accept( XMLVisitor* visitor ) const;
+
+ char* ParseDeep( char*, StrPair* endTag );
+ virtual XMLNode* ShallowClone( XMLDocument* document ) const;
+ virtual bool ShallowEqual( const XMLNode* compare ) const;
+
+protected:
+ XMLComment( XMLDocument* doc );
+ virtual ~XMLComment();
+ XMLComment( const XMLComment& ); // not supported
+ void operator=( const XMLComment& ); // not supported
+
+private:
+};
+
+
+/** In correct XML the declaration is the first entry in the file.
+ @verbatim
+ <?xml version="1.0" standalone="yes"?>
+ @endverbatim
+
+ TinyXML2 will happily read or write files without a declaration,
+ however.
+
+ The text of the declaration isn't interpreted. It is parsed
+ and written as a string.
+*/
+class XMLDeclaration : public XMLNode
+{
+ friend class XMLDocument;
+public:
+ virtual XMLDeclaration* ToDeclaration() { return this; }
+ virtual const XMLDeclaration* ToDeclaration() const { return this; }
+
+ virtual bool Accept( XMLVisitor* visitor ) const;
+
+ char* ParseDeep( char*, StrPair* endTag );
+ virtual XMLNode* ShallowClone( XMLDocument* document ) const;
+ virtual bool ShallowEqual( const XMLNode* compare ) const;
+
+protected:
+ XMLDeclaration( XMLDocument* doc );
+ virtual ~XMLDeclaration();
+ XMLDeclaration( const XMLDeclaration& ); // not supported
+ void operator=( const XMLDeclaration& ); // not supported
+};
+
+
+/** Any tag that tinyXml doesn't recognize is saved as an
+ unknown. It is a tag of text, but should not be modified.
+ It will be written back to the XML, unchanged, when the file
+ is saved.
+
+ DTD tags get thrown into TiXmlUnknowns.
+*/
+class XMLUnknown : public XMLNode
+{
+ friend class XMLDocument;
+public:
+ virtual XMLUnknown* ToUnknown() { return this; }
+ virtual const XMLUnknown* ToUnknown() const { return this; }
+
+ virtual bool Accept( XMLVisitor* visitor ) const;
+
+ char* ParseDeep( char*, StrPair* endTag );
+ virtual XMLNode* ShallowClone( XMLDocument* document ) const;
+ virtual bool ShallowEqual( const XMLNode* compare ) const;
+
+protected:
+ XMLUnknown( XMLDocument* doc );
+ virtual ~XMLUnknown();
+ XMLUnknown( const XMLUnknown& ); // not supported
+ void operator=( const XMLUnknown& ); // not supported
+};
+
+
+enum {
+ XML_NO_ERROR = 0,
+ XML_SUCCESS = 0,
+
+ XML_NO_ATTRIBUTE,
+ XML_WRONG_ATTRIBUTE_TYPE,
+
+ XML_ERROR_FILE_NOT_FOUND,
+ XML_ERROR_FILE_COULD_NOT_BE_OPENED,
+ XML_ERROR_ELEMENT_MISMATCH,
+ XML_ERROR_PARSING_ELEMENT,
+ XML_ERROR_PARSING_ATTRIBUTE,
+ XML_ERROR_IDENTIFYING_TAG,
+ XML_ERROR_PARSING_TEXT,
+ XML_ERROR_PARSING_CDATA,
+ XML_ERROR_PARSING_COMMENT,
+ XML_ERROR_PARSING_DECLARATION,
+ XML_ERROR_PARSING_UNKNOWN,
+ XML_ERROR_EMPTY_DOCUMENT,
+ XML_ERROR_MISMATCHED_ELEMENT,
+ XML_ERROR_PARSING
+};
+
+
+/** An attribute is a name-value pair. Elements have an arbitrary
+ number of attributes, each with a unique name.
+
+ @note The attributes are not XMLNodes. You may only query the
+ Next() attribute in a list.
+*/
+class XMLAttribute
+{
+ friend class XMLElement;
+public:
+ const char* Name() const { return name.GetStr(); } ///< The name of the attribute.
+ const char* Value() const { return value.GetStr(); } ///< The value of the attribute.
+ const XMLAttribute* Next() const { return next; } ///< The next attribute in the list.
+
+ /** IntAttribute interprets the attribute as an integer, and returns the value.
+ If the value isn't an integer, 0 will be returned. There is no error checking;
+ use QueryIntAttribute() if you need error checking.
+ */
+ int IntValue() const { int i=0; QueryIntValue( &i ); return i; }
+ /// Query as an unsigned integer. See IntAttribute()
+ unsigned UnsignedValue() const { unsigned i=0; QueryUnsignedValue( &i ); return i; }
+ /// Query as a boolean. See IntAttribute()
+ bool BoolValue() const { bool b=false; QueryBoolValue( &b ); return b; }
+ /// Query as a double. See IntAttribute()
+ double DoubleValue() const { double d=0; QueryDoubleValue( &d ); return d; }
+ /// Query as a float. See IntAttribute()
+ float FloatValue() const { float f=0; QueryFloatValue( &f ); return f; }
+
+ /** QueryIntAttribute interprets the attribute as an integer, and returns the value
+ in the provided paremeter. The function will return XML_NO_ERROR on success,
+ and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful.
+ */
+ int QueryIntValue( int* value ) const;
+ /// See QueryIntAttribute
+ int QueryUnsignedValue( unsigned int* value ) const;
+ /// See QueryIntAttribute
+ int QueryBoolValue( bool* value ) const;
+ /// See QueryIntAttribute
+ int QueryDoubleValue( double* value ) const;
+ /// See QueryIntAttribute
+ int QueryFloatValue( float* value ) const;
+
+ /// Set the attribute to a string value.
+ void SetAttribute( const char* value );
+ /// Set the attribute to value.
+ void SetAttribute( int value );
+ /// Set the attribute to value.
+ void SetAttribute( unsigned value );
+ /// Set the attribute to value.
+ void SetAttribute( bool value );
+ /// Set the attribute to value.
+ void SetAttribute( double value );
+ /// Set the attribute to value.
+ void SetAttribute( float value );
+
+private:
+ enum { BUF_SIZE = 200 };
+
+ XMLAttribute() : next( 0 ) {}
+ virtual ~XMLAttribute() {}
+ XMLAttribute( const XMLAttribute& ); // not supported
+ void operator=( const XMLAttribute& ); // not supported
+ void SetName( const char* name );
+
+ char* ParseDeep( char* p, bool processEntities );
+
+ mutable StrPair name;
+ mutable StrPair value;
+ XMLAttribute* next;
+ MemPool* memPool;
+};
+
+
+/** The element is a container class. It has a value, the element name,
+ and can contain other elements, text, comments, and unknowns.
+ Elements also contain an arbitrary number of attributes.
+*/
+class XMLElement : public XMLNode
+{
+ friend class XMLBase;
+ friend class XMLDocument;
+public:
+ /// Get the name of an element (which is the Value() of the node.)
+ const char* Name() const { return Value(); }
+ /// Set the name of the element.
+ void SetName( const char* str, bool staticMem=false ) { SetValue( str, staticMem ); }
+
+ virtual XMLElement* ToElement() { return this; }
+ virtual const XMLElement* ToElement() const { return this; }
+ virtual bool Accept( XMLVisitor* visitor ) const;
+
+ /** Given an attribute name, Attribute() returns the value
+ for the attribute of that name, or null if none
+ exists. For example:
+
+ @verbatim
+ const char* value = ele->Attribute( "foo" );
+ @endverbatim
+
+ The 'value' parameter is normally null. However, if specified,
+ the attribute will only be returned if the 'name' and 'value'
+ match. This allow you to write code:
+
+ @verbatim
+ if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar();
+ @endverbatim
+
+ rather than:
+ @verbatim
+ if ( ele->Attribute( "foo" ) ) {
+ if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar();
+ }
+ @endverbatim
+ */
+ const char* Attribute( const char* name, const char* value=0 ) const;
+
+ /** Given an attribute name, IntAttribute() returns the value
+ of the attribute interpreted as an integer. 0 will be
+ returned if there is an error. For a method with error
+ checking, see QueryIntAttribute()
+ */
+ int IntAttribute( const char* name ) const { int i=0; QueryIntAttribute( name, &i ); return i; }
+ /// See IntAttribute()
+ unsigned UnsignedAttribute( const char* name ) const{ unsigned i=0; QueryUnsignedAttribute( name, &i ); return i; }
+ /// See IntAttribute()
+ bool BoolAttribute( const char* name ) const { bool b=false; QueryBoolAttribute( name, &b ); return b; }
+ /// See IntAttribute()
+ double DoubleAttribute( const char* name ) const { double d=0; QueryDoubleAttribute( name, &d ); return d; }
+ /// See IntAttribute()
+ float FloatAttribute( const char* name ) const { float f=0; QueryFloatAttribute( name, &f ); return f; }
+
+ /** Given an attribute name, QueryIntAttribute() returns
+ XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion
+ can't be performed, or XML_NO_ATTRIBUTE if the attribute
+ doesn't exist. If successful, the result of the conversion
+ will be written to 'value'. If not successful, nothing will
+ be written to 'value'. This allows you to provide default
+ value:
+
+ @verbatim
+ int value = 10;
+ QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10
+ @endverbatim
+ */
+ int QueryIntAttribute( const char* name, int* _value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryIntValue( _value ); }
+ /// See QueryIntAttribute()
+ int QueryUnsignedAttribute( const char* name, unsigned int* _value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryUnsignedValue( _value ); }
+ /// See QueryIntAttribute()
+ int QueryBoolAttribute( const char* name, bool* _value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryBoolValue( _value ); }
+ /// See QueryIntAttribute()
+ int QueryDoubleAttribute( const char* name, double* _value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryDoubleValue( _value ); }
+ /// See QueryIntAttribute()
+ int QueryFloatAttribute( const char* name, float* _value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryFloatValue( _value ); }
+
+ /// Sets the named attribute to value.
+ void SetAttribute( const char* name, const char* _value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
+ /// Sets the named attribute to value.
+ void SetAttribute( const char* name, int _value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
+ /// Sets the named attribute to value.
+ void SetAttribute( const char* name, unsigned _value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
+ /// Sets the named attribute to value.
+ void SetAttribute( const char* name, bool _value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
+ /// Sets the named attribute to value.
+ void SetAttribute( const char* name, double _value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
+
+ /**
+ Delete an attribute.
+ */
+ void DeleteAttribute( const char* name );
+
+ /// Return the first attribute in the list.
+ const XMLAttribute* FirstAttribute() const { return rootAttribute; }
+ /// Query a specific attribute in the list.
+ const XMLAttribute* FindAttribute( const char* name ) const;
+
+ /** Convenience function for easy access to the text inside an element. Although easy
+ and concise, GetText() is limited compared to getting the TiXmlText child
+ and accessing it directly.
+
+ If the first child of 'this' is a TiXmlText, the GetText()
+ returns the character string of the Text node, else null is returned.
+
+ This is a convenient method for getting the text of simple contained text:
+ @verbatim
+ <foo>This is text</foo>
+ const char* str = fooElement->GetText();
+ @endverbatim
+
+ 'str' will be a pointer to "This is text".
+
+ Note that this function can be misleading. If the element foo was created from
+ this XML:
+ @verbatim
+ <foo><b>This is text</b></foo>
+ @endverbatim
+
+ then the value of str would be null. The first child node isn't a text node, it is
+ another element. From this XML:
+ @verbatim
+ <foo>This is <b>text</b></foo>
+ @endverbatim
+ GetText() will return "This is ".
+ */
+ const char* GetText() const;
+
+ // internal:
+ enum {
+ OPEN, // <foo>
+ CLOSED, // <foo/>
+ CLOSING // </foo>
+ };
+ int ClosingType() const { return closingType; }
+ char* ParseDeep( char* p, StrPair* endTag );
+ virtual XMLNode* ShallowClone( XMLDocument* document ) const;
+ virtual bool ShallowEqual( const XMLNode* compare ) const;
+
+private:
+ XMLElement( XMLDocument* doc );
+ virtual ~XMLElement();
+ XMLElement( const XMLElement& ); // not supported
+ void operator=( const XMLElement& ); // not supported
+
+ XMLAttribute* FindAttribute( const char* name );
+ XMLAttribute* FindOrCreateAttribute( const char* name );
+ void LinkAttribute( XMLAttribute* attrib );
+ char* ParseAttributes( char* p );
+
+ int closingType;
+ XMLAttribute* rootAttribute;
+};
+
+
+/** A document binds together all the functionality.
+ It can be saved, loaded, and printed to the screen.
+ All Nodes are connected and allocated to a Document.
+ If the Document is deleted, all its Nodes are also deleted.
+*/
+class XMLDocument : public XMLNode
+{
+ friend class XMLElement;
+public:
+ /// constructor
+ XMLDocument( bool processEntities = true );
+ ~XMLDocument();
+
+ virtual XMLDocument* ToDocument() { return this; }
+ virtual const XMLDocument* ToDocument() const { return this; }
+
+ /**
+ Parse an XML file from a character string.
+ Returns XML_NO_ERROR (0) on success, or
+ an errorID.
+ */
+ int Parse( const char* xml );
+
+ /**
+ Load an XML file from disk.
+ Returns XML_NO_ERROR (0) on success, or
+ an errorID.
+ */
+ int LoadFile( const char* filename );
+
+ /**
+ Load an XML file from disk. You are responsible
+ for providing and closing the FILE*.
+
+ Returns XML_NO_ERROR (0) on success, or
+ an errorID.
+ */
+ int LoadFile( TINYXML2_FILE* );
+
+ /**
+ Save the XML file to disk.
+ Returns XML_NO_ERROR (0) on success, or
+ an errorID.
+ */
+ int SaveFile( const char* filename );
+
+ /**
+ Save the XML file to disk. You are responsible
+ for providing and closing the FILE*.
+
+ Returns XML_NO_ERROR (0) on success, or
+ an errorID.
+ */
+ int SaveFile( TINYXML2_FILE* );
+
+ bool ProcessEntities() const { return processEntities; }
+
+ /**
+ Returns true if this document has a leading Byte Order Mark of UTF8.
+ */
+ bool HasBOM() const { return writeBOM; }
+
+ /** Return the root element of DOM. Equivalent to FirstChildElement().
+ To get the first node, use FirstChild().
+ */
+ XMLElement* RootElement() { return FirstChildElement(); }
+ const XMLElement* RootElement() const { return FirstChildElement(); }
+
+ /** Print the Document. If the Printer is not provided, it will
+ print to stdout. If you provide Printer, this can print to a file:
+ @verbatim
+ XMLPrinter printer( fp );
+ doc.Print( &printer );
+ @endverbatim
+
+ Or you can use a printer to print to memory:
+ @verbatim
+ XMLPrinter printer;
+ doc->Print( &printer );
+ // printer.CStr() has a const char* to the XML
+ @endverbatim
+ */
+ void Print( XMLPrinter* streamer=0 );
+ virtual bool Accept( XMLVisitor* visitor ) const;
+
+ /**
+ Create a new Element associated with
+ this Document. The memory for the Element
+ is managed by the Document.
+ */
+ XMLElement* NewElement( const char* name );
+ /**
+ Create a new Comment associated with
+ this Document. The memory for the Comment
+ is managed by the Document.
+ */
+ XMLComment* NewComment( const char* comment );
+ /**
+ Create a new Text associated with
+ this Document. The memory for the Text
+ is managed by the Document.
+ */
+ XMLText* NewText( const char* text );
+ /**
+ Create a new Declaration associated with
+ this Document. The memory for the object
+ is managed by the Document.
+ */
+ XMLDeclaration* NewDeclaration( const char* text );
+ /**
+ Create a new Unknown associated with
+ this Document. The memory for the object
+ is managed by the Document.
+ */
+ XMLUnknown* NewUnknown( const char* text );
+
+ /**
+ Delete a node associated with this documented.
+ It will be unlinked from the DOM.
+ */
+ void DeleteNode( XMLNode* node ) { node->parent->DeleteChild( node ); }
+
+ void SetError( int error, const char* str1, const char* str2 );
+
+ /// Return true if there was an error parsing the document.
+ bool Error() const { return errorID != XML_NO_ERROR; }
+ /// Return the errorID.
+ int ErrorID() const { return errorID; }
+ /// Return a possibly helpful diagnostic location or string.
+ const char* GetErrorStr1() const { return errorStr1; }
+ /// Return possibly helpful secondary diagnostic location or string.
+ const char* GetErrorStr2() const { return errorStr2; }
+ /// If there is an error, print it to stdout
+ void PrintError() const;
+
+ // internal
+ char* Identify( char* p, XMLNode** node );
+
+ virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { return 0; }
+ virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { return false; }
+
+private:
+ XMLDocument( const XMLDocument& ); // not supported
+ void operator=( const XMLDocument& ); // not supported
+ void InitDocument();
+
+ bool writeBOM;
+ bool processEntities;
+ int errorID;
+ const char* errorStr1;
+ const char* errorStr2;
+ char* charBuffer;
+
+ MemPoolT< sizeof(XMLElement) > elementPool;
+ MemPoolT< sizeof(XMLAttribute) > attributePool;
+ MemPoolT< sizeof(XMLText) > textPool;
+ MemPoolT< sizeof(XMLComment) > commentPool;
+};
+
+
+/**
+ A XMLHandle is a class that wraps a node pointer with null checks; this is
+ an incredibly useful thing. Note that XMLHandle is not part of the TinyXML
+ DOM structure. It is a separate utility class.
+
+ Take an example:
+ @verbatim
+ <Document>
+ <Element attributeA = "valueA">
+ <Child attributeB = "value1" />
+ <Child attributeB = "value2" />
+ </Element>
+ <Document>
+ @endverbatim
+
+ Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
+ easy to write a *lot* of code that looks like:
+
+ @verbatim
+ XMLElement* root = document.FirstChildElement( "Document" );
+ if ( root )
+ {
+ XMLElement* element = root->FirstChildElement( "Element" );
+ if ( element )
+ {
+ XMLElement* child = element->FirstChildElement( "Child" );
+ if ( child )
+ {
+ XMLElement* child2 = child->NextSiblingElement( "Child" );
+ if ( child2 )
+ {
+ // Finally do something useful.
+ @endverbatim
+
+ And that doesn't even cover "else" cases. XMLHandle addresses the verbosity
+ of such code. A XMLHandle checks for null pointers so it is perfectly safe
+ and correct to use:
+
+ @verbatim
+ XMLHandle docHandle( &document );
+ XMLElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild().NextSibling().ToElement();
+ if ( child2 )
+ {
+ // do something useful
+ @endverbatim
+
+ Which is MUCH more concise and useful.
+
+ It is also safe to copy handles - internally they are nothing more than node pointers.
+ @verbatim
+ XMLHandle handleCopy = handle;
+ @endverbatim
+
+ See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects.
+*/
+class XMLHandle
+{
+public:
+ /// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
+ XMLHandle( XMLNode* _node ) { node = _node; }
+ /// Create a handle from a node.
+ XMLHandle( XMLNode& _node ) { node = &_node; }
+ /// Copy constructor
+ XMLHandle( const XMLHandle& ref ) { node = ref.node; }
+ /// Assignment
+ XMLHandle operator=( const XMLHandle& ref ) { node = ref.node; return *this; }
+
+ /// Get the first child of this handle.
+ XMLHandle FirstChild() { return XMLHandle( node ? node->FirstChild() : 0 ); }
+ /// Get the first child element of this handle.
+ XMLHandle FirstChildElement( const char* value=0 ) { return XMLHandle( node ? node->FirstChildElement( value ) : 0 ); }
+ /// Get the last child of this handle.
+ XMLHandle LastChild() { return XMLHandle( node ? node->LastChild() : 0 ); }
+ /// Get the last child element of this handle.
+ XMLHandle LastChildElement( const char* _value=0 ) { return XMLHandle( node ? node->LastChildElement( _value ) : 0 ); }
+ /// Get the previous sibling of this handle.
+ XMLHandle PreviousSibling() { return XMLHandle( node ? node->PreviousSibling() : 0 ); }
+ /// Get the previous sibling element of this handle.
+ XMLHandle PreviousSiblingElement( const char* _value=0 ) { return XMLHandle( node ? node->PreviousSiblingElement( _value ) : 0 ); }
+ /// Get the next sibling of this handle.
+ XMLHandle NextSibling() { return XMLHandle( node ? node->NextSibling() : 0 ); }
+ /// Get the next sibling element of this handle.
+ XMLHandle NextSiblingElement( const char* _value=0 ) { return XMLHandle( node ? node->NextSiblingElement( _value ) : 0 ); }
+
+ /// Safe cast to XMLNode. This can return null.
+ XMLNode* ToNode() { return node; }
+ /// Safe cast to XMLElement. This can return null.
+ XMLElement* ToElement() { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
+ /// Safe cast to XMLText. This can return null.
+ XMLText* ToText() { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
+ /// Safe cast to XMLUnknown. This can return null.
+ XMLUnknown* ToUnknown() { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
+ /// Safe cast to XMLDeclaration. This can return null.
+ XMLDeclaration* ToDeclaration() { return ( ( node && node->ToDeclaration() ) ? node->ToDeclaration() : 0 ); }
+
+private:
+ XMLNode* node;
+};
+
+
+/**
+ A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the
+ same in all regards, except for the 'const' qualifiers. See XMLHandle for API.
+*/
+class XMLConstHandle
+{
+public:
+ XMLConstHandle( const XMLNode* _node ) { node = _node; }
+ XMLConstHandle( const XMLNode& _node ) { node = &_node; }
+ XMLConstHandle( const XMLConstHandle& ref ) { node = ref.node; }
+
+ XMLConstHandle operator=( const XMLConstHandle& ref ) { node = ref.node; return *this; }
+
+ const XMLConstHandle FirstChild() const { return XMLConstHandle( node ? node->FirstChild() : 0 ); }
+ const XMLConstHandle FirstChildElement( const char* value=0 ) const { return XMLConstHandle( node ? node->FirstChildElement( value ) : 0 ); }
+ const XMLConstHandle LastChild() const { return XMLConstHandle( node ? node->LastChild() : 0 ); }
+ const XMLConstHandle LastChildElement( const char* _value=0 ) const { return XMLConstHandle( node ? node->LastChildElement( _value ) : 0 ); }
+ const XMLConstHandle PreviousSibling() const { return XMLConstHandle( node ? node->PreviousSibling() : 0 ); }
+ const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const { return XMLConstHandle( node ? node->PreviousSiblingElement( _value ) : 0 ); }
+ const XMLConstHandle NextSibling() const { return XMLConstHandle( node ? node->NextSibling() : 0 ); }
+ const XMLConstHandle NextSiblingElement( const char* _value=0 ) const { return XMLConstHandle( node ? node->NextSiblingElement( _value ) : 0 ); }
+
+
+ const XMLNode* ToNode() const { return node; }
+ const XMLElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
+ const XMLText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
+ const XMLUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
+ const XMLDeclaration* ToDeclaration() const { return ( ( node && node->ToDeclaration() ) ? node->ToDeclaration() : 0 ); }
+
+private:
+ const XMLNode* node;
+};
+
+
+/**
+ Printing functionality. The XMLPrinter gives you more
+ options than the XMLDocument::Print() method.
+
+ It can:
+ -# Print to memory.
+ -# Print to a file you provide
+ -# Print XML without a XMLDocument.
+
+ Print to Memory
+
+ @verbatim
+ XMLPrinter printer;
+ doc->Print( &printer );
+ SomeFunctior( printer.CStr() );
+ @endverbatim
+
+ Print to a File
+
+ You provide the file pointer.
+ @verbatim
+ XMLPrinter printer( fp );
+ doc.Print( &printer );
+ @endverbatim
+
+ Print without a XMLDocument
+
+ When loading, an XML parser is very useful. However, sometimes
+ when saving, it just gets in the way. The code is often set up
+ for streaming, and constructing the DOM is just overhead.
+
+ The Printer supports the streaming case. The following code
+ prints out a trivially simple XML file without ever creating
+ an XML document.
+
+ @verbatim
+ XMLPrinter printer( fp );
+ printer.OpenElement( "foo" );
+ printer.PushAttribute( "foo", "bar" );
+ printer.CloseElement();
+ @endverbatim
+*/
+class XMLPrinter : public XMLVisitor
+{
+public:
+ /** Construct the printer. If the FILE* is specified,
+ this will print to the FILE. Else it will print
+ to memory, and the result is available in CStr()
+ */
+ XMLPrinter( TINYXML2_FILE* file=0 );
+ ~XMLPrinter() {}
+
+ /** If streaming, write the BOM and declaration. */
+ void PushHeader( bool writeBOM, bool writeDeclaration );
+ /** If streaming, start writing an element.
+ The element must be closed with CloseElement()
+ */
+ void OpenElement( const char* name );
+ /// If streaming, add an attribute to an open element.
+ void PushAttribute( const char* name, const char* value );
+ void PushAttribute( const char* name, int value );
+ void PushAttribute( const char* name, unsigned value );
+ void PushAttribute( const char* name, bool value );
+ void PushAttribute( const char* name, double value );
+ /// If streaming, close the Element.
+ void CloseElement();
+
+ /// Add a text node.
+ void PushText( const char* text, bool cdata=false );
+ /// Add a comment
+ void PushComment( const char* comment );
+
+ void PushDeclaration( const char* value );
+ void PushUnknown( const char* value );
+
+ virtual bool VisitEnter( const XMLDocument& /*doc*/ );
+ virtual bool VisitExit( const XMLDocument& /*doc*/ ) { return true; }
+
+ virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
+ virtual bool VisitExit( const XMLElement& element );
+
+ virtual bool Visit( const XMLText& text );
+ virtual bool Visit( const XMLComment& comment );
+ virtual bool Visit( const XMLDeclaration& declaration );
+ virtual bool Visit( const XMLUnknown& unknown );
+
+ /**
+ If in print to memory mode, return a pointer to
+ the XML file in memory.
+ */
+ const char* CStr() const { return buffer.Mem(); }
+
+private:
+ void SealElement();
+ void PrintSpace( int depth );
+ void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
+ void Print( const char* format, ... );
+
+ bool elementJustOpened;
+ bool firstElement;
+ TINYXML2_FILE* fp;
+ int depth;
+ int textDepth;
+ bool processEntities;
+
+ enum {
+ ENTITY_RANGE = 64,
+ BUF_SIZE = 200
+ };
+ bool entityFlag[ENTITY_RANGE];
+ bool restrictedEntityFlag[ENTITY_RANGE];
+
+ DynArray< const char*, 10 > stack;
+ DynArray< char, 20 > buffer, accumulator;
+};
+
+
+} // tinyxml2
+
+
+#endif // TINYXML2_INCLUDED
diff --git a/src/thirdparty/ZenLib/ZenLib/BitStream.h b/src/thirdparty/ZenLib/ZenLib/BitStream.h
new file mode 100644
index 000000000..9f6f894e1
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/BitStream.h
@@ -0,0 +1,366 @@
+// ZenLib::bitStream - Read bit per bit
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Read a stream bit per bit
+// Can read up to 32 bits at once
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenBitStreamH
+#define ZenBitStreamH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+#ifndef MIN
+ #define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+class BitStream
+{
+public:
+ BitStream () {Buffer=NULL;
+ Buffer_Size=Buffer_Size_Init=Buffer_Size_BeforeLastCall=0;
+ LastByte_Size=0;
+ BufferUnderRun=true;
+ BookMark=false;}
+ BitStream (const int8u* Buffer_, size_t Size_) {Buffer=Buffer_;
+ Buffer_Size=Buffer_Size_Init=Buffer_Size_BeforeLastCall=Size_*8; //Size is in bits
+ LastByte_Size=0;
+ BufferUnderRun=Buffer_Size?false:true;
+ BookMark=false;}
+ virtual ~BitStream () {};
+
+ virtual void Attach(const int8u* Buffer_, size_t Size_)
+ {
+ if (Buffer_==Buffer)
+ return; //Nothing to do
+ Buffer=Buffer_;
+ Buffer_Size=Buffer_Size_Init=Buffer_Size_BeforeLastCall=Size_*8; //Size is in bits
+ LastByte_Size=0;
+ BufferUnderRun=Buffer_Size?false:true;
+ BookMark=false;
+ };
+
+ virtual int32u Get (size_t HowMany)
+ {
+ size_t ToReturn;
+ static const int32u Mask[33]={
+ 0x00000000,
+ 0x00000001, 0x00000003, 0x00000007, 0x0000000f,
+ 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
+ 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
+ 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
+ 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff,
+ 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
+ 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
+ 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff,
+ };
+
+ if (HowMany==0 || HowMany>32)
+ return 0;
+ if ((size_t)HowMany>Buffer_Size+LastByte_Size)
+ {
+ Buffer_Size=0;
+ LastByte_Size=0;
+ BufferUnderRun=true;
+ return 0;
+ }
+
+ Buffer_Size_BeforeLastCall=Buffer_Size+LastByte_Size;
+
+ if (HowMany<=LastByte_Size)
+ {
+ LastByte_Size-=HowMany;
+ ToReturn=LastByte>>LastByte_Size;
+ }
+ else
+ {
+ size_t NewBits=HowMany-LastByte_Size;
+ if (NewBits==32)
+ ToReturn=0;
+ else
+ ToReturn=LastByte<<NewBits;
+ switch ((NewBits-1)/8)
+ {
+ case 3 : NewBits-=8;
+ ToReturn|=*Buffer<<NewBits;
+ Buffer++;
+ Buffer_Size-=8;
+ case 2 : NewBits-=8;
+ ToReturn|=*Buffer<<NewBits;
+ Buffer++;
+ Buffer_Size-=8;
+ case 1 : NewBits-=8;
+ ToReturn|=*Buffer<<NewBits;
+ Buffer++;
+ Buffer_Size-=8;
+ case 0 :
+ LastByte=*Buffer;
+ Buffer++;
+ }
+ LastByte_Size=MIN(8, Buffer_Size)-NewBits;
+ Buffer_Size -=MIN(8, Buffer_Size);
+ ToReturn|=(LastByte>>LastByte_Size)&Mask[NewBits];
+ }
+ return (int32u)(ToReturn&Mask[HowMany]);
+ };
+
+ bool GetB ()
+ {
+ return Get(1)?true:false;
+ }
+
+ int8u Get1 (size_t HowMany)
+ {
+ return (int8u )Get(HowMany);
+ }
+
+ int16u Get2 (size_t HowMany)
+ {
+ return (int16u)Get(HowMany);
+ }
+
+ int32u Get4 (size_t HowMany)
+ {
+ return (int32u)Get(HowMany);
+ }
+
+ int64u Get8 (size_t HowMany)
+ {
+ if (HowMany>64)
+ return 0; //Not supported
+ size_t HowMany1, HowMany2;
+ int64u Value1, Value2;
+ if (HowMany>32)
+ HowMany1=HowMany-32;
+ else
+ HowMany1=0;
+ HowMany2=HowMany-HowMany1;
+ Value1=Get(HowMany1);
+ Value2=Get(HowMany2);
+ if (BufferUnderRun)
+ return 0;
+ return Value1*0x100000000LL+Value2;
+ }
+
+ virtual void Skip (size_t HowMany)
+ {
+ if (HowMany==0)
+ return;
+ if (HowMany>32) //Algorithm is only for <=32 bits
+ {
+ do
+ {
+ Skip(32);
+ HowMany-=32;
+ }
+ while(HowMany>32);
+ if (HowMany)
+ Skip(HowMany);
+ return;
+ }
+ if ((size_t)HowMany>Buffer_Size+LastByte_Size)
+ {
+ Buffer_Size=0;
+ LastByte_Size=0;
+ BufferUnderRun=true;
+ return;
+ }
+
+ Buffer_Size_BeforeLastCall=Buffer_Size+LastByte_Size;
+
+ if (HowMany<=LastByte_Size)
+ LastByte_Size-=HowMany;
+ else
+ {
+ size_t NewBits=HowMany-LastByte_Size;
+ switch ((NewBits-1)/8)
+ {
+ case 3 : NewBits-=8;
+ Buffer++;
+ Buffer_Size-=8;
+ case 2 : NewBits-=8;
+ Buffer++;
+ Buffer_Size-=8;
+ case 1 : NewBits-=8;
+ Buffer++;
+ Buffer_Size-=8;
+ case 0 :
+ LastByte=*Buffer;
+ Buffer++;
+ }
+ LastByte_Size=MIN(8, Buffer_Size)-NewBits;
+ Buffer_Size -=MIN(8, Buffer_Size);
+ }
+ };
+
+ void SkipB ()
+ {
+ Skip(1);
+ }
+
+ void Skip1 (size_t HowMany)
+ {
+ Skip(HowMany);
+ }
+
+ void Skip2 (size_t HowMany)
+ {
+ Skip(HowMany);
+ }
+
+ void Skip4 (size_t HowMany)
+ {
+ Skip(HowMany);
+ }
+
+ void Skip8 (size_t HowMany)
+ {
+ if (HowMany>64)
+ return; //Not supported
+ size_t HowMany1, HowMany2;
+ if (HowMany>32)
+ HowMany1=HowMany-32;
+ else
+ HowMany1=0;
+ HowMany2=HowMany-HowMany1;
+ Skip(HowMany1);
+ Skip(HowMany2);
+ }
+
+ int32u Peek(size_t HowMany)
+ {
+ BookMarkPos(true);
+ int32u ToReturn=Get(HowMany);
+ BookMarkPos(false);
+ return ToReturn;
+ }
+
+ bool PeekB()
+ {
+ return Peek(1)?true:false;
+ }
+
+ int8u Peek1(size_t HowMany)
+ {
+ return (int8u )Peek(HowMany);
+ }
+
+ int16u Peek2(size_t HowMany)
+ {
+ return (int16u)Peek(HowMany);
+ }
+
+ int32u Peek4(size_t HowMany)
+ {
+ return (int32u)Peek(HowMany);
+ }
+
+ int32u Peek3(size_t HowMany)
+ {
+ return (int32u)Peek(HowMany);
+ }
+
+ int64u Peek8(size_t HowMany)
+ {
+ return (int64u)Peek(HowMany);
+ }
+
+ void BookMarkPos(bool ToSet)
+ {
+ if (ToSet)
+ {
+ BookMark=1;
+ Buffer_BookMark=Buffer;
+ Buffer_Size_BookMark=Buffer_Size;
+ LastByte_BookMark=LastByte;
+ LastByte_Size_BookMark=LastByte_Size;
+ BufferUnderRun_BookMark=BufferUnderRun;
+ }
+ else
+ {
+ BookMark=0;
+ Buffer=Buffer_BookMark;
+ Buffer_Size=Buffer_Size_BookMark;
+ LastByte=LastByte_BookMark;
+ LastByte_Size=LastByte_Size_BookMark;
+ BufferUnderRun=BufferUnderRun_BookMark;
+ }
+ };
+
+ virtual int32u Remain () //How many bits remain?
+ {
+ return (int32u)(Buffer_Size+LastByte_Size);
+ };
+
+ virtual void Byte_Align()
+ {
+ Get(LastByte_Size);
+ };
+
+ virtual size_t Offset_Get()
+ {
+ if (BufferUnderRun)
+ return 0;
+ return (Buffer_Size_Init-Buffer_Size)/8;
+ };
+
+ virtual size_t BitOffset_Get()
+ {
+ if (BufferUnderRun)
+ return 0;
+ return LastByte_Size;
+ };
+
+ virtual size_t OffsetBeforeLastCall_Get()
+ {
+ if (BufferUnderRun)
+ return 0;
+ return (Buffer_Size_Init-Buffer_Size_BeforeLastCall)/8;
+ };
+
+private :
+ const int8u* Buffer;
+ size_t Buffer_Size;
+ size_t Buffer_Size_Init;
+ size_t Buffer_Size_BeforeLastCall;
+ size_t LastByte;
+ size_t LastByte_Size;
+ bool BufferUnderRun;
+
+ bool BookMark;
+ const int8u* Buffer_BookMark;
+ size_t Buffer_Size_BookMark;
+ size_t LastByte_BookMark;
+ size_t LastByte_Size_BookMark;
+ bool BufferUnderRun_BookMark;
+};
+
+} //namespace ZenLib
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/BitStream_Fast.h b/src/thirdparty/ZenLib/ZenLib/BitStream_Fast.h
new file mode 100644
index 000000000..81c686e3d
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/BitStream_Fast.h
@@ -0,0 +1,434 @@
+// ZenLib::bitStream - Read bit per bit
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Read a stream bit per bit
+// Can read up to 32 bits at once
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenBitStream_FastH
+#define ZenBitStream_FastH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+#ifndef MIN
+ #define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+class BitStream_Fast
+{
+public:
+ BitStream_Fast () {Buffer=NULL;
+ Buffer_Size=Buffer_Size_Init=0;
+ BufferUnderRun=false;}
+ BitStream_Fast (const int8u* Buffer_, size_t Size_) {Buffer=Buffer_;
+ Buffer_Size=Buffer_Size_Init=Size_*8; //Size is in bits
+ BufferUnderRun=false;}
+ ~BitStream_Fast () {};
+
+ void Attach(const int8u* Buffer_, size_t Size_)
+ {
+ Buffer=Buffer_;
+ Buffer_Size=Buffer_Size_Init=Size_*8; //Size is in bits
+ BufferUnderRun=false;
+ };
+
+ bool GetB ()
+ {
+ if (Buffer_Size%8)
+ {
+ Buffer_Size--;
+ return ((LastByte>>(Buffer_Size%8))&0x1)?true:false;
+ }
+
+ if (!Buffer_Size)
+ {
+ Buffer_Size=0;
+ BufferUnderRun=true;
+ return false;
+ }
+
+ LastByte=*Buffer;
+ Buffer++;
+ Buffer_Size--;
+ return (LastByte&0x80)?true:false;
+ }
+
+ int8u Get1 (int8u HowMany)
+ {
+ int8u ToReturn;
+ static const int8u Mask[9]=
+ {
+ 0x00,
+ 0x01, 0x03, 0x07, 0x0f,
+ 0x1f, 0x3f, 0x7f, 0xff,
+ };
+
+ if (HowMany<=(Buffer_Size%8))
+ {
+ Buffer_Size-=HowMany;
+ return (LastByte>>(Buffer_Size%8))&Mask[HowMany];
+ }
+
+ if (HowMany>Buffer_Size)
+ {
+ Buffer_Size=0;
+ BufferUnderRun=true;
+ return 0;
+ }
+
+ int8u NewBits=HowMany-(Buffer_Size%8);
+ if (NewBits==8)
+ ToReturn=0;
+ else
+ ToReturn=LastByte<<NewBits;
+ LastByte=*Buffer;
+ Buffer++;
+ Buffer_Size-=HowMany;
+ ToReturn|=(LastByte>>(Buffer_Size%8))&Mask[NewBits];
+ return ToReturn&Mask[HowMany];
+ }
+
+ int16u Get2 (int8u HowMany)
+ {
+ int16u ToReturn;
+ static const int16u Mask[17]=
+ {
+ 0x0000,
+ 0x0001, 0x0003, 0x0007, 0x000f,
+ 0x001f, 0x003f, 0x007f, 0x00ff,
+ 0x01ff, 0x03ff, 0x07ff, 0x0fff,
+ 0x1fff, 0x3fff, 0x7fff, 0xffff,
+ };
+
+ if (HowMany<=(Buffer_Size%8))
+ {
+ Buffer_Size-=HowMany;
+ return (LastByte>>(Buffer_Size%8))&Mask[HowMany];
+ }
+
+ if (HowMany>Buffer_Size)
+ {
+ Buffer_Size=0;
+ BufferUnderRun=true;
+ return 0;
+ }
+
+ int8u NewBits=HowMany-(Buffer_Size%8);
+ if (NewBits==16)
+ ToReturn=0;
+ else
+ ToReturn=LastByte<<NewBits;
+ if ((NewBits-1)>>3)
+ {
+ NewBits-=8;
+ ToReturn|=*Buffer<<NewBits;
+ Buffer++;
+ }
+ LastByte=*Buffer;
+ Buffer++;
+ Buffer_Size-=HowMany;
+ ToReturn|=(LastByte>>(Buffer_Size%8))&Mask[NewBits];
+ return ToReturn&Mask[HowMany];
+ }
+
+ int32u Get4 (int8u HowMany)
+ {
+ int32u ToReturn;
+ static const int32u Mask[33]=
+ {
+ 0x00000000,
+ 0x00000001, 0x00000003, 0x00000007, 0x0000000f,
+ 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
+ 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
+ 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
+ 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff,
+ 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
+ 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
+ 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff,
+ };
+
+ if (HowMany<=(Buffer_Size%8))
+ {
+ Buffer_Size-=HowMany;
+ return (LastByte>>(Buffer_Size%8))&Mask[HowMany];
+ }
+
+ if (HowMany>Buffer_Size)
+ {
+ Buffer_Size=0;
+ BufferUnderRun=true;
+ return 0;
+ }
+
+ int8u NewBits=HowMany-(Buffer_Size%8);
+ if (NewBits==32)
+ ToReturn=0;
+ else
+ ToReturn=LastByte<<NewBits;
+ switch ((NewBits-1)>>3)
+ {
+ case 3 : NewBits-=8;
+ ToReturn|=*Buffer<<NewBits;
+ Buffer++;
+ case 2 : NewBits-=8;
+ ToReturn|=*Buffer<<NewBits;
+ Buffer++;
+ case 1 : NewBits-=8;
+ ToReturn|=*Buffer<<NewBits;
+ Buffer++;
+ default: ;
+ }
+ LastByte=*Buffer;
+ Buffer++;
+ Buffer_Size-=HowMany;
+ ToReturn|=(LastByte>>(Buffer_Size%8))&Mask[NewBits];
+ return ToReturn&Mask[HowMany];
+ }
+
+ int64u Get8 (int8u HowMany)
+ {
+ if (HowMany>64)
+ return 0; //Not supported
+ int8u HowMany1, HowMany2;
+ int64u Value1, Value2;
+ if (HowMany>32)
+ HowMany1=HowMany-32;
+ else
+ HowMany1=0;
+ HowMany2=HowMany-HowMany1;
+ Value1=Get4(HowMany1);
+ Value2=Get4(HowMany2);
+ if (BufferUnderRun)
+ return 0;
+ return Value1*0x100000000LL+Value2;
+ }
+
+ void Skip (size_t HowMany)
+ {
+ if (HowMany<=(Buffer_Size%8))
+ {
+ Buffer_Size-=HowMany;
+ return;
+ }
+
+ if (HowMany>Buffer_Size)
+ {
+ Buffer_Size=0;
+ BufferUnderRun=true;
+ return;
+ }
+
+ Buffer+=(HowMany-(Buffer_Size%8)-1)>>3;
+ LastByte=*Buffer;
+ Buffer++;
+ Buffer_Size-=HowMany;
+ };
+
+ bool PeekB()
+ {
+ if (Buffer_Size%8)
+ return ((LastByte>>((Buffer_Size-1)%8))&0x1)?true:false;
+
+ if (!Buffer_Size)
+ {
+ Buffer_Size=0;
+ BufferUnderRun=true;
+ return false;
+ }
+
+ return ((*Buffer)&0x80)?true:false;
+ }
+
+ int8u Peek1(int8u HowMany)
+ {
+ int8u ToReturn;
+ static const int8u Mask[9]=
+ {
+ 0x00,
+ 0x01, 0x03, 0x07, 0x0f,
+ 0x1f, 0x3f, 0x7f, 0xff,
+ };
+
+ if (HowMany<=(Buffer_Size%8))
+ return (LastByte>>((Buffer_Size-HowMany)%8))&Mask[HowMany];
+
+ if (HowMany>Buffer_Size)
+ {
+ Buffer_Size=0;
+ BufferUnderRun=true;
+ return 0;
+ }
+
+ int8u NewBits=HowMany-(Buffer_Size%8);
+ if (NewBits==8)
+ ToReturn=0;
+ else
+ ToReturn=LastByte<<NewBits;
+ ToReturn|=((*Buffer)>>((Buffer_Size-HowMany)%8))&Mask[NewBits];
+
+ return ToReturn&Mask[HowMany];
+ }
+
+ int16u Peek2(int8u HowMany)
+ {
+ int16u ToReturn;
+ static const int16u Mask[17]=
+ {
+ 0x0000,
+ 0x0001, 0x0003, 0x0007, 0x000f,
+ 0x001f, 0x003f, 0x007f, 0x00ff,
+ 0x01ff, 0x03ff, 0x07ff, 0x0fff,
+ 0x1fff, 0x3fff, 0x7fff, 0xffff,
+ };
+
+ if (HowMany<=(Buffer_Size%8))
+ return (LastByte>>((Buffer_Size-HowMany)%8))&Mask[HowMany];
+
+ if (HowMany>Buffer_Size)
+ {
+ Buffer_Size=0;
+ BufferUnderRun=true;
+ return 0;
+ }
+
+ const int8u* Buffer_Save=Buffer;
+
+ int8u NewBits=HowMany-(Buffer_Size%8);
+ if (NewBits==16)
+ ToReturn=0;
+ else
+ ToReturn=LastByte<<NewBits;
+ if ((NewBits-1)>>3)
+ {
+ NewBits-=8;
+ ToReturn|=*Buffer<<NewBits;
+ Buffer++;
+ }
+ ToReturn|=((*Buffer)>>((Buffer_Size-HowMany)%8))&Mask[NewBits];
+
+ Buffer=Buffer_Save;
+
+ return ToReturn&Mask[HowMany];
+ }
+
+ int32u Peek4(int8u HowMany)
+ {
+ int32u ToReturn;
+ static const int32u Mask[33]=
+ {
+ 0x00000000,
+ 0x00000001, 0x00000003, 0x00000007, 0x0000000f,
+ 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
+ 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
+ 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
+ 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff,
+ 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
+ 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
+ 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff,
+ };
+
+ if (HowMany<=(Buffer_Size%8))
+ return (LastByte>>((Buffer_Size-HowMany)%8))&Mask[HowMany];
+
+ if (HowMany>Buffer_Size)
+ {
+ Buffer_Size=0;
+ BufferUnderRun=true;
+ return 0;
+ }
+
+ const int8u* Buffer_Save=Buffer;
+
+ int8u NewBits=HowMany-(Buffer_Size%8);
+ if (NewBits==32)
+ ToReturn=0;
+ else
+ ToReturn=LastByte<<NewBits;
+ switch ((NewBits-1)>>3)
+ {
+ case 3 : NewBits-=8;
+ ToReturn|=*Buffer<<NewBits;
+ Buffer++;
+ case 2 : NewBits-=8;
+ ToReturn|=*Buffer<<NewBits;
+ Buffer++;
+ case 1 : NewBits-=8;
+ ToReturn|=*Buffer<<NewBits;
+ Buffer++;
+ default: ;
+ }
+ ToReturn|=((*Buffer)>>((Buffer_Size-HowMany)%8))&Mask[NewBits];
+
+ Buffer=Buffer_Save;
+
+ return ToReturn&Mask[HowMany];
+ }
+
+ int64u Peek8(int8u HowMany)
+ {
+ return (int64u)Peek4(HowMany); //Not yet implemented
+ }
+
+ inline size_t Remain () //How many bits remain?
+ {
+ return Buffer_Size;
+ };
+
+ inline void Byte_Align()
+ {
+ Skip (Buffer_Size%8);
+ };
+
+ inline size_t Offset_Get()
+ {
+ return (Buffer_Size_Init-Buffer_Size)/8;
+ };
+
+ inline size_t BitOffset_Get()
+ {
+ return Buffer_Size%8;
+ };
+
+ inline size_t OffsetBeforeLastCall_Get() //No more valid
+ {
+ return Buffer_Size%8;
+ };
+
+private :
+ const int8u* Buffer;
+ size_t Buffer_Size;
+ size_t Buffer_Size_Init;
+ int8u LastByte;
+public :
+ bool BufferUnderRun;
+};
+
+} //namespace ZenLib
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/BitStream_LE.h b/src/thirdparty/ZenLib/ZenLib/BitStream_LE.h
new file mode 100644
index 000000000..eb71ab1de
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/BitStream_LE.h
@@ -0,0 +1,147 @@
+// ZenLib::BitStream_LE - Read bit per bit, Little Endian version
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Read a stream bit per bit, Little Endian version (rarely used!!!)
+// Can read up to 32 bits at once
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenBitStream_LEH
+#define ZenBitStream_LEH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/BitStream.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+class BitStream_LE : public BitStream
+{
+public:
+ BitStream_LE () :BitStream() {};
+ BitStream_LE (const int8u* Buffer_, size_t Size_) :BitStream(Buffer_, Size_) {};
+
+ void Attach(const int8u* Buffer_, size_t Size_)
+ {
+ endbyte=0;
+ endbit=0;
+ buffer=Buffer_;
+ ptr=Buffer_;
+ storage=(long)Size_;
+ };
+
+ int32u Get (size_t HowMany)
+ {
+ ptr_BeforeLastCall=ptr;
+
+ long ret;
+ static const int32u Mask[33]={
+ 0x00000000,
+ 0x00000001, 0x00000003, 0x00000007, 0x0000000f,
+ 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
+ 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
+ 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
+ 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff,
+ 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
+ 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
+ 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff,
+ };
+ unsigned long m=Mask[HowMany];
+
+ HowMany+=endbit;
+
+ if(endbyte+4>=storage){
+ ret=-1L;
+ if(endbyte*8+(long)HowMany>storage*8){
+ Attach(NULL, 0);
+ goto overflow;
+ }
+ }
+
+ ret=ptr[0]>>endbit;
+ if(HowMany>8){
+ ret|=ptr[1]<<(8-endbit);
+ if(HowMany>16){
+ ret|=ptr[2]<<(16-endbit);
+ if(HowMany>24){
+ ret|=ptr[3]<<(24-endbit);
+ if(HowMany>32 && endbit){
+ ret|=ptr[4]<<(32-endbit);
+ }
+ }
+ }
+ }
+ ret&=m;
+
+ ptr+=HowMany/8;
+ endbyte+=(long)HowMany/8;
+ endbit=(long)HowMany&7;
+
+ overflow:
+
+ return(ret);
+ };
+
+ void Skip(size_t bits)
+ {
+ Get(bits);
+ }
+
+ int32u Remain () //How many bits remain?
+ {
+ return storage*8-(endbyte*8+endbit);
+ };
+
+ void Byte_Align()
+ {
+ };
+
+ size_t Offset_Get()
+ {
+ return ptr-buffer;
+ };
+
+ size_t BitOffset_Get()
+ {
+ return endbit;
+ };
+
+ size_t OffsetBeforeLastCall_Get()
+ {
+ return ptr_BeforeLastCall-buffer;
+ };
+
+private :
+ long endbyte;
+ int endbit;
+
+ const unsigned char *buffer;
+ const unsigned char *ptr;
+ const unsigned char *ptr_BeforeLastCall;
+ long storage;
+};
+
+} //namespace ZenLib
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/Conf.cpp b/src/thirdparty/ZenLib/ZenLib/Conf.cpp
new file mode 100644
index 000000000..c09e9f9b1
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Conf.cpp
@@ -0,0 +1,59 @@
+// ZenLib::ZenTypes - To be independant of platform & compiler
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Platform differences
+//***************************************************************************
+
+//End of line
+#ifdef WINDOWS
+ const Char* EOL=_T("\r\n");
+ const Char PathSeparator=_T('\\');
+#endif
+#ifdef UNIX
+ const Char* EOL=_T("\n");
+ const Char PathSeparator=_T('/');
+#endif
+#if defined (MACOS) || defined (MACOSX)
+ const Char* EOL=_T("\r");
+ const Char PathSeparator=_T('/');
+#endif
+
+//***************************************************************************
+//
+//***************************************************************************
+
+} //namespace
diff --git a/src/thirdparty/ZenLib/ZenLib/Conf.h b/src/thirdparty/ZenLib/ZenLib/Conf.h
new file mode 100644
index 000000000..b7abbf489
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Conf.h
@@ -0,0 +1,372 @@
+// ZenLib::ZenTypes - To be independant of platform & compiler
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenConfH
+#define ZenConfH
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Platforms
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Win32
+#if defined(__NT__) || defined(_WIN32) || defined(WIN32)
+ #ifndef WIN32
+ #define WIN32
+ #endif
+ #ifndef _WIN32
+ #define _WIN32
+ #endif
+ #ifndef __WIN32__
+ #define __WIN32__ 1
+ #endif
+#endif
+
+//---------------------------------------------------------------------------
+//Win64
+#if defined(_WIN64) || defined(WIN64)
+ #ifndef WIN64
+ #define WIN64
+ #endif
+ #ifndef _WIN64
+ #define _WIN64
+ #endif
+ #ifndef __WIN64__
+ #define __WIN64__ 1
+ #endif
+#endif
+
+//---------------------------------------------------------------------------
+//Windows
+#if defined(WIN32) || defined(WIN64)
+ #ifndef WINDOWS
+ #define WINDOWS
+ #endif
+ #ifndef _WINDOWS
+ #define _WINDOWS
+ #endif
+ #ifndef __WINDOWS__
+ #define __WINDOWS__ 1
+ #endif
+#endif
+#if !defined(ZENLIB_NO_WIN9X_SUPPORT) && (defined(_M_X64) || defined(_M_IA64))
+ #define ZENLIB_NO_WIN9X_SUPPORT
+#endif
+
+//---------------------------------------------------------------------------
+//Unix (Linux, HP, Sun, BeOS...)
+#if defined(UNIX) || defined(_UNIX) || defined(__UNIX__) \
+ || defined(__unix) || defined(__unix__) \
+ || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) \
+ || defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) \
+ || defined(__EMX__) || defined(__VMS) || defined(__BEOS__)
+ #ifndef UNIX
+ #define UNIX
+ #endif
+ #ifndef _UNIX
+ #define _UNIX
+ #endif
+ #ifndef __UNIX__
+ #define __UNIX__ 1
+ #endif
+#endif
+
+//---------------------------------------------------------------------------
+//MacOS Classic
+#if defined(macintosh)
+ #ifndef MACOS
+ #define MACOS
+ #endif
+ #ifndef _MACOS
+ #define _MACOS
+ #endif
+ #ifndef __MACOS__
+ #define __MACOS__ 1
+ #endif
+#endif
+
+//---------------------------------------------------------------------------
+//MacOS X
+#if defined(__APPLE__) && defined(__MACH__)
+ #ifndef MACOSX
+ #define MACOSX
+ #endif
+ #ifndef _MACOSX
+ #define _MACOSX
+ #endif
+ #ifndef __MACOSX__
+ #define __MACOSX__ 1
+ #endif
+#endif
+
+//Test of targets
+#if defined(WINDOWS) && defined(UNIX) && defined(MACOS) && defined(MACOSX)
+ #pragma message Multiple platforms???
+#endif
+
+#if !defined(WIN32) && !defined(UNIX) && !defined(MACOS) && !defined(MACOSX)
+ #pragma message No known platforms, assume default
+#endif
+
+//***************************************************************************
+// Internationnal
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Unicode
+#if defined(_UNICODE) || defined(UNICODE) || defined(__UNICODE__)
+ #ifndef _UNICODE
+ #define _UNICODE
+ #endif
+ #ifndef UNICODE
+ #define UNICODE
+ #endif
+ #ifndef __UNICODE__
+ #define __UNICODE__ 1
+ #endif
+#endif
+
+//---------------------------------------------------------------------------
+//wchar_t stuff
+#if defined(MACOS) || defined(MACOSX)
+ #include <wchar.h>
+#endif
+
+//***************************************************************************
+// Compiler bugs/unuseful warning
+//***************************************************************************
+
+//MSVC6 : for(int t=0; t<10; ++t) { do something }; for(int t=0; t<10; ++t) { do something }
+#if defined(_MSC_VER) && _MSC_VER <= 1200
+ #define for if(true)for
+ #pragma warning(disable:4786) // MSVC6 doesn't like typenames longer than 255 chars (which generates an enormous amount of warnings).
+#endif
+
+//MSVC2005 : "deprecated" warning (replacement functions are not in MinGW32 or Borland!)
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ #pragma warning(disable : 4996)
+#endif
+
+//***************************************************************************
+// (Without Namespace)
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+#include <limits.h>
+
+//---------------------------------------------------------------------------
+#if defined(ZENLIB_DEBUG) && (defined(DEBUG) || defined(_DEBUG))
+ #include "ZenLib/MemoryDebug.h"
+#endif // defined(ZENLIB_DEBUG) && (defined(DEBUG) || defined(_DEBUG))
+
+//***************************************************************************
+// Compiler helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Macro to cut down on compiler warnings
+#ifndef UNUSED
+ #define UNUSED(Identifier)
+#endif
+//---------------------------------------------------------------------------
+//If we need size_t specific integer conversion
+#if !defined(SIZE_T_IS_LONG) && (defined(__LP64__) || defined(MACOSX))
+ #define SIZE_T_IS_LONG
+#endif
+
+//---------------------------------------------------------------------------
+//(-1) is known to be the MAX of an unsigned int but GCC complains about it
+#include <new>
+#include <cstring> //size_t
+namespace ZenLib
+{
+ const std::size_t Error=((std::size_t)(-1));
+ const std::size_t All=((std::size_t)(-1));
+ const std::size_t Unlimited=((std::size_t)(-1));
+}
+
+//***************************************************************************
+// (With namespace)
+//***************************************************************************
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// International
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Char types
+#undef _T
+#define _T(__x) __T(__x)
+#undef _TEXT
+#define _TEXT(__x) __T(__x)
+#undef __TEXT
+#define __TEXT(__x) __T(__x)
+#if defined(__UNICODE__)
+ #if defined (_MSC_VER) && !defined (_NATIVE_WCHAR_T_DEFINED)
+ #pragma message Native wchar_t is not defined, not tested, you should put /Zc:wchar_t in compiler options
+ #endif
+ typedef wchar_t Char;
+ #undef __T
+ #define __T(__x) L##__x
+#else // defined(__UNICODE__)
+ typedef char Char;
+ #undef __T
+ #define __T(__x) __x
+#endif // defined(__UNICODE__)
+#ifdef wchar_t
+ typedef wchar_t wchar;
+#endif // wchar_t
+
+//***************************************************************************
+// Platform differences
+//***************************************************************************
+
+//End of line
+extern const Char* EOL;
+extern const Char PathSeparator;
+
+//***************************************************************************
+// Types
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//int
+typedef signed int ints;
+typedef unsigned int intu;
+
+//---------------------------------------------------------------------------
+//8-bit int
+#if UCHAR_MAX==0xff
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 8
+ typedef signed char int8s;
+ typedef unsigned char int8u;
+#else
+ #pragma message This machine has no 8-bit integertype?
+#endif
+
+//---------------------------------------------------------------------------
+//16-bit int
+#if UINT_MAX == 0xffff
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 16
+ typedef signed int int16s;
+ typedef unsigned int int16u;
+#elif USHRT_MAX == 0xffff
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 16
+ typedef signed short int16s;
+ typedef unsigned short int16u;
+#else
+ #pragma message This machine has no 16-bit integertype?
+#endif
+
+//---------------------------------------------------------------------------
+//32-bit int
+#if UINT_MAX == 0xfffffffful
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 32
+ typedef signed int int32s;
+ typedef unsigned int int32u;
+#elif ULONG_MAX == 0xfffffffful
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 32
+ typedef signed long int32s;
+ typedef unsigned long int32u;
+#elif USHRT_MAX == 0xfffffffful
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 32
+ typedef signed short int32s;
+ typedef unsigned short int32u;
+#else
+ #pragma message This machine has no 32-bit integer type?
+#endif
+
+//---------------------------------------------------------------------------
+//64-bit int
+#if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__) || defined(__MACOSX__)
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 64
+ typedef signed long long int64s;
+ typedef unsigned long long int64u;
+#elif defined(__WIN32__)
+ #undef MAXTYPE_INT
+ #define MAXTYPE_INT 64
+ typedef signed __int64 int64s;
+ typedef unsigned __int64 int64u;
+#else
+ #pragma message This machine has no 64-bit integer type?
+#endif
+
+//---------------------------------------------------------------------------
+//32-bit float
+#if defined(WINDOWS) || defined(UNIX) || defined(MACOSX)
+ #undef MAXTYPE_FLOAT
+ #define MAXTYPE_FLOAT 32
+ typedef float float32;
+#else
+ #pragma message This machine has no 32-bit float type?
+#endif
+
+//---------------------------------------------------------------------------
+//64-bit float
+#if defined(WINDOWS) || defined(UNIX) || defined(MACOSX)
+ #undef MAXTYPE_FLOAT
+ #define MAXTYPE_FLOAT 64
+ typedef double float64;
+#else
+ #pragma message This machine has no 64-bit float type?
+#endif
+
+//---------------------------------------------------------------------------
+//80-bit float
+#if defined(WINDOWS) || defined(UNIX) || defined(MACOSX)
+ #undef MAXTYPE_FLOAT
+ #define MAXTYPE_FLOAT 80
+ typedef long double float80;
+#else
+ #pragma message This machine has no 80-bit float type?
+#endif
+
+//***************************************************************************
+// Nested functions
+//***************************************************************************
+
+//Unices
+#if defined (UNIX)
+ #define snwprintf swprintf
+#endif
+
+//Windows - MSVC
+#if defined (_MSC_VER)
+ #define snprintf _snprintf
+ #define snwprintf _snwprintf
+#endif
+
+} //namespace
+#endif
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Conf_Internal.h b/src/thirdparty/ZenLib/ZenLib/Conf_Internal.h
new file mode 100644
index 000000000..cd05b1436
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Conf_Internal.h
@@ -0,0 +1,41 @@
+// ZenLib::Conf_Internal - To be independant of platform & compiler
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenConf_InternalH
+#define ZenConf_InternalH
+//---------------------------------------------------------------------------
+
+#include "ZenLib/Conf.h"
+
+//***************************************************************************
+// Choice of method
+//***************************************************************************
+
+#ifndef ZENLIB_USEWX
+ #ifndef WINDOWS
+ #define ZENLIB_STANDARD //We select the C/C++ standard as much as possible
+ #endif
+#endif //ZENLIB_USEWX
+
+#endif
+
diff --git a/src/thirdparty/ZenLib/ZenLib/CriticalSection.cpp b/src/thirdparty/ZenLib/ZenLib/CriticalSection.cpp
new file mode 100644
index 000000000..a57d09d7e
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/CriticalSection.cpp
@@ -0,0 +1,204 @@
+// ZenLib::CriticalSection - CriticalSection functions
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/CriticalSection.h"
+//---------------------------------------------------------------------------
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// ZENLIB_USEWX
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#ifdef ZENLIB_USEWX
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include <wx/thread.h>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+CriticalSection::CriticalSection()
+{
+ CritSect=new wxCriticalSection();
+}
+
+//---------------------------------------------------------------------------
+CriticalSection::~CriticalSection()
+{
+ delete ((wxCriticalSection*)CritSect); //CritSect=NULL;
+}
+
+//***************************************************************************
+// Enter/Leave
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void CriticalSection::Enter()
+{
+ ((wxCriticalSection*)CritSect)->Enter();
+}
+
+//---------------------------------------------------------------------------
+void CriticalSection::Leave()
+{
+ ((wxCriticalSection*)CritSect)->Leave();
+}
+
+} //Namespace
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// WINDOWS
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#else //ZENLIB_USEWX
+#ifdef WINDOWS
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#undef __TEXT
+#include <windows.h>
+//---------------------------------------------------------------------------
+
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+CriticalSection::CriticalSection()
+{
+ CritSect=new CRITICAL_SECTION;
+ InitializeCriticalSection((CRITICAL_SECTION*)CritSect);
+}
+
+//---------------------------------------------------------------------------
+CriticalSection::~CriticalSection()
+{
+ DeleteCriticalSection((CRITICAL_SECTION*)CritSect);
+ delete ((CRITICAL_SECTION*)CritSect); //CritSect=NULL;
+}
+
+//***************************************************************************
+// Enter/Leave
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void CriticalSection::Enter()
+{
+ EnterCriticalSection((CRITICAL_SECTION*)CritSect);
+}
+
+//---------------------------------------------------------------------------
+void CriticalSection::Leave()
+{
+ LeaveCriticalSection((CRITICAL_SECTION*)CritSect);
+}
+
+} //Namespace
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// UNIX
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#else //WINDOWS
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include <pthread.h>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+CriticalSection::CriticalSection()
+{
+ CritSect=new pthread_mutex_t;
+ pthread_mutex_init((pthread_mutex_t*)CritSect, NULL);
+}
+
+//---------------------------------------------------------------------------
+CriticalSection::~CriticalSection()
+{
+ pthread_mutex_destroy((pthread_mutex_t*)CritSect);
+ delete (pthread_mutex_t*)CritSect;
+}
+
+//***************************************************************************
+// Enter/Leave
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void CriticalSection::Enter()
+{
+ pthread_mutex_lock((pthread_mutex_t*)CritSect);
+}
+
+//---------------------------------------------------------------------------
+void CriticalSection::Leave()
+{
+ pthread_mutex_unlock((pthread_mutex_t*)CritSect);
+}
+
+} //Namespace
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#endif //WINDOWS
+#endif //ZENLIB_USEWX
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
diff --git a/src/thirdparty/ZenLib/ZenLib/CriticalSection.h b/src/thirdparty/ZenLib/ZenLib/CriticalSection.h
new file mode 100644
index 000000000..9498a04d4
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/CriticalSection.h
@@ -0,0 +1,84 @@
+// ZenLib::CriticalSection - CriticalSection functions
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// CriticalSection functions
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_CriticalSectionH
+#define ZenLib_CriticalSectionH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef CS
+ #undef CS //Solaris defines this somewhere
+#endif
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+/// @brief CriticalSection manipulation
+//***************************************************************************
+
+class CriticalSection
+{
+public :
+ //Constructor/Destructor
+ CriticalSection ();
+ ~CriticalSection ();
+
+ //Enter/Leave
+ void Enter();
+ void Leave();
+
+private :
+ void* CritSect;
+};
+
+//***************************************************************************
+/// @brief CriticalSectionLocker helper
+//***************************************************************************
+
+class CriticalSectionLocker
+{
+public:
+ CriticalSectionLocker (ZenLib::CriticalSection &CS)
+ {
+ CritSec=&CS;
+ CritSec->Enter();
+ }
+
+ ~CriticalSectionLocker ()
+ {
+ CritSec->Leave();
+ }
+
+private:
+ ZenLib::CriticalSection *CritSec;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/Dir.cpp b/src/thirdparty/ZenLib/ZenLib/Dir.cpp
new file mode 100644
index 000000000..118c6f511
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Dir.cpp
@@ -0,0 +1,335 @@
+// ZenLib::Dir - Directories functions
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef ZENLIB_USEWX
+ #include <wx/file.h>
+ #include <wx/filename.h>
+ #include <wx/utils.h>
+ #include <wx/dir.h>
+#else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ #undef WINDOWS
+ #endif
+ #ifdef WINDOWS
+ #undef __TEXT
+ #include <windows.h>
+ #else
+ #include <sys/stat.h>
+ #include <sys/types.h>
+ #undef __TEXT //dirent include windows.h on Windows/Borland
+ #include <dirent.h>
+ #include <glob.h>
+ #endif
+#endif //ZENLIB_USEWX
+#include "ZenLib/Dir.h"
+#include "ZenLib/File.h"
+#include "ZenLib/FileName.h"
+#include "ZenLib/ZtringList.h"
+#include "ZenLib/OS_Utils.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+
+//***************************************************************************
+// Open/Close
+//***************************************************************************
+
+ZtringList Dir::GetAllFileNames(const Ztring &Dir_Name_, dirlist_t Options)
+{
+ ZtringList ToReturn;
+ Ztring Dir_Name=Dir_Name_;
+
+ #ifdef ZENLIB_USEWX
+ int Flags=wxDIR_FILES | wxDIR_DIRS;
+
+ //Search for files
+ wxArrayString Liste;
+ wxFileName FullPath; FullPath=Dir_Name.c_str();
+ //-File
+ if (FullPath.FileExists())
+ {
+ FullPath.Normalize();
+ Liste.Add(FullPath.GetFullPath());
+ }
+ //-Directory
+ else if (FullPath.DirExists())
+ {
+ FullPath.Normalize();
+ wxDir::GetAllFiles(FullPath.GetFullPath(), &Liste, Ztring(), Flags);
+ }
+ //-WildCards
+ else
+ {
+ wxString FileName=FullPath.GetFullName();
+ FullPath.SetFullName(Ztring()); //Supress filename
+ FullPath.Normalize();
+ if (FullPath.DirExists())
+ wxDir::GetAllFiles(FullPath.GetPath(), &Liste, FileName, Flags);
+ }
+
+ //Compatible array
+ ToReturn.reserve(Liste.GetCount());
+ for (size_t Pos=0; Pos<Liste.GetCount(); Pos++)
+ ToReturn.push_back(Liste[Pos].c_str());
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ //Is a dir?
+ if (Exists(Dir_Name))
+ Dir_Name+=_T("\\*");
+
+ //Path
+ Ztring Path=FileName::Path_Get(Dir_Name);
+ if (Path.empty())
+ {
+ #ifdef UNICODE
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ {
+ DWORD Path_Size=GetFullPathNameA(Dir_Name.To_Local().c_str(), 0, NULL, NULL);
+ char* PathTemp=new char[Path_Size+1];
+ if (GetFullPathNameA(Dir_Name.To_Local().c_str(), Path_Size+1, PathTemp, NULL))
+ Path=FileName::Path_Get(PathTemp);
+ delete [] PathTemp; //PathTemp=NULL;
+ }
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ {
+ DWORD Path_Size=GetFullPathName(Dir_Name.c_str(), 0, NULL, NULL);
+ Char* PathTemp=new Char[Path_Size+1];
+ if (GetFullPathNameW(Dir_Name.c_str(), Path_Size+1, PathTemp, NULL))
+ Path=FileName::Path_Get(PathTemp);
+ delete [] PathTemp; //PathTemp=NULL;
+ }
+ #else
+ DWORD Path_Size=GetFullPathName(Dir_Name.c_str(), 0, NULL, NULL);
+ Char* PathTemp=new Char[Path_Size+1];
+ if (GetFullPathName(Dir_Name.c_str(), Path_Size+1, PathTemp, NULL))
+ Path=FileName::Path_Get(PathTemp);
+ delete [] PathTemp; //PathTemp=NULL;
+ #endif //UNICODE
+ }
+
+ #ifdef UNICODE
+ WIN32_FIND_DATAW FindFileDataW;
+ HANDLE hFind;
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ WIN32_FIND_DATAA FindFileDataA;
+ if (IsWin9X_Fast())
+ hFind=FindFirstFileA(Dir_Name.To_Local().c_str(), &FindFileDataA);
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ hFind=FindFirstFileW(Dir_Name.c_str(), &FindFileDataW);
+ #else
+ WIN32_FIND_DATA FindFileData;
+ HANDLE hFind=FindFirstFile(Dir_Name.c_str(), &FindFileData);
+ #endif //UNICODE
+
+ if (hFind==INVALID_HANDLE_VALUE)
+ return ZtringList();
+
+ BOOL ReturnValue;
+ do
+ {
+ #ifdef UNICODE
+ Ztring File_Name;
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ File_Name=FindFileDataA.cFileName;
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ File_Name=FindFileDataW.cFileName;
+ #else
+ Ztring File_Name(FindFileData.cFileName);
+ #endif //UNICODE
+ if (File_Name!=_T(".") && File_Name!=_T("..")) //Avoid . an ..
+ {
+ Ztring File_Name_Complete=Path+_T("\\")+File_Name;
+ if (Exists(File_Name_Complete))
+ {
+ if (Options&Parse_SubDirs)
+ ToReturn+=GetAllFileNames(File_Name_Complete, Options); //A SubDir
+ }
+ else if ((Options&Include_Hidden) || (!File_Name.empty() && File_Name[0]!=_T('.')))
+ ToReturn.push_back(File_Name_Complete); //A file
+ }
+ #ifdef UNICODE
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ ReturnValue=FindNextFileA(hFind, &FindFileDataA);
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ ReturnValue=FindNextFileW(hFind, &FindFileDataW);
+ #else
+ ReturnValue=FindNextFile(hFind, &FindFileData);
+ #endif //UNICODE
+ }
+ while (ReturnValue);
+
+ FindClose(hFind);
+ #else //WINDOWS
+ //A file?
+ if (File::Exists(Dir_Name))
+ {
+ ToReturn.push_back(Dir_Name); //TODO
+ return ToReturn;
+ }
+
+ //A dir?
+ if (!Dir::Exists(Dir_Name))
+ return ToReturn; //Does not exist
+
+ //open
+ #ifdef UNICODE
+ DIR* Dir=opendir(Dir_Name.To_Local().c_str());
+ #else
+ DIR* Dir=opendir(Dir_Name.c_str());
+ #endif //UNICODE
+ if (Dir)
+ {
+ //This is a dir
+ //Normalizing dir (the / at the end)
+ size_t Dir_Pos=Dir_Name.rfind(FileName_PathSeparator);
+ if (Dir_Pos==std::string::npos)
+ Dir_Name+=FileName_PathSeparator;
+ else if (Dir_Pos+Ztring(FileName_PathSeparator).size()!=Dir_Name.size())
+ Dir_Name+=FileName_PathSeparator;
+
+ struct dirent *DirEnt;
+ while((DirEnt=readdir(Dir))!=NULL)
+ {
+ //A file
+ Ztring File_Name(DirEnt->d_name);
+ if (File_Name!=_T(".") && File_Name!=_T("..")) //Avoid . an ..
+ {
+ Ztring File_Name_Complete=Dir_Name+File_Name;
+ if (Exists(File_Name_Complete))
+ {
+ if (Options&Parse_SubDirs)
+ ToReturn+=GetAllFileNames(File_Name_Complete, Options); //A SubDir
+ }
+ else if ((Options&Include_Hidden) || (!File_Name.empty() && File_Name[0]!=_T('.')))
+ ToReturn.push_back(File_Name_Complete); //A file
+ }
+ }
+
+ //Close it
+ closedir(Dir);
+ }
+ else
+ {
+ glob_t globbuf;
+ if (glob(Dir_Name.To_Local().c_str(), GLOB_NOSORT, NULL, &globbuf)==0)
+ {
+ for (int Pos=0; Pos<globbuf.gl_pathc; Pos++)
+ ToReturn.push_back(Ztring().From_Local(globbuf.gl_pathv[Pos]));
+ }
+ }
+ #endif
+ #endif //ZENLIB_USEWX
+
+ return ToReturn;
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool Dir::Exists(const Ztring &File_Name)
+{
+ #ifdef ZENLIB_USEWX
+ wxFileName FN(File_Name.c_str());
+ return FN.DirExists();
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ #ifdef UNICODE
+ DWORD FileAttributes;
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ FileAttributes=GetFileAttributesA(File_Name.To_Local().c_str());
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ FileAttributes=GetFileAttributesW(File_Name.c_str());
+ #else
+ DWORD FileAttributes=GetFileAttributes(File_Name.c_str());
+ #endif //UNICODE
+ return ((FileAttributes!=INVALID_FILE_ATTRIBUTES) && (FileAttributes&FILE_ATTRIBUTE_DIRECTORY));
+ #else //WINDOWS
+ struct stat buffer;
+ int status;
+ #ifdef UNICODE
+ status=stat(File_Name.To_Local().c_str(), &buffer);
+ #else
+ status=stat(File_Name.c_str(), &buffer);
+ #endif //UNICODE
+ return status==0 && S_ISDIR(buffer.st_mode);
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+bool Dir::Create(const Ztring &File_Name)
+{
+ #ifdef ZENLIB_USEWX
+ return wxFileName::Mkdir(File_Name.c_str());
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ #ifdef UNICODE
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ return CreateDirectoryA(File_Name.To_Local().c_str(), NULL)!=0;
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ return CreateDirectoryW(File_Name.c_str(), NULL)!=0;
+ #else
+ return CreateDirectory(File_Name.c_str(), NULL)!=0;
+ #endif //UNICODE
+ #else //WINDOWS
+ return mkdir(File_Name.To_Local().c_str(), 0700)==0;
+ #endif //WINDOWS
+ #endif //ZENLIB_USEWX
+}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+} //namespace
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Dir.h b/src/thirdparty/ZenLib/ZenLib/Dir.h
new file mode 100644
index 000000000..c069d286b
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Dir.h
@@ -0,0 +1,70 @@
+// ZenLib::Dir - Directories functions
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Directories functions
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_DirH
+#define ZenLib_DirH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+#include "ZenLib/ZtringList.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+/// @brief Directory manipulation
+//***************************************************************************
+
+class Dir
+{
+public :
+ //---------------------------------------------------------------------------
+ /// @brief Options for Open method
+ enum dirlist_t
+ {
+ Nothing = 0x00, ///<
+ Include_Files = 0x01, ///< Include files
+ Include_Dirs = 0x02, ///< Include directories
+ Include_Hidden = 0x04, ///< Include hidden files
+ Parse_SubDirs = 0x10 ///< Parse subdirectories
+ };
+
+ //Constructor/Destructor
+
+ //Open/close
+ static ZtringList GetAllFileNames(const Ztring &Dir_Name, dirlist_t Options=(dirlist_t)(Include_Files|Parse_SubDirs));
+
+ //Helpers
+ static bool Exists(const Ztring &Dir_Name);
+ static bool Create(const Ztring &Dir_Name);
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/File.cpp b/src/thirdparty/ZenLib/ZenLib/File.cpp
new file mode 100644
index 000000000..618bd293b
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/File.cpp
@@ -0,0 +1,954 @@
+// ZenLib::File - File functions
+// Copyright (C) 2002-2010 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef ZENLIB_USEWX
+ #include <wx/file.h>
+ #include <wx/filename.h>
+ #include <wx/utils.h>
+#else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ #ifdef WINDOWS
+ #else
+ #include <cstdio>
+ #endif
+ #include <sys/stat.h>
+ #if !defined(WINDOWS)
+ #include <unistd.h>
+ #endif //!defined(WINDOWS)
+ #include <fstream>
+ using namespace std;
+ #ifndef S_ISDIR
+ #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
+ #endif
+ #ifndef S_ISREG
+ #define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
+ #endif
+ #elif defined WINDOWS
+ #undef __TEXT
+ #include <windows.h>
+ #endif
+#endif //ZENLIB_USEWX
+#include "ZenLib/File.h"
+#include "ZenLib/OS_Utils.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+File::File()
+{
+ #ifdef ZENLIB_USEWX
+ File_Handle=NULL;
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ File_Handle=NULL;
+ #elif defined WINDOWS
+ File_Handle=INVALID_HANDLE_VALUE;
+ #endif
+ #endif //ZENLIB_USEWX
+ Position=(int64u)-1;
+ Size=(int64u)-1;
+}
+
+File::File(Ztring File_Name, access_t Access)
+{
+ #ifdef ZENLIB_USEWX
+ File_Handle=NULL;
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ File_Handle=NULL;
+ #elif defined WINDOWS
+ File_Handle=INVALID_HANDLE_VALUE;
+ #endif
+ #endif //ZENLIB_USEWX
+ Position=(int64u)-1;
+ Size=(int64u)-1;
+ Open(File_Name, Access);
+}
+
+//---------------------------------------------------------------------------
+File::~File()
+{
+ Close();
+}
+
+//***************************************************************************
+// Open/Close
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File::Open (const tstring &File_Name_, access_t Access)
+{
+ Close();
+
+ File_Name=File_Name_;
+
+ #ifdef ZENLIB_USEWX
+ File_Handle=(void*)new wxFile();
+ if (((wxFile*)File_Handle)->Open(File_Name.c_str(), (wxFile::OpenMode)Access)==0)
+ {
+ //Sometime the file is locked for few milliseconds, we try again later
+ wxMilliSleep(1000);
+ if (((wxFile*)File_Handle)->Open(File_Name.c_str(), (wxFile::OpenMode)Access)==0)
+ //File is not openable
+ return false;
+ }
+ return true;
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ /*
+ int access;
+ switch (Access)
+ {
+ case Access_Read : access=O_BINARY|O_RDONLY ; break;
+ case Access_Write : access=O_BINARY|O_WRONLY|O_CREAT|O_TRUNC ; break;
+ case Access_Read_Write : access=O_BINARY|O_RDWR |O_CREAT ; break;
+ case Access_Write_Append : access=O_BINARY|O_WRONLY|O_CREAT|O_APPEND ; break;
+ default : access=0 ; break;
+ }
+ #ifdef UNICODE
+ File_Handle=open(File_Name.To_Local().c_str(), access);
+ #else
+ File_Handle=open(File_Name.c_str(), access);
+ #endif //UNICODE
+ return File_Handle!=-1;
+ */
+ ios_base::openmode mode;
+ switch (Access)
+ {
+ case Access_Read : mode=ios_base::binary|ios_base::in; break;
+ case Access_Write : mode=ios_base::binary|ios_base::out; break;
+ case Access_Read_Write : mode=ios_base::binary|ios_base::in|ios_base::out; break;
+ case Access_Write_Append : if (!Exists(File_Name))
+ mode=ios_base::binary|ios_base::out;
+ else
+ mode=ios_base::binary|ios_base::out|ios_base::app;
+ break;
+ default : ;
+ }
+ #ifdef UNICODE
+ File_Handle=new fstream(File_Name.To_Local().c_str(), mode);
+ #else
+ File_Handle=new fstream(File_Name.c_str(), mode);
+ #endif //UNICODE
+ if (!((fstream*)File_Handle)->is_open())
+ {
+ delete (fstream*)File_Handle; File_Handle=NULL;
+ return false;
+ }
+ return true;
+ #elif defined WINDOWS
+ DWORD dwDesiredAccess, dwShareMode, dwCreationDisposition;
+ switch (Access)
+ {
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ case Access_Read : dwDesiredAccess=IsWin9X_Fast()?GENERIC_READ:FILE_READ_DATA; dwShareMode=FILE_SHARE_READ|FILE_SHARE_WRITE; dwCreationDisposition=OPEN_EXISTING; break;
+ case Access_Write : dwDesiredAccess=GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=OPEN_ALWAYS; break;
+ case Access_Read_Write : dwDesiredAccess=(IsWin9X_Fast()?GENERIC_READ:FILE_READ_DATA)|GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=OPEN_ALWAYS; break;
+ case Access_Write_Append : dwDesiredAccess=GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=OPEN_ALWAYS; break;
+ #else // ZENLIB_NO_WIN9X_SUPPORT
+ case Access_Read : dwDesiredAccess=FILE_READ_DATA; dwShareMode=FILE_SHARE_READ|FILE_SHARE_WRITE; dwCreationDisposition=OPEN_EXISTING; break;
+ case Access_Write : dwDesiredAccess=GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=OPEN_ALWAYS; break;
+ case Access_Read_Write : dwDesiredAccess=FILE_READ_DATA|GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=OPEN_ALWAYS; break;
+ case Access_Write_Append : dwDesiredAccess=GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=OPEN_ALWAYS; break;
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ default : dwDesiredAccess=0; dwShareMode=0; dwCreationDisposition=0; break;
+ }
+
+ #ifdef UNICODE
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ File_Handle=CreateFileA(File_Name.To_Local().c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ File_Handle=CreateFileW(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ #else
+ File_Handle=CreateFile(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ #endif //UNICODE
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ {
+ //Sometime the file is locked for few milliseconds, we try again later
+ DWORD dw = GetLastError();
+ if (dw!=ERROR_FILE_NOT_FOUND)
+ {
+ /*
+ char lpMsgBuf[1000];
+ FormatMessageA(
+ FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ dw,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ lpMsgBuf,
+ 1000, NULL );
+ */
+ Sleep(1000);
+ #ifdef UNICODE
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ File_Handle=CreateFileA(Ztring(File_Name).To_Local().c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ File_Handle=CreateFileW(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ #else
+ File_Handle=CreateFile(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ #endif //UNICODE
+ }
+ }
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ //File is not openable
+ return false;
+
+ //Append
+ if (Access==Access_Write_Append)
+ GoTo(0, FromEnd);
+
+ return true;
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+bool File::Create (const Ztring &File_Name_, bool OverWrite)
+{
+ Close();
+
+ File_Name=File_Name_;
+
+ #ifdef ZENLIB_USEWX
+ File_Handle=(void*)new wxFile();
+ if (((wxFile*)File_Handle)->Create(File_Name.c_str(), OverWrite)==0)
+ {
+ //Sometime the file is locked for few milliseconds, we try again later
+ wxMilliSleep(3000);
+ if (((wxFile*)File_Handle)->Create(File_Name.c_str(), OverWrite)==0)
+ //File is not openable
+ return false;
+ }
+ return true;
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ /*
+ int access;
+ switch (OverWrite)
+ {
+ case false : access=O_BINARY|O_CREAT|O_WRONLY|O_EXCL ; break;
+ default : access=O_BINARY|O_CREAT|O_WRONLY|O_TRUNC; break;
+ }
+ #ifdef UNICODE
+ File_Handle=open(File_Name.To_Local().c_str(), access);
+ #else
+ File_Handle=open(File_Name.c_str(), access);
+ #endif //UNICODE
+ return File_Handle!=-1;
+ */
+ /*ios_base::openmode mode;
+
+ switch (OverWrite)
+ {
+ //case false : mode= ; break;
+ default : mode=0 ; break;
+ }*/
+ ios_base::openmode access;
+ switch (OverWrite)
+ {
+ case false : if (Exists(File_Name))
+ return false;
+ default : access=ios_base::binary|ios_base::in|ios_base::out|ios_base::trunc; break;
+ }
+ #ifdef UNICODE
+ File_Handle=new fstream(File_Name.To_Local().c_str(), access);
+ #else
+ File_Handle=new fstream(File_Name.c_str(), access);
+ #endif //UNICODE
+ return ((fstream*)File_Handle)->is_open();
+ #elif defined WINDOWS
+ DWORD dwDesiredAccess, dwShareMode, dwCreationDisposition;
+ switch (OverWrite)
+ {
+ case false : dwDesiredAccess=GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=CREATE_NEW; break;
+ default : dwDesiredAccess=GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=CREATE_ALWAYS; break;
+ }
+
+ #ifdef UNICODE
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ File_Handle=CreateFileA(File_Name.To_Local().c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ File_Handle=CreateFileW(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ #else
+ File_Handle=CreateFile(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ #endif //UNICODE
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ {
+ //Sometime the file is locked for few milliseconds, we try again later
+ Sleep(3000);
+ #ifdef UNICODE
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ File_Handle=CreateFileA(File_Name.To_Local().c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ File_Handle=CreateFileW(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ #else
+ File_Handle=CreateFile(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL);
+ #endif //UNICODE
+ }
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ //File is not openable
+ return false;
+ return true;
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+void File::Close ()
+{
+ #ifdef ZENLIB_USEWX
+ delete (wxFile*)File_Handle; File_Handle=NULL;
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ //close(File_Handle); File_Handle=-1;
+ delete (fstream*)File_Handle; File_Handle=NULL;
+ #elif defined WINDOWS
+ CloseHandle(File_Handle); File_Handle=INVALID_HANDLE_VALUE;
+ #endif
+ #endif //ZENLIB_USEWX
+ Position=(int64u)-1;
+ Size=(int64u)-1;
+}
+
+//***************************************************************************
+// Read/Write
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t File::Read (int8u* Buffer, size_t Buffer_Size_Max)
+{
+ #ifdef ZENLIB_USEWX
+ if (File_Handle==NULL)
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ if (File_Handle==NULL)
+ #elif defined WINDOWS
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ #endif
+ #endif //ZENLIB_USEWX
+ return 0;
+
+ #ifdef ZENLIB_USEWX
+ size_t ByteRead=((wxFile*)File_Handle)->Read(Buffer, Buffer_Size_Max);
+ Position+=ByteRead;
+ return ByteRead;
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ //return read((int)File_Handle, Buffer, Buffer_Size_Max);
+ if (Position==(int64u)-1)
+ Position_Get();
+ if (Size==(int64u)-1)
+ Size_Get();
+ if (Position!=(int64u)-1 && Position+Buffer_Size_Max>Size)
+ Buffer_Size_Max=(size_t)(Size-Position); //We don't want to enable eofbit (impossible to seek after)
+ ((fstream*)File_Handle)->read((char*)Buffer, Buffer_Size_Max);
+ size_t ByteRead=((fstream*)File_Handle)->gcount();
+ Position+=ByteRead;
+ return ByteRead;
+ #elif defined WINDOWS
+ DWORD Buffer_Size;
+ if (ReadFile(File_Handle, Buffer, (DWORD)Buffer_Size_Max, &Buffer_Size, NULL))
+ {
+ Position+=Buffer_Size;
+ return Buffer_Size;
+ }
+ else
+ return 0;
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+size_t File::Write (const int8u* Buffer, size_t Buffer_Size)
+{
+ #ifdef ZENLIB_USEWX
+ if (File_Handle==NULL)
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ if (File_Handle==NULL)
+ #elif defined WINDOWS
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ #endif
+ #endif //ZENLIB_USEWX
+ return 0;
+
+ #ifdef ZENLIB_USEWX
+ return ((wxFile*)File_Handle)->Write(Buffer, Buffer_Size);
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ //return write(File_Handle, Buffer, Buffer_Size);
+ ((fstream*)File_Handle)->write((char*)Buffer, Buffer_Size);
+ if (((fstream*)File_Handle)->bad())
+ {
+ Position=(int64u)-1;
+ return 0;
+ }
+ else
+ {
+ if (Position!=(int64u)-1)
+ Position+=Buffer_Size;
+ return Buffer_Size;
+ }
+ #elif defined WINDOWS
+ DWORD Buffer_Size_Written;
+ if (WriteFile(File_Handle, Buffer, (DWORD)Buffer_Size, &Buffer_Size_Written, NULL))
+ {
+ if (Position!=(int64u)-1)
+ Position+=Buffer_Size_Written;
+ return Buffer_Size_Written;
+ }
+ else
+ {
+ Position=(int64u)-1;
+ return 0;
+ }
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+bool File::Truncate (int64u Offset)
+{
+ if (File_Handle==NULL)
+ return false;
+
+ #ifdef ZENLIB_USEWX
+ return false; Not supported
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ #if defined(WINDOWS)
+ return false; //No supported
+ #else //defined(WINDOWS)
+ //Need to close the file, use truncate, reopen it
+ if (Offset==(int64u)-1)
+ Offset=Position_Get();
+ Ztring File_Name_Sav=File_Name;
+ Close();
+ truncate(File_Name_Sav.To_Local().c_str(), Offset);
+ if (!Open(File_Name_Sav, Access_Read_Write))
+ return false;
+ GoTo(0, FromEnd);
+ return true;
+ #endif //!defined(WINDOWS)
+ #elif defined WINDOWS
+ if(Offset!=(int64u)-1 && Offset!=Position_Get())
+ if (!GoTo(Offset))
+ return false;
+ SetEndOfFile(File_Handle);
+ return true;
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+size_t File::Write (const Ztring &ToWrite)
+{
+ std::string AnsiString=ToWrite.To_UTF8();
+ return Write((const int8u*)AnsiString.c_str(), AnsiString.size());
+}
+
+//***************************************************************************
+// Moving
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool File::GoTo (int64s Position_ToMove, move_t MoveMethod)
+{
+ #ifdef ZENLIB_USEWX
+ if (File_Handle==NULL)
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ if (File_Handle==NULL)
+ #elif defined WINDOWS
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ #endif
+ #endif //ZENLIB_USEWX
+ return false;
+
+ Position=(int64u)-1; //Disabling memory
+ #ifdef ZENLIB_USEWX
+ return ((wxFile*)File_Handle)->Seek(Position, (wxSeekMode)MoveMethod)!=wxInvalidOffset; //move_t and wxSeekMode are same
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ /*
+ int fromwhere;
+ switch (MoveMethod)
+ {
+ case FromBegin : fromwhere=SEEK_SET; break;
+ case FromCurrent : fromwhere=SEEK_CUR; break;
+ case FromEnd : fromwhere=SEEK_END; break;
+ default : fromwhere=SEEK_CUR; break;
+ }
+ return lseek(File_Handle, Position, fromwhere)!=-1;
+ */
+ ios_base::seekdir dir;
+ switch (MoveMethod)
+ {
+ case FromBegin : dir=ios_base::beg; break;
+ case FromCurrent : dir=ios_base::cur; break;
+ case FromEnd : dir=ios_base::end; break;
+ default : dir=ios_base::beg;
+ }
+ ((fstream*)File_Handle)->seekg((streamoff)Position_ToMove, dir);
+ return !((fstream*)File_Handle)->fail();
+ #elif defined WINDOWS
+ LARGE_INTEGER GoTo; GoTo.QuadPart=Position_ToMove;
+ //return SetFilePointerEx(File_Handle, GoTo, NULL, MoveMethod)!=0; //Not on win9X
+ GoTo.LowPart=SetFilePointer(File_Handle, GoTo.LowPart, &GoTo.HighPart, MoveMethod);
+ if (GoTo.LowPart==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR)
+ return false;
+ else
+ return true;
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+int64u File::Position_Get ()
+{
+ if (Position!=(int64u)-1)
+ return Position;
+
+ #ifdef ZENLIB_USEWX
+ if (File_Handle==NULL)
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ if (File_Handle==NULL)
+ #elif defined WINDOWS
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ #endif
+ #endif //ZENLIB_USEWX
+ return (int64u)-1;
+
+ #ifdef ZENLIB_USEWX
+ return (int64u)-1;
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ Position=((fstream*)File_Handle)->tellg();
+ return Position;
+ #elif defined WINDOWS
+ LARGE_INTEGER GoTo; GoTo.QuadPart=0;
+ GoTo.LowPart=SetFilePointer(File_Handle, GoTo.LowPart, &GoTo.HighPart, FILE_CURRENT);
+ Position=GoTo.QuadPart;
+ return Position;
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//***************************************************************************
+// Attributes
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+int64u File::Size_Get()
+{
+ #ifdef ZENLIB_USEWX
+ if (File_Handle==NULL)
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ if (File_Handle==NULL)
+ #elif defined WINDOWS
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ #endif
+ #endif //ZENLIB_USEWX
+ return 0;
+
+ #ifdef ZENLIB_USEWX
+ return ((wxFile*)File_Handle)->Length();
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ /*
+ int CurrentPos=lseek(File_Handle, 0, SEEK_CUR);
+ int64u File_Size;
+ File_Size=lseek(File_Handle, 0, SEEK_END);
+ lseek(File_Handle, CurrentPos, SEEK_SET);
+ */
+ streampos CurrentPos=((fstream*)File_Handle)->tellg();
+ if (CurrentPos!=(streampos)-1)
+ {
+ ((fstream*)File_Handle)->seekg(0, ios_base::end);
+ Size=((fstream*)File_Handle)->tellg();
+ ((fstream*)File_Handle)->seekg(CurrentPos, ios_base::beg);
+ }
+ else
+ Size=(int64u)-1;
+ return Size;
+ #elif defined WINDOWS
+ DWORD High;DWORD Low=GetFileSize(File_Handle, &High);
+ if (Low==INVALID_FILE_SIZE && GetLastError()!=NO_ERROR)
+ return (int64u)-1;
+ Size=0x100000000ULL*High+Low;
+ return Size;
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+Ztring File::Created_Get()
+{
+ #ifdef ZENLIB_USEWX
+ if (File_Handle==NULL)
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ if (File_Handle==NULL)
+ #elif defined WINDOWS
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ #endif
+ #endif //ZENLIB_USEWX
+ return Ztring();
+
+ #ifdef ZENLIB_USEWX
+ return _T(""); //Not implemented
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ return _T(""); //Not implemented
+ #elif defined WINDOWS
+ FILETIME TimeFT;
+ if (GetFileTime(File_Handle, &TimeFT, NULL, NULL))
+ {
+ int64u Time64=0x100000000ULL*TimeFT.dwHighDateTime+TimeFT.dwLowDateTime;
+ Ztring Time; Time.Date_From_Milliseconds_1601(Time64/10000);
+ return Time;
+ }
+ else
+ return _T(""); //There was a problem
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+Ztring File::Created_Local_Get()
+{
+ #ifdef ZENLIB_USEWX
+ if (File_Handle==NULL)
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ if (File_Handle==NULL)
+ #elif defined WINDOWS
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ #endif
+ #endif //ZENLIB_USEWX
+ return Ztring();
+
+ #ifdef ZENLIB_USEWX
+ return _T(""); //Not implemented
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ return _T(""); //Not implemented
+ #elif defined WINDOWS
+ FILETIME TimeFT;
+ if (GetFileTime(File_Handle, &TimeFT, NULL, NULL))
+ {
+ int64u Time64=0x100000000ULL*TimeFT.dwHighDateTime+TimeFT.dwLowDateTime;
+ TIME_ZONE_INFORMATION Info;
+ DWORD Result=GetTimeZoneInformation(&Info);
+ if (Result!=TIME_ZONE_ID_INVALID)
+ {
+ Time64-=((int64s)Info.Bias)*60*1000*1000*10;
+ if (Result==TIME_ZONE_ID_DAYLIGHT)
+ Time64-=((int64s)Info.DaylightBias)*60*1000*1000*10;
+ else
+ Time64-=((int64s)Info.StandardBias)*60*1000*1000*10;
+ }
+ Ztring Time; Time.Date_From_Milliseconds_1601(Time64/10000);
+ Time.FindAndReplace(_T("UTC "), _T(""));
+ return Time;
+ }
+ else
+ return _T(""); //There was a problem
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+Ztring File::Modified_Get()
+{
+ #ifdef ZENLIB_USEWX
+ if (File_Handle==NULL)
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ if (File_Handle==NULL)
+ #elif defined WINDOWS
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ #endif
+ #endif //ZENLIB_USEWX
+ return Ztring();
+
+ #ifdef ZENLIB_USEWX
+ return _T(""); //Not implemented
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ struct stat Stat;
+ int Result=stat(File_Name.To_Local().c_str(), &Stat);
+ if (Result<0)
+ return _T(""); //Error
+ Ztring Time; Time.Date_From_Seconds_1970(Stat.st_mtime);
+ return Time;
+ #elif defined WINDOWS
+ FILETIME TimeFT;
+ if (GetFileTime(File_Handle, NULL, NULL, &TimeFT))
+ {
+ int64u Time64=0x100000000ULL*TimeFT.dwHighDateTime+TimeFT.dwLowDateTime;
+ Ztring Time; Time.Date_From_Milliseconds_1601(Time64/10000);
+ return Time;
+ }
+ else
+ return _T(""); //There was a problem
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+Ztring File::Modified_Local_Get()
+{
+ #ifdef ZENLIB_USEWX
+ if (File_Handle==NULL)
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ if (File_Handle==NULL)
+ #elif defined WINDOWS
+ if (File_Handle==INVALID_HANDLE_VALUE)
+ #endif
+ #endif //ZENLIB_USEWX
+ return Ztring();
+
+ #ifdef ZENLIB_USEWX
+ return _T(""); //Not implemented
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ struct stat Stat;
+ int Result=stat(File_Name.To_Local().c_str(), &Stat);
+ if (Result<0)
+ return _T(""); //Error
+ Ztring Time; Time.Date_From_Seconds_1970_Local(Stat.st_mtime);
+ return Time;
+ #elif defined WINDOWS
+ FILETIME TimeFT;
+ if (GetFileTime(File_Handle, NULL, NULL, &TimeFT))
+ {
+ int64u Time64=0x100000000ULL*TimeFT.dwHighDateTime+TimeFT.dwLowDateTime; //100-ns
+ TIME_ZONE_INFORMATION Info;
+ DWORD Result=GetTimeZoneInformation(&Info);
+ if (Result!=TIME_ZONE_ID_INVALID)
+ {
+ Time64-=((int64s)Info.Bias)*60*1000*1000*10;
+ if (Result==TIME_ZONE_ID_DAYLIGHT)
+ Time64-=((int64s)Info.DaylightBias)*60*1000*1000*10;
+ else
+ Time64-=((int64s)Info.StandardBias)*60*1000*1000*10;
+ }
+ Ztring Time; Time.Date_From_Milliseconds_1601(Time64/10000);
+ Time.FindAndReplace(_T("UTC "), _T(""));
+ return Time;
+ }
+ else
+ return _T(""); //There was a problem
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+bool File::Opened_Get()
+{
+ #ifdef ZENLIB_USEWX
+ return File_Handle!=NULL;
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ //return File_Handle!=-1;
+ return File_Handle!=NULL && ((fstream*)File_Handle)->is_open();
+ #elif defined WINDOWS
+ return File_Handle!=INVALID_HANDLE_VALUE;
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+int64u File::Size_Get(const Ztring &File_Name)
+{
+ File F(File_Name);
+ return F.Size_Get();
+}
+
+//---------------------------------------------------------------------------
+Ztring File::Created_Get(const Ztring &File_Name)
+{
+ File F(File_Name);
+ return F.Created_Get();
+}
+
+//---------------------------------------------------------------------------
+Ztring File::Modified_Get(const Ztring &File_Name)
+{
+ File F(File_Name);
+ return F.Modified_Get();
+}
+
+//---------------------------------------------------------------------------
+bool File::Exists(const Ztring &File_Name)
+{
+ if (File_Name.find(_T('*'))!=std::string::npos || File_Name.find(_T('?'))!=std::string::npos)
+ return false;
+
+ #ifdef ZENLIB_USEWX
+ wxFileName FN(File_Name.c_str());
+ return FN.FileExists();
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ struct stat buffer;
+ int status;
+ #ifdef UNICODE
+ status=stat(File_Name.To_Local().c_str(), &buffer);
+ #else
+ status=stat(File_Name.c_str(), &buffer);
+ #endif //UNICODE
+ return status==0 && S_ISREG(buffer.st_mode);
+ #elif defined WINDOWS
+ #ifdef UNICODE
+ DWORD FileAttributes;
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ FileAttributes=GetFileAttributesA(File_Name.To_Local().c_str());
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ FileAttributes=GetFileAttributesW(File_Name.c_str());
+ #else
+ DWORD FileAttributes=GetFileAttributes(File_Name.c_str());
+ #endif //UNICODE
+ return ((FileAttributes!=INVALID_FILE_ATTRIBUTES) && !(FileAttributes&FILE_ATTRIBUTE_DIRECTORY));
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+bool File::Copy(const Ztring &Source, const Ztring &Destination, bool OverWrite)
+{
+ #ifdef ZENLIB_USEWX
+ return wxCopyFile(Source.c_str(), Destination.c_str(), OverWrite);
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ return false;
+ #elif defined WINDOWS
+ #ifdef UNICODE
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ return CopyFileA(Source.To_Local().c_str(), Destination.To_Local().c_str(), !OverWrite)!=0;
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ return CopyFileW(Source.c_str(), Destination.c_str(), !OverWrite)!=0;
+ #else
+ return CopyFile(Source.c_str(), Destination.c_str(), !OverWrite)!=0;
+ #endif //UNICODE
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+bool File::Move(const Ztring &Source, const Ztring &Destination, bool OverWrite)
+{
+ if (OverWrite && Exists(Source))
+ Delete(Destination);
+ #ifdef ZENLIB_USEWX
+ if (OverWrite && Exists(Destination))
+ wxRemoveFile(Destination.c_str());
+ return wxRenameFile(Source.c_str(), Destination.c_str());
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ return !std::rename(Source.To_Local().c_str(), Destination.To_Local().c_str());
+ #elif defined WINDOWS
+ #ifdef UNICODE
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ return MoveFileA(Source.To_Local().c_str(), Destination.To_Local().c_str())!=0;
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ return MoveFileW(Source.c_str(), Destination.c_str())!=0;
+ #else
+ return MoveFile(Source.c_str(), Destination.c_str())!=0;
+ #endif //UNICODE
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+bool File::Delete(const Ztring &File_Name)
+{
+ #ifdef ZENLIB_USEWX
+ return wxRemoveFile(File_Name.c_str());
+ #else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ #ifdef UNICODE
+ return unlink(File_Name.To_Local().c_str())==0;
+ #else
+ return unlink(File_Name.c_str())==0;
+ #endif //UNICODE
+ #elif defined WINDOWS
+ #ifdef UNICODE
+ #ifndef ZENLIB_NO_WIN9X_SUPPORT
+ if (IsWin9X_Fast())
+ return DeleteFileA(File_Name.To_Local().c_str())!=0;
+ else
+ #endif //ZENLIB_NO_WIN9X_SUPPORT
+ return DeleteFileW(File_Name.c_str())!=0;
+ #else
+ return DeleteFile(File_Name.c_str())!=0;
+ #endif //UNICODE
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+} //namespace
+
diff --git a/src/thirdparty/ZenLib/ZenLib/File.h b/src/thirdparty/ZenLib/ZenLib/File.h
new file mode 100644
index 000000000..9be44f271
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/File.h
@@ -0,0 +1,113 @@
+// ZenLib::File - File functions
+// Copyright (C) 2007-2010 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// File functions
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_FileH
+#define ZenLib_FileH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+#include "ZenLib/Ztring.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+/// @brief File manipulation
+//***************************************************************************
+
+class File
+{
+public :
+ //---------------------------------------------------------------------------
+ /// @brief Options for Open method
+ enum access_t
+ {
+ Access_Read = 0, ///< Read permission
+ Access_Write = 1, ///< Write permission
+ Access_Read_Write = 2, ///< Read and Write permissions
+ Access_Write_Append = 3, ///< Write permission without deleting old file
+ Access_Write_Excluding = 4 ///< Write permission preventing reading
+ };
+
+ //---------------------------------------------------------------------------
+ /// @brief Options for Move method
+ enum move_t
+ {
+ FromBegin = 0, ///< Begin of file
+ FromCurrent = 1, ///< Current position
+ FromEnd = 2 ///< End of file
+ };
+
+ //Constructor/Destructor
+ File ();
+ File (ZenLib::Ztring File_Name, access_t Access=Access_Read);
+ ~File ();
+
+ //Open/close
+ bool Open (const tstring &File_Name, access_t Access=Access_Read);
+ bool Create(const ZenLib::Ztring &File_Name, bool OverWrite=true);
+ void Close ();
+
+ //Read/Write
+ size_t Read (int8u* Buffer, size_t Buffer_Size);
+ size_t Write (const int8u* Buffer, size_t Buffer_Size);
+ size_t Write (const Ztring &ToWrite);
+ bool Truncate (int64u Offset=(int64u)-1);
+
+ //Moving
+ bool GoTo (int64s Position, move_t MoveMethod=FromBegin);
+ int64u Position_Get ();
+
+ //Attributes
+ int64u Size_Get();
+ Ztring Created_Get();
+ Ztring Created_Local_Get();
+ Ztring Modified_Get();
+ Ztring Modified_Local_Get();
+ bool Opened_Get();
+
+ //Helpers
+ static int64u Size_Get(const Ztring &File_Name);
+ static Ztring Created_Get(const Ztring &File_Name);
+ static Ztring Modified_Get(const Ztring &File_Name);
+ static bool Exists(const Ztring &File_Name);
+ static bool Copy(const Ztring &Source, const Ztring &Destination, bool OverWrite=false);
+ static bool Move(const Ztring &Source, const Ztring &Destination, bool OverWrite=false);
+ static bool Delete(const Ztring &File_Name);
+
+ //Temp
+ Ztring File_Name;
+ int64u Position; //Position is saved, may be not good because position may change
+ int64u Size; //Size is saved, may be not good because size may change
+ void* File_Handle;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/FileName.cpp b/src/thirdparty/ZenLib/ZenLib/FileName.cpp
new file mode 100644
index 000000000..76f8f4146
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/FileName.cpp
@@ -0,0 +1,239 @@
+// ZenLib::FileName - File name functions
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/FileName.h"
+#ifdef ZENLIB_USEWX
+ #include <wx/filename.h>
+#else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ #undef WINDOWS
+ #endif
+ #ifdef WINDOWS
+ #undef __TEXT
+ #include <windows.h>
+ #endif
+#endif //ZENLIB_USEWX
+//---------------------------------------------------------------------------
+#undef ZENLIB_USEWX
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Read/Write
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Ztring FileName::Path_Get() const
+{
+ #ifdef ZENLIB_USEWX
+ wxFileName FN(c_str());
+ return FN.GetPath().c_str();
+ #else //ZENLIB_USEWX
+ //Path limit
+ size_t Pos_Path=rfind(FileName_PathSeparator);
+ if (Pos_Path==Ztring::npos)
+ return Ztring(); //Not found
+ else
+ return Ztring(*this, 0, Pos_Path);
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+Ztring& FileName::Path_Set(const Ztring &Path)
+{
+ #ifdef ZENLIB_USEWX
+ wxFileName FN(c_str());
+ FN.SetPath(Path.c_str());
+ assign (FN.GetFullPath().c_str());
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ //Path limit
+ size_t Pos_Path=rfind(_T('\\'));
+ if (Pos_Path==Ztring::npos)
+ {
+ insert(0, 1, _T('\\')); //Not found
+ Pos_Path=0;
+ }
+ replace(0, Pos_Path, Path, 0, Ztring::npos);
+ #else
+ //Not supported
+ #endif
+ #endif //ZENLIB_USEWX
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+Ztring FileName::Name_Get() const
+{
+ #ifdef ZENLIB_USEWX
+ wxFileName FN(c_str());
+ if (FN==FN.GetName()) //Bug of WxWidgets? if C:\\dir\\(no name), name is C:\\dir\\(no name)
+ return Ztring();
+ return FN.GetName().c_str();
+ #else //ZENLIB_USEWX
+ size_t Pos_Path=rfind(FileName_PathSeparator); //Path limit
+ if (Pos_Path==Ztring::npos)
+ Pos_Path=0; //Not found
+ else
+ Pos_Path+=Ztring(FileName_PathSeparator).size(); //Path separator size
+ //Extension limit
+ size_t Pos_Ext=rfind(_T('.'));
+ if (Pos_Ext==Ztring::npos || Pos_Ext<Pos_Path)
+ Pos_Ext=size(); //Not found
+ return Ztring(*this, Pos_Path, Pos_Ext-Pos_Path);
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+Ztring& FileName::Name_Set(const Ztring &Name)
+{
+ #ifdef ZENLIB_USEWX
+ wxFileName FN(c_str());
+ if (FN==FN.GetName()) //Bug of WxWidgets? if C:\\dir\\(no name), name is C:\\dir\\(no name)
+ FN.SetPath(c_str());
+ FN.SetName(Name.c_str());
+ assign ((FN.GetFullPath()+FN.GetPathSeparator()/*FileName_PathSeparator*/+FN.GetFullName()).c_str());
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ //Path limit
+ size_t Pos_Path=rfind(_T('\\'));
+ if (Pos_Path==Ztring::npos)
+ Pos_Path=0; //Not found
+ //Extension limit
+ size_t Pos_Ext=rfind(_T('.'));
+ if (Pos_Ext==Ztring::npos || Pos_Ext<Pos_Path)
+ Pos_Ext=size(); //Not found
+ replace(Pos_Path+1, Pos_Ext-Pos_Path-1, Name, 0, Ztring::npos);
+ #else
+ //Not supported
+ #endif
+ #endif //ZENLIB_USEWX
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+Ztring FileName::Extension_Get() const
+{
+ #ifdef ZENLIB_USEWX
+ wxFileName FN(c_str());
+ return FN.GetExt().c_str();
+ #else //ZENLIB_USEWX
+ //Path limit
+ size_t Pos_Path=rfind(FileName_PathSeparator);
+ if (Pos_Path==Ztring::npos)
+ Pos_Path=0; //Not found
+ //Extension limit
+ size_t Pos_Ext=rfind(_T('.'));
+ if (Pos_Ext==Ztring::npos || Pos_Ext<Pos_Path)
+ return Ztring(); //Not found
+ else
+ return Ztring(*this, Pos_Ext+1, size()-Pos_Ext-1);
+ #endif //ZENLIB_USEWX
+}
+
+//---------------------------------------------------------------------------
+Ztring& FileName::Extension_Set(const Ztring &Extension)
+{
+ #ifdef ZENLIB_USEWX
+ wxFileName FN(c_str());
+ FN.SetExt(Extension.c_str());
+ assign (FN.GetFullPath().c_str());
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ //Path limit
+ size_t Pos_Path=rfind(_T('\\'));
+ if (Pos_Path==Ztring::npos)
+ Pos_Path=0; //Not found
+ //Extension limit
+ size_t Pos_Ext=rfind(_T('.'));
+ if (Pos_Ext==Ztring::npos || Pos_Ext<Pos_Path)
+ {
+ append(1, _T('.')); //Not found
+ Pos_Ext=size()-1;
+ }
+ replace(Pos_Ext+1, size()-Pos_Ext-1, Extension, 0, Ztring::npos);
+ #else
+ //Not supported
+ #endif
+ #endif //ZENLIB_USEWX
+ return *this;
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Ztring FileName::TempFileName_Create(const Ztring &Prefix)
+{
+ #ifdef ZENLIB_USEWX
+ return wxFileName::CreateTempFileName(Prefix.c_str()).c_str();
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ Char Path[MAX_PATH+1];
+ if (!GetTempPath(MAX_PATH, Path))
+ return Ztring(); //Problem while getting a temp path
+
+ Char FileName[MAX_PATH+1];
+ if (!GetTempFileName(Path, Prefix.c_str(), 0, FileName))
+ return Ztring(); //Problem while getting a file name
+
+ return Ztring(FileName);
+ #else
+ return _T("C:\\xxx.txt");
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//***************************************************************************
+// Platform differences
+//***************************************************************************
+
+//End of line
+#ifdef __WINDOWS__
+ const Char* FileName_PathSeparator=_T("\\");
+#endif
+#ifdef UNIX
+ const Char* FileName_PathSeparator=_T("/");
+#endif
+#ifdef MACOS
+ const Char* FileName_PathSeparator=_T("/");
+#endif
+#ifdef MACOSX
+ const Char* FileName_PathSeparator=_T("/");
+#endif
+
+} //namespace
+
diff --git a/src/thirdparty/ZenLib/ZenLib/FileName.h b/src/thirdparty/ZenLib/ZenLib/FileName.h
new file mode 100644
index 000000000..58d2a2aed
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/FileName.h
@@ -0,0 +1,81 @@
+// ZenLib::FileName - FileName functions
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// File name related functions
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_FileNameH
+#define ZenLib_FileNameH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+#include "ZenLib/Ztring.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+/// @brief File name manipulation
+//***************************************************************************
+
+class FileName : public ZenLib::Ztring
+{
+public :
+ //Constructor/Destructor
+ FileName () : Ztring(){};
+ FileName (const tstring& str) : Ztring(str){};
+ FileName (const tstring& str, size_type pos, size_type n=npos) : Ztring(str, pos, n){};
+ FileName (const Char* s, size_type n) : Ztring(s, n){};
+ FileName (const Char* s) : Ztring(s){};
+ FileName (size_type n, char c) : Ztring(n, c){};
+
+ //Read/Write
+ ZenLib::Ztring Path_Get () const;
+ ZenLib::Ztring Name_Get () const;
+ ZenLib::Ztring Extension_Get () const;
+ ZenLib::Ztring& Path_Set (const Ztring &Path);
+ ZenLib::Ztring& Name_Set (const Ztring &Name);
+ ZenLib::Ztring& Extension_Set (const Ztring &Extension);
+
+ //Helpers
+ static ZenLib::Ztring Path_Get (const Ztring &File_Name) {return ((FileName&)File_Name).Path_Get();};
+ static ZenLib::Ztring Name_Get (const Ztring &File_Name) {return ((FileName&)File_Name).Name_Get();};
+ static ZenLib::Ztring Extension_Get (const Ztring &File_Name) {return ((FileName&)File_Name).Extension_Get();};
+ static ZenLib::Ztring TempFileName_Create (const Ztring &Prefix);
+};
+
+//Platform differences
+extern const Char* FileName_PathSeparator;
+
+} //NameSpace
+
+//---------------------------------------------------------------------------
+#ifdef __BORLANDC__
+ #pragma warn .8027
+#endif
+//---------------------------------------------------------------------------
+
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Handler.cpp b/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Handler.cpp
new file mode 100644
index 000000000..641f430b2
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Handler.cpp
@@ -0,0 +1,71 @@
+// ZenLib::Format::Html::Handler - A HTML Handler
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Format/Html/Html_Handler.h"
+#include "ZenLib/Ztring.h"
+#include <sstream>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Html
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Handler::Handler()
+{
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+void Handler::CleanUp()
+{
+}
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Handler.h b/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Handler.h
new file mode 100644
index 000000000..284597a8e
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Handler.h
@@ -0,0 +1,91 @@
+// ZenLib::Format::Html::Handler - A HTML Handler
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// A HTML Handler
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_Server_Html_HandlerH
+#define ZenLib_Server_Html_HandlerH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include <string>
+#include <ctime>
+#include <map>
+#include <vector>
+#include "ZenLib/Ztring.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Html
+{
+
+//***************************************************************************
+/// @brief
+//***************************************************************************
+
+struct header
+{
+ //In
+ Ztring Title;
+ Ztring Language;
+
+ //Init
+ header()
+ {
+ }
+};
+
+class Handler
+{
+public:
+ //Constructor/Destructor
+ Handler();
+
+ //Maintenance
+ void CleanUp();
+
+ //The data
+ header Header;
+};
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
+
+#define ENDL "\r\n"
+#define HTML_ENDL "<br />\r\n"
+
+#endif
+
+
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Request.cpp b/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Request.cpp
new file mode 100644
index 000000000..27141acc3
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Request.cpp
@@ -0,0 +1,79 @@
+// ZenLib::Server::Html::Request - A HTML request
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Format/Html/Html_Request.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Html
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Request::Request()
+{
+ //Config
+ Html=new ZenLib::Format::Html::Handler;
+ IsCopy=false;
+}
+
+//---------------------------------------------------------------------------
+Request::Request(const Request &Req)
+{
+ //Config
+ Html=Req.Html;
+ IsCopy=true;
+}
+
+//---------------------------------------------------------------------------
+Request::~Request()
+{
+ //Config
+ if (!IsCopy)
+ delete Html; //Html=NULL
+}
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Request.h b/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Request.h
new file mode 100644
index 000000000..79204993c
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Html/Html_Request.h
@@ -0,0 +1,77 @@
+// ZenLib::Format::Html::Request - A HTML request
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// A HTML Request
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_Server_Html_RequestH
+#define ZenLib_Server_Html_RequestH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Format/Html/Html_Handler.h"
+#include <string>
+#include <ctime>
+#include <map>
+#include <vector>
+//---------------------------------------------------------------------------
+
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Html
+{
+
+//***************************************************************************
+/// @brief
+//***************************************************************************
+
+class Request
+{
+public:
+ //Constructor/Destructor
+ Request();
+ Request(const Request &Req);
+ ~Request();
+
+ //The data
+ ZenLib::Format::Html::Handler *Html;
+ bool IsCopy;
+};
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
+
+#endif
+
+
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Cookies.cpp b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Cookies.cpp
new file mode 100644
index 000000000..a772586dd
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Cookies.cpp
@@ -0,0 +1,118 @@
+// ZenLib::Format::Http::Cookies - Cookies handling
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Format/Http/Http_Cookies.h"
+#include "ZenLib/Format/Http/Http_Utils.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Http
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Cookies::Cookies()
+{
+}
+
+//***************************************************************************
+// Helpers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+size_t Cookies::Set(const std::string &Name, const std::string &Value, std::time_t Expires, const std::string &Path, const std::string &Domain, bool Secure)
+{
+ //Name must not be empty
+ if (Name.empty())
+ return 1;
+
+ //Default values handling
+ if (Value.empty())
+ Expires=time(NULL)-365*24*60*60-1; //minus 1 year
+
+ //Default value
+ if (Expires==(time_t)-1)
+ Expires=time(NULL)+1*365*24*60*60; //+1 year
+
+ //Expires can be the count of seconds to handle instead of real time
+ if (Expires>=0 && Expires<3*365*24*60*60) //Les than year 1973, this is not a date, this is a time
+ Expires+=time(NULL);
+
+ //Registering
+ Cookie Data;
+ Data.Value=Value.empty()?std::string("Deleted"):URL_Encoded_Encode(Value); //If no value, we force a default value for having the cookie understable
+ Data.Expires=Expires;
+ Data.Path=URL_Encoded_Encode(Path.empty()?string("/"):Path);
+ Data.Domain=URL_Encoded_Encode(Domain);
+ Data.Secure=Secure;
+ (*this)[URL_Encoded_Encode(Name)]=Data;
+
+ return 0;
+}
+
+//---------------------------------------------------------------------------
+void Cookies::Create_Lines(std::ostream& Out)
+{
+ for (Cookies::iterator Cookie=begin(); Cookie!=end(); Cookie++)
+ {
+ Out << "Set-Cookie: " << Cookie->first << "=" << Cookie->second.Value;
+ if (Cookie->second.Expires!=(time_t)-1)
+ {
+ char Temp[200];
+ if (strftime(Temp, 200, "%a, %d-%b-%Y %H:%M:%S GMT", gmtime(&Cookie->second.Expires)))
+ Out << "; expires=" << Temp;
+ }
+ if (!Cookie->second.Path.empty())
+ {
+ Out << "; path=" << Cookie->second.Path;
+ }
+ Out << "\r\n";
+ }
+}
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Cookies.h b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Cookies.h
new file mode 100644
index 000000000..635c8e95c
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Cookies.h
@@ -0,0 +1,91 @@
+// ZenLib::Format::Http::Cookies - Cookies handling
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Cookies handling
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_Format_Http_CookiesH
+#define ZenLib_Format_Http_CookiesH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include <string>
+#include <ctime>
+#include <map>
+#include <sstream>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Http
+{
+
+//***************************************************************************
+/// @brief
+//***************************************************************************
+
+struct Cookie
+{
+ std::string Value;
+ std::time_t Expires;
+ std::string Path;
+ std::string Domain;
+ bool Secure;
+
+ Cookie()
+ {
+ Expires=0;
+ Secure=false;
+ }
+};
+
+extern std::string EmptyString; //Must not change
+
+class Cookies : public std::map<std::string, Cookie>
+{
+public :
+ //Constructor/Destructor
+ Cookies();
+
+ //Helpers
+ size_t Set(const std::string &Name, const std::string &Value=EmptyString, std::time_t Expires=(std::time_t)-1, const std::string &Path=EmptyString, const std::string &Domain=EmptyString, bool Secure=false);
+ Cookie &Get(const std::string &Name);
+ void Create_Lines(std::ostream& Out);
+};
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
+
+#endif
+
+
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Handler.cpp b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Handler.cpp
new file mode 100644
index 000000000..3e9de6d4d
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Handler.cpp
@@ -0,0 +1,70 @@
+// ZenLib::Format::Http::Handler - A HTTP Handler
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Format/Http/Http_Handler.h"
+#include "ZenLib/Ztring.h"
+#include <sstream>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Http
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Handler::Handler()
+{
+ //In
+ Foreign_Port=0;
+ Local_Port=0;
+ HeadersOnly=false;
+
+ //Out
+ Response_HTTP_Code=200;
+}
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Handler.h b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Handler.h
new file mode 100644
index 000000000..320f0362d
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Handler.h
@@ -0,0 +1,87 @@
+// ZenLib::Format::Http::Request - A HTTP request
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// A HTTP Request
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_Format_Http_RequestH
+#define ZenLib_Format_Http_RequestH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Format/Http/Http_Cookies.h"
+#include <string>
+#include <ctime>
+#include <map>
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Http
+{
+
+//***************************************************************************
+/// @brief
+//***************************************************************************
+
+class Handler
+{
+public:
+ //Constructor/Destructor
+ Handler();
+
+ //In
+ std::string Path; //The path being requested by this request
+ std::map<std::string, std::string> Request_Headers; //All the incoming HTTP headers from the client web browser.
+ std::map<std::string, std::string> Request_Cookies; //The set of cookies that came from the client along with this request
+ std::map<std::string, std::string> Request_Queries; //All the key/value pairs in the query string of this request
+ std::string Foreign_IP; //The foreign ip address for this request
+ std::string Local_IP; //The foreign port number for this request
+ unsigned short Foreign_Port; //The IP of the local interface this request is coming in on
+ unsigned short Local_Port; //The local port number this request is coming in on
+ bool HeadersOnly; //The request requests only the header
+
+ //Out
+ size_t Response_HTTP_Code; //HTTP code to be sent
+ std::map<std::string, std::string> Response_Headers; //Additional headers you wish to appear in the HTTP response to this request
+ Cookies Response_Cookies; //New cookies to pass back to the client along with the result of this request
+ std::string Response_Body; //To be displayed as the response to this request
+};
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
+
+#endif
+
+
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Request.cpp b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Request.cpp
new file mode 100644
index 000000000..40248eb90
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Request.cpp
@@ -0,0 +1,255 @@
+// ZenLib::Server::Http::Request - A HTTP request
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Format/Http/Http_Request.h"
+#include "ZenLib/Format/Http/Http_Utils.h"
+#include "ZenLib/Ztring.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Http
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Request::Request()
+{
+ //Config
+ Http=new ZenLib::Format::Http::Handler;
+ IsCopy=false;
+}
+
+//---------------------------------------------------------------------------
+Request::Request(const Request &Req)
+{
+ //Config
+ Http=Req.Http;
+ IsCopy=true;
+}
+
+//---------------------------------------------------------------------------
+Request::~Request()
+{
+ //Config
+ if (!IsCopy)
+ delete Http; //Http=NULL
+}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool Request::Http_Begin(std::istream &In, std::ostream &Out)
+{
+ //First line, "Method Path Norm"
+ //-Method
+ string Method;
+ In>>Method;
+ if (Method.size()==3 && Method[0]=='G' && Method[1]=='E' && Method[2]=='T')
+ ;
+ else if (Method.size()==4 && Method[0]=='P' && Method[1]=='O' && Method[2]=='S' && Method[3]=='T')
+ ;
+ else if (Method.size()==4 && Method[0]=='H' && Method[1]=='E' && Method[2]=='A' && Method[2]=='D')
+ Http->HeadersOnly=true;
+ else
+ {
+ Out << "HTTP/1.0 501\r\n";
+ Out << "\r\n";
+ return false; //Unknown request
+ }
+ //-Path
+ In>>Http->Path;
+ if (Http->Path.empty() || Http->Path[0]!='/')
+ {
+ Out << "HTTP/1.0 404\r\n";
+ Out << "\r\n";
+ return false; //Problem
+ }
+ if (Http->Path.find("%")!=string::npos)
+ Http->Path=Format::Http::URL_Encoded_Decode(Http->Path);
+ //-Norm
+ string Line;
+ getline(In, Line); //Drop the first line, no more needed
+
+ //Headers
+ do
+ {
+ //Getting the line
+ getline(In, Line);
+ if (!Line.empty() && Line[Line.size()-1]=='\r')
+ Line.resize(Line.size()-1); //Remove the \r
+
+ //Processing the line, form is "aaa: bbb"
+ if (!Line.empty())
+ {
+ string::size_type Separator_Pos=Line.find(':');
+ string::size_type Content_Begin=Line.find_first_not_of(' ', Separator_Pos+1);
+ if (Separator_Pos!=string::npos && Content_Begin!=string::npos)
+ {
+ string Command=Line.substr(0, Separator_Pos);
+ if (Command=="Cookie")
+ {
+ string Cookie=Line.substr(Separator_Pos+1, string::npos);
+ while (!Cookie.empty())
+ {
+ string::size_type Cookie_Pos=Cookie.rfind(';');
+ if (Cookie_Pos==string::npos)
+ Cookie_Pos=(string::size_type)-1;
+ string Line2=Cookie.substr(Cookie_Pos+1, string::npos);
+ TrimLeft(Line2, ' ');
+ if (Cookie_Pos!=(string::size_type)-1)
+ {
+ Cookie.resize(Cookie_Pos);
+ TrimLeft(Line2, ' ');
+ }
+ else
+ Cookie.clear();
+
+ string::size_type Separator_Pos2=Line2.find('=');
+ if (Separator_Pos2!=string::npos)
+ Http->Request_Cookies[Line2.substr(0, Separator_Pos2)]=Format::Http::URL_Encoded_Decode(Line2.substr(Separator_Pos2+1, string::npos));
+ }
+ }
+ else
+ Http->Request_Headers[Command]=Line.substr(Content_Begin, string::npos);
+ }
+ }
+ }
+ while (!Line.empty());
+
+ //Info
+ if ((Method.size()==3 && Method[0]=='G' && Method[1]=='E' && Method[2]=='T')
+ || (Method.size()==4 && Method[0]=='P' && Method[1]=='O' && Method[2]=='S' && Method[3]=='T'))
+ {
+ do
+ {
+ string Content;
+
+ //Getting the line
+ string::size_type Interogation_Pos=Http->Path.find('?');
+ if (Interogation_Pos!=string::npos)
+ {
+ Content=Http->Path.substr(Interogation_Pos+1, string::npos);
+ Http->Path.resize(Interogation_Pos);
+ }
+
+ if (Method.size()==4) //Only for POST
+ {
+ int64u Content_Lengh=0;
+ std::map<std::string, std::string>::iterator Header_Content_Lengh_Element=Http->Request_Headers.find("Content-Length");
+ if (Header_Content_Lengh_Element==Http->Request_Headers.end())
+ Header_Content_Lengh_Element=Http->Request_Headers.find("Content-length");
+ if (Header_Content_Lengh_Element!=Http->Request_Headers.end())
+ #ifdef UNICODE
+ Content_Lengh=Ztring().From_UTF8(Header_Content_Lengh_Element->second).To_int64u();
+ #else
+ Content_Lengh=Ztring(Header_Content_Lengh_Element->second).To_int64u();
+ #endif
+ if (Content_Lengh>1024) //Verifying there is no big element
+ {
+ Out << "HTTP/1.0 501\r\n";
+ Out << "\r\n";
+ return false; //Malformed request
+ }
+
+ size_t Content_Size_Current=Content.size();
+ if (Content_Size_Current)
+ {
+ Content+='&';
+ Content_Size_Current++;
+ }
+ Content.resize(Content_Size_Current+(size_t)Content_Lengh+1);
+ In.read(&Content[Content_Size_Current], (streamsize)Content_Lengh);
+ Content[Content_Size_Current+(size_t)Content_Lengh]='\0';
+ }
+
+ //Processing the line, form is "aaa=bbb&..."
+ while (!Content.empty())
+ {
+ string::size_type Content_Pos=Content.rfind('&');
+ if (Content_Pos==string::npos)
+ Content_Pos=(string::size_type)-1;
+ std::string Line2=Content.substr(Content_Pos+1, string::npos);
+ if (Content_Pos!=(string::size_type)-1)
+ Content.resize(Content_Pos);
+ else
+ Content.clear();
+
+ string::size_type Separator_Pos=Line2.find('=');
+ if (Separator_Pos!=string::npos)
+ Http->Request_Queries[Line2.substr(0, Separator_Pos)]=Format::Http::URL_Encoded_Decode(Line2.substr(Separator_Pos+1, string::npos));
+ }
+ }
+ while (!Line.empty());
+ }
+
+ return true;
+}
+
+void Request::Http_End(std::ostream &Out)
+{
+ Out << "HTTP/1.0 "<< Http->Response_HTTP_Code << "\r\n";
+ for (std::map<std::string, std::string>::iterator Temp=Http->Response_Headers.begin(); Temp!=Http->Response_Headers.end(); Temp++)
+ Out << Temp->first << ": " << Temp->second << "\r\n";
+ Http->Response_Cookies.Create_Lines(Out);
+ std::map<std::string, std::string>::iterator Content_Type_Element=Http->Response_Headers.find("Content-Type");
+ if (Content_Type_Element!=Http->Response_Headers.end())
+ Out << "Content-Type: "<< Content_Type_Element->second << "\r\n";
+ else if (Http->Response_HTTP_Code==200)
+ {
+ if (!Http->Response_Body.empty() && Http->Response_Body[0]=='<')
+ Out << "Content-Type: "<< "text/html; charset=utf-8" << "\r\n";
+ }
+ if (!Http->Response_Body.empty())
+ Out << "Content-Length: " << Http->Response_Body.size() << "\r\n";
+ Out << "\r\n";
+ if (!Http->HeadersOnly && !Http->Response_Body.empty())
+ Out << Http->Response_Body.c_str();
+}
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Request.h b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Request.h
new file mode 100644
index 000000000..fa8fdd750
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Request.h
@@ -0,0 +1,81 @@
+// ZenLib::Format::Http::Request - A HTTP request
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// A HTTP Request
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_Server_Http_RequestH
+#define ZenLib_Server_Http_RequestH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Format/Http/Http_Handler.h"
+#include <string>
+#include <ctime>
+#include <map>
+#include <vector>
+//---------------------------------------------------------------------------
+
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Http
+{
+
+//***************************************************************************
+/// @brief
+//***************************************************************************
+
+class Request
+{
+public:
+ //Constructor/Destructor
+ Request();
+ Request(const Request &Req);
+ ~Request();
+
+ //The data
+ ZenLib::Format::Http::Handler *Http;
+ bool IsCopy;
+
+ //Helpers
+ bool Http_Begin(std::istream &In, std::ostream &Out);
+ void Http_End (std::ostream &Out);
+};
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
+
+#endif
+
+
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Utils.cpp b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Utils.cpp
new file mode 100644
index 000000000..919faac49
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Utils.cpp
@@ -0,0 +1,251 @@
+// ZenLib::Server::Http::Utils - Utils for HTTP handling
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Format/Http/Http_Utils.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Http
+{
+
+//***************************************************************************
+// Global variables
+//***************************************************************************
+
+std::string EmptyString;
+
+//***************************************************************************
+// Character manipulation
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+unsigned char Char2Hex (unsigned char Char)
+{
+ if (Char<='9' && Char>='0')
+ Char-='0';
+ else if (Char<='f' && Char>='a')
+ Char-='a'-10;
+ else if (Char<='F' && Char>='A')
+ Char-='A'-10;
+ else
+ Char =0;
+ return Char;
+}
+
+//---------------------------------------------------------------------------
+wchar_t Char2Hex (wchar_t Char)
+{
+ if (Char<='9' && Char>='0')
+ Char-='0';
+ else if (Char<='f' && Char>='a')
+ Char-='a'-10;
+ else if (Char<='F' && Char>='A')
+ Char-='A'-10;
+ else
+ Char =0;
+ return Char;
+}
+
+//---------------------------------------------------------------------------
+string Hex2Char (unsigned char Char)
+{
+ string Result;
+ Result+=(char)((Char/16>=10?'a'-10:'0')+Char/16);
+ Result+=(char)((Char%16>=10?'a'-10:'0')+Char%16);
+ return Result;
+}
+
+//---------------------------------------------------------------------------
+wstring Hex2Char (wchar_t Char)
+{
+ wstring Result;
+ Result+=(Char/16>=10?'a'-10:'0')+Char/16;
+ Result+=(Char%16>=10?'a'-10:'0')+Char%16;
+ return Result;
+}
+
+//***************************************************************************
+// URL manipulation
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+std::string URL_Encoded_Encode (const std::string& URL)
+{
+ string Result;
+ string::size_type Pos;
+ for (Pos=0; Pos<URL.size(); Pos++)
+ {
+ if ((URL[Pos]>='\x00' && URL[Pos]<='\x20')
+ || URL[Pos]=='\x7F'
+ || URL[Pos]==' '
+ || URL[Pos]=='<'
+ || URL[Pos]=='>'
+ || URL[Pos]=='#'
+ || URL[Pos]=='%'
+ || URL[Pos]=='\"'
+ || URL[Pos]=='{'
+ || URL[Pos]=='}'
+ || URL[Pos]=='|'
+ || URL[Pos]=='\\'
+ || URL[Pos]=='^'
+ || URL[Pos]=='['
+ || URL[Pos]==']'
+ || URL[Pos]=='`'
+ /*|| URL[Pos]==';'
+ || URL[Pos]=='/'
+ || URL[Pos]=='?'
+ || URL[Pos]==':'
+ || URL[Pos]=='@'
+ || URL[Pos]=='&'
+ || URL[Pos]=='='
+ || URL[Pos]=='+'
+ || URL[Pos]=='$'
+ || URL[Pos]==','*/)
+ Result+='%'+Hex2Char((unsigned char)URL[Pos]);
+ else
+ Result+=URL[Pos];
+ }
+ return Result;
+}
+
+//---------------------------------------------------------------------------
+std::wstring URL_Encoded_Encode (const std::wstring& URL)
+{
+ wstring Result;
+ wstring::size_type Pos;
+ for (Pos=0; Pos<URL.size(); Pos++)
+ {
+ if (URL[Pos]<=L'\x20'
+ || URL[Pos]==L'\x7F'
+ || URL[Pos]==L' '
+ || URL[Pos]==L'<'
+ || URL[Pos]==L'>'
+ || URL[Pos]==L'#'
+ || URL[Pos]==L'%'
+ || URL[Pos]==L'\"'
+ || URL[Pos]==L'{'
+ || URL[Pos]==L'}'
+ || URL[Pos]==L'|'
+ || URL[Pos]==L'\\'
+ || URL[Pos]==L'^'
+ || URL[Pos]==L'['
+ || URL[Pos]==L']'
+ || URL[Pos]==L'`'
+ /*|| URL[Pos]==L';'
+ || URL[Pos]==L'/'
+ || URL[Pos]==L'?'
+ || URL[Pos]==L':'
+ || URL[Pos]==L'@'
+ || URL[Pos]==L'&'
+ || URL[Pos]==L'=L'
+ || URL[Pos]==L'+'
+ || URL[Pos]==L'$'
+ || URL[Pos]==L','*/)
+ Result+=L'%'+Hex2Char(URL[Pos]);
+ else
+ Result+=URL[Pos];
+ }
+ return Result;
+}
+
+//---------------------------------------------------------------------------
+std::string URL_Encoded_Decode (const std::string& URL)
+{
+ string Result;
+ string::size_type Pos;
+ for (Pos=0; Pos<URL.size(); Pos++)
+ {
+ if (URL[Pos]=='%' && Pos+2<URL.size()) //At least 3 chars
+ {
+ const unsigned char Char1 = Char2Hex((unsigned char)URL[Pos+1]);
+ const unsigned char Char2 = Char2Hex((unsigned char)URL[Pos+2]);
+ const unsigned char Char = (Char1<<4) | Char2;
+ Result+=Char;
+ Pos+=2; //3 chars are used
+ }
+ else if (URL[Pos]=='+')
+ Result+=' ';
+ else
+ Result+=URL[Pos];
+ }
+ return Result;
+}
+
+//---------------------------------------------------------------------------
+std::wstring URL_Encoded_Decode (const std::wstring& URL)
+{
+ wstring Result;
+ wstring::size_type Pos;
+ for (Pos=0; Pos<URL.size(); Pos++)
+ {
+ if (URL[Pos]==L'%' && Pos+2<URL.size()) //At least 3 chars
+ {
+ const wchar_t Char1 = Char2Hex(URL[Pos+1]);
+ const wchar_t Char2 = Char2Hex(URL[Pos+2]);
+ const wchar_t Char = (Char1<<4) | Char2;
+ Result+=Char;
+ Pos+=2; //3 chars are used
+ }
+ else if (URL[Pos]==L'+')
+ Result+=L' ';
+ else
+ Result+=URL[Pos];
+ }
+ return Result;
+}
+
+//***************************************************************************
+// Cleanup
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void TrimLeft (std::string& String, char ToTrim)
+{
+ string::size_type First=0;
+ while (String.operator[](First)==ToTrim)
+ First++;
+ String.assign (String.c_str()+First);
+}
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
diff --git a/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Utils.h b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Utils.h
new file mode 100644
index 000000000..17b84f5fd
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Format/Http/Http_Utils.h
@@ -0,0 +1,80 @@
+// ZenLib::Format::Http::Utils - Utils for HTTP handling
+// Copyright (C) 2008-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// HTTP utils
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_Server_Http_UtilsH
+#define ZenLib_Server_Http_UtilsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include <string>
+#include <ctime>
+#include <map>
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+namespace Format
+{
+
+namespace Http
+{
+
+//***************************************************************************
+//
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Character manipulation
+unsigned char Char2Hex (unsigned char Char);
+wchar_t Char2Hex (wchar_t Char);
+std::string Hex2Char (unsigned char Char);
+std::wstring Hex2Char (wchar_t Char);
+
+//---------------------------------------------------------------------------
+// URL manipulation
+std::string URL_Encoded_Encode (const std::string& URL);
+std::wstring URL_Encoded_Encode (const std::wstring& URL);
+std::string URL_Encoded_Decode (const std::string& URL);
+std::wstring URL_Encoded_Decode (const std::wstring& URL);
+
+//---------------------------------------------------------------------------
+// Cleanup
+void TrimLeft (std::string& String, char ToTrim);
+
+} //Namespace
+
+} //Namespace
+
+} //Namespace
+
+#endif //ZENLIB_SERVER_HTTP_UTILS
+
+
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/HTTP_Client.cpp b/src/thirdparty/ZenLib/ZenLib/HTTP_Client.cpp
new file mode 100644
index 000000000..3942ee631
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/HTTP_Client.cpp
@@ -0,0 +1,140 @@
+// ZenLib::HTTPClient - Basic HTTP client
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/HTTP_Client.h"
+#ifdef WINDOWS
+ #undef __TEXT
+ #include <windows.h>
+#endif //WINDOWS
+#include "ZenLib/HTTP_Client/HTTPClient.h"
+using namespace ZenLib;
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+HTTP_Client::HTTP_Client ()
+{
+ #ifdef WINDOWS
+ WSADATA WsaData;
+ WSAStartup(MAKEWORD(1, 2), &WsaData);
+ #endif
+ Handle=0;
+}
+
+//---------------------------------------------------------------------------
+HTTP_Client::~HTTP_Client ()
+{
+ #ifdef WINDOWS
+ WSACleanup();
+ #endif
+}
+
+//***************************************************************************
+// Open/Close
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+int HTTP_Client::Open (Ztring Url)
+{
+ if (Handle)
+ Close();
+
+ //init
+ Handle=HTTPClientOpenRequest(0);
+
+ //Mehtod
+ if (HTTPClientSetVerb(Handle, VerbGet)!=0)
+ {
+ Close();
+ return 0;
+ }
+
+ //Send request
+ if (HTTPClientSendRequest(Handle, (char*)(Url.To_Local().c_str()), NULL, 0, FALSE, 0, 0)!=0)
+ {
+ Close();
+ return 0;
+ }
+
+ //Receive response
+ if (HTTPClientRecvResponse(Handle, 3)!=0)
+ {
+ Close();
+ return 0;
+ }
+
+ return 1;
+}
+
+//---------------------------------------------------------------------------
+void HTTP_Client::Close ()
+{
+ HTTPClientCloseRequest(&Handle);
+ Handle=0;
+}
+
+//***************************************************************************
+// Read
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Ztring HTTP_Client::Read ()
+{
+ if (Handle==0)
+ return Ztring();
+
+ char* Buffer=new char[16384];
+ int32u Size=0;
+
+ int32u ReturnValue=HTTPClientReadData(Handle, Buffer, 16384, 0, &Size);
+ if (ReturnValue!=0 && ReturnValue!=1000) //End of stream
+ {
+ Close();
+ delete[] Buffer;
+ return Ztring();
+ }
+
+ Ztring ToReturn; ToReturn.From_Local(Buffer, Size);
+ delete[] Buffer;
+ return ToReturn;
+}
+
+} //namespace
+
diff --git a/src/thirdparty/ZenLib/ZenLib/HTTP_Client.h b/src/thirdparty/ZenLib/ZenLib/HTTP_Client.h
new file mode 100644
index 000000000..316ce01c6
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/HTTP_Client.h
@@ -0,0 +1,64 @@
+// ZenLib::HTTPClient - Basic HTTP client
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Basic HTTP client
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_HTTPClientH
+#define ZenLib_HTTPClientH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+#include "ZenLib/Ztring.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+/// @brief Basic HTTP client
+//***************************************************************************
+
+class HTTP_Client
+{
+public :
+ //Constructor/Destructor
+ HTTP_Client ();
+ ~HTTP_Client ();
+
+ //Open/Close
+ int Open (Ztring URL);
+ void Close ();
+
+ //Read
+ Ztring Read();
+
+private :
+ int32u Handle;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClient.c b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClient.c
new file mode 100644
index 000000000..0f5900947
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClient.c
@@ -0,0 +1,3646 @@
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Module Name:
+// HTTPClient.c
+//
+// Abstract: Partially Implements the client side of the HTTP 1.1 Protocol as
+// Defined in RFC 2616,2617
+// Platform: Any that supports standard C calls and Berkeley sockets
+//
+// Author: Eitan Michaelson
+// Version: 1.0
+// Date 7/1/2006
+// Opens: HTTP Proxy authentication support (not fully tested).
+// HTTP Keep Alive not impliamented
+// HTTPS not implemented
+// The HTTP counters are not 100% correct (will be fixed)
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include "HTTPClient.h"
+#include "HTTPClientAuth.h" // Crypto support (Digest, MD5)
+#include "HTTPClientString.h" // String utilities
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientSetLocalConnection
+// Purpose : TBD
+// Gets :
+// Returns :
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientSetLocalConnection (HTTP_SESSION_HANDLE pSession, UINT32 nPort)
+{
+
+ return 0;
+}
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientOpenRequest
+// Purpose : Allocate memory for a new HTTP Session
+// Gets : FLAGS
+// Returns : HTTP Session handle
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+HTTP_SESSION_HANDLE HTTPClientOpenRequest (HTTP_CLIENT_SESSION_FLAGS Flags)
+{
+
+ P_HTTP_SESSION pHTTPSession = NULL; // Handle to the session pointer
+ UINT32 nAllocationSize; // Size of the dynamically allocated buffer
+
+ // Attempt to allocate the buffer
+ pHTTPSession = (P_HTTP_SESSION)malloc(ALIGN(sizeof(HTTP_SESSION)));
+
+ // Did we succeed?
+ if(!pHTTPSession)
+ {
+ // Null pointer is returned upon error
+ return 0;
+ }
+ // Reset the allocated space to zeros
+ memset(pHTTPSession,0x00,sizeof(HTTP_SESSION));
+
+ // Allocate space for the incoming and outgoing headers
+ // Check if the headers buffer is resizable
+ if(HTTP_CLIENT_MEMORY_RESIZABLE)
+ {
+ // Memory is resizable, so use the init defined size or the maximum buffer size (which ever is smaller)
+ nAllocationSize = MIN(HTTP_CLIENT_MAX_SEND_RECV_HEADERS,HTTP_CLIENT_INIT_SEND_RECV_HEADERS);
+
+ }
+ else
+ {
+ // Memory is not resizable so simply use the maximum defined size
+ nAllocationSize = HTTP_CLIENT_MAX_SEND_RECV_HEADERS;
+ }
+ // Allocate the headers buffer
+ pHTTPSession->HttpHeaders.HeadersBuffer.pParam = (CHAR*)malloc(ALIGN(nAllocationSize));
+ // Check the returned pointer
+ if(!pHTTPSession->HttpHeaders.HeadersBuffer.pParam)
+ {
+ // malloc() error, free the containing structure and exit.
+ free(pHTTPSession);
+ return 0;
+
+ }
+
+ // Reset the headers allocated memory
+ memset(pHTTPSession->HttpHeaders.HeadersBuffer.pParam ,0x00,nAllocationSize);
+ // Set the buffer length
+ pHTTPSession->HttpHeaders.HeadersBuffer.nLength = nAllocationSize;
+
+ // Set default values in the session structure
+ HTTPClientSetVerb((UINT32)pHTTPSession,(HTTP_VERB)HTTP_CLIENT_DEFAULT_VERB); // Default HTTP verb
+ pHTTPSession->HttpUrl.nPort = HTTP_CLIENT_DEFAULT_PORT; // Default TCP port
+ pHTTPSession->HttpConnection.HttpSocket = HTTP_INVALID_SOCKET; // Invalidate the socket
+ // Set the outgoing headers pointers
+ pHTTPSession->HttpHeaders.HeadersOut.pParam = pHTTPSession->HttpHeaders.HeadersBuffer.pParam;
+ // Set our state
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_INIT;
+
+ // Save the flags
+ pHTTPSession->HttpFlags = Flags;
+
+ // Reset the status
+ pHTTPSession->HttpHeadersInfo.nHTTPStatus = 0;
+ // Return an allocated session pointer (cast to UINT32 first)
+ return (HTTP_SESSION_HANDLE)pHTTPSession;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientReset
+// Purpose : Reset the HTTP session and make it ready for another call
+// Gets : FLAGS
+// Returns : HTTP Session handle
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientReset (HTTP_SESSION_HANDLE pSession)
+{
+
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ return HTTPIntrnSessionReset(pHTTPSession,TRUE);
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Function : HTTPClientCloseRequest
+// Purpose : Closes any active connection and free any used memory
+// Gets : a Session handle
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientCloseRequest (HTTP_SESSION_HANDLE *pSession)
+{
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)*(pSession);
+ if(!pHTTPSession)
+ {
+ // User passed a bad pointer
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ // Check for a valid pointer to the HTTP headers
+ if(pHTTPSession->HttpHeaders.HeadersBuffer.pParam)
+ {
+ // Release the used memory
+ free(pHTTPSession->HttpHeaders.HeadersBuffer.pParam);
+ }
+ // Close any active socket connection
+ HTTPIntrnConnectionClose(pHTTPSession);
+ // free the session structure
+ free(pHTTPSession);
+
+ pHTTPSession = 0; // NULL the pointer
+ *(pSession) = 0;
+
+ return HTTP_CLIENT_SUCCESS;
+}
+
+#ifdef _HTTP_DEBUGGING_
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientSetDebugHook
+// Purpose : Sets the HTTP debug function pointer
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientSetDebugHook (HTTP_SESSION_HANDLE pSession,
+ E_HTTPDebug *pDebug) // [IN] Function pointer to the the caller debugging function)
+{
+
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ pHTTPSession->pDebug = pDebug;
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPClientSetDebugHook",NULL,0,"Debugging hook set, return code is %d",HTTP_CLIENT_SUCCESS);
+ }
+#endif
+
+
+ return HTTP_CLIENT_SUCCESS;
+}
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientSetVerb
+// Purpose : Sets the HTTP verb for the outgoing request
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientSetVerb (HTTP_SESSION_HANDLE pSession,
+ HTTP_VERB HttpVerb) // [IN] Http verb (GET POST HEAD act')
+{
+
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPClientSetVerb",NULL,0,"Selected Verb is %d",(INT32)HttpVerb);
+ }
+#endif
+
+ // Cache the verb (as integer) for later use
+ pHTTPSession->HttpHeaders.HttpVerb = HttpVerb;
+
+ // Convert the Verb parameter into its equivalent string representation
+ switch (HttpVerb)
+ {
+ case VerbGet:
+ strcpy(pHTTPSession->HttpHeaders.Verb,"GET");
+ break;
+ case VerbHead:
+ if(!HTTP_CLIENT_ALLOW_HEAD_VERB)
+ {
+ return HTTP_CLIENT_ERROR_BAD_VERB;
+ }
+ strcpy(pHTTPSession->HttpHeaders.Verb,"HEAD");
+ break;
+ case VerbPost:
+ strcpy(pHTTPSession->HttpHeaders.Verb,"POST");
+ break;
+ default:
+ // Unknown verb
+ return HTTP_CLIENT_ERROR_BAD_VERB;
+ };
+
+ return HTTP_CLIENT_SUCCESS;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientSetVerb
+// Purpose : Sets the HTTP authentication schema
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientSetAuth (HTTP_SESSION_HANDLE pSession,
+ HTTP_AUTH_SCHEMA AuthSchema, // The type of the authentication to perform
+ void *pReserved)
+{
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPClientSetAuth",NULL,0,"Selected authentication is %d",(INT32)AuthSchema);
+ }
+#endif
+
+ switch(AuthSchema)
+ {
+ case(AuthSchemaBasic):
+ strcpy(pHTTPSession->HttpCredentials.AuthSchemaName,"basic");
+ break;
+ case(AuthSchemaDigest):
+ strcpy(pHTTPSession->HttpCredentials.AuthSchemaName,"digest");
+ break;
+ case(AuthSchemaKerberos):
+ strcpy(pHTTPSession->HttpCredentials.AuthSchemaName,"negotiate");
+ break;
+ };
+
+ if(AuthSchema >= AuthNotSupported)
+ {
+ return HTTP_CLIENT_ERROR_BAD_AUTH;
+ }
+
+ pHTTPSession->HttpCredentials.CredAuthSchema = AuthSchema;
+ return HTTP_CLIENT_SUCCESS;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientSetProxy
+// Purpose : Sets all the proxy related parameters
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientSetProxy (HTTP_SESSION_HANDLE pSession,
+ CHAR *pProxyHost, // [IN] Null terminated string containing the host name
+ UINT16 nPort, // [IN] The proxy port number
+ CHAR *pUserName, // [IN] User name for proxy authentication (can be null)
+ CHAR *pPassword) // [IN] User password for proxy authentication (can be null)
+{
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPClientSetProxy",NULL,0,"Proxy host %s,Port %d, Username %s,Password %s",pProxyHost,nPort,pUserName,pPassword);
+ }
+#endif
+
+
+ // Cache the user supplied information in the internal session structure
+ strncpy(pHTTPSession->HttpProxy.ProxyHost,pProxyHost,HTTP_CLIENT_MAX_PROXY_HOST_LENGTH);
+ if(pUserName)
+ {
+ // Proxy user name (for Proxy server authentication)
+ strncpy(pHTTPSession->HttpProxy.ProxtUser,pUserName,HTTP_CLIENT_MAX_USERNAME_LENGTH);
+ }
+ if(pPassword)
+ {
+ // Proxy password (for proxy server authentication)
+ strncpy(pHTTPSession->HttpProxy.ProxyPassword,pPassword,HTTP_CLIENT_MAX_PASSWORD_LENGTH);
+ }
+ // Proxy TCP port
+ pHTTPSession->HttpProxy.nProxyPort = nPort;
+ // Set the Proxy flag in the connection structure
+ pHTTPSession->HttpFlags = pHTTPSession->HttpFlags | HTTP_CLIENT_FLAG_USINGPROXY;
+ // Set the proxy auyjentication schema
+ if(pPassword && pUserName)
+ {
+ pHTTPSession->HttpProxy.ProxyAuthSchema = HTTP_CLIENT_DEFAULT_PROXY_AUTH;
+ }
+ return HTTP_CLIENT_SUCCESS;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientSetCredentials
+// Purpose : Sets credentials for the target host
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientSetCredentials (HTTP_SESSION_HANDLE pSession,
+ CHAR *pUserName, // [IN] Null terminated string containing the sessions user name
+ CHAR *pPassword) // [IN] Null terminated string containing the sessions password
+{
+ UINT32 nLength;
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ // Get the length of the user name string and see if it's not too long
+ nLength = strlen(pUserName);
+ if(nLength > HTTP_CLIENT_MAX_USERNAME_LENGTH)
+ {
+ return HTTP_CLIENT_ERROR_LONG_INPUT;
+ }
+
+ // Get the length of the password string and see if it's not too long
+ nLength = strlen(pPassword);
+ if(nLength > HTTP_CLIENT_MAX_PASSWORD_LENGTH)
+ {
+ return HTTP_CLIENT_ERROR_LONG_INPUT;
+ }
+
+ // Copy them into our internal buffer
+ strcpy(pHTTPSession->HttpCredentials.CredUser ,pUserName);
+ strcpy(pHTTPSession->HttpCredentials.CredPassword ,pPassword);
+
+ // Set the authentication Boolean flag
+ pHTTPSession->HttpHeadersInfo.HaveCredentials = TRUE;
+
+ return HTTP_CLIENT_SUCCESS;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientAddRequestHeaders
+// Purpose : Add headers to the outgoing request
+// Gets :
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientAddRequestHeaders (HTTP_SESSION_HANDLE pSession,
+ CHAR *pHeaderName, // [IN] The Headers name
+ CHAR *pHeaderData, // [IN] The headers data
+ BOOL nInsert) // [IN] Reserved could be any
+{
+
+ UINT32 nRetCode;
+ UINT32 nHeaderLength,nDataLength;
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPClientAddRequestHeaders",NULL,0,"Adding Header %s: %s",pHeaderName,pHeaderData);
+ }
+#endif
+
+ // Get the elements length
+ nHeaderLength = strlen(pHeaderName);
+ nDataLength = strlen(pHeaderData);
+
+ // Call the internal function to add the headers to our session buffer
+ nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,pHeaderName,nHeaderLength,pHeaderData,nDataLength);
+
+ return nRetCode;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientSendRequest
+// Purpose : This function builds the request headers, performs a DNS resolution ,
+// opens the connection (if it was not opened yet by a previous request or if it has closed)
+// and sends the request headers.
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientSendRequest (HTTP_SESSION_HANDLE pSession,
+ CHAR *pUrl, // [IN] The requested URL
+ VOID *pData, // [IN] Data to post to the server
+ UINT32 nDataLength, // [IN] Length of posted data
+ BOOL TotalLength, // [IN]
+ UINT32 nTimeout, // [IN] Operation timeout
+ UINT32 nClientPort) // [IN] Client side port 0 for none
+{
+
+ UINT32 nRetCode; // Function call return code
+ UINT32 nBytes; // Bytes counter (socket operations)
+ UINT32 nUrlLength; // Length of the given Url
+ P_HTTP_SESSION pHTTPSession = NULL; // Session pointer
+ CHAR ContentLength[32];
+ CHAR *pPtr; // Content length (string conversion)
+ do
+ {
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPClientSendRequest",NULL,0,"Url: %s",pUrl);
+ }
+#endif
+
+ // Set the operation timeout counters
+ pHTTPSession->HttpCounters.nActionStartTime = HTTPIntrnSessionGetUpTime();
+ // 0 makes us use the default defined value
+ pHTTPSession->HttpCounters.nActionTimeout = HTTP_TIMEOUT(nTimeout);
+ // Store the cliebt port for later usage
+ pHTTPSession->HttpConnection.HttpClientPort = nClientPort;
+
+ // Parse the URL
+ nUrlLength = strlen(pUrl);
+ nRetCode = HTTPIntrnSetURL(pHTTPSession,pUrl,nUrlLength);
+ if(nRetCode != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+
+ // Create the default headers
+ // Add the "Host" header. we should handle a special case of port incorporated within the host name.
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_URLANDPORT) != HTTP_CLIENT_FLAG_URLANDPORT)
+ {
+ // The case where we don't have the port
+ if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,
+ "Host",4,
+ pHTTPSession->HttpUrl.UrlHost.pParam,
+ pHTTPSession->HttpUrl.UrlHost.nLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+ else
+ {
+ // We have the port so use a deferent element
+ if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Host",4,pHTTPSession->HttpUrl.UrlHost.pParam,
+ (pHTTPSession->HttpUrl.UrlPort.pParam - pHTTPSession->HttpUrl.UrlHost.pParam) -1 )) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+ // We are in a post request without knowing the total length in advance so return error or use chunking
+ if(pHTTPSession->HttpHeaders.HttpVerb == VerbPost && TotalLength == FALSE)
+ {
+ // If the user specified the chunked flag
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SEND_CHUNKED) == HTTP_CLIENT_FLAG_SEND_CHUNKED)
+ {
+ // Add the Transfer-Encoding: header
+ if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Transfer-Encoding",17,"chunked",7))!= HTTP_CLIENT_SUCCESS)
+ {
+ break;;
+ }
+ }
+ else
+ {
+ // Not a supported operation - unknown length
+ nRetCode = HTTP_CLIENT_ERROR_HEADER_NO_LENGTH;
+ break;
+ }
+ }
+
+ // Add the "User-Agent" header
+ if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"User-Agent",10,HTTP_CLIENT_DEFAULT_AGENT,strlen(HTTP_CLIENT_DEFAULT_AGENT)))!= HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Add the "Keep-Alive" header (if requested by the caller)
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_KEEP_ALIVE) == HTTP_CLIENT_FLAG_KEEP_ALIVE)
+ {
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_USINGPROXY) != HTTP_CLIENT_FLAG_USINGPROXY)
+ {
+ // No proxy keep alive:
+ if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Connection",10,"Keep-Alive",10))!= HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+ else // proxy keep alive
+ {
+ if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Proxy-Connection",15,"Keep-Alive",10))!= HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+ }
+
+ // If we know the total length in advance (only when posting)
+ if(pHTTPSession->HttpHeaders.HttpVerb == VerbPost && TotalLength == TRUE)
+ {
+ // set the total content length header
+ pHTTPSession->HttpHeadersInfo.nHTTPPostContentLength = nDataLength; // Store for later usage
+ memset(ContentLength,0,32);
+ pPtr = IToA(ContentLength,nDataLength); // Convert the buffer length to a string value
+ if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Content-Length",14,ContentLength,strlen(ContentLength)))!= HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+
+ // Add the "Cache control" header (if requested by the caller)
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_NO_CACHE) == HTTP_CLIENT_FLAG_NO_CACHE)
+ {
+ if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Cache-Control",13,"no-cache",8))!= HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+
+
+ // Now we can connect to the remote server and send the leading request followed by the HTTP headers
+ // Check for timeout
+ if(HTTPIntrnSessionEvalTimeout(pHTTPSession) == TRUE)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_TIME_OUT;
+ break;
+ }
+ // Handle connection close message (reconnect)
+ if(pHTTPSession->HttpHeadersInfo.Connection == FALSE)
+ {
+ // Gracefully close the connection and set the socket as invalid
+ if(pHTTPSession->HttpConnection.HttpSocket != HTTP_INVALID_SOCKET)
+ {
+ HTTPIntrnConnectionClose(pHTTPSession);
+ }
+ // Connect to the remote server (or proxy)
+ nRetCode = HTTPIntrnConnectionOpen(pHTTPSession);
+ if(nRetCode != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+
+ // Send the request along with the rest of the headers
+ if(pHTTPSession->HttpCredentials.CredAuthSchema != AuthSchemaNone ||
+ pHTTPSession->HttpProxy.ProxyAuthSchema != AuthSchemaNone) // If we have to authenticate we should use the HEAD verb
+ {
+ if(HTTP_CLIENT_ALLOW_HEAD_VERB) // HEAD should not be ussed if not defined
+ {
+ if((nRetCode = HTTPIntrnHeadersSend(pHTTPSession,VerbHead)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the state flag
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HEAD_SENT;
+ }
+ else
+ {
+ // Simply use the verb that was set by the caller without changing to HEAD
+ if((nRetCode = HTTPIntrnHeadersSend(pHTTPSession,pHTTPSession->HttpHeaders.HttpVerb)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // This the case where the caller know the total length to receive in advance
+ // and he wishes to send the data right away
+ if(pHTTPSession->HttpHeaders.HttpVerb == VerbPost && TotalLength == TRUE)
+ {
+
+ // Send the data
+ nBytes = nDataLength;
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,pData,&nBytes)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the session state
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_POST_SENT;
+ }
+
+ }
+
+ // Retrive and analyze the Headers
+ if((nRetCode = HTTPIntrnHeadersReceive(pHTTPSession,nTimeout)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ if(pHTTPSession->HttpHeadersInfo.nHTTPStatus != 401 && pHTTPSession->HttpHeadersInfo.nHTTPStatus != 407)
+ {
+
+ nRetCode = HTTP_CLIENT_ERROR_AUTH_MISMATCH;
+ break;
+ }
+ // Authenticate
+ if((nRetCode = HTTPIntrnAuthenticate(pHTTPSession)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+
+ }
+ else
+ {
+ // No authentication use the verb that was requested by the caller
+ if((nRetCode = HTTPIntrnHeadersSend(pHTTPSession,pHTTPSession->HttpHeaders.HttpVerb)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+ // This the case where the caller know the total length to receive in advance
+ // and he wishes to send the data right away
+ if(pHTTPSession->HttpHeaders.HttpVerb == VerbPost && TotalLength == TRUE)
+ {
+
+ // Send the data
+ nBytes = nDataLength;
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,pData,&nBytes)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the session state
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_POST_SENT;
+ }
+
+ }while(0);
+
+
+
+ return nRetCode;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientRecvResponse
+// Purpose : Receives the response header on the connection and parses it.
+// Performs any required authentication.
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientRecvResponse (HTTP_SESSION_HANDLE pSession,
+ UINT32 nTimeout) // [IN] Timeout for the operation
+{
+
+ UINT32 nRetCode; // Function return code
+ P_HTTP_SESSION pHTTPSession = NULL; // Session pointer
+
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ do
+ {
+ if((nRetCode = HTTPIntrnHeadersReceive(pHTTPSession, nTimeout)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ } while(0);
+
+ return nRetCode;
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientWriteData
+// Purpose : Write data to the remote server
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientWriteData (HTTP_SESSION_HANDLE pSession,
+ VOID *pBuffer,
+ UINT32 nBufferLength,
+ UINT32 nTimeout)
+{
+
+ UINT32 nRetCode = HTTP_CLIENT_SUCCESS;
+ UINT32 nBytes;
+ CHAR Chunk[HTTP_CLIENT_MAX_CHUNK_HEADER];
+ CHAR *pChunkHeaderPtr;
+
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+
+ // Cast the handle to our internal structure and check the pointer validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ do
+ {
+ if(!pHTTPSession)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+
+ // Set the operation timeout counters
+ pHTTPSession->HttpCounters.nActionStartTime = HTTPIntrnSessionGetUpTime();
+ pHTTPSession->HttpCounters.nActionTimeout = HTTP_TIMEOUT(nTimeout);
+
+ // Did the caller specified chunked sending?
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SEND_CHUNKED) == HTTP_CLIENT_FLAG_SEND_CHUNKED)
+ {
+ // Prep the chunk Header and send it
+ memset(Chunk,0x00,HTTP_CLIENT_MAX_CHUNK_HEADER);
+ pChunkHeaderPtr = HTTPStrLToH(Chunk,nBufferLength);
+ strcat(Chunk,HTTP_CLIENT_CRLF);
+
+ // Send the leading CrLf (only after the first chunk)
+ if(pHTTPSession->HttpCounters.nSentChunks >= 1)
+ {
+ nBytes = 2;;
+ nRetCode = HTTPIntrnSend(pHTTPSession,HTTP_CLIENT_CRLF,&nBytes);
+ if(nRetCode != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+
+ // Send the chunk header
+ nBytes = strlen(Chunk);
+ nRetCode = HTTPIntrnSend(pHTTPSession,Chunk,&nBytes);
+ if(nRetCode != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+
+ // Send the data
+ nBytes = nBufferLength;
+ nRetCode = HTTPIntrnSend(pHTTPSession,pBuffer,&nBytes);
+ if(nRetCode != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+
+ // If we are using chunks then..
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SEND_CHUNKED) == HTTP_CLIENT_FLAG_SEND_CHUNKED)
+ {
+ // Set the chunks count
+ pHTTPSession->HttpCounters.nSentChunks++;
+
+ // If it was the last chunk (0) we should re-get the headers from the server reply
+ if(nBufferLength == 0)
+ {
+ // Send the trailing CrLf
+ nBytes = 2;;
+ nRetCode = HTTPIntrnSend(pHTTPSession,HTTP_CLIENT_CRLF,&nBytes);
+ if(nRetCode != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Get the remote headers (since the last chunk was transmitted we can expect the server to start the reply)
+ if((nRetCode = HTTPIntrnHeadersReceive(pHTTPSession,nTimeout)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+ }
+
+ } while(0);
+
+ return nRetCode;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientReadData
+// Purpose : Read data from the server. Parse out the chunks data.
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+ UINT32 HTTPClientReadData (HTTP_SESSION_HANDLE pSession,
+ VOID *pBuffer, // [IN OUT] a pointer to a buffer that will be filled with the servers response
+ UINT32 nBytesToRead, // [IN] The size of the buffer (numbers of bytes to read)
+ UINT32 nTimeout, // [IN] operation timeout in seconds
+ UINT32 *nBytesRecived) // [OUT] Count of the bytes that ware received in this operation
+ {
+
+ UINT32 nBytes = 0;
+ UINT32 nRetCode = 0 ;
+ INT32 nProjectedBytes = 0; // Should support negative numbers
+ CHAR *pNullPtr;
+ BOOL EndOfStream = FALSE;
+
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ // If the last verb that was used was HEAD there is no point to get this data (chanses are that we will endup with timeout)
+ if(pHTTPSession->HttpHeaders.HttpVerb == VerbHead)
+ {
+ return HTTP_CLIENT_EOS;
+
+ }
+
+ // Set the operation timeout counters
+ pHTTPSession->HttpCounters.nActionStartTime = HTTPIntrnSessionGetUpTime();
+ pHTTPSession->HttpCounters.nActionTimeout = HTTP_TIMEOUT(nTimeout);
+
+
+ nBytes = nBytesToRead - 1; // We will spare 1 byte for the trailing null termination
+ *((CHAR*)pBuffer) = 0; // Null terminate the user supplied buffer
+ *(nBytesRecived) = 0; // Set the return bytes count to 0
+
+ // We can read the data only if we got valid headers (and not authentication requests for example)
+ if((pHTTPSession->HttpState & HTTP_CLIENT_STATE_HEADERS_PARSED) != HTTP_CLIENT_STATE_HEADERS_PARSED)
+ {
+ return HTTP_CLIENT_ERROR_BAD_STATE;
+ }
+
+ // Is it a chunked mode transfer?
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_CHUNKED) == HTTP_CLIENT_FLAG_CHUNKED)
+ {
+
+ // How many bytes left until the next chunk?
+ if(pHTTPSession->HttpCounters.nBytesToNextChunk == 0)
+ {
+ // Read the chunk header and get its length
+ if(HTTPIntrnGetRemoteChunkLength(pHTTPSession) != HTTP_CLIENT_SUCCESS)
+ {
+ // Could not parse the chunk parameter
+ return HTTP_CLIENT_ERROR_CHUNK;
+ }
+
+ // 0 Bytes chunk, we should return end of stream
+ if(pHTTPSession->HttpCounters.nRecivedChunkLength == 0)
+ {
+ return HTTP_CLIENT_EOS;
+ }
+ }
+ // If we are about to read pass the next chunk, reduce the read bytes so we will read
+ // non HTML data
+ nProjectedBytes = pHTTPSession->HttpCounters.nBytesToNextChunk - nBytes;
+ if ( nProjectedBytes <= 0)
+ {
+ // Set the correct bytes count we should read
+ nBytes = pHTTPSession->HttpCounters.nBytesToNextChunk;
+ }
+ }
+
+ // Do we have the content length?
+ if(pHTTPSession->HttpHeadersInfo.nHTTPContentLength > 0)
+ {
+ // Length of the projected buffer
+ nProjectedBytes = pHTTPSession->HttpCounters.nRecivedBodyLength + nBytes;
+ // If we are going to read more then the known content length then..
+ if(nProjectedBytes >= (INT32)pHTTPSession->HttpHeadersInfo.nHTTPContentLength)
+ {
+ // Reduce the received bytes count to the correct size
+ nBytes = pHTTPSession->HttpHeadersInfo.nHTTPContentLength - pHTTPSession->HttpCounters.nRecivedBodyLength;
+
+ }
+ }
+ // Receive the data from the socket
+ nRetCode = HTTPIntrnRecv(pHTTPSession,(CHAR*)pBuffer,&nBytes,FALSE);
+ // Set the return bytes count
+ *(nBytesRecived) = nBytes; // + 1; Fixed 11/9/2005
+
+ // Pointer to the end of the buffer
+ pNullPtr = (CHAR*)pBuffer + nBytes ;
+ // And null terminate
+ *pNullPtr = 0;
+
+ // Socket read went OK
+ if(nRetCode == HTTP_CLIENT_SUCCESS)
+ {
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPClientReadData",NULL,0,"Reading %d bytes",nBytes);
+ }
+#endif
+ // Set the HTTP counters
+ pHTTPSession->HttpCounters.nRecivedBodyLength += nBytes;
+ // If we know the total content length and..
+ if(pHTTPSession->HttpHeadersInfo.nHTTPContentLength > 0)
+ {
+ // If total received body is equal or greater then the known content length then..
+ if( pHTTPSession->HttpCounters.nRecivedBodyLength >= pHTTPSession->HttpHeadersInfo.nHTTPContentLength)
+ {
+ // Raise a flag to signal end of stream
+ EndOfStream = TRUE;
+ }
+ }
+ // Is it a chunked mode transfer?
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_CHUNKED) == HTTP_CLIENT_FLAG_CHUNKED)
+ {
+ // We are a little closer to the next chunk now
+ pHTTPSession->HttpCounters.nBytesToNextChunk -= nBytes;
+ }
+ // Is it End of stream?
+ if(EndOfStream == TRUE)
+ {
+ // So exit
+ return HTTP_CLIENT_EOS;
+ }
+ }
+
+ return nRetCode ;
+}
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientGetInfo
+// Purpose : Fill the users structure with the session information
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientGetInfo (HTTP_SESSION_HANDLE pSession, HTTP_CLIENT *HTTPClient)
+{
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+ // Reset the users info structure
+ memset(HTTPClient,0x00,sizeof(HTTP_CLIENT));
+
+ HTTPClient->HTTPStatusCode = pHTTPSession->HttpHeadersInfo.nHTTPStatus;
+ HTTPClient->RequestBodyLengthSent = pHTTPSession->HttpCounters.nSentBodyBytes;
+ HTTPClient->ResponseBodyLengthReceived = pHTTPSession->HttpCounters.nRecivedBodyLength;
+ HTTPClient->TotalResponseBodyLength = pHTTPSession->HttpHeadersInfo.nHTTPContentLength;
+ HTTPClient->HttpState = pHTTPSession->HttpState;
+
+ return HTTP_CLIENT_SUCCESS;
+
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientFindFirstHeader
+// Purpose : Initiate the headr searching functions
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientFindFirstHeader (HTTP_SESSION_HANDLE pSession, CHAR *pSearchClue,CHAR *pHeaderBuffer, UINT32 *nLength)
+{
+
+ P_HTTP_SESSION pHTTPSession = NULL;
+ UINT32 nClueLength;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ nClueLength = strlen(pSearchClue); // See if we are not to long
+ if(nClueLength >= HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE)
+ {
+ return HTTP_CLIENT_ERROR_HEADER_BIG_CLUE;
+ }
+ else
+ {
+ strcpy(pHTTPSession->HttpHeaders.SearchClue,pSearchClue);
+ pHTTPSession->HttpHeaders.HeaderSearch.nLength = 0;
+ pHTTPSession->HttpHeaders.HeaderSearch.pParam = NULL;
+ }
+
+ return HTTP_CLIENT_SUCCESS;
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientFindCloseHeader
+// Purpose : Terminate a headers search session
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPClientFindCloseHeader (HTTP_SESSION_HANDLE pSession)
+{
+
+ P_HTTP_SESSION pHTTPSession = NULL;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ pHTTPSession->HttpHeaders.SearchClue[0] = 0;
+ pHTTPSession->HttpHeaders.HeaderSearch.nLength = 0;
+ pHTTPSession->HttpHeaders.HeaderSearch.pParam = NULL;
+
+ return HTTP_CLIENT_SUCCESS;
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPClientGetNextHeader
+// Purpose : Terminate a headers search session
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+UINT32 HTTPClientGetNextHeader (HTTP_SESSION_HANDLE pSession, CHAR *pHeaderBuffer, UINT32 *nLength)
+{
+
+ P_HTTP_SESSION pHTTPSession = NULL;
+ UINT32 nOffset = 0;
+ UINT32 nRetCode;
+ HTTP_PARAM HttpHeader;
+ CHAR *pPtr;
+
+ // Cast the handle to our internal structure and check the pointers validity
+ pHTTPSession = (P_HTTP_SESSION)pSession;
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+ if(pHTTPSession->HttpHeaders.HeaderSearch.nLength > 0) // We must adjust the search offset since it is not the fierst iteration
+ {
+ nOffset = pHTTPSession->HttpHeaders.HeaderSearch.pParam - pHTTPSession->HttpHeaders.HeadersIn.pParam;
+ }
+ // Search for the next header
+ nRetCode = HTTPIntrnHeadersFind(pHTTPSession,pHTTPSession->HttpHeaders.SearchClue,&HttpHeader,TRUE,nOffset);
+
+ if(nRetCode == HTTP_CLIENT_SUCCESS)
+ {
+ if(HttpHeader.nLength > *(nLength)) // Check for sufficiant length
+ {
+ *(nLength) = HttpHeader.nLength;
+ pHeaderBuffer[0] = 0; // Reset the users buffer
+ return HTTP_CLIENT_ERROR_NO_MEMORY;
+ }
+
+ pPtr = HttpHeader.pParam;
+ nOffset = 0;
+ if(*pPtr == 0x0d)
+ {
+ nOffset++;
+ pPtr++;
+ }
+ if(*pPtr == 0x0a)
+ {
+ nOffset++;
+ pPtr++;
+ }
+
+ strncpy(pHeaderBuffer,pPtr,HttpHeader.nLength - nOffset);
+ pHeaderBuffer[HttpHeader.nLength - nOffset] = 0;
+ *(nLength) = HttpHeader.nLength - nOffset;
+ pHTTPSession->HttpHeaders.HeaderSearch.pParam = HttpHeader.pParam + HttpHeader.nLength;
+ pHTTPSession->HttpHeaders.HeaderSearch.nLength++;
+
+ return HTTP_CLIENT_SUCCESS;
+
+ }
+
+ return nRetCode;
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnSetURL
+// Purpose : Parse the user's URL
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnSetURL (P_HTTP_SESSION pHTTPSession,
+ CHAR *pUrl, // [IN] a null terminated string containing the Url we should retrieve
+ UINT32 nUrlLength) // [IN] The length the Url string
+{
+
+ UINT32 nUrlOffset; // Offset in bytes within the Url string
+ HTTP_URL *pUrlPtr; // a Pointer to the Url structure (within the global session structure)
+ CHAR *pPtr; // a Pointer for the Url port (Used in the parsing process)
+ CHAR UrlPort[16]; // a temporary byte array for the Url port conversion operation (string to number)
+
+ // Check for the session pointer validity
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+
+ // Get the length of the Url
+ nUrlLength = strlen(pUrl);
+
+ // Check if it is not longer than the permitted length
+ if((nUrlLength + 1) > HTTP_CLIENT_MAX_URL_LENGTH)
+ {
+ return HTTP_CLIENT_ERROR_LONG_INPUT;
+ }
+
+ // Point the local pointer on the global structure
+ pUrlPtr = &pHTTPSession->HttpUrl;
+
+ // Copy to the internal buffer
+ memcpy(pHTTPSession->HttpUrl.Url,pUrl,nUrlLength);
+ nUrlOffset = 0;
+
+ // Get the Url base ("http" or "https")
+ if(HTTPStrSearch(pUrlPtr->Url,":",nUrlOffset,nUrlLength,&pUrlPtr->UrlBsee) == FALSE)
+ {
+ return HTTP_CLIENT_ERROR_BAD_URL;
+ }
+ // Increase the offset parameter
+ nUrlOffset += pUrlPtr->UrlBsee.nLength;
+ // If we can parse the string "HTTPS" we can assume a secured session
+ if(HTTPStrInsensitiveCompare(pUrlPtr->UrlBsee.pParam,"https",pUrlPtr->UrlBsee.nLength) == TRUE)
+ {
+ // Set the secured flags on the session
+ pHTTPSession->HttpFlags = pHTTPSession->HttpFlags | HTTP_CLIENT_FLAG_URLHTTPS;
+ pHTTPSession->HttpFlags = pHTTPSession->HttpFlags | HTTP_CLIENT_FLAG_SECURE;
+ // ToDo: Init TLS (GetProtocol)
+#ifdef _HTTP_BUILD_AMT
+ // OS_GET_CLIENT_SUBSET_PROTOCOL(TRUE,&pHTTPSession->pSecProtocol);
+#endif
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnSetURL",NULL,0,"SSL Protected Url %s",pUrl);
+ }
+#endif
+ }
+ else // it should be "http"
+ {
+ if(HTTPStrInsensitiveCompare(pUrlPtr->UrlBsee.pParam,"http",pUrlPtr->UrlBsee.nLength) == FALSE)
+ {
+ return HTTP_CLIENT_ERROR_BAD_URL; // cOULD NOT DETECT http or https prefix
+
+ }
+ }
+ // Look for standard Url elements
+ if(HTTPStrSearch(pUrlPtr->Url,"://",nUrlOffset,3,0) == FALSE)
+ {
+ return HTTP_CLIENT_ERROR_BAD_URL; // Could not detect "://"
+ }
+ // Increase the offset parameter
+ nUrlOffset += 3;
+
+ // Get the host name
+ if(HTTPStrSearch(pUrlPtr->Url,"/",nUrlOffset,(nUrlLength - nUrlOffset),&pUrlPtr->UrlHost) == FALSE)
+ {
+ pUrlPtr->Url[nUrlLength] = '/';
+ nUrlLength++;
+ if(HTTPStrSearch(pUrlPtr->Url,"/",nUrlOffset,(nUrlLength - nUrlOffset),&pUrlPtr->UrlHost) == FALSE)
+ {
+ return HTTP_CLIENT_ERROR_BAD_URL;
+ }
+ }
+
+ nUrlOffset += pUrlPtr->UrlHost.nLength;
+
+ // Do we have the port within the hostname?
+ if(HTTPStrSearch(pUrlPtr->Url,":",
+ (nUrlOffset - pUrlPtr->UrlHost.nLength),
+ pUrlPtr->UrlHost.nLength,
+ &pUrlPtr->UrlPort) == TRUE)
+ {
+ if((pUrlPtr->UrlHost.nLength - pUrlPtr->UrlPort.nLength) < 10)
+ {
+ // To-Do: check the actual port length before the memcpy
+ pUrlPtr->UrlPort.pParam += pUrlPtr->UrlPort.nLength + 1;
+ memcpy(UrlPort,pUrlPtr->UrlPort.pParam,15);
+ pUrlPtr->UrlPort.nLength = 0;
+ pPtr = UrlPort;
+ while(*pPtr && pPtr++)
+ {
+
+ pUrlPtr->UrlPort.nLength++;
+ if(*pPtr == '/')
+ {
+ *pPtr = 0;
+ pUrlPtr->nPort = (UINT16)atol(UrlPort);
+ pHTTPSession->HttpFlags = pHTTPSession->HttpFlags | HTTP_CLIENT_FLAG_URLANDPORT;
+ break;
+ }
+ }
+ }
+ else
+ {
+ // Port too big
+ return HTTP_CLIENT_ERROR_BAD_URL;
+ }
+ }
+
+ // Get the request body
+ pUrlPtr->UrlRequest.pParam = pUrlPtr->Url + nUrlOffset;
+ pUrlPtr->UrlRequest.nLength = nUrlLength - nUrlOffset;
+
+ // If we got SSL url with no port we should set the default ssl port
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_URLHTTPS) == HTTP_CLIENT_FLAG_URLHTTPS)
+ {
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_URLANDPORT) != HTTP_CLIENT_FLAG_URLANDPORT)
+ {
+ pHTTPSession->HttpUrl.nPort = HTTP_CLIENT_DEFAULT_SSL_PORT;
+
+ }
+
+ }
+
+ // Set the state flag
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_URL_PARSED;
+
+ return HTTP_CLIENT_SUCCESS;
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnResizeBuffer
+// Purpose : Resize the HTTP headers buffer and reset the pointers
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnResizeBuffer (P_HTTP_SESSION pHTTPSession,
+ UINT32 nNewBufferSize) // [IN] The new (and larger) buffer size
+{
+
+ CHAR *pPtr = NULL;
+ UINT32 nCurrentBufferSize;
+
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+ // If the new buffer size is less or equal to the current buffer size then..
+ if(pHTTPSession->HttpHeaders.HeadersBuffer.nLength >= nNewBufferSize)
+ {
+
+ // Return an error (bad buffer)
+ return HTTP_CLIENT_ERROR_BUFFER_RSIZE;
+ }
+
+ // If the new buffer size is bigger then the defined maximum buffer size then..
+ if(nNewBufferSize > HTTP_CLIENT_MAX_SEND_RECV_HEADERS)
+ {
+ // Return an error (bad buffer)
+ return HTTP_CLIENT_ERROR_BUFFER_RSIZE;
+ }
+ // Current buffer size is the sum of the incoming and outgoing headers strings lengths
+ nCurrentBufferSize = pHTTPSession->HttpHeaders.HeadersOut.nLength + pHTTPSession->HttpHeaders.HeadersIn.nLength;
+ // Allocate a new buffer with the requested buffer size
+ pPtr = (CHAR*)malloc(ALIGN(nNewBufferSize));
+ if(!pPtr)
+ {
+ // malloc() error
+ return HTTP_CLIENT_ERROR_NO_MEMORY;
+ }
+
+ // Copy the memory only if there is data to copy
+ if(nCurrentBufferSize > 0)
+ {
+ memcpy(pPtr,pHTTPSession->HttpHeaders.HeadersBuffer.pParam,nCurrentBufferSize);
+ // Reset the rest of the buffer
+ memset(pPtr + nCurrentBufferSize, 0x00,(nNewBufferSize - nCurrentBufferSize));
+ }
+ else
+ {
+ // Reset the entire buffer (no previous buffer was copied)
+ memset(pPtr,0x00,nNewBufferSize);
+ }
+
+ free(pHTTPSession->HttpHeaders.HeadersBuffer.pParam);
+
+ pHTTPSession->HttpHeaders.HeadersBuffer.pParam = pPtr;
+ pHTTPSession->HttpHeaders.HeadersBuffer.nLength = nNewBufferSize;
+
+ // Refresh the pointers
+ pHTTPSession->HttpHeaders.HeadersOut.pParam = pHTTPSession->HttpHeaders.HeadersBuffer.pParam;
+ if(pHTTPSession->HttpHeaders.HeadersIn.pParam)
+ {
+ pHTTPSession->HttpHeaders.HeadersIn.pParam =pHTTPSession->HttpHeaders.HeadersBuffer.pParam + pHTTPSession->HttpHeaders.HeadersOut.nLength;
+ }
+ return HTTP_CLIENT_SUCCESS;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnRemoveHeader
+// Purpose : Removes an HTTP headers by its name
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnHeadersRemove (P_HTTP_SESSION pHTTPSession,
+ CHAR *pHeaderName) // [IN] The header's name
+
+{
+
+ HTTP_PARAM HttpParam;
+ UINT32 nRetCode = HTTP_CLIENT_SUCCESS;
+ UINT32 nBytes;
+
+ if(!pHTTPSession) // Pointer validation check
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ // First see if we have that header in our outgoing headers buffer
+ do
+ {
+
+ if((nRetCode = HTTPIntrnHeadersFind(pHTTPSession,pHeaderName,&HttpParam,FALSE,0)) != HTTP_CLIENT_SUCCESS)
+ {
+ // Could not find this header
+ break;
+ }
+ // Calculate the new headers length
+ nBytes = (HttpParam.pParam - pHTTPSession->HttpHeaders.HeadersOut.pParam);
+ nBytes -= HttpParam.nLength;
+
+
+ // Copy the memory
+ memcpy(HttpParam.pParam, HttpParam.pParam + HttpParam.nLength,nBytes);
+
+ // Set the new length
+ pHTTPSession->HttpHeaders.HeadersOut.nLength -= HttpParam.nLength;
+
+ // Reset the buffer from it's modified end to it's previous end
+ memset(pHTTPSession->HttpHeaders.HeadersOut.pParam + pHTTPSession->HttpHeaders.HeadersOut.nLength,0x00,HttpParam.nLength);
+
+ } while(0);
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnHeadersRemove",NULL,0,"Removing Header %",pHeaderName);
+ }
+#endif
+
+
+ return nRetCode;
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnHeadersAdd
+// Purpose : Add HTTP headers to the outgoing headers buffers
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnHeadersAdd (P_HTTP_SESSION pHTTPSession,
+ CHAR *pHeaderName, // [IN] The header's name
+ UINT32 nNameLength, // [IN] Name length
+ CHAR *pHeaderData, // [IN] The Header's data
+ UINT32 nDataLength) // [IN] Data length
+{
+ CHAR *pPtr;
+ UINT32 nProjectedHeaderLength;
+ UINT32 nProjectedBufferLength;
+ INT32 nCurrentfreeSpace;
+ INT32 nProjectedfreeSpace;
+ UINT32 nRetCode;
+
+ if(!pHTTPSession) // pointer validation check
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ nProjectedHeaderLength = nNameLength + nDataLength + 4;
+ nProjectedBufferLength = nProjectedHeaderLength + pHTTPSession->HttpHeaders.HeadersOut.nLength + pHTTPSession->HttpHeaders.HeadersIn.nLength;
+ nCurrentfreeSpace = pHTTPSession->HttpHeaders.HeadersBuffer.nLength - (pHTTPSession->HttpHeaders.HeadersOut.nLength + pHTTPSession->HttpHeaders.HeadersIn.nLength);
+ nProjectedfreeSpace = nCurrentfreeSpace - nProjectedHeaderLength;
+
+ // Check total size limit
+ if(nProjectedBufferLength > HTTP_CLIENT_MAX_SEND_RECV_HEADERS)
+ {
+ return HTTP_CLIENT_ERROR_NO_MEMORY;
+ }
+
+ if((INT32)nProjectedfreeSpace < 0)
+ {
+ if(HTTP_CLIENT_MEMORY_RESIZABLE == FALSE)
+ {
+ // Need more space but we can't grow beyond the current size
+ return HTTP_CLIENT_ERROR_NO_MEMORY;
+ }
+ else
+ {
+ // We can resizes so..
+ nRetCode = HTTPIntrnResizeBuffer(pHTTPSession,nProjectedBufferLength + HTTP_CLIENT_MEMORY_RESIZE_FACTOR);
+ if(nRetCode != HTTP_CLIENT_SUCCESS)
+ {
+ return nRetCode;
+ }
+ }
+ }
+
+ // Move the incoming headers data within the buffer so we will have space for the added headers
+ if(pHTTPSession->HttpHeaders.HeadersIn.pParam)
+ {
+ // Move the data and reset the data in the offset.
+ memcpy(pHTTPSession->HttpHeaders.HeadersIn.pParam + nProjectedHeaderLength ,
+ pHTTPSession->HttpHeaders.HeadersIn.pParam,
+ pHTTPSession->HttpHeaders.HeadersIn.nLength);
+ // Reset the space created
+ memset(pHTTPSession->HttpHeaders.HeadersOut.pParam + pHTTPSession->HttpHeaders.HeadersOut.nLength,
+ 0x00,
+ nProjectedHeaderLength);
+
+ }
+
+ pPtr = pHTTPSession->HttpHeaders.HeadersOut.pParam + pHTTPSession->HttpHeaders.HeadersOut.nLength;
+ // Create the new header
+ memcpy(pPtr,pHeaderName,nNameLength);
+ pPtr += nNameLength;
+ memcpy(pPtr,": ",2);
+ pPtr += 2;
+ memcpy(pPtr,pHeaderData,nDataLength);
+ pPtr += nDataLength;
+ memcpy(pPtr,HTTP_CLIENT_CRLF,2);
+ pPtr += 2;
+
+ // Set the new length
+ pHTTPSession->HttpHeaders.HeadersOut.nLength += nProjectedHeaderLength;
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnHeadersAdd",NULL,0,"Adding Header %s: %s",pHeaderName,pHeaderData);
+ }
+#endif
+
+ return HTTP_CLIENT_SUCCESS;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnConnectionClose
+// Purpose : Closes an active socket connection and invalidate the socket handle
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPIntrnConnectionClose (P_HTTP_SESSION pHTTPSession)
+{
+
+ INT32 nRetCode = HTTP_CLIENT_SUCCESS;
+
+ do
+ {
+ if(!pHTTPSession) // Validate the session pointer
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+
+ // If we have a valid socket then..
+ if(pHTTPSession->HttpConnection.HttpSocket != HTTP_INVALID_SOCKET)// INVALID_SOCKET
+ {
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SECURE) == HTTP_CLIENT_FLAG_SECURE)
+ {
+ // TLS Close
+ nRetCode = HTTPWrapperSSLClose(pHTTPSession->HttpConnection.HttpSocket);
+ }
+
+ // Gracefully close it
+ shutdown(pHTTPSession->HttpConnection.HttpSocket,0x01);
+ closesocket(pHTTPSession->HttpConnection.HttpSocket);
+ // And invalidate the socket
+ pHTTPSession->HttpConnection.HttpSocket = HTTP_INVALID_SOCKET;
+
+ break;;
+ }
+ else
+ {
+ // Not a valid socket error
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_INVALID;
+ break;
+ }
+
+ } while(0);
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnConnectionClose",NULL,0,"");
+ }
+#endif
+ return nRetCode;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnConnectionOpen
+// Purpose : Opens a socket connection to the remote host or proxy server
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnConnectionOpen (P_HTTP_SESSION pHTTPSession)
+{
+ INT32 nRetCode = HTTP_CLIENT_SUCCESS; // a function return code value
+ UINT32 nNullOffset; // a helper value to null terminate a given string
+ int nNonBlocking = 1; // non blocking mode parameter
+ CHAR Backup; // a container for a char value (helps in temporary null termination)
+ // HTTP_HOSTNET *HostEntry; // Socket host entry pointer
+ UINT32 Address = 0;
+ HTTP_SOCKADDR_IN ServerAddress; // Socket address structure
+ HTTP_SOCKADDR_IN LoaclAddress; // Socket address structure (for client binding)
+ do
+ {
+
+ if(!pHTTPSession)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+ // Use an existing connection if valid
+ if(pHTTPSession->HttpConnection.HttpSocket != HTTP_INVALID_SOCKET)
+ {
+ // Set the state flag
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HOST_CONNECTED;
+ return HTTP_CLIENT_SUCCESS;
+ }
+ // Zero the socket events
+ FD_ZERO(&pHTTPSession->HttpConnection.FDRead);
+ FD_ZERO(&pHTTPSession->HttpConnection.FDWrite);
+ FD_ZERO(&pHTTPSession->HttpConnection.FDError);
+
+ if(pHTTPSession->HttpConnection.HttpSocket == HTTP_INVALID_SOCKET)
+ {
+
+ // Create a TCP/IP stream socket
+ pHTTPSession->HttpConnection.HttpSocket = socket(AF_INET, // Address family
+ SOCK_STREAM, // Socket type
+ IPPROTO_TCP); // Protocol
+ }
+
+ // Exit if we don't have a valid socket
+ if(pHTTPSession->HttpConnection.HttpSocket == HTTP_INVALID_SOCKET)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_INVALID;
+ break;
+ }
+ // Set non blocking socket
+ nRetCode = ioctlsocket(pHTTPSession->HttpConnection.HttpSocket, FIONBIO, &nNonBlocking);
+ if(nRetCode != 0)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_CANT_SET;
+ break;
+ }
+ // Resolve the target host name
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_USINGPROXY) != HTTP_CLIENT_FLAG_USINGPROXY)
+ {
+ // No proxy, directly resolving the host name
+ // Prep the parameter
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_URLANDPORT) == HTTP_CLIENT_FLAG_URLANDPORT)
+ {
+ nNullOffset = pHTTPSession->HttpUrl.UrlHost.nLength - pHTTPSession->HttpUrl.UrlPort.nLength - 1;
+ }
+ else
+ {
+ nNullOffset = pHTTPSession->HttpUrl.UrlHost.nLength;
+ }
+
+ Backup = HTTPStrExtract(pHTTPSession->HttpUrl.UrlHost.pParam,nNullOffset,0);
+ // Resolve the host name
+ nRetCode = HostByName(pHTTPSession->HttpUrl.UrlHost.pParam,&Address);
+
+ // Restore from backup (fix the buffer)
+ HTTPStrExtract(pHTTPSession->HttpUrl.UrlHost.pParam,nNullOffset,Backup);
+
+ }
+
+ else
+ {
+ // Using a Proxy server so resolve the proxy host name
+ nRetCode = HostByName(pHTTPSession->HttpProxy.ProxyHost,&Address);
+ }
+
+ // See if we have a valid response from the net resolve operation
+ /*
+ if(nRetCode)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_RESOLVE;
+ break;
+ }
+ */
+ // Reset the address structures
+ memset(&ServerAddress, 0, sizeof(HTTP_SOCKADDR_IN));
+ memset(&LoaclAddress, 0, sizeof(HTTP_SOCKADDR_IN));
+
+ // Fill in the address structure
+ ServerAddress.sin_family = AF_INET;
+#ifdef _HTTP_BUILD_AMT
+ ServerAddress.sin_len = sizeof(HTTP_SOCKADDR_IN);
+ ServerAddress.sin_addr.s_addr = htonl(Address); // Server's address
+#endif
+#ifdef _HTTP_BUILD_WIN32
+ ServerAddress.sin_addr.s_addr = Address; // Server's address
+#endif
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_USINGPROXY) != HTTP_CLIENT_FLAG_USINGPROXY)
+ {
+ // Use the remote web server port
+ ServerAddress.sin_port = htons(pHTTPSession->HttpUrl.nPort); // Host Port number
+ }
+ else
+ {
+ // Use the proxy port
+ ServerAddress.sin_port = htons(pHTTPSession->HttpProxy.nProxyPort); // Proxy Port number
+ }
+
+ // Client-side Binding
+ if(pHTTPSession->HttpConnection.HttpClientPort != 0)
+ {
+ LoaclAddress.sin_family = AF_INET;
+#ifdef _HTTP_BUILD_AMT
+ LoaclAddress.sin_len = sizeof(HTTP_SOCKADDR_IN);
+#endif
+ LoaclAddress.sin_port = htons((unsigned short)pHTTPSession->HttpConnection.HttpClientPort);
+
+ nRetCode = bind(pHTTPSession->HttpConnection.HttpSocket,
+ (HTTP_SOCKADDR*)&LoaclAddress,
+ sizeof(HTTP_SOCKADDR_IN));
+
+ if(nRetCode != 0)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_BIND;
+ }
+ }
+
+ // Connect using TLS or otherwise clear connection
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SECURE) == HTTP_CLIENT_FLAG_SECURE)
+ { // Is it a TLS connection?
+ nRetCode = HTTPWrapperSSLConnect(pHTTPSession->HttpConnection.HttpSocket, // Socket
+ (HTTP_SOCKADDR*)&ServerAddress, // Server address
+ sizeof(HTTP_SOCKADDR), // Length of server address structure
+ "desktop"); // Hostname (ToDo: Fix this)
+ }
+ else // Non TLS so..
+ {
+ nRetCode = connect(pHTTPSession->HttpConnection.HttpSocket, // Socket
+ (HTTP_SOCKADDR*)&ServerAddress, // Server address
+ sizeof(HTTP_SOCKADDR)); // Length of server address structure
+ }
+
+ // The socket was set to be asyn so we should check the error being returned from connect()
+ nRetCode = SocketGetErr(pHTTPSession->HttpConnection.HttpSocket);
+ if(nRetCode == 0 || nRetCode == HTTP_EWOULDBLOCK || nRetCode == HTTP_EINPROGRESS)
+ {
+ // Set TLS Nego flag to flase
+ pHTTPSession->HttpConnection.TlsNego = FALSE;
+ // Set the Write fd_sets for a socket connection event
+ FD_SET(pHTTPSession->HttpConnection.HttpSocket, &pHTTPSession->HttpConnection.FDWrite);
+ // Set the state flag
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HOST_CONNECTED;
+ // We have connected so set the return value to success
+ nRetCode = HTTP_CLIENT_SUCCESS;
+ break;
+ }
+ else
+ {
+ // Socket connection problem
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_CONNECT;
+ break;
+ }
+ }while(0);
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnConnectionOpen",NULL,0,"");
+ }
+#endif
+
+ return nRetCode;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnSend
+// Purpose : Send data to the remote server (Asynchronous sockets)
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnSend (P_HTTP_SESSION pHTTPSession,
+ CHAR *pData, // [IN] a pointer to the data to be sent
+ UINT32 *nLength) // [IN OUT] Length of data to send and the transmitted bytes count
+{
+
+ INT32 nSocketEvents; // Socket events center
+ INT32 nRetCode = HTTP_CLIENT_SUCCESS; // a function return code value
+ HTTP_TIMEVAL Timeval = { 1 , 0 }; // Timeout value for the socket() method
+ HTTP_CONNECTION *pConnection = NULL; // Pointer for the connection structure
+
+
+ do
+ {
+ // Validate the session pointer
+ if(!pHTTPSession)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+
+ // Have a pointer on the internal connection structure for simplifying code reading
+ pConnection = &pHTTPSession->HttpConnection;
+
+ while(1)
+ {
+
+ // Check for timeout
+ if(HTTPIntrnSessionEvalTimeout(pHTTPSession) == TRUE)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_TIME_OUT;
+ break;
+ }
+
+ // Reset socket events , only Error, since we don't want to get
+ // a repeated Write events (socket is connected)
+
+ FD_SET(pConnection->HttpSocket, &pConnection->FDError);
+
+ // See if we got any events on the socket
+ nSocketEvents = select((pConnection->HttpSocket + 1), 0,
+ &pConnection->FDWrite,
+ &pConnection->FDError,
+ &Timeval);
+
+ if(nSocketEvents < 0) // No events on the socket
+ {
+ *(nLength) = 0;
+ break; // To-Do: This might be an error
+ }
+
+ if(nSocketEvents == 0) // No new events so
+ {
+ continue; // restart this loop
+ }
+
+ // Socket is writable (we are connected) so send the data
+ if(FD_ISSET(pConnection->HttpSocket ,&pConnection->FDWrite))
+ {
+
+ // Send the data
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SECURE) == HTTP_CLIENT_FLAG_SECURE)
+ {
+ // TLS Protected connection
+ if(pConnection->TlsNego == FALSE)
+ {
+ nRetCode = HTTPWrapperSSLNegotiate(pConnection->HttpSocket,0,0,"desktop");
+ if(nRetCode != 0)
+ {
+ // TLS Error
+ nRetCode = HTTP_CLIENT_ERROR_TLS_NEGO;
+ break;
+ }
+ pConnection->TlsNego = TRUE;
+ }
+ nRetCode = HTTPWrapperSSLSend(pConnection->HttpSocket,pData,*(nLength),0);
+ }
+ else
+ {
+ nRetCode = send(pConnection->HttpSocket,pData,*(nLength),0);
+ }
+ if(nRetCode == SOCKET_ERROR)
+ {
+ nRetCode = SocketGetErr(pHTTPSession->HttpConnection.HttpSocket);
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_SEND;
+ break;
+ }
+ // The data was sent to the remote server
+ *(nLength) = nRetCode;
+ nRetCode = HTTP_CLIENT_SUCCESS;
+ break;
+ }
+
+ // We had a socket related error
+ if(FD_ISSET(pConnection->HttpSocket ,&pConnection->FDError))
+ {
+ FD_CLR((UINT32)pConnection->HttpSocket,&pConnection->FDError);
+ *(nLength) = 0;
+ // To-Do: Handle this case
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_SEND;
+ break;
+ }
+ }
+ } while(0);
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnSend",pData,*(nLength),"");
+ }
+#endif
+
+
+ return nRetCode;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnRecv
+// Purpose : Receive data from the connected socket using asynchronous sockets
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnRecv (P_HTTP_SESSION pHTTPSession,
+ CHAR *pData, // [IN] a pointer for a buffer that receives the data
+ UINT32 *nLength, // [IN OUT] Length of the buffer and the count of the received bytes
+ BOOL PeekOnly) // [IN] State if we should only peek the socket (default is no)
+{
+ INT32 nSocketEvents;
+ INT32 nRetCode = HTTP_CLIENT_SUCCESS;
+ HTTP_TIMEVAL Timeval = { 0, 50000 };
+ HTTP_CONNECTION *pConnection = NULL;
+
+ do
+ {
+ if(!pHTTPSession)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+
+ // Set a pointer on the session internal connection structure (simplify code reading)
+ pConnection = &pHTTPSession->HttpConnection;
+ while(1)
+ {
+ // Check for timeout
+ if(HTTPIntrnSessionEvalTimeout(pHTTPSession) == TRUE)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_TIME_OUT;
+ break;
+ }
+
+
+ // Reset socket events
+ FD_SET(pConnection->HttpSocket, &pConnection->FDRead);
+ FD_SET(pConnection->HttpSocket, &pConnection->FDError);
+
+ // See if we got any events on the socket
+ nSocketEvents = select(pConnection->HttpSocket + 1, &pConnection->FDRead,
+ 0,
+ &pConnection->FDError,
+ &Timeval);
+
+ if(nSocketEvents < 0) // Error or no new socket events
+ {
+ *(nLength) = 0;
+ break;
+ }
+ if(nSocketEvents == 0)
+ {
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // This is a simple bypass for the TSL session (for some reason the socket read event is not set so
+ // The pending bytes on the socket are being checked manualy.
+ // TLS hack:
+
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SECURE) == HTTP_CLIENT_FLAG_SECURE)
+ {
+ nRetCode = HTTPWrapperSSLRecvPending(pConnection->HttpSocket);
+ if(nRetCode > 0)
+ {
+ // Recive without being notified by the socket event
+ if((nRetCode = HTTPWrapperSSLRecv(pConnection->HttpSocket,pData,*(nLength),0)) == SOCKET_ERROR)
+ {
+ // Socket error
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_RECV;
+ break;
+ }
+ *(nLength) = nRetCode;
+ // Break on no data or server connection reset
+ if ( nRetCode == 0 || nRetCode == HTTP_ECONNRESET)
+ {
+ // Connection closed, simply break - this is not an error
+ nRetCode = HTTP_CLIENT_EOS; // Signal end of stream
+ break;
+ }
+ // We have successfully got the data from the server
+ nRetCode = HTTP_CLIENT_SUCCESS;
+ break;
+ }
+ }
+ // End Of the TLS bypass section
+ //
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ continue; // select() timed out - restart this loop
+ }
+ if(FD_ISSET(pConnection->HttpSocket ,&pConnection->FDRead)) // Are there any read events on the socket ?
+ {
+ // Clear the event
+ FD_CLR((UINT32)pConnection->HttpSocket,&pConnection->FDRead);
+
+ // Socket is readable so so read the data
+ if(PeekOnly == FALSE)
+ {
+ // Get the data (secuure)
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SECURE) == HTTP_CLIENT_FLAG_SECURE)
+ {
+ if((nRetCode = HTTPWrapperSSLRecv(pConnection->HttpSocket,pData,*(nLength),0)) == SOCKET_ERROR)
+ {
+ // Socket error
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_RECV;
+ break;
+ }
+ }
+ else // Get the data (non secuure)
+ {
+ if((nRetCode = recv(pConnection->HttpSocket,pData,*(nLength),0)) == SOCKET_ERROR)
+ {
+ // Socket error
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_RECV;
+ break;
+ }
+ }
+
+ }
+ else
+ {
+ // Only peek te socket
+ if((nRetCode = recv(pConnection->HttpSocket,pData,*(nLength),MSG_PEEK)) == SOCKET_ERROR)
+ {
+ // Socket error
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_RECV;
+ break;
+ }
+
+ }
+ *(nLength) = nRetCode;
+ // Break on no data or server connection reset
+ // MSDN: If the connection has been gracefully closed, the return value is zero.
+ if ( nRetCode == 0 || nRetCode == HTTP_ECONNRESET)
+ {
+ // Connection closed, simply break - this is not an error
+ nRetCode = HTTP_CLIENT_EOS; // Signal end of stream
+ break;
+ }
+ // We have successfully got the data from the server
+ nRetCode = HTTP_CLIENT_SUCCESS;
+ break;
+ }
+
+ // We had a socket related error
+ if(FD_ISSET(pConnection->HttpSocket ,&pConnection->FDError))
+ {
+ FD_CLR((UINT32)pConnection->HttpSocket,&pConnection->FDError);
+ *(nLength) = 0;
+
+ // To-Do: Handle this case
+ nRetCode = HTTP_CLIENT_ERROR_SOCKET_RECV;
+ break;
+
+ }
+ }
+ }while(0);
+
+ return nRetCode;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnGetRemoteChunkLength
+// Purpose : Receive (byte by byte) the chunk parameter (while in chunk mode receive) and
+// Convert the HEX string into an integer
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnGetRemoteChunkLength (P_HTTP_SESSION pHTTPSession)
+{
+
+ UINT32 nBytesRead = 1;
+ UINT32 nRetCode = HTTP_CLIENT_SUCCESS;
+ UINT32 nBytesCount = 0;
+ CHAR ChunkHeader[HTTP_CLIENT_MAX_CHUNK_HEADER];
+ CHAR *pPtr;
+
+ do
+ {
+ if(!pHTTPSession)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+
+ // Read byte by byte until we get a CrLf
+ pPtr = ChunkHeader; // Get a pointer to the received buffer
+ *pPtr = 0; // Terminate with null
+
+ while(nBytesRead > 0)
+ {
+ // Receive a single byte
+ nRetCode = HTTPIntrnRecv(pHTTPSession,pPtr,&nBytesRead,FALSE);
+ // Did we succeed?
+ if(nRetCode == HTTP_CLIENT_SUCCESS && nBytesRead > 0)
+ {
+ // Increment the bytes count
+ nBytesCount += nBytesRead;
+ if(nBytesRead > HTTP_CLIENT_MAX_CHUNK_HEADER)
+ {
+ // Error chunk buffer is full
+ nRetCode = HTTP_CLIENT_ERROR_CHUNK_TOO_BIG;
+ break;
+ }
+ // Don't Process if the fist 2 bytes are CrLf.
+ if(! ((nBytesCount == 1 && *pPtr == 0x0d) || (nBytesCount == 2 && *pPtr == 0x0a)))
+ {
+ // Advance the pointer by the received data length
+ pPtr += nBytesRead;
+ // Look for CrLf in the last 2 bytes
+ if(memcmp(pPtr - 2,HTTP_CLIENT_CRLF,2) == 0)
+ {
+ // Chunk Header was received
+ *pPtr = 0; // null terminate the chunk parameter
+ pHTTPSession->HttpCounters.nRecivedChunkLength = HTTPStrHToL(ChunkHeader); // Convert to a number
+ // Set the HTTP counters
+ pHTTPSession->HttpCounters.nBytesToNextChunk = pHTTPSession->HttpCounters.nRecivedChunkLength;
+ break;
+ }
+ }
+ }
+ else // Socket Error
+ {
+ nRetCode = 0;
+ break;
+ }
+ }
+ } while(0);
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnGetRemoteChunkLength",NULL,0,"Next chunk is %d bytes",pHTTPSession->HttpCounters.nRecivedChunkLength);
+ }
+#endif
+
+ return nRetCode;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnGetRemoteHeaders
+// Purpose : Perform a socket receive (byte by byte) until all the HTTP headers are received
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnGetRemoteHeaders (P_HTTP_SESSION pHTTPSession)
+{
+
+ UINT32 nBytesRead = 1;
+ UINT32 nRetCode = HTTP_CLIENT_SUCCESS;
+ UINT32 nProjectedHeaderLength;
+ UINT32 nProjectedBufferLength;
+ INT32 nCurrentfreeSpace;
+ INT32 nProjectedfreeSpace;
+ CHAR *pPtr;
+
+ do
+ {
+ if(!pHTTPSession)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+
+ // Read byte by byte until we get CrLf followed by CrLf
+ // Set the incoming headers pointer
+
+ if(!pHTTPSession->HttpHeaders.HeadersIn.pParam)
+ {
+ /// The incoming headers starts where the outgoing headers ends
+ pHTTPSession->HttpHeaders.HeadersIn.pParam = pHTTPSession->HttpHeaders.HeadersOut.pParam + pHTTPSession->HttpHeaders.HeadersOut.nLength;
+ }
+
+ // Receive until we get all the headers or any other error event
+ while(nBytesRead > 0)
+ {
+
+ // Size of the projected buffer we are going to receive
+ nProjectedHeaderLength = nBytesRead;
+ // Size of the projected total incoming buffer
+ nProjectedBufferLength = nProjectedHeaderLength + pHTTPSession->HttpHeaders.HeadersOut.nLength + pHTTPSession->HttpHeaders.HeadersIn.nLength;
+ // Current free space on the incoming headers buffer
+ nCurrentfreeSpace = pHTTPSession->HttpHeaders.HeadersBuffer.nLength - (pHTTPSession->HttpHeaders.HeadersOut.nLength + pHTTPSession->HttpHeaders.HeadersIn.nLength);
+ // Projected free space after the completion of the receive
+ nProjectedfreeSpace = nCurrentfreeSpace - nProjectedHeaderLength;
+
+ // Check total size limit
+ if(nProjectedBufferLength > HTTP_CLIENT_MAX_SEND_RECV_HEADERS)
+ {
+ return HTTP_CLIENT_ERROR_NO_MEMORY;
+ }
+
+ if((INT32)nProjectedfreeSpace < 0)
+ {
+ if(HTTP_CLIENT_MEMORY_RESIZABLE == FALSE)
+ {
+ // Need more space but we can't grow beyond the current size
+ nRetCode = HTTP_CLIENT_ERROR_NO_MEMORY;
+ break;
+ }
+ else
+ {
+ // We can resizes so..
+ nRetCode = HTTPIntrnResizeBuffer(pHTTPSession,nProjectedBufferLength + HTTP_CLIENT_MEMORY_RESIZE_FACTOR);
+ if(nRetCode != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+ }
+ // Jump to the beginning of the incoming headers (just after the end of the outgoing headers)
+ pPtr = pHTTPSession->HttpHeaders.HeadersIn.pParam + pHTTPSession->HttpHeaders.HeadersIn.nLength;
+ // Read a single byte
+ nRetCode = HTTPIntrnRecv(pHTTPSession,pPtr,&nBytesRead,FALSE);
+
+ // ToDo: Break if not getting HTTP on the first 4 bytes
+
+ if(nRetCode == HTTP_CLIENT_SUCCESS && nBytesRead > 0)
+ {
+ // Advance the pointer by 1 byte
+ pPtr += nBytesRead;
+ // Increase the total receive length
+ pHTTPSession->HttpHeaders.HeadersIn.nLength++;
+
+ // Set the HTTP counters
+ pHTTPSession->HttpCounters.nRecivedHeaderLength++;
+
+ if(memcmp(pPtr - 4,HTTP_CLIENT_CRLFX2,4) == 0)
+ {
+ // Headers were received
+ break;
+ }
+ }
+ else
+ {
+ nRetCode = HTTP_CLIENT_ERROR_HEADER_RECV; // This was marked out for some reason
+ break;
+ }
+ }
+ }while(0);
+
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnGetRemoteHeaders",NULL,0,"Got %d bytes",pHTTPSession->HttpHeaders.HeadersIn.nLength);
+ }
+#endif
+
+ return nRetCode;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnHeadersFind
+// Purpose : Look for a header (insensitive search) by its name
+// Gets : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnHeadersFind (P_HTTP_SESSION pHTTPSession,CHAR *pHeaderName,
+ HTTP_PARAM *pParam, // [OUT] HTTP parameter structure that holds the search results
+ BOOL IncommingHeaders, // [IN] Indicate if we are to search in the incoming or outgoing headers
+ UINT32 nOffset) // [IN] Optionaly privide an offset to start looking from
+{
+ CHAR *pHeaderEnd;
+ CHAR Header[HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE]; // To-Do: Use pointers insted of fixed length
+ UINT32 nLength;
+ UINT32 nRetCode = HTTP_CLIENT_ERROR_HEADER_NOT_FOUND;
+
+ do
+ {
+ if(!pHTTPSession)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+
+ // Reset the input parameter structure
+ pParam->pParam = NULL;
+ pParam->nLength = 0;
+ // Get the requested header length
+ nLength = strlen(pHeaderName);
+ if(nLength > (HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE - 3))
+ {
+ // Error : header search clue too big
+ nRetCode = HTTP_CLIENT_ERROR_HEADER_BIG_CLUE;
+ break;
+ }
+ // Build the searched header name , add a leading CrLf before the header name and trailing ":"
+ memset(Header,0x00,HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE);
+ strcpy(Header,HTTP_CLIENT_CRLF);
+ strcat(Header,pHeaderName);
+ strcat(Header,":");
+ // Case insensitive search for the header name (search the incoming headers)
+ if(IncommingHeaders == TRUE)
+ {
+ pParam->pParam = HTTPStrCaseStr(pHTTPSession->HttpHeaders.HeadersIn.pParam + nOffset,
+ pHTTPSession->HttpHeaders.HeadersIn.nLength,
+ Header);
+ }
+ else
+ {
+ // Optionally search the outgoing headers
+ pParam->pParam = HTTPStrCaseStr(pHTTPSession->HttpHeaders.HeadersOut.pParam + nOffset,
+ pHTTPSession->HttpHeaders.HeadersOut.nLength,
+ Header);
+ }
+
+ if(pParam->pParam) // Did we find it?
+ {
+ // Search for the token end (trailing CrLf)
+ pHeaderEnd = strstr(pParam->pParam + 2,HTTP_CLIENT_CRLF);
+ if(pHeaderEnd)
+ {
+ // Get the length (up to the CrLf)
+ pParam->nLength = pHeaderEnd - pParam->pParam;
+ nRetCode = HTTP_CLIENT_SUCCESS;
+ break;
+
+ }
+ }
+ }while(0);
+
+ // Could not find the header
+ return nRetCode;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnAuthenticate
+// Purpose :
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnAuthenticate(P_HTTP_SESSION pHTTPSession)
+{
+ UINT32 nRetCode = HTTP_CLIENT_SUCCESS; // Function call return code
+ UINT32 nBytes = 32;
+ UINT32 nTotalBytes = 0;
+ CHAR ErrorPage[32];
+ BOOL NewConnection = FALSE;
+
+
+ do
+ {
+ // Validate the session pointer
+ if(!pHTTPSession)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+
+ // Handle connection close message (reconnect)
+ if(pHTTPSession->HttpHeadersInfo.Connection == FALSE)
+ {
+ // Gracefully close the connection and set the socket as invalid
+ if(pHTTPSession->HttpConnection.HttpSocket != HTTP_INVALID_SOCKET)
+ {
+ HTTPIntrnConnectionClose(pHTTPSession);
+ }
+ // Connect to the remote server (or proxy)
+ nRetCode = HTTPIntrnConnectionOpen(pHTTPSession);
+ if(nRetCode != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+
+ NewConnection = TRUE;
+ }
+
+ // Analyze the security headers and optionally build the authentication reply header
+ if((nRetCode = HTTPIntrnParseAuthHeader(pHTTPSession))!= HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // We have to recive any HTML data here inorder to "Clear" the socket buffer for later usage
+ // Note: We should skip this when the HEAD verb was used
+ while(NewConnection == FALSE && pHTTPSession->HttpHeaders.HttpLastVerb != VerbHead && pHTTPSession->HttpHeadersInfo.nHTTPContentLength > 0 && nBytes > 0)
+ {
+ ErrorPage[0] = 0;
+ if((nRetCode = HTTPIntrnRecv(pHTTPSession,ErrorPage,&nBytes,FALSE)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+
+ nTotalBytes += nBytes;
+ if(nTotalBytes >= pHTTPSession->HttpHeadersInfo.nHTTPContentLength)
+ {
+ break;
+ }
+ }
+
+ // Re-Send the headers after having analyzed the authorizaton headers
+ if((nRetCode = HTTPIntrnHeadersSend(pHTTPSession,pHTTPSession->HttpHeaders.HttpVerb)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+
+ }while(0);
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnAuthenticate",NULL,0,"");
+ }
+#endif
+
+ return nRetCode;
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnHeadersParse
+// Purpose : Parse the HTTP incoming headers.
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnHeadersParse (P_HTTP_SESSION pHTTPSession)
+{
+
+ CHAR *pPtr; // a pointer that points on the incoming headers
+ UINT32 nTokenLength = 0; // Length of the parsed token
+ UINT32 nRetCode = HTTP_CLIENT_SUCCESS; // a function return code value
+ UINT32 nOffset = 0; // Bytes offset (strings comperision)
+ CHAR HTTPToken[HTTP_CLIENT_MAX_TOKEN_LENGTH]; // Buffer for the parsed HTTP token
+ HTTP_PARAM HTTPParam; // A generic pointer\length parameter for parsing
+ BOOL AuthHeaders = FALSE; // While we are searching the authentication methods
+
+ do
+ {
+ // Validate the session pointer
+ if(!pHTTPSession)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnHeadersParse",pHTTPSession->HttpHeaders.HeadersIn.pParam,pHTTPSession->HttpHeaders.HeadersIn.nLength,"[Incomming Headers]");
+ }
+#endif
+
+
+ // Set a pointer on the incoming headers
+ pPtr = pHTTPSession->HttpHeaders.HeadersIn.pParam;
+
+ // Detect the leading HTTP string
+ if(HTTPStrInsensitiveCompare(pPtr,"http",4) != TRUE)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_BAD_HEADER;
+ break;
+ }
+
+ // Get the HTTP Version
+ while ((*pPtr) && (*pPtr != 0x20))
+ {
+ nTokenLength++;
+ pPtr++; // Move to the first space
+ }
+ strncpy(pHTTPSession->HttpHeadersInfo.HTTPVersion,
+ pPtr - nTokenLength,
+ MIN(15,nTokenLength));
+ pPtr++;
+
+ // Get the HTTP status code
+ memset(HTTPToken,0x00,HTTP_CLIENT_MAX_TOKEN_LENGTH);
+ nTokenLength = 0;
+ while ((*pPtr) && (*pPtr != 0x20))
+ {
+ nTokenLength++;
+ pPtr++; // Move to the next space
+ }
+ strncpy(HTTPToken,(pPtr - nTokenLength),MIN(HTTP_CLIENT_MAX_TOKEN_LENGTH,nTokenLength));
+
+ pHTTPSession->HttpHeadersInfo.nHTTPStatus = atol(HTTPToken);
+
+ // Search for content length
+ pHTTPSession->HttpHeadersInfo.nHTTPContentLength = 0; // Default no unknown length
+ // Look for the token
+ if(HTTPIntrnHeadersFind(pHTTPSession,"content-length",&HTTPParam,TRUE,0) == HTTP_CLIENT_SUCCESS)
+ {
+
+ memset(HTTPToken,0x00,HTTP_CLIENT_MAX_TOKEN_LENGTH); // Reset the token buffer
+ nTokenLength = HTTP_CLIENT_MAX_TOKEN_LENGTH; // Set the buffer length
+ // Attempt to extract the token
+ if(HTTPStrGetToken(HTTPParam.pParam,HTTPParam.nLength,HTTPToken,&nTokenLength))
+ {
+ // Convert the content-length into an integer.
+ pHTTPSession->HttpHeadersInfo.nHTTPContentLength = atol(HTTPToken);
+ }
+ }
+
+ // Search for connection status
+ pHTTPSession->HttpHeadersInfo.Connection = TRUE; // Default status where no server connection header was detected
+ // Look for token (can be standard connection or a proxy connection)
+ if( (HTTPIntrnHeadersFind(pHTTPSession,"connection",&HTTPParam,TRUE,0) == HTTP_CLIENT_SUCCESS) ||
+ (HTTPIntrnHeadersFind(pHTTPSession,"proxy-connection",&HTTPParam,TRUE,0) == HTTP_CLIENT_SUCCESS))
+ {
+
+ memset(HTTPToken,0x00,HTTP_CLIENT_MAX_TOKEN_LENGTH);
+ nTokenLength = HTTP_CLIENT_MAX_TOKEN_LENGTH;
+ // Attempt to extract the token
+ if(HTTPStrGetToken(HTTPParam.pParam,HTTPParam.nLength,HTTPToken,&nTokenLength))
+ {
+ // Is this a keep alive session?
+ pHTTPSession->HttpHeadersInfo.Connection = HTTPStrInsensitiveCompare(HTTPToken,"keep-alive",0);
+ // Is it a closed session
+ if(HTTPStrInsensitiveCompare(HTTPToken,"close",0) == TRUE)
+ {
+ pHTTPSession->HttpHeadersInfo.Connection = FALSE;
+ }
+ }
+ }
+
+ // Search for chunking mode transfer
+ pHTTPSession->HttpFlags = pHTTPSession->HttpFlags &~ HTTP_CLIENT_FLAG_CHUNKED; // Remove the flag
+ if(HTTPIntrnHeadersFind(pHTTPSession,"transfer-encoding",&HTTPParam,TRUE,0) == HTTP_CLIENT_SUCCESS)
+ {
+
+ memset(HTTPToken,0x00,HTTP_CLIENT_MAX_TOKEN_LENGTH);
+ nTokenLength = HTTP_CLIENT_MAX_TOKEN_LENGTH;
+ if(HTTPStrGetToken(HTTPParam.pParam,HTTPParam.nLength,HTTPToken,&nTokenLength))
+ {
+ // If the chunks token was find then set the session flag accordingly
+ if(HTTPStrInsensitiveCompare(HTTPToken,"chunked",0) == TRUE)
+ {
+ pHTTPSession->HttpFlags = pHTTPSession->HttpFlags | HTTP_CLIENT_FLAG_CHUNKED;
+ }
+ }
+ }
+ // Look for the authentication header
+ while(AuthHeaders == FALSE) // address multiple authentication methods presented by the server
+ {
+ if(pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_UNAUTHORIZED)
+ {
+ // Double check for the "www-authenticate" header token
+ if(HTTPIntrnHeadersFind(pHTTPSession,"www-authenticate",&pHTTPSession->HttpAuthHeader.AuthHeader,TRUE,nOffset) != HTTP_CLIENT_SUCCESS)
+ {
+ if(nOffset > 0) // an authentication header was found but not the right one so adjust the error
+ {
+ nRetCode = HTTP_CLIENT_ERROR_AUTH_MISMATCH;
+ }
+ else
+ {
+ nRetCode = HTTP_CLIENT_ERROR_BAD_HEADER;
+ }
+
+ break;
+ }
+
+ // Make sure that we get an authentication header that maches the caller requested schema
+ pPtr = HTTPStrCaseStr(pHTTPSession->HttpAuthHeader.AuthHeader.pParam,
+ pHTTPSession->HttpAuthHeader.AuthHeader.nLength,
+ pHTTPSession->HttpCredentials.AuthSchemaName);
+ if(pPtr)
+ {
+ AuthHeaders = TRUE;
+ }
+ else
+ {
+ // Simply pass the point where the last "www" was found
+ nOffset = (pHTTPSession->HttpAuthHeader.AuthHeader.pParam - pHTTPSession->HttpHeaders.HeadersIn.pParam) + 3;
+ }
+ }
+ else
+ {
+ AuthHeaders = TRUE;
+ }
+ }
+
+ // Is this a proxy authentication header?
+ if(pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED)
+ {
+ // Double check for the "Proxy-Authentication" header token
+ if (HTTPIntrnHeadersFind(pHTTPSession,"proxy-authenticate",&pHTTPSession->HttpAuthHeader.AuthHeader,TRUE,0) != HTTP_CLIENT_SUCCESS)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_BAD_HEADER;
+ break;
+ }
+ }
+
+ // Do we have a redirection response?
+ if( (pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_OBJECT_MOVED) ||
+ (pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_OBJECT_MOVED_PERMANENTLY))
+ {
+ // Check for the "Location" header token
+ if (HTTPIntrnHeadersFind(pHTTPSession,"location",&pHTTPSession->HttpHeadersInfo.HttpRedirectURL,TRUE,0) != HTTP_CLIENT_SUCCESS)
+ {
+ // Protocol violation, we got a redirect code without the host name to redirect to
+ nRetCode = HTTP_CLIENT_ERROR_BAD_HEADER;
+ break;
+ }
+ // Fix the pointers location (address the "Location: " prefix)
+ pHTTPSession->HttpHeadersInfo.HttpRedirectURL.pParam += 12;
+ pHTTPSession->HttpHeadersInfo.HttpRedirectURL.nLength -= 12;
+
+ }
+
+ }while(0);
+
+
+ return nRetCode;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnParseAuthHeader
+// Purpose : Parse the HTTP headers for the required authentication method
+// Gets :
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnParseAuthHeader(P_HTTP_SESSION pHTTPSession)
+{
+
+ CHAR *pPtrStart, *pPtrEnd;
+
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ if(pHTTPSession->HttpProxy.ProxyAuthSchema != AuthSchemaNone)
+ {
+ // for proxy authentication simply assume basic and exit
+ return HTTP_CLIENT_SUCCESS;
+ }
+ // Advance the pointer in the string and break on the first space
+ pPtrEnd = pHTTPSession->HttpAuthHeader.AuthHeader.pParam + pHTTPSession->HttpAuthHeader.AuthHeader.nLength;
+ pPtrStart = pHTTPSession->HttpAuthHeader.AuthHeader.pParam;
+ // Jump to the first space
+ while ((pPtrEnd - pPtrStart) > 0 && *pPtrStart != 0x20) pPtrStart++;
+
+ do
+ {
+ if(HTTPStrCaseStr(pPtrStart,8,"basic"))
+ {
+ pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA = AuthSchemaBasic;
+ break;
+ }
+
+ if(HTTPStrCaseStr(pPtrStart,8,"digest"))
+ {
+ pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA = AuthSchemaDigest;
+ break;
+ }
+ if(HTTPStrCaseStr(pPtrStart,8,"negotiate")) // Note that this could be NLM negotiation as well (which is not supported)
+ {
+ pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA = AuthSchemaKerberos;
+ break;
+ }
+ // To-Do: Add any other supported authentication method
+ }
+ while(0);
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnParseAuthHeader",pHTTPSession->HttpAuthHeader.AuthHeader.pParam,
+ pHTTPSession->HttpAuthHeader.AuthHeader.nLength,"[Incomming Auth Headers: %d]",pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA);
+ }
+#endif
+
+ // If we could not detect the authentication schema return an error
+ if(pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA == AuthSchemaNone)
+ {
+ return HTTP_CLIENT_ERROR_BAD_AUTH;
+ }
+
+ //Make sure we are going to authenticate with the method specified by the caller
+ if(pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA != (UINT32)pHTTPSession->HttpCredentials.CredAuthSchema)
+ {
+ return HTTP_CLIENT_ERROR_AUTH_MISMATCH;
+ }
+
+
+ return HTTP_CLIENT_SUCCESS;
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnHeadersSend
+// Purpose : Build and send the HTTP request. this includes the HTTP headers
+// and any required authentication data
+// Gets :
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnHeadersSend(P_HTTP_SESSION pHTTPSession,
+ HTTP_VERB HttpVerb) // [IN] Argument that can bypass the requested verb
+ // Can be used for evaluating a HEAD request
+{
+
+ UINT32 nBytes;
+ UINT32 nRetCode = HTTP_CLIENT_SUCCESS;
+ CHAR RequestCmd[16];
+ CHAR ContentLength[32];
+ BOOL RestoreHeadersFlag = FALSE;
+ HTTP_VERB HttpCachedVerb;
+ CHAR *pPtr; // Content length conversion
+
+ if(!pHTTPSession)
+ {
+ // Bad session pointer error
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnHeadersSend",NULL,
+ 0,"Using Verb: %d",(INT32)HttpVerb);
+ }
+#endif
+ // Cache the original VERB
+ HttpCachedVerb = pHTTPSession->HttpHeaders.HttpVerb;
+
+ do
+ {
+
+ // Set the verb (temporarily)
+ if(pHTTPSession->HttpHeaders.HttpVerb != HttpVerb)
+ {
+ if((nRetCode = HTTPClientSetVerb((HTTP_SESSION_HANDLE)pHTTPSession,HttpVerb)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+
+ // Remeber this state for later usage
+ pHTTPSession->HttpHeaders.HttpLastVerb = pHTTPSession->HttpHeaders.HttpVerb;
+
+ // If this is a head request we should temporary remove the chunking header and the content length header
+ if(pHTTPSession->HttpHeaders.HttpVerb == VerbHead)
+ {
+
+ // If send in chunks flag was set
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SEND_CHUNKED) == HTTP_CLIENT_FLAG_SEND_CHUNKED)
+ {
+ // Chunking
+ if((nRetCode = HTTPIntrnHeadersRemove(pHTTPSession,"Transfer-Encoding")) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+ // Content-Length
+ if(pHTTPSession->HttpHeadersInfo.nHTTPPostContentLength > 0) // Attempt to remove only if it was previusly set
+ {
+ if((nRetCode = HTTPIntrnHeadersRemove(pHTTPSession,"Content-Length")) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+
+ RestoreHeadersFlag = TRUE; // So it would be restored later
+ }
+ // Request Verb
+ nBytes = strlen(pHTTPSession->HttpHeaders.Verb) + 1;
+ memset(RequestCmd,0x00,16);
+ strcpy(RequestCmd,pHTTPSession->HttpHeaders.Verb);
+ strcat(RequestCmd," ");
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,RequestCmd,&nBytes)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes;
+
+
+ // Request URI
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_USINGPROXY) != HTTP_CLIENT_FLAG_USINGPROXY)
+ {
+ nBytes = pHTTPSession->HttpUrl.UrlRequest.nLength;
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,pHTTPSession->HttpUrl.UrlRequest.pParam,&nBytes)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes;
+ }
+ else
+ {
+ nBytes = strlen(pHTTPSession->HttpUrl.Url);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,pHTTPSession->HttpUrl.Url,&nBytes)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes;
+ }
+ // Request HTTP Version
+ memset(RequestCmd,0x00,16);
+ strcpy(RequestCmd," ");
+ strcat(RequestCmd,HTTP_CLIENT_DEFAULT_VER);
+ strcat(RequestCmd,HTTP_CLIENT_CRLF);
+ nBytes = strlen(RequestCmd);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,RequestCmd,&nBytes)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes;
+
+ // Request headers
+ nBytes = pHTTPSession->HttpHeaders.HeadersOut.nLength;
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,pHTTPSession->HttpHeaders.HeadersOut.pParam,&nBytes)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes;
+
+ // Optionally add authentication headers and send them (for host or proxy authentication)
+ if(pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_UNAUTHORIZED || pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED )
+ {
+
+ if((nRetCode = HTTPIntrnAuthHandler(pHTTPSession)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+
+ // Request terminating CrLf
+ nBytes = strlen(HTTP_CLIENT_CRLF);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,HTTP_CLIENT_CRLF,&nBytes)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes;
+
+ // Restore the verb
+ if(pHTTPSession->HttpHeaders.HttpVerb != HttpCachedVerb)
+ {
+ if((nRetCode = HTTPClientSetVerb((HTTP_SESSION_HANDLE)pHTTPSession,HttpCachedVerb)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+
+ if(RestoreHeadersFlag == TRUE)
+ {
+ // Restore chunking header (since it was temporarily removed for the head request
+ // Add the Transfer-Encoding: header
+ if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SEND_CHUNKED) == HTTP_CLIENT_FLAG_SEND_CHUNKED)
+ {
+ if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Transfer-Encoding",17,"chunked",7))!= HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ }
+ // Restore the content length
+ if(pHTTPSession->HttpHeadersInfo.nHTTPPostContentLength > 0) // Attempt to remove only if it was previusly set
+ {
+ pPtr = IToA(ContentLength,pHTTPSession->HttpHeadersInfo.nHTTPPostContentLength); // Convert the buffer length to a string value
+ if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Content-Length",14,ContentLength,strlen(ContentLength)))!= HTTP_CLIENT_SUCCESS)
+ {
+ return nRetCode;
+ }
+ }
+ }
+ // Set the session stage
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_REQUEST_SENT;
+
+ } while(0);
+
+
+ return nRetCode; // end of HTTPIntrnSendHeaders()
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnAuthHandler
+// Purpose : Differentiate between the authenticate method that we have to implement and perform
+// the required operation.
+// Gets :
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnAuthHandler (P_HTTP_SESSION pHTTPSession)
+{
+
+ UINT32 nRetCode = HTTP_CLIENT_SUCCESS;
+
+ if(!pHTTPSession)
+ {
+ // Bad session pointer error
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ if(pHTTPSession->HttpProxy.ProxyAuthSchema != AuthSchemaNone)
+ {
+ // For proxy authentication simply assume basic and exit
+ // Basic authentication
+ nRetCode = HTTPIntrnAuthSendBasic(pHTTPSession);
+ return nRetCode;
+ }
+
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnAuthHandler",NULL,
+ 0,"");
+ }
+#endif
+
+ // Use the correct authentication method as requested by the server
+ switch(pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA)
+ {
+
+ case AuthSchemaBasic:
+ {
+ // Basic authentication
+ nRetCode = HTTPIntrnAuthSendBasic(pHTTPSession);
+ break;
+
+ }
+ case AuthSchemaDigest:
+ {
+ // Digest authentication
+ nRetCode = HTTPIntrnAuthSendDigest(pHTTPSession);
+ break;
+
+ }
+ case AuthSchemaKerberos:
+ {
+ // ToDo: impliament the Kerberos nego authentication here
+ nRetCode = HTTP_CLIENT_ERROR_NOT_IMPLEMENTED;
+ break;
+
+ }
+ default:
+ {
+ // Not supported method
+ return HTTP_CLIENT_ERROR_BAD_AUTH; // Not implemented error
+ }
+
+ };
+
+ // This session requested an authentication so..
+ pHTTPSession->HttpCredentials.Authentication = TRUE;
+ return nRetCode;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnAuthSendBasic
+// Purpose : Handle basic authentication for direst host connection and proxy authentication
+// Gets :
+// Returns :
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+
+static UINT32 HTTPIntrnAuthSendBasic (P_HTTP_SESSION pHTTPSession)
+{
+
+ UINT32 nSegmentLength;
+ UINT32 nRetCode;
+ CHAR Cred[HTTP_CLIENT_MAX_64_ENCODED_CRED /2]; // Credentials (Clear)
+ CHAR Cred64[HTTP_CLIENT_MAX_64_ENCODED_CRED]; // Credentials (64 bit encoded)
+ UINT32 nSrcLength, nDestLength;
+ CHAR* pPtr;
+ CHAR* INITIAL_HDR = "Authorization: Basic ";
+ CHAR* INITIAL_PROXY_HDR = "Proxy-Authorization: Basic ";
+
+
+ do
+ {
+ if(!pHTTPSession)
+ {
+ nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ break;
+ }
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnAuthSendBasic",NULL,
+ 0,"");
+ }
+#endif
+
+ memset(Cred,0x00,HTTP_CLIENT_MAX_64_ENCODED_CRED /2);
+ memset(Cred64,0x00,HTTP_CLIENT_MAX_64_ENCODED_CRED);
+
+
+ switch (pHTTPSession->HttpHeadersInfo.nHTTPStatus)
+ {
+ case( HTTP_STATUS_UNAUTHORIZED): // For host authentication
+ {
+
+ // Copy the clear text credentials to a format of user:password
+ strcpy(Cred,pHTTPSession->HttpCredentials.CredUser);
+ strcat(Cred,":");
+ strcat(Cred,pHTTPSession->HttpCredentials.CredPassword);
+ nSrcLength = strlen(Cred);
+ nDestLength = HTTP_CLIENT_MAX_64_ENCODED_CRED;
+ nSegmentLength = strlen(INITIAL_HDR);
+ // Build and send the data first the hard-coded static portion
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,INITIAL_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+ // Convert to base 64
+ HTTPBase64Encoder((unsigned char *)Cred64,(CONST unsigned char *)Cred,nSrcLength);
+ nDestLength = strlen(Cred64);
+
+ };
+ break;
+ case (HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED): // For Proxy authentication
+ {
+ // Copy the clear text credentials to a format of user:password
+ strcpy(Cred,pHTTPSession->HttpProxy.ProxtUser);
+ strcat(Cred,":");
+ strcat(Cred,pHTTPSession->HttpProxy.ProxyPassword);
+ nSrcLength = strlen(Cred);
+ nDestLength = HTTP_CLIENT_MAX_64_ENCODED_CRED;
+
+ // Convert to base 64
+ HTTPBase64Encoder((unsigned char *)Cred64,(unsigned char *)Cred,nSrcLength);
+ nDestLength = strlen(Cred64);
+ nSegmentLength = strlen(INITIAL_PROXY_HDR);
+ // Build and send the data first the hard-coded static portion
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,INITIAL_PROXY_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+ };
+ break;
+ default:
+ {
+ return HTTP_CLIENT_ERROR_BAD_AUTH; // Wrong status for this function
+ };
+ };
+
+ // Send the base 64 encoded data
+ pPtr = Cred64;
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,pPtr, &nDestLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nDestLength;
+
+ // Terminating CRLF
+ nSegmentLength = strlen(HTTP_CLIENT_CRLF);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,HTTP_CLIENT_CRLF, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+
+ } while (0);
+
+ return nRetCode;
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnAuthSendDigest
+// Purpose : Handle digest authentication for direct host connection and proxy authentication
+// Gets :
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnAuthSendDigest (P_HTTP_SESSION pHTTPSession)
+{
+ CHAR Cnonce[33];
+ UINT32 nSegmentLength;
+ UINT32 nRetCode;
+ UINT32 nAlgType = 0; // a flag for the algorithem type (default to MD5)
+ HTTP_PARAM HttpParamOpq,HttpParamRealm,HttpParamNonce,HttpParamQop,HttpParamAlg; // Pointers and lengths of the dynamic sections
+ // of the Digest response.
+
+
+ // Fragments of the Digest client response (The hard coded text portion of the response)
+ CHAR* INITIAL_HDR = "Authorization: Digest username=\"";
+ CHAR* INITIAL_PROXY_HDR = "Proxy-Authorization: Digest username=\"";
+ CHAR* REALEM_HDR = "\", realm=\"";
+ CHAR* QOP_HDR = "\", qop=\"";
+ CHAR* ALGO_HDR = "\", algorithm=\"";
+ CHAR* URI_HDR = "\", uri=\"";
+ CHAR* NONCE_HDR = "\", nonce=\"";
+ CHAR* NC_HDR = "\", nc=00000001, cnonce=\""; // To-Do: This should be tested!!
+ CHAR* RSP_HDR = "\", response=\"";
+ CHAR* OPQ_HDR = "\", opaque=\"";
+ // Digest Calculation related
+ HASHHEX HA1;
+ HASHHEX HA2 = "";
+ HASHHEX Response;
+
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnAuthSendDigest",NULL,
+ 0,"");
+ }
+#endif
+
+ // Generate random Cnonce number
+ HTTPDigestGenerateCNonce(Cnonce);
+
+ switch (pHTTPSession->HttpHeadersInfo.nHTTPStatus)
+ {
+ case( HTTP_STATUS_UNAUTHORIZED): // For host authentication
+ {
+ // "Authorization: Digest username="
+ nSegmentLength = strlen(INITIAL_HDR);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,INITIAL_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ return nRetCode;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+ };
+ break;
+ case (HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED): // For Proxy authentication
+ {
+ // "Proxy-Authorization: Digest username="
+ nSegmentLength = strlen(INITIAL_PROXY_HDR);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,INITIAL_PROXY_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ return nRetCode;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+ };
+ break;
+ default:
+ {
+ return HTTP_CLIENT_ERROR_BAD_AUTH; // Wrong status for this function
+ };
+ };
+
+ do
+ {
+
+ // "Authorization: Digest username="username
+ nSegmentLength = strlen(pHTTPSession->HttpCredentials.CredUser);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,pHTTPSession->HttpCredentials.CredUser, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+ // "Authorization: Digest username="username", realm="
+ nSegmentLength = strlen(REALEM_HDR);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,REALEM_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+ // "Authorization: Digest username="username", realm="realm
+ if((nRetCode = HTTPStrGetDigestToken(pHTTPSession->HttpAuthHeader.AuthHeader,"realm", &HttpParamRealm)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,HttpParamRealm.pParam, &HttpParamRealm.nLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += HttpParamRealm.nLength;
+
+ // "Authorization: Digest username="username", realm="myRealm", qop="auth",
+ nSegmentLength = strlen(QOP_HDR);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,QOP_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+ if((nRetCode = HTTPStrGetDigestToken(pHTTPSession->HttpAuthHeader.AuthHeader,"qop", &HttpParamQop)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,HttpParamQop.pParam, &HttpParamQop.nLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += HttpParamQop.nLength;
+
+ // "Authorization: Digest username="username", realm="myRealm", qop="auth",
+ // algorithm="MD5",
+
+ nSegmentLength = strlen(ALGO_HDR);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,ALGO_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+ if((nRetCode = HTTPStrGetDigestToken(pHTTPSession->HttpAuthHeader.AuthHeader,"algorithm", &HttpParamAlg)) != HTTP_CLIENT_SUCCESS)
+ {
+
+ // The server did not state its required algorithm so use the default
+ HttpParamAlg.pParam = HTTP_CLIENT_DEFAULT_DIGEST_AUTH;
+ HttpParamAlg.nLength = strlen(HTTP_CLIENT_DEFAULT_DIGEST_AUTH);
+ }
+ // Get the algorithem type
+ if(HTTPStrInsensitiveCompare(HttpParamAlg.pParam ,"md5",3 ) == TRUE)
+ {
+ if(HTTPStrInsensitiveCompare(HttpParamAlg.pParam ,"md5-sess", HttpParamAlg.nLength) == TRUE)
+ {
+ nAlgType = 1;
+ }
+
+ }
+ else
+ {
+ // Error algorithem not supported
+ nRetCode = HTTP_CLIENT_ERROR_NO_DIGEST_ALG;
+ break;
+ }
+
+ // Send the algorithem
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,HttpParamAlg.pParam, &HttpParamAlg.nLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += HttpParamAlg.nLength;
+
+
+ // "Authorization: Digest username="username", realm="myRealm", qop="auth",
+ // algorithm="MD5", uri="
+ nSegmentLength = strlen(URI_HDR);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,URI_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+
+ // "Authorization: Digest username="username", realm="myRealm", qop="auth",
+ // algorithm="MD5", uri="/....Service
+ nSegmentLength = strlen(pHTTPSession->HttpUrl.UrlRequest.pParam);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,pHTTPSession->HttpUrl.UrlRequest.pParam, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+
+ // "Authorization: Digest username="username", realm="myRealm", qop="auth",
+ // algorithm="MD5", uri="/....Service", nonce="
+ nSegmentLength = strlen(NONCE_HDR);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,NONCE_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+
+ // "Authorization: Digest username="username", realm="myRealm", qop="auth",
+ // algorithm="MD5", uri="/....Service", nonce="7a5c...
+ if((nRetCode = HTTPStrGetDigestToken(pHTTPSession->HttpAuthHeader.AuthHeader,"nonce", &HttpParamNonce)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,HttpParamNonce.pParam, &HttpParamNonce.nLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += HttpParamNonce.nLength;
+
+ // "Authorization: Digest username="username", realm="myRealm", qop="auth",
+ // algorithm="MD5", uri="/....Service", nonce="7a5c...", nc=00000001, cnonce="
+ nSegmentLength = strlen(NC_HDR);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,NC_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+ // "Authorization: Digest username="username", realm="myRealm", qop="auth",
+ // algorithm="MD5", uri="/....Service", nonce="7a5c...", nc=00000001, cnonce="ab341...
+ nSegmentLength = strlen(Cnonce);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,Cnonce, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+ // Send the opaque data if we got it from the server
+ if((nRetCode = HTTPStrGetDigestToken(pHTTPSession->HttpAuthHeader.AuthHeader,"opaque", &HttpParamOpq)) == HTTP_CLIENT_SUCCESS)
+ {
+
+ nSegmentLength = strlen(OPQ_HDR);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,OPQ_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,HttpParamOpq.pParam, &HttpParamOpq.nLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += HttpParamOpq.nLength;
+
+ }
+
+ // "Authorization: Digest username="username", realm="myRealm", qop="auth",
+ // algorithm="MD5", uri="/....Service", nonce="7a5c...", nc=00000001, cnonce="ab341...", response="
+ nSegmentLength = strlen(RSP_HDR);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,RSP_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+ // Calculate response
+ HTTPDigestCalcHA1(nAlgType, pHTTPSession->HttpCredentials.CredUser,
+ HttpParamRealm.pParam,HttpParamRealm.nLength ,
+ pHTTPSession->HttpCredentials.CredPassword ,
+ HttpParamNonce.pParam, HttpParamNonce.nLength,
+ Cnonce, HA1);
+
+ HTTPDigestCalcResponse(HA1,
+ HttpParamNonce.pParam, HttpParamNonce.nLength,
+ "00000001", Cnonce,
+ HttpParamQop.pParam,HttpParamQop.nLength, pHTTPSession->HttpHeaders.Verb,
+ pHTTPSession->HttpUrl.UrlRequest.pParam,pHTTPSession->HttpUrl.UrlRequest.nLength,
+ HA2, Response);
+
+ // "Authorization: Digest username="username", realm="myRealm", qop="auth",
+ // algorithm="MD5", uri="/....Service", nonce="7a5c...", nc=00000001, cnonce="ab341...", response="8bbf2...
+ nSegmentLength = strlen(Response);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,Response, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+
+ // Terminate 0x24 (")
+ nSegmentLength = 1;
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,"\"", &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+ // Terminating CRLF
+ nSegmentLength = strlen(HTTP_CLIENT_CRLF);
+ if((nRetCode = HTTPIntrnSend(pHTTPSession,HTTP_CLIENT_CRLF, &nSegmentLength)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+ // Set the counters
+ pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength;
+
+ } while(0);
+
+ return nRetCode; // End of digest respobse sending
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnSessionReset
+// Purpose : Reset the session data for the next operation
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnSessionReset (P_HTTP_SESSION pHTTPSession, BOOL EntireSession)
+{
+ UINT32 nActionTimeout; // For restoring a parameter after this reset
+ UINT32 nAllocationSize;
+
+ // Validate the pointer
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ pHTTPSession->pDebug("HTTPIntrnSessionReset",NULL,
+ 0,"");
+ }
+#endif
+
+
+ memset(pHTTPSession->HttpHeaders.HeadersIn.pParam,0x00,pHTTPSession->HttpHeaders.HeadersIn.nLength);
+ pHTTPSession->HttpHeaders.HeadersIn.nLength = 0;
+
+
+ // Reset the HTTP counters
+ nActionTimeout = pHTTPSession->HttpCounters.nActionTimeout;
+ memset(&pHTTPSession->HttpCounters,0x00,sizeof(HTTP_COUNTERS));
+ pHTTPSession->HttpCounters.nActionStartTime = HTTPIntrnSessionGetUpTime();
+ // Restore the parameter
+ pHTTPSession->HttpCounters.nActionTimeout = nActionTimeout;
+ // Reset the authentication flag
+ pHTTPSession->HttpCredentials.Authentication = FALSE;
+
+
+ if(EntireSession == TRUE) // Partial reset, clear only the incoming headers
+ {
+ memset(&pHTTPSession->HttpUrl,0,sizeof(HTTP_URL));
+ nAllocationSize = pHTTPSession->HttpHeaders.HeadersBuffer.nLength;
+ // Reset the headers allocated memory
+ memset(pHTTPSession->HttpHeaders.HeadersBuffer.pParam ,0x00,nAllocationSize);
+
+ // Set default values in the session structure
+ HTTPClientSetVerb((UINT32)pHTTPSession,(HTTP_VERB)HTTP_CLIENT_DEFAULT_VERB); // Default HTTP verb
+ pHTTPSession->HttpUrl.nPort = HTTP_CLIENT_DEFAULT_PORT; // Default TCP port
+ // Set the outgoing headers pointers
+ memset(&pHTTPSession->HttpHeaders.HeadersIn,0,sizeof(HTTP_PARAM));
+ memset(&pHTTPSession->HttpHeaders.HeadersOut,0,sizeof(HTTP_PARAM));
+
+ pHTTPSession->HttpHeaders.HeadersOut.pParam = pHTTPSession->HttpHeaders.HeadersBuffer.pParam;
+ // Set our state
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_INIT;
+
+ memset(&pHTTPSession->HttpHeadersInfo,0,sizeof(HTTP_HEADERS_INFO));
+ if(pHTTPSession->HttpConnection.HttpSocket != HTTP_INVALID_SOCKET)
+ {
+ pHTTPSession->HttpHeadersInfo.Connection = TRUE;
+ }
+ memset(&pHTTPSession->HttpAuthHeader,0,sizeof(HTTP_AUTH_HEADER));
+ memset(&pHTTPSession->HttpProxy,0,sizeof(HTTP_PROXY));
+
+ }
+
+ return HTTP_CLIENT_SUCCESS;
+
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnHeadersReceive
+// Purpose : Receives the response header on the connection and parses it.
+// Performs any required authentication.
+// Returns : HTTP Status
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnHeadersReceive (P_HTTP_SESSION pHTTPSession,
+ UINT32 nTimeout) // [IN] Timeout for the operation
+
+{
+
+ UINT32 nRetCode; // Function call return code
+ UINT32 nCount = 0;
+ if(!pHTTPSession)
+ {
+ // Bad session pointer error
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ do
+ {
+
+
+ // Set the operation time out if was set by the caller
+ if(nTimeout > 0)
+ {
+ // 0 makes us use the default defined value
+ pHTTPSession->HttpCounters.nActionTimeout = HTTP_TIMEOUT(nTimeout);
+
+ }
+
+ // Reset the incoming headers
+ if((nRetCode = HTTPIntrnSessionReset(pHTTPSession,FALSE)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+
+ // Get the server response
+ if((nRetCode = HTTPIntrnGetRemoteHeaders(pHTTPSession)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+
+ // Set the session state
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HEADERS_RECIVED;
+
+ // Parse the response headers
+ if((nRetCode = HTTPIntrnHeadersParse(pHTTPSession)) != HTTP_CLIENT_SUCCESS)
+ {
+ break;
+ }
+
+ // Set the session state
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HEADERS_PARSED;
+
+ // Set the session stage upon seccess
+ if(pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_OK)
+ {
+ pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HEADERS_OK;
+ }
+ // Handle 100 continue message
+ if(pHTTPSession->HttpHeadersInfo.nHTTPStatus != HTTP_STATUS_CONTINUE)
+ {
+ nCount++;
+ }
+
+#ifdef _HTTP_DEBUGGING_
+ if(pHTTPSession->pDebug)
+ {
+ if(pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_CONTINUE)
+ {
+ pHTTPSession->pDebug("HTTPIntrnHeadersReceive",NULL,0,"100 Continue Header");
+ }
+ }
+#endif
+
+ }while(nCount < 1);
+
+ return nRetCode;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnGetTicks
+// Purpose : Like GetTickCount() (implemented with time.h)
+// Gets : void
+// Returns : System ticks
+// Last updated : 01/09/200515/05/2005
+// Author Name : Eitan Michaelson
+// Notes : Assuming 1000 ticks per sec, should be implemented by the OS
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static UINT32 HTTPIntrnSessionGetUpTime(VOID)
+{
+
+ return GetUpTime();
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPIntrnSessionEvalTimeout
+// Purpose : Check if we have to break the operation and return a time out error
+// Gets : a pointer to the session structure
+// Returns : BOOL, True if we have to break
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+static BOOL HTTPIntrnSessionEvalTimeout(P_HTTP_SESSION pHTTPSession)
+{
+
+ UINT32 nElapsedTime; // Integer for calculating the elapsed time
+
+ // Validate the session pointer
+ if(!pHTTPSession)
+ {
+ return HTTP_CLIENT_ERROR_INVALID_HANDLE;
+ }
+
+ // Calculate the elapsed time since the last call
+ nElapsedTime = HTTPIntrnSessionGetUpTime() - pHTTPSession->HttpCounters.nActionStartTime;
+ // If the elapsed time is greater then the time out value we should return true
+ if(nElapsedTime >= pHTTPSession->HttpCounters.nActionTimeout)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClient.h b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClient.h
new file mode 100644
index 000000000..fac290ae1
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClient.h
@@ -0,0 +1,306 @@
+
+#ifndef _HTTP_CLIENT
+#define _HTTP_CLIENT
+
+#include "HTTPClientWrapper.h"
+#include "HTTPClientCommon.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////////
+ //
+ // Section : HTTP API global definitions
+ // Last updated : 01/09/2005
+ //
+ ///////////////////////////////////////////////////////////////////////////////
+#ifdef _HTTP_BUILD_AMT
+#define CMSI_HTTPCLIENT_PROTOCOL_GUID {0x471b2c0e, 0x6137, 0x4d55, 0x92, 0x36, 0xdd, 0x0f, 0xdb, 0xc2, 0x52, 0xfb}
+#endif
+
+ // Debug hook
+ // #define _HTTP_DEBUGGING_ // Simply dumps more debugging data to the console
+
+ // API Version
+#define HTTP_CLIENT_VERSION_MINOR 0
+#define HTTP_CLIENT_VERSION_MAJOR 1
+
+ // Global default sizes
+#define HTTP_CLIENT_MAX_SEND_RECV_HEADERS 1024 // Maximum Send and receive buffers size
+#define HTTP_CLIENT_INIT_SEND_RECV_HEADERS 2048 // If we can resize the buffers this would be the initial size
+
+#define HTTP_CLIENT_MAX_USERNAME_LENGTH 16 // Maximum length the user name (host and proxy authentication)
+#define HTTP_CLIENT_MAX_PASSWORD_LENGTH 16 // Maximum length for the password
+ // Maximum length for the base 64 encoded credentials (twice the size of the user name and password max parameters)
+#define HTTP_CLIENT_MAX_64_ENCODED_CRED ((HTTP_CLIENT_MAX_USERNAME_LENGTH + HTTP_CLIENT_MAX_PASSWORD_LENGTH) * 2) + 4
+#define HTTP_CLIENT_MAX_CHUNK_HEADER 64 // Maximum length for the received chunk header (hex - string) size
+#define HTTP_CLIENT_MAX_PROXY_HOST_LENGTH 64 // Maximum length for the proxy host name
+#define HTTP_CLIENT_MAX_TOKEN_LENGTH 512 // Maximum length for an HTTP token data (authentication header elements)
+#define HTTP_CLIENT_MAX_TOKEN_NAME_LENGTH 32 // Maximum length for an HTTP authorization token name ("qop")
+#define HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE 1024 // Maximum length for a search clue string (Headers searching)
+#define HTTP_CLIENT_ALLOW_HEAD_VERB 0 // Can we use the HTTP HEAD verb in our outgoing requests?
+
+#define HTTP_CLIENT_MEMORY_RESIZABLE FALSE // Permission to dynamically resize the headers buffer
+#define HTTP_CLIENT_MEMORY_RESIZE_FACTOR 16 // Factor for memory resizing operation
+
+#define HTTP_CLIENT_DEFAULT_PORT 80 // Default HTTP port
+#define HTTP_CLIENT_DEFAULT_SSL_PORT 443 // Default HTTPS port
+#define HTTP_CLIENT_DEFAULT_VERB 0 // GET
+#define HTTP_CLIENT_DEFAULT_VER "HTTP/1.1" // We will send this in the outgoing header
+#define HTTP_CLIENT_DEFAULT_PROXY_VER "HTTP/1.0" // We will send this in the outgoing header (proxy)
+#define HTTP_CLIENT_DEFAULT_AGENT "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)"
+#define HTTP_CLIENT_DEFAULT_TIMEOUT 30 // Default timeout in seconds
+#define HTTP_CLIENT_DEFAULT_KEEP_ALIVE 30 // Default Keep-alive value in seconds
+#define HTTP_CLIENT_DEFAULT_DIGEST_AUTH "MD5" // This is for bypassing a known bug in AMT05..
+#define HTTP_CLIENT_DEFAULT_PROXY_AUTH 1 // Basic
+
+#define HTTP_CLIENT_CRLF "\r\n" // End of line macro
+#define HTTP_CLIENT_CRLFX2 "\r\n\r\n" // Double End of line macro
+
+ // HTTP Session internal API flags
+ // Note: Not intended to be set the by the API user
+#define HTTP_CLIENT_FLAG_SECURE 0x00000010 // The session is secured using TLS
+#define HTTP_CLIENT_FLAG_URLANDPORT 0x00000020 // Url has a port within
+#define HTTP_CLIENT_FLAG_URLHTTPS 0x00000040 // Url has a https prefix
+#define HTTP_CLIENT_FLAG_USINGPROXY 0x00000080 // Operation will be performed using a proxy server
+#define HTTP_CLIENT_FLAG_CHUNKED 0x00000100 // The incoming data is chunked
+
+ // HTTP Status codes
+#define HTTP_STATUS_OK 200 // The request has succeeded
+#define HTTP_STATUS_UNAUTHORIZED 401 // The request requires user authentic
+#define HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED 407 // The client must first authenticate itself with the proxy
+
+ // Redirection (Note: there are more 30x codes, those are the most popular)
+#define HTTP_STATUS_OBJECT_MOVED 302 // Page redirection notification
+#define HTTP_STATUS_OBJECT_MOVED_PERMANENTLY 301 // Page redirection notification
+#define HTTP_STATUS_CONTINUE 100 // Page continue message
+
+
+ // MIN AMX macro
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+ // HTTP timeout macro for selecting the default value if the caller passed 0 (no timeout) to the function
+#define HTTP_TIMEOUT(nTimeout) (((nTimeout) > (0)) ? (nTimeout) : (HTTP_CLIENT_DEFAULT_TIMEOUT))
+
+ // 32 bit alignment macro
+#define ALIGN(size) ((size & 0xfffffffc) + ((size & 3) ? 4 : 0))
+
+
+#ifdef _HTTP_DEBUGGING_
+ typedef VOID _stdcall E_HTTPDebug(const char *,const char*,UINT32,char *,...); // HTTPDebug hook function
+#endif
+
+
+ ///////////////////////////////////////////////////////////////////////////////
+ //
+ // Section : HTTP API internals structures
+ // Last updated : 01/09/2005
+ //
+ ///////////////////////////////////////////////////////////////////////////////
+
+ // Generic parameter structure contains a pointer to the buffer and its length
+
+ typedef struct _HTTP_PARAM
+ {
+
+ CHAR *pParam;
+ UINT32 nLength;
+
+ } HTTP_PARAM;
+
+ // HTTP socket events
+ typedef struct _HTTP_CONNECTION
+ {
+
+ fd_set FDRead; // socket read event
+ fd_set FDWrite; // socket write event
+ fd_set FDError; // socket error event
+ INT32 HttpSocket; // The underling socket
+ UINT32 HttpStartTime; // Time stamp for the session
+ UINT32 HttpClientPort; // For client side binding
+ BOOL TlsNego; // TLS negotiation flag
+
+ } HTTP_CONNECTION;
+
+ // Request URL
+ typedef struct _HTTP_URL
+ {
+
+ HTTP_PARAM UrlBsee; // a pointer and length to the "http" section of the URL
+ HTTP_PARAM UrlHost; // a pointer and length to the host section of the URL
+ HTTP_PARAM UrlPort; // a pointer and length to the PORT (if was specified section)
+ HTTP_PARAM UrlRequest; // a pointer and length of the request section of the URL
+ UINT16 nPort; // the PORT that we should use (could be default or the one found within the URL)
+ CHAR Url[HTTP_CLIENT_MAX_URL_LENGTH]; // a buffer for the URL
+
+ }HTTP_URL;
+ // HTTP headers (incoming and outgoing)
+ typedef struct _HTTP_HEADERS
+ {
+
+ HTTP_PARAM HeadersBuffer; // a pointer and length of the complete Headers (in\out) buffer
+ HTTP_PARAM HeadersOut; // a pointer and length of the outgoing HTTP headers
+ HTTP_PARAM HeadersIn; // a pointer and length of the incoming headers
+ HTTP_PARAM HeaderSearch; // Index and pointer for the header search functions
+ HTTP_VERB HttpVerb; // the HTTP verb that was used in the session
+ HTTP_VERB HttpLastVerb; // the HTTP verb that was last transmited to the server
+ CHAR SearchClue[HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE];
+ CHAR Verb[16]; // the actual string buffer of the HTTP verb
+
+
+ }HTTP_HEADERS;
+
+ // HTTP headers (parsed headers information)
+ typedef struct _HTTP_HEADERS_INFO
+ {
+ HTTP_PARAM HttpRedirectURL; // Stores the redirection URL if we got a 301 or 303 return code
+ UINT32 nHTTPStatus; // the HTTP status code (200 401 407 act')
+ UINT32 nHTTPContentLength; // the Content length if specified of the returned data
+ UINT32 nHTTPPostContentLength;// the Content-Length of the POSTed data (if known)
+ BOOL Connection; // True = Keep alive or undefined, False = Closed
+ BOOL ValidHeaders; // a flag that indicates if the incoming header ware parsed OK and found to be valid
+ BOOL HaveCredentials; // a flag that indicates if we have credentials for the session
+ CHAR HTTPVersion[16]; // HTTP version string buffer (for example: "HTTP 1.1")
+
+ }HTTP_HEADERS_INFO;
+
+ // Authentication parameters that ware extracted from the incoming headers
+ typedef struct _HTTP_AUTH_HEADER
+ {
+
+ HTTP_PARAM AuthHeader; // the pointer and length of the authentication header
+ UINT32 HTTP_AUTH_SCHEMA; // Its schema (could be any of the supported)
+
+ }HTTP_AUTH_HEADER;
+ // Proxy related data
+ typedef struct _HTTP_PROXY
+ {
+ CHAR ProxyHost[HTTP_CLIENT_MAX_PROXY_HOST_LENGTH];
+ CHAR ProxtUser[HTTP_CLIENT_MAX_USERNAME_LENGTH];
+ CHAR ProxyPassword[HTTP_CLIENT_MAX_PASSWORD_LENGTH];
+ UINT16 nProxyPort;
+ CHAR AuthSchemaName[16]; // The authentication schema name (for string comperission)
+ HTTP_AUTH_SCHEMA ProxyAuthSchema;
+
+ }HTTP_PROXY;
+
+ // HTTP User credentials
+ typedef struct _HTTP_CREDENTIALS
+ {
+
+ CHAR CredUser[HTTP_CLIENT_MAX_USERNAME_LENGTH];
+ CHAR CredPassword[HTTP_CLIENT_MAX_PASSWORD_LENGTH];
+ CHAR AuthSchemaName[16]; // The authentication schema name (for string comperission)
+ HTTP_AUTH_SCHEMA CredAuthSchema; // The schema that calle has selected for the session
+ BOOL Authentication; // a flag that indicates that this session has requested a user authentication
+
+ }HTTP_CREDENTIALS;
+ // HTTP Counters
+ typedef struct _HTTP_COUNTERS
+ {
+
+ UINT32 nRecivedHeaderLength; // Bytes count of the incoming header
+ UINT32 nRecivedBodyLength; // Bytes count of the incoming body length
+ UINT32 nRecivedChunkLength; // The next chunk length in bytes
+ UINT32 nBytesToNextChunk; // How many bytes we have to read until we can expect the next chunk
+ UINT32 nActionStartTime; // Operation start time
+ UINT32 nActionTimeout; // Timeout for the session
+ UINT32 nSentChunks; // Count of sent chunks
+ UINT32 nSentBodyBytes; // Count of body bytes that ware sent
+ UINT32 nSentHeaderBytes; // Count of header bytes thhat ware sent
+
+ }HTTP_COUNTERS;
+
+ // HTTP Client Session data
+ typedef struct _HTTP_REQUEST
+ {
+
+ HTTP_URL HttpUrl;
+ HTTP_HEADERS HttpHeaders;
+ HTTP_HEADERS_INFO HttpHeadersInfo;
+ HTTP_AUTH_HEADER HttpAuthHeader;
+ HTTP_PROXY HttpProxy;
+ HTTP_CREDENTIALS HttpCredentials;
+ HTTP_CONNECTION HttpConnection;
+ HTTP_COUNTERS HttpCounters;
+ UINT32 HttpState;
+ UINT32 HttpFlags;
+#ifdef _HTTP_DEBUGGING_
+ E_HTTPDebug *pDebug;
+#endif
+ } HTTP_SESSION, *P_HTTP_SESSION;
+
+
+ // HTTP Type Definitions
+ typedef UINT32 HTTP_SESSION_HANDLE;
+ typedef UINT32 HTTP_CLIENT_SESSION_FLAGS;
+
+
+ ///////////////////////////////////////////////////////////////////////////////
+ //
+ // Section : HTTP API public interface
+ // Last updated : 01/09/2005
+ //
+ ///////////////////////////////////////////////////////////////////////////////
+
+
+ HTTP_SESSION_HANDLE HTTPClientOpenRequest (HTTP_CLIENT_SESSION_FLAGS Flags);
+ UINT32 HTTPClientCloseRequest (HTTP_SESSION_HANDLE *pSession);
+ UINT32 HTTPClientSetLocalConnection (HTTP_SESSION_HANDLE pSession, UINT32 nPort);
+ UINT32 HTTPClientSetAuth (HTTP_SESSION_HANDLE pSession, HTTP_AUTH_SCHEMA AuthSchema, void *pReserved);
+ UINT32 HTTPClientSetCredentials (HTTP_SESSION_HANDLE pSession, CHAR *pUserName, CHAR *pPassword);
+ UINT32 HTTPClientSetProxy (HTTP_SESSION_HANDLE pSession, CHAR *pProxyName, UINT16 nPort, CHAR *pUserName, CHAR *pPassword);
+ UINT32 HTTPClientSetVerb (HTTP_SESSION_HANDLE pSession, HTTP_VERB HttpVerb);
+ UINT32 HTTPClientAddRequestHeaders (HTTP_SESSION_HANDLE pSession, CHAR *pHeaderName, CHAR *pHeaderData, BOOL nInsert);
+ UINT32 HTTPClientSendRequest (HTTP_SESSION_HANDLE pSession, CHAR *pUrl, VOID *pData, UINT32 nDataLength, BOOL TotalLength, UINT32 nTimeout,UINT32 nClientPort);
+ UINT32 HTTPClientWriteData (HTTP_SESSION_HANDLE pSession, VOID *pBuffer, UINT32 nBufferLength, UINT32 nTimeout);
+ UINT32 HTTPClientRecvResponse (HTTP_SESSION_HANDLE pSession, UINT32 nTimeout);
+ UINT32 HTTPClientReadData (HTTP_SESSION_HANDLE pSession, VOID *pBuffer, UINT32 nBytesToRead, UINT32 nTimeout, UINT32 *nBytesRecived);
+ UINT32 HTTPClientGetInfo (HTTP_SESSION_HANDLE pSession, HTTP_CLIENT *HTTPClient);
+
+ UINT32 HTTPClientFindFirstHeader (HTTP_SESSION_HANDLE pSession, CHAR *pSearchClue,CHAR *pHeaderBuffer, UINT32 *nLength);
+ UINT32 HTTPClientGetNextHeader (HTTP_SESSION_HANDLE pSession, CHAR *pHeaderBuffer, UINT32 *nLength);
+ UINT32 HTTPClientFindCloseHeader (HTTP_SESSION_HANDLE pSession);
+
+
+#ifdef _HTTP_DEBUGGING_
+ UINT32 HTTPClientSetDebugHook (HTTP_SESSION_HANDLE pSession,E_HTTPDebug *pDebug);
+#endif
+
+
+ ///////////////////////////////////////////////////////////////////////////////
+ //
+ // Section : HTTP API private function
+ // Last updated : 01/09/2005
+ //
+ ///////////////////////////////////////////////////////////////////////////////
+
+ UINT32 HTTPIntrnResizeBuffer (P_HTTP_SESSION pHTTPSession, UINT32 nNewSize);
+ UINT32 HTTPIntrnSetURL (P_HTTP_SESSION pHTTPSession, CHAR *pUrl,UINT32 nUrlLength);
+ UINT32 HTTPIntrnConnectionClose (P_HTTP_SESSION pHTTPSession);
+ UINT32 HTTPIntrnConnectionOpen (P_HTTP_SESSION pHTTPSession);
+ UINT32 HTTPIntrnGetRemoteHeaders (P_HTTP_SESSION pHTTPSession);
+ UINT32 HTTPIntrnGetRemoteChunkLength (P_HTTP_SESSION pHTTPSession);
+ UINT32 HTTPIntrnSend (P_HTTP_SESSION pHTTPSession, CHAR *pData,UINT32 *nLength);
+ UINT32 HTTPIntrnRecv (P_HTTP_SESSION pHTTPSession, CHAR *pData,UINT32 *nLength,BOOL PeekOnly);
+ UINT32 HTTPIntrnParseAuthHeader (P_HTTP_SESSION pHTTPSession);
+ UINT32 HTTPIntrnAuthHandler (P_HTTP_SESSION pHTTPSession);
+ UINT32 HTTPIntrnAuthSendDigest (P_HTTP_SESSION pHTTPSession);
+ UINT32 HTTPIntrnAuthSendBasic (P_HTTP_SESSION pHTTPSession);
+ UINT32 HTTPIntrnAuthenticate (P_HTTP_SESSION pHTTPSession);
+ UINT32 HTTPIntrnHeadersAdd (P_HTTP_SESSION pHTTPSession, CHAR *pHeaderName, UINT32 nNameLength, CHAR *pHeaderData, UINT32 nDataLength);
+ UINT32 HTTPIntrnHeadersRemove (P_HTTP_SESSION pHTTPSession, CHAR *pHeaderName);
+ UINT32 HTTPIntrnHeadersReceive (P_HTTP_SESSION pHTTPSession, UINT32 nTimeout);
+ UINT32 HTTPIntrnHeadersSend (P_HTTP_SESSION pHTTPSession, HTTP_VERB HttpVerb);
+ UINT32 HTTPIntrnHeadersParse (P_HTTP_SESSION pHTTPSession);
+ UINT32 HTTPIntrnHeadersFind (P_HTTP_SESSION pHTTPSession, CHAR *pHeaderName, HTTP_PARAM *pParam,BOOL IncommingHeaders,UINT32 nOffset);
+ UINT32 HTTPIntrnSessionReset (P_HTTP_SESSION pHTTPSession, BOOL EntireSession);
+ UINT32 HTTPIntrnSessionGetUpTime (VOID);
+ BOOL HTTPIntrnSessionEvalTimeout (P_HTTP_SESSION pHTTPSession);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_HTTP_CLIENT
diff --git a/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientAuth.c b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientAuth.c
new file mode 100644
index 000000000..7874be518
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientAuth.c
@@ -0,0 +1,665 @@
+
+///////////////////////////////////////////////////////////////////////////////
+// Module Name:
+// HTTPClientAuth.c
+//
+// Abstract: Handle Digest, MD5 and 64 Bit Encoding
+//
+// Platform: Any that supports standard C calls
+///////////////////////////////////////////////////////////////////////////////
+
+#include "HTTPClientAuth.h"
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPBase64Encoder
+// Purpose : Converts a given string into a base64 encoded buffer.
+// Last updated : 01/09/200515/05/2005
+// Author Name : Eitan Michaelson
+// Notes :
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void HTTPBase64Encoder(unsigned char *out, const unsigned char *in, int inlen)
+// [OUT] out A pointer to a char to hold the converted string
+// [IN] in String to convert
+// [IN] inlen Length of the string to be converted
+
+{
+ for (; inlen >= 3; inlen -= 3)
+ {
+ *out++ = base64digits[in[0] >> 2];
+ *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
+ *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
+ *out++ = base64digits[in[2] & 0x3f];
+ in += 3;
+ }
+
+ if (inlen > 0)
+ {
+ unsigned char fragment;
+
+ *out++ = base64digits[in[0] >> 2];
+ fragment = (in[0] << 4) & 0x30;
+
+ if (inlen > 1)
+ fragment |= in[1] >> 4;
+
+ *out++ = base64digits[fragment];
+ *out++ = (inlen < 2) ? '=' : base64digits[(in[1] << 2) & 0x3c];
+ *out++ = '=';
+ }
+
+ *out = '\0';
+}
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPBase64Decoder
+// Purpose : Converts a given base64 string into a bytes buffer.
+// Last updated : 01/09/200515/05/2005
+// Author Name : Eitan Michaelson
+// Notes :
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int HTTPBase64Decoder(char *out, const char *in)
+{ // [OUT] out Where to save the converted string
+ // [IN] in String to convert
+
+ int len = 0;
+ register unsigned char digit1, digit2, digit3, digit4;
+
+ if (in[0] == '+' && in[1] == ' ')
+ in += 2;
+ if (*in == '\r')
+ return(0);
+
+ do {
+
+ digit1 = in[0];
+ if (DECODE64(digit1) == BAD)
+ return(-1);
+ digit2 = in[1];
+ if (DECODE64(digit2) == BAD)
+ return(-1);
+ digit3 = in[2];
+ if (digit3 != '=' && DECODE64(digit3) == BAD)
+ return(-1);
+ digit4 = in[3];
+ if (digit4 != '=' && DECODE64(digit4) == BAD)
+ return(-1);
+ in += 4;
+ *out++ = (DECODE64(digit1) << 2) | (DECODE64(digit2) >> 4);
+ ++len;
+ if (digit3 != '=')
+ {
+ *out++ = ((DECODE64(digit2) << 4) & 0xf0) | (DECODE64(digit3) >> 2);
+ ++len;
+ if (digit4 != '=')
+ {
+ *out++ = ((DECODE64(digit3) << 6) & 0xc0) | DECODE64(digit4);
+ ++len;
+ }
+ }
+ } while (*in && *in != '\r' && digit4 != '=');
+
+ return (len);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Purpose : The following code implements the calculations of H(A1), H(A2),
+// request-digest and response-digest
+// Last updated : 01/09/200515/05/2005
+// Author Name : Public Domain\RFC2617
+// Notes : Digest Access Authentication
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function : GenerateCNonce
+// Purpose : Generates a 32 byte random hexadecimal string such as "4f6ba982..."
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes :
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void HTTPDigestGenerateCNonce(char *outbuff)
+{
+ int i,num;
+ InitRandomeNumber();
+ for(i = 0; i < 32; i++) {
+ num = GetRandomeNumber();
+ switch(num) {
+ case 0: case 1: case 2: case 3: case 4: case 5:
+ case 6: case 7: case 8: case 9:
+ outbuff[i] = '0' + num;
+ break;
+ case 10: case 11: case 12: case 13: case 14: case 15:
+ outbuff[i] = 'a' + (num-10);
+ break;
+ default:
+ outbuff[i] = 'f';
+ }
+ }
+ outbuff[32] = 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function : DigestCvtHex
+// Purpose : CConvert to HEX
+// Last updated : 15/05/2005
+// Author Name : Public Domain\RFC2617
+// Notes :
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+void HTTPDigestCvtHex(IN HASH Bin,OUT HASHHEX Hex)
+{
+ unsigned short i;
+ unsigned char j;
+
+ for (i = 0; i < HASHLEN; i++) {
+ j = (Bin[i] >> 4) & 0xf;
+ if (j <= 9)
+ Hex[i*2] = (j + '0');
+ else
+ Hex[i*2] = (j + 'a' - 10);
+ j = Bin[i] & 0xf;
+ if (j <= 9)
+ Hex[i*2+1] = (j + '0');
+ else
+ Hex[i*2+1] = (j + 'a' - 10);
+ };
+ Hex[HASHHEXLEN] = '\0';
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function : DigestCalcHA1
+// Purpose : Calculate H(A1) as per spec
+// Last updated : 15/05/2005
+// Author Name : Public Domain\RFC2617
+// Notes :
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void HTTPDigestCalcHA1(
+ IN int nAlg, /* 0 = MD5, 1 = MD5-Sess */
+ IN char * pszUserName,
+ IN char * pszRealm,
+ IN int nRealmLength,
+ IN char * pszPassword,
+ IN char * pszNonce,
+ IN int nNonceLength,
+ IN char * pszCNonce,
+ OUT HASHHEX SessionKey
+ )
+{
+ MD5_CTX Md5Ctx;
+ HASH HA1;
+ HASHHEX HASess;
+ HASH HAll;
+
+ HTTPMD5Init(&Md5Ctx);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszUserName, strlen(pszUserName)); //Daniel casting
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszRealm, nRealmLength); //Daniel
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszPassword, strlen(pszPassword)); //Daniel
+ HTTPMD5Final((unsigned char *)HA1, &Md5Ctx);
+
+ if (nAlg == 1) /* MD5-Sess */
+ {
+ HTTPDigestCvtHex(HA1, HASess);
+ HTTPMD5Init(&Md5Ctx);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)HASess, HASHHEXLEN);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszNonce, nNonceLength);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszCNonce, strlen(pszCNonce));
+ HTTPMD5Final((unsigned char *)HAll, &Md5Ctx);
+ HTTPDigestCvtHex(HAll, SessionKey);
+ return;
+
+ }
+
+ HTTPDigestCvtHex(HA1, SessionKey);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function : DigestCalcResponse
+// Purpose : Calculate request-digest/response-digest as per HTTP Digest spec
+// Last updated : 15/05/2005
+// Author Name : Public Domain\RFC2617
+// Notes :
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void HTTPDigestCalcResponse(
+ IN HASHHEX HA1, // H(A1)
+ IN char * pszNonce, // nonce from server
+ IN int nNonceLength, // Length of nonce
+ IN char * pszNonceCount, // 8 hex digits
+ IN char * pszCNonce, // client nonce */
+ IN char * pszQop, // qop-value: "", "auth", "auth-int"
+ IN int nQopLength, // qop param length
+ IN char * pszMethod, // method from the request
+ IN char * pszDigestUri, // requested URL
+ IN int nDigestUriLebgth, // Uri Length
+ IN HASHHEX HEntity, // H(entity body) if qop="auth-int"
+ OUT HASHHEX Response // request-digest or response-digest
+ )
+{
+ MD5_CTX Md5Ctx;
+ HASH HA2;
+ HASH RespHash;
+ HASHHEX HA2Hex;
+
+ // Calculate H(A2)
+ HTTPMD5Init(&Md5Ctx);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszMethod, strlen(pszMethod));
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszDigestUri, nDigestUriLebgth);
+ if (stricmp(pszQop, "auth-int") == 0)
+ {
+
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)HEntity, HASHHEXLEN);
+ };
+ HTTPMD5Final((unsigned char *)HA2, &Md5Ctx);
+ HTTPDigestCvtHex(HA2, HA2Hex);
+
+ // Calculate response
+ HTTPMD5Init(&Md5Ctx);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)HA1, HASHHEXLEN);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszNonce, nNonceLength);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1);
+ if (*pszQop)
+ {
+
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszNonceCount, strlen(pszNonceCount));
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszCNonce, strlen(pszCNonce));
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszQop, nQopLength);
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1);
+ };
+ HTTPMD5Update(&Md5Ctx, (const unsigned char *)HA2Hex, HASHHEXLEN);
+ HTTPMD5Final((unsigned char *)RespHash, &Md5Ctx);
+ HTTPDigestCvtHex(RespHash, Response);
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Purpose : This code implements the MD5 message-digest algorithm.
+// The algorithm is due to Ron Rivest. This code was
+// written by Colin Plumb in 1993, no copyright is claimed.
+// This code is in the public domain; do with it what you wish.
+// Equivalent code is available from RSA Data Security, Inc.
+// This code has been tested against that, and is equivalent,
+// except that you don't need to include two pages of legalese
+// with every copy.
+// Usage : To compute the message digest of a chunk of bytes, declare an
+// MD5Context structure, pass it to MD5Init, call MD5Update as
+// needed on buffers full of bytes, and then call MD5Final, which
+// will fill a supplied 16-byte array with the digest.
+// Last updated : 15/05/2005
+// Author Name : Public Domain
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+#ifndef HIGHFIRST
+#define HTTPMD5ByteReverse(buf, len) /* Nothing */
+#else
+void HTTPMD5ByteReverse(unsigned char *buf, unsigned longs);
+#ifndef ASM_MD5
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function : ByteReverse
+// Purpose : Little\Big Endian support
+// Gets :
+// Returns :
+// Last updated : 15/05/2005
+// Author Name : Public Domain
+// Notes : this code is harmless on little-endian machines.
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void HTTPMD5ByteReverse(unsigned char *buf, unsigned longs)
+{
+ uint32 t;
+ do {
+ t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+ ((unsigned) buf[1] << 8 | buf[0]);
+ *(uint32 *) buf = t;
+ buf += 4;
+ } while (--longs);
+}
+#endif
+#endif
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function : MD5Init
+// Purpose : Initialize the MD5Context structure
+// Gets : MD5Context structure
+// Returns :
+// Last updated : 15/05/2005
+// Author Name : Public Domain
+// Notes : Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
+// initialization constants.
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+void HTTPMD5Init(struct MD5Context *ctx)
+{
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
+
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function : MD5Update
+// Purpose : Update the MD5Context structure with the target byte array
+// Gets : MD5Context structure, buffer and length
+// Returns :
+// Last updated : 15/05/2005
+// Author Name : Public Domain
+// Notes : Update context to reflect the concatenation of another buffer full of bytes.
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void HTTPMD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
+{
+ uint32 t;
+
+ // Update bitcount
+
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
+ ctx->bits[1]++; // Carry from low to high
+ ctx->bits[1] += len >> 29;
+
+ t = (t >> 3) & 0x3f; // Bytes already in shsInfo->data
+
+ // Handle any leading odd-sized chunks
+
+ if (t) {
+ unsigned char *p = (unsigned char *) ctx->in + t;
+
+ t = 64 - t;
+ if (len < t) {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ HTTPMD5ByteReverse(ctx->in, 16);
+ HTTPMD5Transform(ctx->buf, (uint32 *) ctx->in);
+ buf += t;
+ len -= t;
+ }
+ // Process data in 64-byte chunks
+
+ while (len >= 64) {
+ memcpy(ctx->in, buf, 64);
+ HTTPMD5ByteReverse(ctx->in, 16);
+ HTTPMD5Transform(ctx->buf, (uint32 *) ctx->in);
+ buf += 64;
+ len -= 64;
+ }
+
+ // Handle any remaining bytes of data.
+
+ memcpy(ctx->in, buf, len);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function : MD5Final
+// Purpose : Finalize.
+// Gets : Output digest structure, MD5Context structure
+// Returns :
+// Last updated : 15/05/2005
+// Author Name : Public Domain
+// Notes : Final wrapup - pad to 64-byte boundary with the bit pattern
+// 1 0* (64-bit count of bits processed, MSB-first).
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
+
+
+void HTTPMD5Final(unsigned char digest[16], struct MD5Context *ctx)
+{
+ unsigned count;
+ unsigned char *p;
+
+ // Compute number of bytes mod 64
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ // Set the first char of padding to 0x80. This is safe since there is
+ // always at least one byte free
+ p = ctx->in + count;
+ *p++ = 0x80;
+
+ // Bytes of padding needed to make 64 bytes
+ count = 64 - 1 - count;
+
+ // Pad out to 56 mod 64 */
+ if (count < 8) {
+ // Two lots of padding: Pad the first block to 64 bytes
+ memset(p, 0, count);
+ HTTPMD5ByteReverse(ctx->in, 16);
+ HTTPMD5Transform(ctx->buf, (uint32 *) ctx->in);
+
+ // Now fill the next block with 56 bytes
+ memset(ctx->in, 0, 56);
+ } else {
+ // Pad block to 56 bytes
+ memset(p, 0, count - 8);
+ }
+ HTTPMD5ByteReverse(ctx->in, 14);
+
+ // Append length in bits and transform
+ ((uint32 *) ctx->in)[14] = ctx->bits[0];
+ ((uint32 *) ctx->in)[15] = ctx->bits[1];
+
+ HTTPMD5Transform(ctx->buf, (uint32 *) ctx->in);
+ HTTPMD5ByteReverse((unsigned char *) ctx->buf, 4);
+ memcpy(digest, ctx->buf, 16);
+ memset(ctx, 0, sizeof(ctx)); // In case it's sensitive
+}
+
+#ifndef ASM_MD5
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function :
+// Purpose : The four core functions - F1 is optimized somewhat
+// Last updated : 15/05/2005
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#define F1(x, y, z) (z ^ (x & (y ^ z)))
+#define F2(x, y, z) F1(z, x, y)
+#define F3(x, y, z) (x ^ y ^ z)
+#define F4(x, y, z) (y ^ (x | ~z))
+
+// This is the central step in the MD5 algorithm.
+#ifdef __PUREC__
+#define MD5STEP(f, w, x, y, z, data, s) \
+ ( w += f /*(x, y, z)*/ + data, w = w<<s | w>>(32-s), w += x )
+#else
+#define MD5STEP(f, w, x, y, z, data, s) \
+ ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Function : MD5Transform
+// Purpose : The core of the MD5 algorithm, this alters an existing MD5 hash to
+// reflect the addition of 16 longwords of new data. MD5Update blocks
+// the data and converts bytes into longwords for this routine.
+// Last updated : 15/05/2005
+// Author Name : Public Domain
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+void HTTPMD5Transform(uint32 buf[4], uint32 const in[16])
+{
+ register uint32 a, b, c, d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+#ifdef __PUREC__ // PureC Weirdness... (GG)
+ MD5STEP(F1(b,c,d), a, b, c, d, in[0] + 0xd76aa478L, 7);
+ MD5STEP(F1(a,b,c), d, a, b, c, in[1] + 0xe8c7b756L, 12);
+ MD5STEP(F1(d,a,b), c, d, a, b, in[2] + 0x242070dbL, 17);
+ MD5STEP(F1(c,d,a), b, c, d, a, in[3] + 0xc1bdceeeL, 22);
+ MD5STEP(F1(b,c,d), a, b, c, d, in[4] + 0xf57c0fafL, 7);
+ MD5STEP(F1(a,b,c), d, a, b, c, in[5] + 0x4787c62aL, 12);
+ MD5STEP(F1(d,a,b), c, d, a, b, in[6] + 0xa8304613L, 17);
+ MD5STEP(F1(c,d,a), b, c, d, a, in[7] + 0xfd469501L, 22);
+ MD5STEP(F1(b,c,d), a, b, c, d, in[8] + 0x698098d8L, 7);
+ MD5STEP(F1(a,b,c), d, a, b, c, in[9] + 0x8b44f7afL, 12);
+ MD5STEP(F1(d,a,b), c, d, a, b, in[10] + 0xffff5bb1L, 17);
+ MD5STEP(F1(c,d,a), b, c, d, a, in[11] + 0x895cd7beL, 22);
+ MD5STEP(F1(b,c,d), a, b, c, d, in[12] + 0x6b901122L, 7);
+ MD5STEP(F1(a,b,c), d, a, b, c, in[13] + 0xfd987193L, 12);
+ MD5STEP(F1(d,a,b), c, d, a, b, in[14] + 0xa679438eL, 17);
+ MD5STEP(F1(c,d,a), b, c, d, a, in[15] + 0x49b40821L, 22);
+
+ MD5STEP(F2(b,c,d), a, b, c, d, in[1] + 0xf61e2562L, 5);
+ MD5STEP(F2(a,b,c), d, a, b, c, in[6] + 0xc040b340L, 9);
+ MD5STEP(F2(d,a,b), c, d, a, b, in[11] + 0x265e5a51L, 14);
+ MD5STEP(F2(c,d,a), b, c, d, a, in[0] + 0xe9b6c7aaL, 20);
+ MD5STEP(F2(b,c,d), a, b, c, d, in[5] + 0xd62f105dL, 5);
+ MD5STEP(F2(a,b,c), d, a, b, c, in[10] + 0x02441453L, 9);
+ MD5STEP(F2(d,a,b), c, d, a, b, in[15] + 0xd8a1e681L, 14);
+ MD5STEP(F2(c,d,a), b, c, d, a, in[4] + 0xe7d3fbc8L, 20);
+ MD5STEP(F2(b,c,d), a, b, c, d, in[9] + 0x21e1cde6L, 5);
+ MD5STEP(F2(a,b,c), d, a, b, c, in[14] + 0xc33707d6L, 9);
+ MD5STEP(F2(d,a,b), c, d, a, b, in[3] + 0xf4d50d87L, 14);
+ MD5STEP(F2(c,d,a), b, c, d, a, in[8] + 0x455a14edL, 20);
+ MD5STEP(F2(b,c,d), a, b, c, d, in[13] + 0xa9e3e905L, 5);
+ MD5STEP(F2(a,b,c), d, a, b, c, in[2] + 0xfcefa3f8L, 9);
+ MD5STEP(F2(d,a,b), c, d, a, b, in[7] + 0x676f02d9L, 14);
+ MD5STEP(F2(c,d,a), b, c, d, a, in[12] + 0x8d2a4c8aL, 20);
+
+ MD5STEP(F3(b,c,d), a, b, c, d, in[5] + 0xfffa3942L, 4);
+ MD5STEP(F3(a,b,c), d, a, b, c, in[8] + 0x8771f681L, 11);
+ MD5STEP(F3(d,a,b), c, d, a, b, in[11] + 0x6d9d6122L, 16);
+ MD5STEP(F3(c,d,a), b, c, d, a, in[14] + 0xfde5380cL, 23);
+ MD5STEP(F3(b,c,d), a, b, c, d, in[1] + 0xa4beea44L, 4);
+ MD5STEP(F3(a,b,c), d, a, b, c, in[4] + 0x4bdecfa9L, 11);
+ MD5STEP(F3(d,a,b), c, d, a, b, in[7] + 0xf6bb4b60L, 16);
+ MD5STEP(F3(c,d,a), b, c, d, a, in[10] + 0xbebfbc70L, 23);
+ MD5STEP(F3(b,c,d), a, b, c, d, in[13] + 0x289b7ec6L, 4);
+ MD5STEP(F3(a,b,c), d, a, b, c, in[0] + 0xeaa127faL, 11);
+ MD5STEP(F3(d,a,b), c, d, a, b, in[3] + 0xd4ef3085L, 16);
+ MD5STEP(F3(c,d,a), b, c, d, a, in[6] + 0x04881d05L, 23);
+ MD5STEP(F3(b,c,d), a, b, c, d, in[9] + 0xd9d4d039L, 4);
+ MD5STEP(F3(a,b,c), d, a, b, c, in[12] + 0xe6db99e5L, 11);
+ MD5STEP(F3(d,a,b), c, d, a, b, in[15] + 0x1fa27cf8L, 16);
+ MD5STEP(F3(c,d,a), b, c, d, a, in[2] + 0xc4ac5665L, 23);
+
+ MD5STEP(F4(b,c,d), a, b, c, d, in[0] + 0xf4292244L, 6);
+ MD5STEP(F4(a,b,c), d, a, b, c, in[7] + 0x432aff97L, 10);
+ MD5STEP(F4(d,a,b), c, d, a, b, in[14] + 0xab9423a7L, 15);
+ MD5STEP(F4(c,d,a), b, c, d, a, in[5] + 0xfc93a039L, 21);
+ MD5STEP(F4(b,c,d), a, b, c, d, in[12] + 0x655b59c3L, 6);
+ MD5STEP(F4(a,b,c), d, a, b, c, in[3] + 0x8f0ccc92L, 10);
+ MD5STEP(F4(d,a,b), c, d, a, b, in[10] + 0xffeff47dL, 15);
+ MD5STEP(F4(c,d,a), b, c, d, a, in[1] + 0x85845dd1L, 21);
+ MD5STEP(F4(b,c,d), a, b, c, d, in[8] + 0x6fa87e4fL, 6);
+ MD5STEP(F4(a,b,c), d, a, b, c, in[15] + 0xfe2ce6e0L, 10);
+ MD5STEP(F4(d,a,b), c, d, a, b, in[6] + 0xa3014314L, 15);
+ MD5STEP(F4(c,d,a), b, c, d, a, in[13] + 0x4e0811a1L, 21);
+ MD5STEP(F4(b,c,d), a, b, c, d, in[4] + 0xf7537e82L, 6);
+ MD5STEP(F4(a,b,c), d, a, b, c, in[11] + 0xbd3af235L, 10);
+ MD5STEP(F4(d,a,b), c, d, a, b, in[2] + 0x2ad7d2bbL, 15);
+ MD5STEP(F4(c,d,a), b, c, d, a, in[9] + 0xeb86d391L, 21);
+#else
+ MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+#endif
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
+}
+
+#endif
+
diff --git a/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientAuth.h b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientAuth.h
new file mode 100644
index 000000000..65af8a5cb
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientAuth.h
@@ -0,0 +1,90 @@
+
+#ifndef HTTP_CLIENT_AUTH_H
+#define HTTP_CLIENT_AUTH_H
+
+#include "HTTPClientWrapper.h" // Cross platform support
+
+
+#define HASHLEN 16
+#define HASHHEXLEN 32
+#define IN
+#define OUT
+
+typedef char HASH[HASHLEN];
+typedef char HASHHEX[HASHHEXLEN+1];
+typedef unsigned long uint32;
+
+// Base 64 Related
+#define DECODE64(c) (isascii(c) ? base64val[c] : BAD)
+#define BAD -1
+
+static const char base64digits[] =
+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+static const char base64val[] = {
+BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD,
+BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD,
+BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD, 62, BAD,BAD,BAD, 63,
+52, 53, 54, 55, 56, 57, 58, 59, 60, 61,BAD,BAD, BAD,BAD,BAD,BAD,
+BAD, 0, 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,BAD, BAD,BAD,BAD,BAD,
+BAD, 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,BAD, BAD,BAD,BAD,BAD
+};
+
+void HTTPBase64Encoder(unsigned char *out, const unsigned char *in, int inlen);
+int HTTPBase64Decoder(char *out, const char *in);
+
+
+// Digest Related
+// Generates a 32 byte random hexadecimal string such as "4f6ba982..."
+void HTTPDigestGenerateCNonce(char *outbuff);
+
+// Calculate H(A1) as per HTTP Digest spec
+void HTTPDigestCalcHA1(
+ IN int nAlg, /* 0 = MD5, 1 = MD5-Sess */
+ IN char * pszUserName,
+ IN char * pszRealm,
+ IN int nRealmLength,
+ IN char * pszPassword,
+ IN char * pszNonce,
+ IN int nNonceLength,
+ IN char * pszCNonce,
+ OUT HASHHEX SessionKey
+ );
+
+// Calculate request-digest/response-digest as per HTTP Digest spec
+void HTTPDigestCalcResponse(
+ IN HASHHEX HA1, // H(A1)
+ IN char * pszNonce, // nonce from server
+ IN int nNonceLength, // Length of nonce
+ IN char * pszNonceCount, // 8 hex digits
+ IN char * pszCNonce, // client nonce
+ IN char * pszQop, // qop-value: "", "auth", "auth-int"
+ IN int nQopLength, // qop param length
+ IN char * pszMethod, // method from the request
+ IN char * pszDigestUri, // requested URL
+ IN int nDigestUriLebgth, // Uri Length
+ IN HASHHEX HEntity, // H(entity body) if qop="auth-int"
+ OUT HASHHEX Response // request-digest or response-digest
+ );
+
+// MD5 structures and functions
+struct MD5Context
+{
+ uint32 buf[4];
+ uint32 bits[2];
+ unsigned char in[64];
+};
+
+void HTTPMD5Init (struct MD5Context *context);
+void HTTPMD5Update (struct MD5Context *context, unsigned char const *buf,unsigned len);
+void HTTPMD5Final (unsigned char digest[16], struct MD5Context *context);
+void HTTPMD5Transform (uint32 buf[4], uint32 const in[16]);
+
+
+// This is needed to make RSAREF happy on some MS-DOS compilers.
+typedef struct MD5Context MD5_CTX;
+
+#endif
+
diff --git a/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientCommon.h b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientCommon.h
new file mode 100644
index 000000000..b54eb3ec5
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientCommon.h
@@ -0,0 +1,120 @@
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Module Name:
+// CmsiHTTPClientCommon.h
+//
+// Abstract: Coomon structs and types for the HTTP protocol API
+// Author: Eitan Michaelso
+// Version: 1.0
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _HTTPCLIENT_PROTOCOL_H_
+#define _HTTPCLIENT_PROTOCOL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ // Global default sizes
+#define HTTP_CLIENT_MAX_URL_LENGTH 512 // Maximum length for an HTTP Url parameter
+
+ // HTTP Session flags (Public flags)
+#define HTTP_CLIENT_FLAG_KEEP_ALIVE 0x00000001 // Set the keep alive header
+#define HTTP_CLIENT_FLAG_SEND_CHUNKED 0x00000002 // The outgoing should chunked
+#define HTTP_CLIENT_FLAG_NO_CACHE 0x00000004 // Set the no cache header
+#define HTTP_CLIENT_FLAG_ASYNC 0x00000008 // Currently not implemented
+
+ // HTTP status internal flags
+#define HTTP_CLIENT_STATE_PRE_INIT 0x00000000 // Starting stage
+#define HTTP_CLIENT_STATE_INIT 0x00000001 // API was initialized (memory was allocated)
+#define HTTP_CLIENT_STATE_URL_PARSED 0x00000002 // Url was parsed
+#define HTTP_CLIENT_STATE_HOST_CONNECTED 0x00000004 // HEAD verb was sent
+#define HTTP_CLIENT_STATE_HEAD_SENT 0x00000008 // Post verb was sent
+#define HTTP_CLIENT_STATE_POST_SENT 0x00000010 // HTTP requet was sent
+#define HTTP_CLIENT_STATE_REQUEST_SENT 0x00000020 // HTTP request was sent
+#define HTTP_CLIENT_STATE_HEADERS_RECIVED 0x00000040 // Headers ware recived from the server
+#define HTTP_CLIENT_STATE_HEADERS_PARSED 0x00000080 // HTTP headers ware parsed
+#define HTTP_CLIENT_STATE_HEADERS_OK 0x00000100 // Headers status was OK
+
+ // HTTP Return codes
+#define HTTP_CLIENT_SUCCESS 0 // HTTP Success status
+
+#define HTTP_CLIENT_UNKNOWN_ERROR 1 // Unknown error
+#define HTTP_CLIENT_ERROR_INVALID_HANDLE 2 // an Invalid handle or possible bad pointer was passed to a function
+#define HTTP_CLIENT_ERROR_NO_MEMORY 3 // Buffer too small or a failure while in memory allocation
+#define HTTP_CLIENT_ERROR_SOCKET_INVALID 4 // an attempt to use an invalid socket handle was made
+#define HTTP_CLIENT_ERROR_SOCKET_CANT_SET 5 // Can't send socket parameters
+#define HTTP_CLIENT_ERROR_SOCKET_RESOLVE 6 // Error while resolving host name
+#define HTTP_CLIENT_ERROR_SOCKET_CONNECT 7 // Error while connecting to the remote server
+#define HTTP_CLIENT_ERROR_SOCKET_TIME_OUT 8 // socket time out error
+#define HTTP_CLIENT_ERROR_SOCKET_RECV 9 // Error while receiving data
+#define HTTP_CLIENT_ERROR_SOCKET_SEND 10 // Error while sending data
+#define HTTP_CLIENT_ERROR_HEADER_RECV 11 // Error while receiving the remote HTTP headers
+#define HTTP_CLIENT_ERROR_HEADER_NOT_FOUND 12 // Could not find element within header
+#define HTTP_CLIENT_ERROR_HEADER_BIG_CLUE 13 // The headers search clue was too large for the internal API buffer
+#define HTTP_CLIENT_ERROR_HEADER_NO_LENGTH 14 // No content length was specified for the outgoing data. the caller should specify chunking mode in the session creation
+#define HTTP_CLIENT_ERROR_CHUNK_TOO_BIG 15 // The HTTP chunk token that was received from the server was too big and possibly wrong
+#define HTTP_CLIENT_ERROR_AUTH_HOST 16 // Could not authenticate with the remote host
+#define HTTP_CLIENT_ERROR_AUTH_PROXY 17 // Could not authenticate with the remote proxy
+#define HTTP_CLIENT_ERROR_BAD_VERB 18 // Bad or not supported HTTP verb was passed to a function
+#define HTTP_CLIENT_ERROR_LONG_INPUT 19 // a function received a parameter that was too large
+#define HTTP_CLIENT_ERROR_BAD_STATE 20 // The session state prevents the current function from proceeding
+#define HTTP_CLIENT_ERROR_CHUNK 21 // Could not parse the chunk length while in chunked transfer
+#define HTTP_CLIENT_ERROR_BAD_URL 22 // Could not parse curtail elements from the URL (such as the host name, HTTP prefix act')
+#define HTTP_CLIENT_ERROR_BAD_HEADER 23 // Could not detect key elements in the received headers
+#define HTTP_CLIENT_ERROR_BUFFER_RSIZE 24 // Error while attempting to resize a buffer
+#define HTTP_CLIENT_ERROR_BAD_AUTH 25 // Authentication schema is not supported
+#define HTTP_CLIENT_ERROR_AUTH_MISMATCH 26 // The selected authentication schema does not match the server response
+#define HTTP_CLIENT_ERROR_NO_DIGEST_TOKEN 27 // an element was missing while parsing the digest authentication challenge
+#define HTTP_CLIENT_ERROR_NO_DIGEST_ALG 28 // Digest algorithem could be MD5 or MD5-sess other types are not supported
+#define HTTP_CLIENT_ERROR_SOCKET_BIND 29 // Binding error
+#define HTTP_CLIENT_ERROR_TLS_NEGO 30 // Tls negotiation error
+#define HTTP_CLIENT_ERROR_NOT_IMPLEMENTED 64 // Feature is not (yet) implemented
+#define HTTP_CLIENT_EOS 1000 // HTTP end of stream message
+
+ ///////////////////////////////////////////////////////////////////////////////
+ //
+ // Section : HTTP API structures
+ // Last updated : 01/09/2005
+ //
+ ///////////////////////////////////////////////////////////////////////////////
+
+ // HTTP Supported authentication methods
+ typedef enum _HTTP_AUTH_SCHEMA
+ {
+ AuthSchemaNone = 0,
+ AuthSchemaBasic,
+ AuthSchemaDigest,
+ AuthSchemaKerberos,
+ AuthNotSupported
+
+ } HTTP_AUTH_SCHEMA;
+
+ // HTTP supported verbs
+ typedef enum _HTTP_VERB
+ {
+ VerbGet = 0,
+ VerbHead,
+ VerbPost,
+ VerbNotSupported
+ // Note: others verb such as connect and put are currently not supported
+
+ } HTTP_VERB;
+
+ // Data structure that the caller can request at any time that will include some information regarding the session
+ typedef struct _HTTP_CLIENT
+ {
+ UINT32 HTTPStatusCode; // HTTP Status code (200 OK)
+ UINT32 RequestBodyLengthSent; // Total bytes sent (body only)
+ UINT32 ResponseBodyLengthReceived; // Total bytes received (body only)
+ UINT32 TotalResponseBodyLength; // as extracted from the “content-length" header
+ UINT32 HttpState;
+ } HTTP_CLIENT;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _HTTPCLIENT_PROTOCOL_H_
diff --git a/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientString.c b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientString.c
new file mode 100644
index 000000000..b1010cc8b
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientString.c
@@ -0,0 +1,424 @@
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Module Name:
+// HTTPClientString.c
+//
+// Abstract: Helper function (string parsing related) for HTTPClient.c module
+//
+// Platform: Any that supports standard C calls
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include "HTTPClient.h"
+#include "HTTPClientWrapper.h" // Cross platform support
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPStrInsensitiveCompare
+// Purpose : Same as strcmp() only case insensitive
+// Returns : BOOL - TRUE if destination string is identical to the source
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+BOOL HTTPStrInsensitiveCompare(CHAR *pSrc, // [IN] a pointer to the source string
+ CHAR* pDest, // [IN] a pointer to the string we should search for
+ UINT32 nLength) // [IN] The bytes range we should search in
+{
+
+ // Lower case comparison
+ UINT32 nPosition;
+ UINT32 nDestLength;
+ CHAR *pSrcIn, *pDestIn;
+ CHAR a,b;
+ pSrcIn = pSrc;
+ pDestIn = pDest;
+
+ nPosition = 0;
+ nDestLength = strlen(pDest);
+
+ if(nLength == 0)
+ {
+ nLength = strlen(pSrc);
+ }
+ if(nDestLength != nLength)
+ {
+ return FALSE;
+ }
+
+ while(pSrcIn || pDestIn)
+ {
+
+ if(nLength > 0 && nPosition == nLength)
+ {
+ return TRUE;
+ }
+
+ a = *pSrcIn;
+ b = *pDestIn;
+
+
+ if(*pSrcIn >= 64 && *pSrcIn <= 90)
+ {
+ // Upper case to lower case
+ a = *pSrcIn + 32;
+ }
+
+ if(*pDestIn >= 64 && *pDestIn <= 90)
+ {
+ // Upper case to lower case
+ b = *pDestIn + 32;
+ }
+
+ if(a != b)
+ {
+ return FALSE;
+ }
+
+ pSrcIn++;
+ pDestIn++;
+ nPosition++;
+ }
+ return TRUE;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPStrExtract
+// Purpose : Extract a string by placing null in the offset parameter
+// Returns : a pointer to the new string
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+CHAR HTTPStrExtract(CHAR *pParam, // [IN] a pointer to the input parameter
+ UINT32 nOffset, // [IN] the offset position (where we should null terminate the string)
+ CHAR Restore) // [IN] if this is not 0 we should restore it (instead of the null)
+ // and reverse the effect.
+{
+ CHAR Replaced;
+
+ if(!pParam)
+ {
+ return 0;
+ }
+ // We should restore
+ if(Restore != 0)
+ {
+ pParam[nOffset] = Restore;
+ return Restore;
+ }
+ else
+ {
+ Replaced = pParam[nOffset];
+ pParam[nOffset] = 0;
+ return Replaced;
+
+ }
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPStrSearch
+// Purpose : Search a string within another and return its pointer and a length
+// Returns : BOOL - TRUE on success
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+BOOL HTTPStrSearch(CHAR *pSrc, // [IN] The source string
+ CHAR *pSearched, // [IN] Parameter to search for
+ UINT32 nOffset, // [IN] Offset from the source string start position
+ UINT32 nScope, // [IN] Length in bytes we should search in
+ HTTP_PARAM *HttpParam) // [IN OUT] The Pointer\Length value that will be returned on success
+{
+
+ CHAR *pSrcStart;
+ CHAR *pDstStart;
+ CHAR nOrigCharacter;
+ UINT32 nPosition = 0;
+
+ do
+ {
+ pSrcStart = pSrc + nOffset;
+ nOrigCharacter = pSrcStart[nScope];
+
+ // Temporarily null terminate
+ pSrcStart[nScope] = 0;
+
+ pDstStart = strstr(pSrcStart,pSearched);
+ if(!pDstStart)
+ {
+ break;
+ }
+
+ nPosition = pDstStart - pSrcStart + 1;
+
+ } while(0);
+
+ // Remove the null termination
+ pSrcStart[nScope] = nOrigCharacter;
+
+ if(!nPosition)
+ {
+ return FALSE;
+ }
+
+ if(HttpParam)
+ {
+
+ HttpParam->nLength = nPosition -1;
+ HttpParam->pParam = pSrcStart;
+ }
+
+ return TRUE;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPStrCaseStr
+// Purpose : Same as strstr() only case insensitive
+// Returns : a pointer to the position of the searched string (or 0 on error)
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+CHAR *HTTPStrCaseStr(const char *pSrc,UINT32 nSrcLength,const char *pFind)
+{
+ const char *ptr = pSrc;
+ const char *ptr2;
+ UINT32 iLength = 0;
+
+ while(1)
+ {
+ if(iLength >= nSrcLength)
+ {
+ break;
+ }
+ ptr = strchr(pSrc,toupper(*pFind));
+ ptr2 = strchr(pSrc,tolower(*pFind));
+ if (!ptr)
+ {
+ ptr = ptr2;
+ }
+ if (!ptr)
+ {
+ break;
+ }
+ if (ptr2 && (ptr2 < ptr)) {
+ ptr = ptr2;
+ }
+ if (!strnicmp(ptr,pFind,strlen(pFind)))
+ {
+ return (char *) ptr;
+ }
+ pSrc = ptr+1;
+ iLength++;
+ }
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPStrCaseStr
+// Purpose :
+// Gets :
+// Returns :
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+
+CHAR* HTTPStrGetToken (CHAR *pSrc, UINT32 nSrcLength, CHAR *pDest, UINT32 *nDestLength)
+{
+
+ // Get text between the ":" and \r\n or end of string.
+ CHAR *pStart = pSrc;
+ CHAR *pEnd;
+ UINT32 nTokenLength = 0;
+ UINT32 nPosition = 0;
+
+ pStart = strchr(pSrc,':') + 1;
+ if(pStart)
+ {
+ pEnd = pStart ;
+ // First pass, count required space
+ while ((*pEnd) && (*pEnd != '\r') && (*pEnd != '\n'))
+ {
+ if(*pEnd != 0x20)
+ {
+ nTokenLength++;
+ }
+
+ if(nSrcLength && nPosition > nSrcLength)
+ {
+ break;
+ }
+ pEnd++;
+ nPosition++;
+ }
+
+ if(nTokenLength > *(nDestLength))
+ {
+ *(nDestLength) = nTokenLength;
+ pDest = NULL;
+ return pDest;
+ }
+
+ // Second pass copy into the destination buffer
+ pEnd = pStart;
+ *(nDestLength) = nTokenLength;
+ nTokenLength = 0;
+ // First pass, count required space
+ while ((*pEnd) && (*pEnd != '\r') && (*pEnd != '\n'))
+ {
+ if(*pEnd != 0x20)
+ {
+ pDest[nTokenLength++] = *pEnd;
+ }
+ pEnd++;
+ }
+
+ pDest[nTokenLength] = 0;
+
+ }
+
+
+ return pDest;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Function : HTTPStrGetDigestToken
+// Purpose :
+// Gets :
+// Returns :
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+UINT32 HTTPStrGetDigestToken (HTTP_PARAM pParamSrc, CHAR *pSearched, HTTP_PARAM *pParamDest)
+{
+
+ CHAR Token[HTTP_CLIENT_MAX_TOKEN_NAME_LENGTH];
+ CHAR *pPtrStart, *pPtrEnd, *pPtrEndSrc;
+ BOOL Brackets = FALSE;
+
+ // Build the searched token
+ memset(Token,0x00,HTTP_CLIENT_MAX_TOKEN_NAME_LENGTH);
+ strcpy(Token,pSearched);
+ strcat(Token,"=");
+
+ // Reset destination values
+ pParamDest->nLength = 0;
+ pParamDest->pParam = 0;
+
+ pPtrEndSrc = pParamSrc.pParam + pParamSrc.nLength;
+
+ pPtrStart = HTTPStrCaseStr(pParamSrc.pParam,pParamSrc.nLength,Token);
+ if(pPtrStart)
+ {
+ // Found the token so jump to the end of it
+ pPtrStart += strlen(Token);
+ // jump passed any spaces that may be
+ while ((*pPtrStart) && (*pPtrStart == 0x20) && (pPtrStart != pPtrEndSrc)) pPtrStart++;
+ // Any Brackets around the string?
+ if(*pPtrStart == 0x22) Brackets = TRUE;
+
+
+ switch (Brackets)
+ {
+
+ case TRUE:
+ // Find the next brackets
+ pPtrStart++;
+ pPtrEnd = pPtrStart;
+ while ((*pPtrEnd) && (*pPtrEnd != 0x22) && (*pPtrEnd != 0x0d) && (*pPtrEnd != 0x0a) && (pPtrStart != pPtrEndSrc)) pPtrEnd++;
+ break;
+
+ case FALSE:
+ // Find the next space or comma (0x2c)
+ pPtrEnd = pPtrStart;
+ while ((*pPtrEnd) && (*pPtrEnd != 0x20) && (*pPtrEnd != 0x2c) && (*pPtrEnd != 0x0d) && (*pPtrEnd != 0x0a) && (pPtrStart != pPtrEndSrc)) pPtrEnd++;
+ break;
+
+ };
+
+ pParamDest->nLength = (pPtrEnd - pPtrStart);
+ pParamDest->pParam = pPtrStart;
+
+ return HTTP_CLIENT_SUCCESS;
+ }
+ return HTTP_CLIENT_ERROR_NO_DIGEST_TOKEN;
+
+
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+// Function : HTTPStrHToL
+// Purpose : Convert a hex string "0x00" to long 0
+// Gets : a pointer to the Hex string
+// Last updated : 15/05/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+
+UINT32 HTTPStrHToL (CHAR * s)
+{
+ UINT32 i , nn, digit;
+ UINT32 n ;
+
+ n = i = nn = 0;
+ do
+ {
+ if ( isalnum(s[i]) ) {
+ s[i] = toupper(s[i]) ;
+ if (s[i] == 'X') nn=n=0; else {
+ digit = (isalpha(s[i]) ? (s[i] - 'A' + 10) : s[i] - '0') ;
+ if ( digit > 15 ) digit = 15;
+ n = n * 16 + digit;
+ if (n |= 0) nn++;
+ if (nn == 8) break;}
+ }
+ i++;
+ }
+ while ( s[i] |= 0 );
+ return n ;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+// Function : HTTPStrLToH
+// Purpose : Convert a long to hex string 0 to "00"
+// Gets :
+// Last updated : 15/05/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+CHAR* HTTPStrLToH (CHAR * dest,UINT32 nSrc)
+{
+
+ char *hex = "0123456789abcdef";
+ INT i;
+
+ if (nSrc == 0) {
+ dest[0] = '0';
+ dest[1] = 0;
+ }
+ else
+ {
+ for(i = 28; ((nSrc >> i) && 0xf) == 0; i -= 4);
+ for(; i >= 0; i -= 4) {
+ *dest++ = hex[(nSrc >> i) & 0xf];
+ }
+ *dest = 0;
+ }
+
+ return dest;
+}
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientString.h b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientString.h
new file mode 100644
index 000000000..fdc58e350
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientString.h
@@ -0,0 +1,23 @@
+
+#ifndef _HTTP_CLIENT_STRING
+#define _HTTP_CLIENT_STRING
+
+#include "HTTPClientWrapper.h" // Cross platform support
+#include "HTTPClient.h"
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Section : HTTP Api global definitions
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+BOOL HTTPStrInsensitiveCompare (CHAR *pSrc, CHAR* pDest, UINT32 nLength);
+BOOL HTTPStrSearch (CHAR *pSrc, CHAR *pSearched, UINT32 nOffset, UINT32 nScope,HTTP_PARAM *HttpParam);
+CHAR HTTPStrExtract (CHAR *pParam,UINT32 nOffset,CHAR Restore);
+CHAR* HTTPStrCaseStr (CHAR *pSrc, UINT32 nSrcLength, CHAR *pFind);
+CHAR* HTTPStrGetToken (CHAR *pSrc, UINT32 nSrcLength, CHAR *pDest, UINT32 *nDestLength);
+UINT32 HTTPStrGetDigestToken (HTTP_PARAM pParamSrc, CHAR *pSearched, HTTP_PARAM *pParamDest);
+UINT32 HTTPStrHToL (CHAR * s);
+CHAR* HTTPStrLToH (CHAR * dest,UINT32 nSrc);
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientWrapper.c b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientWrapper.c
new file mode 100644
index 000000000..046b6e0c7
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientWrapper.c
@@ -0,0 +1,348 @@
+
+#include "HTTPClientWrapper.h"
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : Stdc: HTTPWrapperIsAscii
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes : Same as stdc: isascii
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int HTTPWrapperIsAscii(int c)
+{
+ return (!(c & ~0177));
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : Stdc: HTTPWrapperToUpper
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes : Convert character to uppercase.
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int HTTPWrapperToUpper(int c)
+{
+ // -32
+ if(HTTPWrapperIsAscii(c) > 0)
+ {
+ if(c >= 97 && c <= 122)
+ {
+ return (c - 32);
+ }
+ }
+
+ return c;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : Stdc: HTTPWrapperToLower
+// Last updated : 13/06/2006
+// Author Name : Eitan Michaelson
+// Notes : Convert character to lowercase.
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int HTTPWrapperToLower(int c)
+{
+ // +32
+ if(HTTPWrapperIsAscii(c) > 0)
+ {
+ if(c >= 65 && c <= 90)
+ {
+ return (c + 32);
+ }
+ }
+
+ return c;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : Stdc: isalpha
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes : returns nonzero if c is a particular representation of an alphabetic character
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int HTTPWrapperIsAlpha(int c)
+{
+
+ if(HTTPWrapperIsAscii(c) > 0)
+ {
+ if( (c >= 97 && c <= 122) || (c >= 65 && c <= 90))
+ {
+ return c;
+ }
+ }
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : Stdc: isalnum
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes : returns nonzero if c is a particular representation of an alphanumeric character
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int HTTPWrapperIsAlNum(int c)
+{
+ if(HTTPWrapperIsAscii(c) > 0)
+ {
+
+ if(HTTPWrapperIsAlpha(c) > 0)
+ {
+ return c;
+ }
+
+ if( c >= 48 && c <= 57)
+ {
+ return c;
+ }
+
+ }
+ return 0;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : HTTPWrapper_itoa
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes : same as stdc itoa() // hmm.. allmost the same
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+char* HTTPWrapperItoa(char *s,int a)
+{
+
+ unsigned int b;
+ if(a > 2147483647)
+ {
+ return 0; // overflow
+ }
+
+ if (a < 0) b = -a, *s++ = '-';
+ else b = a;
+ for(;a;a=a/10) s++;
+ for(*s='\0';b;b=b/10) *--s=b%10+'0';
+ return s;
+
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : HTTPWrapper_ShutDown
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes : Handles parameter changes in the socket shutdown() function in AMT
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+int HTTPWrapperShutDown (int s,int how)
+{
+ return shutdown(s,how);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : HTTPWrapper_GetSocketError
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes : WSAGetLastError Wrapper (Win32 Specific)
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int HTTPWrapperGetSocketError (int s)
+{
+
+ return WSAGetLastError();
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : HTTPWrapper_GetHostByName
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes : gethostbyname for Win32 (supports the AMT edition of the function)
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+unsigned long HTTPWrapperGetHostByName(char *name,unsigned long *address)
+{
+ HTTP_HOSTNET *HostEntry;
+ int iPos = 0, iLen = 0,iNumPos = 0,iDots =0;
+ long iIPElement;
+ char c = 0;
+ char Num[4];
+ int iHostType = 0; // 0 : numeric IP
+
+ // Check if the name is an IP or host
+ iLen = strlen(name);
+ for(iPos = 0; iPos <= iLen;iPos++)
+ {
+ c = name[iPos];
+ if((c >= 48 && c <= 57) || (c == '.') )
+ {
+ // c is numeric or dot
+ if(c != '.')
+ {
+ // c is numeric
+ if(iNumPos > 3)
+ {
+ iHostType++;
+ break;
+ }
+ Num[iNumPos] = c;
+ Num[iNumPos + 1] = 0;
+ iNumPos ++;
+ }
+ else
+ {
+ iNumPos = 0;
+ iDots++;
+ iIPElement = atol(Num);
+ if(iIPElement > 256 || iDots > 3)
+ {
+ return 0; // error invalid IP
+ }
+ }
+ }
+ else
+ {
+ break; // this is an alpha numeric address type
+ }
+ }
+
+ if(c == 0 && iHostType == 0 && iDots == 3)
+ {
+ iIPElement = atol(Num);
+ if(iIPElement > 256)
+ {
+ return 0; // error invalid IP
+ }
+ }
+ else
+ {
+ iHostType++;
+ }
+
+ if(iHostType > 0)
+ {
+
+ HostEntry = gethostbyname(name);
+ if(HostEntry)
+ {
+ *(address) = *((u_long*)HostEntry->h_addr_list[0]);
+
+ //*(address) = (unsigned long)HostEntry->h_addr_list[0];
+ return 1; // Error
+ }
+ else
+ {
+ return 0; // OK
+ }
+ }
+
+ else // numeric address - no need for DNS resolve
+ {
+ *(address) = inet_addr(name);
+ return 1;
+
+ }
+ return 0;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : HTTPWrapper_GetRandomeNumber
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes : GetRandom number for Win32 & AMT
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void HTTPWrapperInitRandomeNumber()
+{
+ srand((unsigned int)time(NULL));
+}
+
+int HTTPWrapperGetRandomeNumber()
+{
+ int num;
+ num = (int)(((double) rand()/ ((double)RAND_MAX+1)) * 16);
+ return num;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : HTTPWrapper_GetRTC
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes : Get uptime under Win32 & AMT
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+long HTTPWrapperGetUpTime()
+{
+
+ long lTime = 0;
+
+ lTime = (GetTickCount() / CLOCKS_PER_SEC);
+ return lTime;
+
+}
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Section : TSL Wrapper
+// Last updated : 15/05/2005
+// Author Name : Eitan Michaelson
+// Notes : HTTPWrapper_Sec_Connect
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int HTTPWrapperSSLConnect(int s,const struct sockaddr *name,int namelen,char *hostname)
+{
+ return -1;
+}
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int HTTPWrapperSSLNegotiate(int s,const struct sockaddr *name,int namelen,char *hostname)
+{
+ return -1;
+}
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int HTTPWrapperSSLSend(int s,char *buf, int len,int flags)
+{
+ return -1;
+}
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int HTTPWrapperSSLRecv(int s,char *buf, int len,int flags)
+{
+ return -1;
+}
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+int HTTPWrapperSSLRecvPending(int s)
+{
+ return -1;
+}
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+int HTTPWrapperSSLClose(int s)
+{
+ return -1;
+
+}
diff --git a/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientWrapper.h b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientWrapper.h
new file mode 100644
index 000000000..617d918af
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/HTTP_Client/HTTPClientWrapper.h
@@ -0,0 +1,111 @@
+
+#ifndef HTTP_CLIENT_WRAPPER
+#define HTTP_CLIENT_WRAPPER
+
+// Compilation mode
+#define _HTTP_BUILD_WIN32 // Set Windows Build flag
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Section : Microsoft Windows Support
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifdef _HTTP_BUILD_WIN32
+
+#if defined(_MSC_VER)
+ #pragma warning (disable: 4996) // 'function': was declared deprecated (VS 2005)
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <memory.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <time.h>
+#if defined(_WIN32) || defined(WIN32)
+ #include <winsock.h>
+#endif
+
+// Generic types
+typedef unsigned int UINT32;
+typedef int INT32;
+
+// Sockets (Winsock wrapper)
+#define HTTP_ECONNRESET (WSAECONNRESET)
+#define HTTP_EINPROGRESS (WSAEINPROGRESS)
+#define HTTP_EWOULDBLOCK (WSAEWOULDBLOCK)
+#endif
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Section : Functions that are not supported by the AMT stdc framework
+// So they had to be specificaly added.
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ // STDC Wrapper implimentation
+ int HTTPWrapperIsAscii (int c);
+ int HTTPWrapperToUpper (int c);
+ int HTTPWrapperToLower (int c);
+ int HTTPWrapperIsAlpha (int c);
+ int HTTPWrapperIsAlNum (int c);
+ char* HTTPWrapperItoa (char *buff,int i);
+ void HTTPWrapperInitRandomeNumber ();
+ long HTTPWrapperGetUpTime ();
+ int HTTPWrapperGetRandomeNumber ();
+ int HTTPWrapperGetSocketError (int s);
+ unsigned long HTTPWrapperGetHostByName (char *name,unsigned long *address);
+ int HTTPWrapperShutDown (int s,int in);
+ // SSL Wrapper prototypes
+ int HTTPWrapperSSLConnect (int s,const struct sockaddr *name,int namelen,char *hostname);
+ int HTTPWrapperSSLNegotiate (int s,const struct sockaddr *name,int namelen,char *hostname);
+ int HTTPWrapperSSLSend (int s,char *buf, int len,int flags);
+ int HTTPWrapperSSLRecv (int s,char *buf, int len,int flags);
+ int HTTPWrapperSSLClose (int s);
+ int HTTPWrapperSSLRecvPending (int s);
+ // Global wrapper Functions
+#define IToA HTTPWrapperItoa
+#define GetUpTime HTTPWrapperGetUpTime
+#define SocketGetErr HTTPWrapperGetSocketError
+#define HostByName HTTPWrapperGetHostByName
+#define InitRandomeNumber HTTPWrapperInitRandomeNumber
+#define GetRandomeNumber HTTPWrapperGetRandomeNumber
+
+#ifdef __cplusplus
+}
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Section : Global type definitions
+// Last updated : 01/09/2005
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#define VOID void
+#ifndef NULL
+#define NULL 0
+#endif
+#define TRUE 1
+#define FALSE 0
+typedef char CHAR;
+typedef unsigned short UINT16;
+typedef int BOOL;
+typedef unsigned long ULONG;
+
+// Global socket structures and definitions
+#define HTTP_INVALID_SOCKET (-1)
+typedef struct sockaddr_in HTTP_SOCKADDR_IN;
+typedef struct timeval HTTP_TIMEVAL;
+typedef struct hostent HTTP_HOSTNET;
+typedef struct sockaddr HTTP_SOCKADDR;
+typedef struct in_addr HTTP_INADDR;
+
+
+#endif // HTTP_CLIENT_WRAPPER
diff --git a/src/thirdparty/ZenLib/ZenLib/InfoMap.cpp b/src/thirdparty/ZenLib/ZenLib/InfoMap.cpp
new file mode 100644
index 000000000..38532416d
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/InfoMap.cpp
@@ -0,0 +1,182 @@
+// ZenLib::InfoMap - Helper for InfoMap
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef ZENLIB_USEWX
+ #include <wx/strconv.h>
+#endif //ZENLIB_USEWX
+#include <algorithm>
+#include "ZenLib/InfoMap.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//---------------------------------------------------------------------------
+const Ztring InfoMap_EmptyZtring_Const; //Use it when we can't return a reference to a true Ztring, const version
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Constructors/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Constructors
+InfoMap::InfoMap()
+: std::multimap<ZenLib::Ztring, ZenLib::ZtringList> ()
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+}
+
+InfoMap::InfoMap(const Ztring &Source)
+: std::multimap<ZenLib::Ztring, ZenLib::ZtringList> ()
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+ Write(Source);
+}
+
+InfoMap::InfoMap(const Char *Source)
+: std::multimap<ZenLib::Ztring, ZenLib::ZtringList> ()
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+ Write(Source);
+}
+
+#ifdef _UNICODE
+InfoMap::InfoMap (const char* S)
+: std::multimap<ZenLib::Ztring, ZenLib::ZtringList> ()
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+ Write(Ztring(S));
+}
+#endif
+
+//***************************************************************************
+// In/Out
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+const Ztring &InfoMap::Get (const Ztring &Value, size_t Pos) const
+{
+ InfoMap::const_iterator List=find(Value);
+ if (List==end())
+ return InfoMap_EmptyZtring_Const; //Not found
+ if (Pos<List->second.size())
+ return List->second[Pos];
+ else
+ return InfoMap_EmptyZtring_Const; //Not found
+}
+
+//---------------------------------------------------------------------------
+const Ztring &InfoMap::Get (const Ztring &Value, size_t Pos, const Ztring &WithValue, size_t WithValue_Pos) const
+{
+ InfoMap::const_iterator List=find(Value);
+ if (List==end())
+ return InfoMap_EmptyZtring_Const; //Not found
+ if (Pos<List->second.size())
+ {
+ if (List->second[WithValue_Pos]==WithValue)
+ return List->second[Pos];
+ else
+ {
+ List++; //The second one, this is a stupid hack for a 2 value, should be changed later...
+ if (Pos<List->second.size())
+ {
+ if (List->second[WithValue_Pos]==WithValue)
+ return List->second[Pos];
+ else
+ return InfoMap_EmptyZtring_Const; //Not found
+ }
+ else
+ return InfoMap_EmptyZtring_Const; //Not found
+ }
+ }
+ else
+ return InfoMap_EmptyZtring_Const; //Not found
+}
+
+//---------------------------------------------------------------------------
+// Set
+void InfoMap::Write(const Ztring &NewInfoMap)
+{
+ clear();
+
+ if (!&NewInfoMap || !NewInfoMap.size())
+ return;
+
+ size_t Pos1=0, Pos2_EOL=0, Pos2_Separator=0;
+
+ while (Pos2_EOL!=(size_t)-1)
+ {
+ Pos2_EOL=NewInfoMap.find(_T('\n'), Pos1);
+ Pos2_Separator=NewInfoMap.find(_T(';'), Pos1);
+ if (Pos2_Separator<Pos2_EOL)
+ {
+ ZtringList List; List.Write(NewInfoMap.substr(Pos1, Pos2_EOL-Pos1));
+ insert (pair<Ztring, ZtringList>(NewInfoMap.substr(Pos1, Pos2_Separator-Pos1), List));
+ }
+ Pos1=Pos2_EOL+1;
+ }
+}
+
+//***************************************************************************
+// Configuration
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Separator
+void InfoMap::Separator_Set (size_type Level, const Ztring &NewSeparator)
+{
+ if (Level>1)
+ return;
+
+ Separator[Level]=NewSeparator;
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //namespace
+
+
+
+
+
+
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/InfoMap.h b/src/thirdparty/ZenLib/ZenLib/InfoMap.h
new file mode 100644
index 000000000..e179cf068
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/InfoMap.h
@@ -0,0 +1,77 @@
+// ZenLib::InfoMap - Helper for InfoMap
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+//
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_InfoMapH
+#define ZenLib_InfoMapH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/ZtringList.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+/// @brief Helper for InfoMap
+//***************************************************************************
+
+class InfoMap : public std::multimap<Ztring, ZtringList>
+{
+public :
+ //Constructors/Destructor
+ InfoMap ();
+ InfoMap (const Ztring &Source);
+ InfoMap (const Char *Source);
+ #ifdef _UNICODE
+ InfoMap (const char *Source); //convert a UTF-8 string into Unicode
+ #endif
+
+ //In/Out
+ const Ztring &Get (const Ztring &Value, size_t Pos) const;
+ const Ztring &Get (const Ztring &Value, size_t Pos, const Ztring &WithValue, size_t WithValue_Pos) const;
+ void Write (const Ztring &NewLanguage);
+
+ //Configuration
+ /// @brief Set the Separator character
+ void Separator_Set (size_type Level, const Ztring &NewSeparator);
+ /// @brief Set the Quote character
+ /// During Read() or Write() method, if Separator is in the sequence, we must quote it
+ void Quote_Set (const Ztring &NewQuote);
+ /// @brief Set the Maximum number of element to read
+ /// During Read() or Write() method, if there is more elements, merge them with the last element
+ void Max_Set (size_type Level, size_type Max);
+
+protected :
+ Ztring Separator[2];
+ Ztring Quote;
+ size_type Max[2];
+};
+
+} //namespace
+#endif
+
diff --git a/src/thirdparty/ZenLib/ZenLib/MemoryDebug.cpp b/src/thirdparty/ZenLib/ZenLib/MemoryDebug.cpp
new file mode 100644
index 000000000..6122ddeba
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/MemoryDebug.cpp
@@ -0,0 +1,201 @@
+// ZenLib::MemoryDebug - To debug memory leaks
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(ZENLIB_DEBUG)
+//---------------------------------------------------------------------------
+#include <iomanip>
+#include <sstream>
+#include "ZenLib/MemoryDebug.h"
+#include "ZenLib/Ztring.h"
+#ifdef WINDOWS
+ #include <io.h>
+#else
+ #include <cstdio>
+#endif
+#include <fcntl.h>
+#include <sys/stat.h>
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Constructors/destructor
+//***************************************************************************
+
+MemoryDebug::MemoryDebug()
+{
+}
+
+MemoryDebug::~MemoryDebug()
+{
+ if (!m_Blocks.empty())
+ ReportLeaks();
+}
+
+//***************************************************************************
+// Instance
+//***************************************************************************
+
+MemoryDebug& MemoryDebug::Instance()
+{
+ static MemoryDebug Inst;
+ return Inst;
+}
+
+//***************************************************************************
+// Reports
+//***************************************************************************
+
+void MemoryDebug::ReportLeaks()
+{
+ Ztring m_File;
+ //std::ofstream m_File ("Debug_MemoryLeak.txt"); // Fichier de sortie
+
+ // Détail des fuites
+ std::size_t TotalSize = 0;
+ for (TBlockMap::iterator i = m_Blocks.begin(); i != m_Blocks.end(); ++i)
+ {
+ // Ajout de la taille du bloc au cumul
+ TotalSize += i->second.Size;
+
+ // Inscription dans le fichier des informations sur le bloc courant
+ /*
+ m_File << "-> 0x" << std::hex << i->first << std::dec
+ << " | " << std::setw(7) << std::setfill(' ') << static_cast<int>(i->second.Size) << " bytes"
+ << " | " << i->second.File.c_str() << " (" << i->second.Line << ")" << std::endl;
+ */
+ m_File.append(_T("-> 0x"));
+ m_File.append(Ztring::ToZtring((size_t)i->first, 16));
+ m_File.append(_T(" | "));
+ Ztring Temp;
+ Temp.From_Number(static_cast<int>(i->second.Size));
+ while(Temp.size()<7)
+ Temp=_T(" ")+Temp;
+ m_File.append(Temp);
+ m_File.append(_T(" bytes"));
+ m_File.append(_T(" | "));
+ m_File.append(Ztring().From_Local(i->second.File.c_str()));
+ m_File.append(_T(" ("));
+ m_File.append(Ztring::ToZtring(i->second.Line));
+ m_File.append(_T(")"));
+ m_File.append(EOL);
+ }
+
+ // Affichage du cumul des fuites
+ /*
+ m_File << std::endl << std::endl << "-- "
+ << static_cast<int>(m_Blocks.size()) << " non-released blocs, "
+ << static_cast<int>(TotalSize) << " bytes --"
+ << std::endl;
+ */
+ m_File.append(EOL);
+ m_File.append(EOL);
+ m_File.append(_T("-- "));
+ m_File.append(Ztring::ToZtring(static_cast<int>(m_Blocks.size())));
+ m_File.append(_T(" non-released blocs, "));
+ m_File.append(Ztring::ToZtring(static_cast<int>(TotalSize)));
+ m_File.append(_T(" bytes --"));
+ m_File.append(EOL);
+
+ std::string ToWrite=m_File.To_Local().c_str();
+ int m_File_sav=open("Debug_MemoryLeak.txt", O_BINARY|O_RDWR |O_CREAT); // Fichier de sortie
+ write(m_File_sav, (int8u*)ToWrite.c_str(), ToWrite.size());
+ close(m_File_sav);
+}
+
+//***************************************************************************
+// Memory management
+//***************************************************************************
+
+void* MemoryDebug::Allocate(std::size_t Size, const char* File, int Line, bool Array)
+{
+ // Allocation de la mémoire
+ void* Ptr = malloc(Size);
+
+ // Ajout du bloc à la liste des blocs alloués
+ TBlock NewBlock;
+ NewBlock.Size = Size;
+ NewBlock.File = File;
+ NewBlock.Line = Line;
+ NewBlock.Array = Array;
+ m_Blocks[Ptr] = NewBlock;
+ return Ptr;
+}
+
+void MemoryDebug::Free(void* Ptr, bool Array)
+{
+ // Recherche de l'adresse dans les blocs alloués
+ TBlockMap::iterator It = m_Blocks.find(Ptr);
+
+ // Si le bloc n'a pas été alloué, on génère une erreur
+ if (It == m_Blocks.end())
+ {
+ // En fait ça arrive souvent, du fait que le delete surcharge est pris en compte meme la ou on n'inclue pas DebugNew.h,
+ // mais pas la macro pour le new
+ // Dans ce cas on détruit le bloc et on quitte immédiatement
+ free(Ptr);
+ return;
+ }
+
+ // Si le type d'allocation ne correspond pas, on génère une erreur
+ if (It->second.Array != Array)
+ {
+ //throw CBadDelete(Ptr, It->second.File.c_str(), It->second.Line, !Array);
+ }
+
+ // Finalement, si tout va bien, on supprime le bloc et on loggiz tout ça
+ m_Blocks.erase(It);
+ m_DeleteStack.pop();
+
+ // Libération de la mémoire
+ free(Ptr);
+}
+
+void MemoryDebug::NextDelete(const char* File, int Line)
+{
+ TBlock Delete;
+ Delete.File = File;
+ Delete.Line = Line;
+
+ m_DeleteStack.push(Delete);
+}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+} //NameSpace
+
+#endif // defined(ZENLIB_DEBUG)
diff --git a/src/thirdparty/ZenLib/ZenLib/MemoryDebug.h b/src/thirdparty/ZenLib/ZenLib/MemoryDebug.h
new file mode 100644
index 000000000..c01cd2216
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/MemoryDebug.h
@@ -0,0 +1,130 @@
+// ZenLib::MemoryDebug - To debug memory leaks
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// MemoryDebug
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Provide "new" and "delete" overloadings to be able to detect memory leaks
+// Based on http://loulou.developpez.com/tutoriels/moteur3d/partie1/ 2.2.1
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenMemoryDebugH
+#define ZenMemoryDebugH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(ZENLIB_DEBUG)
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+#include <fstream>
+#include <map>
+#include <stack>
+#include <string>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Class
+//***************************************************************************
+
+class MemoryDebug
+{
+public :
+ ~MemoryDebug();
+ static MemoryDebug& Instance();
+
+ void* Allocate(std::size_t Size, const char* File, int Line, bool Array);
+ void Free(void* Ptr, bool Array);
+ void NextDelete(const char*, int Line); //Sauvegarde les infos sur la désallocation courante
+
+private :
+ MemoryDebug();
+ void ReportLeaks();
+ struct TBlock
+ {
+ std::size_t Size; // Taille allouée
+ std::string File; // Fichier contenant l'allocation
+ int Line; // Ligne de l'allocation
+ bool Array; // Est-ce un objet ou un tableau ?
+ };
+ typedef std::map<void*, TBlock> TBlockMap;
+
+ TBlockMap m_Blocks; // Blocs de mémoire alloués
+ std::stack<TBlock> m_DeleteStack; // Pile dont le sommet contient la ligne et le fichier de la prochaine désallocation
+};
+
+} //NameSpace
+
+//***************************************************************************
+// operator overloadings
+//***************************************************************************
+
+inline void* operator new(std::size_t Size, const char* File, int Line)
+{
+ return ZenLib::MemoryDebug::Instance().Allocate(Size, File, Line, false);
+}
+inline void* operator new[](std::size_t Size, const char* File, int Line)
+{
+ return ZenLib::MemoryDebug::Instance().Allocate(Size, File, Line, true);
+}
+
+inline void operator delete(void* Ptr)
+{
+ ZenLib::MemoryDebug::Instance().Free(Ptr, false);
+}
+
+inline void operator delete[](void* Ptr)
+{
+ ZenLib::MemoryDebug::Instance().Free(Ptr, true);
+}
+
+#if !defined(__BORLANDC__) // Borland does not support overloaded delete
+inline void operator delete(void* Ptr, const char* File, int Line)
+{
+ ZenLib::MemoryDebug::Instance().NextDelete(File, Line);
+ ZenLib::MemoryDebug::Instance().Free(Ptr, false);
+}
+
+inline void operator delete[](void* Ptr, const char* File, int Line)
+{
+ ZenLib::MemoryDebug::Instance().NextDelete(File, Line);
+ ZenLib::MemoryDebug::Instance().Free(Ptr, true);
+}
+#endif
+
+#if !defined(__MINGW32__) //TODO: Does not work on MinGW, don't know why
+#ifndef new
+ #define new new(__FILE__, __LINE__)
+#endif
+#ifndef delete
+ #define delete ZenLib::MemoryDebug::Instance().NextDelete(__FILE__, __LINE__), delete
+#endif
+#endif // __MINGW32__
+
+#endif // defined(ZENLIB_DEBUG)
+
+#endif // ZenMemoryDebugH
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/OS_Utils.cpp b/src/thirdparty/ZenLib/ZenLib/OS_Utils.cpp
new file mode 100644
index 000000000..e156892f3
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/OS_Utils.cpp
@@ -0,0 +1,233 @@
+// ZenLib::OS_Utils - Cross platform OS utils
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef ZENLIB_USEWX
+#else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ #undef __TEXT
+ #include <windows.h>
+ #include <shlobj.h>
+ #endif
+#endif //ZENLIB_USEWX
+#include "ZenLib/OS_Utils.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// OS info
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool IsWin9X ()
+{
+ #ifdef ZENLIB_USEWX
+ return true;
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ if (GetVersion()<0x80000000)
+ return false;
+ else
+ return true;
+ #else //WINDOWS
+ return true;
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//***************************************************************************
+// Shell
+//***************************************************************************
+
+void Shell_Execute(const Ztring &ToExecute)
+{
+ #ifdef ZENLIB_USEWX
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ #ifdef UNICODE
+ if (IsWin9X())
+ ShellExecuteA(NULL, "open", ToExecute.To_Local().c_str(), NULL, NULL, 0);
+ else
+ ShellExecute (NULL, _T("open"), ToExecute.c_str(), NULL, NULL, 0);
+ #else
+ ShellExecute(NULL, _T("open"), ToExecute.c_str(), NULL, NULL, 0);
+ #endif
+ #else
+ //Not supported
+ #endif
+ #endif //ZENLIB_USEWX
+}
+
+//***************************************************************************
+// Directories
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Select directory code
+// Extracted from TBffolder by Torsten Johann (t-johann@gmx.de)
+
+Ztring Directory_Select_Caption;
+
+#ifdef WINDOWS
+ #ifdef UNICODE
+ char InitDirA[MAX_PATH];
+ wchar_t InitDir [MAX_PATH];
+
+ int __stdcall ShowOpenFolder_CallbackProc (HWND hwnd, UINT uMsg, LPARAM, LPARAM)
+ {
+ if (uMsg==BFFM_INITIALIZED)
+ {
+ if (IsWin9X())
+ {
+ SetWindowTextA (hwnd, Directory_Select_Caption.To_Local().c_str()); // Caption
+ SendMessageA (hwnd, BFFM_ENABLEOK, 0, TRUE);
+ SendMessageA (hwnd, BFFM_SETSELECTION, true, (LPARAM)&InitDirA);
+ }
+ else
+ {
+ SetWindowText (hwnd, Directory_Select_Caption.c_str()); // Caption
+ SendMessage (hwnd, BFFM_ENABLEOK, 0, TRUE);
+ SendMessage (hwnd, BFFM_SETSELECTION, true, (LPARAM)&InitDir);
+ }
+ }
+ return 0;
+ }
+
+ Ztring OpenFolder_Show(void* Handle, const Ztring &Title, const Ztring &Caption)
+ {
+ //Caption
+ Directory_Select_Caption=Caption;
+
+ if (IsWin9X())
+ {
+ return Ztring(); //Not supported in Win9X
+ }
+ else
+ {
+ //Values
+ LPMALLOC Malloc;
+ LPSHELLFOLDER ShellFolder;
+ BROWSEINFO BrowseInfo;
+ LPITEMIDLIST ItemIdList;
+
+ //Initializing the SHBrowseForFolder function
+ if (SHGetMalloc(&Malloc)!=NOERROR)
+ return Ztring();
+ if (SHGetDesktopFolder(&ShellFolder)!=NOERROR)
+ return Ztring();
+ ZeroMemory(&BrowseInfo, sizeof(BROWSEINFOW));
+ BrowseInfo.ulFlags+=BIF_RETURNONLYFSDIRS;
+ BrowseInfo.hwndOwner=(HWND)Handle;
+ BrowseInfo.pszDisplayName=InitDir;
+ BrowseInfo.lpszTitle=Title.c_str();
+ BrowseInfo.lpfn=ShowOpenFolder_CallbackProc;
+
+ //Displaying
+ ItemIdList=SHBrowseForFolder(&BrowseInfo);
+
+ //Releasing
+ ShellFolder->Release();
+ if (ItemIdList!=NULL)
+ {
+ SHGetPathFromIDList(ItemIdList, InitDir);
+ Malloc->Free(ItemIdList);
+ Malloc->Release();
+
+ //The value
+ return InitDir;
+ }
+ else
+ return Ztring();
+ }
+ }
+
+ #else
+ char InitDirA[MAX_PATH];
+
+ int __stdcall ShowOpenFolder_CallbackProc (HWND hwnd, UINT uMsg, LPARAM, LPARAM)
+ {
+ if (uMsg==BFFM_INITIALIZED)
+ {
+ SetWindowText (hwnd, Directory_Select_Caption.c_str()); // Caption
+ SendMessage (hwnd, BFFM_ENABLEOK, 0, TRUE);
+ SendMessage (hwnd, BFFM_SETSELECTION, true, (LPARAM)&InitDirA);
+ }
+ return 0;
+ }
+
+ Ztring OpenFolder_Show(void* Handle, const Ztring &Title, const Ztring &Caption)
+ {
+ //Caption
+ Directory_Select_Caption=Caption;
+
+ //Values
+ LPMALLOC Malloc;
+ LPSHELLFOLDER ShellFolder;
+ BROWSEINFO BrowseInfo;
+ LPITEMIDLIST ItemIdList;
+
+ //Initializing the SHBrowseForFolder function
+ if (SHGetMalloc(&Malloc)!=NOERROR)
+ return Ztring();
+ if (SHGetDesktopFolder(&ShellFolder)!=NOERROR)
+ return Ztring();
+ ZeroMemory(&BrowseInfo, sizeof(BROWSEINFO));
+ BrowseInfo.ulFlags+=BIF_RETURNONLYFSDIRS;
+ BrowseInfo.hwndOwner=(HWND)Handle;
+ BrowseInfo.pszDisplayName=InitDirA;
+ BrowseInfo.lpszTitle=Title.c_str();
+ BrowseInfo.lpfn=ShowOpenFolder_CallbackProc;
+
+ //Displaying
+ ItemIdList=SHBrowseForFolder(&BrowseInfo);
+
+ //Releasing
+ ShellFolder->Release();
+ if (ItemIdList!=NULL)
+ {
+ SHGetPathFromIDList(ItemIdList, InitDirA);
+ Malloc->Free(ItemIdList);
+ Malloc->Release();
+
+ //The value
+ return InitDirA;
+ }
+ else
+ return Ztring();
+ }
+ #endif //UNICODE
+#endif //WINDOWS
+
+} //namespace ZenLib
diff --git a/src/thirdparty/ZenLib/ZenLib/OS_Utils.h b/src/thirdparty/ZenLib/ZenLib/OS_Utils.h
new file mode 100644
index 000000000..7e0513e19
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/OS_Utils.h
@@ -0,0 +1,64 @@
+// ZenLib::OS_Utils - Cross platform OS utils
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenOS_UtilsH
+#define ZenOS_UtilsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+#include "ZenLib/Ztring.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// OS Information
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool IsWin9X ();
+#ifdef WINDOWS
+#ifndef ZENLIB_NO_WIN9X_SUPPORT
+inline bool IsWin9X_Fast ()
+{
+ return GetVersion()>=0x80000000;
+}
+#endif //ZENLIB_NO_WIN9X_SUPPORT
+#endif //WINDOWS
+
+//***************************************************************************
+// Execute
+//***************************************************************************
+
+void Shell_Execute(const Ztring &ToExecute);
+
+//***************************************************************************
+// Directorues
+//***************************************************************************
+
+Ztring OpenFolder_Show(void* Handle, const Ztring &Title, const Ztring &Caption);
+
+} //namespace ZenLib
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/PreComp.cpp b/src/thirdparty/ZenLib/ZenLib/PreComp.cpp
new file mode 100644
index 000000000..b086a0953
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/PreComp.cpp
@@ -0,0 +1,25 @@
+// PreComp - PreComp file for ZenLib
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+//---------------------------------------------------------------------------
+
diff --git a/src/thirdparty/ZenLib/ZenLib/PreComp.h b/src/thirdparty/ZenLib/ZenLib/PreComp.h
new file mode 100644
index 000000000..aeea94701
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/PreComp.h
@@ -0,0 +1,44 @@
+// PreComp - PreComp file for ZenLib
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Helpers for compilers (precompilation)
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_PreCompH
+#define ZenLib_PreCompH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+ #include <cstring>
+ #include <cstdio>
+ #include <cstdlib>
+ #include <ctime>
+ #include <algorithm>
+ #include <map>
+ #include <sstream>
+ #include <iomanip>
+ #include <cmath>
+ #include "ZenLib/Conf.h"
+ #include "ZenLib/Conf_Internal.h"
+#endif //defined(_MSC_VER) || defined(__BORLANDC__)
+//---------------------------------------------------------------------------
+
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/Thread.cpp b/src/thirdparty/ZenLib/ZenLib/Thread.cpp
new file mode 100644
index 000000000..0d612177e
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Thread.cpp
@@ -0,0 +1,654 @@
+// ZenLib::Thread - Thread functions
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Thread.h"
+#include <ZenLib/Ztring.h>
+#include <ZenLib/CriticalSection.h>
+//---------------------------------------------------------------------------
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// ZENLIB_USEWX
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#ifdef ZENLIB_USEWX
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include <wx/thread.h>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+class ThreadEntry : public wxThread
+{
+public :
+ ThreadEntry(Thread* Th_) : wxThread(wxTHREAD_JOINABLE)
+ {Th=Th_;};
+ void* Entry() {Th->Entry(); return NULL;}
+private :
+ Thread* Th;
+};
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Thread::Thread()
+{
+ ThreadPointer=(void*)new ThreadEntry(this);
+ ((ThreadEntry*)ThreadPointer)->Create();
+}
+
+//---------------------------------------------------------------------------
+Thread::~Thread()
+{
+ delete (ThreadEntry*)ThreadPointer;
+}
+
+//***************************************************************************
+// Main Entry
+//***************************************************************************
+
+void Thread::Entry()
+{
+}
+
+//***************************************************************************
+// Control
+//***************************************************************************
+
+void Thread::Run()
+{
+ ((ThreadEntry*)ThreadPointer)->Resume();
+}
+
+void Thread::Pause()
+{
+ ((ThreadEntry*)ThreadPointer)->Pause();
+}
+
+void Thread::Stop()
+{
+ ((ThreadEntry*)ThreadPointer)->Delete();
+}
+
+bool Thread::IsRunning()
+{
+ return ((ThreadEntry*)ThreadPointer)->IsRunning();
+}
+
+//***************************************************************************
+// Communicating
+//***************************************************************************
+
+void Thread::Sleep(size_t Millisecond)
+{
+ ((ThreadEntry*)ThreadPointer)->Sleep((unsigned long)Millisecond);
+}
+
+void Thread::Yield()
+{
+ ((ThreadEntry*)ThreadPointer)->Yield();
+}
+
+} //Namespace
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// WINDOWS
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#else //ZENLIB_USEWX
+#ifdef WINDOWS
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#undef __TEXT
+#include <windows.h>
+#undef Yield
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+//Config
+
+#ifndef _MT
+ #define _MT //Must have this symbol defined to get _beginthread/_endthread declarations
+#endif
+
+#ifdef __BORLANDC__
+ #if !defined(__MT__)
+ #define __MT__ //-tWM in the IDE is not always set
+ #endif
+
+ #if !defined(__MFC_COMPAT__)
+ #define __MFC_COMPAT__ // Needed to know about _beginthreadex etc..
+ #endif
+#endif //__BORLANDC__
+
+
+#if defined(_MSC_VER) || \
+ (defined(__GNUG__) && defined(__MSVCRT__)) || \
+ defined(__WATCOMC__) || \
+ defined(__MWERKS__)
+ //(defined(__BORLANDC__) && (__BORLANDC__ >= 0x500))
+
+ #ifndef __WXWINCE__
+ #define USING_BEGINTHREAD //Using _beginthreadex() instead of CreateThread() if possible (better, because of Win32 API has problems with memory leaks in C library)
+ #endif
+#endif
+
+#ifdef USING_BEGINTHREAD
+ #include <process.h>
+ typedef unsigned THREAD_RETVAL; //The return type of the thread function entry point
+ #define THREAD_CALLCONV __stdcall //The calling convention of the thread function entry point
+#else
+ // the settings for CreateThread()
+ typedef DWORD THREAD_RETVAL;
+ #define THREAD_CALLCONV WINAPI
+#endif
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//---------------------------------------------------------------------------
+THREAD_RETVAL THREAD_CALLCONV Thread_Start(void *param)
+{
+ ((Thread*)param)->Entry();
+
+ ((Thread*)param)->Internal_Exit();
+
+ return 1;
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Thread::Thread()
+{
+ C.Enter();
+
+ State=State_New;
+ ThreadPointer=NULL;
+
+ C.Leave();
+}
+
+//---------------------------------------------------------------------------
+Thread::~Thread()
+{
+ C.Enter();
+
+ if (ThreadPointer!=NULL)
+ CloseHandle((HANDLE)ThreadPointer); //ThreadPointer=NULL
+
+ C.Leave();
+}
+
+//***************************************************************************
+// Control
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Thread::returnvalue Thread::Run()
+{
+ C.Enter();
+
+ //Coherency
+ if (State!=State_New || ThreadPointer!=NULL)
+ {
+ C.Leave();
+ return Incoherent;
+ }
+
+ //Creating
+ #ifdef USING_BEGINTHREAD
+ #ifdef __WATCOMC__
+ const unsigned stksize=10240; //Watcom is reported to not like 0 stack size (which means "use default")
+ #else
+ const unsigned stksize=0; //Default
+ #endif //__WATCOMC__
+
+ ThreadPointer=(void*)_beginthreadex (NULL, stksize, Thread_Start, this, CREATE_SUSPENDED, NULL);
+ #else
+ ThreadPointer=(void*)CreateThread (NULL, 0, Thread_Start, this, CREATE_SUSPENDED, NULL);
+ #endif //USING_BEGINTHREAD
+ if (ThreadPointer==NULL)
+ {
+ C.Leave();
+ return Resource;
+ }
+
+ //Running
+ ResumeThread((HANDLE)ThreadPointer);
+
+ //Configuring
+ State=State_Running;
+
+ C.Leave();
+ return Ok;
+}
+
+//---------------------------------------------------------------------------
+Thread::returnvalue Thread::RunAgain()
+{
+ //Coherency
+ C.Enter();
+
+ //Coherency
+ if (State!=State_New
+ && State!=State_Terminated)
+ {
+ C.Leave();
+ return Incoherent;
+ }
+
+ //Configuring
+ if (State==State_Terminated)
+ State=State_New;
+
+ C.Leave();
+
+ return Run();
+}
+
+//---------------------------------------------------------------------------
+Thread::returnvalue Thread::Pause()
+{
+ C.Enter();
+
+ //Pausing
+ SuspendThread((HANDLE)ThreadPointer);
+
+ //Configuring
+ State=State_Paused;
+
+ C.Leave();
+ return Ok;
+}
+
+//---------------------------------------------------------------------------
+Thread::returnvalue Thread::RequestTerminate()
+{
+ C.Enter();
+
+ //Coherency
+ if (State!=State_Running)
+ {
+ C.Leave();
+ return IsNotRunning;
+ }
+
+ //Configuring
+ State=State_Terminating;
+
+ C.Leave();
+ return Ok;
+}
+
+//---------------------------------------------------------------------------
+Thread::returnvalue Thread::ForceTerminate()
+{
+ C.Enter();
+
+ //Terminating (not clean)
+ TerminateThread((HANDLE)ThreadPointer, 1); ThreadPointer=NULL;
+
+ //Configuring
+ State=State_Terminated;
+
+ C.Leave();
+ return Ok;
+}
+
+//***************************************************************************
+// Status
+//***************************************************************************
+
+bool Thread::IsRunning()
+{
+ C.Enter();
+ bool ToReturn=State==State_Running;
+ C.Leave();
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+bool Thread::IsTerminating()
+{
+ C.Enter();
+ bool ToReturn=State==State_Terminating;
+ C.Leave();
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+bool Thread::IsExited()
+{
+ C.Enter();
+ bool ToReturn=State==State_New || State==State_Terminating;
+ C.Leave();
+ return ToReturn;
+}
+
+//***************************************************************************
+// Main Entry
+//***************************************************************************
+
+void Thread::Entry()
+{
+}
+
+//***************************************************************************
+// Communicating
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+void Thread::Sleep(size_t Millisecond)
+{
+ ::Sleep((DWORD)Millisecond);
+}
+
+//---------------------------------------------------------------------------
+void Thread::Yield()
+{
+ ::Sleep(0);
+}
+
+//***************************************************************************
+// Internal
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Thread::returnvalue Thread::Internal_Exit()
+{
+ C.Enter();
+
+ //Coherency
+ if (State!=State_Running
+ && State!=State_Terminating)
+ {
+ C.Leave();
+ return IsNotRunning;
+ }
+
+ //Closing old handle
+ CloseHandle((HANDLE)ThreadPointer); ThreadPointer=NULL;
+
+ //Configuring
+ State=State_Terminated;
+
+ C.Leave();
+ return Ok;
+}
+
+} //Namespace
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// UNIX
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#else //WINDOWS
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+//Source: http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include <pthread.h>
+#include <unistd.h>
+#ifdef _POSIX_PRIORITY_SCHEDULING
+ #include <sched.h>
+#endif //_POSIX_PRIORITY_SCHEDULING
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//---------------------------------------------------------------------------
+void *Thread_Start(void *param)
+{
+ ((Thread*)param)->Entry();
+ ((Thread*)param)->Internal_Exit();
+
+ return NULL;
+}
+
+//***************************************************************************
+// Constructor/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+Thread::Thread()
+{
+ C.Enter();
+
+ State=State_New;
+ ThreadPointer=NULL;
+
+ C.Leave();
+
+}
+
+//---------------------------------------------------------------------------
+Thread::~Thread()
+{
+}
+
+//***************************************************************************
+// Main Entry
+//***************************************************************************
+
+void Thread::Entry()
+{
+}
+
+//***************************************************************************
+// Control
+//***************************************************************************
+
+Thread::returnvalue Thread::Run()
+{
+ C.Enter();
+
+ //Coherency
+ if (State!=State_New || ThreadPointer!=NULL)
+ {
+ C.Leave();
+ return Incoherent;
+ }
+
+ //Creating
+ pthread_attr_t Attr;
+ pthread_attr_init(&Attr);
+ pthread_attr_setdetachstate(&Attr, PTHREAD_CREATE_DETACHED);
+
+ //Running
+ pthread_create((pthread_t*)&ThreadPointer, &Attr, Thread_Start, (void*)this);
+
+ //Configuring
+ State=State_Running;
+
+ C.Leave();
+ return Ok;
+}
+
+Thread::returnvalue Thread::RunAgain()
+{
+ //Coherency
+ C.Enter();
+
+ //Coherency
+ if (State!=State_New
+ && State!=State_Terminated)
+ {
+ C.Leave();
+ return Incoherent;
+ }
+
+ //Configuring
+ if (State==State_Terminated)
+ State=State_New;
+
+ C.Leave();
+
+ return Run();
+}
+
+Thread::returnvalue Thread::Pause()
+{
+ //pthread_cond_wait
+ return Ok;
+}
+
+Thread::returnvalue Thread::RequestTerminate()
+{
+ C.Enter();
+
+ if (State!=State_Running)
+ {
+ C.Leave();
+ return IsNotRunning;
+ }
+
+ State=State_Terminating;
+
+ C.Leave();
+ return Ok;
+}
+
+Thread::returnvalue Thread::ForceTerminate()
+{
+ //Terminating (not clean)
+
+ //Configuring
+ State=State_Terminated;
+
+ return Ok;
+}
+
+//***************************************************************************
+// Status
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+bool Thread::IsRunning()
+{
+ C.Enter();
+ bool ToReturn=State==State_Running;
+ C.Leave();
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+bool Thread::IsTerminating()
+{
+ C.Enter();
+ bool ToReturn=State==State_Terminating;
+ C.Leave();
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+bool Thread::IsExited()
+{
+ C.Enter();
+ bool ToReturn=State==State_New || State==State_Terminating;
+ C.Leave();
+ return ToReturn;
+}
+
+//***************************************************************************
+// Communicating
+//***************************************************************************
+
+void Thread::Sleep(size_t)
+{
+}
+
+void Thread::Yield()
+{
+ #ifdef _POSIX_PRIORITY_SCHEDULING
+ sched_yield();
+ #endif //_POSIX_PRIORITY_SCHEDULING
+}
+
+//***************************************************************************
+// Internal
+//***************************************************************************
+
+Thread::returnvalue Thread::Internal_Exit()
+{
+ C.Enter();
+
+ //Coherency
+ if (State!=State_Running
+ && State!=State_Terminating)
+ {
+ C.Leave();
+ return IsNotRunning;
+ }
+
+ //Closing old handle
+ ; ThreadPointer=NULL;
+
+ //Configuring
+ State=State_Terminated;
+
+ C.Leave();
+ return Ok;
+}
+
+} //Namespace
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+#endif //WINDOWS
+#endif //ZENLIB_USEWX
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Thread.h b/src/thirdparty/ZenLib/ZenLib/Thread.h
new file mode 100644
index 000000000..9b96c758c
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Thread.h
@@ -0,0 +1,105 @@
+// ZenLib::Thread - Thread functions
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Thread functions
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_ThreadH
+#define ZenLib_ThreadH
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+#include "ZenLib/CriticalSection.h"
+#ifdef _WINDOWS
+ #undef Yield
+#endif
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+/// @brief Thread manipulation
+//***************************************************************************
+
+class Thread
+{
+public :
+ //Constructor/Destructor
+ Thread ();
+ virtual ~Thread ();
+
+ //Control
+ enum returnvalue
+ {
+ Ok,
+ IsNotRunning,
+ Incoherent,
+ Resource,
+ };
+ returnvalue Run();
+ returnvalue RunAgain();
+ returnvalue Pause();
+ returnvalue RequestTerminate();
+ returnvalue ForceTerminate();
+
+ //Status
+ bool IsRunning();
+ bool IsTerminating();
+ bool IsExited();
+
+ //Configuration
+ void Priority_Set(int8s Priority); //-100 to +100
+
+ //Main Entry
+ virtual void Entry();
+
+ //Internal
+ returnvalue Internal_Exit(); //Do not use it
+
+protected :
+
+ //Communicating
+ void Sleep(std::size_t Millisecond);
+ void Yield();
+
+private :
+ //Internal
+ void* ThreadPointer;
+
+ //The possible states of the thread ("-->" shows all possible transitions from this state)
+ enum state
+ {
+ State_New, // didn't start execution yet (--> Running)
+ State_Running, // thread is running (--> Paused, Terminating)
+ State_Paused, // thread is temporarily suspended (--> Running)
+ State_Terminating, // thread should terminate a.s.a.p. (--> Terminated)
+ State_Terminated, // thread is terminated
+ };
+ state State;
+ CriticalSection C;
+};
+
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/Trace.h b/src/thirdparty/ZenLib/ZenLib/Trace.h
new file mode 100644
index 000000000..daed1639d
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Trace.h
@@ -0,0 +1,77 @@
+// ZenLib::Trace - To trace (in files)
+// Copyright (C) 2006-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Trace
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Provide a direct to file trace
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenTraceH
+#define ZenTraceH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include <fstream>
+#include "ZenLib/Ztring.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+
+static std::FILE* Trace_F;
+static ZenLib::Ztring Trace;
+static ZenLib::Ztring Trace2;
+
+#ifdef TRACE
+ #undef TRACE
+#endif //TRACE
+
+#if 1
+#define TRACE(_TOAPPEND)
+#else
+#define TRACE(_TOAPPEND) \
+Trace.clear(); \
+Trace2.clear(); \
+_TOAPPEND; \
+if (!Trace2.empty()) \
+{ \
+ Trace+=_T(" - "); \
+ Trace+=Trace2; \
+} \
+Trace+=_T("\r\n"); \
+Trace_F=std::fopen("Trace.txt", "a+t"); \
+std::fwrite(Trace.To_Local().c_str(), Trace.size(), 1, Trace_F); \
+std::fclose(Trace_F);
+#endif
+
+//***************************************************************************
+
+
+} //NameSpace
+
+#endif // ZenTraceH
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Translation.cpp b/src/thirdparty/ZenLib/ZenLib/Translation.cpp
new file mode 100644
index 000000000..e925a388d
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Translation.cpp
@@ -0,0 +1,174 @@
+// ZenLib::Translation - Helper for translation
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef ZENLIB_USEWX
+ #include <wx/strconv.h>
+#endif //ZENLIB_USEWX
+#include <algorithm>
+#include "ZenLib/Translation.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Constructors/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Constructors
+Translation::Translation()
+: std::map<ZenLib::Ztring, ZenLib::Ztring> ()
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+}
+
+Translation::Translation(const Ztring &Source)
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+ Write(Source);
+}
+
+Translation::Translation(const Char *Source)
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+ Write(Source);
+}
+
+#ifdef _UNICODE
+Translation::Translation (const char* S)
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+ Write(Ztring(S));
+}
+#endif
+
+//***************************************************************************
+// In/Out
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Get
+Ztring Translation::Get () const
+{
+ Ztring ToReturn;
+ const_iterator Temp=begin();
+ while (Temp!=end())
+ {
+ ToReturn+=Temp->first;
+ ToReturn+=Separator[1];
+ ToReturn+=Temp->second;
+ ToReturn+=Separator[0];
+ Temp++;
+ }
+ return ToReturn;
+}
+
+const Ztring &Translation::Get (const Ztring &Value)
+{
+ iterator Pos=find(Value);
+ if (Pos==end())
+ operator[](Value)=Value;
+ return operator[](Value);
+}
+
+Ztring Translation::Get (const Ztring &Value, const Ztring &Default)
+{
+ iterator Pos=find(Value);
+ if (Pos==end())
+ operator[](Value)=Default;
+ return operator[](Value);
+}
+
+//---------------------------------------------------------------------------
+// Set
+void Translation::Write(const Ztring &NewLanguage)
+{
+ clear();
+
+ if (!&NewLanguage || !NewLanguage.size())
+ return;
+
+ size_t Pos1=0, Pos2_EOL=0, Pos2_Separator=0;
+
+ while (Pos2_EOL!=(size_t)-1)
+ {
+ Pos2_EOL=NewLanguage.find(_T('\n'), Pos1);
+ Pos2_Separator=NewLanguage.find(_T(';'), Pos1);
+ if (Pos2_Separator<Pos2_EOL)
+ {
+ operator[](NewLanguage.substr(Pos1, Pos2_Separator-Pos1))=NewLanguage.substr(Pos2_Separator+1, Pos2_EOL-Pos2_Separator-1);
+ }
+ Pos1=Pos2_EOL+1;
+ }
+}
+
+//---------------------------------------------------------------------------
+// Set
+void Translation::Write(const Ztring &Value, const Ztring &NewLanguage)
+{
+ operator[](Value)=NewLanguage;
+}
+
+//***************************************************************************
+// Configuration
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Separator
+void Translation::Separator_Set (size_type Level, const Ztring &NewSeparator)
+{
+ if (Level>1)
+ return;
+
+ Separator[Level]=NewSeparator;
+}
+
+//***************************************************************************
+// C++
+//***************************************************************************
+
+} //namespace
+
+
+
+
+
+
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Translation.h b/src/thirdparty/ZenLib/ZenLib/Translation.h
new file mode 100644
index 000000000..53e9f09e2
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Translation.h
@@ -0,0 +1,79 @@
+// ZenLib::Translation - Helper for translation
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+//
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_TranslationH
+#define ZenLib_TranslationH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Ztring.h"
+#include <map>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+/// @brief Helper for translation
+//***************************************************************************
+
+class Translation : public std::map<Ztring, Ztring>
+{
+public :
+ //Constructors/Destructor
+ Translation ();
+ Translation (const Ztring &Source);
+ Translation (const Char *Source);
+ #ifdef _UNICODE
+ Translation (const char *Source); //convert a UTF-8 string into Unicode
+ #endif
+
+ //In/Out
+ Ztring Get () const;
+ const Ztring &Get (const Ztring &Value);
+ Ztring Get (const Ztring &Count, const Ztring &Value);
+ void Write (const Ztring &NewLanguage); //All language in one
+ void Write (const Ztring &Value, const Ztring &NewLanguage); //Per item
+
+ //Configuration
+ /// @brief Set the Separator character
+ void Separator_Set (size_type Level, const Ztring &NewSeparator);
+ /// @brief Set the Quote character
+ /// During Read() or Write() method, if Separator is in the sequence, we must quote it
+ void Quote_Set (const Ztring &NewQuote);
+ /// @brief Set the Maximum number of element to read
+ /// During Read() or Write() method, if there is more elements, merge them with the last element
+ void Max_Set (size_type Level, size_type Max);
+
+protected :
+ Ztring Separator[2];
+ Ztring Quote;
+ size_type Max[2];
+};
+
+} //namespace
+#endif
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Utils.cpp b/src/thirdparty/ZenLib/ZenLib/Utils.cpp
new file mode 100644
index 000000000..3ae149c1a
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Utils.cpp
@@ -0,0 +1,1042 @@
+// ZenLib::Utils - Very small utilities
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Utils.h"
+#include <cmath>
+#include <complex>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Transformations - Little Endian to something
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Little Endian - 8 bits
+int8s LittleEndian2int8s (const char* Liste)
+{
+ return (int8s)Liste[0];
+}
+
+int8u LittleEndian2int8u (const char* Liste)
+{
+ return (int8u)Liste[0];
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 16 bits
+int16s LittleEndian2int16s (const char* Liste)
+{
+ int16s Retour= (int8s)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+int16u LittleEndian2int16u (const char* Liste)
+{
+ int16u Retour= (int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 24 bits
+int32s LittleEndian2int24s (const char* Liste)
+{
+ int32s Retour= (int8s)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+int32u LittleEndian2int24u (const char* Liste)
+{
+ int32u Retour= (int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 32 bits
+int32s LittleEndian2int32s (const char* Liste)
+{
+ int32s Retour= (int8s)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+int32u LittleEndian2int32u (const char* Liste)
+{
+ int32u Retour= (int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 40 bits
+int64s LittleEndian2int40s (const char* Liste)
+{
+ int64s Retour= (int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+int64u LittleEndian2int40u (const char* Liste)
+{
+ int64u Retour= (int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 48 bits
+int64s LittleEndian2int48s (const char* Liste)
+{
+ int64s Retour= (int8u)Liste[5];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+int64u LittleEndian2int48u (const char* Liste)
+{
+ int64u Retour= (int8u)Liste[5];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 56 bits
+int64s LittleEndian2int56s (const char* Liste)
+{
+ int64s Retour= (int8u)Liste[6];
+ Retour=(Retour<<8)|(int8u)Liste[5];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+int64u LittleEndian2int56u (const char* Liste)
+{
+ int64u Retour= (int8u)Liste[6];
+ Retour=(Retour<<8)|(int8u)Liste[5];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 64 bits
+int64s LittleEndian2int64s (const char* Liste)
+{
+ int64s Retour= (int8s)Liste[7];
+ Retour=(Retour<<8)|(int8u)Liste[6];
+ Retour=(Retour<<8)|(int8u)Liste[5];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+int64u LittleEndian2int64u (const char* Liste)
+{
+ int64u Retour= (int8u)Liste[7];
+ Retour=(Retour<<8)|(int8u)Liste[6];
+ Retour=(Retour<<8)|(int8u)Liste[5];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[0];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 128 bits
+int128u LittleEndian2int128u(const char* Liste)
+{
+ int128u Retour;
+ Retour.lo=LittleEndian2int64u(Liste);
+ Retour.hi=LittleEndian2int64u(Liste+8);
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - float 16 bits
+float32 LittleEndian2float16(const char* Liste)
+{
+ //sign 1 bit
+ //exponent 5 bit
+ //significand 10 bit
+
+ //Retrieving data
+ int32u Integer=LittleEndian2int32u(Liste);
+
+ //Retrieving elements
+ bool Sign =(Integer&0x8000)?true:false;
+ int32u Exponent=(Integer>>10)&0xFF;
+ int32u Mantissa= Integer&0x03FF;
+
+ //Some computing
+ if (Exponent==0 || Exponent==0xFF)
+ return 0; //These are denormalised numbers, NANs, and other horrible things
+ Exponent-=0x7F; //Bias
+ float64 Answer=(((float64)Mantissa)/8388608+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent
+ if (Sign)
+ Answer=-Answer;
+
+ return (float32)Answer;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - float 32 bits
+float32 LittleEndian2float32(const char* Liste)
+{
+ //sign 1 bit
+ //exponent 8 bit
+ //significand 23 bit
+
+ //Retrieving data
+ int32u Integer=LittleEndian2int32u(Liste);
+
+ //Retrieving elements
+ bool Sign =(Integer&0x80000000)?true:false;
+ int32u Exponent=(Integer>>23)&0xFF;
+ int32u Mantissa= Integer&0x007FFFFF;
+
+ //Some computing
+ if (Exponent==0 || Exponent==0xFF)
+ return 0; //These are denormalised numbers, NANs, and other horrible things
+ Exponent-=0x7F; //Bias
+ float64 Answer=(((float64)Mantissa)/8388608+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent
+ if (Sign)
+ Answer=-Answer;
+
+ return (float32)Answer;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - float 64 bits
+float64 LittleEndian2float64(const char* Liste)
+{
+ //sign 1 bit
+ //exponent 11 bit
+ //significand 52 bit
+
+ //Retrieving data
+ int64u Integer=LittleEndian2int64u(Liste);
+
+ //Retrieving elements
+ bool Sign =(Integer&0x8000000000000000LL)?true:false;
+ int64u Exponent=(Integer>>52)&0x7FF;
+ int64u Mantissa= Integer&0xFFFFFFFFFFFFFLL;
+
+ //Some computing
+ if (Exponent==0 || Exponent==0x7FF)
+ return 0; //These are denormalised numbers, NANs, and other horrible things
+ Exponent-=0x3FF; //Bias
+ float64 Answer=(((float64)Mantissa)/4503599627370496.0+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent
+ if (Sign)
+ Answer=-Answer;
+
+ return (float64)Answer;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - float 80 bits
+float80 LittleEndian2float80(const char* Liste)
+{
+ //sign 1 bit
+ //exponent 15 bit
+ //integer? 1 bit
+ //significand 63 bit
+
+ //Retrieving data
+ int16u Integer1=LittleEndian2int16u(Liste);
+ int64u Integer2=LittleEndian2int64u(Liste+2);
+
+ //Retrieving elements
+ bool Sign =(Integer1&0x8000)?true:false;
+ int16u Exponent= Integer1&0x7FFF;
+ int64u Mantissa= Integer2&0x7FFFFFFFFFFFFFFFLL; //Only 63 bits, 1 most significant bit is explicit
+ //Some computing
+ if (Exponent==0 || Exponent==0x7FFF)
+ return 0; //These are denormalised numbers, NANs, and other horrible things
+ Exponent-=0x3FFF; //Bias
+ float80 Answer=(((float80)Mantissa)/9223372036854775808.0+1.0)*std::pow((float)2, (int)Exponent); //(1+Mantissa) * 2^Exponent
+ if (Sign)
+ Answer=-Answer;
+
+ return (float80)Answer;
+}
+
+//***************************************************************************
+// Transformations - Something to Little Endian
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Little Endian - 8 bits
+void int8s2LittleEndian (char* List, int8s Value)
+{
+ List[0]=(char)Value;
+}
+
+void int8u2LittleEndian (char* List, int8u Value)
+{
+ List[0]=(char)Value;
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 16 bits
+void int16s2LittleEndian (char* List, int16s Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+}
+
+void int16u2LittleEndian (char* List, int16u Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 24 bits
+void int24s2LittleEndian (char* List, int32s Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+}
+
+void int24u2LittleEndian (char* List, int32u Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 32 bits
+void int32s2LittleEndian (char* List, int32s Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>>24);
+}
+
+void int32u2LittleEndian (char* List, int32u Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>>24);
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 40 bits
+void int40s2LittleEndian (char* List, int64s Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>>24);
+ List[4]=(char)(Value>>32);
+}
+
+void int40u2LittleEndian (char* List, int64u Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>>24);
+ List[4]=(char)(Value>>32);
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 48 bits
+void int48s2LittleEndian (char* List, int64s Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>>24);
+ List[4]=(char)(Value>>32);
+ List[5]=(char)(Value>>40);
+}
+
+void int48u2LittleEndian (char* List, int64u Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>>24);
+ List[4]=(char)(Value>>32);
+ List[5]=(char)(Value>>40);
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 56 bits
+void int56s2LittleEndian (char* List, int64s Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>>24);
+ List[4]=(char)(Value>>32);
+ List[5]=(char)(Value>>40);
+ List[6]=(char)(Value>>48);
+}
+
+void int56u2LittleEndian (char* List, int64u Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>>24);
+ List[4]=(char)(Value>>32);
+ List[5]=(char)(Value>>40);
+ List[6]=(char)(Value>>48);
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 64 bits
+void int64s2LittleEndian (char* List, int64s Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>>24);
+ List[4]=(char)(Value>>32);
+ List[5]=(char)(Value>>40);
+ List[6]=(char)(Value>>48);
+ List[7]=(char)(Value>>56);
+}
+
+void int64u2LittleEndian (char* List, int64u Value)
+{
+ List[0]=(char) Value;
+ List[1]=(char)(Value>> 8);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>>24);
+ List[4]=(char)(Value>>32);
+ List[5]=(char)(Value>>40);
+ List[6]=(char)(Value>>48);
+ List[7]=(char)(Value>>56);
+}
+
+//---------------------------------------------------------------------------
+// Little Endian - 128 bits
+void int128u2LittleEndian(char* List, int128u Value)
+{
+ int64u2LittleEndian(List+8, Value.lo);
+ int64u2LittleEndian(List , Value.hi);
+}
+
+//***************************************************************************
+// Transformations - Big Endian to something
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Big Endian - 8 bits
+int8s BigEndian2int8s (const char* Liste)
+{
+ return (int8s)Liste[0];
+}
+
+int8u BigEndian2int8u (const char* Liste)
+{
+ return (int8u)Liste[0];
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 16 bits
+int16s BigEndian2int16s (const char* Liste)
+{
+ int16s Retour= (int8s)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ return Retour;
+}
+
+int16u BigEndian2int16u (const char* Liste)
+{
+ int16u Retour= (int8u)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 24 bits
+int32s BigEndian2int24s (const char* Liste)
+{
+ int32s Retour= (int8s)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ return Retour;
+}
+
+int32u BigEndian2int24u (const char* Liste)
+{
+ int32u Retour= (int8u)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 32 bits
+int32s BigEndian2int32s (const char* Liste)
+{
+ int32s Retour= (int8s)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ return Retour;
+}
+
+int32u BigEndian2int32u (const char* Liste)
+{
+ int32u Retour= (int8u)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 40 bits
+int64s BigEndian2int40s (const char* Liste)
+{
+ int64s Retour= (int8s)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ return Retour;
+}
+
+int64u BigEndian2int40u (const char* Liste)
+{
+ int64u Retour= (int8u)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 48 bits
+int64s BigEndian2int48s (const char* Liste)
+{
+ int64s Retour= (int8s)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[5];
+ return Retour;
+}
+
+int64u BigEndian2int48u (const char* Liste)
+{
+ int64u Retour= (int8u)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[5];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 56 bits
+int64s BigEndian2int56s (const char* Liste)
+{
+ int64s Retour= (int8s)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[5];
+ Retour=(Retour<<8)|(int8u)Liste[6];
+ return Retour;
+}
+
+int64u BigEndian2int56u (const char* Liste)
+{
+ int64u Retour= (int8u)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[5];
+ Retour=(Retour<<8)|(int8u)Liste[6];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 64 bits
+int64s BigEndian2int64s (const char* Liste)
+{
+ int64s Retour=(int8s)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[5];
+ Retour=(Retour<<8)|(int8u)Liste[6];
+ Retour=(Retour<<8)|(int8u)Liste[7];
+ return Retour;
+}
+
+int64u BigEndian2int64u (const char* Liste)
+{
+ int64u Retour=(int8u)Liste[0];
+ Retour=(Retour<<8)|(int8u)Liste[1];
+ Retour=(Retour<<8)|(int8u)Liste[2];
+ Retour=(Retour<<8)|(int8u)Liste[3];
+ Retour=(Retour<<8)|(int8u)Liste[4];
+ Retour=(Retour<<8)|(int8u)Liste[5];
+ Retour=(Retour<<8)|(int8u)Liste[6];
+ Retour=(Retour<<8)|(int8u)Liste[7];
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 128 bits
+int128u BigEndian2int128u(const char* Liste)
+{
+ int128u Retour;
+ Retour.hi=BigEndian2int64u(Liste);
+ Retour.lo=BigEndian2int64u(Liste+8);
+ return Retour;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - float 16 bits
+float32 BigEndian2float16(const char* Liste)
+{
+ //sign 1 bit
+ //exponent 5 bit
+ //significand 10 bit
+
+ //Retrieving data
+ int32u Integer=BigEndian2int32u(Liste);
+
+ //Retrieving elements
+ bool Sign =(Integer&0x8000)?true:false;
+ int32u Exponent=(Integer>>10)&0xFF;
+ int32u Mantissa= Integer&0x03FF;
+
+ //Some computing
+ if (Exponent==0 || Exponent==0xFF)
+ return 0; //These are denormalised numbers, NANs, and other horrible things
+ Exponent-=0x7F; //Bias
+ float64 Answer=(((float64)Mantissa)/8388608+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent
+ if (Sign)
+ Answer=-Answer;
+
+ return (float32)Answer;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - float 32 bits
+float32 BigEndian2float32(const char* Liste)
+{
+ //sign 1 bit
+ //exponent 8 bit
+ //significand 23 bit
+
+ //Retrieving data
+ int32u Integer=BigEndian2int32u(Liste);
+
+ //Retrieving elements
+ bool Sign =(Integer&0x80000000)?true:false;
+ int32u Exponent=(Integer>>23)&0xFF;
+ int32u Mantissa= Integer&0x007FFFFF;
+
+ //Some computing
+ if (Exponent==0 || Exponent==0xFF)
+ return 0; //These are denormalised numbers, NANs, and other horrible things
+ Exponent-=0x7F; //Bias
+ float64 Answer=(((float64)Mantissa)/8388608+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent
+ if (Sign)
+ Answer=-Answer;
+
+ return (float32)Answer;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - float 64 bits
+float64 BigEndian2float64(const char* Liste)
+{
+ //sign 1 bit
+ //exponent 11 bit
+ //significand 52 bit
+
+ //Retrieving data
+ int64u Integer=BigEndian2int64u(Liste);
+
+ //Retrieving elements
+ bool Sign =(Integer&0x8000000000000000LL)?true:false;
+ int64u Exponent=(Integer>>52)&0x7FF;
+ int64u Mantissa= Integer&0xFFFFFFFFFFFFFLL;
+
+ //Some computing
+ if (Exponent==0 || Exponent==0x7FF)
+ return 0; //These are denormalised numbers, NANs, and other horrible things
+ Exponent-=0x3FF; //Bias
+ float64 Answer=(((float64)Mantissa)/4503599627370496.0+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent
+ if (Sign)
+ Answer=-Answer;
+
+ return (float64)Answer;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - float 80 bits
+float80 BigEndian2float80(const char* Liste)
+{
+ //sign 1 bit
+ //exponent 15 bit
+ //integer? 1 bit
+ //significand 63 bit
+
+ //Retrieving data
+ int16u Integer1=BigEndian2int16u(Liste);
+ int64u Integer2=BigEndian2int64u(Liste+2);
+
+ //Retrieving elements
+ bool Sign =(Integer1&0x8000)?true:false;
+ int16u Exponent= Integer1&0x7FFF;
+ int64u Mantissa= Integer2&0x7FFFFFFFFFFFFFFFLL; //Only 63 bits, 1 most significant bit is explicit
+ //Some computing
+ if (Exponent==0 || Exponent==0x7FFF)
+ return 0; //These are denormalised numbers, NANs, and other horrible things
+ Exponent-=0x3FFF; //Bias
+ float80 Answer=(((float80)Mantissa)/9223372036854775808.0+1.0)*std::pow((float)2, (int)Exponent); //(1+Mantissa) * 2^Exponent
+ if (Sign)
+ Answer=-Answer;
+
+ return (float80)Answer;
+}
+
+//***************************************************************************
+// Transformations - Something to Big Endian
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Big Endian - 8 bits
+void int8s2BigEndian (char* List, int8s Value)
+{
+ List[0]=(char)Value;
+}
+
+void int8u2BigEndian (char* List, int8u Value)
+{
+ List[0]=(char)Value;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 16 bits
+void int16s2BigEndian (char* List, int16s Value)
+{
+ List[0]=(char)(Value>> 8);
+ List[1]=(char) Value;
+}
+
+void int16u2BigEndian (char* List, int16u Value)
+{
+ List[0]=(char)(Value>> 8);
+ List[1]=(char) Value;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 24 bits
+void int24s2BigEndian (char* List, int32s Value)
+{
+ List[0]=(char)(Value>>16);
+ List[1]=(char)(Value>> 8);
+ List[2]=(char) Value;
+}
+
+void int24u2BigEndian (char* List, int32u Value)
+{
+ List[0]=(char)(Value>>16);
+ List[1]=(char)(Value>> 8);
+ List[2]=(char) Value;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 32 bits
+void int32s2BigEndian (char* List, int32s Value)
+{
+ List[0]=(char)(Value>>24);
+ List[1]=(char)(Value>>16);
+ List[2]=(char)(Value>> 8);
+ List[3]=(char) Value;
+}
+
+void int32u2BigEndian (char* List, int32u Value)
+{
+ List[0]=(char)(Value>>24);
+ List[1]=(char)(Value>>16);
+ List[2]=(char)(Value>> 8);
+ List[3]=(char) Value;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 40 bits
+void int40s2BigEndian (char* List, int64s Value)
+{
+ List[0]=(char)(Value>>32);
+ List[1]=(char)(Value>>24);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>> 8);
+ List[4]=(char) Value;
+}
+
+void int40u2BigEndian (char* List, int64u Value)
+{
+ List[0]=(char)(Value>>32);
+ List[1]=(char)(Value>>24);
+ List[2]=(char)(Value>>16);
+ List[3]=(char)(Value>> 8);
+ List[4]=(char) Value;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 48 bits
+void int48s2BigEndian (char* List, int64s Value)
+{
+ List[0]=(char)(Value>>40);
+ List[1]=(char)(Value>>32);
+ List[2]=(char)(Value>>24);
+ List[3]=(char)(Value>>16);
+ List[4]=(char)(Value>> 8);
+ List[5]=(char) Value;
+}
+
+void int48u2BigEndian (char* List, int64u Value)
+{
+ List[0]=(char)(Value>>40);
+ List[1]=(char)(Value>>32);
+ List[2]=(char)(Value>>24);
+ List[3]=(char)(Value>>16);
+ List[4]=(char)(Value>> 8);
+ List[5]=(char) Value;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 56 bits
+void int56s2BigEndian (char* List, int64s Value)
+{
+ List[0]=(char)(Value>>48);
+ List[1]=(char)(Value>>40);
+ List[2]=(char)(Value>>32);
+ List[3]=(char)(Value>>24);
+ List[4]=(char)(Value>>16);
+ List[5]=(char)(Value>> 8);
+ List[6]=(char) Value;
+}
+
+void int56u2BigEndian (char* List, int64u Value)
+{
+ List[0]=(char)(Value>>48);
+ List[1]=(char)(Value>>40);
+ List[2]=(char)(Value>>32);
+ List[3]=(char)(Value>>24);
+ List[4]=(char)(Value>>16);
+ List[5]=(char)(Value>> 8);
+ List[6]=(char) Value;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 64 bits
+void int64s2BigEndian (char* List, int64s Value)
+{
+ List[0]=(char)(Value>>56);
+ List[1]=(char)(Value>>48);
+ List[2]=(char)(Value>>40);
+ List[3]=(char)(Value>>32);
+ List[4]=(char)(Value>>24);
+ List[5]=(char)(Value>>16);
+ List[6]=(char)(Value>> 8);
+ List[7]=(char) Value;
+}
+
+void int64u2BigEndian (char* List, int64u Value)
+{
+ List[0]=(char)(Value>>56);
+ List[1]=(char)(Value>>48);
+ List[2]=(char)(Value>>40);
+ List[3]=(char)(Value>>32);
+ List[4]=(char)(Value>>24);
+ List[5]=(char)(Value>>16);
+ List[6]=(char)(Value>> 8);
+ List[7]=(char) Value;
+}
+
+//---------------------------------------------------------------------------
+// Big Endian - 128 bits
+void int128u2BigEndian(char* List, int128u Value)
+{
+ int64u2BigEndian(List, Value.hi);
+ int64u2BigEndian(List+8, Value.lo);
+}
+
+//***************************************************************************
+// Int to Int
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// int32 - int64
+int64s int32s_int64s ( int32s High, int32u Low)
+{
+ return ((((int64s)High)<<32) | Low);
+}
+
+int64u int32u_int64u ( int32u High, int32u Low)
+{
+ return ((((int64s)High)<<32) | Low);
+}
+
+void int32s_int64s (int64s &BigInt, int32s High, int32u Low)
+{
+ BigInt= ((((int64s)High)<<32) | Low);
+}
+void int32u_int64u (int64s &BigInt, int32u High, int32u Low)
+{
+ BigInt= ((((int64s)High)<<32) | Low);
+}
+
+void int64s_int32s (int64s BigInt, int32s &High, int32u &Low)
+{
+ High = (int32s) ((BigInt & 0xFFFFFFFF00000000LL)>>32);
+ Low = (int32u) ( BigInt & 0x00000000FFFFFFFF);
+}
+
+void int64u_int32u (int64u BigInt, int32u &High, int32u &Low)
+{
+ High = (int32u) ((BigInt & 0xFFFFFFFF00000000LL)>>32);
+ Low = (int32u) ( BigInt & 0x00000000FFFFFFFF);
+}
+
+//---------------------------------------------------------------------------
+// Floats and ints
+int32s float32_int32s (float32 F, bool Rounded)
+{
+ //Not rounded
+ if (!Rounded)
+ return (int32s)F;
+ //Rounded
+ int I1=(int)F;
+ if (F-I1>=0.5)
+ return I1+1;
+ else
+ return I1;
+}
+
+int64s float32_int64s (float32 F, bool Rounded)
+{
+ //Not rounded
+ if (!Rounded)
+ return (int64s)F;
+ //Rounded
+ int I1=(int)F;
+ if (F-I1>=0.5)
+ return I1+1;
+ else
+ return I1;
+}
+
+int32s float64_int32s (float64 F, bool Rounded)
+{
+ //Not rounded
+ if (!Rounded)
+ return (int32s)F;
+ //Rounded
+ int32s I1=(int32s)F;
+ if (F-I1>=0.5)
+ return I1+1;
+ else
+ return I1;
+}
+
+int64s float64_int64s (float64 F, bool Rounded)
+{
+ //Not rounded
+ if (!Rounded)
+ return (int64s)F;
+ //Rounded
+ int64s I1=(int64s)F;
+ if (F-I1>=0.5)
+ return I1+1;
+ else
+ return I1;
+}
+
+} //namespace ZenLib
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Utils.h b/src/thirdparty/ZenLib/ZenLib/Utils.h
new file mode 100644
index 000000000..0bbcb52a6
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Utils.h
@@ -0,0 +1,320 @@
+// ZenLib::Utils - Very small utilities
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// Integer and float manipulation
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenUtilsH
+#define ZenUtilsH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+#include "ZenLib/int128u.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+// Integer transformations
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Little Endians
+int8s LittleEndian2int8s (const char* List);
+int8u LittleEndian2int8u (const char* List);
+int16s LittleEndian2int16s (const char* List);
+int16u LittleEndian2int16u (const char* List);
+int32s LittleEndian2int24s (const char* List);
+int32u LittleEndian2int24u (const char* List);
+int32s LittleEndian2int32s (const char* List);
+int32u LittleEndian2int32u (const char* List);
+#if (MAXTYPE_INT >= 64)
+int64s LittleEndian2int40s (const char* List);
+int64u LittleEndian2int40u (const char* List);
+int64s LittleEndian2int48s (const char* List);
+int64u LittleEndian2int48u (const char* List);
+int64s LittleEndian2int56s (const char* List);
+int64u LittleEndian2int56u (const char* List);
+int64s LittleEndian2int64s (const char* List);
+int64u LittleEndian2int64u (const char* List);
+int128u LittleEndian2int128u (const char* List);
+#endif
+float32 LittleEndian2float16 (const char* List);
+float32 LittleEndian2float32 (const char* List);
+float64 LittleEndian2float64 (const char* List);
+float80 LittleEndian2float80 (const char* List);
+
+void int8s2LittleEndian (char* List, int8s Value);
+void int8u2LittleEndian (char* List, int8u Value);
+void int16s2LittleEndian (char* List, int16s Value);
+void int16u2LittleEndian (char* List, int16u Value);
+void int24s2LittleEndian (char* List, int32s Value);
+void int24u2LittleEndian (char* List, int32u Value);
+void int32s2LittleEndian (char* List, int32s Value);
+void int32u2LittleEndian (char* List, int32u Value);
+#if (MAXTYPE_INT >= 64)
+void int40s2LittleEndian (char* List, int64s Value);
+void int40u2LittleEndian (char* List, int64u Value);
+void int48s2LittleEndian (char* List, int64s Value);
+void int48u2LittleEndian (char* List, int64u Value);
+void int56s2LittleEndian (char* List, int64s Value);
+void int56u2LittleEndian (char* List, int64u Value);
+void int64s2LittleEndian (char* List, int64s Value);
+void int64u2LittleEndian (char* List, int64u Value);
+void int128u2LittleEndian (char* List, int128u Value);
+#endif
+void float162LittleEndian (char* List, float32 Value);
+void float322LittleEndian (char* List, float32 Value);
+void float642LittleEndian (char* List, float64 Value);
+void float802LittleEndian (char* List, float80 Value);
+
+#ifndef __BORLANDC__
+inline int8s LittleEndian2int8s (const int8u* List) {return LittleEndian2int8s ((const char*)List);}
+inline int8u LittleEndian2int8u (const int8u* List) {return LittleEndian2int8u ((const char*)List);}
+inline int16s LittleEndian2int16s (const int8u* List) {return LittleEndian2int16s ((const char*)List);}
+inline int16u LittleEndian2int16u (const int8u* List) {return LittleEndian2int16u ((const char*)List);}
+inline int32s LittleEndian2int24s (const int8u* List) {return LittleEndian2int24s ((const char*)List);}
+inline int32u LittleEndian2int24u (const int8u* List) {return LittleEndian2int24u ((const char*)List);}
+inline int32s LittleEndian2int32s (const int8u* List) {return LittleEndian2int32s ((const char*)List);}
+inline int32u LittleEndian2int32u (const int8u* List) {return LittleEndian2int32u ((const char*)List);}
+#if (MAXTYPE_INT >= 64)
+inline int64s LittleEndian2int40s (const int8u* List) {return LittleEndian2int40s ((const char*)List);}
+inline int64u LittleEndian2int40u (const int8u* List) {return LittleEndian2int40u ((const char*)List);}
+inline int64s LittleEndian2int48s (const int8u* List) {return LittleEndian2int48s ((const char*)List);}
+inline int64u LittleEndian2int48u (const int8u* List) {return LittleEndian2int48u ((const char*)List);}
+inline int64s LittleEndian2int56s (const int8u* List) {return LittleEndian2int56s ((const char*)List);}
+inline int64u LittleEndian2int56u (const int8u* List) {return LittleEndian2int56u ((const char*)List);}
+inline int64s LittleEndian2int64s (const int8u* List) {return LittleEndian2int64s ((const char*)List);}
+inline int64u LittleEndian2int64u (const int8u* List) {return LittleEndian2int64u ((const char*)List);}
+inline int128u LittleEndian2int128u (const int8u* List) {return LittleEndian2int64u ((const char*)List);}
+#endif
+inline float32 LittleEndian2float16 (const int8u* List) {return LittleEndian2float16 ((const char*)List);}
+inline float32 LittleEndian2float32 (const int8u* List) {return LittleEndian2float32 ((const char*)List);}
+inline float64 LittleEndian2float64 (const int8u* List) {return LittleEndian2float64 ((const char*)List);}
+inline float80 LittleEndian2float80 (const int8u* List) {return LittleEndian2float80 ((const char*)List);}
+
+inline void int8s2LittleEndian (int8u* List, int8s Value) {return int8s2LittleEndian ((char*)List, Value);}
+inline void int8u2LittleEndian (int8u* List, int8u Value) {return int8u2LittleEndian ((char*)List, Value);}
+inline void int16s2LittleEndian (int8u* List, int16s Value) {return int16s2LittleEndian ((char*)List, Value);}
+inline void int16u2LittleEndian (int8u* List, int16u Value) {return int16u2LittleEndian ((char*)List, Value);}
+inline void int24s2LittleEndian (int8u* List, int32s Value) {return int24s2LittleEndian ((char*)List, Value);}
+inline void int24u2LittleEndian (int8u* List, int32u Value) {return int24u2LittleEndian ((char*)List, Value);}
+inline void int32s2LittleEndian (int8u* List, int32s Value) {return int32s2LittleEndian ((char*)List, Value);}
+inline void int32u2LittleEndian (int8u* List, int32u Value) {return int32u2LittleEndian ((char*)List, Value);}
+#if (MAXTYPE_INT >= 64)
+inline void int40s2LittleEndian (int8u* List, int64s Value) {return int40s2LittleEndian ((char*)List, Value);}
+inline void int40u2LittleEndian (int8u* List, int64u Value) {return int40u2LittleEndian ((char*)List, Value);}
+inline void int48s2LittleEndian (int8u* List, int64s Value) {return int48s2LittleEndian ((char*)List, Value);}
+inline void int48u2LittleEndian (int8u* List, int64u Value) {return int48u2LittleEndian ((char*)List, Value);}
+inline void int56s2LittleEndian (int8u* List, int64s Value) {return int56s2LittleEndian ((char*)List, Value);}
+inline void int56u2LittleEndian (int8u* List, int64u Value) {return int56u2LittleEndian ((char*)List, Value);}
+inline void int64s2LittleEndian (int8u* List, int64s Value) {return int64s2LittleEndian ((char*)List, Value);}
+inline void int64u2LittleEndian (int8u* List, int64u Value) {return int64u2LittleEndian ((char*)List, Value);}
+inline void int128u2LittleEndian (int8u* List, int128u Value) {return int128u2LittleEndian ((char*)List, Value);}
+#endif
+inline void float162LittleEndian (int8u* List, float32 Value) {return float162LittleEndian ((char*)List, Value);}
+inline void float322LittleEndian (int8u* List, float32 Value) {return float322LittleEndian ((char*)List, Value);}
+inline void float642LittleEndian (int8u* List, float64 Value) {return float642LittleEndian ((char*)List, Value);}
+inline void float802LittleEndian (int8u* List, float80 Value) {return float802LittleEndian ((char*)List, Value);}
+#endif //__BORLANDC__
+
+//---------------------------------------------------------------------------
+//Big Endians
+int8s BigEndian2int8s (const char* List);
+int8u BigEndian2int8u (const char* List);
+int16s BigEndian2int16s (const char* List);
+int16u BigEndian2int16u (const char* List);
+int32s BigEndian2int24s (const char* List);
+int32u BigEndian2int24u (const char* List);
+int32s BigEndian2int32s (const char* List);
+int32u BigEndian2int32u (const char* List);
+#if (MAXTYPE_INT >= 64)
+int64s BigEndian2int40s (const char* List);
+int64u BigEndian2int40u (const char* List);
+int64s BigEndian2int48s (const char* List);
+int64u BigEndian2int48u (const char* List);
+int64s BigEndian2int56s (const char* List);
+int64u BigEndian2int56u (const char* List);
+int64s BigEndian2int64s (const char* List);
+int64u BigEndian2int64u (const char* List);
+int128u BigEndian2int128u (const char* List);
+#endif
+float32 BigEndian2float16 (const char* List);
+float32 BigEndian2float32 (const char* List);
+float64 BigEndian2float64 (const char* List);
+float80 BigEndian2float80 (const char* List);
+
+void int8s2BigEndian (char* List, int8s Value);
+void int8u2BigEndian (char* List, int8u Value);
+void int16s2BigEndian (char* List, int16s Value);
+void int16u2BigEndian (char* List, int16u Value);
+void int24s2BigEndian (char* List, int32s Value);
+void int24u2BigEndian (char* List, int32u Value);
+void int32s2BigEndian (char* List, int32s Value);
+void int32u2BigEndian (char* List, int32u Value);
+#if (MAXTYPE_INT >= 64)
+void int40s2BigEndian (char* List, int64s Value);
+void int40u2BigEndian (char* List, int64u Value);
+void int48s2BigEndian (char* List, int64s Value);
+void int48u2BigEndian (char* List, int64u Value);
+void int56s2BigEndian (char* List, int64s Value);
+void int56u2BigEndian (char* List, int64u Value);
+void int64s2BigEndian (char* List, int64s Value);
+void int64u2BigEndian (char* List, int64u Value);
+void int128u2BigEndian (char* List, int128u Value);
+#endif
+void float162BigEndian (char* List, float32 Value);
+void float322BigEndian (char* List, float32 Value);
+void float642BigEndian (char* List, float64 Value);
+void float802BigEndian (char* List, float80 Value);
+
+#ifndef __BORLANDC__
+inline int8s BigEndian2int8s (const int8u* List) {return BigEndian2int8s ((const char*)List);}
+inline int8u BigEndian2int8u (const int8u* List) {return BigEndian2int8u ((const char*)List);}
+inline int16s BigEndian2int16s (const int8u* List) {return BigEndian2int16s ((const char*)List);}
+inline int16u BigEndian2int16u (const int8u* List) {return BigEndian2int16u ((const char*)List);}
+inline int32s BigEndian2int32s (const int8u* List) {return BigEndian2int32s ((const char*)List);}
+inline int32u BigEndian2int24u (const int8u* List) {return BigEndian2int24u ((const char*)List);}
+inline int32s BigEndian2int24s (const int8u* List) {return BigEndian2int24s ((const char*)List);}
+inline int32u BigEndian2int32u (const int8u* List) {return BigEndian2int32u ((const char*)List);}
+#if (MAXTYPE_INT >= 64)
+inline int64s BigEndian2int40s (const int8u* List) {return BigEndian2int40s ((const char*)List);}
+inline int64u BigEndian2int40u (const int8u* List) {return BigEndian2int40u ((const char*)List);}
+inline int64s BigEndian2int48s (const int8u* List) {return BigEndian2int48s ((const char*)List);}
+inline int64u BigEndian2int48u (const int8u* List) {return BigEndian2int48u ((const char*)List);}
+inline int64s BigEndian2int56s (const int8u* List) {return BigEndian2int56s ((const char*)List);}
+inline int64u BigEndian2int56u (const int8u* List) {return BigEndian2int56u ((const char*)List);}
+inline int64s BigEndian2int64s (const int8u* List) {return BigEndian2int64s ((const char*)List);}
+inline int64u BigEndian2int64u (const int8u* List) {return BigEndian2int64u ((const char*)List);}
+inline int128u BigEndian2int128u (const int8u* List) {return BigEndian2int128u ((const char*)List);}
+#endif
+inline float32 BigEndian2float16 (const int8u* List) {return BigEndian2float16 ((const char*)List);}
+inline float32 BigEndian2float32 (const int8u* List) {return BigEndian2float32 ((const char*)List);}
+inline float64 BigEndian2float64 (const int8u* List) {return BigEndian2float64 ((const char*)List);}
+inline float80 BigEndian2float80 (const int8u* List) {return BigEndian2float80 ((const char*)List);}
+
+inline void int8s2BigEndian (int8u* List, int8s Value) {return int8s2BigEndian ((char*)List, Value);}
+inline void int8u2BigEndian (int8u* List, int8u Value) {return int8u2BigEndian ((char*)List, Value);}
+inline void int16s2BigEndian (int8u* List, int16s Value) {return int16s2BigEndian ((char*)List, Value);}
+inline void int16u2BigEndian (int8u* List, int16u Value) {return int16u2BigEndian ((char*)List, Value);}
+inline void int24s2BigEndian (int8u* List, int32s Value) {return int24s2BigEndian ((char*)List, Value);}
+inline void int24u2BigEndian (int8u* List, int32u Value) {return int24u2BigEndian ((char*)List, Value);}
+inline void int32s2BigEndian (int8u* List, int32s Value) {return int32s2BigEndian ((char*)List, Value);}
+inline void int32u2BigEndian (int8u* List, int32u Value) {return int32u2BigEndian ((char*)List, Value);}
+#if (MAXTYPE_INT >= 64)
+inline void int40s2BigEndian (int8u* List, int64s Value) {return int40s2BigEndian ((char*)List, Value);}
+inline void int40u2BigEndian (int8u* List, int64u Value) {return int40u2BigEndian ((char*)List, Value);}
+inline void int48s2BigEndian (int8u* List, int64s Value) {return int48s2BigEndian ((char*)List, Value);}
+inline void int48u2BigEndian (int8u* List, int64u Value) {return int48u2BigEndian ((char*)List, Value);}
+inline void int56s2BigEndian (int8u* List, int64s Value) {return int56s2BigEndian ((char*)List, Value);}
+inline void int56u2BigEndian (int8u* List, int64u Value) {return int56u2BigEndian ((char*)List, Value);}
+inline void int64s2BigEndian (int8u* List, int64s Value) {return int64s2BigEndian ((char*)List, Value);}
+inline void int64u2BigEndian (int8u* List, int64u Value) {return int64u2BigEndian ((char*)List, Value);}
+inline void int128u2BigEndian (int8u* List, int128u Value) {return int128u2BigEndian ((char*)List, Value);}
+#endif
+inline void float162BigEndian (int8u* List, float32 Value) {return float162BigEndian ((char*)List, Value);}
+inline void float322BigEndian (int8u* List, float32 Value) {return float322BigEndian ((char*)List, Value);}
+inline void float642BigEndian (int8u* List, float64 Value) {return float642BigEndian ((char*)List, Value);}
+inline void float802BigEndian (int8u* List, float80 Value) {return float802BigEndian ((char*)List, Value);}
+#endif //__BORLANDC__
+
+//---------------------------------------------------------------------------
+// int32 - int64
+int64s int32s_int64s ( int32s High, int32u Low);
+int64u int32u_int64u ( int32u High, int32u Low);
+void int32s_int64s (int64s &BigInt, int32s High, int32u Low);
+void int32u_int64u (int64s &BigInt, int32u High, int32u Low);
+void int64s_int32s (int64s BigInt, int32s &High, int32u &Low);
+void int64u_int32u (int64u BigInt, int32u &High, int32u &Low);
+
+//---------------------------------------------------------------------------
+// Floats and ints
+int32s float32_int32s (float32 F, bool Rounded=true);
+int64s float32_int64s (float32 F, bool Rounded=true);
+int32s float64_int32s (float64 F, bool Rounded=true);
+int64s float64_int64s (float64 F, bool Rounded=true);
+
+// These functions are used because MSVC6 isn't able to convert an unsigned int64 to a floating-point value, and I couldn't think of a cleaner way to handle it.
+#if defined(_MSC_VER) && _MSC_VER<=1200
+ inline float32 int64u_float32 (int64u v) {return static_cast<float32>(static_cast<int64s>(v>>1))*2.0f + static_cast<float32>(static_cast<int64s>(v & 1));}
+ inline float64 int64u_float64 (int64u v) {return static_cast<float64>(static_cast<int64s>(v>>1))*2.0f + static_cast<float32>(static_cast<int64s>(v & 1));}
+#else
+ inline float32 int64u_float32 (int64u v) {return (float32)v;}
+ inline float64 int64u_float64 (int64u v) {return (float64)v;}
+#endif // defined(_MSC_VER) && _MSC_VER<=1200
+
+//---------------------------------------------------------------------------
+// CC (often used in all containers to identify a stream
+inline int64u CC8(const char* C) {return BigEndian2int64u(C);}
+inline int64u CC7(const char* C) {return BigEndian2int56u(C);}
+inline int64u CC6(const char* C) {return BigEndian2int48u(C);}
+inline int64u CC5(const char* C) {return BigEndian2int40u(C);}
+inline int32u CC4(const char* C) {return BigEndian2int32u(C);}
+inline int32u CC3(const char* C) {return BigEndian2int24u(C);}
+inline int16u CC2(const char* C) {return BigEndian2int16u(C);}
+inline int8u CC1(const char* C) {return BigEndian2int8u (C);}
+#ifndef __BORLANDC__
+inline int64u CC8(const int8u* C) {return BigEndian2int64u(C);}
+inline int64u CC7(const int8u* C) {return BigEndian2int56u(C);}
+inline int64u CC6(const int8u* C) {return BigEndian2int48u(C);}
+inline int64u CC5(const int8u* C) {return BigEndian2int40u(C);}
+inline int32u CC4(const int8u* C) {return BigEndian2int32u(C);}
+inline int32u CC3(const int8u* C) {return BigEndian2int24u(C);}
+inline int16u CC2(const int8u* C) {return BigEndian2int16u(C);}
+inline int8u CC1(const int8u* C) {return BigEndian2int8u (C);}
+#endif // __BORLANDC__
+
+//---------------------------------------------------------------------------
+// turn a numeric literal into a hex constant
+// (avoids problems with leading zeroes)
+// 8-bit constants max value 0x11111111, always fits in unsigned long
+#define HEX__(n) 0x##n##LU
+
+// 8-bit conversion function
+#define B8__(x) ((x&0x0000000FLU)?0x01:0) \
+ +((x&0x000000F0LU)?0x02:0) \
+ +((x&0x00000F00LU)?0x04:0) \
+ +((x&0x0000F000LU)?0x08:0) \
+ +((x&0x000F0000LU)?0x10:0) \
+ +((x&0x00F00000LU)?0x20:0) \
+ +((x&0x0F000000LU)?0x40:0) \
+ +((x&0xF0000000LU)?0x80:0)
+
+// for upto 8-bit binary constants
+#define B8(d) ((int8u)B8__(HEX__(d)))
+
+// for upto 16-bit binary constants, MSB first
+#define B16(dmsb, dlsb) (((int16u)B8(dmsb)<<8) \
+ + ((int16u)B8(dlsb)<<0))
+
+// for upto 32-bit binary constants, MSB first
+#define B32(dmsb, db2, db3, dlsb) (((int32u)B8(dmsb)<<24) \
+ + ((int32u)B8( db2)<<16) \
+ + ((int32u)B8( db3)<< 8) \
+ + ((int32u)B8(dlsb)<< 0))
+
+} //namespace ZenLib
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/Ztring.cpp b/src/thirdparty/ZenLib/ZenLib/Ztring.cpp
new file mode 100644
index 000000000..f114ddc03
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Ztring.cpp
@@ -0,0 +1,2420 @@
+// ZenLib::Ztring - std::(w)string is better
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// More methods for std::(w)string
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#ifdef ZENLIB_USEWX
+ #include <wx/strconv.h>
+ #include <wx/datetime.h>
+#else //ZENLIB_USEWX
+ #ifdef ZENLIB_STANDARD
+ #undef WINDOWS
+ #endif
+ #ifdef WINDOWS
+ #undef __TEXT
+ #include <windows.h>
+ #include <tchar.h>
+ #endif
+#endif //ZENLIB_USEWX
+#ifdef __MINGW32__
+ #include <windows.h>
+#endif //__MINGW32__
+#include <cstring>
+#include <cstdio>
+#include <cstdlib>
+#ifdef SS
+ #undef SS //Solaris defines this in cstdlib
+#endif
+#include <algorithm>
+#include <sstream>
+#include <iomanip>
+#include <cmath>
+#include "ZenLib/Ztring.h"
+#include "ZenLib/OS_Utils.h"
+#include "ZenLib/File.h"
+using namespace std;
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+int16u Ztring_ISO_8859_2[96]=
+{
+ 0x00A0,
+ 0x0104,
+ 0x02D8,
+ 0x0141,
+ 0x00A4,
+ 0x013D,
+ 0x015A,
+ 0x00A7,
+ 0x00A8,
+ 0x0160,
+ 0x015E,
+ 0x0164,
+ 0x0179,
+ 0x00AD,
+ 0x017D,
+ 0x017B,
+ 0x00B0,
+ 0x0105,
+ 0x02DB,
+ 0x0142,
+ 0x00B4,
+ 0x013E,
+ 0x015B,
+ 0x02C7,
+ 0x00B8,
+ 0x0161,
+ 0x015F,
+ 0x0165,
+ 0x017A,
+ 0x02DD,
+ 0x017E,
+ 0x017C,
+ 0x0154,
+ 0x00C1,
+ 0x00C2,
+ 0x0102,
+ 0x00C4,
+ 0x0139,
+ 0x0106,
+ 0x00C7,
+ 0x010C,
+ 0x00C9,
+ 0x0118,
+ 0x00CB,
+ 0x011A,
+ 0x00CD,
+ 0x00CE,
+ 0x010E,
+ 0x0110,
+ 0x0143,
+ 0x0147,
+ 0x00D3,
+ 0x00D4,
+ 0x0150,
+ 0x00D6,
+ 0x00D7,
+ 0x0158,
+ 0x016E,
+ 0x00DA,
+ 0x0170,
+ 0x00DC,
+ 0x00DD,
+ 0x0162,
+ 0x00DF,
+ 0x0155,
+ 0x00E1,
+ 0x00E2,
+ 0x0103,
+ 0x00E4,
+ 0x013A,
+ 0x0107,
+ 0x00E7,
+ 0x010D,
+ 0x00E9,
+ 0x0119,
+ 0x00EB,
+ 0x011B,
+ 0x00ED,
+ 0x00EE,
+ 0x010F,
+ 0x0111,
+ 0x0144,
+ 0x0148,
+ 0x00F3,
+ 0x00F4,
+ 0x0151,
+ 0x00F6,
+ 0x00F7,
+ 0x0159,
+ 0x016F,
+ 0x00FA,
+ 0x0171,
+ 0x00FC,
+ 0x00FD,
+ 0x0163,
+ 0x02D9,
+};
+
+//---------------------------------------------------------------------------
+Ztring EmptyZtring;
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if defined(STREAM_MISSING)
+ #if defined (_UNICODE)
+ #define _tnprintf snwprintf
+ #else
+ #define _tnprintf snprintf
+ #endif
+#else
+ typedef basic_stringstream<Char> tStringStream;
+ typedef basic_istringstream<Char> tiStringStream;
+ typedef basic_ostringstream<Char> toStringStream;
+#endif
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Operators
+//***************************************************************************
+
+Char &Ztring::operator() (size_type Pos)
+{
+ if (Pos>size())
+ resize(Pos);
+ return operator[] (Pos);
+}
+
+//***************************************************************************
+// Assign
+//***************************************************************************
+
+bool Ztring::Assign_FromFile (const Ztring &FileName)
+{
+ File F;
+ if (!F.Open(FileName))
+ return false;
+ int64u F_Size=F.Size_Get();
+ if (F_Size>((size_t)-1)-1)
+ return false;
+
+ //Creating buffer
+ int8u* Buffer=new int8u[(size_t)F_Size+1];
+ size_t Buffer_Offset=0;
+
+ //Reading the file
+ while(Buffer_Offset<F_Size)
+ {
+ size_t BytesRead=F.Read(Buffer+Buffer_Offset, (size_t)F_Size-Buffer_Offset);
+ if (BytesRead==0)
+ break; //Read is finished
+ Buffer_Offset+=BytesRead;
+ }
+ if (Buffer_Offset<F_Size)
+ {
+ delete[] Buffer;
+ return false;
+ }
+ Buffer[Buffer_Offset]='\0';
+
+ //Filling
+ assign((const Char*)Buffer);
+ delete[] Buffer;
+
+ return true;
+}
+
+//***************************************************************************
+// Conversions
+//***************************************************************************
+
+Ztring& Ztring::From_Unicode (const wchar_t* S)
+{
+ if (S==NULL)
+ return *this;
+
+ #ifdef _UNICODE
+ assign(S);
+ #else
+ #ifdef ZENLIB_USEWX
+ size_type OK=wxConvCurrent->WC2MB(NULL, S, 0);
+ if (OK!=0 && OK!=Error)
+ assign(wxConvCurrent->cWC2MB(S));
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ if (IsWin9X())
+ {
+ clear();
+ return *this; //Is not possible, UTF-8 is not supported by Win9X
+ }
+ int Size=WideCharToMultiByte(CP_UTF8, 0, S, -1, NULL, 0, NULL, NULL);
+ if (Size!=0)
+ {
+ char* AnsiString=new char[Size+1];
+ WideCharToMultiByte(CP_UTF8, 0, S, -1, AnsiString, Size, NULL, NULL);
+ AnsiString[Size]='\0';
+ assign (AnsiString);
+ delete[] AnsiString;
+ }
+ else
+ clear();
+ #else //WINDOWS
+ size_t Size=wcstombs(NULL, S, 0);
+ if (Size!=0 && Size!=(size_t)-1)
+ {
+ char* AnsiString=new char[Size+1];
+ Size=wcstombs(AnsiString, S, wcslen(S));
+ AnsiString[Size]='\0';
+ assign (AnsiString);
+ delete[] AnsiString;
+ }
+ else
+ clear();
+ #endif
+ #endif //ZENLIB_USEWX
+ #endif
+ return *this;
+}
+
+Ztring& Ztring::From_Unicode (const wchar_t *S, size_type Start, size_type Length)
+{
+ if (S==NULL)
+ return *this;
+
+ if (Length==Error)
+ Length=wcslen(S+Start);
+ wchar_t* Temp=new wchar_t[Length+1];
+ wcsncpy (Temp, S+Start, Length);
+ Temp[Length]=_T('\0');
+
+ From_Unicode(Temp);
+ delete[] Temp; //Temp=NULL;
+ return *this;
+}
+
+Ztring& Ztring::From_UTF8 (const char* S)
+{
+ if (S==NULL)
+ return *this;
+
+ #ifdef ZENLIB_USEWX
+ size_type OK=wxConvUTF8.MB2WC(NULL, S, 0);
+ if (OK!=0 && OK!=Error)
+ #ifdef _UNICODE
+ assign(wxConvUTF8.cMB2WC(S).data());
+ #else
+ assign(wxConvCurrent->cWC2MB(wxConvUTF8.cMB2WC(S)));
+ #endif
+ #else //ZENLIB_USEWX
+ #ifdef _UNICODE
+ // Don't use MultiByteToWideChar(), some characters are not well decoded
+ clear();
+ const int8u* Z=(const int8u*)S;
+ while (*Z) //0 is end
+ {
+ //1 byte
+ if (*Z<0x80)
+ {
+ operator += ((wchar_t)(*Z));
+ Z++;
+ }
+ //2 bytes
+ else if ((*Z&0xE0)==0xC0)
+ {
+ if ((*(Z+1)&0xC0)==0x80)
+ {
+ operator += ((((wchar_t)(*Z&0x1F))<<6)|(*(Z+1)&0x3F));
+ Z+=2;
+ }
+ else
+ {
+ clear();
+ return *this; //Bad character
+ }
+ }
+ //3 bytes
+ else if ((*Z&0xF0)==0xE0)
+ {
+ if ((*(Z+1)&0xC0)==0x80 && (*(Z+2)&0xC0)==0x80)
+ {
+ operator += ((((wchar_t)(*Z&0x0F))<<12)|((*(Z+1)&0x3F)<<6)|(*(Z+2)&0x3F));
+ Z+=3;
+ }
+ else
+ {
+ clear();
+ return *this; //Bad character
+ }
+ }
+ //4 bytes
+ else if ((*Z&0xF8)==0xF0)
+ {
+ if ((*(Z+1)&0xC0)==0x80 && (*(Z+2)&0xC0)==0x80 && (*(Z+3)&0xC0)==0x80)
+ {
+ operator += ((((wchar_t)(*Z&0x0F))<<18)|((*(Z+1)&0x3F)<<12)||((*(Z+2)&0x3F)<<6)|(*(Z+3)&0x3F));
+ Z+=4;
+ }
+ else
+ {
+ clear();
+ return *this; //Bad character
+ }
+ }
+ else
+ {
+ clear();
+ return *this; //Bad character
+ }
+ }
+ #else
+ assign(S); //Not implemented
+ #endif
+ #endif //ZENLIB_USEWX
+ return *this;
+}
+
+Ztring& Ztring::From_UTF8 (const char* S, size_type Start, size_type Length)
+{
+ if (S==NULL)
+ return *this;
+
+ if (Length==Error)
+ Length=strlen(S+Start);
+ char* Temp=new char[Length+1];
+ strncpy (Temp, S+Start, Length);
+ Temp[Length]='\0';
+
+ From_UTF8(Temp);
+ delete[] Temp; //Temp=NULL;
+ return *this;
+}
+
+Ztring& Ztring::From_UTF16 (const char* S)
+{
+ if (S==NULL)
+ return *this;
+
+ if ((unsigned char)S[0]==(unsigned char)0xFF && (unsigned char)S[1]==(unsigned char)0xFE)
+ return From_UTF16LE(S+2);
+ else if ((unsigned char)S[0]==(unsigned char)0xFE && (unsigned char)S[1]==(unsigned char)0xFF)
+ return From_UTF16BE(S+2);
+ else if ((unsigned char)S[0]==(unsigned char)0x00 && (unsigned char)S[1]==(unsigned char)0x00)
+ {
+ clear(); //No begin!
+ return *this;
+ }
+ else
+ return From_UTF16LE(S); //Not sure, default
+}
+
+Ztring& Ztring::From_UTF16 (const char* S, size_type Start, size_type Length)
+{
+ if (S==NULL)
+ return *this;
+
+ if (Length<2)
+ return *this;
+
+ if ((unsigned char)S[0]==(unsigned char)0xFF && (unsigned char)S[1]==(unsigned char)0xFE)
+ return From_UTF16LE(S+2, Start, Length-2);
+ else if ((unsigned char)S[0]==(unsigned char)0xFE && (unsigned char)S[1]==(unsigned char)0xFF)
+ return From_UTF16BE(S+2, Start, Length-2);
+ else if ((unsigned char)S[0]==(unsigned char)0x00 && (unsigned char)S[1]==(unsigned char)0x00)
+ {
+ clear(); //No begin!
+ return *this;
+ }
+ else
+ return From_UTF16LE(S, Start, Length); //Not sure, default
+}
+
+Ztring& Ztring::From_UTF16BE (const char* S)
+{
+ if (S==NULL)
+ return *this;
+
+ #ifdef ZENLIB_USEWX
+ //clear(); return *this;
+ wxMBConvUTF16BE wxConvUTF16BE;
+ size_type OK=wxConvUTF16BE.MB2WC(NULL, S, 0);
+ if (OK!=0 && OK!=Error)
+ #ifdef _UNICODE
+ assign(wxConvUTF16BE.cMB2WC(S).data());
+ #else
+ assign(wxConvCurrent->cWC2MB(wxConvUTF16BE.cMB2WC(S)));
+ #endif
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ clear();
+ const wchar_t* SW=(const wchar_t*)S;
+ size_t Pos=0;
+ while (SW[Pos]!=_T('\0'))
+ {
+ Char Temp=(Char)(((SW[Pos]&0xFF00)>>8)+((SW[Pos]&0x00FF)<<8));
+ append(1, Temp);
+ Pos++;
+ }
+ #else //WINDOWS
+ clear();
+ while (S[0]!=0 || S[1]!=0)
+ {
+ append(1, (Char)BigEndian2int16u(S));
+ S+=2;
+ }
+ #endif
+ #endif //ZENLIB_USEWX
+ return *this;
+}
+
+Ztring& Ztring::From_UTF16BE (const char* S, size_type Start, size_type Length)
+{
+ if (S==NULL)
+ return *this;
+
+ if (Length==Error)
+ {
+ Length=0;
+ while(S[Length]!=0x0000)
+ Length++;
+ }
+
+ char* Temp=new char[Length+2];
+ memcpy (Temp, S+Start, Length);
+ Temp[Length+0]=0x00;
+ Temp[Length+1]=0x00;
+ reserve(Length);
+ From_UTF16BE(Temp);
+ delete[] Temp; //Temp=NULL;
+ return *this;
+}
+
+Ztring& Ztring::From_UTF16LE (const char* S)
+{
+ if (S==NULL)
+ return *this;
+
+ #ifdef ZENLIB_USEWX
+ //clear(); return *this;
+ wxMBConvUTF16LE wxConvUTF16LE;
+ size_type OK=wxConvUTF16LE.MB2WC(NULL, S, 0);
+ if (OK!=0 && OK!=Error)
+ #ifdef _UNICODE
+ assign(wxConvUTF16LE.cMB2WC(S).data());
+ #else
+ assign(wxConvCurrent->cWC2MB(wxConvUTF16LE.cMB2WC(S)));
+ #endif
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ #ifdef UNICODE
+ const wchar_t* SW=(const wchar_t*)S;
+ assign(SW);
+ #else
+ clear(); //Not implemented
+ #endif
+ #else //WINDOWS
+ clear();
+ while (S[0]!=0 || S[1]!=0)
+ {
+ append(1, (Char)LittleEndian2int16u(S));
+ S+=2;
+ }
+ #endif
+ #endif //ZENLIB_USEWX
+ return *this;
+}
+
+Ztring& Ztring::From_UTF16LE (const char* S, size_type Start, size_type Length)
+{
+ if (S==NULL)
+ return *this;
+
+ if (Length==Error)
+ {
+ Length=0;
+ while(S[Length]!=0x0000)
+ Length+=2;
+ }
+
+ char* Temp=new char[Length+2];
+ memcpy (Temp, S+Start, Length);
+ Temp[Length+0]=0x00;
+ Temp[Length+1]=0x00;
+ From_UTF16LE(Temp);
+ delete[] Temp; //Temp=NULL;
+ return *this;
+}
+
+Ztring& Ztring::From_Local (const char* S)
+{
+ if (S==NULL)
+ return *this;
+
+ #ifdef _UNICODE
+ #ifdef ZENLIB_USEWX
+ size_type OK=wxConvCurrent->MB2WC(NULL, S, 0);
+ if (OK!=0 && OK!=Error)
+ assign(wxConvCurrent->cMB2WC(S).data());
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ int Size=MultiByteToWideChar(CP_ACP, 0, S, -1, NULL, 0);
+ if (Size!=0)
+ {
+ wchar_t* WideString=new wchar_t[Size+1];
+ MultiByteToWideChar(CP_ACP, 0, S, -1, WideString, Size);
+ WideString[Size]=L'\0';
+ assign (WideString);
+ delete[] WideString; //WideString=NULL;
+ }
+ else
+ clear();
+ #else //WINDOWS
+ size_t Size=mbstowcs(NULL, S, 0);
+ if (Size!=0 && Size!=(size_t)-1)
+ {
+ wchar_t* WideString=new wchar_t[Size+1];
+ Size=mbstowcs(WideString, S, Size);
+ WideString[Size]=L'\0';
+ assign (WideString);
+ delete[] WideString; //WideString=NULL;
+ }
+ else
+ clear();
+ #endif
+ #endif //ZENLIB_USEWX
+ #else
+ assign(S);
+ #endif
+ return *this;
+}
+
+Ztring& Ztring::From_Local (const char* S, size_type Start, size_type Length)
+{
+ if (S==NULL)
+ return *this;
+
+ if (Length==Error)
+ Length=strlen(S+Start);
+ #ifdef _UNICODE
+ char* Temp=new char[Length+1];
+ strncpy (Temp, S+Start, Length);
+ Temp[Length]='\0';
+ From_Local(Temp);
+ delete[] Temp; //Temp=NULL;
+ #else
+ assign(S+Start, Length);
+ if (find(_T('\0'))!=std::string::npos)
+ resize(find(_T('\0')));
+ #endif
+ return *this;
+}
+
+Ztring& Ztring::From_ISO_8859_1(const char* S)
+{
+ size_t Length = strlen(S);
+ wchar_t* Temp = new wchar_t[Length +1];
+
+ for (size_t Pos=0; Pos<Length+1; Pos++)
+ Temp[Pos]=(wchar_t)((int8u)S[Pos]);
+
+ From_Unicode(Temp);
+ delete[] Temp;
+ return *this;
+}
+
+Ztring& Ztring::From_ISO_8859_1(const char* S, size_type Start, size_type Length)
+{
+ if (S==NULL)
+ return *this;
+
+ if (Length==Error)
+ Length=strlen(S+Start);
+ #ifdef _UNICODE
+ char* Temp = new char[Length+1];
+ strncpy(Temp, S +Start, Length);
+ Temp[Length] = '\0';
+ From_ISO_8859_1(Temp);
+ delete[] Temp;
+ #else
+ assign(S +Start, Length);
+ if (find(_T('\0')) != std::string::npos)
+ resize(find(_T('\0')));
+ #endif
+ return *this;
+}
+
+Ztring& Ztring::From_ISO_8859_2(const char* S)
+{
+ size_t Length = strlen(S);
+ wchar_t* Temp = new wchar_t[Length +1];
+
+ for (size_t Pos=0; Pos<Length+1; Pos++)
+ {
+ if ((int8u)S[Pos]>=0xA0)
+ Temp[Pos]=(wchar_t)Ztring_ISO_8859_2[((int8u)S[Pos])-0xA0];
+ else
+ Temp[Pos]=(wchar_t)((int8u)S[Pos]);
+ }
+
+ From_Unicode(Temp);
+ delete[] Temp;
+ return *this;
+}
+
+Ztring& Ztring::From_ISO_8859_2(const char* S, size_type Start, size_type Length)
+{
+ if (S==NULL)
+ return *this;
+
+ if (Length==Error)
+ Length=strlen(S+Start);
+ #ifdef _UNICODE
+ char* Temp = new char[Length+1];
+ strncpy(Temp, S +Start, Length);
+ Temp[Length] = '\0';
+ From_ISO_8859_2(Temp);
+ delete[] Temp;
+ #else
+ assign(S +Start, Length);
+ if (find(_T('\0')) != std::string::npos)
+ resize(find(_T('\0')));
+ #endif
+ return *this;
+}
+
+Ztring& Ztring::From_GUID (const int128u S)
+{
+ Ztring S1;
+ S1.From_CC1((int8u) ((S.hi&0x000000FF00000000LL)>>32)); append(S1);
+ S1.From_CC1((int8u) ((S.hi&0x0000FF0000000000LL)>>40)); append(S1);
+ S1.From_CC1((int8u) ((S.hi&0x00FF000000000000LL)>>48)); append(S1);
+ S1.From_CC1((int8u) ((S.hi&0xFF00000000000000LL)>>56)); append(S1); append(_T("-"));
+ S1.From_CC1((int8u) ((S.hi&0x0000000000FF0000LL)>>16)); append(S1);
+ S1.From_CC1((int8u) ((S.hi&0x00000000FF000000LL)>>24)); append(S1); append(_T("-"));
+ S1.From_CC1((int8u) ( S.hi&0x00000000000000FFLL )); append(S1);
+ S1.From_CC1((int8u) ((S.hi&0x000000000000FF00LL)>> 8)); append(S1); append(_T("-"));
+ S1.From_CC2((int16u)((S.lo&0xFFFF000000000000LL)>>48)); append(S1); append(_T("-"));
+ S1.From_CC2((int16u)((S.lo&0x0000FFFF00000000LL)>>32)); append(S1);
+ S1.From_CC2((int16u)((S.lo&0x00000000FFFF0000LL)>>16)); append(S1);
+ S1.From_CC2((int16u)( S.lo&0x000000000000FFFFLL )); append(S1);
+
+ return *this;
+}
+
+Ztring& Ztring::From_UUID (const int128u S)
+{
+ Ztring S1;
+ S1.From_CC2((int16u)((S.hi&0xFFFF000000000000LL)>>48)); assign(S1);
+ S1.From_CC2((int16u)((S.hi&0x0000FFFF00000000LL)>>32)); append(S1); append(_T("-"));
+ S1.From_CC2((int16u)((S.hi&0x00000000FFFF0000LL)>>16)); append(S1); append(_T("-"));
+ S1.From_CC2((int16u)( S.hi&0x000000000000FFFFLL )); append(S1); append(_T("-"));
+ S1.From_CC2((int16u)((S.lo&0xFFFF000000000000LL)>>48)); append(S1); append(_T("-"));
+ S1.From_CC2((int16u)((S.lo&0x0000FFFF00000000LL)>>32)); append(S1);
+ S1.From_CC2((int16u)((S.lo&0x00000000FFFF0000LL)>>16)); append(S1);
+ S1.From_CC2((int16u)( S.lo&0x000000000000FFFFLL )); append(S1);
+
+ return *this;
+}
+
+Ztring& Ztring::From_CC4 (const int32u S)
+{
+ std::string S1;
+ S1.append(1, (char)((S&0xFF000000)>>24));
+ S1.append(1, (char)((S&0x00FF0000)>>16));
+ S1.append(1, (char)((S&0x0000FF00)>> 8));
+ S1.append(1, (char)((S&0x000000FF)>> 0));
+ From_Local(S1.c_str());
+
+ //Test
+ if (empty())
+ assign(_T("(empty)"));
+
+ return *this;
+}
+
+Ztring& Ztring::From_CC3 (const int32u S)
+{
+ std::string S1;
+ S1.append(1, (char)((S&0x00FF0000)>>16));
+ S1.append(1, (char)((S&0x0000FF00)>> 8));
+ S1.append(1, (char)((S&0x000000FF)>> 0));
+ From_Local(S1.c_str());
+
+ //Test
+ if (empty())
+ assign(_T("(empty)"));
+
+ return *this;
+}
+
+Ztring& Ztring::From_CC2 (const int16u S)
+{
+ clear();
+ Ztring Pos1; Pos1.From_Number(S, 16);
+ resize(4-Pos1.size(), _T('0'));
+ append(Pos1);
+ MakeUpperCase();
+
+ return *this;
+}
+
+Ztring& Ztring::From_CC1 (const int8u S)
+{
+ clear();
+ Ztring Pos1; Pos1.From_Number(S, 16);
+ resize(2-Pos1.size(), _T('0'));
+ append(Pos1);
+ MakeUpperCase();
+
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const int8s I, int8u Radix)
+{
+ #if defined(STREAM_MISSING)
+ if (Radix==0)
+ {
+ clear();
+ return *this;
+ }
+ Char* C1=new Char[33];
+ #ifdef __MINGW32__
+ _itot (I, C1, Radix);
+ #else
+ _tnprintf(C1, 32, Radix==10?_T("%d"):(Radix==16?_T("%x"):(Radix==8?_T("%o"):_T(""))), I);
+ #endif
+ assign (C1);
+ delete[] C1; //C1=NULL;
+ #else
+ toStringStream SS;
+ #ifdef UNICODE
+ SS << setbase(Radix) << I;
+ #else //UNICODE
+ SS << setbase(Radix) << (size_t)I; //On linux (at least), (un)signed char is detected as a char
+ #endif //UNICODE
+ assign(SS.str());
+ #endif
+ MakeUpperCase();
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const int8u I, int8u Radix)
+{
+ #if defined(STREAM_MISSING)
+ if (Radix==0)
+ {
+ clear();
+ return *this;
+ }
+ Char* C1=new Char[33];
+ #ifdef __MINGW32__
+ _ultot (I, C1, Radix);
+ #else
+ _tnprintf(C1, 32, Radix==10?_T("%d"):(Radix==16?_T("%x"):(Radix==8?_T("%o"):_T(""))), I);
+ #endif
+ assign (C1);
+ delete[] C1; //C1=NULL;
+ #else
+ if (Radix==2)
+ {
+ clear();
+ for (int8u Pos=0; Pos<8; Pos++)
+ {
+ if (I<(((int8u)1)<<Pos))
+ break;
+ insert(0, 1, (I&(((int8u)1)<<Pos))?_T('1'):_T('0'));
+ }
+ }
+ else
+ {
+ toStringStream SS;
+ #ifdef UNICODE
+ SS << setbase(Radix) << I;
+ #else //UNICODE
+ SS << setbase(Radix) << (size_t)I; //On linux (at least), (un)signed char is detected as a char
+ #endif //UNICODE
+ assign(SS.str());
+ }
+ #endif
+ MakeUpperCase();
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const int16s I, int8u Radix)
+{
+ #if defined(STREAM_MISSING)
+ if (Radix==0)
+ {
+ clear();
+ return *this;
+ }
+ Char* C1=new Char[33];
+ #ifdef __MINGW32__
+ _itot (I, C1, Radix);
+ #else
+ _tnprintf(C1, 32, Radix==10?_T("%d"):(Radix==16?_T("%x"):(Radix==8?_T("%o"):_T(""))), I);
+ #endif
+ assign (C1);
+ delete[] C1; //C1=NULL;
+ #else
+ toStringStream SS;
+ SS << setbase(Radix) << I;
+ assign(SS.str());
+ #endif
+ MakeUpperCase();
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const int16u I, int8u Radix)
+{
+ #if defined(STREAM_MISSING)
+ if (Radix==0)
+ {
+ clear();
+ return *this;
+ }
+ Char* C1=new Char[33];
+ #ifdef __MINGW32__
+ _ultot (I, C1, Radix);
+ #else
+ _tnprintf(C1, 32, Radix==10?_T("%u"):(Radix==16?_T("%x"):(Radix==8?_T("%o"):_T(""))), I);
+ #endif
+ assign (C1);
+ delete[] C1; //C1=NULL;
+ #else
+ if (Radix==2)
+ {
+ clear();
+ for (int8u Pos=0; Pos<16; Pos++)
+ {
+ if (I<(((int16u)1)<<Pos))
+ break;
+ insert(0, 1, (I&(((int16u)1)<<Pos))?_T('1'):_T('0'));
+ }
+ }
+ else
+ {
+ toStringStream SS;
+ SS << setbase(Radix) << I;
+ assign(SS.str());
+ }
+ #endif
+ MakeUpperCase();
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const int32s I, int8u Radix)
+{
+ #if defined(STREAM_MISSING)
+ if (Radix==0)
+ {
+ clear();
+ return *this;
+ }
+ Char* C1=new Char[33];
+ #ifdef __MINGW32__
+ _itot (I, C1, Radix);
+ #else
+ _tnprintf(C1, 32, Radix==10?_T("%ld"):(Radix==16?_T("%lx"):(Radix==8?_T("%lo"):_T(""))), I);
+ #endif
+ assign (C1);
+ delete[] C1; //C1=NULL;
+ #else
+ toStringStream SS;
+ SS << setbase(Radix) << I;
+ assign(SS.str());
+ #endif
+ MakeUpperCase();
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const int32u I, int8u Radix)
+{
+ #if defined(STREAM_MISSING)
+ if (Radix==0)
+ {
+ clear();
+ return *this;
+ }
+ Char* C1=new Char[33];
+ #ifdef __MINGW32__
+ _ultot (I, C1, Radix);
+ #else
+ _tnprintf(C1, 32, Radix==10?_T("%lu"):(Radix==16?_T("%lx"):(Radix==8?_T("%lo"):_T(""))), I);
+ #endif
+ assign (C1);
+ delete[] C1; //C1=NULL;
+ #else
+ if (Radix==2)
+ {
+ clear();
+ for (int8u Pos=0; Pos<32; Pos++)
+ {
+ if (I<(((int32u)1)<<Pos))
+ break;
+ insert(0, 1, (I&(((int32u)1)<<Pos))?_T('1'):_T('0'));
+ }
+ }
+ else
+ {
+ toStringStream SS;
+ SS << setbase(Radix) << I;
+ assign(SS.str());
+ }
+ #endif
+ MakeUpperCase();
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const int64s I, int8u Radix)
+{
+ #if defined(STREAM_MISSING)
+ if (Radix==0)
+ {
+ clear();
+ return *this;
+ }
+ Char* C1=new Char[65];
+ #ifdef __MINGW32__
+ _i64tot (I, C1, Radix);
+ #else
+ _tnprintf(C1, 64, Radix==10?_T("%lld"):(Radix==16?_T("%llx"):(Radix==8?_T("%llo"):_T(""))), I);
+ #endif
+ assign (C1);
+ delete[] C1; //C1=NULL;
+ #else
+ toStringStream SS;
+ SS << setbase(Radix) << I;
+ assign(SS.str());
+ #endif
+ MakeUpperCase();
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const int64u I, int8u Radix)
+{
+ #if defined(STREAM_MISSING)
+ if (Radix==0)
+ {
+ clear();
+ return *this;
+ }
+ Char* C1=new Char[65];
+ #ifdef __MINGW32__
+ _ui64tot (I, C1, Radix);
+ #else
+ _tnprintf(C1, 64, Radix==10?_T("%llu"):(Radix==16?_T("%llx"):(Radix==8?_T("%llo"):_T(""))), I);
+ #endif
+ assign (C1);
+ delete[] C1; //C1=NULL;
+ #else
+ if (Radix==2)
+ {
+ clear();
+ for (int8u Pos=0; Pos<32; Pos++)
+ {
+ if (I<(((int64u)1)<<Pos))
+ break;
+ insert(0, 1, (I&(((int64u)1)<<Pos))?_T('1'):_T('0'));
+ }
+ }
+ else
+ {
+ toStringStream SS;
+ SS << setbase(Radix) << I;
+ assign(SS.str());
+ }
+ #endif
+ MakeUpperCase();
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const int128u I, int8u Radix)
+{
+ From_Local(I.toString(Radix));
+
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const float32 F, int8u Precision, ztring_t Options)
+{
+ #if defined(STREAM_MISSING)
+ Char C1[100];
+ _tnprintf (C1, 99, (Ztring(_T("%."))+Ztring::ToZtring(Precision)+_T("f")).c_str(), F);
+ assign(C1);
+ #else
+ toStringStream SS;
+ SS << setprecision(Precision) << fixed << F;
+ assign(SS.str());
+ #if defined(__BORLANDC__)
+ FindAndReplace(_T(","), _T(".")); //Borland C++ Builder 2010+Windows Seven put a comma for istringstream, but does not support comma for ostringstream
+ #endif
+ #endif
+
+ if ((Options & Ztring_NoZero && size()>0) && find(_T('.'))>0)
+ {
+ while (size()>0 && ((*this)[size()-1]==_T('0')))
+ resize(size()-1);
+ if (size()>0 && (*this)[size()-1]==_T('.'))
+ resize(size()-1);
+ }
+
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const float64 F, int8u Precision, ztring_t Options)
+{
+ #if defined(STREAM_MISSING)
+ Char C1[100];
+ _tnprintf (C1, 99, (Ztring(_T("%."))+Ztring::ToZtring(Precision)+_T("f")).c_str(), F);
+ assign(C1);
+ #else
+ toStringStream SS;
+ SS << setprecision(Precision) << fixed << F;
+ assign(SS.str());
+ #if defined(__BORLANDC__)
+ FindAndReplace(_T(","), _T(".")); //Borland C++ Builder 2010+Windows Seven put a comma for istringstream, but does not support comma for ostringstream
+ #endif
+ #endif
+
+ if ((Options & Ztring_NoZero && size()>0) && find(_T('.'))>0)
+ {
+ while (size()>0 && ((*this)[size()-1]==_T('0')))
+ resize(size()-1);
+ if (size()>0 && (*this)[size()-1]==_T('.'))
+ resize(size()-1);
+ }
+
+ return *this;
+}
+
+Ztring& Ztring::From_Number (const float80 F, int8u Precision, ztring_t Options)
+{
+ #if defined(STREAM_MISSING)
+ Char C1[100];
+ _tnprintf (C1, 99, (Ztring(_T("%."))+Ztring::ToZtring(Precision)+_T("f")).c_str(), F);
+ assign(C1);
+ #else
+ toStringStream SS;
+ SS << setprecision(Precision) << fixed << F;
+ assign(SS.str());
+ #if defined(__BORLANDC__)
+ FindAndReplace(_T(","), _T(".")); //Borland C++ Builder 2010+Windows Seven put a comma for istringstream, but does not support comma for ostringstream
+ #endif
+ #endif
+
+ if ((Options & Ztring_NoZero && size()>0) && find(_T('.'))>0)
+ {
+ while (size()>0 && ((*this)[size()-1]==_T('0')))
+ resize(size()-1);
+ if (size()>0 && (*this)[size()-1]==_T('.'))
+ resize(size()-1);
+ }
+
+ return *this;
+}
+
+#ifdef SIZE_T_IS_LONG
+Ztring& Ztring::From_Number (const size_t I, int8u Radix)
+{
+ #if defined(STREAM_MISSING)
+ Char C1[100];
+ _tnprintf(C1, 64, Radix==10?_T("%zu"):(Radix==16?_T("%zx"):(Radix==8?_T("%zo"):_T(""))), I);
+ assign(C1);
+ #else
+ toStringStream SS;
+ SS << setbase(Radix) << I;
+ assign(SS.str());
+ #if defined(__BORLANDC__)
+ FindAndReplace(_T(","), _T(".")); //Borland C++ Builder 2010+Windows Seven put a comma for istringstream, but does not support comma for ostringstream
+ #endif
+ #endif
+ MakeUpperCase();
+ return *this;
+}
+#endif //SIZE_T_IS_LONG
+
+Ztring& Ztring::From_BCD (const int8u I)
+{
+ #if defined(STREAM_MISSING)
+ clear();
+ append(1, _T('0')+I/0x10);
+ append(1, _T('0')+I%0x10);
+ #else
+ toStringStream SS;
+ SS << I/0x10;
+ SS << I%0x10;
+ assign(SS.str());
+ #endif
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+Ztring& Ztring::Duration_From_Milliseconds (const int64s Value_)
+{
+ int64s Value=Value_;
+ bool Negative=false;
+ if (Value<0)
+ {
+ Value=-Value;
+ Negative=true;
+ }
+
+ int64u HH=(int8u)(Value/1000/60/60);
+ int64u MM=Value/1000/60 -((HH*60));
+ int64u SS=Value/1000 -((HH*60+MM)*60);
+ int64u MS=Value -((HH*60+MM)*60+SS)*1000;
+ Ztring DateT;
+ Ztring Date;
+ DateT.From_Number(HH); if (DateT.size()<2){DateT=Ztring(_T("0"))+DateT;}
+ Date+=DateT;
+ Date+=_T(":");
+ DateT.From_Number(MM); if (DateT.size()<2){DateT=Ztring(_T("0"))+DateT;}
+ Date+=DateT;
+ Date+=_T(":");
+ DateT.From_Number(SS); if (DateT.size()<2){DateT=Ztring(_T("0"))+DateT;}
+ Date+=DateT;
+ Date+=_T(".");
+ DateT.From_Number(MS); if (DateT.size()<2){DateT=Ztring(_T("00"))+DateT;} else if (DateT.size()<3){DateT=Ztring(_T("0"))+DateT;}
+ Date+=DateT;
+ if (Negative)
+ {
+ assign(_T("-"));
+ append(Date);
+ }
+ else
+ assign (Date.c_str());
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+Ztring& Ztring::Duration_From_Milliseconds (const int64u Value)
+{
+ int64u HH=(int8u)(Value/1000/60/60);
+ int64u MM=Value/1000/60 -((HH*60));
+ int64u SS=Value/1000 -((HH*60+MM)*60);
+ int64u MS=Value -((HH*60+MM)*60+SS)*1000;
+ Ztring DateT;
+ Ztring Date;
+ DateT.From_Number(HH); if (DateT.size()<2){DateT=Ztring(_T("0"))+DateT;}
+ Date+=DateT;
+ Date+=_T(":");
+ DateT.From_Number(MM); if (DateT.size()<2){DateT=Ztring(_T("0"))+DateT;}
+ Date+=DateT;
+ Date+=_T(":");
+ DateT.From_Number(SS); if (DateT.size()<2){DateT=Ztring(_T("0"))+DateT;}
+ Date+=DateT;
+ Date+=_T(".");
+ DateT.From_Number(MS); if (DateT.size()<2){DateT=Ztring(_T("00"))+DateT;} else if (DateT.size()<3){DateT=Ztring(_T("0"))+DateT;}
+ Date+=DateT;
+ assign (Date.c_str());
+ return *this;
+}
+
+Ztring& Ztring::Date_From_Milliseconds_1601 (const int64u Value)
+{
+ if (Value>=11644473600000LL) //Values <1970 are not supported
+ {
+ Date_From_Seconds_1970((int32u)((Value-11644473600000LL)/1000));
+ append(_T("."));
+ Ztring Milliseconds; Milliseconds.From_Number(Value%1000);
+ while (Milliseconds.size()<3)
+ Milliseconds+=_T('0');
+ append(Milliseconds);
+ }
+ else
+ clear(); //Not supported
+
+ return *this;
+}
+
+Ztring& Ztring::Date_From_Seconds_1601 (const int64u Value)
+{
+ if (Value>=11644473600LL) //Values <1970 are not supported
+ Date_From_Seconds_1970((int32u)(Value-11644473600LL));
+ else
+ clear(); //Not supported
+
+ return *this;
+}
+
+Ztring& Ztring::Date_From_Seconds_1904 (const int64u Value)
+{
+ #ifdef ZENLIB_USEWX
+ /*
+ wxDateTime Date;
+ Date.SetYear(1904);
+ Date.SetMonth(wxDateTime::Jan);
+ Date.SetDay(1);
+ Date.SetHour(0);
+ Date.SetMinute(0);
+ Date.SetSecond(0);
+ if (Value>=0x80000000)
+ {
+ //wxTimeSpan doesn't support unsigned int
+ int64u Value2=Value;
+ while (Value2>0x7FFFFFFF)
+ {
+ Date+=wxTimeSpan::Seconds(0x7FFFFFFF);
+ Value2-=0x7FFFFFFF;
+ }
+ Date+=wxTimeSpan::Seconds(Value2);
+ }
+ else
+ Date+=wxTimeSpan::Seconds(Value);
+
+ Ztring ToReturn=_T("UTC ");
+ ToReturn+=Date.FormatISODate();
+ ToReturn+=_T(" ");
+ ToReturn+=Date.FormatISOTime();
+
+ assign (ToReturn.c_str());
+ */ //WxDateTime is buggy???
+ if (Value>2082844800 && Value<2082844800+0x100000000LL) //Values <1970 and >2038 are not supported, 1970-01-01 00:00:00 is considered as not possible too
+ Date_From_Seconds_1970((int32u)(Value-2082844800));
+ else
+ clear(); //Not supported
+
+ #else //ZENLIB_USEWX
+ if (Value>2082844800 && Value<2082844800+0x100000000LL) //Values <1970 and >2038 are not supported, 1970-01-01 00:00:00 is considered as not possible too
+ Date_From_Seconds_1970((int32u)(Value-2082844800));
+ else
+ clear(); //Not supported
+ #endif //ZENLIB_USEWX
+ return *this;
+}
+
+Ztring& Ztring::Date_From_Seconds_1970 (const int32u Value)
+{
+ time_t Time=(time_t)Value;
+ struct tm *Gmt=gmtime(&Time);
+ Ztring DateT;
+ Ztring Date=_T("UTC ");
+ Date+=Ztring::ToZtring((Gmt->tm_year+1900));
+ Date+=_T("-");
+ DateT.From_Number(Gmt->tm_mon+1); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Gmt->tm_mon+1);}
+ Date+=DateT;
+ Date+=_T("-");
+ DateT.From_Number(Gmt->tm_mday); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Gmt->tm_mday);}
+ Date+=DateT;
+ Date+=_T(" ");
+ DateT.From_Number(Gmt->tm_hour); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Gmt->tm_hour);}
+ Date+=DateT;
+ Date+=_T(":");
+ DateT=Ztring::ToZtring(Gmt->tm_min); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Gmt->tm_min);}
+ Date+=DateT;
+ Date+=_T(":");
+ DateT.From_Number(Gmt->tm_sec); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Gmt->tm_sec);}
+ Date+=DateT;
+ assign (Date.c_str());
+ return *this;
+}
+
+Ztring& Ztring::Date_From_Seconds_1970_Local (const int32u Value)
+{
+ time_t Time=(time_t)Value;
+ struct tm *Gmt=localtime(&Time);
+ Ztring DateT;
+ Ztring Date;
+ Date+=Ztring::ToZtring((Gmt->tm_year+1900));
+ Date+=_T("-");
+ DateT.From_Number(Gmt->tm_mon+1); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Gmt->tm_mon+1);}
+ Date+=DateT;
+ Date+=_T("-");
+ DateT.From_Number(Gmt->tm_mday); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Gmt->tm_mday);}
+ Date+=DateT;
+ Date+=_T(" ");
+ DateT.From_Number(Gmt->tm_hour); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Gmt->tm_hour);}
+ Date+=DateT;
+ Date+=_T(":");
+ DateT=Ztring::ToZtring(Gmt->tm_min); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Gmt->tm_min);}
+ Date+=DateT;
+ Date+=_T(":");
+ DateT.From_Number(Gmt->tm_sec); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Gmt->tm_sec);}
+ Date+=DateT;
+ assign (Date.c_str());
+ return *this;
+}
+
+Ztring& Ztring::Date_From_String (const char* Value, size_t Value_Size)
+{
+ //Only the year
+ if (Value_Size<10)
+ {
+ From_Local(Value, 0, Value_Size);
+ return *this;
+ }
+
+ #ifdef ZENLIB_USEWX
+ Ztring ToReturn=_T("UTC ");
+ wxDateTime Date;
+ Ztring DateS;
+ DateS.From_Local(Value, Value_Size).c_str();
+ if (!DateS.empty() && DateS[DateS.size()-1]==_T('\n'))
+ DateS.resize(DateS.size()-1);
+
+ //Some strange formating : exactly 24 bytes (or 25 with 0x0A at the end) and Year is at the end
+ if (DateS.size()==24 && DateS[23]>=_T('0') && DateS[23]<=_T('9') && DateS[21]>=_T('0') && DateS[21]<=_T('9') && DateS[19]==_T(' '))
+ Date.ParseFormat(DateS.c_str(), _T("%a %b %d %H:%M:%S %Y"));
+ //ISO date
+ else if (DateS.size()==10 && (DateS[4]<_T('0') || DateS[4]>_T('9')) && (DateS[7]<_T('0') || DateS[7]>_T('9')))
+ {
+ DateS[4]=_T('-');
+ DateS[7]=_T('-');
+ ToReturn+=DateS;
+ }
+ //Default
+ else
+ Date.ParseDateTime(DateS.c_str());
+
+ if (ToReturn.size()<5)
+ {
+ ToReturn+=Date.FormatISODate();
+ ToReturn+=_T(" ");
+ ToReturn+=Date.FormatISOTime();
+ }
+ else if (ToReturn.size()<5)
+ ToReturn+=DateS;
+
+ assign (ToReturn.c_str());
+ #else //ZENLIB_USEWX
+ Ztring DateS; DateS.From_Local(Value, 0, Value_Size);
+ //Unix style formating : exactly 24 bytes (or 25 with 0x0A at the end) and Year is at the end
+ if ((DateS.size()==24 || (DateS.size()==25 && DateS[24]==_T('\n'))) && DateS[23]>=_T('0') && DateS[23]<=_T('9') && DateS[21]>=_T('0') && DateS[21]<=_T('9') && DateS[19]==_T(' '))
+ {
+ clear();
+ append(1, DateS[20]);
+ append(1, DateS[21]);
+ append(1, DateS[22]);
+ append(1, DateS[23]);
+ append(1, _T('-'));
+ if (DateS[4]==_T('J') && DateS[5]==_T('a') && DateS[6]==_T('n') && DateS[7]==_T(' '))
+ {
+ append(1, _T('0'));
+ append(1, _T('1'));
+ }
+ else if (DateS[4]==_T('F') && DateS[5]==_T('e') && DateS[6]==_T('b') && DateS[7]==_T(' '))
+ {
+ append(1, _T('0'));
+ append(1, _T('2'));
+ }
+ else if (DateS[4]==_T('M') && DateS[5]==_T('a') && DateS[6]==_T('r') && DateS[7]==_T(' '))
+ {
+ append(1, _T('0'));
+ append(1, _T('3'));
+ }
+ else if (DateS[4]==_T('A') && DateS[5]==_T('p') && DateS[6]==_T('r') && DateS[7]==_T(' '))
+ {
+ append(1, _T('0'));
+ append(1, _T('4'));
+ }
+ else if (DateS[4]==_T('M') && DateS[5]==_T('a') && DateS[6]==_T('y') && DateS[7]==_T(' '))
+ {
+ append(1, _T('0'));
+ append(1, _T('5'));
+ }
+ else if (DateS[4]==_T('J') && DateS[5]==_T('u') && DateS[6]==_T('n') && DateS[7]==_T(' '))
+ {
+ append(1, _T('0'));
+ append(1, _T('6'));
+ }
+ else if (DateS[4]==_T('J') && DateS[5]==_T('u') && DateS[6]==_T('l') && DateS[7]==_T(' '))
+ {
+ append(1, _T('0'));
+ append(1, _T('7'));
+ }
+ else if (DateS[4]==_T('A') && DateS[5]==_T('u') && DateS[6]==_T('g') && DateS[7]==_T(' '))
+ {
+ append(1, _T('0'));
+ append(1, _T('8'));
+ }
+ else if (DateS[4]==_T('S') && DateS[5]==_T('e') && DateS[6]==_T('p') && DateS[7]==_T(' '))
+ {
+ append(1, _T('0'));
+ append(1, _T('9'));
+ }
+ else if (DateS[4]==_T('O') && DateS[5]==_T('c') && DateS[6]==_T('t') && DateS[7]==_T(' '))
+ {
+ append(1, _T('1'));
+ append(1, _T('0'));
+ }
+ else if (DateS[4]==_T('N') && DateS[5]==_T('o') && DateS[6]==_T('v') && DateS[7]==_T(' '))
+ {
+ append(1, _T('1'));
+ append(1, _T('1'));
+ }
+ else if (DateS[4]==_T('D') && DateS[5]==_T('e') && DateS[6]==_T('c') && DateS[7]==_T(' '))
+ {
+ append(1, _T('1'));
+ append(1, _T('2'));
+ }
+ else
+ {
+ assign(DateS);
+ return *this;
+ }
+ append(1, _T('-'));
+ append(1, DateS[8]);
+ append(1, DateS[9]);
+ append(1, _T(' '));
+ append(1, DateS[11]);
+ append(1, DateS[12]);
+ append(1, _T(':'));
+ append(1, DateS[14]);
+ append(1, DateS[15]);
+ append(1, _T(':'));
+ append(1, DateS[17]);
+ append(1, DateS[18]);
+ }
+ else if (DateS.size()==20 && DateS[4]==_T('-') && DateS[7]==_T('-') && DateS[10]==_T('T') && DateS[13]==_T(':') && DateS[16]==_T(':') && DateS[19]==_T('Z'))
+ {
+ DateS.resize(19);
+ DateS[10]=_T(' ');
+ assign(_T("UTC "));
+ append(DateS);
+ }
+ else if (DateS.size()==23 && DateS[4]==_T('-') && DateS[7]==_T('-') && DateS[10]==_T(' ') && DateS[14]==_T(' ') && DateS[17]==_T(':') && DateS[20]==_T(':'))
+ {
+ DateS.erase(10, 4);
+ //assign(_T("UTC ")); //Is not UTC
+ append(DateS);
+ }
+ else
+ From_Local(Value, 0, Value_Size); //Not implemented
+ #endif //ZENLIB_USEWX
+ return *this;
+}
+
+Ztring& Ztring::Date_From_Numbers (const int8u Year, const int8u Month, const int8u Day, const int8u Hour, const int8u Minute, const int8u Second)
+{
+ Ztring DateT;
+ Ztring Date=_T("UTC ");
+ DateT.From_Number(Year); if (DateT.size()<2){DateT=Ztring(_T("200"))+Ztring::ToZtring(Year);}; if (DateT.size()<3){DateT=Ztring(_T("20"))+Ztring::ToZtring(Year);}
+ Date+=DateT;
+ Date+=_T("-");
+ DateT.From_Number(Month); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Month);}
+ Date+=DateT;
+ Date+=_T("-");
+ DateT.From_Number(Day); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Day);}
+ Date+=DateT;
+ Date+=_T(" ");
+ DateT.From_Number(Hour); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Hour);}
+ Date+=DateT;
+ Date+=_T(":");
+ DateT=Ztring::ToZtring(Minute); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Minute);}
+ Date+=DateT;
+ Date+=_T(":");
+ DateT.From_Number(Second); if (DateT.size()<2){DateT=Ztring(_T("0"))+Ztring::ToZtring(Second);}
+ Date+=DateT;
+ assign (Date.c_str());
+ return *this;
+}
+
+#ifndef WSTRING_MISSING
+//---------------------------------------------------------------------------
+std::wstring Ztring::To_Unicode () const
+{
+ #ifdef _UNICODE
+ return c_str();
+ #else //_UNICODE
+ #ifdef ZENLIB_USEWX
+ return wxConvCurrent->cMB2WC(c_str()).data();
+ #else //ZENLIB_USEWX
+ return std::wstring(); //Not implemented
+ #endif //ZENLIB_USEWX
+ #endif //_UNICODE
+}
+#endif //WSTRING_MISSING
+
+std::string Ztring::To_UTF8 () const
+{
+ #ifdef _UNICODE
+ //Correction thanks to Andrew Jang
+ // Don't use WideCharToMultiByte(), some characters are not well converted
+ std::string ToReturn;
+ ToReturn.reserve(size()); // more efficient
+
+ const wchar_t* Z=c_str();
+
+ while (*Z)
+ {
+ int32u wc; // must be unsigned.
+
+ #if defined(_MSC_VER)
+ #pragma warning(disable:4127)
+ #endif //defined(__VISUALC__)
+ if (sizeof(wchar_t) == 2)
+ #if defined(_MSC_VER)
+ #pragma warning(default:4127)
+ #endif //defined(__VISUALC__)
+ wc = (int16u) *Z; // avoid a cast problem if wchar_t is signed.
+ else
+ wc = *Z;
+
+ int count;
+
+ // refer to http://en.wikipedia.org/wiki/UTF-8#Description
+
+ if (wc < 0x80)
+ count = 1;
+ else if (wc < 0x800)
+ count = 2;
+ else if (wc < 0x10000)
+ count = 3;
+ else if (wc < 0x200000)
+ count = 4;
+ else if (wc < 0x4000000)
+ count = 5;
+ else if (wc <= 0x7fffffff)
+ count = 6;
+ else
+ break; // bad character
+
+ int64u utfbuf = 0; // 8 bytes
+ char* utf8chars = (char*) &utfbuf;
+
+ switch (count)
+ {
+ case 6:
+ utf8chars[5] = 0x80 | (wc & 0x3f);
+ wc = (wc >> 6) | 0x4000000;
+ case 5:
+ utf8chars[4] = 0x80 | (wc & 0x3f);
+ wc = (wc >> 6) | 0x200000;
+ case 4:
+ utf8chars[3] = 0x80 | (wc & 0x3f);
+ wc = (wc >> 6) | 0x10000;
+ case 3:
+ utf8chars[2] = 0x80 | (wc & 0x3f);
+ wc = (wc >> 6) | 0x800;
+ case 2:
+ utf8chars[1] = 0x80 | (wc & 0x3f);
+ wc = (wc >> 6) | 0xc0;
+ case 1:
+ utf8chars[0] = (char) wc;
+ }
+
+ ToReturn += utf8chars;
+
+ ++Z;
+ }
+
+ return ToReturn;
+ #else
+ #ifdef ZENLIB_USEWX
+ return wxConvUTF8.cWC2MB(wxConvCurrent->cMB2WC(c_str())).data();
+ #else //ZENLIB_USEWX
+ return c_str(); //Not implemented
+ #endif //ZENLIB_USEWX
+ #endif
+}
+
+std::string Ztring::To_Local () const
+{
+ #ifdef _UNICODE
+ #ifdef ZENLIB_USEWX
+ wxCharBuffer C=wxConvCurrent->cWC2MB(c_str());
+ if (C.data())
+ return C.data();
+ else
+ return std::string();
+ #else //ZENLIB_USEWX
+ #ifdef WINDOWS
+ int Size=WideCharToMultiByte(CP_ACP, 0, c_str(), -1, NULL, 0, NULL, NULL);
+ if (Size!=0)
+ {
+ char* AnsiString=new char[Size+1];
+ WideCharToMultiByte(CP_ACP, 0, c_str(), -1, AnsiString, Size, NULL, NULL);
+ AnsiString[Size]='\0';
+ std::string ToReturn(AnsiString);
+ delete[] AnsiString; //AnsiString=NULL;
+ return ToReturn;
+ }
+ else
+ return std::string();
+ #else //WINDOWS
+ if (empty())
+ return std::string();
+
+ size_t Size=wcstombs(NULL, c_str(), 0);
+ if (Size!=0 && Size!=(size_t)-1)
+ {
+ char* AnsiString=new char[Size+1];
+ Size=wcstombs(AnsiString, c_str(), Size);
+ if (Size!=0 && Size!=(size_t)-1)
+ {
+ AnsiString[Size]='\0';
+ std::string ToReturn(AnsiString);
+ delete[] AnsiString; //AnsiString=NULL;
+ return ToReturn;
+ }
+
+ //Failed
+ delete[] AnsiString; //AnsiString=NULL;
+ }
+
+ //Trying with bad chars
+ char* Result=new char[MB_CUR_MAX];
+ std::string AnsiString;
+ for (size_t Pos=0; Pos<size(); Pos++)
+ {
+ int Result_Size=wctomb(Result, operator[](Pos));
+ if (Result_Size>=0)
+ AnsiString.append(Result, Result_Size);
+ else
+ AnsiString+='?';
+ }
+ delete[] Result; //Result=NULL;
+ return AnsiString;
+ #endif
+ #endif //ZENLIB_USEWX
+ #else
+ return c_str();
+ #endif
+}
+
+//---------------------------------------------------------------------------
+int128u Ztring::To_UUID () const
+{
+ if (size()!=36)
+ return 0;
+
+ Ztring Temp=*this;
+
+ for (size_t Pos=0; Pos<36; Pos++)
+ {
+ if ((Temp[Pos]< _T('0') || Temp[Pos]> _T('9'))
+ && (Temp[Pos]< _T('A') || Temp[Pos]> _T('F'))
+ && (Temp[Pos]< _T('a') || Temp[Pos]> _T('f')))
+ return 0;
+ if (Temp[Pos]>=_T('A') && Temp[Pos]<=_T('F'))
+ {
+ Temp[Pos]-=_T('A');
+ Temp[Pos]+=_T('9')+1;
+ }
+ if (Temp[Pos]>=_T('a') && Temp[Pos]<=_T('f'))
+ {
+ Temp[Pos]-=_T('a');
+ Temp[Pos]+=_T('9')+1;
+ }
+
+ switch(Pos)
+ {
+ case 7 :
+ case 12 :
+ case 17 :
+ case 22 :
+ if (at(Pos+1)!=_T('-'))
+ return 0;
+ Pos++; //Skipping dash in the test
+ }
+ }
+
+ int128u I;
+ I.hi=((int64u)((int8u)(Temp[ 0]-'0'))<<60)
+ | ((int64u)((int8u)(Temp[ 1]-'0'))<<56)
+ | ((int64u)((int8u)(Temp[ 2]-'0'))<<52)
+ | ((int64u)((int8u)(Temp[ 3]-'0'))<<48)
+ | ((int64u)((int8u)(Temp[ 4]-'0'))<<44)
+ | ((int64u)((int8u)(Temp[ 5]-'0'))<<40)
+ | ((int64u)((int8u)(Temp[ 6]-'0'))<<36)
+ | ((int64u)((int8u)(Temp[ 7]-'0'))<<32)
+ | ((int64u)((int8u)(Temp[ 9]-'0'))<<28)
+ | ((int64u)((int8u)(Temp[10]-'0'))<<24)
+ | ((int64u)((int8u)(Temp[11]-'0'))<<20)
+ | ((int64u)((int8u)(Temp[12]-'0'))<<16)
+ | ((int64u)((int8u)(Temp[14]-'0'))<<12)
+ | ((int64u)((int8u)(Temp[15]-'0'))<< 8)
+ | ((int64u)((int8u)(Temp[16]-'0'))<< 4)
+ | ((int64u)((int8u)(Temp[17]-'0')) );
+ I.lo=((int64u)((int8u)(Temp[19]-'0'))<<60)
+ | ((int64u)((int8u)(Temp[20]-'0'))<<56)
+ | ((int64u)((int8u)(Temp[21]-'0'))<<52)
+ | ((int64u)((int8u)(Temp[22]-'0'))<<48)
+ | ((int64u)((int8u)(Temp[24]-'0'))<<44)
+ | ((int64u)((int8u)(Temp[25]-'0'))<<40)
+ | ((int64u)((int8u)(Temp[26]-'0'))<<36)
+ | ((int64u)((int8u)(Temp[27]-'0'))<<32)
+ | ((int64u)((int8u)(Temp[28]-'0'))<<28)
+ | ((int64u)((int8u)(Temp[29]-'0'))<<24)
+ | ((int64u)((int8u)(Temp[30]-'0'))<<20)
+ | ((int64u)((int8u)(Temp[31]-'0'))<<16)
+ | ((int64u)((int8u)(Temp[32]-'0'))<<12)
+ | ((int64u)((int8u)(Temp[33]-'0'))<< 8)
+ | ((int64u)((int8u)(Temp[34]-'0'))<< 4)
+ | ((int64u)((int8u)(Temp[35]-'0')) );
+
+ return I;
+}
+
+//---------------------------------------------------------------------------
+int32u Ztring::To_CC4 () const
+{
+ int32u I;
+ I =((int32u)((int8u)at(0))<<24)
+ | ((int32u)((int8u)at(1))<<16)
+ | ((int32u)((int8u)at(2))<< 8)
+ | ((int32u)((int8u)at(3)) );
+
+ return I;
+}
+
+//---------------------------------------------------------------------------
+//Operateur ToInt
+int8s Ztring::To_int8s (int8u Radix, ztring_t Options) const
+{
+ //Integrity
+ if (empty())
+ return 0;
+
+ //Conversion
+ int I;
+ #if defined(STREAM_MISSING)
+ #ifdef __MINGW32__
+ I=_ttoi(c_str());
+ #elif defined(UNICODE)
+ std::string S=To_UTF8();
+ I=atoi(S.c_str());
+ #else //UNICODE
+ I=atoi(c_str());
+ #endif //UNICODE
+ #else
+ tStringStream SS(*this);
+ SS >> setbase(Radix) >> I;
+ if (SS.fail())
+ return 0;
+ #endif
+
+ //Rounded
+ if (Options==Ztring_Rounded && find(_T("."))!=Error)
+ {
+ float80 F=To_float80();
+ F-=I;
+ if (F>=0.5)
+ return (int8s)I+1;
+ }
+
+ return (int8s)I;
+}
+
+//---------------------------------------------------------------------------
+//Operateur ToInt
+int8u Ztring::To_int8u (int8u Radix, ztring_t Options) const
+{
+ //Integrity
+ if (empty())
+ return 0;
+
+ //Conversion
+ unsigned int I;
+ #if defined(STREAM_MISSING)
+ #ifdef __MINGW32__
+ I=_ttoi64(c_str()); //TODO : I>0x7FFFFFFF - Replaced by i64 version to support, but not good
+ #elif defined(UNICODE)
+ std::string S=To_UTF8();
+ I=atoi(S.c_str());
+ #else //defined(UNICODE)
+ I=atoi(c_str());
+ #endif //defined(UNICODE)
+ #else
+ tStringStream SS(*this);
+ SS >> setbase(Radix) >> I;
+ if (SS.fail())
+ return 0;
+ #endif
+
+ //Rounded
+ if (Options==Ztring_Rounded && find(_T("."))!=std::string::npos)
+ {
+ float32 F=To_float32();
+ F-=I;
+ if (F>=0.5)
+ return (int8u)I+1;
+ }
+
+ return (int8u)I;
+}
+
+//---------------------------------------------------------------------------
+//Operateur ToInt
+int16s Ztring::To_int16s (int8u Radix, ztring_t Options) const
+{
+ //Integrity
+ if (empty())
+ return 0;
+
+ //Conversion
+ int I;
+ #if defined(STREAM_MISSING)
+ #ifdef __MINGW32__
+ I=_ttoi(c_str());
+ #elif defined(UNICODE)
+ std::string S=To_UTF8();
+ I=atoi(S.c_str());
+ #else //defined(UNICODE)
+ I=atoi(c_str());
+ #endif //defined(UNICODE)
+ #else
+ tStringStream SS(*this);
+ SS >> setbase(Radix) >> I;
+ if (SS.fail())
+ return 0;
+ #endif
+
+ //Rounded
+ if (Options==Ztring_Rounded && find(_T("."))!=Error)
+ {
+ float80 F=To_float80();
+ F-=I;
+ if (F>=0.5)
+ return (int16s)I+1;
+ }
+
+ return (int16s)I;
+}
+
+//---------------------------------------------------------------------------
+//Operateur ToInt
+int16u Ztring::To_int16u (int8u Radix, ztring_t Options) const
+{
+ //Integrity
+ if (empty())
+ return 0;
+
+ //Conversion
+ unsigned int I;
+ #if defined(STREAM_MISSING)
+ #ifdef __MINGW32__
+ I=_ttoi64(c_str()); //TODO : I>0x7FFFFFFF - Replaced by i64 version to support, but not good
+ #elif defined(UNICODE)
+ std::string S=To_UTF8();
+ I=atoi(S.c_str());
+ #else //defined(UNICODE)
+ I=atoi(c_str());
+ #endif //defined(UNICODE)
+ #else
+ tStringStream SS(*this);
+ SS >> setbase(Radix) >> I;
+ if (SS.fail())
+ return 0;
+ #endif
+
+ //Rounded
+ if (Options==Ztring_Rounded && find(_T("."))!=std::string::npos)
+ {
+ float32 F=To_float32();
+ F-=I;
+ if (F>=0.5)
+ return (int16u)I+1;
+ }
+
+ return (int16u)I;
+}
+
+//---------------------------------------------------------------------------
+//Operateur ToInt
+int32s Ztring::To_int32s (int8u Radix, ztring_t Options) const
+{
+ //Integrity
+ if (empty())
+ return 0;
+
+ //Conversion
+ int32s I;
+ #if defined(STREAM_MISSING)
+ #ifdef __MINGW32__
+ I=_ttoi(c_str());
+ #elif defined(UNICODE)
+ std::string S=To_UTF8();
+ I=atol(S.c_str());
+ #else //defined(UNICODE)
+ I=atol(c_str());
+ #endif //defined(UNICODE)
+ #else
+ tStringStream SS(*this);
+ SS >> setbase(Radix) >> I;
+ if (SS.fail())
+ return 0;
+ #endif
+
+ //Rounded
+ if (Options==Ztring_Rounded && find(_T("."))!=Error)
+ {
+ float80 F=To_float80();
+ F-=I;
+ if (F>=0.5)
+ return I+1;
+ }
+
+ return I;
+}
+
+//---------------------------------------------------------------------------
+//Operateur ToInt
+int32u Ztring::To_int32u (int8u Radix, ztring_t Options) const
+{
+ //Integrity
+ if (empty())
+ return 0;
+
+ //Conversion
+ int32u I;
+ #if defined(STREAM_MISSING)
+ #ifdef __MINGW32__
+ I=_ttoi64(c_str()); //TODO : I>0x7FFFFFFF - Replaced by i64 version to support, but not good
+ #elif defined(UNICODE)
+ std::string S=To_UTF8();
+ I=atol(S.c_str());
+ #else //defined(UNICODE)
+ I=atol(c_str());
+ #endif //defined(UNICODE)
+ #else
+ tStringStream SS(*this);
+ SS >> setbase(Radix) >> I;
+ if (SS.fail())
+ return 0;
+ #endif
+
+ //Rounded
+ if (Options==Ztring_Rounded && find(_T("."))!=std::string::npos)
+ {
+ float32 F=To_float32();
+ F-=I;
+ if (F>=0.5)
+ return I+1;
+ }
+
+ return I;
+}
+
+//---------------------------------------------------------------------------
+//Operateur ToInt
+int64s Ztring::To_int64s (int8u Radix, ztring_t Options) const
+{
+ //Integrity
+ if (empty())
+ return 0;
+
+ //Conversion
+ int64s I;
+ #if defined(STREAM_MISSING)
+ #ifdef __MINGW32__
+ I=_ttoi64(c_str());
+ #elif defined(UNICODE)
+ std::string S=To_UTF8();
+ I=atoll(S.c_str());
+ #else //defined(UNICODE)
+ I=atoll(c_str());
+ #endif //defined(UNICODE)
+ #else
+ tStringStream SS(*this);
+ SS >> setbase(Radix) >> I;
+ if (SS.fail())
+ return 0;
+ #endif
+
+ //Rounded
+ if (Options==Ztring_Rounded && find(_T("."))!=std::string::npos)
+ {
+ float32 F=To_float32();
+ F-=I;
+ if (F>0.5)
+ return I+1;
+ }
+
+ return I;
+}
+
+//---------------------------------------------------------------------------
+//Operateur ToInt
+int64u Ztring::To_int64u (int8u Radix, ztring_t Options) const
+{
+ //Integrity
+ if (empty())
+ return 0;
+
+ //Conversion
+ int64u I;
+ #if defined(STREAM_MISSING)
+ #ifdef __MINGW32__
+ I=_ttoi64(c_str()); //TODO : I>0x7FFFFFFFFFFFFFFF
+ #elif defined(UNICODE)
+ std::string S=To_UTF8();
+ I=atoll(S.c_str());
+ #else //defined(UNICODE)
+ I=atoll(c_str());
+ #endif //defined(UNICODE)
+ #else
+ tStringStream SS(*this);
+ SS >> setbase(Radix) >> I;
+ if (SS.fail())
+ return 0;
+ #endif
+
+ //Rounded
+ if (Options==Ztring_Rounded && find(_T("."))!=std::string::npos)
+ {
+ float32 F=To_float32();
+ F-=I;
+ if (F>=0.5)
+ return I+1;
+ }
+
+ return I;
+}
+
+//---------------------------------------------------------------------------
+int128u Ztring::To_int128u (int8u, ztring_t) const
+{
+ if (size()!=32)
+ return 0;
+
+ Ztring Temp=*this;
+
+ for (size_t Pos=0; Pos<32; Pos++)
+ {
+ if ((Temp[Pos]< _T('0') || Temp[Pos]> _T('9'))
+ && (Temp[Pos]< _T('A') || Temp[Pos]> _T('F'))
+ && (Temp[Pos]< _T('a') || Temp[Pos]> _T('f')))
+ return 0;
+ if (Temp[Pos]>=_T('A') && Temp[Pos]<=_T('F'))
+ {
+ Temp[Pos]-=_T('A');
+ Temp[Pos]+=_T('9')+1;
+ }
+ if (Temp[Pos]>=_T('a') && Temp[Pos]<=_T('f'))
+ {
+ Temp[Pos]-=_T('a');
+ Temp[Pos]+=_T('9')+1;
+ }
+ }
+
+ int128u I;
+ I.hi=((int64u)((int8u)(Temp[ 0]-'0'))<<60)
+ | ((int64u)((int8u)(Temp[ 1]-'0'))<<56)
+ | ((int64u)((int8u)(Temp[ 2]-'0'))<<52)
+ | ((int64u)((int8u)(Temp[ 3]-'0'))<<48)
+ | ((int64u)((int8u)(Temp[ 4]-'0'))<<44)
+ | ((int64u)((int8u)(Temp[ 5]-'0'))<<40)
+ | ((int64u)((int8u)(Temp[ 6]-'0'))<<36)
+ | ((int64u)((int8u)(Temp[ 7]-'0'))<<32)
+ | ((int64u)((int8u)(Temp[ 8]-'0'))<<28)
+ | ((int64u)((int8u)(Temp[ 9]-'0'))<<24)
+ | ((int64u)((int8u)(Temp[10]-'0'))<<20)
+ | ((int64u)((int8u)(Temp[11]-'0'))<<16)
+ | ((int64u)((int8u)(Temp[12]-'0'))<<12)
+ | ((int64u)((int8u)(Temp[13]-'0'))<< 8)
+ | ((int64u)((int8u)(Temp[14]-'0'))<< 4)
+ | ((int64u)((int8u)(Temp[15]-'0')) );
+ I.lo=((int64u)((int8u)(Temp[16]-'0'))<<60)
+ | ((int64u)((int8u)(Temp[17]-'0'))<<56)
+ | ((int64u)((int8u)(Temp[18]-'0'))<<52)
+ | ((int64u)((int8u)(Temp[19]-'0'))<<48)
+ | ((int64u)((int8u)(Temp[20]-'0'))<<44)
+ | ((int64u)((int8u)(Temp[21]-'0'))<<40)
+ | ((int64u)((int8u)(Temp[22]-'0'))<<36)
+ | ((int64u)((int8u)(Temp[23]-'0'))<<32)
+ | ((int64u)((int8u)(Temp[24]-'0'))<<28)
+ | ((int64u)((int8u)(Temp[25]-'0'))<<24)
+ | ((int64u)((int8u)(Temp[26]-'0'))<<20)
+ | ((int64u)((int8u)(Temp[27]-'0'))<<16)
+ | ((int64u)((int8u)(Temp[28]-'0'))<<12)
+ | ((int64u)((int8u)(Temp[29]-'0'))<< 8)
+ | ((int64u)((int8u)(Temp[30]-'0'))<< 4)
+ | ((int64u)((int8u)(Temp[31]-'0')) );
+
+ return I;
+}
+
+//---------------------------------------------------------------------------
+//Operateur ToFloat
+float32 Ztring::To_float32(ztring_t) const
+{
+ //Integrity
+ if (empty())
+ return 0;
+
+ //Conversion
+ #if defined(STREAM_MISSING)
+ #ifdef UNICODE
+ return (wcstod(c_str(),NULL));
+ #else
+ return (strtod(c_str(),NULL));
+ #endif
+ #else
+ float32 F;
+ tStringStream SS(*this);
+ SS >> F;
+ if (SS.fail())
+ return 0;
+
+ return F;
+ #endif
+}
+
+//---------------------------------------------------------------------------
+//Operateur ToFloat
+float64 Ztring::To_float64(ztring_t) const
+{
+ //Integrity
+ if (empty())
+ return 0;
+
+ //Conversion
+ #if defined(STREAM_MISSING)
+ #ifdef UNICODE
+ return (wcstod(c_str(),NULL)); //TODO verify no wcstold
+ #else
+ return (strtod(c_str(),NULL)); //TODO verify no strtold
+ #endif
+ #else
+ float64 F;
+ tStringStream SS(*this);
+ SS >> F;
+ if (SS.fail())
+ return 0;
+
+ return F;
+ #endif
+}
+
+//---------------------------------------------------------------------------
+//Operateur ToFloat
+float80 Ztring::To_float80(ztring_t) const
+{
+ //Integrity
+ if (empty())
+ return 0;
+
+ //Conversion
+ #if defined(STREAM_MISSING)
+ #ifdef UNICODE
+ return (wcstod(c_str(),NULL)); //TODO verify no wcstold
+ #else
+ return (strtod(c_str(),NULL)); //TODO verify no strtold
+ #endif
+ #else
+ float80 F;
+ tStringStream SS(*this);
+ SS >> F;
+ if (SS.fail())
+ return 0;
+
+ return F;
+ #endif
+}
+
+//***************************************************************************
+// Edition
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Retourne une partie de la chaine
+Ztring Ztring::SubString (const tstring &Begin, const tstring &End, size_type Pos, ztring_t Options) const
+{
+ //Recherche Début
+ size_type I_Debut=find(Begin, Pos);
+ if (I_Debut==Error)
+ return Ztring();
+ I_Debut+=Begin.size();
+
+ //gestion fin NULL
+ if (End.empty())
+ return substr(I_Debut);
+
+ //Recherche Fin
+ size_type I_Fin=find(End, I_Debut);
+ if (I_Fin==Error)
+ {
+ if (Options & Ztring_AddLastItem)
+ return substr(I_Debut);
+ else
+ return Ztring();
+ }
+
+ return substr(I_Debut, I_Fin-I_Debut);
+}
+
+//---------------------------------------------------------------------------
+//FindAndReplace
+Ztring::size_type Ztring::FindAndReplace (const ZenLib::tstring &ToFind, const ZenLib::tstring &ReplaceBy, size_type Pos, ZenLib::ztring_t Options)
+{
+ if (ToFind.empty())
+ return 0;
+
+ size_type Count=0;
+ size_type Middle=Pos;
+ while (!(Count==1 && !(Options&Ztring_Recursive)) && (Middle=find(ToFind, Middle))!=npos)
+ {
+ replace(Middle, ToFind.length(), ReplaceBy);
+ Middle += ReplaceBy.length();
+ Count++;
+ }
+
+ return Count;
+}
+
+//---------------------------------------------------------------------------
+//test if it is a number
+bool Ztring::IsNumber() const
+{
+ if (empty())
+ return false;
+
+ bool OK=true;
+ size_t Size=size();
+ for (size_t Pos=0; Pos<Size; Pos++)
+ if (operator[](Pos)<_T('0') || operator[](Pos)>_T('9'))
+ {
+ OK=false;
+ break;
+ }
+ return OK;
+}
+
+//---------------------------------------------------------------------------
+//Mise en minuscules
+Ztring &Ztring::MakeLowerCase()
+{
+ transform(begin(), end(), begin(), (int(*)(int))tolower); //(int(*)(int)) is a patch for unix
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+// Mise en majuscules
+Ztring &Ztring::MakeUpperCase()
+{
+ transform(begin(), end(), begin(), (int(*)(int))toupper); //(int(*)(int)) is a patch for unix
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+// Remove leading whitespaces from a string
+Ztring &Ztring::TrimLeft(Char ToTrim)
+{
+ size_type First=0;
+ while (First<size() && operator[](First)==ToTrim)
+ First++;
+ assign (c_str()+First);
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+// Remove trailing whitespaces from a string
+Ztring &Ztring::TrimRight(Char ToTrim)
+{
+ if (size()==0)
+ return *this;
+
+ size_type Last=size()-1;
+ while (Last!=(size_type)-1 && operator[](Last)==ToTrim)
+ Last--;
+ assign (c_str(), Last+1);
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+// Remove leading and trailing whitespaces from a string
+Ztring &Ztring::Trim(Char ToTrim)
+{
+ TrimLeft(ToTrim);
+ TrimRight(ToTrim);
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+// Quotes a string
+Ztring &Ztring::Quote(Char ToTrim)
+{
+ assign(tstring(1, ToTrim)+c_str()+ToTrim);
+ return *this;
+}
+
+//***************************************************************************
+// Information
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Count
+Ztring::size_type Ztring::Count (const Ztring &ToCount, ztring_t) const
+{
+ size_type Count=0;
+ for (size_type Pos=0; Pos<=size(); Pos++)
+ if (find(ToCount, Pos)!=npos)
+ {
+ Count++;
+ Pos+=ToCount.size()-1; //-1 because the loop will add 1
+ }
+ return Count;
+}
+
+//---------------------------------------------------------------------------
+//Compare
+bool Ztring::Compare (const Ztring &ToCompare, const Ztring &Comparator, ztring_t Options) const
+{
+ //Integers management
+ if (IsNumber() && ToCompare.IsNumber())
+ {
+ int64s Left=To_int64s();
+ int64s Right=ToCompare.To_int64s();
+ if (Comparator==_T("==")) return (Left==Right);
+ if (Comparator==_T("<")) return (Left< Right);
+ if (Comparator==_T("<=")) return (Left<=Right);
+ if (Comparator==_T(">=")) return (Left>=Right);
+ if (Comparator==_T(">")) return (Left> Right);
+ if (Comparator==_T("!=")) return (Left!=Right);
+ if (Comparator==_T("<>")) return (Left!=Right);
+ return false;
+ }
+
+ //Case sensitive option
+ if (!(Options & Ztring_CaseSensitive))
+ {
+ //Need to copy strings and make it lowercase
+ Ztring Left (c_str());
+ Ztring Right (ToCompare.c_str());
+ Left.MakeLowerCase();
+ Right.MakeLowerCase();
+
+ //string comparasion
+ if (Comparator==_T("==")) return (Left==Right);
+ if (Comparator==_T("IN")) {if (Left.find(Right)!=string::npos) return true; else return false;}
+ if (Comparator==_T("<")) return (Left< Right);
+ if (Comparator==_T("<=")) return (Left<=Right);
+ if (Comparator==_T(">=")) return (Left>=Right);
+ if (Comparator==_T(">")) return (Left> Right);
+ if (Comparator==_T("!=")) return (Left!=Right);
+ if (Comparator==_T("<>")) return (Left!=Right);
+ return false;
+ }
+ else
+ {
+ //string comparasion
+ if (Comparator==_T("==")) return (*this==ToCompare);
+ if (Comparator==_T("IN")) {if (this->find(ToCompare)!=string::npos) return true; else return false;}
+ if (Comparator==_T("<")) return (*this< ToCompare);
+ if (Comparator==_T("<=")) return (*this<=ToCompare);
+ if (Comparator==_T(">=")) return (*this>=ToCompare);
+ if (Comparator==_T(">")) return (*this> ToCompare);
+ if (Comparator==_T("!=")) return (*this!=ToCompare);
+ if (Comparator==_T("<>")) return (*this!=ToCompare);
+ return false;
+ }
+}
+
+} //namespace
+
diff --git a/src/thirdparty/ZenLib/ZenLib/Ztring.h b/src/thirdparty/ZenLib/ZenLib/Ztring.h
new file mode 100644
index 000000000..c366ae6f7
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/Ztring.h
@@ -0,0 +1,372 @@
+// ZenLib::Ztring - More methods for std::(w)string
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// More methods for std::(w)string
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_ZtringH
+#define ZenLib_ZtringH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf.h"
+#include "ZenLib/Utils.h"
+#include "ZenLib/int128u.h"
+#include <string>
+#include <sstream>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//---------------------------------------------------------------------------
+typedef std::basic_string<Char, std::char_traits<Char>, std::allocator<Char> > tstring;
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+/// @brief Options for Ztring methods
+enum ztring_t
+{
+ Ztring_Nothing,
+ Ztring_Rounded = 1, ///< if >.5, upper, else lower
+ Ztring_CaseSensitive = 2, ///< Case sensitive ("A" and "a" are different)
+ Ztring_AddLastItem = 4, ///< if Begin is found and End is not found, return between Begin and end of string
+ Ztring_Recursive = 8, ///< Do all strings
+ Ztring_NoZero =16 ///> Doesn't keep Zero in the float number
+};
+
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+/// @brief String manipulation (based on std::(w)string)
+//***************************************************************************
+
+class Ztring : public tstring //for details about undocumented methods see http://www.sgi.com/tech/stl/basic_string.html
+{
+public :
+ //Constructor/destructor
+ Ztring () : tstring(){};
+ Ztring (const tstring& str) : tstring(str){};
+ Ztring (const tstring& str, size_type pos, size_type n=npos) : tstring(str, pos, n){};
+ Ztring (const Char* s, size_type n) : tstring(s, n){};
+ Ztring (const Char* s) : tstring(s){};
+ Ztring (size_type n, Char c) : tstring(n, c){};
+ #ifdef UNICODE
+ Ztring (const char* S) : tstring(){From_UTF8(S);};
+ Ztring (const char* S, size_type n) : tstring(){From_UTF8(S, 0, n);};
+ #endif //UNICODE
+
+ //Operators
+ ///Same as [], but resize the string if Pos doesn't exist yet
+ Char &operator () (size_type Pos);
+
+ //Assign
+ bool Assign_FromFile (const Ztring &FileName);
+
+ //Conversions - From
+ #ifndef WSTRING_MISSING
+ /// @brief convert an Unicode encoded string into Ztring
+ Ztring& From_Unicode (const std::wstring &S) {return From_Unicode(S.c_str());};
+ #endif //WSTRING_MISSING
+ /// @brief convert an Unicode encoded string into Ztring
+ Ztring& From_Unicode (const wchar_t *S);
+ /// @brief convert an Unicode encoded string into Ztring
+ Ztring& From_Unicode (const wchar_t *S, size_type Start, size_type Length);
+ /// @brief convert an Unicode encoded string into Ztring
+ Ztring& From_Unicode (const wchar_t *S, size_type Length) {return From_Unicode(S, 0, Length);};
+ /// @brief convert an UTF-8 encoded string into Ztring
+ Ztring& From_UTF8 (const std::string &S) {return From_UTF8(S.c_str());};
+ /// @brief convert an UTF-8 encoded string into Ztring
+ Ztring& From_UTF8 (const char *S);
+ /// @brief convert an UTF-8 encoded string into Ztring
+ Ztring& From_UTF8 (const char *S, size_type Start, size_type Length);
+ /// @brief convert an UTF-8 encoded string into Ztring
+ Ztring& From_UTF8 (const char *S, size_type Length) {return From_UTF8(S, 0, Length);};
+ /// @brief convert an UTF-16 encoded string into Ztring
+ Ztring& From_UTF16 (const char *S);
+ /// @brief convert an UTF-16 encoded string into Ztring
+ Ztring& From_UTF16 (const char *S, size_type Start, size_type Length);
+ /// @brief convert an UTF-16 encoded string into Ztring
+ Ztring& From_UTF16 (const char *S, size_type Length) {return From_UTF16(S, 0, Length);};
+ /// @brief convert an UTF-16BE encoded string into Ztring
+ Ztring& From_UTF16BE (const char *S);
+ /// @brief convert an UTF-16BE encoded string into Ztring
+ Ztring& From_UTF16BE (const char *S, size_type Start, size_type Length);
+ /// @brief convert an UTF-16BE encoded string into Ztring
+ Ztring& From_UTF16BE (const char *S, size_type Length) {return From_UTF16BE(S, 0, Length);};
+ /// @brief convert an UTF-16LE encoded string into Ztring
+ Ztring& From_UTF16LE (const char *S);
+ /// @brief convert an UTF-16LE encoded string into Ztring
+ Ztring& From_UTF16LE (const char *S, size_type Start, size_type Length);
+ /// @brief convert an UTF-16LE encoded string into Ztring
+ Ztring& From_UTF16LE (const char *S, size_type Length) {return From_UTF16LE(S, 0, Length);};
+ /// @brief convert an Locael encoded string into Ztring
+ Ztring& From_Local (const std::string &S) {return From_Local(S.c_str());};
+ /// @brief convert an Local encoded string into Ztring
+ Ztring& From_Local (const char *S);
+ /// @brief convert an Local encoded string into Ztring
+ Ztring& From_Local (const char *S, size_type Start, size_type Length);
+ /// @brief convert an Local encoded string into Ztring
+ Ztring& From_Local (const char *S, size_type Length) {return From_Local(S, 0, Length);};
+
+ /// @brief convert an ISO-8859-1 encoded string into Ztring
+ Ztring& From_ISO_8859_1 (const char *S);
+ /// @brief convert an ISO-8859-1 encoded string into Ztring
+ Ztring& From_ISO_8859_1 (const char *S, size_type Start, size_type Length);
+ /// @brief convert an ISO-8859-1 encoded string into Ztring
+ Ztring& From_ISO_8859_1 (const char *S, size_type Length) {return From_ISO_8859_1(S, 0, Length);};
+
+ /// @brief convert an ISO-8859-2 encoded string into Ztring
+ Ztring& From_ISO_8859_2 (const char *S);
+ /// @brief convert an ISO-8859-1 encoded string into Ztring
+ Ztring& From_ISO_8859_2 (const char *S, size_type Start, size_type Length);
+ /// @brief convert an ISO-8859-1 encoded string into Ztring
+ Ztring& From_ISO_8859_2 (const char *S, size_type Length) {return From_ISO_8859_2(S, 0, Length);};
+
+ /// @brief convert an 16 byte GUID into Ztring
+ Ztring& From_GUID (const int128u S);
+ /// @brief convert an 16 byte UUID into Ztring
+ Ztring& From_UUID (const int128u S);
+ /// @brief convert an 4 Character Code into Ztring
+ Ztring& From_CC4 (const char *S) {return From_Local(S, 0, 4);};
+ /// @brief convert an 4 Character Code into Ztring
+ Ztring& From_CC4 (const int8u *S) {return From_Local((const char*)S, 0, 4);};
+ /// @brief convert an 4 Character Code into Ztring
+ Ztring& From_CC4 (const int32u S);
+ /// @brief convert an 2 Character Code into Ztring
+ Ztring& From_CC3 (const char *S) {return From_Local(S, 0, 3);};
+ /// @brief convert an 4 Character Code into Ztring
+ Ztring& From_CC3 (const int8u *S) {return From_Local((const char*)S, 0, 3);};
+ /// @brief convert an 4 Character Code into Ztring
+ Ztring& From_CC3 (const int32u S);
+ /// @brief convert an 2 Character Code into Ztring
+ Ztring& From_CC2 (const char *S) {return From_CC2(ZenLib::CC2(S));};
+ /// @brief convert an 2 Character Code into Ztring
+ Ztring& From_CC2 (const int8u *S) {return From_CC2(ZenLib::CC2(S));};
+ /// @brief convert an 2 Character Code into Ztring
+ Ztring& From_CC2 (const int16u S);
+ /// @brief convert an 1 Character Code into Ztring
+ Ztring& From_CC1 (const char *S) {return From_CC1(ZenLib::CC1(S));};
+ /// @brief convert an 1 Character Code into Ztring
+ Ztring& From_CC1 (const int8u *S) {return From_CC1(ZenLib::CC1(S));};
+ /// @brief convert an 1 Character Code into Ztring
+ Ztring& From_CC1 (const int8u S);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const int8s, int8u Radix=10);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const int8u, int8u Radix=10);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const int16s, int8u Radix=10);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const int16u, int8u Radix=10);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const int32s, int8u Radix=10);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const int32u, int8u Radix=10);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const int64s, int8u Radix=10);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const int64u, int8u Radix=10);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const int128u, int8u Radix=10);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const float32, int8u AfterComma=3, ztring_t Options=Ztring_Nothing);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const float64, int8u AfterComma=3, ztring_t Options=Ztring_Nothing);
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const float80, int8u AfterComma=3, ztring_t Options=Ztring_Nothing);
+ #ifdef SIZE_T_IS_LONG
+ /// @brief convert number into Ztring
+ Ztring& From_Number (const size_t, int8u Radix=10);
+ #endif //SIZE_T_IS_LONG
+ /// @brief convert number (BCD coded) into Ztring
+ Ztring& From_BCD (const int8u);
+ /// @brief convert count of milliseconds into a readable and sortable string
+ Ztring& Duration_From_Milliseconds (const int64s Milliseconds);
+ /// @deprecated replaced by the int64s version
+ Ztring& Duration_From_Milliseconds (const int64u Milliseconds);
+ /// @brief convert count of seconds since 1601 into a readable and sortable string
+ Ztring& Date_From_Milliseconds_1601 (const int64u Milliseconds);
+ /// @brief convert count of seconds since 1601 into a readable and sortable string
+ Ztring& Date_From_Seconds_1601 (const int64u Seconds);
+ /// @brief convert count of seconds since 1970 into a readable and sortable string
+ Ztring& Date_From_Seconds_1904 (const int64u Seconds);
+ /// @brief convert count of seconds since 1970 into a readable and sortable string
+ Ztring& Date_From_Seconds_1970 (const int32u Seconds);
+ /// @brief convert count of seconds since 1970 into a readable and sortable string (in local time)
+ Ztring& Date_From_Seconds_1970_Local (const int32u Seconds);
+ /// @brief convert a free formated string into a readable and sortable string
+ Ztring& Date_From_String (const char* Date, size_type Value_Size=Error);
+ /// @brief convert numbers into a readable and sortable string
+ Ztring& Date_From_Numbers (const int8u Year, const int8u Month, const int8u Day, const int8u Hour, const int8u Minute, const int8u Second);
+
+ //Conversions - To
+ #ifndef WSTRING_MISSING
+ /// @brief Convert into Unicode chars
+ /// @return the string corresponding \n
+ std::wstring To_Unicode () const;
+ #endif //WSTRING_MISSING
+ /// @brief Convert into char* (UTF-8 encoded)
+ /// @return the string corresponding \n
+ std::string To_UTF8 () const;
+ /// @brief Convert into char* (Local encoded)
+ /// @return the string corresponding \n
+ std::string To_Local () const;
+ /// @brief Convert into 16 byte UUID number
+ /// @return the value corresponding \n
+ /// 0 if there is a problem
+ int128u To_UUID () const;
+ /// @brief Convert into a 4 Character Code
+ /// @return the value corresponding \n
+ /// 0 if there is a problem
+ int32u To_CC4 () const;
+ /// @brief Convert into Int (8 bits)
+ /// @return the value corresponding \n
+ /// 0 if there is a problem
+ int8s To_int8s (int8u Radix=10, ztring_t Options=Ztring_Rounded) const;
+ /// @brief Convert into unsigned Int (8 bits)
+ /// @return the value corresponding
+ /// 0 if there is a problem
+ int8u To_int8u (int8u Radix=10, ztring_t Options=Ztring_Rounded) const;
+ /// @brief Convert into Int (16 bits)
+ /// @return the value corresponding \n
+ /// 0 if there is a problem
+ int16s To_int16s (int8u Radix=10, ztring_t Options=Ztring_Rounded) const;
+ /// @brief Convert into unsigned Int (16 bits)
+ /// @return the value corresponding
+ /// 0 if there is a problem
+ int16u To_int16u (int8u Radix=10, ztring_t Options=Ztring_Rounded) const;
+ /// @brief Convert into Int (32 bits)
+ /// @return the value corresponding \n
+ /// 0 if there is a problem
+ int32s To_int32s (int8u Radix=10, ztring_t Options=Ztring_Rounded) const;
+ /// @brief Convert into unsigned Int (32 bits)
+ /// @return the value corresponding
+ /// 0 if there is a problem
+ int32u To_int32u (int8u Radix=10, ztring_t Options=Ztring_Rounded) const;
+ /// @brief Convert into Int (64 bits)
+ /// @return the value corresponding \n
+ /// 0 if there is a problem
+ int64s To_int64s (int8u Radix=10, ztring_t Options=Ztring_Rounded) const;
+ /// @brief Convert into unsigned Int (64 bits)
+ /// @return the value corresponding \n
+ /// 0 if there is a problem
+ int64u To_int64u (int8u Radix=10, ztring_t Options=Ztring_Rounded) const;
+ /// @brief Convert into unsigned Int (64 bits)
+ /// @warning only hexadecimal and no rounding are currenlty supported \n
+ /// @return the value corresponding \n
+ /// 0 if there is a problem
+ int128u To_int128u (int8u Radix=10, ztring_t Options=Ztring_Rounded) const;
+ /// @brief Convert into float
+ /// @return the value corresponding \n
+ /// 0 if there is a problem
+ float32 To_float32 (ztring_t Options=Ztring_Nothing) const;
+ float64 To_float64 (ztring_t Options=Ztring_Nothing) const;
+ float80 To_float80 (ztring_t Options=Ztring_Nothing) const;
+
+ //Static versions
+ static Ztring ToZtring_From_Local(const std::string &S) {return Ztring().From_Local(S);};
+ static Ztring ToZtring_From_Local(const char *S) {return Ztring().From_Local(S);};
+ static Ztring ToZtring_From_Local(const char *S, size_type Start, size_type Length) {return Ztring().From_Local(S, Start, Length);};
+ static Ztring ToZtring_From_Local(const char *S, size_type Length) {return Ztring().From_Local(S, Length);};
+ static Ztring ToZtring_From_CC4 (const char *S) {return Ztring().From_CC4(S);};
+ static Ztring ToZtring_From_CC4 (const int8u *S) {return Ztring().From_CC4(S);};
+ static Ztring ToZtring_From_CC4 (const int32u S) {return Ztring().From_CC4(S);};
+ static Ztring ToZtring_From_CC3 (const char *S) {return Ztring().From_CC3(S);};
+ static Ztring ToZtring_From_CC3 (const int8u *S) {return Ztring().From_CC3(S);};
+ static Ztring ToZtring_From_CC3 (const int32u S) {return Ztring().From_CC3(S);};
+ static Ztring ToZtring_From_CC2 (const char *S) {return Ztring().From_CC2(S);};
+ static Ztring ToZtring_From_CC2 (const int8u *S) {return Ztring().From_CC2(S);};
+ static Ztring ToZtring_From_CC2 (const int16u S) {return Ztring().From_CC2(S);};
+ static Ztring ToZtring_From_CC1 (const char *S) {return Ztring().From_CC1(S);};
+ static Ztring ToZtring_From_CC1 (const int8u *S) {return Ztring().From_CC1(S);};
+ static Ztring ToZtring_From_CC1 (const int8u S) {return Ztring().From_CC1(S);};
+ static Ztring ToZtring (const int8s I, int8u Radix=10) {return Ztring().From_Number(I, Radix);};
+ static Ztring ToZtring (const int8u I, int8u Radix=10) {return Ztring().From_Number(I, Radix);};
+ static Ztring ToZtring (const int16s I, int8u Radix=10) {return Ztring().From_Number(I, Radix);};
+ static Ztring ToZtring (const int16u I, int8u Radix=10) {return Ztring().From_Number(I, Radix);};
+ static Ztring ToZtring (const int32s I, int8u Radix=10) {return Ztring().From_Number(I, Radix);};
+ static Ztring ToZtring (const int32u I, int8u Radix=10) {return Ztring().From_Number(I, Radix);};
+ static Ztring ToZtring (const int64s I, int8u Radix=10) {return Ztring().From_Number(I, Radix);};
+ static Ztring ToZtring (const int64u I, int8u Radix=10) {return Ztring().From_Number(I, Radix);};
+ static Ztring ToZtring (const int128u I, int8u Radix=10) {return Ztring().From_Number(I, Radix);};
+ static Ztring ToZtring (const float32 F, int8u AfterComma=3) {return Ztring().From_Number(F, AfterComma);};
+ static Ztring ToZtring (const float64 F, int8u AfterComma=3) {return Ztring().From_Number(F, AfterComma);};
+ static Ztring ToZtring (const float80 F, int8u AfterComma=3) {return Ztring().From_Number(F, AfterComma);};
+ #ifdef SIZE_T_IS_LONG
+ static Ztring ToZtring (const size_t I, int8u Radix=10) {return Ztring().From_Number(I, Radix);};
+ #endif //SIZE_T_IS_LONG
+
+ //Edition
+ /// @brief test if it is a number
+ bool IsNumber() const;
+ /// @brief convert into lowercase
+ Ztring &MakeLowerCase();
+ /// @brief convert into uppercase
+ Ztring &MakeUpperCase();
+ /// @brief Remove leading whitespaces from a string
+ Ztring &TrimLeft(Char ToTrim=_T(' '));
+ /// @brief Remove trailing whitespaces from a string
+ Ztring &TrimRight(Char ToTrim=_T(' '));
+ /// @brief Remove leading and trailing whitespaces from a string
+ Ztring &Trim(Char ToTrim=_T(' '));
+ /// @brief Quotes a string
+ Ztring &Quote(Char ToTrim=_T('\"'));
+ /// @brief return a string between two strings
+ /// @param Begin First string
+ /// @param End Second string
+ /// @param Pos Position to begin to scan string
+ /// @param Options Options for searching \n
+ /// Available : Ztring_CaseSensitive
+ /// @return The substring \n
+ /// "" if not found
+ Ztring SubString (const tstring &Begin, const tstring &End, size_type Pos=0, ztring_t Options=Ztring_Nothing) const;
+ /// @brief replace a string by another one
+ /// @param ToFind string to find
+ /// @param ToReplace string wich replace the string found
+ /// @param Pos Position to begin to scan string
+ /// @param Options Options for searching \n
+ /// Available : Ztring_CaseSensitive, Ztring_Recursive
+ /// @return The count of replacements
+ size_type FindAndReplace (const tstring &ToFind, const tstring &ReplaceBy, size_type Pos=0, ztring_t Options=Ztring_Nothing); //Remplace une chaine par une autre
+ /// @brief Count the number of occurencies of a string in the string
+ /// @param ToCount string to count
+ /// @param Options Options for count \n
+ /// Available : Ztring_CaseSensitive
+ /// @return the count
+
+ //Information
+ size_type Count (const Ztring &ToCount, ztring_t Options=Ztring_Nothing) const;
+ /// @brief compare with another string
+ /// @param ToCompare string to compare with
+ /// @param Options Options for comaparing \n
+ /// Available : Ztring_CaseSensitive
+ /// @return The result of comparasion
+ bool Compare (const Ztring &ToCompare, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing) const;
+};
+
+} //NameSpace
+
+#endif
+
diff --git a/src/thirdparty/ZenLib/ZenLib/ZtringList.cpp b/src/thirdparty/ZenLib/ZenLib/ZtringList.cpp
new file mode 100644
index 000000000..4ce7bc732
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/ZtringList.cpp
@@ -0,0 +1,379 @@
+// ZenLib::ZtringList - More methods for vector<std::(w)string>
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include <algorithm>
+#include <functional>
+#include "ZenLib/ZtringList.h"
+using namespace std;
+#if defined(_MSC_VER) && _MSC_VER <= 1200
+ using std::vector; //Visual C++ 6 patch
+#endif
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//---------------------------------------------------------------------------
+extern Ztring EmptyZtring;
+//---------------------------------------------------------------------------
+
+
+//***************************************************************************
+// Constructors/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Constructors
+ZtringList::ZtringList ()
+: std::vector<ZenLib::Ztring, std::allocator<ZenLib::Ztring> > ()
+{
+ Separator[0]=_T(";");
+ Quote=_T("\"");
+ Max[0]=Error;
+}
+
+ZtringList::ZtringList(const ZtringList &Source)
+: std::vector<ZenLib::Ztring, std::allocator<ZenLib::Ztring> > ()
+{
+ Separator[0]=Source.Separator[0];
+ Quote=Source.Quote;
+
+ reserve(Source.size());
+ for (intu Pos=0; Pos<Source.size(); Pos++)
+ push_back(Source[Pos]);
+}
+
+ZtringList::ZtringList (const Ztring &Source)
+{
+ Separator[0]=_T(";");
+ Quote=_T("\"");
+ Max[0]=Error;
+ Write(Source.c_str());
+}
+
+ZtringList::ZtringList (const Char *Source)
+{
+ Separator[0]=_T(";");
+ Quote=_T("\"");
+ Max[0]=Error;
+ Write(Source);
+}
+
+#ifdef _UNICODE
+ZtringList::ZtringList (const char* S)
+{
+ Write(Ztring(S));
+}
+#endif
+
+//***************************************************************************
+// Operator
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Operator ==
+bool ZtringList::operator== (const ZtringList &Source) const
+{
+ return (Read()==Source.Read());
+}
+
+//---------------------------------------------------------------------------
+// Operator !=
+bool ZtringList::operator!= (const ZtringList &Source) const
+{
+ return (!(Read()==Source.Read()));
+}
+
+//---------------------------------------------------------------------------
+// Operator +=
+ZtringList &ZtringList::operator+= (const ZtringList &Source)
+{
+ reserve(size()+Source.size());
+ for (size_type Pos=0; Pos<Source.size(); Pos++)
+ push_back(Source[Pos]);
+
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+// Operator =
+ZtringList &ZtringList::operator= (const ZtringList &Source)
+{
+ clear();
+ Ztring C=Separator[0];
+ Ztring Q=Quote;
+
+ Separator[0]=Source.Separator[0];
+ Quote=Source.Quote;
+ reserve(Source.size());
+ for (size_type Pos=0; Pos<Source.size(); Pos++)
+ push_back(Source[Pos]);
+
+ Separator[0]=C;
+ Quote=Q;
+
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+// Operator ()
+Ztring &ZtringList::operator() (size_type Pos)
+{
+ if (Pos>=size())
+ Write(Ztring(), Pos);
+
+ return operator[](Pos);
+}
+
+//***************************************************************************
+// In/Out
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Read
+Ztring ZtringList::Read () const
+{
+ //Integrity
+ if (size()==0)
+ return Ztring();
+
+ Ztring Retour;
+ Ztring ToFind=Separator[0]+Quote[0]+_T("\r\n");
+ for (size_type Pos=0; Pos<size(); Pos++)
+ {
+ if (operator[](Pos).find_first_of(ToFind)==std::string::npos)
+ Retour+=operator[](Pos)+Separator[0];
+ else if (operator[](Pos).find(Separator[0])==std::string::npos
+ && operator[](Pos).find(Quote)==std::string::npos
+ && operator[](Pos).find('\r')==std::string::npos
+ && operator[](Pos).find('\n')==std::string::npos)
+ Retour+=operator[](Pos)+Separator[0];
+ else
+ {
+ if (operator[](Pos).find(Quote)==std::string::npos)
+ Retour+=Quote+operator[](Pos)+Quote+Separator[0];
+ else
+ {
+ Ztring Value=operator[](Pos);
+ Value.FindAndReplace(Quote, Quote+Quote, 0, Ztring_Recursive);
+ Retour+=Quote+Value+Quote+Separator[0];
+ }
+ }
+ }
+
+ //delete all useless separators at the end
+ //while (Retour.find(Separator[0].c_str(), Retour.size()-Separator[0].size())!=std::string::npos)
+ if (Retour.find(Separator[0].c_str(), Retour.size()-Separator[0].size())!=std::string::npos)
+ Retour.resize(Retour.size()-Separator[0].size());
+
+ return Retour;
+}
+
+const Ztring &ZtringList::Read (size_type Pos) const
+{
+ //Integrity
+ if (Pos>=size())
+ return EmptyZtring;
+
+ return operator[](Pos);
+}
+
+//---------------------------------------------------------------------------
+// Write
+void ZtringList::Write(const Ztring &ToWrite)
+{
+ clear();
+
+ if (!&ToWrite || !ToWrite.size())
+ return;
+
+ size_type PosC=0;
+ bool Fini=false;
+ Ztring C1;
+
+ Ztring DelimiterL;
+ Ztring DelimiterR;
+ do
+ {
+ //Searching quotes
+ if (ToWrite[PosC]==Quote[0])
+ {
+ size_t Pos_End=PosC+1;
+ while (Pos_End<ToWrite.size())
+ {
+ if (ToWrite[Pos_End]==Quote[0] && Pos_End+1<ToWrite.size() && ToWrite[Pos_End+1]==Quote[0])
+ Pos_End+=2; //Double quote, skipping
+ else
+ {
+ if (ToWrite[Pos_End]==Quote[0])
+ break;
+ Pos_End++;
+ }
+ }
+ C1=ToWrite.substr(PosC+Quote.size(), Pos_End-PosC);
+ PosC+=C1.size()+Quote.size();
+ if (C1.size()>0 && C1[C1.size()-1]==Quote[0])
+ {
+ C1.resize(C1.size()-1);
+ PosC+=Quote.size();
+ }
+ }
+ else //Normal
+ {
+ C1=ToWrite.SubString(tstring(), Separator[0], PosC, Ztring_AddLastItem);
+ PosC+=C1.size()+Separator[0].size();
+ }
+ C1.FindAndReplace(Quote+Quote, Quote, 0, Ztring_Recursive);
+ if (size()<Max[0])
+ push_back(C1);
+ if (PosC>=ToWrite.size())
+ Fini=true;
+ }
+ while (!Fini);
+
+ return;
+}
+
+void ZtringList::Write(const Ztring &ToWrite, size_type Pos)
+{
+ if (Pos==Error)
+ return;
+ if (Pos>=size())
+ {
+ //Resource reservation
+ size_t ToReserve=1;
+ while (ToReserve<Pos)
+ ToReserve*=2;
+ reserve(ToReserve);
+
+ while (Pos>size())
+ push_back(Ztring());
+ push_back(ToWrite);
+ }
+ else
+ operator[](Pos)=ToWrite;
+
+ return;
+}
+
+//***************************************************************************
+// Edition
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Swap
+void ZtringList::Swap (size_type Pos0_A, size_type Pos0_B)
+{
+ //Integrity
+ size_type Pos_Max;
+ if (Pos0_A<Pos0_B)
+ Pos_Max=Pos0_B;
+ else
+ Pos_Max=Pos0_A;
+ if (Pos_Max>=size())
+ Write(Ztring(), Pos_Max);
+
+ operator [] (Pos0_A).swap(operator [] (Pos0_B));
+}
+
+//---------------------------------------------------------------------------
+// Sort
+void ZtringList::Sort(ztring_t)
+{
+ std::stable_sort(begin(), end());
+ return;
+}
+
+//***************************************************************************
+// Information
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Find
+Ztring::size_type ZtringList::Find (const Ztring &ToFind, size_type Pos, const Ztring &Comparator, ztring_t Options) const
+{
+ while (Pos<size() && !(operator[](Pos).Compare(ToFind, Comparator, Options)))
+ Pos++;
+ if (Pos>=size())
+ return Error;
+ return Pos;
+}
+
+//---------------------------------------------------------------------------
+// Return the length of the longest string in the list.
+Ztring::size_type ZtringList::MaxStringLength_Get ()
+{
+ size_type Max = 0;
+ for (ZtringList::const_iterator it=begin(); it!=end(); ++it)
+ if (it->size()>Max)
+ Max=it->size();
+ return Max;
+}
+
+//***************************************************************************
+// Configuration
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Separator
+void ZtringList::Separator_Set (size_type Level, const Ztring &NewSeparator)
+{
+ if (Level>0)
+ return;
+ Separator[Level]=NewSeparator;
+}
+
+//---------------------------------------------------------------------------
+// Quote
+void ZtringList::Quote_Set (const Ztring &NewQuote)
+{
+ Quote=NewQuote;
+}
+
+//---------------------------------------------------------------------------
+// Separator
+void ZtringList::Max_Set (size_type Level, size_type Max_New)
+{
+ if (Level>0 || Max_New==0)
+ return;
+ Max[Level]=Max_New;
+}
+
+} //namespace
+
+
+
+
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/ZtringList.h b/src/thirdparty/ZenLib/ZenLib/ZtringList.h
new file mode 100644
index 000000000..6f9c82313
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/ZtringList.h
@@ -0,0 +1,103 @@
+// ZenLib::ZtringList - More methods for vector<std::(w)string>
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// More methods for std::vector<std::(w)string>
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_ZtringListH
+#define ZenLib_ZtringListH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Ztring.h"
+#include <vector>
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+/// @brief Vector of strings manipulation (based on std::vector<std::(w)string>)
+//***************************************************************************
+
+class ZtringList : public std::vector<Ztring>
+{
+public :
+ //Constructors/destructor
+ ZtringList ();
+ ZtringList (const ZtringList &Source);
+ ZtringList (const Ztring &Source);
+ ZtringList (const Char *Source);
+ #ifdef _UNICODE
+ ZtringList (const char *Source); //convert a UTF-8 string into Unicode
+ #endif
+
+ //Operators
+ bool operator == (const ZtringList &Source) const;
+ bool operator != (const ZtringList &Source) const;
+ ZtringList &operator += (const ZtringList &Source);
+ ZtringList &operator = (const ZtringList &Source);
+
+ Ztring &operator () (size_type Pos); ///< Same as [], but write a empty string if Pos doesn't exist yet
+
+ //In/out
+ Ztring Read () const; /// Read all
+ const Ztring &Read (size_type Pos) const; /// Read a string
+ void Write (const Ztring &ToWrite); /// Write all
+ void Write (const Ztring &ToWrite, size_type Pos); /// Write a string
+ /// @brief Insert a string at position Pos0
+ void Insert (const Ztring &ToInsert, size_type Pos0) {insert(begin()+Pos0, ToInsert);};
+ /// @brief Delete a string at position Pos0
+ void Delete (size_type Pos0) {erase(begin()+Pos0);};
+
+ //Edition
+ /// @brief Swap 2 positions
+ void Swap (size_type Pos0_A, size_type Pos0_B);
+ /// @brief Sort
+ void Sort (ztring_t Options=Ztring_Nothing);
+
+ //Information
+ /// @brief Find the position of the string in the vector
+ size_type Find (const Ztring &ToFind, size_type PosBegin=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing) const;
+ /// @brief Return the length of the longest string in the list.
+ size_type MaxStringLength_Get ();
+
+ //Configuration
+ /// @brief Set the Separator character
+ void Separator_Set (size_type Level, const Ztring &NewSeparator);
+ /// @brief Set the Quote character
+ /// During Read() or Write() method, if Separator is in the sequence, we must quote it
+ void Quote_Set (const Ztring &NewQuote);
+ /// @brief Set the Maximum number of element to read
+ /// During Read() or Write() method, if there is more elements, merge them with the last element
+ void Max_Set (size_type Level, size_type Max_New);
+
+protected :
+ Ztring Separator[1];
+ Ztring Quote;
+ size_type Max[1];
+};
+
+} //namespace
+#endif
+
diff --git a/src/thirdparty/ZenLib/ZenLib/ZtringListList.cpp b/src/thirdparty/ZenLib/ZenLib/ZtringListList.cpp
new file mode 100644
index 000000000..0e379be8e
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/ZtringListList.cpp
@@ -0,0 +1,605 @@
+// ZenLib::ZtringListList - More methods for std::vector<std::vector<std::(w)string>>
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include <algorithm>
+#include "ZenLib/ZtringListList.h"
+using namespace std;
+#if defined(_MSC_VER) && _MSC_VER <= 1200
+ using std::vector; //Visual C++ 6 patch
+#endif
+//---------------------------------------------------------------------------
+
+
+namespace ZenLib
+{
+
+//---------------------------------------------------------------------------
+extern Ztring EmptyZtring;
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Constructors/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Constructors
+ZtringListList::ZtringListList()
+: std::vector<ZenLib::ZtringList, std::allocator<ZenLib::ZtringList> > ()
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+ Quote=_T("\"");
+ Max[0]=Error;
+ Max[1]=Error;
+}
+
+ZtringListList::ZtringListList(const ZtringListList &Source)
+: std::vector<ZenLib::ZtringList, std::allocator<ZenLib::ZtringList> > ()
+{
+ Separator[0]=Source.Separator[0];
+ Separator[1]=Source.Separator[1];
+ Quote=Source.Quote;
+ Max[0]=Source.Max[0];
+ Max[1]=Source.Max[1];
+ reserve(Source.size());
+ for (intu Pos=0; Pos<Source.size(); Pos++)
+ push_back(Source[Pos]);
+}
+
+ZtringListList::ZtringListList(const Ztring &Source)
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+ Quote=_T("\"");
+ Max[0]=Error;
+ Max[1]=Error;
+ Write(Source.c_str());
+}
+
+ZtringListList::ZtringListList(const Char *Source)
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+ Quote=_T("\"");
+ Max[0]=Error;
+ Max[1]=Error;
+ Write(Source);
+}
+
+#ifdef _UNICODE
+ZtringListList::ZtringListList (const char* S)
+{
+ Separator[0]=EOL;
+ Separator[1]=_T(";");
+ Quote=_T("\"");
+ Max[0]=Error;
+ Max[1]=Error;
+ Write(Ztring(S));
+}
+#endif
+
+//***************************************************************************
+// Operators
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+//Operator ==
+bool ZtringListList::operator== (const ZtringListList &Source) const
+{
+ return (Read()==Source.Read());
+}
+
+//---------------------------------------------------------------------------
+//Operator !=
+bool ZtringListList::operator!= (const ZtringListList &Source) const
+{
+ return (!(Read()==Source.Read()));
+}
+
+//---------------------------------------------------------------------------
+// Operator +=
+ZtringListList &ZtringListList::operator+= (const ZtringListList &Source)
+{
+ reserve(size()+Source.size());
+ for (size_type Pos=0; Pos<Source.size(); Pos++)
+ {
+ push_back(Source[Pos]);
+ operator[](size()-1).Separator_Set(0, Separator[1]);
+ operator[](size()-1).Quote_Set(Quote);
+ operator[](size()-1).Max_Set(0, Max[1]);
+ }
+
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+// Operator =
+ZtringListList &ZtringListList::operator= (const ZtringListList &Source)
+{
+ clear();
+
+ reserve(Source.size());
+ for (size_type Pos=0; Pos<Source.size(); Pos++)
+ {
+ push_back(Source[Pos]);
+ operator[](size()-1).Separator_Set(0, Separator[1]);
+ operator[](size()-1).Quote_Set(Quote);
+ operator[](size()-1).Max_Set(0, Max[1]);
+ }
+
+ return *this;
+}
+
+//---------------------------------------------------------------------------
+// Operatorr ()
+ZtringList &ZtringListList::operator() (size_type Pos0)
+{
+ //Integrity
+ if (Pos0>=size())
+ Write(Ztring(), Pos0);
+
+ return operator[](Pos0);
+}
+
+Ztring &ZtringListList::operator() (size_type Pos0, size_type Pos1)
+{
+ //Integrity
+ if (Pos0>=size())
+ Write(Ztring(), Pos0);
+
+ return operator[](Pos0).operator()(Pos1);
+}
+
+Ztring &ZtringListList::operator() (const Ztring &Pos0, size_type Pos0_1, size_type Pos1)
+{
+ size_type Pos=0;
+ size_t Size=size();
+ for (; Pos<Size; Pos++)
+ if (operator[](Pos).size()>Pos0_1)
+ if (operator[](Pos)[Pos0_1]==Pos0)
+ break;
+
+ if (Pos>=Size)
+ {
+ Write(Pos0, Size, Pos0_1);
+ Pos=size()-1;
+ }
+
+ return operator[](Pos).operator()(Pos1);
+}
+
+//***************************************************************************
+// In/Out
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Read
+Ztring ZtringListList::Read () const
+{
+ //Integrity
+ if (size()==0)
+ return Ztring();
+
+ Ztring ToReturn;
+ size_type Size=size()-1;
+ for (size_type Pos0=0; Pos0<Size; Pos0++)
+ ToReturn+=Read(Pos0)+Separator[0];
+ ToReturn+=Read(Size);
+
+ //Delete all useless separators at the end
+ //if(ToReturn.size()>0 && Separator[0].size() && ToReturn(ToReturn.size()-1)==Separator[0][Separator[0].size()-1]) //Optimize speed
+ // while (ToReturn.find(Separator[0].c_str(), ToReturn.size()-Separator[0].size())!=std::string::npos)
+ // ToReturn.resize(ToReturn.size()-Separator[0].size());
+
+ return ToReturn;
+}
+
+Ztring ZtringListList::Read (size_type Pos0) const
+{
+ //Integrity
+ if (Pos0>=size())
+ return Ztring();
+
+ return operator[](Pos0).Read();
+}
+
+const Ztring &ZtringListList::Read (size_type Pos0, size_type Pos1) const
+{
+ //Integrity
+ if (Pos0>=size())
+ return EmptyZtring;
+
+ return operator[](Pos0).Read(Pos1);
+}
+
+const Ztring &ZtringListList::Read (const Ztring &Pos0, size_type Pos1) const
+{
+ size_type Pos=Find(Pos0);
+ if (Pos==Error)
+ return EmptyZtring;
+
+ return operator[](Pos).Read(Pos1);
+}
+
+const Ztring &ZtringListList::Read (const Ztring &Pos0, size_type Pos0_1, size_type Pos1) const
+{
+ size_type Pos=Find(Pos0, Pos0_1);
+ if (Pos==Error)
+ return EmptyZtring;
+
+ return operator[](Pos).Read(Pos1);
+}
+
+const Ztring &ZtringListList::Read (const Ztring &Pos0, const Ztring &Default, size_type Pos1) const
+{
+ size_type Pos=Find(Pos0);
+ if (Pos==Error)
+ return Default;
+
+ return operator[](Pos).Read(Pos1);
+}
+
+const Ztring &ZtringListList::Read (const Ztring &Pos0, const Ztring &Default, size_type Pos0_1, size_type Pos1) const //Lecture d'un champs en position 0 avec une option par defaut
+{
+ size_type Pos=Find(Pos0, Pos0_1);
+ if (Pos==Error)
+ return Default;
+
+ return operator[](Pos).Read(Pos1);
+}
+
+Ztring ZtringListList::Read1 (size_type Pos1) const
+{
+ Ztring ToReturn;
+ size_type Size=size()-1;
+ for (size_type Pos=0; Pos<Size; Pos++)
+ ToReturn+=operator[](Pos).Read(Pos1)+Separator[0];
+ ToReturn+=operator[](Size).Read(Pos1);
+
+ //Delete all useless separators at the end
+ if(ToReturn(ToReturn.size()-1)==Separator[0][Separator[0].size()-1]) //Optimize speed
+ while (ToReturn.find(Separator[0].c_str(), ToReturn.size()-Separator[0].size())!=std::string::npos)
+ ToReturn.resize(ToReturn.size()-Separator[0].size());
+
+ return ToReturn;
+}
+
+//---------------------------------------------------------------------------
+// Write
+void ZtringListList::Write(const Ztring &ToWrite)
+{
+ clear();
+
+ if (!&ToWrite || !ToWrite.size())
+ return;
+
+ size_type PosC=0;
+ bool Fini=false;
+ Ztring C1;
+ ZtringList ZL1;
+ ZL1.Separator_Set(0, Separator[1]);
+ ZL1.Quote_Set(Quote);
+ ZL1.Max_Set(0, Max[1]);
+
+ //Detecting carriage return format
+ Ztring WriteSeparator;
+ if (Separator[0]==EOL)
+ {
+ size_t CarriageReturn_Pos=ToWrite.find_first_of(_T("\r\n"));
+ if (CarriageReturn_Pos!=string::npos)
+ {
+ if (ToWrite[CarriageReturn_Pos]==_T('\r'))
+ {
+ if (CarriageReturn_Pos+1<ToWrite.size() && ToWrite[CarriageReturn_Pos+1]==_T('\n'))
+ WriteSeparator=_T("\r\n");
+ else
+ WriteSeparator=_T("\r");
+ }
+ else
+ WriteSeparator=_T("\n");
+ }
+ else
+ WriteSeparator=Separator[0];
+ }
+ else
+ WriteSeparator=Separator[0];
+
+ do
+ {
+ //Searching end of line, but it must not be in quotes
+ bool InQuotes=false;
+ Ztring CharsToFind=WriteSeparator+Quote;
+ size_t Pos_End=PosC;
+ while (Pos_End<ToWrite.size())
+ {
+ Pos_End=ToWrite.find(WriteSeparator, Pos_End);
+ if (Pos_End!=string::npos)
+ {
+ if (Pos_End+Quote.size()<ToWrite.size() && ToWrite[Pos_End]==Quote[0] && ToWrite[Pos_End+1]!=Quote[0])
+ {
+ InQuotes=!InQuotes; //This is not double quotes, so this is a normal quote
+ /*if (!InQuotes)
+ {
+ C1=ToWrite.substr(PosC, Pos_End-PosC);
+ break;
+ }*/
+ }
+
+ if (!InQuotes && Pos_End+WriteSeparator.size()<=ToWrite.size() && ToWrite[Pos_End]==WriteSeparator[0])
+ {
+ C1=ToWrite.substr(PosC, Pos_End-PosC);
+ break;
+ }
+
+ if (InQuotes && Pos_End+Quote.size()*2<ToWrite.size() && ToWrite[Pos_End]==Quote[0] && ToWrite[Pos_End+1]==Quote[0])
+ Pos_End+=2;
+ else
+ Pos_End++;
+ }
+ }
+ if (Pos_End>=ToWrite.size())
+ C1=ToWrite.substr(PosC, string::npos);
+
+ ZL1.Write(C1);
+ push_back(ZL1);
+ PosC+=C1.size()+WriteSeparator.size();
+ if (PosC>=ToWrite.size())
+ Fini=true;
+ }
+ while (!Fini);
+}
+
+void ZtringListList::Write(const ZtringList &ToWrite, size_type Pos)
+{
+ //Integrity
+ if (Pos==Error)
+ return;
+
+ //Writing
+ if (Pos>=size())
+ {
+ //Reservation de ressources
+ if (!capacity())
+ reserve(1);
+ while (Pos>=capacity())
+ reserve(capacity()*2);
+
+ while (Pos>size())
+ push_back (Ztring());
+ push_back(ToWrite);
+ }
+ else
+ operator[](Pos)=ToWrite;
+}
+
+void ZtringListList::Write(const Ztring &ToWrite, size_type Pos0, size_type Pos1)
+{
+ if (Pos0>=size())
+ Write(Ztring(), Pos0);
+
+ operator[](Pos0).Write(ToWrite, Pos1);
+}
+
+void ZtringListList::push_back (const ZtringList &ToAdd)
+{
+ vector<ZtringList>::push_back(ToAdd); //Visual C++ 6 patch, should be std::vector
+ operator[](size()-1).Separator_Set(0, Separator[1]);
+ operator[](size()-1).Quote_Set(Quote);
+ operator[](size()-1).Max_Set(0, Max[1]);
+}
+
+void ZtringListList::push_back (const Ztring &ToAdd)
+{
+ ZtringList ZL1;
+ ZL1.Separator_Set(0, Separator[1]);
+ ZL1.Quote_Set(Quote);
+ ZL1.Max_Set(0, Max[1]);
+ ZL1.Write(ToAdd);
+ push_back(ZL1);
+}
+
+//---------------------------------------------------------------------------
+// Insert
+void ZtringListList::Insert1 (const Ztring &ToInsert, size_type Pos1)
+{
+ for (size_type Pos0=0; Pos0<size(); Pos0++)
+ operator[](Pos0).Insert(ToInsert, Pos1);
+}
+
+//---------------------------------------------------------------------------
+// Delete
+void ZtringListList::Delete (const Ztring &ToFind, size_type Pos1, const Ztring &Comparator, ztring_t Options)
+{
+ size_type Pos0=0;
+ while ((Pos0=Find(ToFind, Pos1, Pos0, Comparator, Options))!=Error)
+ operator [] (Pos0).Delete(Pos1);
+}
+
+void ZtringListList::Delete1 (size_type Pos1)
+{
+ for (size_type Pos0=0; Pos0<size(); Pos0++)
+ operator [] (Pos0).Delete(Pos1);
+}
+
+//***************************************************************************
+// Edition
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Swap
+void ZtringListList::Swap (size_type Pos0_A, size_type Pos0_B)
+{
+ //Integrity
+ size_type Pos_Max;
+ if (Pos0_A<Pos0_B)
+ Pos_Max=Pos0_B;
+ else
+ Pos_Max=Pos0_A;
+ if (Pos_Max>=size())
+ Write(Ztring(), Pos_Max);
+
+ operator [] (Pos0_A).swap(operator [] (Pos0_B));
+}
+
+void ZtringListList::Swap1 (size_type Pos1_A, size_type Pos1_B)
+{
+ for (size_type Pos0=0; Pos0<size(); Pos0++)
+ operator () (Pos0, Pos1_A).swap(operator () (Pos0, Pos1_B));
+}
+
+//---------------------------------------------------------------------------
+// Sort
+void ZtringListList::Sort(size_type, ztring_t)
+{
+ std::stable_sort(begin(), end());
+ return;
+}
+
+//---------------------------------------------------------------------------
+// Find
+Ztring::size_type ZtringListList::Find (const Ztring &ToFind, size_type Pos1, size_type Pos0) const
+{
+ size_t Size=size();
+ for (; Pos0<Size; Pos0++)
+ if (operator[](Pos0).size()>Pos1)
+ if (operator[](Pos0)[Pos1]==ToFind)
+ break;
+
+ if (Pos0>=Size)
+ return Error;
+ return Pos0;
+}
+
+Ztring::size_type ZtringListList::Find_Filled (size_type Pos1, size_type Pos0) const
+{
+ size_t Size=size();
+ for (; Pos0<Size; Pos0++)
+ if (operator[](Pos0).size()>Pos1)
+ if (!operator[](Pos0)[Pos1].empty())
+ break;
+
+ if (Pos0>=Size)
+ return Error;
+ return Pos0;
+}
+
+Ztring::size_type ZtringListList::Find (const Ztring &ToFind, size_type Pos1, size_type Pos0, const Ztring &Comparator, ztring_t Options) const
+{
+ while ( Pos0<size()
+ && ( Pos1>=at(Pos0).size()
+ || !at(Pos0).at(Pos1).Compare(ToFind, Comparator, Options)))
+ Pos0++;
+ if (Pos0>=size())
+ return Error;
+ return Pos0;
+}
+
+Ztring ZtringListList::FindValue (const Ztring &ToFind, size_type Pos1Value, size_type Pos1, size_type Pos0Begin, const Ztring &Comparator, ztring_t) const
+{
+ size_type Pos0=Find(ToFind, Pos1, Pos0Begin, Comparator);
+ if (Pos0==Error)
+ return Ztring();
+
+ return Read(Pos0, Pos1Value);
+}
+
+ZtringListList ZtringListList::SubSheet (const Ztring &ToFind, size_type Pos1, size_type Pos0, const Ztring &Comparator, ztring_t) const
+{
+ ZtringListList ToReturn;
+ ToReturn.Separator[0]=Separator[0];
+ ToReturn.Separator[1]=Separator[1];
+ ToReturn.Quote=Quote;
+
+ Pos0--;
+ do
+ {
+ Pos0=Find(ToFind, Pos1, Pos0+1, Comparator);
+ ToReturn.push_back(Read(Pos0));
+ }
+ while (Pos0!=Error);
+
+ return ToReturn;
+}
+
+//***************************************************************************
+// Configuration
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Separator
+void ZtringListList::Separator_Set (size_type Level, const Ztring &NewSeparator)
+{
+ if (Level>1)
+ return;
+
+ Separator[Level]=NewSeparator;
+ if (Level==1)
+ for (size_type Pos0=0; Pos0<size(); Pos0++)
+ operator () (Pos0).Separator_Set(0, Separator[1]);
+}
+
+//---------------------------------------------------------------------------
+// Quote
+void ZtringListList::Quote_Set (const Ztring &NewQuote)
+{
+ Quote=NewQuote;
+ for (size_type Pos0=0; Pos0<size(); Pos0++)
+ operator () (Pos0).Quote_Set(Quote);
+}
+
+//---------------------------------------------------------------------------
+// Max
+void ZtringListList::Max_Set (size_type Level, size_type NewMax)
+{
+ if (Level>1 || NewMax==0)
+ return;
+
+ Max[Level]=NewMax;
+ if (Level==1)
+ for (size_type Pos0=0; Pos0<size(); Pos0++)
+ operator () (Pos0).Max_Set(0, Max[1]);
+}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+} //namespace
+
+
+
+
+
+
+
+
diff --git a/src/thirdparty/ZenLib/ZenLib/ZtringListList.h b/src/thirdparty/ZenLib/ZenLib/ZtringListList.h
new file mode 100644
index 000000000..cb0435519
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/ZtringListList.h
@@ -0,0 +1,146 @@
+// ZenLib::ZtringListList - More methods for std::vector<std::vector<std::(w)string>>
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// More methods for std::vector<std::vector<std::(w)string>>
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZenLib_ZtringListListH
+#define ZenLib_ZtringListListH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/ZtringList.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+/// @brief Vector of vectors of strings manipulation (based on std::vector<std::vector<std::(w)string>>)
+//***************************************************************************
+
+class ZtringListList : public std::vector<ZtringList>
+{
+public :
+ //Constructors/Destructor
+ ZtringListList ();
+ ZtringListList (const ZtringListList &Source);
+ ZtringListList (const Ztring &Source);
+ ZtringListList (const Char *Source);
+ #ifdef _UNICODE
+ ZtringListList (const char *Source); //convert a UTF-8 string into Unicode
+ #endif
+
+ //Operateurs
+ bool operator == (const ZtringListList &Source) const;
+ bool operator != (const ZtringListList &Source) const;
+ ZtringListList &operator += (const ZtringListList &Source);
+ ZtringListList &operator = (const ZtringListList &Source);
+
+ ZtringList &operator () (size_type Pos0); ///< Same as [], but write a empty string if Pos doesn't exist yet
+ Ztring &operator () (size_type Pos0, size_type Pos1);
+ /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0]
+ Ztring &operator () (const Ztring &Pos0, size_type Pos1=1) {return operator() (Pos0, 0 , Pos1);};
+ /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1]
+ Ztring &operator () (const Ztring &Pos0, size_type Pos0_1, size_type Pos1);
+
+ //In/Out
+ /// @brief Read all
+ Ztring Read () const;
+ /// @brief Read a vector of string
+ Ztring Read (size_type Pos0) const;
+ /// @brief Read a string
+ const Ztring &Read (size_type Pos0, size_type Pos1) const;
+ /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0]
+ const Ztring &Read (const Ztring &Pos0, size_type Pos1=1) const;
+ /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1]
+ const Ztring &Read (const Ztring &Pos0, size_type Pos0_1, size_type Pos1) const;
+ /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0], with default value
+ const Ztring &Read (const Ztring &Pos0, const Ztring &Default, size_type Pos1=1) const;
+ /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1], with default value
+ const Ztring &Read (const Ztring &Pos0, const Ztring &Default, size_type Pos0_1, size_type Pos1) const;
+ /// @brief Read all strings at position Pos1
+ Ztring Read1 (size_type Pos1) const;
+
+ /// @brief Write all
+ void Write (const Ztring &ToWrite);
+ /// @brief Write a vector of string
+ void Write (const ZtringList &ToWrite, size_type Pos0);
+ /// @brief Write a vector of string
+ void Write (const Ztring &ToWrite, size_type Pos0, size_type Pos1);
+ /// @brief Add a vector of string
+ void push_back (const ZtringList &ToAdd);
+ /// @brief Add a vector of string (with separator is ZtringListList Separator)
+ void push_back (const Ztring &ToAdd);
+ /// @brief Add a vector of string (Char version)
+ void push_back (const Char* ToAdd) {push_back(Ztring(ToAdd));};
+ /// @brief Insert a vector of string at position Pos0
+ void Insert (const ZtringList &ToInsert, size_type Pos0) {insert(begin()+Pos0, ToInsert);};
+ /// @brief Insert a string at all positions Pos1
+ void Insert1 (const Ztring &ToInsert, size_type Pos1);
+ /// @brief Delete a vector of string at position Pos0
+ void Delete (size_type Pos0) {erase(begin()+Pos0);};
+ /// @brief Delete all vectors of string, with [xxx][Pos1] == ToFind
+ void Delete (const Ztring &ToFind, size_type Pos1=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing);
+ /// @brief Delete a string at all positions Pos1
+ void Delete1 (size_type Pos1);
+
+ //Edition
+ /// @brief Swap 2 positions
+ void Swap (size_type Pos0_A, size_type Pos0_B);
+ /// @brief Swap 2 columns for each line
+ void Swap1 (size_type Pos1_A, size_type Pos1_B);
+ /// @brief Sort
+ void Sort (size_type Pos1, ztring_t Options=Ztring_Nothing);
+
+ //Information
+ /// @brief Find the first position of the string in the vector of vector, in a specific column
+ size_type Find (const Ztring &ToFind, size_type Pos1=0, size_type Pos0Begin=0) const;
+ /// @brief Find the first position of the string in the vector of vector, in a specific column, which is not empty
+ size_type Find_Filled (size_type Pos1=0, size_type Pos0Begin=0) const;
+ /// @brief Find the first position of the string in the vector of vector, in a specific column
+ size_type Find (const Ztring &ToFind, size_type Pos1, size_type Pos0Begin, const Ztring &Comparator, ztring_t Options=Ztring_Nothing) const;
+ /// @brief Return [xxx][Pos1Value] when founded the first position of the string in the vector of vector, in a specific column
+ Ztring FindValue (const Ztring &ToFind, size_type Pos1Value=1, size_type Pos1=0, size_type Pos0Begin=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing) const;
+ /// @brief Return a subsheet, with all lines with position of the string in the vector of vector, in a specific column
+ ZtringListList SubSheet (const Ztring &ToFind, size_type Pos1=0, size_type Pos0Begin=0, const Ztring &Comparator=_T("=="), ztring_t Options=Ztring_Nothing) const;
+
+ //Configuration
+ /// @brief Set the Separator character
+ void Separator_Set (size_type Level, const Ztring &NewSeparator);
+ /// @brief Set the Quote character
+ /// During Read() or Write() method, if Separator is in the sequence, we must quote it
+ void Quote_Set (const Ztring &NewQuote);
+ /// @brief Set the Maximum number of element to read
+ /// During Read() or Write() method, if there is more elements, merge them with the last element
+ void Max_Set (size_type Level, size_type Max);
+
+protected :
+ Ztring Separator[2];
+ Ztring Quote;
+ size_type Max[2];
+};
+
+} //namespace
+#endif
+
diff --git a/src/thirdparty/ZenLib/ZenLib/ZtringListListF.cpp b/src/thirdparty/ZenLib/ZenLib/ZtringListListF.cpp
new file mode 100644
index 000000000..87265dbed
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/ZtringListListF.cpp
@@ -0,0 +1,384 @@
+// ZenLib::ZtringListListF - ZtringListList with file load/save
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// ZtringListList with file load/save
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/ZtringListListF.h"
+#include "ZenLib/File.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//---------------------------------------------------------------------------
+#define READ_SIZE 512*1024
+//---------------------------------------------------------------------------
+
+//***************************************************************************
+// Constructors/Destructor
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Constructors
+void ZtringListListF::ZtringListListF_Common ()
+{
+ Backup_Nb_Max=0;
+ Backup_Nb=0;
+ Sauvegarde=true;
+ #ifdef _UNICODE
+ Local=false;
+ #else
+ Local=true;
+ #endif
+}
+
+ZtringListListF::ZtringListListF ()
+:ZtringListList ()
+{
+ ZtringListListF_Common();
+}
+
+ZtringListListF::ZtringListListF (const ZtringListList &Source)
+:ZtringListList (Source)
+{
+ ZtringListListF_Common();
+}
+
+ZtringListListF::ZtringListListF (const Ztring &Source)
+:ZtringListList (Source)
+{
+ ZtringListListF_Common();
+}
+
+ZtringListListF::ZtringListListF (const Char *Source)
+:ZtringListList (Source)
+{
+ ZtringListListF_Common();
+}
+
+#ifdef _UNICODE
+ZtringListListF::ZtringListListF (const char* Source)
+:ZtringListList (Source)
+{
+ ZtringListListF_Common();
+}
+#endif
+
+//***************************************************************************
+// File management
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Load
+bool ZtringListListF::Load (const Ztring &NewFileName)
+{
+ clear();
+ if (!NewFileName.empty())
+ Name=NewFileName;
+
+ size_t I1=Error;
+
+ if (Name.find(_T(".csv"))!=Error)
+ I1=CSV_Charger();
+ if (Name.find(_T(".cfg"))!=Error)
+ I1=CFG_Charger();
+ if (I1!=Error)
+ {
+ Backup_Nb=0; //mettre ici le code pour trouver le nb de backup
+ return true;
+ }
+ else
+ return false;
+}
+
+//---------------------------------------------------------------------------
+// Load CSV
+bool ZtringListListF::CSV_Charger ()
+{
+ //Read file
+ File F;
+ if (!F.Open(Name))
+ return false;
+
+ int8u* Buffer=new int8u[(size_t)F.Size_Get()+1];
+ size_t BytesCount=F.Read(Buffer, (size_t)F.Size_Get());
+ F.Close();
+ if (BytesCount==Error)
+ {
+ delete[] Buffer; //Buffer=NULL;
+ return false;
+ }
+ Buffer[(int32u)BytesCount]=(int8u)'\0';
+
+ //Convert file in UTF-8 or Local
+ Ztring File;
+ if (!Local)
+ {
+ //UTF-8
+ File.From_UTF8((char*)Buffer, 0, BytesCount);
+ #ifdef _DEBUG
+ if (File.size()==0)
+ File.From_Local((char*)Buffer, 0, BytesCount);
+ #endif //_DEBUG
+ }
+ if (File.size()==0)
+ //Local of UTF-8 failed
+ File.From_Local((char*)Buffer, 0, BytesCount);
+
+ //Separators
+ if (Separator[0]==_T("(Default)"))
+ Separator[0]=EOL;
+ Ztring SeparatorT=Separator[1];
+ Separator[1]=_T(";");
+
+ //Writing
+ Write(File);
+
+ //Separators
+ Separator[1]=SeparatorT;
+
+ delete[] Buffer; //Buffer=NULL;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+// Chargement CFG
+bool ZtringListListF::CFG_Charger ()
+{
+ //Read file
+ File F(Name);
+ int8u* Buffer=new int8u[(size_t)F.Size_Get()+1];
+ size_t BytesCount=F.Read(Buffer, (size_t)F.Size_Get());
+ F.Close();
+ if (BytesCount==Error)
+ {
+ delete[] Buffer; //Buffer=NULL;
+ return false;
+ }
+ Buffer[(int32u)BytesCount]=(int8u)'\0';
+
+ //Convert File --> ZtringList
+ ZtringList List;
+ List.Separator_Set(0, EOL);
+ Ztring Z1;
+ Z1.From_UTF8((char*)Buffer, 0, BytesCount);
+ List.Write(Z1);
+
+ Ztring SeparatorT=Separator[1];
+ Separator[1]=_T(";");
+
+ Ztring Propriete, Valeur, Commentaire;
+
+ for (size_t Pos=0; Pos<List.size(); Pos++)
+ {
+ Ztring &Lu=List(Pos);
+ if (Lu.find(_T("="))>0)
+ {
+ //Obtention du Name
+ Propriete=Lu.SubString(Ztring(), _T("="));
+ NettoyerEspaces(Propriete);
+ //Obtention de la valeur
+ Valeur=Lu.SubString(_T("="), _T(";"), 0, Ztring_AddLastItem);
+ NettoyerEspaces(Valeur);
+ }
+ //Obtention du commentaire
+ Commentaire=Lu.SubString(_T(";"), Ztring(), 0, Ztring_AddLastItem);
+ NettoyerEspaces(Commentaire);
+ //Ecriture
+ push_back((Propriete+_T(";")+Valeur+_T(";")+Commentaire).c_str()); //Visual C++ 6 is old...
+ }
+ Separator[1]=SeparatorT;
+
+ delete[] Buffer; //Buffer=NULL;
+ return true;
+}
+
+//---------------------------------------------------------------------------
+// Sauvegarde globale
+bool ZtringListListF::Save (const Ztring &FileName)
+{
+ //Gestion de l'annulation de la sauvegarde
+ if (!Sauvegarde)
+ return true;
+
+ if (FileName!=Ztring())
+ Name=FileName;
+
+ //Gestion des backups
+ Backup_Nb=0;
+ int8u I2;
+ Separator[0]=EOL;
+ if (Backup_Nb_Max>0)
+ {
+ //TODO : not tested
+ for (int8u I1=Backup_Nb_Max-1; I1>0; I1--)
+ {
+ Ztring Z1=Name+_T(".sav"); Z1+=Ztring::ToZtring(I1);
+ Ztring Z2=Name+_T(".sav"); Z2+=Ztring::ToZtring(I1+1);
+ File::Delete(Z2.c_str());
+ I2=File::Move(Z1.c_str(), Z2.c_str());
+ if (I2 && !Backup_Nb)
+ Backup_Nb=I2;
+ }
+ Ztring Z1=Name+_T(".sav0");
+ File::Delete(Z1.c_str());
+ File::Move(Name.c_str(), Z1.c_str());
+ Backup_Nb++;
+ }
+
+ I2=0;
+ if (Name.find(_T(".csv"))!=Error)
+ I2=CSV_Sauvegarder();
+ if (Name.find(_T(".cfg"))!=Error)
+ I2=CFG_Sauvegarder();
+
+ if (I2>0)
+ {
+ return true;
+ }
+ else
+ return false;
+}
+
+//---------------------------------------------------------------------------
+// Sauvegarde CSV
+bool ZtringListListF::CSV_Sauvegarder ()
+{
+ //Sauvegarde
+ File F;
+ if (!F.Create(Name, true))
+ return Error;
+
+ if (Separator[0]==_T("(Default)"))
+ Separator[0]=EOL;
+
+ F.Write(Read());
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+// Sauvegarde CFG
+bool ZtringListListF::CFG_Sauvegarder ()
+{
+ File F;
+ if (!F.Create(Name, true))
+ return Error;
+
+ Ztring ToWrite;
+ Ztring Propriete, Valeur, Commentaire;
+
+ ;
+ for (size_t Pos=0; Pos<size(); Pos++)
+ {
+ Propriete=Read(Pos, 0);
+ Valeur=Read(Pos, 1);
+ Commentaire=Read(Pos, 2);
+ if (Propriete!=Ztring())
+ {
+ ToWrite+=Propriete+_T(" = ");
+ if (Valeur!=Ztring())
+ ToWrite+=Valeur+_T(" ");
+ }
+ if (Commentaire!=Ztring())
+ ToWrite+=_T("; ")+Commentaire;
+ ToWrite+=EOL;
+ }
+ F.Write(ToWrite);
+
+ return true;
+}
+
+//---------------------------------------------------------------------------
+// Annulation
+bool ZtringListListF::Cancel ()
+{
+ Ztring Z1=Name+_T(".sav0"); //Visual C++ 6 patch
+ File::Delete(Name.c_str());
+ File::Move(Z1.c_str(), Name.c_str());
+ for (int8u I1=1; I1<=Backup_Nb; I1++)
+ {
+ Ztring Z2=Name+_T(".sav"); Z2+=Ztring::ToZtring(I1); //Visual C++ 6 patch
+ Ztring Z3=Name+_T(".sav"); Z3+=Ztring::ToZtring(I1-1); //Visual C++ 6 patch
+ File::Delete(Z3.c_str());
+ File::Move(Z2.c_str(), Z3.c_str());
+ }
+ Write(Ztring());
+ return CSV_Charger();
+}
+
+//***************************************************************************
+// Divers
+//***************************************************************************
+
+//---------------------------------------------------------------------------
+// Nettoyage
+bool ZtringListListF::NettoyerEspaces (Ztring &ANettoyer)
+{
+ size_t Debut=0;
+ while (Debut<ANettoyer.size() && ANettoyer[Debut]==_T(' '))
+ Debut++;
+ size_t Fin=ANettoyer.size()-1;
+ while (Fin!=(size_t)-2 && ANettoyer[Fin]==_T(' '))
+ Fin--;
+ if (Fin>=Debut)
+ ANettoyer=ANettoyer.substr(Debut, Fin-Debut+1);
+ else
+ ANettoyer=Ztring();
+ return true;
+}
+
+//---------------------------------------------------------------------------
+// Backup
+void ZtringListListF::Backup_Set (bool NewSave)
+{
+ Sauvegarde=NewSave;
+ Save();
+}
+
+void ZtringListListF::Backup_Count_Set (int8u NewCount)
+{
+ Backup_Nb_Max=NewCount;
+}
+
+//---------------------------------------------------------------------------
+// Local
+void ZtringListListF::Local_Set (bool NewLocal)
+{
+ Local=NewLocal;
+}
+
+} //Namespace
+
diff --git a/src/thirdparty/ZenLib/ZenLib/ZtringListListF.h b/src/thirdparty/ZenLib/ZenLib/ZtringListListF.h
new file mode 100644
index 000000000..e60ec3f3f
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/ZtringListListF.h
@@ -0,0 +1,91 @@
+// ZenLib::ZtringListListF - ZtringListList with files
+// Copyright (C) 2002-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// ZtringListList with file load/save
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#ifndef ZtringListListFH
+#define ZtringListListFH
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/ZtringListList.h"
+//---------------------------------------------------------------------------
+
+namespace ZenLib
+{
+
+//***************************************************************************
+/// @brief ZtringListList with file management
+//***************************************************************************
+
+class ZtringListListF : public ZtringListList
+{
+public :
+ //Constructors/Destructor
+ ZtringListListF ();
+ ZtringListListF (const ZtringListList &Source);
+ ZtringListListF (const Ztring &Source);
+ ZtringListListF (const Char *Source);
+ #ifdef _UNICODE
+ ZtringListListF (const char *Source); //convert a UTF-8 string into Unicode
+ #endif
+
+ //File management
+ bool Load (const Ztring &FileName=Ztring());
+ bool Save (const Ztring &FileName=Ztring());
+ bool Cancel ();
+
+ //Configuration
+ // @brief enable or disable backup creation
+ void Backup_Set (bool Save);
+ // @brief Set the count of versions to save
+ void Backup_Count_Set (int8u Count);
+ // @brief Set if the content of file is a localized (=not UTF8) file
+ void Local_Set (bool Local);
+
+protected :
+ Ztring Name; //Nom du fichier
+ bool Sauvegarde; //Indicateur si on a le droit de sauvegarder (par defaut)
+ int8u Backup_Nb_Max; //Nombre maxi de sauvegardes
+ int8u Backup_Nb; //Nombre actuel de backups pour cette session
+ bool Local; //if true, this is a local charset, else this is a UTF8 charset
+
+ //File management
+ bool CSV_Charger ();
+ bool CFG_Charger ();
+ bool CSV_Sauvegarder ();
+ bool CFG_Sauvegarder ();
+ bool File_Load ();
+
+ //Divers
+ bool NettoyerEspaces (Ztring &ANettoyer); //Enlever les espaces avant et apres
+
+private:
+ void ZtringListListF_Common();
+};
+
+} //Namespace
+
+#endif
+
diff --git a/src/thirdparty/ZenLib/ZenLib/int128s.cpp b/src/thirdparty/ZenLib/ZenLib/int128s.cpp
new file mode 100644
index 000000000..51d3aa571
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/int128s.cpp
@@ -0,0 +1,421 @@
+// int128u - integer 8 bytes
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// based on http://Tringi.Mx-3.cz
+// Only adapted for ZenLib:
+// - uint128.hpp --> int128u.h
+// - Namespace
+// - int128u alias
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+#include "int128s.h"
+
+/*
+ Name: int128.cpp
+ Copyright: Copyright (C) 2005, Jan Ringos
+ Author: Jan Ringos, http://Tringi.Mx-3.cz
+
+ Version: 1.1
+*/
+
+#include <memory>
+#include <cmath>
+#include <cstring>
+#if defined (__BORLANDC__) || defined (__SUNPRO_CC)
+ #define fmodf fmod
+#endif
+#if defined (__NO_LONG_DOUBLE_MATH) || \
+ defined (__MONTAVISTA__) || defined (__ARMEL__) || \
+ defined (__FreeBSD__) || defined (__OpenBSD__) || \
+ defined (__NetBSD__) || defined (__DragonFly__) || \
+ defined (__sparc__) || defined (__sparc64__) || \
+ defined (__SUNPRO_CC)
+ #define fmodl fmod
+#endif
+using namespace std;
+
+namespace ZenLib
+{
+
+// IMPLEMENTATION
+
+const char * int128::toString (unsigned int radix) const throw () {
+ if (!*this) return "0";
+ if (radix < 2 || radix > 37) return "(invalid radix)";
+
+ static char sz [256];
+ memset (sz, 0, 256);
+
+ int128 r;
+ int128 ii = (*this < 0) ? -*this : *this;
+ int i = 255;
+
+ while (!!ii && i) {
+ ii = ii.div (radix, r);
+ sz [--i] = (char) (r.toInt () + ((r.toInt () > 9) ? 'A' - 10 : '0'));
+ };
+
+ if (*this < 0)
+ sz [--i] = '-';
+
+ return &sz [i];
+};
+
+int128::int128 (const char * sz) throw ()
+ : lo (0u), hi (0) {
+
+ if (!sz) return;
+ if (!sz [0]) return;
+
+ unsigned int radix = 10;
+ unsigned int i = 0;
+ bool minus = false;
+
+ if (sz [i] == '-') {
+ ++i;
+ minus = true;
+ };
+
+ if (sz [i] == '0') {
+ radix = 8;
+ ++i;
+ if (sz [i] == 'x') {
+ radix = 16;
+ ++i;
+ };
+ };
+
+ for (; i < strlen (sz); ++i) {
+ unsigned int n = 0;
+ if (sz [i] >= '0' && sz [i] <= (('0' + (int) radix) < '9'?('0' + (int) radix):'9')) //if (sz [i] >= '0' && sz [i] <= (('0' + (int) radix) <? '9'))
+ n = sz [i] - '0';
+ else if (sz [i] >= 'a' && sz [i] <= 'a' + (int) radix - 10)
+ n = sz [i] - 'a' + 10;
+ else if (sz [i] >= 'A' && sz [i] <= 'A' + (int) radix - 10)
+ n = sz [i] - 'A' + 10;
+ else
+ break;
+
+ (*this) *= radix;
+ (*this) += n;
+ };
+
+ if (minus)
+ *this = 0 - *this;
+
+ return;
+};
+
+int128::int128 (const float a) throw ()
+ #if defined (__mips__) || defined (__mipsel__)
+ : lo ((int64u) fmodf ((const double)a, 18446744073709551616.0)),
+ #else
+ : lo ((int64u) fmodf (a, 18446744073709551616.0f)),
+ #endif
+ hi ((int64s) (a / 18446744073709551616.0f)) {};
+
+int128::int128 (const double & a) throw ()
+ : lo ((int64u) fmod (a, 18446744073709551616.0)),
+ hi ((int64s) (a / 18446744073709551616.0)) {};
+
+int128::int128 (const long double & a) throw ()
+ #if defined (__mips__) || defined (__mipsel__)
+ : lo ((int64u) fmod ((const double)a, 18446744073709551616.0)),
+ #else
+ : lo ((int64u) fmodl (a, 18446744073709551616.0l)),
+ #endif
+ hi ((int64s) (a / 18446744073709551616.0l)) {};
+
+float int128::toFloat () const throw () {
+ return (float) this->hi * 18446744073709551616.0f
+ + (float) this->lo;
+};
+
+double int128::toDouble () const throw () {
+ return (double) this->hi * 18446744073709551616.0
+ + (double) this->lo;
+};
+
+long double int128::toLongDouble () const throw () {
+ return (long double) this->hi * 18446744073709551616.0l
+ + (long double) this->lo;
+};
+
+int128 int128::operator - () const throw () {
+ if (!this->hi && !this->lo)
+ // number is 0, just return 0
+ return *this;
+ else
+ // non 0 number
+ return int128 (0-this->lo, ~this->hi);
+};
+
+int128 int128::operator ~ () const throw () {
+ return int128 (~this->lo, ~this->hi);
+};
+
+int128 & int128::operator ++ () {
+ ++this->lo;
+ if (!this->lo)
+ ++this->hi;
+
+ return *this;
+};
+
+int128 & int128::operator -- () {
+ if (!this->lo)
+ --this->hi;
+ --this->lo;
+
+ return *this;
+};
+
+int128 int128::operator ++ (int) {
+ int128 b = *this;
+ ++ *this;
+
+ return b;
+};
+
+int128 int128::operator -- (int) {
+ int128 b = *this;
+ -- *this;
+
+ return b;
+};
+
+int128 & int128::operator += (const int128 & b) throw () {
+ int64u old_lo = this->lo;
+
+ this->lo += b.lo;
+ this->hi += b.hi + (this->lo < old_lo);
+
+ return *this;
+};
+
+int128 & int128::operator *= (const int128 & b) throw () {
+ if (!b)
+ return *this = 0u;
+ if (b == 1u)
+ return *this;
+
+ int128 a = *this;
+ int128 t = b;
+
+ this->lo = 0ull;
+ this->hi = 0ll;
+
+ for (unsigned int i = 0; i < 128; ++i) {
+ if (t.lo & 1)
+ *this += a << i;
+
+ t >>= 1;
+ };
+
+ return *this;
+};
+
+
+int128 int128::div (const int128 & divisor, int128 & remainder) const throw () {
+ if (!divisor)
+ return 1u / (unsigned int) divisor.lo;
+ // or RaiseException (EXCEPTION_INT_DIVIDE_BY_ZERO,
+ // EXCEPTION_NONCONTINUABLE, 0, NULL);
+
+ int128 ds = (divisor < 0) ? -divisor : divisor;
+ int128 dd = (*this < 0) ? -*this : *this;
+
+ // only remainder
+ if (ds > dd) {
+ remainder = *this;
+ return 0ull;
+ };
+
+ int128 r = 0ull;
+ int128 q = 0ull;
+// while (dd >= ds) { dd -= ds; q += 1; }; // extreme slow version
+
+ unsigned int b = 127;
+ while (r < ds) {
+ r <<= 1;
+ if (dd.bit (b--))
+ r.lo |= 1;
+ };
+ ++b;
+
+ for (;;)
+ if (r < ds) {
+ if (!(b--)) break;
+
+ r <<= 1;
+ if (dd.bit (b))
+ r.lo |= 1;
+
+ } else {
+ r -= ds;
+ q.bit (b, true);
+ };
+
+ // correct
+ if ((divisor < 0) ^ (*this < 0)) q =- q;
+ if (*this < 0) r =- r;
+
+ remainder = r;
+ return q;
+};
+
+bool int128::bit (unsigned int n) const throw () {
+ n &= 0x7F;
+
+ if (n < 64)
+ return (this->lo & (1ull << n))?true:false;
+ else
+ return (this->hi & (1ull << (n - 64)))?true:false;
+};
+
+void int128::bit (unsigned int n, bool val) throw () {
+ n &= 0x7F;
+
+ if (val) {
+ if (n < 64) this->lo |= (1ull << n);
+ else this->hi |= (1ull << (n - 64));
+ } else {
+ if (n < 64) this->lo &= ~(1ull << n);
+ else this->hi &= ~(1ull << (n - 64));
+ };
+};
+
+
+int128 & int128::operator >>= (unsigned int n) throw () {
+ n &= 0x7F;
+
+ if (n > 63) {
+ n -= 64;
+ this->lo = this->hi;
+
+ if (this->hi < 0) this->hi = -1ll;
+ else this->hi = 0ll;
+ };
+
+ if (n) {
+ // shift low qword
+ this->lo >>= n;
+
+ // get lower N bits of high qword
+ int64u mask = 0ull;
+ for (unsigned int i = 0; i < n; ++i) mask |= (1ull << i);
+
+ // and add them to low qword
+ this->lo |= (this->hi & mask) << (64 - n);
+
+ // and finally shift also high qword
+ this->hi >>= n;
+ };
+
+ return *this;
+};
+
+int128 & int128::operator <<= (unsigned int n) throw () {
+ n &= 0x7F;
+
+ if (n > 63) {
+ n -= 64;
+ this->hi = this->lo;
+ this->lo = 0ull;
+ };
+
+ if (n) {
+ // shift high qword
+ this->hi <<= n;
+
+ // get higher N bits of low qword
+ int64u mask = 0ull;
+ for (unsigned int i = 0; i < n; ++i) mask |= (1ull << (63 - i));
+
+ // and add them to high qword
+ this->hi |= (this->lo & mask) >> (64 - n);
+
+ // and finally shift also low qword
+ this->lo <<= n;
+ };
+
+ return *this;
+};
+
+bool int128::operator ! () const throw () {
+ return !(this->hi || this->lo);
+};
+
+int128 & int128::operator |= (const int128 & b) throw () {
+ this->hi |= b.hi;
+ this->lo |= b.lo;
+
+ return *this;
+};
+
+int128 & int128::operator &= (const int128 & b) throw () {
+ this->hi &= b.hi;
+ this->lo &= b.lo;
+
+ return *this;
+};
+
+int128 & int128::operator ^= (const int128 & b) throw () {
+ this->hi ^= b.hi;
+ this->lo ^= b.lo;
+
+ return *this;
+};
+
+bool operator < (const int128 & a, const int128 & b) throw () {
+ if (a.hi == b.hi) {
+ if (a.hi < 0)
+ return (int64s) a.lo < (int64s) b.lo;
+ else
+ return a.lo < b.lo;
+ } else
+ return a.hi < b.hi;
+};
+
+bool operator == (const int128 & a, const int128 & b) throw () {
+ return a.hi == b.hi && a.lo == b.lo;
+};
+bool operator && (const int128 & a, const int128 & b) throw () {
+ return (a.hi || a.lo) && (b.hi || b.lo);
+};
+bool operator || (const int128 & a, const int128 & b) throw () {
+ return (a.hi || a.lo) || (b.hi || b.lo);
+};
+
+} //NameSpace
diff --git a/src/thirdparty/ZenLib/ZenLib/int128s.h b/src/thirdparty/ZenLib/ZenLib/int128s.h
new file mode 100644
index 000000000..5a934831e
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/int128s.h
@@ -0,0 +1,205 @@
+// int128s - integer 8 bytes
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// based on http://Tringi.Mx-3.cz
+// Only adapted for ZenLib:
+// - .hpp --> .h
+// - Namespace
+// - int128s alias
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+#ifndef INT128_HPP
+#define INT128_HPP
+
+/*
+ Name: int128.hpp
+ Copyright: Copyright (C) 2005, Jan Ringos
+ Author: Jan Ringos, http://Tringi.Mx-3.cz
+
+ Version: 1.1
+*/
+
+#include <exception>
+#include <cstdlib>
+#include <cstdio>
+#include <new>
+#include "ZenLib/Conf.h"
+
+namespace ZenLib
+{
+
+// CLASS
+
+class int128 {
+ private:
+ // Binary correct representation of signed 128bit integer
+ int64u lo;
+ int64s hi;
+
+ protected:
+ // Some global operator functions must be friends
+ friend bool operator < (const int128 &, const int128 &) throw ();
+ friend bool operator == (const int128 &, const int128 &) throw ();
+ friend bool operator || (const int128 &, const int128 &) throw ();
+ friend bool operator && (const int128 &, const int128 &) throw ();
+
+ public:
+ // Constructors
+ inline int128 () throw () {};
+ inline int128 (const int128 & a) throw () : lo (a.lo), hi (a.hi) {};
+
+ inline int128 (const unsigned int & a) throw () : lo (a), hi (0ll) {};
+ inline int128 (const signed int & a) throw () : lo (a), hi (0ll) {
+ if (a < 0) this->hi = -1ll;
+ };
+
+ inline int128 (const int64u & a) throw () : lo (a), hi (0ll) {};
+ inline int128 (const int64s & a) throw () : lo (a), hi (0ll) {
+ if (a < 0) this->hi = -1ll;
+ };
+
+ int128 (const float a) throw ();
+ int128 (const double & a) throw ();
+ int128 (const long double & a) throw ();
+
+ int128 (const char * sz) throw ();
+
+ // TODO: Consider creation of operator= to eliminate
+ // the need of intermediate objects during assignments.
+
+ private:
+ // Special internal constructors
+ int128 (const int64u & a, const int64s & b) throw ()
+ : lo (a), hi (b) {};
+
+ public:
+ // Operators
+ bool operator ! () const throw ();
+
+ int128 operator - () const throw ();
+ int128 operator ~ () const throw ();
+
+ int128 & operator ++ ();
+ int128 & operator -- ();
+ int128 operator ++ (int);
+ int128 operator -- (int);
+
+ int128 & operator += (const int128 & b) throw ();
+ int128 & operator *= (const int128 & b) throw ();
+
+ int128 & operator >>= (unsigned int n) throw ();
+ int128 & operator <<= (unsigned int n) throw ();
+
+ int128 & operator |= (const int128 & b) throw ();
+ int128 & operator &= (const int128 & b) throw ();
+ int128 & operator ^= (const int128 & b) throw ();
+
+ // Inline simple operators
+ inline const int128 & operator + () const throw () { return *this; };
+
+ // Rest of inline operators
+ inline int128 & operator -= (const int128 & b) throw () {
+ return *this += (-b);
+ };
+ inline int128 & operator /= (const int128 & b) throw () {
+ int128 dummy;
+ *this = this->div (b, dummy);
+ return *this;
+ };
+ inline int128 & operator %= (const int128 & b) throw () {
+ this->div (b, *this);
+ return *this;
+ };
+
+ // Common methods
+ int toInt () const throw () { return (int) this->lo; };
+ int64s toInt64 () const throw () { return (int64s) this->lo; };
+
+ const char * toString (unsigned int radix = 10) const throw ();
+ float toFloat () const throw ();
+ double toDouble () const throw ();
+ long double toLongDouble () const throw ();
+
+ // Arithmetic methods
+ int128 div (const int128 &, int128 &) const throw ();
+
+ // Bit operations
+ bool bit (unsigned int n) const throw ();
+ void bit (unsigned int n, bool val) throw ();
+}
+#ifdef __GNUC__
+ __attribute__ ((__aligned__ (16), __packed__))
+#endif
+;
+
+
+// GLOBAL OPERATORS
+
+bool operator < (const int128 & a, const int128 & b) throw ();
+bool operator == (const int128 & a, const int128 & b) throw ();
+bool operator || (const int128 & a, const int128 & b) throw ();
+bool operator && (const int128 & a, const int128 & b) throw ();
+
+// GLOBAL OPERATOR INLINES
+
+inline int128 operator + (const int128 & a, const int128 & b) throw () {
+ return int128 (a) += b; };
+inline int128 operator - (const int128 & a, const int128 & b) throw () {
+ return int128 (a) -= b; };
+inline int128 operator * (const int128 & a, const int128 & b) throw () {
+ return int128 (a) *= b; };
+inline int128 operator / (const int128 & a, const int128 & b) throw () {
+ return int128 (a) /= b; };
+inline int128 operator % (const int128 & a, const int128 & b) throw () {
+ return int128 (a) %= b; };
+
+inline int128 operator >> (const int128 & a, unsigned int n) throw () {
+ return int128 (a) >>= n; };
+inline int128 operator << (const int128 & a, unsigned int n) throw () {
+ return int128 (a) <<= n; };
+
+inline int128 operator & (const int128 & a, const int128 & b) throw () {
+ return int128 (a) &= b; };
+inline int128 operator | (const int128 & a, const int128 & b) throw () {
+ return int128 (a) |= b; };
+inline int128 operator ^ (const int128 & a, const int128 & b) throw () {
+ return int128 (a) ^= b; };
+
+inline bool operator > (const int128 & a, const int128 & b) throw () {
+ return b < a; };
+inline bool operator <= (const int128 & a, const int128 & b) throw () {
+ return !(b < a); };
+inline bool operator >= (const int128 & a, const int128 & b) throw () {
+ return !(a < b); };
+inline bool operator != (const int128 & a, const int128 & b) throw () {
+ return !(a == b); };
+
+
+// MISC
+
+//typedef int128 __int128;
+
+typedef int128 int128s;
+} //NameSpace
+
+#endif
diff --git a/src/thirdparty/ZenLib/ZenLib/int128u.cpp b/src/thirdparty/ZenLib/ZenLib/int128u.cpp
new file mode 100644
index 000000000..65832abf6
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/int128u.cpp
@@ -0,0 +1,403 @@
+// int128u - integer 8 bytes
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// based on http://Tringi.Mx-3.cz
+// Only adapted for ZenLib:
+// - uint128.hpp --> int128u.h
+// - Namespace
+// - int128u alias
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+#include "ZenLib/PreComp.h"
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "ZenLib/Conf_Internal.h"
+//---------------------------------------------------------------------------
+
+#include "int128u.h"
+
+/*
+ Name: uint128.cpp
+ Copyright: Copyright (C) 2005, Jan Ringos
+ Author: Jan Ringos, http://Tringi.Mx-3.cz
+
+ Version: 1.1
+*/
+
+#include <memory>
+#include <cmath>
+#include <cstring>
+#if defined (__BORLANDC__) || defined (__SUNPRO_CC)
+ #define fmodf fmod
+#endif
+#if defined (__NO_LONG_DOUBLE_MATH) || \
+ defined (__MONTAVISTA__) || defined (__ARMEL__) || \
+ defined (__FreeBSD__) || defined (__OpenBSD__) || \
+ defined (__NetBSD__) || defined (__DragonFly__) || \
+ defined (__sparc__) || defined (__sparc64__) || \
+ defined (__SUNPRO_CC)
+ #define fmodl fmod
+#endif
+using namespace std;
+
+namespace ZenLib
+{
+
+// IMPLEMENTATION
+
+const char * uint128::toString (unsigned int radix) const throw () {
+ if (!*this) return "0";
+ if (radix < 2 || radix > 37) return "(invalid radix)";
+
+ static char sz [256];
+ memset (sz, 0, 256);
+
+ uint128 r;
+ uint128 ii = *this;
+ int i = 255;
+
+ while (!!ii && i) {
+ ii = ii.div (radix, r);
+ sz [--i] = (char) (r.toUint () + ((r.toUint () > 9) ? 'A' - 10 : '0'));
+ };
+
+ return &sz [i];
+};
+
+uint128::uint128 (const char * sz) throw ()
+ : lo (0u), hi (0u) {
+
+ if (!sz) return;
+ if (!sz [0]) return;
+
+ unsigned int radix = 10;
+ unsigned int i = 0;
+ bool minus = false;
+
+ if (sz [i] == '-') {
+ ++i;
+ minus = true;
+ };
+
+ if (sz [i] == '0') {
+ radix = 8;
+ ++i;
+ if (sz [i] == 'x') {
+ radix = 16;
+ ++i;
+ };
+ };
+
+ for (; i < strlen (sz); ++i) {
+ unsigned int n = 0;
+ if (sz [i] >= '0' && sz [i] <= (('0' + (int) radix) < '9'?('0' + (int) radix):'9')) //if (sz [i] >= '0' && sz [i] <= (('0' + (int) radix) <? '9'))
+ n = sz [i] - '0';
+ else if (sz [i] >= 'a' && sz [i] <= 'a' + (int) radix - 10)
+ n = sz [i] - 'a' + 10;
+ else if (sz [i] >= 'A' && sz [i] <= 'A' + (int) radix - 10)
+ n = sz [i] - 'A' + 10;
+ else
+ break;
+
+ (*this) *= radix;
+ (*this) += n;
+ };
+
+ if (minus)
+ *this = 0u - *this;
+
+ return;
+};
+
+uint128::uint128 (const float a) throw ()
+ #if defined (__mips__) || defined (__mipsel__)
+ : lo ((int64u) fmod ((const double)a, 18446744073709551616.0)),
+ #else
+ : lo ((int64u) fmodf (a, 18446744073709551616.0f)),
+ #endif
+ hi ((int64u) (a / 18446744073709551616.0f)) {};
+
+uint128::uint128 (const double & a) throw ()
+ : lo ((int64u) fmod (a, 18446744073709551616.0)),
+ hi ((int64u) (a / 18446744073709551616.0)) {};
+
+uint128::uint128 (const long double & a) throw ()
+ #if defined (__mips__) || defined (__mipsel__)
+ : lo ((int64u) fmod ((const double)a, 18446744073709551616.0)),
+ #else
+ : lo ((int64u) fmodl (a, 18446744073709551616.0l)),
+ #endif
+ hi ((int64u) (a / 18446744073709551616.0l)) {};
+
+float uint128::toFloat () const throw () {
+ return (float) this->hi * 18446744073709551616.0f
+ + (float) this->lo;
+};
+
+double uint128::toDouble () const throw () {
+ return (double) this->hi * 18446744073709551616.0
+ + (double) this->lo;
+};
+
+long double uint128::toLongDouble () const throw () {
+ return (long double) this->hi * 18446744073709551616.0l
+ + (long double) this->lo;
+};
+
+uint128 uint128::operator - () const throw () {
+ if (!this->hi && !this->lo)
+ // number is 0, just return 0
+ return *this;
+ else
+ // non 0 number
+ return uint128 (0-this->lo, ~this->hi);
+};
+
+uint128 uint128::operator ~ () const throw () {
+ return uint128 (~this->lo, ~this->hi);
+};
+
+uint128 & uint128::operator ++ () {
+ ++this->lo;
+ if (!this->lo)
+ ++this->hi;
+
+ return *this;
+};
+
+uint128 & uint128::operator -- () {
+ if (!this->lo)
+ --this->hi;
+ --this->lo;
+
+ return *this;
+};
+
+uint128 uint128::operator ++ (int) {
+ uint128 b = *this;
+ ++ *this;
+
+ return b;
+};
+
+uint128 uint128::operator -- (int) {
+ uint128 b = *this;
+ -- *this;
+
+ return b;
+};
+
+uint128 & uint128::operator += (const uint128 & b) throw () {
+ int64u old_lo = this->lo;
+
+ this->lo += b.lo;
+ this->hi += b.hi + (this->lo < old_lo);
+
+ return *this;
+};
+
+uint128 & uint128::operator *= (const uint128 & b) throw () {
+ if (!b)
+ return *this = 0u;
+ if (b == 1u)
+ return *this;
+
+ uint128 a = *this;
+ uint128 t = b;
+
+ this->lo = 0ull;
+ this->hi = 0ull;
+
+ for (unsigned int i = 0; i < 128; ++i) {
+ if (t.lo & 1)
+ *this += a << i;
+
+ t >>= 1;
+ };
+
+ return *this;
+};
+
+
+uint128 uint128::div (const uint128 & ds, uint128 & remainder) const throw () {
+ if (!ds)
+ return 1u / (unsigned int) ds.lo;
+
+ uint128 dd = *this;
+
+ // only remainder
+ if (ds > dd) {
+ remainder = *this;
+ return 0ull;
+ };
+
+ uint128 r = 0ull;
+ uint128 q = 0ull;
+// while (dd >= ds) { dd -= ds; q += 1; }; // extreme slow version
+
+ unsigned int b = 127;
+ while (r < ds) {
+ r <<= 1;
+ if (dd.bit (b--))
+ r.lo |= 1;
+ };
+ ++b;
+
+ for (;;)
+ if (r < ds) {
+ if (!(b--)) break;
+
+ r <<= 1;
+ if (dd.bit (b))
+ r.lo |= 1;
+
+ } else {
+ r -= ds;
+ q.bit (b, true);
+ };
+
+ remainder = r;
+ return q;
+};
+
+bool uint128::bit (unsigned int n) const throw () {
+ n &= 0x7F;
+
+ if (n < 64)
+ return (this->lo & (1ull << n))?true:false;
+ else
+ return (this->hi & (1ull << (n - 64)))?true:false;
+};
+
+void uint128::bit (unsigned int n, bool val) throw () {
+ n &= 0x7F;
+
+ if (val) {
+ if (n < 64) this->lo |= (1ull << n);
+ else this->hi |= (1ull << (n - 64));
+ } else {
+ if (n < 64) this->lo &= ~(1ull << n);
+ else this->hi &= ~(1ull << (n - 64));
+ };
+};
+
+
+uint128 & uint128::operator >>= (unsigned int n) throw () {
+ n &= 0x7F;
+
+ if (n > 63) {
+ n -= 64;
+ this->lo = this->hi;
+ this->hi = 0ull;
+ };
+
+ if (n) {
+ // shift low qword
+ this->lo >>= n;
+
+ // get lower N bits of high qword
+ int64u mask = 0ull;
+ for (unsigned int i = 0; i < n; ++i) mask |= (1ull << i);
+
+ // and add them to low qword
+ this->lo |= (this->hi & mask) << (64 - n);
+
+ // and finally shift also high qword
+ this->hi >>= n;
+ };
+
+ return *this;
+};
+
+uint128 & uint128::operator <<= (unsigned int n) throw () {
+ n &= 0x7F;
+
+ if (n > 63) {
+ n -= 64;
+ this->hi = this->lo;
+ this->lo = 0ull;
+ };
+
+ if (n) {
+ // shift high qword
+ this->hi <<= n;
+
+ // get higher N bits of low qword
+ int64u mask = 0ull;
+ for (unsigned int i = 0; i < n; ++i) mask |= (1ull << (63 - i));
+
+ // and add them to high qword
+ this->hi |= (this->lo & mask) >> (64 - n);
+
+ // and finally shift also low qword
+ this->lo <<= n;
+ };
+
+ return *this;
+};
+
+bool uint128::operator ! () const throw () {
+ return !(this->hi || this->lo);
+};
+
+uint128 & uint128::operator |= (const uint128 & b) throw () {
+ this->hi |= b.hi;
+ this->lo |= b.lo;
+
+ return *this;
+};
+
+uint128 & uint128::operator &= (const uint128 & b) throw () {
+ this->hi &= b.hi;
+ this->lo &= b.lo;
+
+ return *this;
+};
+
+uint128 & uint128::operator ^= (const uint128 & b) throw () {
+ this->hi ^= b.hi;
+ this->lo ^= b.lo;
+
+ return *this;
+};
+
+bool operator < (const uint128 & a, const uint128 & b) throw () {
+ return (a.hi == b.hi) ? (a.lo < b.lo) : (a.hi < b.hi);
+};
+
+bool operator == (const uint128 & a, const uint128 & b) throw () {
+ return a.hi == b.hi && a.lo == b.lo;
+};
+bool operator && (const uint128 & a, const uint128 & b) throw () {
+ return (a.hi || a.lo) && (b.hi || b.lo);
+};
+bool operator || (const uint128 & a, const uint128 & b) throw () {
+ return (a.hi || a.lo) || (b.hi || b.lo);
+};
+
+} //NameSpace
diff --git a/src/thirdparty/ZenLib/ZenLib/int128u.h b/src/thirdparty/ZenLib/ZenLib/int128u.h
new file mode 100644
index 000000000..5636472ef
--- /dev/null
+++ b/src/thirdparty/ZenLib/ZenLib/int128u.h
@@ -0,0 +1,201 @@
+// int128u - integer 8 bytes
+// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// based on http://Tringi.Mx-3.cz
+// Only adapted for ZenLib:
+// - .hpp --> .h
+// - Namespace
+// - int128u alias
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+#ifndef UINT128_HPP
+#define UINT128_HPP
+
+/*
+ Name: uint128.hpp
+ Copyright: Copyright (C) 2005, Jan Ringos
+ Author: Jan Ringos, http://Tringi.Mx-3.cz
+
+ Version: 1.1
+*/
+
+
+#include <exception>
+#include <cstdlib>
+#include <cstdio>
+#include <new>
+#include "ZenLib/Conf.h"
+
+// CLASS
+
+namespace ZenLib
+{
+
+class uint128 {
+ public://private:
+ // Binary correct representation of signed 128bit integer
+ int64u lo;
+ int64u hi;
+
+ protected:
+ // Some global operator functions must be friends
+ friend bool operator < (const uint128 &, const uint128 &) throw ();
+ friend bool operator == (const uint128 &, const uint128 &) throw ();
+ friend bool operator || (const uint128 &, const uint128 &) throw ();
+ friend bool operator && (const uint128 &, const uint128 &) throw ();
+
+ public:
+ // Constructors
+ inline uint128 () throw () {};
+ inline uint128 (const uint128 & a) throw () : lo (a.lo), hi (a.hi) {};
+
+ inline uint128 (const int & a) throw () : lo (a), hi (0ull) {};
+ inline uint128 (const unsigned int & a) throw () : lo (a), hi (0ull) {};
+ inline uint128 (const int64u & a) throw () : lo (a), hi (0ull) {};
+
+ uint128 (const float a) throw ();
+ uint128 (const double & a) throw ();
+ uint128 (const long double & a) throw ();
+
+ uint128 (const char * sz) throw ();
+
+ // TODO: Consider creation of operator= to eliminate
+ // the need of intermediate objects during assignments.
+
+ private:
+ // Special internal constructors
+ uint128 (const int64u & a, const int64u & b) throw ()
+ : lo (a), hi (b) {};
+
+ public:
+ // Operators
+ bool operator ! () const throw ();
+
+ uint128 operator - () const throw ();
+ uint128 operator ~ () const throw ();
+
+ uint128 & operator ++ ();
+ uint128 & operator -- ();
+ uint128 operator ++ (int);
+ uint128 operator -- (int);
+
+ uint128 & operator += (const uint128 & b) throw ();
+ uint128 & operator *= (const uint128 & b) throw ();
+
+ uint128 & operator >>= (unsigned int n) throw ();
+ uint128 & operator <<= (unsigned int n) throw ();
+
+ uint128 & operator |= (const uint128 & b) throw ();
+ uint128 & operator &= (const uint128 & b) throw ();
+ uint128 & operator ^= (const uint128 & b) throw ();
+
+ // Inline simple operators
+ inline const uint128 & operator + () const throw () { return *this; };
+
+ // Rest of inline operators
+ inline uint128 & operator -= (const uint128 & b) throw () {
+ return *this += (-b);
+ };
+ inline uint128 & operator /= (const uint128 & b) throw () {
+ uint128 dummy;
+ *this = this->div (b, dummy);
+ return *this;
+ };
+ inline uint128 & operator %= (const uint128 & b) throw () {
+ this->div (b, *this);
+ return *this;
+ };
+
+ // Common methods
+ unsigned int toUint () const throw () {
+ return (unsigned int) this->lo; };
+ int64u toUint64 () const throw () {
+ return (int64u) this->lo; };
+ const char * toString (unsigned int radix = 10) const throw ();
+ float toFloat () const throw ();
+ double toDouble () const throw ();
+ long double toLongDouble () const throw ();
+
+ // Arithmetic methods
+ uint128 div (const uint128 &, uint128 &) const throw ();
+
+ // Bit operations
+ bool bit (unsigned int n) const throw ();
+ void bit (unsigned int n, bool val) throw ();
+}
+#ifdef __GNUC__
+ __attribute__ ((__aligned__ (16), __packed__))
+#endif
+;
+
+
+// GLOBAL OPERATORS
+
+bool operator < (const uint128 & a, const uint128 & b) throw ();
+bool operator == (const uint128 & a, const uint128 & b) throw ();
+bool operator || (const uint128 & a, const uint128 & b) throw ();
+bool operator && (const uint128 & a, const uint128 & b) throw ();
+
+// GLOBAL OPERATOR INLINES
+
+inline uint128 operator + (const uint128 & a, const uint128 & b) throw () {
+ return uint128 (a) += b; };
+inline uint128 operator - (const uint128 & a, const uint128 & b) throw () {
+ return uint128 (a) -= b; };
+inline uint128 operator * (const uint128 & a, const uint128 & b) throw () {
+ return uint128 (a) *= b; };
+inline uint128 operator / (const uint128 & a, const uint128 & b) throw () {
+ return uint128 (a) /= b; };
+inline uint128 operator % (const uint128 & a, const uint128 & b) throw () {
+ return uint128 (a) %= b; };
+
+inline uint128 operator >> (const uint128 & a, unsigned int n) throw () {
+ return uint128 (a) >>= n; };
+inline uint128 operator << (const uint128 & a, unsigned int n) throw () {
+ return uint128 (a) <<= n; };
+
+inline uint128 operator & (const uint128 & a, const uint128 & b) throw () {
+ return uint128 (a) &= b; };
+inline uint128 operator | (const uint128 & a, const uint128 & b) throw () {
+ return uint128 (a) |= b; };
+inline uint128 operator ^ (const uint128 & a, const uint128 & b) throw () {
+ return uint128 (a) ^= b; };
+
+inline bool operator > (const uint128 & a, const uint128 & b) throw () {
+ return b < a; };
+inline bool operator <= (const uint128 & a, const uint128 & b) throw () {
+ return !(b < a); };
+inline bool operator >= (const uint128 & a, const uint128 & b) throw () {
+ return !(a < b); };
+inline bool operator != (const uint128 & a, const uint128 & b) throw () {
+ return !(a == b); };
+
+
+// MISC
+
+typedef uint128 __uint128;
+
+typedef uint128 int128u;
+} //NameSpace
+
+#endif